From d987930338be8b934779a5b95dca28608f98c935 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 17 Dec 2017 06:56:59 +0100 Subject: [PATCH] Sketcher: Enable switching of virtual space in ViewProvider --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 21 ++++++++++++++++----- src/Mod/Sketcher/Gui/ViewProviderSketch.h | 4 +++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 86a903d384..04469bf8e4 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -278,7 +278,7 @@ ViewProviderSketch::ViewProviderSketch() Mode(STATUS_NONE), visibleInformationChanged(true), combrepscalehyst(0), - isShowVirtualSpace(false) + isShownVirtualSpace(false) { ADD_PROPERTY_TYPE(Autoconstraints,(true),"Auto Constraints",(App::PropertyType)(App::Prop_None),"Create auto constraints"); ADD_PROPERTY_TYPE(TempoVis,(Py::None()),"Visibility automation",(App::PropertyType)(App::Prop_None),"Object that handles hiding and showing other objects when entering/leaving sketch."); @@ -5146,15 +5146,26 @@ void ViewProviderSketch::updateVirtualSpace(void) SbBool *sws = edit->constrGroup->enable.startEditing(); - for (size_t i = 0; i < constrlist.size(); i++) { - //for (size_t i = 0; i < 15; i++) { - sws[i] = !constrlist[i]->isInVirtualSpace; - } + for (size_t i = 0; i < constrlist.size(); i++) + sws[i] = !(constrlist[i]->isInVirtualSpace != isShownVirtualSpace); // XOR of constraint mode and VP mode + edit->constrGroup->enable.finishEditing(); } } +void ViewProviderSketch::setIsShownVirtualSpace(bool isshownvirtualspace) +{ + this->isShownVirtualSpace = isshownvirtualspace; + + updateVirtualSpace(); +} + +bool ViewProviderSketch::getIsShownVirtualSpace() const +{ + return this->isShownVirtualSpace; +} + void ViewProviderSketch::drawEdit(const std::vector &EditCurve) { diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index 8aa595bfda..acba0c2100 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -227,6 +227,8 @@ public: /// updates the visibility of the virtual space void updateVirtualSpace(void); + void setIsShownVirtualSpace(bool isshownvirtualspace); + bool getIsShownVirtualSpace(void) const; friend class DrawSketchHandler; friend struct ::EditData; @@ -412,7 +414,7 @@ protected: double combrepscalehyst; // Virtual space variables - bool isShowVirtualSpace; + bool isShownVirtualSpace; // indicates whether the present virtual space view is the Real Space or the Virtual Space (virtual space 1 or 2) }; } // namespace PartGui