X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_ConstraintRigid.cpp;h=418c0dd53a523e12590e40f59cc392df7b5b4b1f;hb=29e40e5c48e4ac68c20cfc0bf202d6e01f7fb2e3;hp=51f4b3a01eb49249bd9e9745f3975365977c48e2;hpb=0c0573f4321deb94f9c5d3182a34fb672cc6e1f0;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp index 51f4b3a01..418c0dd53 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRigid.cpp @@ -6,6 +6,9 @@ #include "SketchPlugin_ConstraintRigid.h" #include "SketchPlugin_ConstraintParallel.h" +#include "SketchPlugin_Feature.h" + +#include #include #include @@ -19,7 +22,7 @@ SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid() void SketchPlugin_ConstraintRigid::initAttributes() { - data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); } void SketchPlugin_ConstraintRigid::execute() @@ -31,50 +34,24 @@ AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious if (!sketch()) return thePrevious; - std::shared_ptr aData = data(); - std::shared_ptr anAttr = std::dynamic_pointer_cast< - ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - if (!anAttr /*|| !anAttr->isObject()*/) - return thePrevious; - - std::shared_ptr aShape; - - if (anAttr->isObject()) { - std::shared_ptr aConst; - aConst = std::dynamic_pointer_cast(anAttr->object()); - - if (!aConst) - return thePrevious; - - std::shared_ptr aSketchFea = - std::dynamic_pointer_cast(ModelAPI_Feature::feature(aConst)); - if (aSketchFea.get() != NULL) { - if (aSketchFea->isExternal()) - return thePrevious; - } - aShape = aConst->shape(); - } - else { - std::shared_ptr aPointAttr = - std::dynamic_pointer_cast(anAttr->attr()); - if (!aPointAttr) - return thePrevious; - std::shared_ptr aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y())); - aShape = GeomAlgoAPI_PointBuilder::point(aPoint); - } - AISObjectPtr anAIS = thePrevious; - if (!anAIS) - anAIS = AISObjectPtr(new GeomAPI_AISObject); - std::shared_ptr aPlane = sketch()->plane(); - anAIS->createFixed(aShape, aPlane); - - // Set color from preferences - std::vector aRGB = Config_PropManager::color("Visualization", "sketch_constraint_color", - SKETCH_CONSTRAINT_COLOR); + bool isValidRigid = false; + std::shared_ptr aData = data(); + AttributeRefAttrPtr anAttr = aData->refattr(SketchPlugin_Constraint::ENTITY_A()); + ObjectPtr aObj = anAttr->object(); + if (aObj.get() != NULL) { + FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); + std::shared_ptr aSkFea = + std::dynamic_pointer_cast(aFeature); + if (!aSkFea->isExternal()) + isValidRigid = true; + } - anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]); + if (isValidRigid) + anAIS = SketcherPrs_Factory::rigidConstraint(this, sketch()->coordinatePlane(), thePrevious); + else + anAIS = AISObjectPtr(); return anAIS; } \ No newline at end of file