Salome HOME
Updated copyright comment
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Tools.h
1 // Copyright (C) 2014-2024  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 SketcherPrs_Tools_H
21 #define SketcherPrs_Tools_H
22
23 #include "SketcherPrs.h"
24 #include <GeomAPI_Shape.h>
25 #include <GeomAPI_Pnt2d.h>
26 #include <GeomAPI_Ax3.h>
27 #include <ModelAPI_Object.h>
28 #include <ModelAPI_Attribute.h>
29 #include <ModelAPI_Feature.h>
30 #include <ModelAPI_CompositeFeature.h>
31 #include <ModelAPI_Result.h>
32 #include <string>
33
34 #include <Events_Loop.h>
35 #include <Events_Message.h>
36
37 class GeomDataAPI_Point2D;
38
39 namespace SketcherPrs_Tools {
40
41   /// \enum ParameterStyle lists styles of parameter
42   enum ParameterStyle {
43     ParameterValue, ///< using symbol with the parameter value
44     ParameterText ///< using parameter text
45   };
46
47   /// Set dimensions parameters style
48   /// \param theStyle new style
49   SKETCHERPRS_EXPORT void setParameterStyle(ParameterStyle theStyle);
50
51   /// Return dimensions parameters style
52   SKETCHERPRS_EXPORT ParameterStyle parameterStyle();
53
54   /// Enumeration with modes for activation of selection custom presentations
55   enum SelectionModes {
56     /// Start of enumeration
57     Sel_Mode_First = 100,
58
59     /// Selection mode for all constraints exclude dimensions
60     Sel_Constraint,
61
62     /// Selection mode for whole dimension
63     Sel_Dimension_All,
64
65     /// Selection mode for line of dimension
66     Sel_Dimension_Line,
67
68     /// Selection mode for text of dimension
69     Sel_Dimension_Text,
70
71     /// Selectiom mode for faces selection on sketch
72     Sel_Sketch_Face,
73
74     /// Selectiom mode for wires selection on sketch
75     Sel_Sketch_Wire
76   };
77
78   /// Type of angle
79   enum AngleType{
80     ANGLE_DIRECT,   ///< Angle from the first line to the second line
81     ANGLE_COMPLEMENTARY,  ///< Additional angle to the angle from first to second line
82     ANGLE_BACKWARD ///< Angle from the second line to the first line
83   };
84
85   /// Type of dimension location
86   enum LocationType{
87     LOCATION_RIGHT,   ///< Position is marked by right arrow placed on the left
88     LOCATION_AUTOMATIC,  ///< Position is marked by two arrow placed on the both sides
89     LOCATION_LEFT ///< Position is marked by left arrow placed on the left
90   };
91
92   /// Event ID about expression visual state has been changed, the symbol with a digit
93   /// or parameter text is shown
94
95   /// Returns attribute object referenced by feature
96   /// \param theFeature a feature
97   /// \param theAttrName an attribute name
98   SKETCHERPRS_EXPORT AttributePtr getAttribute(ModelAPI_Feature* theFeature,
99                                                const std::string& theAttrName);
100
101   /// Returns result object referenced by feature
102   /// \param theFeature a feature
103   /// \param theAttrName an attribute name
104   SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
105                                          const std::string& theAttrName);
106
107   /// Returns shape from result object (or NULL)
108   /// \param theObject a result object
109   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
110
111
112   /// Returns point from a line feature
113   /// \param theFeature a line feature
114   /// \param theAttrName an attribute of the point
115   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
116                                           const std::string& theAttrName);
117
118
119   /// Returns point projected on a line
120   /// \param theLine  a line
121   /// \param thePoint a projecting point
122   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
123                         const FeaturePtr theLine,
124                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
125
126   SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
127                                                const std::string& theAttribute);
128
129   /// Obtain the point object from specified constraint parameter
130   /// \param theData a data object
131   /// \param theAttribute an attribute name
132   /// \param thePlane a projection plane (sketcher plane)
133   SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
134                                                const std::string& theAttribute,
135                                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
136
137   /// Collect all sketch points which are not connected with other entities.
138   /// \param theSketch sketch feature
139   /// \return list of results of SketchPlugin_Point features
140   SKETCHERPRS_EXPORT std::list<ResultPtr> getFreePoints(const CompositeFeaturePtr& theSketch);
141
142   /// Returns value of dimension arrows size
143   SKETCHERPRS_EXPORT double getArrowSize();
144
145   /// Set value of dimension arrows size
146   /// \param theSize a size value
147   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
148
149   /// Returns default value of dimension arrows size
150   SKETCHERPRS_EXPORT int getDefaultArrowSize();
151
152   /// Returns value of dimension arrows size set in preferences
153   SKETCHERPRS_EXPORT int getConfigArrowSize();
154
155   /// Set value of dimension text height
156   /// \param theHeight a height value
157   SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
158
159   /// Returns value of dimension text height
160   SKETCHERPRS_EXPORT double getTextHeight();
161
162   /// Returns default value of dimension text height
163   SKETCHERPRS_EXPORT double getDefaultTextHeight();
164
165   /// Returns value of dimension text height set in preferences
166   SKETCHERPRS_EXPORT double getConfigTextHeight();
167
168   /// Get flayout distance of the dimension constraint
169   /// \param theConstraint a dimension constraint object
170   SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
171
172   /// Compute anchor pint for radius dimension
173   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
174                                               const ModelAPI_Feature* theConstraint,
175                                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
176
177   /// Throws an exception(in debug mode) and sends a signal about necessity to hide the object
178   /// \param theFeature a feature where AIS presentation is empty
179   /// \param theError a debug error information
180   SKETCHERPRS_EXPORT void sendEmptyPresentationError(ModelAPI_Feature* theFeature,
181                                                      const std::string theError);
182
183   SKETCHERPRS_EXPORT void setPixelRatio(int theRatio);
184
185   SKETCHERPRS_EXPORT int pixelRatio();
186 };
187
188 #endif