]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Optimization of sketch plane update
authorvsv <vsv@opencascade.com>
Thu, 30 May 2019 09:55:25 +0000 (12:55 +0300)
committervsv <vsv@opencascade.com>
Thu, 30 May 2019 09:55:25 +0000 (12:55 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_PreviewSketchPlane.cpp

index ee3f43ae50c933d242095eebaf1eb575b7e2eeae..f202db9f6c6a8e2ea18d4eb7534f43ded9d4ad95 100644 (file)
@@ -1516,7 +1516,9 @@ void PartSet_Module::processEvent(const std::shared_ptr<Events_Message>& theMess
   else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
     CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
     if (aSketch.get()) {
-      mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+      ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+      if (PartSet_SketcherMgr::isSketchOperation(anOperation))
+        mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
     }
   }
 }
index 55db2ece6d0e16e97db624514738b40f4f28c096..43d7005ee73ae2f4a4bdcb72b9f5501e68712d3a 100644 (file)
@@ -68,6 +68,14 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th
   if (!PartSet_Tools::sketchPlane(theSketch).get())
     return;
 
+  AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+    (theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+  if (!aSelAttr)
+    return;
+
+  if (myShape.get() && myShape->isSame(aSelAttr->value()))
+    return;
+
   XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
   if (myPreviewIsDisplayed) {
     aDisp->eraseAIS(myPlane, false);
@@ -75,15 +83,12 @@ void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& th
 
   // Create Preview
   // selected linear face parameters
-  AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-    (theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-  if (aSelAttr) {
-    myShape = aSelAttr->value();
-    // this case is needed by constructing sketch on a plane, where result shape is equal
-    // to context result, therefore value() returns NULL and we should use shape of context.
-    if (!myShape.get() && aSelAttr->context().get())
-      myShape = aSelAttr->context()->shape();
-  }
+  myShape = aSelAttr->value();
+  // this case is needed by constructing sketch on a plane, where result shape is equal
+  // to context result, therefore value() returns NULL and we should use shape of context.
+  if (!myShape.get() && aSelAttr->context().get())
+    myShape = aSelAttr->context()->shape();
+
   if (!myShape.get()) {
     // Create Preview for default planes
     std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(