SHAPER  9.12.0
FeaturesPlugin_Measurement.h
1 // Copyright (C) 2018-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 FeaturesPlugin_Measurement_H_
21 #define FeaturesPlugin_Measurement_H_
22 
23 #include "FeaturesPlugin.h"
24 #include <ModelAPI_Feature.h>
25 
26 #include <GeomAPI_IPresentable.h>
27 #include <GeomAPI_IScreenParams.h>
28 
39  public GeomAPI_IPresentable,
41 {
42 public:
44  inline static const std::string& ID()
45  {
46  static const std::string MY_ID("Measurement");
47  return MY_ID;
48  }
49 
51  virtual const std::string& getKind()
52  {
53  return ID();
54  }
55 
57  inline static const std::string& MEASURE_KIND()
58  {
59  static const std::string MY_MEASURE_KIND_ID("MeasureKind");
60  return MY_MEASURE_KIND_ID;
61  }
62 
64  inline static const std::string& MEASURE_LENGTH()
65  {
66  static const std::string MY_MEASURE_ID("Length");
67  return MY_MEASURE_ID;
68  }
69 
71  inline static const std::string& MEASURE_DISTANCE()
72  {
73  static const std::string MY_MEASURE_ID("Distance");
74  return MY_MEASURE_ID;
75  }
76 
78  inline static const std::string& MEASURE_PROXIMITY()
79  {
80  static const std::string MY_MEASURE_ID("Proximity");
81  return MY_MEASURE_ID;
82  }
83 
85  inline static const std::string& MEASURE_RADIUS()
86  {
87  static const std::string MY_MEASURE_ID("Radius");
88  return MY_MEASURE_ID;
89  }
90 
92  inline static const std::string& MEASURE_ANGLE()
93  {
94  static const std::string MY_MEASURE_ID("Angle");
95  return MY_MEASURE_ID;
96  }
97 
99  inline static const std::string& MEASURE_ANGLE_POINTS()
100  {
101  static const std::string MY_MEASURE_ID("AngleBy3Points");
102  return MY_MEASURE_ID;
103  }
104 
105 
107  inline static const std::string& EDGE_FOR_LENGTH_ID()
108  {
109  static const std::string MY_EDGE_FOR_LENGTH_ID("edge_for_length");
110  return MY_EDGE_FOR_LENGTH_ID;
111  }
112 
114  inline static const std::string& DISTANCE_FROM_OBJECT_ID()
115  {
116  static const std::string MY_DISTANCE_FROM_OBJECT_ID("distance_from");
117  return MY_DISTANCE_FROM_OBJECT_ID;
118  }
119 
121  inline static const std::string& DISTANCE_TO_OBJECT_ID()
122  {
123  static const std::string MY_DISTANCE_TO_OBJECT_ID("distance_to");
124  return MY_DISTANCE_TO_OBJECT_ID;
125  }
126 
127  // Attribute name of edge or face selected to calculate radius.
128  inline static const std::string& CIRCULAR_OBJECT_ID()
129  {
130  static const std::string MY_CIRCULAR_OBJECT_ID("circular");
131  return MY_CIRCULAR_OBJECT_ID;
132  }
133 
135  inline static const std::string& ANGLE_FROM_EDGE_ID()
136  {
137  static const std::string MY_ANGLE_FROM_EDGE_ID("angle_from");
138  return MY_ANGLE_FROM_EDGE_ID;
139  }
140 
142  inline static const std::string& ANGLE_TO_EDGE_ID()
143  {
144  static const std::string MY_ANGLE_TO_EDGE_ID("angle_to");
145  return MY_ANGLE_TO_EDGE_ID;
146  }
147 
149  inline static const std::string& ANGLE_POINT1_ID()
150  {
151  static const std::string MY_ANGLE_POINT1_ID("angle_point_1");
152  return MY_ANGLE_POINT1_ID;
153  }
154 
156  inline static const std::string& ANGLE_POINT2_ID()
157  {
158  static const std::string MY_ANGLE_POINT2_ID("angle_point_2");
159  return MY_ANGLE_POINT2_ID;
160  }
161 
163  inline static const std::string& ANGLE_POINT3_ID()
164  {
165  static const std::string MY_ANGLE_POINT3_ID("angle_point_3");
166  return MY_ANGLE_POINT3_ID;
167  }
168 
170  inline static const std::string& RESULT_ID()
171  {
172  static const std::string MY_RESULT_ID("result");
173  return MY_RESULT_ID;
174  }
175 
177  inline static const std::string& RESULT_VALUES_ID()
178  {
179  static const std::string MY_RESULT_VALUES_ID("result_values");
180  return MY_RESULT_VALUES_ID;
181  }
182 
184  FEATURESPLUGIN_EXPORT virtual void execute();
185 
187  FEATURESPLUGIN_EXPORT virtual void initAttributes();
188 
191  FEATURESPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID);
192 
194  virtual bool isMacro() const { return true; }
195 
199  FEATURESPLUGIN_EXPORT virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
200 
203  virtual void setScreenPlane(GeomPlanePtr theScreenPlane) {
204  myScreenPlane = theScreenPlane;
205  }
206 
209  virtual void setViewScale(double theScale) {
210  mySceenScale = theScale;
211  }
212 
215 
216 private:
218  void computeLength();
220  void computeDistance();
222  void computeProximity();
224  void computeRadius();
226  void computeAngle();
228  void computeAngleByPoints();
229 
232  AISObjectPtr lengthDimension(AISObjectPtr thePrevious);
233 
236  AISObjectPtr distanceDimension(AISObjectPtr thePrevious);
237 
240  AISObjectPtr radiusDimension(AISObjectPtr thePrevious);
241 
244  AISObjectPtr angleDimension(AISObjectPtr thePrevious);
245 
248  AISObjectPtr angleByPointsDimension(AISObjectPtr thePrevious);
249 
251  void setupDimension(AISObjectPtr theDim);
252 
253  GeomPlanePtr myScreenPlane; //< a plane of current screen
254  double mySceenScale; //< a scale of current view
255 };
256 
257 #endif
Feature for calculation metrics.
Definition: FeaturesPlugin_Measurement.h:41
static const std::string & DISTANCE_FROM_OBJECT_ID()
Attribute name of first shape selected for distance calculation.
Definition: FeaturesPlugin_Measurement.h:114
virtual void setScreenPlane(GeomPlanePtr theScreenPlane)
Set current screen plane.
Definition: FeaturesPlugin_Measurement.h:203
static const std::string & EDGE_FOR_LENGTH_ID()
Attribute name of edge selected for length calculation.
Definition: FeaturesPlugin_Measurement.h:107
static const std::string & MEASURE_KIND()
Attribute name for measurement method.
Definition: FeaturesPlugin_Measurement.h:57
static const std::string & MEASURE_LENGTH()
Attribute name for length measure.
Definition: FeaturesPlugin_Measurement.h:64
static const std::string & ANGLE_POINT3_ID()
Attribute name of third point selected for angle calculation.
Definition: FeaturesPlugin_Measurement.h:163
virtual void initAttributes()
Request for initialization of data model of the feature: adding all attributes.
Definition: FeaturesPlugin_Measurement.cpp:60
virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious)
Returns the AIS preview.
Definition: FeaturesPlugin_Measurement.cpp:373
static const std::string & ANGLE_POINT2_ID()
Attribute name of second point (apex) selected for angle calculation.
Definition: FeaturesPlugin_Measurement.h:156
virtual bool isMacro() const
Reimplemented from ModelAPI_Feature::isMacro(). Returns true.
Definition: FeaturesPlugin_Measurement.h:194
static const std::string & ANGLE_FROM_EDGE_ID()
Attribute name of first edge selected for angle calculation.
Definition: FeaturesPlugin_Measurement.h:135
virtual const std::string & getKind()
Definition: FeaturesPlugin_Measurement.h:51
static const std::string & ANGLE_POINT1_ID()
Attribute name of first point selected for angle calculation.
Definition: FeaturesPlugin_Measurement.h:149
virtual void execute()
Performs the algorithm and stores results it in the data structure.
Definition: FeaturesPlugin_Measurement.cpp:84
static const std::string & RESULT_VALUES_ID()
Attribute name for values of result.
Definition: FeaturesPlugin_Measurement.h:177
static const std::string & ID()
Feature kind.
Definition: FeaturesPlugin_Measurement.h:44
static const std::string & MEASURE_ANGLE_POINTS()
Attribute name for angle measurement by 3 points.
Definition: FeaturesPlugin_Measurement.h:99
static const std::string & RESULT_ID()
Attribute name for result.
Definition: FeaturesPlugin_Measurement.h:170
static const std::string & MEASURE_RADIUS()
Attribute name for radius measure.
Definition: FeaturesPlugin_Measurement.h:85
static const std::string & MEASURE_ANGLE()
Attribute name for angle measure.
Definition: FeaturesPlugin_Measurement.h:92
static const std::string & DISTANCE_TO_OBJECT_ID()
Attribute name of second shape selected for distance calculation.
Definition: FeaturesPlugin_Measurement.h:121
FeaturesPlugin_Measurement()
Use plugin manager for features creation.
Definition: FeaturesPlugin_Measurement.cpp:56
virtual void setViewScale(double theScale)
Set current view scale.
Definition: FeaturesPlugin_Measurement.h:209
static const std::string & ANGLE_TO_EDGE_ID()
Attribute name of second shape selected for angle calculation.
Definition: FeaturesPlugin_Measurement.h:142
static const std::string & MEASURE_DISTANCE()
Attribute name for distance measure.
Definition: FeaturesPlugin_Measurement.h:71
static const std::string & MEASURE_PROXIMITY()
Attribute name for distance measure.
Definition: FeaturesPlugin_Measurement.h:78
virtual void attributeChanged(const std::string &theID)
Called on change of any argument-attribute of this object.
Definition: FeaturesPlugin_Measurement.cpp:88
A class which defines an interface of object which is able to create its own presentation.
Definition: GeomAPI_IPresentable.h:29
A class which defines an interface of object which has to be provided with current screen parameters.
Definition: GeomAPI_IScreenParams.h:30
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:39