1 // File: SketchPlugin_ConstraintLength.cpp
2 // Created: 30 May 2014
3 // Author: Artem ZHIDKOV
5 #include "SketchPlugin_ConstraintLength.h"
7 #include <GeomDataAPI_Point2D.h>
9 #include <ModelAPI_AttributeDouble.h>
10 #include <ModelAPI_Data.h>
12 SketchPlugin_ConstraintLength::SketchPlugin_ConstraintLength()
16 void SketchPlugin_ConstraintLength::initAttributes()
18 data()->addAttribute(CONSTRAINT_ATTR_VALUE, ModelAPI_AttributeDouble::type());
19 data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE, ModelAPI_AttributeDouble::type());
20 data()->addAttribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT, GeomDataAPI_Point2D::type());
21 data()->addAttribute(CONSTRAINT_ATTR_ENTITY_A, ModelAPI_AttributeRefAttr::type());
24 void SketchPlugin_ConstraintLength::execute()
28 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_ConstraintLength::preview()
30 /// \todo Preview for distance constraint
34 void SketchPlugin_ConstraintLength::move(double theDeltaX, double theDeltaY)
36 boost::shared_ptr<ModelAPI_Data> aData = data();
37 if (!aData->isValid())
40 boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
41 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(CONSTRAINT_ATTR_FLYOUT_VALUE_PNT));
42 aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);