1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_MacroArc.h
4 // Created: 26 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_MacroArc_H_
8 #define SketchPlugin_MacroArc_H_
10 #include "SketchPlugin.h"
12 #include "SketchPlugin_SketchEntity.h"
14 #include <GeomAPI_IPresentable.h>
19 /**\class SketchPlugin_MacroArc
21 * \brief Feature for creation of the new arc of circle in PartSet.
22 * The visualization of this object is separated in two parts. The first one is an AIS object
23 * calculated when there is non-initialized attributes of the arc. The second is a result and
24 * it is calculated if all attributes are initialized.
26 class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity,
27 public GeomAPI_IPresentable
31 inline static const std::string& ID()
33 static const std::string ID("SketchMacroArc");
37 inline static const std::string& ARC_TYPE()
39 static const std::string ID("arc_type");
43 static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS()
45 static const std::string ID("by_center_and_points");
48 static const std::string& ARC_TYPE_BY_THREE_POINTS()
50 static const std::string ID("by_three_points");
54 inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE()
56 static const std::string ID("by_tangent_edge");
60 /// Central 2D point of the circle which contains the arc
61 inline static const std::string& CENTER_POINT_ID()
63 static const std::string ID = "center_point";
67 inline static const std::string& CENTER_POINT_REF_ID()
69 static const std::string ID = "center_point_ref";
73 /// Start 2D point of the arc
74 inline static const std::string& START_POINT_ID()
76 static const std::string ID = "start_point";
80 inline static const std::string& START_POINT_REF_ID()
82 static const std::string ID = "start_point_ref";
86 /// End 2D point of the arc
87 inline static const std::string& END_POINT_ID()
89 static const std::string ID = "end_point";
93 inline static const std::string& END_POINT_REF_ID()
95 static const std::string ID = "end_point_ref";
99 /// Passed point of the arc.
100 static const std::string& PASSED_POINT_ID()
102 static const std::string ID("passed_point");
106 static const std::string& PASSED_POINT_REF_ID()
108 static const std::string ID("passed_point_ref");
112 static const std::string& TANGENT_POINT_ID()
114 static const std::string ID("tangent_point");
119 inline static const std::string& REVERSED_ID()
121 static const std::string ID("reversed");
126 static const std::string& RADIUS_ID()
128 static const std::string ID("radius");
133 static const std::string& ANGLE_ID()
135 static const std::string ID("angle");
139 /// Returns the kind of a feature
140 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
142 static std::string MY_KIND = SketchPlugin_MacroArc::ID();
146 /// \brief Request for initialization of data model of the feature: adding all attributes.
147 SKETCHPLUGIN_EXPORT virtual void initAttributes();
149 /// Called on change of any argument-attribute of this object
150 /// \param theID identifier of changed attribute
151 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
153 /// Returns the AIS preview
154 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
156 /// Creates an arc-shape
157 SKETCHPLUGIN_EXPORT virtual void execute();
159 /// Moves the feature
160 /// \param theDeltaX the delta for X coordinate is moved
161 /// \param theDeltaY the delta for Y coordinate is moved
162 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
166 /// Reimplemented from ModelAPI_Feature::isMacro().
167 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
169 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
171 /// Use plugin manager for features creation.
172 SketchPlugin_MacroArc();
175 /// Set fields for center, start and end points
176 void fillByCenterAndTwoPassed();
177 /// Set fields for center, start and end points by selected passed points
178 void fillByThreePassedPoints();
179 /// Set fields for center, start and end points by selected tangent edge
180 void fillByTangentEdge();
182 FeaturePtr createArcFeature();
184 void recalculateReversedFlagByEnd(const GeomAPI_Circ2d& theCurrentCircular);
185 void recalculateReversedFlagByPassed(const GeomAPI_Circ2d& theCurrentCircular);
188 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
189 std::shared_ptr<GeomAPI_Pnt2d> myStart;
190 std::shared_ptr<GeomAPI_Pnt2d> myEnd;
192 /// To define in which direction draw arc.
193 double myParamBefore;