]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #221: constraint defining fixed object - selection of object is wrong
authornds <natalia.donis@opencascade.com>
Fri, 31 Oct 2014 08:25:12 +0000 (11:25 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 31 Oct 2014 08:25:12 +0000 (11:25 +0300)
src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp
src/SketchPlugin/plugin-Sketch.xml

index c9763327e2b6f23f97452473eef478a45c902b2a..1b02335dffd69fe730f98ee3c8f62e476ecfb920 100644 (file)
@@ -6,6 +6,9 @@
 
 #include <ModelAPI_ResultConstruction.h>
 
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+
 SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
 {
 }
@@ -27,16 +30,27 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious
   boost::shared_ptr<ModelAPI_Data> aData = data();
   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = boost::dynamic_pointer_cast<
       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
-  if (!anAttr || !anAttr->isObject())
-    return thePrevious;
-
-  boost::shared_ptr<ModelAPI_ResultConstruction> aConst = 
-    boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
-  if (!aConst) 
+  if (!anAttr /*|| !anAttr->isObject()*/)
     return thePrevious;
 
   boost::shared_ptr<GeomAPI_Shape> aShape;
-  aShape = aConst->shape();
+
+  if (anAttr->isObject()) {
+    boost::shared_ptr<ModelAPI_ResultConstruction> aConst;
+    aConst = boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
+
+    if (!aConst) 
+      return thePrevious;
+    aShape = aConst->shape();
+  }
+  else {
+    boost::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
+                             boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
+    if (!aPointAttr)
+      return thePrevious;
+    boost::shared_ptr<GeomAPI_Pnt> aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y()));
+    aShape = GeomAlgoAPI_PointBuilder::point(aPoint);
+  }
 
   AISObjectPtr anAIS = thePrevious;
   if (!anAIS)
index 9e212a4fabc9cd972e63e994dd1d87c288cc8685..14deb7083d3773f5f4e14cba643c2e9e284c1ee5 100644 (file)
       </feature>
 
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Create constraint defining fixed object" icon=":icons/fixed.png">
-        <feature_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer">
+        <feature_or_attribute_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer">
           <validator id="SketchPlugin_ResultPoint"/>
           <validator id="SketchPlugin_ResultLine"/>
           <validator id="SketchPlugin_ResultArc"/>
-        </feature_selector>
+        </feature_or_attribute_selector>
       </feature>
     </group>
   </workbench>