]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #3220: Show/Hide sketch plane
authorvsv <vsv@opencascade.com>
Tue, 28 Jul 2020 09:35:15 +0000 (12:35 +0300)
committervsv <vsv@opencascade.com>
Tue, 28 Jul 2020 09:35:15 +0000 (12:35 +0300)
src/PartSet/PartSet_PreviewSketchPlane.cpp
src/PartSet/PartSet_PreviewSketchPlane.h
src/PartSet/PartSet_WidgetSketchLabel.cpp

index 83529e23891f309d9eab8290d9d5932e6a84470b..72018bd0f21b6a0002c71e8871b2c68aeda8627e 100644 (file)
@@ -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();
index a8025956ca2a789b8acf98a33f6280dd2fbdcd4e..c255aca421067563fccfbe02f43e3b51e746a290 100644 (file)
@@ -74,6 +74,12 @@ public:
   void setSizeOfView(double theSizeOfView, bool isUseSizeOfView,
     const std::shared_ptr<GeomAPI_Pnt>& theCentralPoint = std::shared_ptr<GeomAPI_Pnt>());
 
+  bool isPlaneCreated() const {
+    return myPlane.get();
+  }
+
+  void displaySketchPlane(ModuleBase_IWorkshop* theWorkshop);
+
 private:
   /// Create a square face by parameters
   std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
index e8244c6542e647d34d66b9c0977146240dce70f1..4a2a5154f0f0a6cfee6b7afcdbbd52565c2dcb71 100644 (file)
@@ -889,12 +889,16 @@ bool PartSet_WidgetSketchLabel::eventFilter(QObject* theObj, QEvent* theEvent)
 void PartSet_WidgetSketchLabel::onShowViewPlane(bool toShow)
 {
   PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  PartSet_PreviewSketchPlane* aPreviewPlane = aModule->sketchMgr()->previewSketchPlane();
   if (toShow) {
     CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(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();
 }