1 // File: SketchPlugin_ConstraintRigid.cpp
2 // Created: 13 Oct 2014
3 // Author: Artem ZHIDKOV
5 #include "SketchPlugin_ConstraintRigid.h"
7 #include <ModelAPI_ResultConstruction.h>
8 #include <Config_PropManager.h>
10 #include <GeomDataAPI_Point2D.h>
11 #include <GeomAlgoAPI_PointBuilder.h>
13 SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
17 void SketchPlugin_ConstraintRigid::initAttributes()
19 data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
22 void SketchPlugin_ConstraintRigid::execute()
26 AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious)
31 std::shared_ptr<ModelAPI_Data> aData = data();
32 std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
33 ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
34 if (!anAttr /*|| !anAttr->isObject()*/)
37 std::shared_ptr<GeomAPI_Shape> aShape;
39 if (anAttr->isObject()) {
40 std::shared_ptr<ModelAPI_ResultConstruction> aConst;
41 aConst = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
45 aShape = aConst->shape();
48 std::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
49 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
52 std::shared_ptr<GeomAPI_Pnt> aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y()));
53 aShape = GeomAlgoAPI_PointBuilder::point(aPoint);
56 AISObjectPtr anAIS = thePrevious;
58 anAIS = AISObjectPtr(new GeomAPI_AISObject);
60 std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
61 anAIS->createFixed(aShape, aPlane);
63 // Set color from preferences
64 std::vector<int> aRGB = Config_PropManager::color("Visualization", "fixing_color",
66 anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);