本文整理汇总了C++中DBbox类的典型用法代码示例。如果您正苦于以下问题:C++ DBbox类的具体用法?C++ DBbox怎么用?C++ DBbox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBbox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DBbox
void trend::TrendBase::wirem(int4b* pdata, unsigned psize, WireWidth width, const SGBitSet* psel)
{
// first check whether to draw only the center line
DBbox wsquare = DBbox(TP(0,0),TP(width,width));
bool center_line_only = !wsquare.visible(topCTM() * scrCTM(), visualLimit());
_clayer->wire(pdata, psize, width, center_line_only,psel,*_rmm);
}
示例2: fitinsubtree
/*! Build a new quadTree structure for the tdtdata in the inlist. The method is
using the existing _overlap variable. For every layout shape fitinsubtree()
method is called in a try to put the data in the child quadTree. At the end
the method is called for every of the child structures.
*/
void laydata::quadTree::sort(dataList& inlist)
{
// if the input list is empty - nothing to do!
if (0 == inlist.size()) return;
dataList::iterator DI = inlist.begin();
// if the list contains only one component - link it and run away
if (1 == inlist.size())
{
DI->first->nextis(NULL); _first = DI->first;
return;
}
byte i;
// the overlapping box of the currnet shape
// DBbox shovl(TP(0,0));
DBbox shovl = DEFAULT_OVL_BOX;
// the maximum possible overlapping boxes of the 4 children
DBbox maxsubbox[4] = {DEFAULT_OVL_BOX, DEFAULT_OVL_BOX,
DEFAULT_OVL_BOX, DEFAULT_OVL_BOX};
for (i = 0; i < 4; i++) maxsubbox[i] = _overlap.getcorner(i);
// the sub-lists data will be sorted in
dataList sublist[4];
// which is the child where current shape fits
int fitinsubbox;
// initialize the iterator
float sharea, totalarea = _overlap.area();
while (inlist.end() != DI)
{
// get the overlap of the current shape
shovl = DI->first->overlap();shovl.normalize();
sharea = shovl.area();
// Check it fits in some of the children
if (totalarea <= 4 * sharea ||
(-1 == (fitinsubbox = fitsubtree(shovl, maxsubbox))))
{
// no fit. The shape is sorted in the current tree
DI->first->nextis(_first); _first = DI->first;
}
else
{
// fits in sub-tree fitinsubbox
sublist[fitinsubbox].push_back(*DI);
// check this child already exists
if (_quads[fitinsubbox]) // yes ?
_quads[fitinsubbox]->_overlap.overlap(shovl);
else
{
// create the child, initialize the overlapping box
_quads[fitinsubbox] = DEBUG_NEW quadTree();
_quads[fitinsubbox]->_overlap = shovl;
}
}
// in all cases get rid of the current shape pointer. It is already sorted
DI = inlist.erase(DI);
}
// at this point inlist MUST be empty - split over max 4+this quadTrees
// now go and sort the children - if any
for(i = 0; i < 4; i++)
if (_quads[i]) _quads[i]->sort(sublist[i]);
}
示例3: add
/*! Checks whether a single layout object shape will fit into one of the
childrens quadTree. It calls add() and returns success if the new layout object
fits entirely into one of the possible subtrees or if it blows up its
overlaping area not more than 10%. Returns false if the shape does not fit
anywhere - means it should be placed higher into the quadTree structure.\n
The method might be called recursively via the add() method.
*/
bool laydata::quadTree::fitintree(tdtdata* shape) {
DBbox shovl = shape->overlap();
float clipedarea[4];
// check the clipping to see in witch region to place the shape
for (byte i = 0; i < 4 ; i++) {
DBbox subbox = _overlap.getcorner(i);
clipedarea[i] = subbox.cliparea(shovl,true);
if (-1 == clipedarea[i]) {//entirely inside the area
if (!_quads[i]) _quads[i] = DEBUG_NEW quadTree();
_quads[i]->add(shape);
return true;
}
}
// if we got to this point - means that the shape does not fit
// entirely inside neither of the four sub-areas.
// It is a decision time then
byte candidate = biggest(clipedarea);
// now calculate the eventual new overlaping box
DBbox newovl = _overlap.getcorner(candidate);
newovl.overlap(shovl);
// if the max area of the candidate does not blow more than 10% -
// then seems to be OK to get it
if (newovl.area() < 1.1 * (_overlap.area() / 4)) {
if (!_quads[candidate]) _quads[candidate] = DEBUG_NEW quadTree();
_quads[candidate]->add(shape);
return true;
}
return false; // shape can not be fit into any subtree
}
示例4: while
/*!*/
laydata::tdtdata* laydata::quadTree::merge_selected(tdtdata*& shapeRef) {
laydata::tdtdata* mergeres = NULL;
DBbox overlapRef = shapeRef->overlap();
// check the entire holder for clipping...
if (overlapRef.cliparea(_overlap) == 0) return NULL;
// now start traversing the shapes in the current horlder one by one
tdtdata* wdt = _first;
while(wdt) {
// for fully selected shapes if they overlap with the reference
// and this is not the same shape as the reference
if ((wdt != shapeRef) &&
((sh_selected == wdt->status()) || (sh_merged == wdt->status())) &&
(overlapRef.cliparea(wdt->overlap()) != 0)) {
// go and merge it
mergeres = polymerge(wdt->shape2poly(), shapeRef->shape2poly());
if (NULL != mergeres) {
// If the merge produce a result - return the result and
// substitute the shapeRef with its merged counterpart
shapeRef = wdt;
return mergeres;
}
}
wdt = wdt->next();
}
// if we've got to this point - means that no more shapes to merge
// in this area
for(byte i = 0; i < 4; i++)
if (_quads[i]) {
mergeres = _quads[i]->merge_selected(shapeRef);
if (NULL != mergeres) return mergeres;
}
//at this point there is nothing more to traverse, so return NULL
return NULL;
}
示例5: be
/*! Add a single layout object shape into the quadTree.
It first checks whether or not another layout object is already placed into this
quadTree. If not it simply links the shape and exits. If another object is already
here, then the new overlap area is calculated. \n In case the new area is the same as
the existing one, then the object might be (possibly) fited into one of the childrens
quadTree. To check this fitintree() method is called. If this is unsuccessfull, just
then the layout object is linked to this quadTree. \n If the new overlapping area is
bigger that the existing one, then the layout object is linked to the current quadTree
after what the current quadTree as well as its successors has to be rebuild using
resort().\n The method might be called recursively via fitintree() method.
*/
void laydata::quadTree::add(tdtdata* shape) {
DBbox shovl = shape->overlap();shovl.normalize();
if (empty()) {
// first shape in the container
_overlap = shovl;
_first = shape;shape->nextis(NULL);
}
else {
// save the old overlap
DBbox oldovl = _overlap;
// calculate the new container overlap
_overlap.overlap(shovl);
float areaold = oldovl.area();
float areanew = _overlap.area();
// The equation below produce problems with severe consequences.
// It seems to be because of the type of the conversion
// if (oldovl.area() == _overlap->area()) {
if (areaold == areanew) {
// if the overlapping box hasn't changed,
// try to fit the shape into subtree
if ((areanew <= 4 * shovl.area()) || !fitintree(shape)) {
// shape doesn't fit into the subtree, so place it here
shape->nextis(_first); _first = shape;
}
}
else { // the overlapping box has had blown-up
shape->nextis(_first); _first = shape;
resort(); // re-sort the entire tree
}
}
}
示例6: DBline
void trend::TrendBase::genRulerMarks(const CTM& LayCTM, DBline& long_mark, DBline& short_mark, DBline& text_bp, double& scaledpix)
{
// Side ticks (segments) of the rulers has to be with constant size. The next
// lines are generating a segment with the size 7/3 screen pixels centred in
// the {0,0} point of the canvas (logical coordinates)
// The coefficients 1e3/1e-3 are picked arbitrary in an attempt to reduce the
// error
const double ico = 1e3;
const double dco = 1/ico;
DBline tick_sample = DBline(TP(0,0),TP(0,7,ico)) * LayCTM;
double tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
long_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
tick_sample = DBline(TP(0,0),TP(0,3,ico)) * LayCTM;
tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
short_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
tick_sample = DBline(TP(0,0),TP(0,20,ico)) * LayCTM;
tick_size = ((double)(tick_sample.p1().y()-tick_sample.p2().y()));
text_bp = DBline(TP(0,0),TP(0,tick_size, dco));
// now prepare to draw the size
DBbox pixelbox = DBbox(TP(),TP(15,15)) * LayCTM;
scaledpix = ((double)(pixelbox.p2().x()-pixelbox.p1().x()));
}
示例7: DBline
void layprop::SupplementaryData::getConsts(const CTM& LayCTM, DBline& long_mark, DBline& short_mark, DBline& text_bp, double& scaledpix)
{
// Side ticks (segments) of the rulers has to be with constant size. The next lines
// are generating a segment with the size 7/3 screen pixels centered in
// the {0,0} point of the canvas (logical coords)
// the coeffitients 1e3/1e-3 are picked ramdomly attempting to reduce the
// error
const double ico = 1e3;
const double dco = 1/ico;
DBline tick_sample = DBline(TP(0,0),TP(0,7,ico)) * LayCTM;
double tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
long_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
tick_sample = DBline(TP(0,0),TP(0,3,ico)) * LayCTM;
tick_size = ((double)(tick_sample.p2().y()-tick_sample.p1().y()));
short_mark = DBline(TP(0,-tick_size, dco),TP(0,tick_size, dco));
tick_sample = DBline(TP(0,0),TP(0,20,ico)) * LayCTM;
tick_size = ((double)(tick_sample.p1().y()-tick_sample.p2().y()));
text_bp = DBline(TP(0,0),TP(0,tick_size, dco));
// now prepare to draw the size
DBbox pixelbox = DBbox(TP(),TP(15,15)) * LayCTM;
scaledpix = ((double)(pixelbox.p2().x()-pixelbox.p1().x()));
}
示例8: overlap
/*! A temporary Draw (during move/copy operations) of the container contents
on the screen using the virtual quadTree::tmp_draw() method of the
parent object. */
void laydata::tdtlayer::motion_draw(const layprop::DrawProperties& drawprop,
ctmqueue& transtack) const {
// check the entire layer for clipping...
DBbox clip = drawprop.clipRegion();
if (empty()) return;
DBbox areal = overlap().overlap(transtack.front());
if ( clip.cliparea(areal) == 0 ) return;
else if (!areal.visible(drawprop.ScrCTM())) return;
quadTree::motion_draw(drawprop, transtack);
}
示例9: move
/*! Removes marked shapes from the quadtree without deleting them. The removed
shapes are still listed in the _shapesel container of the current cell.
The new overlapping box is calculated during this process and the method
returns true to notify its parent that the overlapping box has changed and
resort has to be initiated on the upper levels of the tree. The tree is
processed bottom-up, i.e. the method is recursively called first for child
quadTree structures.\n
On the top level the method is called by two tdtcell methods:
delete_selected and move selected. The difference is that for delete,
partially selected shapes are ignored and not processed.\n
Fully selected shapes are always marked as sh_deleted. When move operation is
going on they will be re-marked afterwards to sh_selected by the move(copy)
virtual methods of tdtdata.
*/
bool laydata::quadTree::delete_marked(SH_STATUS stat, bool partselect) {
assert(!((stat != sh_selected) && (partselect == true)));
// Create and initialize a variable "to be sorted"
bool _2B_sorted = false;
// save the old overlap, and initialize the new one
DBbox oldovl = _overlap;
_overlap = DEFAULT_OVL_BOX;
// deleteing sequence is bottom-up, so start from the children
for (byte i = 0; i < 4; i++)
if (_quads[i]) {
_2B_sorted |= _quads[i]->delete_marked(stat, partselect);
// check that there is still something left in the child quadTree
if (_quads[i]->empty()) {
delete _quads[i]; _quads[i] = NULL;
}
else update_overlap(_quads[i]->overlap());
}
// prepare a pair of pointers to tdtdata
tdtdata* wds = _first;
tdtdata* wdsP = NULL;
// loop all tdtdata in the current tree and check they are selected
while (wds)
// if selected ...
if ((stat == wds->status()) ||
(partselect && (sh_partsel == wds->status()))) {
// mark the fully selected shapes as deleted
if (stat == wds->status()) wds->set_status(sh_deleted);
// Unlink the marked shape from the list
if (wdsP) { // if this is not the first shape
wdsP->nextis(wds->next()); wds->nextis(NULL);
wds = wdsP->next();
}
else { // Special attention when this is the first shape
_first = wds->next(); wds->nextis(NULL);
wds = _first;
}
}
// If not selected, or partially selected but partselect == false,
// update the overlapping box, and move further
else {
update_overlap(wds->overlap());
wdsP = wds; wds = wds->next();
}
// If _overlap is still NULL here -> means the placeholder is empty. Will
// be deleted by the parent
if (empty()) _invalid = true;
else {
//Now if the overlapping rectangles differ, then invalidate
//the current quadTree
float areaold = oldovl.area();
float areanew = _overlap.area();
if (areaold != areanew) _invalid = true;
}
return _2B_sorted |= _invalid;
}
示例10:
short laydata::quadTree::clip_type(tenderer::TopRend& rend) const
{
if (empty()) return 0;
// check the entire holder for clipping...
DBbox clip = rend.clipRegion();
DBbox areal = _overlap.overlap(rend.topCTM());
float clip_area = clip.cliparea(areal);
if ( ( 0.0 == clip_area ) || (!areal.visible(rend.ScrCTM())) ) return 0;
if (0.0 < clip_area) return 1;
else return -1;
}
示例11: assert
int tellstdfunc::stdGETOVERLAP::execute()
{
telldata::TtLayout* layObject = static_cast<telldata::TtLayout*>(OPstack.top());OPstack.pop();
assert(layObject);
real DBscale = PROPC->DBscale();
DBbox ovlBox = layObject->data()->overlap();
telldata::TtPnt p1DB(ovlBox.p1().x()/DBscale, ovlBox.p1().y()/DBscale );
telldata::TtPnt p2DB(ovlBox.p2().x()/DBscale, ovlBox.p2().y()/DBscale);
OPstack.push(DEBUG_NEW telldata::TtBox( p1DB, p2DB ));
delete layObject;
return EXEC_NEXT;
}
示例12: assert
bool laydata::DrawIterator<DataT>::secureNonEmptyDown()
{
assert(_drawprop);
DBbox clip = _drawprop->clipRegion();
DBbox areal = Iterator<DataT>::_cQuad->_overlap.overlap(_ctm);
if (0ll == clip.cliparea(areal) ) return false;
else if (!areal.visible(_drawprop->scrCtm(), _drawprop->visualLimit())) return false;
while (0 == Iterator<DataT>::_cQuad->_props._numObjects)
{
return this->nextSubQuad(0,Iterator<DataT>::_cQuad->_props.numSubQuads());
}
Iterator<DataT>::_cData = 0;
return true;
}
示例13: overlap
/*! A temporary Draw (during move/copy operations) of the container contents
on the screen using the virtual quadTree::tmp_draw() method of the
parent object. */
void laydata::tdtlayer::tmp_draw(const layprop::DrawProperties& drawprop,
ctmqueue& transtack) const {
// check the entire layer for clipping...
DBbox clip = drawprop.clipRegion();
if (empty()) return;
DBbox areal = overlap() * transtack.front();
areal.normalize();
if (clip.cliparea(areal) == 0) return;
else {
areal = areal * drawprop.ScrCTM();
if (areal.area() < MIN_VISUAL_AREA) return;
}
quadTree::tmp_draw(drawprop, transtack);
}
示例14: if
void trend::TrendBase::pushCell(std::string cname, const CTM& trans, const DBbox& overlap, bool active, bool selected)
{
TrxCellRef* cRefBox = DEBUG_NEW TrxCellRef(cname,
trans * _cellStack.top()->ctm(),
overlap,
_cellStack.size()
);
if (selected || (!_drawprop->cellBoxHidden()))
_refLayer->addCellOBox(cRefBox, _cellStack.size(), selected);
else
// This list is to keep track of the hidden cRefBox - so we can clean
// them up. Don't get confused - we need cRefBox during the collecting
// and drawing phase so we can't really delete them here or after they're
// poped-up from _cellStack. The confusion is coming from the "duality"
// of the TrxCellRef - once as a cell reference with CTM, view depth etc.
// and then as a placeholder of the overlapping reference box
_hiddenRefBoxes.push_back(cRefBox);
_cellStack.push(cRefBox);
if (active)
{
assert(NULL == _activeCS);
_activeCS = cRefBox;
}
else if (!_drawprop->cellMarksHidden())
{
_marks->addRefMark(overlap.p1(), _cellStack.top()->ctm());
}
}
示例15: if
/*! Temporary draw of the container contents on the screen using the virtual
tmp_draw methods of the tdtddata objects. This happens only if
the current quadTree object is visible. Current clip region data is
obtained from LayoutCanvas. In a sence this method is the same as openGL_draw
without fill and not handling selected shapes*/
void laydata::quadTree::motion_draw(const layprop::DrawProperties& drawprop,
ctmqueue& transtack) const {
if (empty()) return;
// check the entire holder for clipping...
DBbox clip = drawprop.clipRegion();
DBbox areal = _overlap.overlap(transtack.front());
if (clip.cliparea(areal) == 0 ) return;
else if (!areal.visible(drawprop.ScrCTM())) return;
tdtdata* wdt = _first;
while(wdt) {
wdt->motion_draw(drawprop, transtack, NULL);
wdt = wdt->next();
}
for(byte i = 0; i < 4; i++)
if (_quads[i]) _quads[i]->motion_draw(drawprop, transtack);
}