proper handling of setting and reverting preview mode in PD view provider

This commit is contained in:
wmayer
2018-02-10 00:42:10 +01:00
parent a20e13b8ae
commit a81a785b52
2 changed files with 17 additions and 10 deletions

View File

@@ -57,7 +57,6 @@ PROPERTY_SOURCE(PartDesignGui::ViewProviderAddSub,PartDesignGui::ViewProvider)
ViewProviderAddSub::ViewProviderAddSub()
{
previewShape = new SoSeparator();
previewShape->ref();
previewFaceSet = new PartGui::SoBrepFaceSet();
@@ -66,7 +65,7 @@ ViewProviderAddSub::ViewProviderAddSub()
previewCoords->ref();
previewNorm = new SoNormal();
previewNorm->ref();
whichChild = -1;
}
ViewProviderAddSub::~ViewProviderAddSub()
@@ -275,18 +274,23 @@ void ViewProviderAddSub::updateData(const App::Property* p) {
}
void ViewProviderAddSub::setPreviewDisplayMode(bool onoff) {
if(onoff && displayMode!="Shape preview") {
// A mask mode is always set, also for hidden objects.
// Now when changing to another mask mode this automatically
// displays an object and when restoring the previous state it's
// not sufficient to only revert the mask mode. Also the child
// number of the switch node must be reverted.
if (onoff && displayMode!="Shape preview") {
displayMode = getActiveDisplayMode();
whichChild = pcModeSwitch->whichChild.getValue();
setDisplayMaskMode("Shape preview");
}
if(!onoff) {
if (!onoff) {
setDisplayMaskMode(displayMode.c_str());
pcModeSwitch->whichChild.setValue(whichChild);
}
App::DocumentObject* obj = static_cast<PartDesign::Feature*>(getObject())->BaseFeature.getValue();
if(obj)
if (obj)
static_cast<PartDesignGui::ViewProvider*>(Gui::Application::Instance->getViewProvider(obj))->makeTemporaryVisible(onoff);
}