diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp index e2297aaa00..29e1ae3d77 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.cpp @@ -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(getObject())->BaseFeature.getValue(); - if(obj) + if (obj) static_cast(Gui::Application::Instance->getViewProvider(obj))->makeTemporaryVisible(onoff); } diff --git a/src/Mod/PartDesign/Gui/ViewProviderAddSub.h b/src/Mod/PartDesign/Gui/ViewProviderAddSub.h index 9a1ebbe169..4555113479 100644 --- a/src/Mod/PartDesign/Gui/ViewProviderAddSub.h +++ b/src/Mod/PartDesign/Gui/ViewProviderAddSub.h @@ -46,11 +46,14 @@ protected: void updateAddSubShapeIndicator(); void setPreviewDisplayMode(bool); - std::string displayMode; SoSeparator* previewShape; PartGui::SoBrepFaceSet* previewFaceSet; SoCoordinate3* previewCoords; SoNormal* previewNorm; + +private: + int whichChild; + std::string displayMode; }; } // namespace PartDesignGui