Salome HOME
Fix for the issue #2274: closing the study takes too much time.
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index aa209656b328a61230ef0ff4e5efe3eacce1a881..d3908d81e0e350937d88b90f512c7156dd2fe35d 100644 (file)
@@ -272,8 +272,14 @@ bool PartSet_WidgetSketchLabel::setSelectionInternal(
 
 void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrsPtr& thePrs)
 {
-  // 1. hide main planes if they have been displayed
+  // 1. hide main planes if they have been displayed and display sketch preview plane
   myPreviewPlanes->erasePreviewPlanes(myWorkshop);
+
+  PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+  if (aModule) {
+    CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+    aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+  }
   // 2. if the planes were displayed, change the view projection
   const GeomShapePtr& aShape = thePrs->shape();
   std::shared_ptr<GeomAPI_Shape> aGShape;
@@ -294,7 +300,8 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
   // If the selected object is a sketch then use its plane
   std::shared_ptr<GeomAPI_Pln> aPlane;
   ObjectPtr aObj = thePrs->object();
-  if (aObj.get()) {
+  // obsolete as selected sketch is stored in external attribute
+  /*if (aObj.get()) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
     if (aFeature.get() && (aFeature != feature())) {
       if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
@@ -303,7 +310,7 @@ void PartSet_WidgetSketchLabel::updateByPlaneSelected(const ModuleBase_ViewerPrs
         aPlane = PartSet_Tools::sketchPlane(aSketch);
       }
     }
-  }
+  }*/
   if (aGShape.get() != NULL) {
     // get plane parameters
     if (!aPlane.get()) {
@@ -452,17 +459,6 @@ bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_View
 
   if (thePrs->object() && (feature() != thePrs->object())) {
     FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object());
-    if (aFeature.get() && (aFeature != feature())) {
-      if (aFeature->getKind() == SketchPlugin_Sketch::ID()) {
-        CompositeFeaturePtr aSketch =
-          std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aFeature);
-        std::shared_ptr<GeomAPI_Pln> aPlane = PartSet_Tools::sketchPlane(aSketch);
-        if (aPlane.get()) {
-          aDir = setSketchPlane(aPlane);
-          return aDir.get();
-        }
-      }
-    }
     DataPtr aData = feature()->data();
     AttributeSelectionPtr aSelAttr =
       std::dynamic_pointer_cast<ModelAPI_AttributeSelection>