#include <ModelAPI_ResultConstruction.h>
+#include <GeomDataAPI_Point2D.h>
+#include <GeomAlgoAPI_PointBuilder.h>
+
SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
{
}
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)
</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>