MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / findFrontRootOfType

Method findFrontRootOfType

src/Gui/ViewProviderDocumentObject.cpp:510–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

508}
509
510SoNode* ViewProviderDocumentObject::findFrontRootOfType(const SoType& type) const
511{
512 if (!pcObject) {
513 return nullptr;
514 }
515 // first get the document this object is part of and get its GUI counterpart
516 App::Document* pAppDoc = pcObject->getDocument();
517 Gui::Document* pGuiDoc = Gui::Application::Instance->getDocument(pAppDoc);
518
519 SoSearchAction searchAction;
520 searchAction.setType(type);
521 searchAction.setInterest(SoSearchAction::FIRST);
522
523 // search in all view providers for the node type
524 std::vector<App::DocumentObject*> obj = pAppDoc->getObjects();
525 for (auto& it : obj) {
526 const ViewProvider* vp = pGuiDoc->getViewProvider(it);
527 // Ignore 'this' view provider. It could also happen that vp is 0, e.g. when
528 // several objects have been added to the App::Document before notifying the
529 // Gui::Document
530 if (!vp || vp == this) {
531 continue;
532 }
533 SoSeparator* front = vp->getFrontRoot();
534 // if (front && front->getTypeId() == type)
535 // return front;
536 if (front) {
537 searchAction.apply(front);
538 SoPath* path = searchAction.getPath();
539 if (path) {
540 return path->getTail();
541 }
542 }
543 }
544
545 return nullptr;
546}
547
548void ViewProviderDocumentObject::setActiveMode()
549{

Callers

nothing calls this directly

Calls 7

getDocumentMethod · 0.45
setTypeMethod · 0.45
getObjectsMethod · 0.45
getViewProviderMethod · 0.45
getFrontRootMethod · 0.45
applyMethod · 0.45
getPathMethod · 0.45

Tested by

no test coverage detected