From 0f30096cec832a3a7a3f6f04dc36e18d4dfbd52b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tr=C3=B6ger?= Date: Tue, 26 May 2015 20:04:23 +0200 Subject: [PATCH] make new document views obey the scene graph children stacking --- src/Gui/ActiveObjectList.cpp | 14 +++++++------- src/Gui/Document.cpp | 26 +++++++++++++++++++------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/Gui/ActiveObjectList.cpp b/src/Gui/ActiveObjectList.cpp index 03a0d208c..b11ce692c 100644 --- a/src/Gui/ActiveObjectList.cpp +++ b/src/Gui/ActiveObjectList.cpp @@ -40,14 +40,14 @@ using namespace Gui; void Gui::ActiveObjectList::setObject(App::DocumentObject* obj, const char* name, const Gui::HighlightMode& mode) { - if (obj){ - if (hasObject(name)){ - Gui::Application::Instance->activeDocument()->signalHighlightObject(*dynamic_cast(Gui::Application::Instance->activeDocument()->getViewProvider(getObject(name))), mode, false); - } - _ObjectMap[name] = obj; + if (obj){ + if (hasObject(name)){ + Gui::Application::Instance->activeDocument()->signalHighlightObject(*dynamic_cast(Gui::Application::Instance->activeDocument()->getViewProvider(getObject(name))), mode, false); + } + _ObjectMap[name] = obj; - Gui::Application::Instance->activeDocument()->signalHighlightObject(*dynamic_cast(Gui::Application::Instance->activeDocument()->getViewProvider(obj)), mode, true); - } + Gui::Application::Instance->activeDocument()->signalHighlightObject(*dynamic_cast(Gui::Application::Instance->activeDocument()->getViewProvider(obj)), mode, true); + } } bool Gui::ActiveObjectList::hasObject(const char*name)const diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index af545e7f3..b4be78722 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -515,10 +515,10 @@ void Document::slotChangedObject(const App::DocumentObject& Obj, const App::Prop if (d->_editViewProvider == ChildViewProvider) resetEdit(); //remove the viewprovider serves the purpose of detaching the inventor nodes from the - //top level root in the viewer. However, if some of the children were grouped beneath the object - //earlier they are not anymore part of the toplevel inventor node. we need to check for that. - if(activeView->getViewer()->hasViewProvider(ChildViewProvider)) - activeView->getViewer()->removeViewProvider(ChildViewProvider); + //top level root in the viewer. However, if some of the children were grouped beneath the object + //earlier they are not anymore part of the toplevel inventor node. we need to check for that. + if(activeView->getViewer()->hasViewProvider(ChildViewProvider)) + activeView->getViewer()->removeViewProvider(ChildViewProvider); } } } @@ -1035,13 +1035,25 @@ void Document::createView(const Base::Type& typeId) view3D->getViewer()->setOverrideMode(overrideMode); } - // attach the viewprovider + // attach the viewproviders. we need to make sure that we only attach the toplevel ones + // and not viewproviders which are claimed by other providers. To ensure this we first + // add all providers and then remove the ones already claimed std::map::const_iterator It1; - for (It1=d->_ViewProviderMap.begin();It1!=d->_ViewProviderMap.end();++It1) + std::vector child_vps; + for (It1=d->_ViewProviderMap.begin();It1!=d->_ViewProviderMap.end();++It1) { view3D->getViewer()->addViewProvider(It1->second); + std::vector children = It1->second->claimChildren3D(); + child_vps.insert(child_vps.end(), children.begin(), children.end()); + } std::map::const_iterator It2; - for (It2=d->_ViewProviderMapAnnotation.begin();It2!=d->_ViewProviderMapAnnotation.end();++It2) + for (It2=d->_ViewProviderMapAnnotation.begin();It2!=d->_ViewProviderMapAnnotation.end();++It2) { view3D->getViewer()->addViewProvider(It2->second); + std::vector children = It2->second->claimChildren3D(); + child_vps.insert(child_vps.end(), children.begin(), children.end()); + } + + for(App::DocumentObject* obj : child_vps) + view3D->getViewer()->removeViewProvider(getViewProvider(obj)); const char* name = getDocument()->Label.getValue(); QString title = QString::fromLatin1("%1 : %2[*]")