1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: SketchPlugin_Arc.h
4 // Created: 26 May 2014
5 // Author: Artem ZHIDKOV
7 #ifndef SketchPlugin_Arc_H_
8 #define SketchPlugin_Arc_H_
10 #include "SketchPlugin.h"
11 #include <SketchPlugin_SketchEntity.h>
12 #include <SketchPlugin_Sketch.h>
13 #include <GeomAPI_IPresentable.h>
15 /**\class SketchPlugin_Arc
17 * \brief Feature for creation of the new arc of circle in PartSet.
18 * The visualization of this object is separated in two parts. The first one is an AIS object
19 * calculated when there is non-initialized attributes of the arc. The second is a result and
20 * it is calculated if all attributes are initialized.
22 class SketchPlugin_Arc : public SketchPlugin_SketchEntity, public GeomAPI_IPresentable
24 /// to avoid cyclic dependencies in automatic updates: they mean that
25 /// update is performed right now and automatic updates are not needed
26 bool myStartUpdate, myEndUpdate;
27 /// to avoid (if possible) additional modification of changed coordinate (issue #855)
28 double myXEndBefore, myYEndBefore;
30 /// to define in which direction draw arc
35 inline static const std::string& ID()
37 static const std::string MY_SKETCH_ARC_ID("SketchArc");
38 return MY_SKETCH_ARC_ID;
41 inline static const std::string& ARC_TYPE()
43 static const std::string TYPE("ArcType");
47 inline static const std::string& ARC_TYPE_TANGENT()
49 static const std::string TYPE("Tangent");
53 static const std::string& TANGENT_POINT_ID()
55 static const std::string TANGENT_PNT("ArcTangentPoint");
59 /// Central 2D point of the circle which contains the arc
60 inline static const std::string& CENTER_ID()
62 static const std::string MY_CENTER_ID = "ArcCenter";
65 /// Start 2D point of the arc
66 inline static const std::string& START_ID()
68 static const std::string MY_START_ID = "ArcStartPoint";
71 /// End 2D point of the arc
72 inline static const std::string& END_ID()
74 static const std::string MY_END_ID = "ArcEndPoint";
79 inline static const std::string& INVERSED_ID()
81 static const std::string MY_INVERSED_ID("InversedArc");
82 return MY_INVERSED_ID;
85 /// Returns the kind of a feature
86 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
88 static std::string MY_KIND = SketchPlugin_Arc::ID();
92 /// Returns true is sketch element is under the rigid constraint
93 SKETCHPLUGIN_EXPORT virtual bool isFixed();
95 /// Creates an arc-shape
96 SKETCHPLUGIN_EXPORT virtual void execute();
98 /// Called on change of any argument-attribute of this object
99 /// \param theID identifier of changed attribute
100 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
102 /// Returns the AIS preview
103 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
105 /// Moves the feature
106 /// \param theDeltaX the delta for X coordinate is moved
107 /// \param theDeltaY the delta for Y coordinate is moved
108 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY);
110 /// Updates the "reversed" flag
111 /// \param isReversed whether the arc will be reversed
112 void setReversed(bool isReversed);
113 /// Returns \c true is the arc is reversed
116 /// Use plugin manager for features creation
120 /// \brief Initializes attributes of derived class.
121 virtual void initDerivedClassAttributes();
124 /// Returns true if all obligatory attributes are initialized
125 bool isFeatureValid();
127 /// Update attributes like passed point, radius and angle of the arc
128 void updateDependentAttributes();
130 /// Compose constraints to build tangency arc
131 void tangencyArcConstraints();
133 /// Project end point of arc to the circle
134 void projectEndPoint();