More work on highlighting and hiding/showing

This commit is contained in:
jrheinlaender 2013-04-10 17:42:46 +04:30 committed by Stefan Tröger
parent 1ec99c5d32
commit e184c9f229
6 changed files with 75 additions and 45 deletions

View File

@ -28,7 +28,10 @@
#endif
#include "ViewProviderBody.h"
#include "Workbench.h"
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/Application.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeatureSketchBased.h>
#include <algorithm>
@ -139,3 +142,40 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren3D(void)const
return static_cast<PartDesign::Body*>(getObject())->Model.getValues();
}
void ViewProviderBody::updateTree()
{
// Highlight active body and all its features
//Base::Console().Error("ViewProviderBody::updateTree()\n");
PartDesign::Body* body = static_cast<PartDesign::Body*>(getObject());
bool active = body->IsActive.getValue();
//Base::Console().Error("Body is %s\n", active ? "active" : "inactive");
ActiveGuiDoc->signalHighlightObject(*this, Gui::Blue, active);
std::vector<App::DocumentObject*> features = body->Model.getValues();
bool highlight = true;
App::DocumentObject* tip = body->Tip.getValue();
for (std::vector<App::DocumentObject*>::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::ViewProviderDocumentObject*>(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);
}

View File

@ -57,12 +57,19 @@ public:
virtual SoGroup* getChildRoot(void) const {return pcBodyChildren;}
std::vector<App::DocumentObject*> 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();
};

View File

@ -132,24 +132,19 @@ void ViewProviderGroove::unsetEdit(int ModNum)
}
}
bool ViewProviderGroove::onDelete(const std::vector<std::string> &)
bool ViewProviderGroove::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
// get the Sketch
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(getObject());
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcGroove->Sketch.getValue()){
if (pcGroove->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(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);
}

View File

@ -31,6 +31,8 @@
#include "ViewProviderPad.h"
#include "TaskPadParameters.h"
#include "Workbench.h"
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeaturePad.h>
#include <Mod/Sketcher/App/SketchObject.h>
#include <Gui/Control.h>
@ -125,23 +127,19 @@ void ViewProviderPad::unsetEdit(int ModNum)
}
}
bool ViewProviderPad::onDelete(const std::vector<std::string> &)
bool ViewProviderPad::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(getObject());
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcPad->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcPad->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(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<Sketcher::SketchObject*>(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);
}

View File

@ -122,24 +122,19 @@ void ViewProviderPocket::unsetEdit(int ModNum)
}
}
bool ViewProviderPocket::onDelete(const std::vector<std::string> &)
bool ViewProviderPocket::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
// get the Sketch
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(getObject());
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcPocket->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcPocket->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
if (pcPocket->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(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);
}

View File

@ -132,24 +132,19 @@ void ViewProviderRevolution::unsetEdit(int ModNum)
}
}
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &)
bool ViewProviderRevolution::onDelete(const std::vector<std::string> &s)
{
// get the support and Sketch
// get the Sketch
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(getObject());
Sketcher::SketchObject *pcSketch = 0;
App::DocumentObject *pcSupport = 0;
if (pcRevolution->Sketch.getValue()){
pcSketch = static_cast<Sketcher::SketchObject*>(pcRevolution->Sketch.getValue());
pcSupport = pcSketch->Support.getValue();
}
if (pcRevolution->Sketch.getValue())
pcSketch = static_cast<Sketcher::SketchObject*>(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);
}