Salome HOME
Base class for constraints was updated. Constraint manager functionality was started.
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Constraint.cpp
1 // File:    SketchPlugin_Constraint.cpp
2 // Created: 08 May 2014
3 // Author:  Artem ZHIDKOV
4
5 #include "SketchPlugin_Constraint.h"
6
7 #include <ModelAPI_Data.h>
8 #include <SketchPlugin_Sketch.h>
9
10 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Constraint::preview()
11 {
12   return getPreview();
13 }
14
15 void SketchPlugin_Constraint::addConstrainedObject(
16           const std::string&                                    theAttrID,
17           const boost::shared_ptr<ModelAPI_AttributeReference>& theReference)
18 {
19   if (!data()->attribute(theAttrID).get())
20     data()->addAttribute(theAttrID, theReference->type());
21   boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(
22     data()->attribute(theAttrID))->setValue(theReference->value());
23 }
24
25 void SketchPlugin_Constraint::addConstrainedObject(
26           const std::string&                                  theAttrID,
27           const boost::shared_ptr<ModelAPI_AttributeRefAttr>& theReference)
28 {
29   if (!data()->attribute(theAttrID).get())
30     data()->addAttribute(theAttrID, theReference->type());
31   boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
32     data()->attribute(theAttrID))->setValue(theReference->value());
33 }
34
35 void SketchPlugin_Constraint::getSketchParameters(
36           std::list< boost::shared_ptr<ModelAPI_Attribute> >& theParams)
37 {
38   theParams.push_back(sketch()->data()->attribute(SKETCH_ATTR_ORIGIN));
39   theParams.push_back(sketch()->data()->attribute(SKETCH_ATTR_DIRX));
40   theParams.push_back(sketch()->data()->attribute(SKETCH_ATTR_DIRY));
41   theParams.push_back(sketch()->data()->attribute(SKETCH_ATTR_NORM));
42 }