1 // File: SketchPlugin_Point.cpp
2 // Created: 07 May 2014
3 // Author: Artem ZHIDKOV
5 #include "SketchPlugin_Point.h"
6 #include "SketchPlugin_Sketch.h"
7 #include <ModelAPI_Data.h>
8 #include <GeomDataAPI_Point2D.h>
9 #include <GeomAlgoAPI_PointBuilder.h>
13 SketchPlugin_Point::SketchPlugin_Point()
17 void SketchPlugin_Point::initAttributes()
19 data()->addAttribute(POINT_ATTR_COORD, GeomDataAPI_Point2D::type());
22 void SketchPlugin_Point::execute()
26 const boost::shared_ptr<GeomAPI_Shape>& SketchPlugin_Point::preview()
28 SketchPlugin_Sketch* aSketch = sketch();
30 // compute a point in 3D view
31 boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
32 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(POINT_ATTR_COORD));
33 boost::shared_ptr<GeomAPI_Pnt> aPoint3D(aSketch->to3D(aPoint->x(), aPoint->y()));
34 // make a visible point
35 boost::shared_ptr<GeomAPI_Shape> aPointShape = GeomAlgoAPI_PointBuilder::point(aPoint3D);
36 setPreview(aPointShape);
41 void SketchPlugin_Point::move(double theDeltaX, double theDeltaY)
43 boost::shared_ptr<ModelAPI_Data> aData = data();
44 if (!aData->isValid())
47 boost::shared_ptr<GeomDataAPI_Point2D> aPoint1 =
48 boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(POINT_ATTR_COORD));
49 aPoint1->setValue(aPoint1->x() + theDeltaX, aPoint1->y() + theDeltaY);