SHAPER  9.12.0
SketchPlugin_MacroEllipticArc.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_MacroEllipticArc_H_
21 #define SketchPlugin_MacroEllipticArc_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 class GeomAPI_Shape;
30 
36  public GeomAPI_IPresentable,
37  public ModelAPI_IReentrant
38 {
39 public:
41  inline static const std::string& ID()
42  {
43  static const std::string ID("SketchMacroEllipticArc");
44  return ID;
45  }
46 
48  inline static const std::string& CENTER_ID()
49  {
50  static const std::string ID("center");
51  return ID;
52  }
53 
55  inline static const std::string& CENTER_REF_ID()
56  {
57  static const std::string ID("center_ref");
58  return ID;
59  }
60 
62  inline static const std::string& MAJOR_AXIS_POINT_ID()
63  {
64  static const std::string ID("major_axis_point");
65  return ID;
66  }
67 
69  inline static const std::string& MAJOR_AXIS_POINT_REF_ID()
70  {
71  static const std::string ID("major_axis_point_ref");
72  return ID;
73  }
74 
76  inline static const std::string& START_POINT_ID()
77  {
78  static const std::string ID("start_point");
79  return ID;
80  }
81 
83  inline static const std::string& START_POINT_REF_ID()
84  {
85  static const std::string ID("start_point_ref");
86  return ID;
87  }
88 
90  inline static const std::string& END_POINT_ID()
91  {
92  static const std::string ID("end_point");
93  return ID;
94  }
95 
97  inline static const std::string& END_POINT_REF_ID()
98  {
99  static const std::string ID("end_point_ref");
100  return ID;
101  }
102 
104  inline static const std::string& MAJOR_RADIUS_ID()
105  {
106  static const std::string ID("major_radius");
107  return ID;
108  }
109 
111  inline static const std::string& MINOR_RADIUS_ID()
112  {
113  static const std::string ID("minor_radius");
114  return ID;
115  }
116 
118  inline static const std::string& REVERSED_ID()
119  {
120  static const std::string ID("reversed");
121  return ID;
122  }
123 
125  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
126  {
127  static std::string MY_KIND = SketchPlugin_MacroEllipticArc::ID();
128  return MY_KIND;
129  }
130 
132  SKETCHPLUGIN_EXPORT virtual void initAttributes();
133 
135  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
136 
138  virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
139 
141  SKETCHPLUGIN_EXPORT virtual void execute();
142 
145  SKETCHPLUGIN_EXPORT virtual bool isMacro() const
146  {return true;}
147 
148  SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const
149  {return false;}
150 
153  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
154 
157 
158 private:
159  std::shared_ptr<GeomAPI_Shape> getArcShape();
160 
161  FeaturePtr createEllipticArcFeature();
162  void constraintsForEllipticArc(FeaturePtr theEllipticArc);
163 
164 private:
165  std::shared_ptr<GeomAPI_Pnt2d> myCenter;
166  std::shared_ptr<GeomAPI_Pnt2d> myMajorAxis;
167  std::shared_ptr<GeomAPI_Pnt2d> myStartPnt;
168  std::shared_ptr<GeomAPI_Pnt2d> myEndPnt;
169  double myMajorRadius;
170  double myMinorRadius;
171  double myParamDelta;
172 };
173 
174 #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 to the topological shape object.
Definition: GeomAPI_Shape.h:43
Interface of a class which can process specific messages.
Definition: ModelAPI_IReentrant.h:35
Feature for creation of the new elliptic arc in Sketch.
Definition: SketchPlugin_MacroEllipticArc.h:38
static const std::string & ID()
Elliptic arc feature kind.
Definition: SketchPlugin_MacroEllipticArc.h:41
virtual SKETCHPLUGIN_EXPORT void execute()
Creates a new part document if needed.
Definition: SketchPlugin_MacroEllipticArc.cpp:84
static const std::string & MINOR_RADIUS_ID()
Minor radius of the ellipse.
Definition: SketchPlugin_MacroEllipticArc.h:111
SketchPlugin_MacroEllipticArc()
Use plugin manager for features creation.
Definition: SketchPlugin_MacroEllipticArc.cpp:50
static const std::string & CENTER_ID()
Attribute for the central point selected during elliptic arc creation.
Definition: SketchPlugin_MacroEllipticArc.h:48
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_MacroEllipticArc.cpp:186
static const std::string & START_POINT_ID()
Attribute for the start point of the elliptic arc selected during creation.
Definition: SketchPlugin_MacroEllipticArc.h:76
static const std::string & START_POINT_REF_ID()
Reference for the start point selection.
Definition: SketchPlugin_MacroEllipticArc.h:83
static const std::string & CENTER_REF_ID()
Reference to the first selected point (center of ellipse).
Definition: SketchPlugin_MacroEllipticArc.h:55
virtual SKETCHPLUGIN_EXPORT void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_MacroEllipticArc.cpp:97
static const std::string & MAJOR_AXIS_POINT_ID()
Attribute for the point on major semi-axis selected during elliptic arc creation.
Definition: SketchPlugin_MacroEllipticArc.h:62
static const std::string & MAJOR_AXIS_POINT_REF_ID()
Reference to the second selected point (major semi-axis of the ellipse).
Definition: SketchPlugin_MacroEllipticArc.h:69
virtual SKETCHPLUGIN_EXPORT bool isPreviewNeeded() const
Returns true if preview update during the edition needed.
Definition: SketchPlugin_MacroEllipticArc.h:148
virtual SKETCHPLUGIN_EXPORT bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro().
Definition: SketchPlugin_MacroEllipticArc.h:145
virtual SKETCHPLUGIN_EXPORT void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_MacroEllipticArc.cpp:58
static const std::string & END_POINT_REF_ID()
Reference for the end point selection.
Definition: SketchPlugin_MacroEllipticArc.h:97
static const std::string & REVERSED_ID()
Flag the arc is reversed.
Definition: SketchPlugin_MacroEllipticArc.h:118
static const std::string & MAJOR_RADIUS_ID()
Major radius of the ellipse.
Definition: SketchPlugin_MacroEllipticArc.h:104
static const std::string & END_POINT_ID()
Attribute for the end point of the elliptic arc selected during creation.
Definition: SketchPlugin_MacroEllipticArc.h:90
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_MacroEllipticArc.cpp:335
virtual SKETCHPLUGIN_EXPORT const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_MacroEllipticArc.h:125
Sketch Entity for creation of the new feature in PartSet.
Definition: SketchPlugin_SketchEntity.h:45