SHAPER 9.16.0
SketchPlugin_MacroArc.h
1// Copyright (C) 2014-2026 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_MacroArc_H_
21#define SketchPlugin_MacroArc_H_
22
23#include <ModelAPI_IReentrant.h>
24
25#include "SketchPlugin.h"
26#include "SketchPlugin_SketchEntity.h"
27
28#include <GeomAPI_IPresentable.h>
29
30class GeomAPI_Circ2d;
31class GeomAPI_Pnt2d;
32
43{
44 public:
46 inline static const std::string& ID()
47 {
48 static const std::string ID("SketchMacroArc");
49 return ID;
50 }
51
52 inline static const std::string& ARC_TYPE()
53 {
54 static const std::string ID("arc_type");
55 return ID;
56 }
57
58 static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS()
59 {
60 static const std::string ID("by_center_and_points");
61 return ID;
62 }
63 static const std::string& ARC_TYPE_BY_THREE_POINTS()
64 {
65 static const std::string ID("by_three_points");
66 return ID;
67 }
68
69 inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE()
70 {
71 static const std::string ID("by_tangent_edge");
72 return ID;
73 }
74
75 inline static const std::string& ARC_TYPE_BY_TRANSVERSAL_LINE()
76 {
77 static const std::string ID("by_transversal_line");
78 return ID;
79 }
80
82 inline static const std::string& CENTER_POINT_ID()
83 {
84 static const std::string ID = "center_point";
85 return ID;
86 }
87
88 inline static const std::string& CENTER_POINT_REF_ID()
89 {
90 static const std::string ID = "center_point_ref";
91 return ID;
92 }
93
95 inline static const std::string& START_POINT_1_ID()
96 {
97 static const std::string ID = "start_point_1";
98 return ID;
99 }
100
102 inline static const std::string& START_POINT_2_ID()
103 {
104 static const std::string ID = "start_point_2";
105 return ID;
106 }
107
108 inline static const std::string& START_POINT_REF_ID()
109 {
110 static const std::string ID = "start_point_ref";
111 return ID;
112 }
113
115 inline static const std::string& END_POINT_1_ID()
116 {
117 static const std::string ID = "end_point_1";
118 return ID;
119 }
120
122 inline static const std::string& END_POINT_2_ID()
123 {
124 static const std::string ID = "end_point_2";
125 return ID;
126 }
127
129 inline static const std::string& END_POINT_3_ID()
130 {
131 static const std::string ID = "end_point_3";
132 return ID;
133 }
134
136 inline static const std::string& END_POINT_4_ID()
137 {
138 static const std::string ID = "end_point_4";
139 return ID;
140 }
141
142 inline static const std::string& END_POINT_REF_ID()
143 {
144 static const std::string ID = "end_point_ref";
145 return ID;
146 }
147
149 static const std::string& PASSED_POINT_ID()
150 {
151 static const std::string ID("passed_point");
152 return ID;
153 }
154
155 static const std::string& PASSED_POINT_REF_ID()
156 {
157 static const std::string ID("passed_point_ref");
158 return ID;
159 }
160
161 static const std::string& TANGENT_POINT_ID()
162 {
163 static const std::string ID("tangent_point");
164 return ID;
165 }
166
167 static const std::string& TRANSVERSAL_POINT_ID()
168 {
169 static const std::string ID("transversal_point");
170 return ID;
171 }
172
174 inline static const std::string& REVERSED_ID()
175 {
176 static const std::string ID("reversed");
177 return ID;
178 }
179
181 static const std::string& RADIUS_ID()
182 {
183 static const std::string ID("radius");
184 return ID;
185 }
186
188 static const std::string& ANGLE_ID()
189 {
190 static const std::string ID("angle");
191 return ID;
192 }
193
195 static const std::string& EDIT_ARC_TYPE_ID()
196 {
197 static const std::string ID("edit_arc_type");
198 return ID;
199 }
200
202 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
203 {
204 static std::string MY_KIND = SketchPlugin_MacroArc::ID();
205 return MY_KIND;
206 }
207
209 SKETCHPLUGIN_EXPORT virtual void initAttributes();
210
213 SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
214
216 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
217
219 SKETCHPLUGIN_EXPORT virtual void execute();
220
222 SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;};
223
224 SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;};
225
228 virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
229
232
235 GeomShapePtr getArcShape(bool isBound = true);
236
237private:
239 void fillByCenterAndTwoPassed();
241 void fillByThreePassedPoints();
244 void fillByEdge(bool theTransversal);
245
246 FeaturePtr createArcFeature();
247
248 void recalculateReversedFlagByEnd(const GeomAPI_Circ2d& theCurrentCircular);
249 void recalculateReversedFlagByPassed(const GeomAPI_Circ2d& theCurrentCircular);
250
251private:
252 std::shared_ptr<GeomAPI_Pnt2d> myCenter;
253 std::shared_ptr<GeomAPI_Pnt2d> myStart;
254 std::shared_ptr<GeomAPI_Pnt2d> myEnd;
255
257 double myParamBefore;
258};
259
260#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:36
Feature for creation of the new arc of circle in PartSet.
Definition: SketchPlugin_MacroArc.h:43
static const std::string & CENTER_POINT_ID()
Central 2D point of the circle which contains the arc.
Definition: SketchPlugin_MacroArc.h:82
virtual bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_MacroArc.h:224
static const std::string & RADIUS_ID()
Arc radius.
Definition: SketchPlugin_MacroArc.h:181
SketchPlugin_MacroArc()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroArc.cpp:136
static const std::string & START_POINT_2_ID()
Start 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:102
static const std::string & END_POINT_4_ID()
End 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:136
static const std::string & END_POINT_1_ID()
End 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:115
static const std::string & ID()
Arc feature kind.
Definition: SketchPlugin_MacroArc.h:46
static const std::string & END_POINT_2_ID()
End 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:122
static const std::string & EDIT_ARC_TYPE_ID()
Arc angle.
Definition: SketchPlugin_MacroArc.h:195
virtual void execute()
Creates an arc-shape.
Definition: SketchPlugin_MacroArc.cpp:309
GeomShapePtr getArcShape(bool isBound=true)
Returns shape of arc.
Definition: SketchPlugin_MacroArc.cpp:251
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_MacroArc.h:222
static const std::string & ANGLE_ID()
Arc angle.
Definition: SketchPlugin_MacroArc.h:188
static const std::string & PASSED_POINT_ID()
Passed point of the arc.
Definition: SketchPlugin_MacroArc.h:149
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_MacroArc.cpp:282
static const std::string & REVERSED_ID()
Reversed flag.
Definition: SketchPlugin_MacroArc.h:174
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroArc.h:202
static const std::string & START_POINT_1_ID()
Start 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:95
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_MacroArc.cpp:395
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_MacroArc.cpp:184
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_MacroArc.cpp:142
static const std::string & END_POINT_3_ID()
End 2D point of the arc.
Definition: SketchPlugin_MacroArc.h:129
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45