1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_MacroCircle.h
4 // Created: 26 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_MacroCircle_H_
8 #define SketchPlugin_MacroCircle_H_
10 #include "SketchPlugin.h"
12 #include "SketchPlugin_SketchEntity.h"
14 #include <GeomAPI_IPresentable.h>
19 /**\class SketchPlugin_MacroCircle
21 * \brief Feature for creation of the new circle in Sketch.
23 class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity,
24 public GeomAPI_IPresentable
27 /// Circle feature kind
28 inline static const std::string& ID()
30 static const std::string ID("SketchMacroCircle");
34 inline static const std::string& CIRCLE_TYPE()
36 static const std::string ID("circle_type");
40 /// Creation method by center and passed point.
41 inline static const std::string& CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
43 static const std::string ID("circle_type_by_center_and_passed_points");
47 /// Creation method by three points.
48 inline static const std::string& CIRCLE_TYPE_BY_THREE_POINTS()
50 static const std::string ID("circle_type_by_three_points");
54 /// 2D point - center of the circle.
55 inline static const std::string& CENTER_POINT_ID()
57 static const std::string ID("center_point");
61 /// Reference for center point selection.
62 inline static const std::string& CENTER_POINT_REF_ID()
64 static const std::string ID("center_point_ref");
68 /// 2D point - passed point of the circle
69 inline static const std::string& PASSED_POINT_ID()
71 static const std::string ID("passed_point");
75 /// Reference for passed point selection.
76 inline static const std::string& PASSED_POINT_REF_ID()
78 static const std::string ID("passed_point_ref");
83 inline static const std::string& FIRST_POINT_ID()
85 static const std::string ID("first_point");
89 /// Reference for first point selection.
90 inline static const std::string& FIRST_POINT_REF_ID()
92 static const std::string ID("first_point_ref");
97 inline static const std::string& SECOND_POINT_ID()
99 static const std::string ID("second_point");
103 /// Reference for second point selection.
104 inline static const std::string& SECOND_POINT_REF_ID()
106 static const std::string ID("second_point_ref");
111 inline static const std::string& THIRD_POINT_ID()
113 static const std::string ID("third_point");
117 /// Reference for third point selection.
118 inline static const std::string& THIRD_POINT_REF_ID()
120 static const std::string ID("third_point_ref");
124 /// Radius of the circle
125 inline static const std::string& CIRCLE_RADIUS_ID()
127 static const std::string ID("circle_radius");
131 /// Returns the kind of a feature
132 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
134 static std::string MY_KIND = SketchPlugin_MacroCircle::ID();
138 /// \brief Request for initialization of data model of the feature: adding all attributes.
139 SKETCHPLUGIN_EXPORT virtual void initAttributes();
141 /// Called on change of any argument-attribute of this object
142 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
144 /// Returns the AIS preview
145 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
147 /// Creates a new part document if needed
148 SKETCHPLUGIN_EXPORT virtual void execute();
150 /// Moves the feature
151 /// \param theDeltaX the delta for X coordinate is moved
152 /// \param theDeltaY the delta for Y coordinate is moved
153 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
156 /// Reimplemented from ModelAPI_Feature::isMacro().
158 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
160 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
162 /// Use plugin manager for features creation
163 SketchPlugin_MacroCircle();
166 std::shared_ptr<GeomAPI_Circ2d> shapeByCenterAndPassed();
167 std::shared_ptr<GeomAPI_Circ2d> shapeByThreePoints();
168 /// Creates shape if only two of three points is initialized
169 std::shared_ptr<GeomAPI_Circ2d> shapeByTwoPassedPoints();
171 void createCircleByCenterAndPassed();
172 void createCircleByThreePoints();
174 FeaturePtr createCircleFeature(const std::shared_ptr<GeomAPI_Circ2d>& theCircle);