SHAPER  9.12.0
SketchPlugin_ConstraintAngle.h
1 // Copyright (C) 2014-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_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 
37  public ModelAPI_IReentrant
38 {
39 public:
41  inline static const std::string& ID()
42  {
43  static const std::string MY_CONSTRAINT_ANGLE_ID("SketchConstraintAngle");
44  return MY_CONSTRAINT_ANGLE_ID;
45  }
47  SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
48  {
49  static std::string MY_KIND = SketchPlugin_ConstraintAngle::ID();
50  return MY_KIND;
51  }
52 
54  inline static const std::string& TYPE_ID()
55  {
56  static const std::string MY_TYPE_ID("AngleType");
57  return MY_TYPE_ID;
58  }
60  inline static const std::string& PREV_TYPE_ID()
61  {
62  static const std::string MY_TYPE_ID("AngleTypePrevious");
63  return MY_TYPE_ID;
64  }
65 
67  inline static const std::string& ANGLE_VALUE_ID()
68  {
69  static const std::string MY_ANGLE_VALUE_ID("AngleValue");
70  return MY_ANGLE_VALUE_ID;
71  }
72 
74  inline static const std::string& ANGLE_REVERSED_FIRST_LINE_ID()
75  {
76  static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine1");
77  return MY_ANGLE_REVERSED_ID;
78  }
80  inline static const std::string& ANGLE_REVERSED_SECOND_LINE_ID()
81  {
82  static const std::string MY_ANGLE_REVERSED_ID("AngleReversedLine2");
83  return MY_ANGLE_REVERSED_ID;
84  }
85 
87  inline static const std::string& LOCATION_TYPE_ID()
88  {
89  static const std::string MY_LOCATION_TYPE_ID("LocationType");
90  return MY_LOCATION_TYPE_ID;
91  }
92 
94  inline static const std::string& SELECTED_FIRST_POINT_ID()
95  {
96  static const std::string MY_SELECTED_FIRST_POINT_ID("SelectedPointA");
97  return MY_SELECTED_FIRST_POINT_ID;
98  }
99 
101  inline static const std::string& SELECTED_SECOND_POINT_ID()
102  {
103  static const std::string MY_SELECTED_SECOND_POINT_ID("SelectedPointB");
104  return MY_SELECTED_SECOND_POINT_ID;
105  }
106 
107 public:
108  static const int THE_VERSION_0 = 0;
109  static const int THE_VERSION_1 = 20191210;
110 
112  inline static const std::string& VERSION_ID()
113  {
114  static const std::string MY_VERSION_ID("version");
115  return MY_VERSION_ID;
116  }
117 
118 public:
120  SKETCHPLUGIN_EXPORT virtual void execute();
121 
125  SKETCHPLUGIN_EXPORT virtual bool compute(const std::string& theAttributeId);
126 
128  SKETCHPLUGIN_EXPORT virtual void initAttributes();
129 
131  SKETCHPLUGIN_EXPORT virtual void colorConfigInfo(std::string& theSection, std::string& theName,
132  std::string& theDefault);
133 
136  SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
137 
139  SKETCHPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
140 
143  virtual std::string processEvent(const std::shared_ptr<Events_Message>& theMessage);
144 
147 
148 protected:
150  void calculateAngle();
151 
153  void calculateAnglePosition();
154 
159  double getAngleForType(double theAngle, bool isReversed1 = false, bool isReversed2 = false);
160 
162  void updateAngleValue();
163 
165  void updateVersion();
166 
167 private:
168  bool myFlyoutUpdate;
169 };
170 
171 #endif
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:38
static const std::string & LOCATION_TYPE_ID()
attribute name of dimension location type
Definition: SketchPlugin_ConstraintAngle.h:87
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:316
SketchPlugin_ConstraintAngle()
Use plugin manager for features creation.
Definition: SketchPlugin_ConstraintAngle.cpp:68
static const std::string & VERSION_ID()
Attribute name of the version of Angle feature.
Definition: SketchPlugin_ConstraintAngle.h:112
virtual const std::string & getKind()
Returns the kind of a feature.
Definition: SketchPlugin_ConstraintAngle.h:47
static const std::string & PREV_TYPE_ID()
attribute name of previous value of operation type
Definition: SketchPlugin_ConstraintAngle.h:60
void updateVersion()
Update parameters of the Angle to meet requirements for the latest version.
Definition: SketchPlugin_ConstraintAngle.cpp:530
static const std::string & ANGLE_REVERSED_FIRST_LINE_ID()
attribute name indicating the first line is reversed
Definition: SketchPlugin_ConstraintAngle.h:74
static const std::string & TYPE_ID()
attribute name of operation type
Definition: SketchPlugin_ConstraintAngle.h:54
virtual void colorConfigInfo(std::string &theSection, std::string &theName, std::string &theDefault)
Retuns the parameters of color definition in the resources config manager.
Definition: SketchPlugin_ConstraintAngle.cpp:116
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:210
static const std::string & ID()
Angle constraint kind.
Definition: SketchPlugin_ConstraintAngle.h:41
static const std::string & SELECTED_SECOND_POINT_ID()
attribute name indicating the second point selected
Definition: SketchPlugin_ConstraintAngle.h:101
void updateAngleValue()
Update value of ANGLE_VALUE attribute according to the current type.
Definition: SketchPlugin_ConstraintAngle.cpp:426
static const std::string & SELECTED_FIRST_POINT_ID()
attribute name indicating the first point selected
Definition: SketchPlugin_ConstraintAngle.h:94
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:450
void calculateAnglePosition()
Compute the position of the angle presentation (the quarter selected by the user)
Definition: SketchPlugin_ConstraintAngle.cpp:248
static const std::string & ANGLE_REVERSED_SECOND_LINE_ID()
attribute name indicating the second line is reversed
Definition: SketchPlugin_ConstraintAngle.h:80
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: SketchPlugin_ConstraintAngle.cpp:151
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: SketchPlugin_ConstraintAngle.cpp:181
static const std::string & ANGLE_VALUE_ID()
attribute name of operation type
Definition: SketchPlugin_ConstraintAngle.h:67
virtual void execute()
Creates a new part document if needed.
Definition: SketchPlugin_ConstraintAngle.cpp:124
virtual std::string processEvent(const std::shared_ptr< Events_Message > &theMessage)
Apply information of the message to current object.
Definition: SketchPlugin_ConstraintAngle.cpp:164
Feature for creation of a new constraint between other features.
Definition: SketchPlugin_ConstraintBase.h:56