]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #672 - Crash when distance constraint
authornds <natalia.donis@opencascade.com>
Wed, 24 Jun 2015 05:01:48 +0000 (08:01 +0300)
committernds <natalia.donis@opencascade.com>
Wed, 24 Jun 2015 05:01:48 +0000 (08:01 +0300)
reason: an empty shape if the selected shape is equal to the shape of result

src/PartSet/PartSet_WidgetMultiSelector.cpp
src/PartSet/PartSet_WidgetShapeSelector.cpp

index d6c0008974f044bc263b532811cd073b0dd897fc..60b2573e7433877b2e77f83ab66a027b0757dbed 100644 (file)
@@ -99,11 +99,19 @@ void PartSet_WidgetMultiSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
   // there is no a sketch feature is selected, but the shape exists, try to create an exernal object
-  if (aSPFeature.get() == NULL && theShape.get() != NULL && !theShape->isNull() &&
-      myExternalObjectMgr->useExternal()) {
-    if (myIsInVaildate)
-      theObject = myExternalObjectMgr->externalObjectValidated(theObject, theShape, sketch());
-    else
-      theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch());
+  // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
+  if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) {
+    GeomShapePtr aShape = theShape;
+    if (!aShape.get()) {
+      ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+      if (aResult.get())
+        aShape = aResult->shape();
+    }
+    if (aShape.get() != NULL && !aShape->isNull()) {
+      if (myIsInVaildate)
+        theObject = myExternalObjectMgr->externalObjectValidated(theObject, theShape, sketch());
+      else
+        theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch());
+    }
   }
 }
index 7fca13598405600bfe582cdbd24d256429bbcc71..431f1e8a88db447743c393aaff943f3778878684 100644 (file)
@@ -77,9 +77,17 @@ void PartSet_WidgetShapeSelector::getGeomSelection(const ModuleBase_ViewerPrs& t
   std::shared_ptr<SketchPlugin_Feature> aSPFeature = 
           std::dynamic_pointer_cast<SketchPlugin_Feature>(aSelectedFeature);
   // there is no a sketch feature is selected, but the shape exists, try to create an exernal object
-  if (aSPFeature.get() == NULL && theShape.get() != NULL && !theShape->isNull() &&
-      myExternalObjectMgr->useExternal())
-    theObject = myExternalObjectMgr->externalObject(theObject, theShape, sketch());
+  // TODO: unite with the same functionality in PartSet_WidgetShapeSelector
+  if (aSPFeature.get() == NULL && myExternalObjectMgr->useExternal()) {
+    GeomShapePtr aShape = theShape;
+    if (!aShape.get()) {
+      ResultPtr aResult = myWorkshop->selection()->getResult(thePrs);
+      if (aResult.get())
+        aShape = aResult->shape();
+    }
+    if (aShape.get() != NULL && !aShape->isNull())
+      theObject = myExternalObjectMgr->externalObject(theObject, aShape, sketch());
+  }
 }
 
 //********************************************************************