1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_ConstraintRigid.cpp
4 // Created: 13 Oct 2014
5 // Author: Artem ZHIDKOV
7 #include "SketchPlugin_ConstraintRigid.h"
9 #include <ModelAPI_ResultConstruction.h>
10 #include <Config_PropManager.h>
12 #include <GeomDataAPI_Point2D.h>
13 #include <GeomAlgoAPI_PointBuilder.h>
15 SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
19 void SketchPlugin_ConstraintRigid::initAttributes()
21 data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
24 void SketchPlugin_ConstraintRigid::execute()
28 AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious)
33 std::shared_ptr<ModelAPI_Data> aData = data();
34 std::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = std::dynamic_pointer_cast<
35 ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
36 if (!anAttr /*|| !anAttr->isObject()*/)
39 std::shared_ptr<GeomAPI_Shape> aShape;
41 if (anAttr->isObject()) {
42 std::shared_ptr<ModelAPI_ResultConstruction> aConst;
43 aConst = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
47 aShape = aConst->shape();
50 std::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
51 std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anAttr->attr());
54 std::shared_ptr<GeomAPI_Pnt> aPoint(sketch()->to3D(aPointAttr->x(), aPointAttr->y()));
55 aShape = GeomAlgoAPI_PointBuilder::point(aPoint);
58 AISObjectPtr anAIS = thePrevious;
60 anAIS = AISObjectPtr(new GeomAPI_AISObject);
62 std::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
63 anAIS->createFixed(aShape, aPlane);
65 // Set color from preferences
66 std::vector<int> aRGB = Config_PropManager::color("Visualization", "fixing_color",
68 anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);