SHAPER  9.15.0
SketchPlugin_MacroCircle.h
1 // Copyright (C) 2014-2025 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef SketchPlugin_MacroCircle_H_
21 #define SketchPlugin_MacroCircle_H_
22 
23 #include <ModelAPI_IReentrant.h>
24 
25 #include "SketchPlugin.h"
26 
27 #include "SketchPlugin_SketchEntity.h"
28 
29 #include <GeomAPI_IPresentable.h>
30 
31 class GeomAPI_Circ2d;
32 class GeomAPI_Pnt2d;
33 
39  public GeomAPI_IPresentable,
40  public ModelAPI_IReentrant
41 {
42  public:
44  inline static const std::string& ID()
45  {
46  static const std::string ID("SketchMacroCircle");
47  return ID;
48  }
49 
50  inline static const std::string& CIRCLE_TYPE()
51  {
52  static const std::string ID("circle_type");
53  return ID;
54  }
55 
56  inline static const std::string& EDIT_CIRCLE_TYPE()
57  {
58  static const std::string ID("edit_circle_type");
59  return ID;
60  }
61 
63  inline static const std::string& CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
64  {
65  static const std::string ID("circle_type_by_center_and_passed_points");
66  return ID;
67  }
68 
70  inline static const std::string& CIRCLE_TYPE_BY_THREE_POINTS()
71  {
72  static const std::string ID("circle_type_by_three_points");
73  return ID;
74  }
75 
77  inline static const std::string& CENTER_POINT_ID()
78  {
79  static const std::string ID("center_point");
80  return ID;
81  }
82 
84  inline static const std::string& CENTER_POINT_REF_ID()
85  {
86  static const std::string ID("center_point_ref");
87  return ID;
88  }
89 
91  inline static const std::string& PASSED_POINT_ID()
92  {
93  static const std::string ID("passed_point");
94  return ID;
95  }
96 
98  inline static const std::string& PASSED_POINT_REF_ID()
99  {
100  static const std::string ID("passed_point_ref");
101  return ID;
102  }
103 
105  inline static const std::string& FIRST_POINT_ID()
106  {
107  static const std::string ID("first_point");
108  return ID;
109  }
110 
112  inline static const std::string& FIRST_POINT_REF_ID()
113  {
114  static const std::string ID("first_point_ref");
115  return ID;
116  }
117 
119  inline static const std::string& SECOND_POINT_ID()
120  {
121  static const std::string ID("second_point");
122  return ID;
123  }
124 
126  inline static const std::string& SECOND_POINT_REF_ID()
127  {
128  static const std::string ID("second_point_ref");
129  return ID;
130  }
131 
133  inline static const std::string& THIRD_POINT_ID()
134  {
135  static const std::string ID("third_point");
136  return ID;
137  }
138 
140  inline static const std::string& THIRD_POINT_REF_ID()
141  {
142  static const std::string ID("third_point_ref");
143  return ID;
144  }
145 
147  inline static const std::string& CIRCLE_RADIUS_ID()
148  {
149  static const std::string ID("circle_radius");
150  return ID;
151  }
152 
154  inline static const std::string& ADD_CONSTRUCTION_POINT_ID()
155  {
156  static const std::string ID("add_construction_point");
157  return ID;
158  }
159 
161  inline static const std::string& CIRCLE_ROTATE_ANGLE_ID()
162  {
163  static const std::string ID("circle_angle");
164  return ID;
165  }
166 
168  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
169  {
170  static std::string MY_KIND = SketchPlugin_MacroCircle::ID();
171  return MY_KIND;
172  }
173 
175  SKETCHPLUGIN_EXPORT virtual void initAttributes();
176 
178  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
179 
181  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
182 
184  SKETCHPLUGIN_EXPORT virtual void execute();
185 
188  SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
189 
190  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
191 
194  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
195 
198 
199 private:
200  void fillByCenterAndPassed();
201  void fillByThreePoints();
203  void fillByTwoPassedPoints();
204 
205  void constraintsForCircleByCenterAndPassed(FeaturePtr theCircleFeature);
206  void constraintsForCircleByThreePoints(FeaturePtr theCircleFeature);
207 
208  void computeNewAngle(std::shared_ptr<GeomAPI_Circ2d>& theCircle);
209 
210  FeaturePtr createCircleFeature();
211 
212 private:
213  std::shared_ptr<GeomAPI_Pnt2d> myCenter;
214  double myRadius;
215 };
216 
217 #endif
Circle in 2D.
Definition: GeomAPI_Circ2d.h:37
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
2D point defined by two coordinates
Definition: GeomAPI_Pnt2d.h:36
Interface of a class which can process specific messages.
Definition: ModelAPI_IReentrant.h:35
Feature for creation of the new circle in Sketch.
Definition: SketchPlugin_MacroCircle.h:41
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroCircle.h:168
static const std::string & FIRST_POINT_ID()
First point id.
Definition: SketchPlugin_MacroCircle.h:105
static const std::string & CIRCLE_ROTATE_ANGLE_ID()
Rotate angle of the circle.
Definition: SketchPlugin_MacroCircle.h:161
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_MacroCircle.h:188
static const std::string & PASSED_POINT_ID()
2D point - passed point of the circle
Definition: SketchPlugin_MacroCircle.h:91
SketchPlugin_MacroCircle()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroCircle.cpp:71
static const std::string & CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()
Creation method by center and passed point.
Definition: SketchPlugin_MacroCircle.h:63
static const std::string & PASSED_POINT_REF_ID()
Reference for passed point selection.
Definition: SketchPlugin_MacroCircle.h:98
static const std::string & THIRD_POINT_REF_ID()
Reference for third point selection.
Definition: SketchPlugin_MacroCircle.h:140
virtual bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_MacroCircle.h:190
static const std::string & THIRD_POINT_ID()
Third point id.
Definition: SketchPlugin_MacroCircle.h:133
static const std::string & FIRST_POINT_REF_ID()
Reference for first point selection.
Definition: SketchPlugin_MacroCircle.h:112
static const std::string & CIRCLE_RADIUS_ID()
Radius of the circle.
Definition: SketchPlugin_MacroCircle.h:147
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_MacroCircle.cpp:124
static const std::string & SECOND_POINT_ID()
Second point id.
Definition: SketchPlugin_MacroCircle.h:119
static const std::string & CENTER_POINT_ID()
2D point - center of the circle.
Definition: SketchPlugin_MacroCircle.h:77
static const std::string & CENTER_POINT_REF_ID()
Reference for center point selection.
Definition: SketchPlugin_MacroCircle.h:84
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_MacroCircle.cpp:77
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_MacroCircle.cpp:146
static const std::string & SECOND_POINT_REF_ID()
Reference for second point selection.
Definition: SketchPlugin_MacroCircle.h:126
static const std::string & ADD_CONSTRUCTION_POINT_ID()
Is to create construction point or not.
Definition: SketchPlugin_MacroCircle.h:154
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_MacroCircle.cpp:439
static const std::string & ID()
Circle feature kind.
Definition: SketchPlugin_MacroCircle.h:44
static const std::string & CIRCLE_TYPE_BY_THREE_POINTS()
Creation method by three points.
Definition: SketchPlugin_MacroCircle.h:70
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_MacroCircle.cpp:392
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45