]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/PartSet/PartSet_WidgetSketchLabel.cpp
Salome HOME
Merge remote-tracking branch 'remotes/origin/occ/eliminateWarnings'
[modules/shaper.git] / src / PartSet / PartSet_WidgetSketchLabel.cpp
index a076560ada3a4e099a2183e85da3e77982f0b7af..234a7699d3097e8013fd3e31e789a7d141876d1e 100644 (file)
@@ -39,6 +39,7 @@
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_AttributeString.h>
 #include <ModelAPI_Events.h>
+#include <ModelAPI_ResultConstruction.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_ViewerPrs.h>
@@ -505,48 +506,61 @@ bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_View
 {
   bool isOwnerSet = false;
 
-  const GeomShapePtr& aShape = thePrs->shape();
+  GeomShapePtr aShape = thePrs->shape();
   std::shared_ptr<GeomAPI_Dir> aDir;
 
+  if (!aShape.get() || aShape->isNull()) {
+    if (thePrs->object() && (feature() != thePrs->object())) {
+      if (thePrs->object()->groupName() == ModelAPI_ResultConstruction::group()) {
+        ResultConstructionPtr aConstruction =
+          std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(thePrs->object());
+        if (aConstruction.get())
+          aShape = aConstruction->shape();
+      }
+    }
+  }
+
   if (aShape.get() && !aShape->isNull()) {
     const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
     aDir = setSketchPlane(aTDShape);
     isOwnerSet = aDir.get();
   }
   if (thePrs->object() && (feature() != thePrs->object())) {
-    FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object());
-    DataPtr aData = feature()->data();
-    AttributeSelectionPtr aSelAttr =
-      std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
-      (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
-    if (aSelAttr.get()) {
-      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs->object());
-      if (aRes.get()) {
-        GeomShapePtr aShapePtr;
-        if (!aShape.get() || aShape->isNull()) {  // selection happens in the OCC viewer
-          aShapePtr = ModelAPI_Tools::shape(aRes);
-        }
-        else { // selection happens in OB browser
-          aShapePtr = aShape;
-        }
-        if (aShapePtr.get() && aShapePtr->isFace()) {
-          const TopoDS_Shape& aTDShape = aShapePtr->impl<TopoDS_Shape>();
-          setSketchPlane(aTDShape);
-          aSelAttr->setValue(aRes, aShapePtr);
-          isOwnerSet = true;
-        }
-      }
-      else {
-        aSelAttr->setValue(aFeature, GeomShapePtr());
-        GeomShapePtr aSelShape = aSelAttr->value();
-        if (!aSelShape.get() && aSelAttr->contextFeature().get() &&
-          aSelAttr->contextFeature()->firstResult().get()) {
-          aSelShape = aSelAttr->contextFeature()->firstResult()->shape();
+    if (thePrs->object()->groupName() != ModelAPI_ResultConstruction::group()) {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(thePrs->object());
+      DataPtr aData = feature()->data();
+      AttributeSelectionPtr aSelAttr =
+        std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+        (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+      if (aSelAttr.get()) {
+        ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(thePrs->object());
+        if (aRes.get()) {
+          GeomShapePtr aShapePtr;
+          if (!aShape.get() || aShape->isNull()) {  // selection happens in the OCC viewer
+            aShapePtr = ModelAPI_Tools::shape(aRes);
+          }
+          else { // selection happens in OB browser
+            aShapePtr = aShape;
+          }
+          if (aShapePtr.get() && aShapePtr->isFace()) {
+            const TopoDS_Shape& aTDShape = aShapePtr->impl<TopoDS_Shape>();
+            setSketchPlane(aTDShape);
+            aSelAttr->setValue(aRes, aShapePtr);
+            isOwnerSet = true;
+          }
         }
-        if (aSelShape.get() && aSelShape->isPlanar()) {
-          const TopoDS_Shape& aTDShape = aSelShape->impl<TopoDS_Shape>();
-          setSketchPlane(aTDShape);
-          isOwnerSet = true;
+        else {
+          aSelAttr->setValue(aFeature, GeomShapePtr());
+          GeomShapePtr aSelShape = aSelAttr->value();
+          if (!aSelShape.get() && aSelAttr->contextFeature().get() &&
+            aSelAttr->contextFeature()->firstResult().get()) {
+            aSelShape = aSelAttr->contextFeature()->firstResult()->shape();
+          }
+          if (aSelShape.get() && aSelShape->isPlanar()) {
+            const TopoDS_Shape& aTDShape = aSelShape->impl<TopoDS_Shape>();
+            setSketchPlane(aTDShape);
+            isOwnerSet = true;
+          }
         }
       }
     }