From 968fb5be344cf35ca1ec385f7ed90b105aef619e Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Wed, 31 Aug 2022 09:55:31 +0200 Subject: [PATCH] Sketcher/BackEdit: makes clip plane switch side according to view side --- src/Mod/Sketcher/Gui/Command.cpp | 12 +++++++++++- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 5 +++++ src/Mod/Sketcher/Gui/ViewProviderSketch.h | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index e4fe78854d..47e55bb60e 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -964,7 +964,17 @@ CmdSketcherViewSection::CmdSketcherViewSection() void CmdSketcherViewSection::activated(int iMsg) { Q_UNUSED(iMsg); - doCommand(Doc,"ActiveSketch.ViewObject.TempoVis.sketchClipPlane(ActiveSketch)"); + QString cmdStr = QLatin1String("ActiveSketch.ViewObject.TempoVis.sketchClipPlane(ActiveSketch, None, %1)\n"); + Gui::Document *doc = getActiveGuiDocument(); + bool revert = false; + if(doc) { + SketcherGui::ViewProviderSketch* vp = dynamic_cast(doc->getInEdit()); + if (vp) { + revert = vp->getViewOrientationFactor() < 0?true:false; + } + } + cmdStr = cmdStr.arg(revert?QLatin1String("True"):QLatin1String("False")); + doCommand(Doc, cmdStr.toLatin1()); } bool CmdSketcherViewSection::isActive() diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 03583c4985..bfc7a37a2d 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -3149,6 +3149,11 @@ void ViewProviderSketch::camSensCB(void *data, SoSensor *) Base::Console().Log("Switching side, now %s, redrawing\n", tmpFactor < 0 ? "back" : "front"); vp->viewOrientationFactor = tmpFactor; vp->draw(); + + QString cmdStr = QStringLiteral( + "ActiveSketch.ViewObject.TempoVis.sketchClipPlane(ActiveSketch, ActiveSketch.ViewObject.SectionView, %1)\n") + .arg(tmpFactor<0?QLatin1String("True"):QLatin1String("False")); + Base::Interpreter().runStringObject(cmdStr.toLatin1()); } } diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index 5a98133d85..7620dc090f 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -500,6 +500,8 @@ public: void centerSelection(); /// returns the scale factor float getScaleFactor() const; + /// returns view orientation factor + int getViewOrientationFactor() const; //@} /** @name constraint Virtual Space visibility management */ @@ -685,8 +687,6 @@ private: int getApplicationLogicalDPIX() const; - int getViewOrientationFactor() const; - double getRotation(SbVec3f pos0, SbVec3f pos1) const; bool isSketchInvalid() const;