From 40b0af1c45bd2633880349a5773469b399a5655a Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 31 Oct 2014 11:25:12 +0300 Subject: [PATCH] refs #221: constraint defining fixed object - selection of object is wrong --- .../SketchPlugin_ConstraintRigid.cpp | 28 ++++++++++++++----- src/SketchPlugin/plugin-Sketch.xml | 4 +-- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index c9763327e..1b02335df 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -6,6 +6,9 @@ #include +#include +#include + SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid() { } @@ -27,16 +30,27 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious boost::shared_ptr aData = data(); boost::shared_ptr anAttr = boost::dynamic_pointer_cast< ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - if (!anAttr || !anAttr->isObject()) - return thePrevious; - - boost::shared_ptr aConst = - boost::dynamic_pointer_cast(anAttr->object()); - if (!aConst) + if (!anAttr /*|| !anAttr->isObject()*/) return thePrevious; boost::shared_ptr aShape; - aShape = aConst->shape(); + + if (anAttr->isObject()) { + boost::shared_ptr aConst; + aConst = boost::dynamic_pointer_cast(anAttr->object()); + + if (!aConst) + return thePrevious; + aShape = aConst->shape(); + } + else { + boost::shared_ptr aPointAttr = + boost::dynamic_pointer_cast(anAttr->attr()); + if (!aPointAttr) + return thePrevious; + boost::shared_ptr aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y())); + aShape = GeomAlgoAPI_PointBuilder::point(aPoint); + } AISObjectPtr anAIS = thePrevious; if (!anAIS) diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 9e212a4fa..14deb7083 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -94,11 +94,11 @@ - + - + -- 2.39.2