From: vsv Date: Tue, 28 Jul 2020 09:35:15 +0000 (+0300) Subject: Issue #3220: Show/Hide sketch plane X-Git-Tag: V9_6_0a1~38 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a1c06b10bddc9ffc5efd70dde14c21772a2fba46;p=modules%2Fshaper.git Issue #3220: Show/Hide sketch plane --- diff --git a/src/PartSet/PartSet_PreviewSketchPlane.cpp b/src/PartSet/PartSet_PreviewSketchPlane.cpp index 83529e238..72018bd0f 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.cpp +++ b/src/PartSet/PartSet_PreviewSketchPlane.cpp @@ -61,6 +61,16 @@ void PartSet_PreviewSketchPlane::eraseSketchPlane(ModuleBase_IWorkshop* theWorks } } +void PartSet_PreviewSketchPlane::displaySketchPlane(ModuleBase_IWorkshop* theWorkshop) +{ + if (myPlane.get() && (!myPreviewIsDisplayed)) { + XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer(); + aDisp->displayAIS(myPlane, false/*load object in selection*/, 1/*shaded*/, false); + myPreviewIsDisplayed = true; + } +} + + void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& theSketch, ModuleBase_IWorkshop* theWorkshop) { @@ -73,7 +83,7 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th if (!aSelAttr) return; - if (myShape.get() && myShape->isSame(aSelAttr->value())) + if (myShape.get() && myShape->isSame(aSelAttr->value()) && myPlane.get()) return; XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer(); diff --git a/src/PartSet/PartSet_PreviewSketchPlane.h b/src/PartSet/PartSet_PreviewSketchPlane.h index a8025956c..c255aca42 100644 --- a/src/PartSet/PartSet_PreviewSketchPlane.h +++ b/src/PartSet/PartSet_PreviewSketchPlane.h @@ -74,6 +74,12 @@ public: void setSizeOfView(double theSizeOfView, bool isUseSizeOfView, const std::shared_ptr& theCentralPoint = std::shared_ptr()); + bool isPlaneCreated() const { + return myPlane.get(); + } + + void displaySketchPlane(ModuleBase_IWorkshop* theWorkshop); + private: /// Create a square face by parameters std::shared_ptr createPreviewPlane(); diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index e8244c654..4a2a5154f 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -889,12 +889,16 @@ bool PartSet_WidgetSketchLabel::eventFilter(QObject* theObj, QEvent* theEvent) void PartSet_WidgetSketchLabel::onShowViewPlane(bool toShow) { PartSet_Module* aModule = dynamic_cast(myWorkshop->module()); + PartSet_PreviewSketchPlane* aPreviewPlane = aModule->sketchMgr()->previewSketchPlane(); if (toShow) { CompositeFeaturePtr aSketch = std::dynamic_pointer_cast(myFeature); - aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop); + if (aPreviewPlane->isPlaneCreated()) + aPreviewPlane->displaySketchPlane(myWorkshop); + else + aPreviewPlane->createSketchPlane(aSketch, myWorkshop); } else { - aModule->sketchMgr()->previewSketchPlane()->eraseSketchPlane(myWorkshop, false); + aPreviewPlane->eraseSketchPlane(myWorkshop, false); } myWorkshop->viewer()->update(); }