diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp index 4d48ab309b..b869008119 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.cpp @@ -28,7 +28,10 @@ #endif #include "ViewProviderBody.h" +#include "Workbench.h" #include +#include +#include #include #include #include @@ -139,3 +142,40 @@ std::vector ViewProviderBody::claimChildren3D(void)const return static_cast(getObject())->Model.getValues(); } + +void ViewProviderBody::updateTree() +{ + // Highlight active body and all its features + //Base::Console().Error("ViewProviderBody::updateTree()\n"); + PartDesign::Body* body = static_cast(getObject()); + bool active = body->IsActive.getValue(); + //Base::Console().Error("Body is %s\n", active ? "active" : "inactive"); + ActiveGuiDoc->signalHighlightObject(*this, Gui::Blue, active); + std::vector features = body->Model.getValues(); + bool highlight = true; + App::DocumentObject* tip = body->Tip.getValue(); + for (std::vector::const_iterator f = features.begin(); f != features.end(); f++) { + //Base::Console().Error("Highlighting %s: %s\n", (*f)->getNameInDocument(), highlight ? "true" : "false"); + Gui::ViewProviderDocumentObject* vp = dynamic_cast(Gui::Application::Instance->getViewProvider(*f)); + ActiveGuiDoc->signalHighlightObject(*vp, Gui::LightBlue, active ? highlight : false); + if (highlight && (tip == *f)) + highlight = false; + } +} + +void ViewProviderBody::updateData(const App::Property* prop) +{ + //Base::Console().Error("ViewProviderBody::updateData for %s\n", getObject()->getNameInDocument()); + if (ActiveGuiDoc == NULL) + // PartDesign workbench not active + return PartGui::ViewProviderPart::updateData(prop); + + if (prop->getTypeId() == App::PropertyBool::getClassTypeId() && strcmp(prop->getName(),"IsActive") == 0) { + updateTree(); + } else if (prop->getTypeId() == App::PropertyLink::getClassTypeId() && strcmp(prop->getName(),"Tip") == 0) { + updateTree(); + } + // Note: The Model property only changes by itself (without the Tip also changing) if a feature is deleted somewhere + + PartGui::ViewProviderPart::updateData(prop); +} diff --git a/src/Mod/PartDesign/Gui/ViewProviderBody.h b/src/Mod/PartDesign/Gui/ViewProviderBody.h index 667baf7522..34aa9b5a2b 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderBody.h +++ b/src/Mod/PartDesign/Gui/ViewProviderBody.h @@ -57,12 +57,19 @@ public: virtual SoGroup* getChildRoot(void) const {return pcBodyChildren;} std::vector claimChildren3D(void)const; + /// Update the children's highlighting when triggered + void updateData(const App::Property* prop); + private: /// group used to store children collected by claimChildren3D() SoGroup *pcBodyChildren; /// group used to show the tip element in "edit" mode SoGroup *pcBodyTip; + /// Update the children's highlighting + void updateTree(); + + }; diff --git a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp index 1d210af009..fbe733e5c5 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderGroove.cpp @@ -132,24 +132,19 @@ void ViewProviderGroove::unsetEdit(int ModNum) } } -bool ViewProviderGroove::onDelete(const std::vector &) +bool ViewProviderGroove::onDelete(const std::vector &s) { - // get the support and Sketch + // get the Sketch PartDesign::Groove* pcGroove = static_cast(getObject()); Sketcher::SketchObject *pcSketch = 0; - App::DocumentObject *pcSupport = 0; - if (pcGroove->Sketch.getValue()){ + if (pcGroove->Sketch.getValue()) pcSketch = static_cast(pcGroove->Sketch.getValue()); - pcSupport = pcSketch->Support.getValue(); - } - // if abort command deleted the object the support is visible again + // if abort command deleted the object the Sketch is visible again if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) Gui::Application::Instance->getViewProvider(pcSketch)->show(); - if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) - Gui::Application::Instance->getViewProvider(pcSupport)->show(); - return true; + return ViewProvider::onDelete(s); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp index dc6c71a900..0ff00ad055 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPad.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPad.cpp @@ -31,6 +31,8 @@ #include "ViewProviderPad.h" #include "TaskPadParameters.h" +#include "Workbench.h" +#include #include #include #include @@ -125,23 +127,19 @@ void ViewProviderPad::unsetEdit(int ModNum) } } -bool ViewProviderPad::onDelete(const std::vector &) +bool ViewProviderPad::onDelete(const std::vector &s) { - // get the support and Sketch - PartDesign::Pad* pcPad = static_cast(getObject()); - Sketcher::SketchObject *pcSketch = 0; - App::DocumentObject *pcSupport = 0; - if (pcPad->Sketch.getValue()){ - pcSketch = static_cast(pcPad->Sketch.getValue()); - pcSupport = pcSketch->Support.getValue(); - } + PartDesign::Pad* pcPad = static_cast(getObject()); - // if abort command deleted the object the support is visible again + // get the Sketch + Sketcher::SketchObject *pcSketch = 0; + if (pcPad->Sketch.getValue()) + pcSketch = static_cast(pcPad->Sketch.getValue()); + + // if abort command deleted the object the sketch is visible again if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) Gui::Application::Instance->getViewProvider(pcSketch)->show(); - if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) - Gui::Application::Instance->getViewProvider(pcSupport)->show(); - return true; + return ViewProvider::onDelete(s); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp index 7c8dbd19f4..e21cf00bde 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderPocket.cpp @@ -122,24 +122,19 @@ void ViewProviderPocket::unsetEdit(int ModNum) } } -bool ViewProviderPocket::onDelete(const std::vector &) +bool ViewProviderPocket::onDelete(const std::vector &s) { - // get the support and Sketch + // get the Sketch PartDesign::Pocket* pcPocket = static_cast(getObject()); Sketcher::SketchObject *pcSketch = 0; - App::DocumentObject *pcSupport = 0; - if (pcPocket->Sketch.getValue()){ - pcSketch = static_cast(pcPocket->Sketch.getValue()); - pcSupport = pcSketch->Support.getValue(); - } + if (pcPocket->Sketch.getValue()) + pcSketch = static_cast(pcPocket->Sketch.getValue()); - // if abort command deleted the object the support is visible again + // if abort command deleted the object the sketch is visible again if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) Gui::Application::Instance->getViewProvider(pcSketch)->show(); - if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) - Gui::Application::Instance->getViewProvider(pcSupport)->show(); - return true; + return ViewProvider::onDelete(s); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp index 0d27812d76..398f8aeae7 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderRevolution.cpp @@ -132,24 +132,19 @@ void ViewProviderRevolution::unsetEdit(int ModNum) } } -bool ViewProviderRevolution::onDelete(const std::vector &) +bool ViewProviderRevolution::onDelete(const std::vector &s) { - // get the support and Sketch + // get the Sketch PartDesign::Revolution* pcRevolution = static_cast(getObject()); Sketcher::SketchObject *pcSketch = 0; - App::DocumentObject *pcSupport = 0; - if (pcRevolution->Sketch.getValue()){ - pcSketch = static_cast(pcRevolution->Sketch.getValue()); - pcSupport = pcSketch->Support.getValue(); - } + if (pcRevolution->Sketch.getValue()) + pcSketch = static_cast(pcRevolution->Sketch.getValue()); - // if abort command deleted the object the support is visible again + // if abort command deleted the object the Sketch is visible again if (pcSketch && Gui::Application::Instance->getViewProvider(pcSketch)) Gui::Application::Instance->getViewProvider(pcSketch)->show(); - if (pcSupport && Gui::Application::Instance->getViewProvider(pcSupport)) - Gui::Application::Instance->getViewProvider(pcSupport)->show(); - return true; + return ViewProvider::onDelete(s); }