Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ConstraintRigid.cpp
1 // File:    SketchPlugin_ConstraintRigid.cpp
2 // Created: 13 Oct 2014
3 // Author:  Artem ZHIDKOV
4
5 #include "SketchPlugin_ConstraintRigid.h"
6
7 #include <ModelAPI_ResultConstruction.h>
8
9 SketchPlugin_ConstraintRigid::SketchPlugin_ConstraintRigid()
10 {
11 }
12
13 void SketchPlugin_ConstraintRigid::initAttributes()
14 {
15   data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::type());
16 }
17
18 void SketchPlugin_ConstraintRigid::execute()
19 {
20 }
21
22 AISObjectPtr SketchPlugin_ConstraintRigid::getAISObject(AISObjectPtr thePrevious)
23 {
24   if (!sketch())
25     return thePrevious;
26
27   boost::shared_ptr<ModelAPI_Data> aData = data();
28   boost::shared_ptr<ModelAPI_AttributeRefAttr> anAttr = boost::dynamic_pointer_cast<
29       ModelAPI_AttributeRefAttr>(aData->attribute(SketchPlugin_Constraint::ENTITY_A()));
30   if (!anAttr || !anAttr->isObject())
31     return thePrevious;
32
33   boost::shared_ptr<ModelAPI_ResultConstruction> aConst = 
34     boost::dynamic_pointer_cast<ModelAPI_ResultConstruction>(anAttr->object());
35   if (!aConst) 
36     return thePrevious;
37
38   boost::shared_ptr<GeomAPI_Shape> aShape;
39   aShape = aConst->shape();
40
41   AISObjectPtr anAIS = thePrevious;
42   if (!anAIS)
43     anAIS = AISObjectPtr(new GeomAPI_AISObject);
44
45   boost::shared_ptr<GeomAPI_Pln> aPlane = sketch()->plane();
46   anAIS->createFixed(aShape, aPlane);
47
48   // Set color from preferences
49   //std::vector<int> aRGB = Config_PropManager::color("Visualization", "perpendicular_color",
50   //                                                  PERPENDICULAR_COLOR);
51   //anAIS->setColor(aRGB[0], aRGB[1], aRGB[2]);
52
53   return anAIS;
54 }