From 097b95f6867a919501464620f6403780b9d7d4c2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 14 Jul 2013 15:53:57 +0200 Subject: [PATCH] Show linked objects of compound objects as children in tree view --- src/Mod/Part/Gui/ViewProviderCompound.cpp | 24 +++++++++++++++++++++++ src/Mod/Part/Gui/ViewProviderCompound.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/Mod/Part/Gui/ViewProviderCompound.cpp b/src/Mod/Part/Gui/ViewProviderCompound.cpp index a9bc1727c..3fccded18 100644 --- a/src/Mod/Part/Gui/ViewProviderCompound.cpp +++ b/src/Mod/Part/Gui/ViewProviderCompound.cpp @@ -45,6 +45,24 @@ ViewProviderCompound::~ViewProviderCompound() { } +std::vector ViewProviderCompound::claimChildren(void) const +{ + return static_cast(getObject())->Links.getValues(); +} + +bool ViewProviderCompound::onDelete(const std::vector &) +{ + // get the input shapes + Part::Compound* pComp = static_cast(getObject()); + std::vector pLinks = pComp->Links.getValues(); + for (std::vector::iterator it = pLinks.begin(); it != pLinks.end(); ++it) { + if (*it) + Gui::Application::Instance->showViewProvider(*it); + } + + return true; +} + void ViewProviderCompound::updateData(const App::Property* prop) { PartGui::ViewProviderPart::updateData(prop); @@ -88,4 +106,10 @@ void ViewProviderCompound::updateData(const App::Property* prop) if (setColor) this->DiffuseColor.setValues(compCol); } + else if (prop->getTypeId() == App::PropertyLinkList::getClassTypeId()) { + const std::vector& pBases = static_cast(prop)->getValues(); + for (std::vector::const_iterator it = pBases.begin(); it != pBases.end(); ++it) { + if (*it) Gui::Application::Instance->hideViewProvider(*it); + } + } } diff --git a/src/Mod/Part/Gui/ViewProviderCompound.h b/src/Mod/Part/Gui/ViewProviderCompound.h index d648f9864..1ec37b628 100644 --- a/src/Mod/Part/Gui/ViewProviderCompound.h +++ b/src/Mod/Part/Gui/ViewProviderCompound.h @@ -38,6 +38,8 @@ public: ViewProviderCompound(); /// destructor virtual ~ViewProviderCompound(); + std::vector claimChildren() const; + bool onDelete(const std::vector &); protected: void updateData(const App::Property*);