SHAPER  9.15.0
SketchPlugin_ConstraintAngle.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_ConstraintAngle_H_
21 #define SketchPlugin_ConstraintAngle_H_
22 
23 #include "SketchPlugin.h"
24 #include "SketchPlugin_Sketch.h"
25 #include "SketchPlugin_ConstraintBase.h"
26 
27 #include <ModelAPI_IReentrant.h>
28 
29 #include <limits>
30 
39  public ModelAPI_IReentrant
40 {
41 public:
43  inline static const std::string& ID()
44  {
45  static const std::string MY_CONSTRAINT_ANGLE_ID("SketchConstraintAngle");
46  return MY_CONSTRAINT_ANGLE_ID;
47  }
49  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
50  {
51  static std::string MY_KIND = SketchPlugin_ConstraintAngle::ID();
52  return MY_KIND;
53  }
54 
56  inline static const std::string& TYPE_ID()
57  {
58  static const std::string MY_TYPE_ID("AngleType");
59  return MY_TYPE_ID;
60  }
62  inline static const std::string& PREV_TYPE_ID()
63  {
64  static const std::string MY_TYPE_ID("AngleTypePrevious");
65  return MY_TYPE_ID;
66  }
67 
69  inline static const std::string& ANGLE_VALUE_ID()
70  {
71  static const std::string MY_ANGLE_VALUE_ID("AngleValue");
72  return MY_ANGLE_VALUE_ID;
73  }
74 
76  inline static const std::string& ANGLE_REVERSED_FIRST_LINE_ID()
77  {
78  static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine1");
79  return MY_ANGLE_REVERSED_ID;
80  }
82  inline static const std::string& ANGLE_REVERSED_SECOND_LINE_ID()
83  {
84  static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine2");
85  return MY_ANGLE_REVERSED_ID;
86  }
87 
89  inline static const std::string& LOCATION_TYPE_ID()
90  {
91  static const std::string MY_LOCATION_TYPE_ID("LocationType");
92  return MY_LOCATION_TYPE_ID;
93  }
94 
96  inline static const std::string& SELECTED_FIRST_POINT_ID()
97  {
98  static const std::string MY_SELECTED_FIRST_POINT_ID("SelectedPointA");
99  return MY_SELECTED_FIRST_POINT_ID;
100  }
101 
103  inline static const std::string& SELECTED_SECOND_POINT_ID()
104  {
105  static const std::string MY_SELECTED_SECOND_POINT_ID("SelectedPointB");
106  return MY_SELECTED_SECOND_POINT_ID;
107  }
108 
109 public:
110  static const int THE_VERSION_0 = 0;
111  static const int THE_VERSION_1 = 20191210;
112 
114  inline static const std::string& VERSION_ID()
115  {
116  static const std::string MY_VERSION_ID("version");
117  return MY_VERSION_ID;
118  }
119 
120 public:
122  SKETCHPLUGIN_EXPORT virtual void execute();
123 
127  SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
128 
130  SKETCHPLUGIN_EXPORT virtual void initAttributes();
131 
133  SKETCHPLUGIN_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
134  std::string& theDefault);
135 
138  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
139 
141  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
142 
145  void setNumericValue(const double theValue) override;
146 
148  inline double getNumericValue() override
149  {
150  return real(ANGLE_VALUE_ID())? real(ANGLE_VALUE_ID())->value() : std::numeric_limits<double>::lowest();
151  }
152 
155  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
156 
159 
160 protected:
162  void calculateAngle();
163 
165  void calculateAnglePosition();
166 
171  double getAngleForType(double theAngle, bool isReversed1 = false, bool isReversed2 = false);
172 
174  void updateAngleValue();
175 
177  void updateVersion();
178 
179 private:
180  bool myFlyoutUpdate;
181 };
182 
183 #endif
std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)
Returns the real attribute by the identifier.
Definition: ModelAPI_Feature.h:211
Interface of a class which can process specific messages.
Definition: ModelAPI_IReentrant.h:35
Feature for creation of a new constraint fix angle between two lines.
Definition: SketchPlugin_ConstraintAngle.h:40
static const std::string & LOCATION_TYPE_ID()
attribute name of dimension location type
Definition: SketchPlugin_ConstraintAngle.h:89
double getAngleForType(double theAngle, bool isReversed1=false, bool isReversed2=false)
Converts the angle value according to the current angle type and sketch plane normal.
Definition: SketchPlugin_ConstraintAngle.cpp:328
SketchPlugin_ConstraintAngle()
Use plugin manager for features creation.
Definition: SketchPlugin_ConstraintAngle.cpp:68
double getNumericValue() override
Get numeric value of attribute MY_ANGLE_VALUE_ID()
Definition: SketchPlugin_ConstraintAngle.h:148
static const std::string & VERSION_ID()
Attribute name of the version of Angle feature.
Definition: SketchPlugin_ConstraintAngle.h:114
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_ConstraintAngle.h:49
static const std::string & PREV_TYPE_ID()
attribute name of previous value of operation type
Definition: SketchPlugin_ConstraintAngle.h:62
void updateVersion()
Update parameters of the Angle to meet requirements for the latest version.
Definition: SketchPlugin_ConstraintAngle.cpp:542
static const std::string & ANGLE_REVERSED_FIRST_LINE_ID()
attribute name indicating the first line is reversed
Definition: SketchPlugin_ConstraintAngle.h:76
static const std::string & TYPE_ID()
attribute name of operation type
Definition: SketchPlugin_ConstraintAngle.h:56
virtual void colorConfigInfo(std::string &theSection, std::string &theName, std::string &theDefault)
Returns the parameters of color definition in the resources config manager.
Definition: SketchPlugin_ConstraintAngle.cpp:122
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: SketchPlugin_ConstraintAngle.cpp:73
void calculateAngle()
Calculate current value of the angle.
Definition: SketchPlugin_ConstraintAngle.cpp:222
static const std::string & ID()
Angle constraint kind.
Definition: SketchPlugin_ConstraintAngle.h:43
static const std::string & SELECTED_SECOND_POINT_ID()
attribute name indicating the second point selected
Definition: SketchPlugin_ConstraintAngle.h:103
void updateAngleValue()
Update value of ANGLE_VALUE attribute according to the current type.
Definition: SketchPlugin_ConstraintAngle.cpp:438
static const std::string & SELECTED_FIRST_POINT_ID()
attribute name indicating the first point selected
Definition: SketchPlugin_ConstraintAngle.h:96
virtual bool compute(const std::string &theAttributeId)
Computes the attribute value on the base of other attributes if the value can be computed.
Definition: SketchPlugin_ConstraintAngle.cpp:462
void calculateAnglePosition()
Compute the position of the angle presentation (the quarter selected by the user)
Definition: SketchPlugin_ConstraintAngle.cpp:260
static const std::string & ANGLE_REVERSED_SECOND_LINE_ID()
attribute name indicating the second line is reversed
Definition: SketchPlugin_ConstraintAngle.h:82
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_ConstraintAngle.cpp:157
void setNumericValue(const double theValue) override
Set numeric value to attribute ANGLE_VALUE_ID()
Definition: SketchPlugin_ConstraintAngle.cpp:169
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_ConstraintAngle.cpp:193
static const std::string & ANGLE_VALUE_ID()
attribute name of operation type
Definition: SketchPlugin_ConstraintAngle.h:69
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_ConstraintAngle.cpp:130
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_ConstraintAngle.cpp:176
Feature for creation of a new constraint between other features.
Definition: SketchPlugin_ConstraintBase.h:56