]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Use selection attribute for sketch plane
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 31 Oct 2014 12:14:18 +0000 (15:14 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 31 Oct 2014 12:14:18 +0000 (15:14 +0300)
src/PartSet/PartSet_OperationSketch.cpp

index 331f7e63e24b2ea1b26a17e99d3870b7bf353cfc..64f77867c74e9e8a503bc556a3ff0622a1229830 100644 (file)
@@ -94,9 +94,28 @@ void PartSet_OperationSketch::selectionChanged(ModuleBase_ISelection* theSelecti
   if (!aSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = aSelected.first();
     // We have to select a plane before any operation
-    const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull())
+    TopoDS_Shape aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
       setSketchPlane(aShape);
+      // If selection is not a sketcher presentation then it has to be stored as 
+      // External shape
+      if (feature() != aPrs.object()) {
+        boost::shared_ptr<SketchPlugin_Sketch> aSketch = 
+          boost::dynamic_pointer_cast<SketchPlugin_Sketch>(feature());
+        DataPtr aData = aSketch->data();
+        AttributeSelectionPtr aSelAttr = 
+          boost::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+          (aData->attribute(SketchPlugin_Feature::EXTERNAL_ID()));
+        if (aSelAttr) {
+          ResultPtr aRes = boost::dynamic_pointer_cast<ModelAPI_Result>(aPrs.object());
+          if (aRes) {
+            GeomShapePtr aShapePtr(new GeomAPI_Shape());
+            aShapePtr->setImpl(new TopoDS_Shape(aShape));
+            aSelAttr->setValue(aRes, aShapePtr);
+          }
+        }
+      }
+    }
   }
 }