SHAPER  9.12.0
SketchPlugin_MacroEllipse.h
1 // Copyright (C) 2017-2023 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_MacroEllipse_H_
21 #define SketchPlugin_MacroEllipse_H_
22 
23 #include <ModelAPI_IReentrant.h>
24 #include <SketchPlugin.h>
25 #include <SketchPlugin_SketchEntity.h>
26 #include <GeomAPI_IPresentable.h>
27 
28 class GeomAPI_Pnt2d;
29 
35  public GeomAPI_IPresentable,
36  public ModelAPI_IReentrant
37 {
38  public:
40  inline static const std::string& ID()
41  {
42  static const std::string ID("SketchMacroEllipse");
43  return ID;
44  }
45 
46  static const std::string& ELLIPSE_TYPE()
47  {
48  static const std::string ID("ellipse_type");
49  return ID;
50  }
51 
52  static const std::string& ELLIPSE_TYPE_BY_CENTER_AXIS_POINT()
53  {
54  static const std::string ID("by_center_axis_point");
55  return ID;
56  }
57  static const std::string& ELLIPSE_TYPE_BY_AXIS_AND_POINT()
58  {
59  static const std::string ID("by_major_axis_and_point");
60  return ID;
61  }
62 
63  static const std::string& EDIT_ELLIPSE_TYPE()
64  {
65  static const std::string ID("edit_ellipse_type");
66  return ID;
67  }
68 
70  inline static const std::string& CENTER_POINT_ID()
71  {
72  static const std::string ID("first_point");
73  return ID;
74  }
75 
77  inline static const std::string& CENTER_POINT_REF_ID()
78  {
79  static const std::string ID("first_point_ref");
80  return ID;
81  }
82 
84  inline static const std::string& MAJOR_AXIS_POINT_ID()
85  {
86  static const std::string ID("second_point");
87  return ID;
88  }
89 
91  inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
92  {
93  static const std::string ID("second_point_ref");
94  return ID;
95  }
96 
98  inline static const std::string& PASSED_POINT_ID()
99  {
100  static const std::string ID("passed_point");
101  return ID;
102  }
103 
105  inline static const std::string& PASSED_POINT_REF_ID()
106  {
107  static const std::string ID("passed_point_ref");
108  return ID;
109  }
110 
112  inline static const std::string& MAJOR_AXIS_START_ID()
113  {
114  static const std::string ID("first_point_1");
115  return ID;
116  }
117 
119  inline static const std::string& MAJOR_AXIS_START_REF_ID()
120  {
121  static const std::string ID("first_point_ref_1");
122  return ID;
123  }
124 
126  inline static const std::string& MAJOR_AXIS_END_ID()
127  {
128  static const std::string ID("second_point_1");
129  return ID;
130  }
131 
133  inline static const std::string& MAJOR_AXIS_END_REF_ID()
134  {
135  static const std::string ID("second_point_ref_1");
136  return ID;
137  }
138 
140  inline static const std::string& PASSED_POINT_1_ID()
141  {
142  static const std::string ID("passed_point_1");
143  return ID;
144  }
145 
147  inline static const std::string& PASSED_POINT_1_REF_ID()
148  {
149  static const std::string ID("passed_point_ref_1");
150  return ID;
151  }
152 
154  inline static const std::string& MAJOR_RADIUS_ID()
155  {
156  static const std::string ID("major_radius");
157  return ID;
158  }
159 
161  inline static const std::string& MINOR_RADIUS_ID()
162  {
163  static const std::string ID("minor_radius");
164  return ID;
165  }
166 
168  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
169  {
170  static std::string MY_KIND = SketchPlugin_MacroEllipse::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
189  {return true;}
190 
191  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
192  {return false;}
193 
196  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
197 
200 
201 private:
202  void constraintsForEllipseByCenterAxisAndPassed(FeaturePtr theEllipseFeature);
203  void constraintsForEllipseByMajoxAxisAndPassed(FeaturePtr theEllipseFeature);
204 
205  FeaturePtr createEllipseFeature();
206 
207 private:
208  std::shared_ptr<GeomAPI_Pnt2d> myCenter;
209  std::shared_ptr<GeomAPI_Pnt2d> myFocus;
210  double myMajorRadius;
211  double myMinorRadius;
212 };
213 
214 #endif
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 ellipse in Sketch.
Definition: SketchPlugin_MacroEllipse.h:37
static const std::string & MAJOR_RADIUS_ID()
Major radius of the ellipse.
Definition: SketchPlugin_MacroEllipse.h:154
static const std::string & PASSED_POINT_REF_ID()
Reference for passed point selection.
Definition: SketchPlugin_MacroEllipse.h:105
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_MacroEllipse.cpp:208
static const std::string & MAJOR_AXIS_POINT_ID()
Attribute for the second point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:84
static const std::string & MINOR_RADIUS_ID()
Minor radius of the ellipse.
Definition: SketchPlugin_MacroEllipse.h:161
virtual SKETCHPLUGIN_EXPORT void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_MacroEllipse.cpp:56
static const std::string & ID()
Ellipse feature kind.
Definition: SketchPlugin_MacroEllipse.h:40
static const std::string & CENTER_POINT_ID()
Attribute for the first point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:70
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_MacroEllipse.cpp:356
static const std::string & MAJOR_AXIS_START_REF_ID()
Reference to the first selected point.
Definition: SketchPlugin_MacroEllipse.h:119
static const std::string & MAJOR_AXIS_START_ID()
Attribute for the first point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:112
static const std::string & PASSED_POINT_ID()
Attribute for the third point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:98
virtual SKETCHPLUGIN_EXPORT void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_MacroEllipse.cpp:113
virtual SKETCHPLUGIN_EXPORT const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroEllipse.h:168
static const std::string & PASSED_POINT_1_REF_ID()
Reference for passed point selection.
Definition: SketchPlugin_MacroEllipse.h:147
virtual SKETCHPLUGIN_EXPORT bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_MacroEllipse.h:191
static const std::string & MAJOR_AXIS_END_REF_ID()
Reference to the second selected point.
Definition: SketchPlugin_MacroEllipse.h:133
static const std::string & MAJOR_AXIS_END_ID()
Attribute for the second point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:126
SketchPlugin_MacroEllipse()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroEllipse.cpp:49
static const std::string & CENTER_POINT_REF_ID()
Reference to the first selected point.
Definition: SketchPlugin_MacroEllipse.h:77
virtual SKETCHPLUGIN_EXPORT bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_MacroEllipse.h:188
static const std::string & PASSED_POINT_1_ID()
Attribute for the third point selected during ellipse creation.
Definition: SketchPlugin_MacroEllipse.h:140
virtual SKETCHPLUGIN_EXPORT void execute()
Creates a new part document if needed.
Definition: SketchPlugin_MacroEllipse.cpp:92
static const std::string & MAJOR_AXIS_POINT_REF_ID()
Reference to the second selected point.
Definition: SketchPlugin_MacroEllipse.h:91
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45