1 // Copyright (C) 2014-2020 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketcherPrs_Tools_H
21 #define SketcherPrs_Tools_H
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>
34 #include <Events_Loop.h>
35 #include <Events_Message.h>
37 class GeomDataAPI_Point2D;
39 namespace SketcherPrs_Tools {
41 /// \enum ParameterStyle lists styles of parameter
43 ParameterValue, ///< using symbol with the parameter value
44 ParameterText ///< using parameter text
47 /// Set dimensions parameters style
48 /// \param theStyle new style
49 SKETCHERPRS_EXPORT void setParameterStyle(ParameterStyle theStyle);
51 /// Return dimensions parameters style
52 SKETCHERPRS_EXPORT ParameterStyle parameterStyle();
54 /// Enumeration with modes for activation of selection custom presentations
56 /// Start of enumeration
59 /// Selection mode for all constraints exclude dimensions
62 /// Selection mode for whole dimension
65 /// Selection mode for line of dimension
68 /// Selection mode for text of dimension
71 /// Selectiom mode for faces selection on sketch
74 /// Selectiom mode for wires selection on sketch
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
85 /// Type of dimension location
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
92 /// Event ID about expression visual state has been changed, the symbol with a digit
93 /// or parameter text is shown
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);
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);
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);
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);
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);
126 SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
127 const std::string& theAttribute);
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);
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);
142 /// Returns value of dimension arrows size
143 SKETCHERPRS_EXPORT double getArrowSize();
145 /// Set value of dimension arrows size
146 /// \param theSize a size value
147 SKETCHERPRS_EXPORT void setArrowSize(double theSize);
149 /// Returns default value of dimension arrows size
150 SKETCHERPRS_EXPORT int getDefaultArrowSize();
152 /// Returns value of dimension arrows size set in preferences
153 SKETCHERPRS_EXPORT int getConfigArrowSize();
155 /// Set value of dimension text height
156 /// \param theHeight a height value
157 SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
159 /// Returns value of dimension text height
160 SKETCHERPRS_EXPORT double getTextHeight();
162 /// Returns default value of dimension text height
163 SKETCHERPRS_EXPORT double getDefaultTextHeight();
165 /// Returns value of dimension text height set in preferences
166 SKETCHERPRS_EXPORT double getConfigTextHeight();
168 /// Get flayout distance of the dimension constraint
169 /// \param theConstraint a dimension constraint object
170 SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
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);
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);
183 SKETCHERPRS_EXPORT void setPixelRatio(int theRatio);
185 SKETCHERPRS_EXPORT int pixelRatio();