CK3dEntity* findSimilarInSourceObject(CK3dEntity *parentOriginal,CK3dEntity* partentCopied,CK3dEntity *copiedObject,CK3dEntity*prev) { if (!parentOriginal || !copiedObject ) return NULL; if (parentOriginal->GetChildrenCount() < 1) return NULL; if ( prev && prev!=copiedObject && isChildOf(parentOriginal,prev) && !isChildOf(partentCopied,prev) ) return prev; CK3dEntity *orginalObject= (CK3dEntity*)ctx()->GetObjectByNameAndClass(copiedObject->GetName(),CKCID_3DOBJECT,prev); if (orginalObject) { //---------------------------------------------------------------- // // tests // if ( orginalObject==copiedObject ) findSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject); if ( !isChildOf(parentOriginal,orginalObject)) findSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject); if( isChildOf(partentCopied,orginalObject) ) findSimilarInSourceObject(parentOriginal,partentCopied,copiedObject,orginalObject); return orginalObject; } return NULL; }
bool Node::addChild(Node& child) { if (isChildOf(child)) return false; child.removeFromParent(); m_children.push_back(&child); child.m_parent = this; child.setGraph(m_graph); child.invalidateWorldTransform(); invalidateBounds(); return true; }
static bool isChildOf( QWidget* child, QWidget *parent ) { const QObjectList *list = parent->children(); if ( !child || !list ) return FALSE; QObjectListIt it(*list); QObject *obj; while ( (obj = it.current()) ) { ++it; if ( !obj->isWidgetType() || ((QWidget *)obj)->isTopLevel() ) continue; QWidget *widget = (QWidget *)obj; if ( widget == child || isChildOf( child, widget ) ) return TRUE; } return FALSE; }
bool PathName::makeRelativeTo(const PathName& root) { mDebugAssert(root.getPath() != NULL); mDebugAssert(mRelativePath != NULL); if (!isChildOf(root)) { return false; } mRelativePath = mRelativePath + root.getPathLength(); if (*mRelativePath != '\0') { // Move beyond path separator mRelativePath++; } return true; }
bool ClassId::isEqualOrChildOf( int classId ) const { return (m_id == classId) || isChildOf( classId ); }
GPMultiLayerTree::GPMultiLayerTree(const GPFunctionTree* tree) { auto _root = tree->root(); /*Find Origin Inputs*/ int maxInputNumber = -1; if (GPFunctionTreePoint::OUTPUT != _root->type()) { GPPtr<GPFunctionTreePoint> root = GPFunctionTree::copy(tree->root()); mLayers.insert(std::make_pair(-1, root)); maxInputNumber = root->maxInputPos(); } else { for (int i=0; i<_root->getChildrenNumber(); ++i) { GPPtr<GPFunctionTreePoint> subRoot = GPFunctionTree::copy(GPCONVERT(const GPFunctionTreePoint, _root->getChild(i))); int _maxI = subRoot->maxInputPos(); if (_maxI > maxInputNumber) { maxInputNumber = _maxI; } mLayers.insert(std::make_pair(-i-1, subRoot)); } } int subtree_inputpos = maxInputNumber+1; std::vector<GPFunctionTreePoint*> workLists; while (true) { /*Generate Next workLists*/ workLists.clear(); for (auto iter :mLayers) { auto childrens = iter.second->display(); for (auto p : childrens) { auto pp = GPCONVERT(const GPFunctionTreePoint, p); if (GPFunctionTreePoint::FUNCTION == pp->type()) { workLists.push_back((GPFunctionTreePoint*)pp); } } } /*Find same subtree*/ std::map<GPFunctionTreePoint*, std::vector<GPFunctionTreePoint*>> equallist; for (size_t i=0; i<workLists.size(); ++i) { auto forcompare = workLists[i]; bool valid = true; for (auto iter : equallist) { if (forcompare->isChildOf(iter.first)) { valid = false; } for (auto p : iter.second) { if (forcompare->isChildOf(p)) { valid = false; break; } } if (!valid) { break; } } if (!valid) { continue; } std::vector<GPFunctionTreePoint*> equalpairs; for (size_t j=i+1; j<workLists.size(); ++j) { if (workLists[j]->equal(forcompare)) { equalpairs.push_back(workLists[j]); } } /*Valid Point, Added to equallist*/ if (!equalpairs.empty()) { std::map<GPFunctionTreePoint*, std::vector<GPFunctionTreePoint*>> filtered_equallist; for (auto iter : equallist) { bool valid = true; if (iter.first->isChildOf(forcompare)) { continue; } for (auto p : iter.second) { if (p->isChildOf(forcompare)) { valid = false; break; } } if (valid) { filtered_equallist.insert(std::make_pair(iter.first, iter.second)); } } equallist = filtered_equallist; equallist.insert(std::make_pair(forcompare, equalpairs)); } } /*Generate New Points*/ for (auto iter : equallist) { GPFunctionTreePoint* inputpoints = NULL; int inputCur = -1; /*Find iter.first in previous layer*/ for (auto l : mLayers) { if (iter.first->equal(l.second.get())) { inputpoints = new GPFunctionTreePoint(GPFunctionTreePoint::INPUT, l.first); inputCur = l.first; break; } } /*Not find exists tree, create a new one*/ if (NULL == inputpoints) { /*replace will decRef the iter.first, addRef to avoid free*/ iter.first->addRef(); inputpoints = new GPFunctionTreePoint(GPFunctionTreePoint::INPUT, subtree_inputpos); GPPtr<GPFunctionTreePoint> match = (GPFunctionTreePoint*)iter.first; mLayers.insert(std::make_pair(subtree_inputpos, match)); inputCur = subtree_inputpos; subtree_inputpos++; } for (auto root_iter : mLayers) { if (root_iter.first!=inputCur) { root_iter.second->replace((GPFunctionTreePoint*)iter.first, inputpoints); for (auto p : iter.second) { root_iter.second->replace((GPFunctionTreePoint*)p, inputpoints); } } } inputpoints->decRef(); } if (equallist.empty()) { break; } } }
void QWidgetStack::raiseWidget( QWidget *w ) { if ( !w || w == invisible || w->parent() != this || w == topWidget ) return; if ( id(w) == -1 ) addWidget( w ); if ( !isVisible() ) { topWidget = w; return; } if (w->maximumSize().width() < invisible->width() || w->maximumSize().height() < invisible->height()) invisible->setBackgroundMode(backgroundMode()); else if (invisible->backgroundMode() != NoBackground) invisible->setBackgroundMode(NoBackground); if ( invisible->isHidden() ) { invisible->setGeometry( contentsRect() ); invisible->lower(); invisible->show(); QApplication::sendPostedEvents( invisible, QEvent::ShowWindowRequest ); } // try to move focus onto the incoming widget if focus // was somewhere on the outgoing widget. if ( topWidget ) { QWidget * fw = focusWidget(); QWidget* p = fw; while ( p && p != topWidget ) p = p->parentWidget(); if ( p == topWidget ) { // focus was on old page if ( !focusWidgets ) focusWidgets = new QPtrDict<QWidget>( 17 ); focusWidgets->replace( topWidget, fw ); fw->clearFocus(); // look for the best focus widget we can find // best == what we had (which may be deleted) fw = focusWidgets->take( w ); if ( isChildOf( fw, w ) ) { fw->setFocus(); } else { // second best == first child widget in the focus chain QFocusData *f = focusData(); QWidget* home = f->home(); QWidget *i = home; do { if ( ( ( i->focusPolicy() & TabFocus ) == TabFocus ) && !i->focusProxy() && i->isVisibleTo(w) && i->isEnabled() ) { p = i; while ( p && p != w ) p = p->parentWidget(); if ( p == w ) { i->setFocus(); break; } } i = f->next(); } while( i != home ); } } } if ( isVisible() ) { emit aboutToShow( w ); int i = id( w ); if ( i != -1 ) emit aboutToShow( i ); } topWidget = w; const QObjectList * c = children(); QObjectListIt it( *c ); QObject * o; while( (o=it.current()) != 0 ) { ++it; if ( o->isWidgetType() && o != w && o != invisible ) ((QWidget *)o)->hide(); } w->setGeometry( invisible->geometry() ); w->show(); }