1 // Copyright (C) 2014-2019 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;
40 namespace SketcherPrs_Tools {
42 /// \enum ParameterStyle lists styles of parameter
44 ParameterValue, ///< using symbol with the parameter value
45 ParameterText ///< using parameter text
48 /// Set dimensions parameters style
49 /// \param theStyle new style
50 SKETCHERPRS_EXPORT void setParameterStyle(ParameterStyle theStyle);
52 /// Return dimensions parameters style
53 SKETCHERPRS_EXPORT ParameterStyle parameterStyle();
55 /// Enumeration with modes for activation of selection custom presentations
57 /// Start of enumeration
60 /// Selection mode for all constraints exclude dimensions
63 /// Selection mode for whole dimension
66 /// Selection mode for line of dimension
69 /// Selection mode for text of dimension
72 /// Selectiom mode for faces selection on sketch
75 /// Selectiom mode for wires selection on sketch
81 ANGLE_DIRECT, ///< Angle from the first line to the second line
82 ANGLE_COMPLEMENTARY, ///< Additional angle to the angle from first to second line
83 ANGLE_BACKWARD ///< Angle from the second line to the first line
86 /// Type of dimension location
88 LOCATION_RIGHT, ///< Position is marked by right arrow placed on the left
89 LOCATION_AUTOMATIC, ///< Position is marked by two arrow placed on the both sides
90 LOCATION_LEFT ///< Position is marked by left arrow placed on the left
93 /// Event ID about expression visual state has been changed, the symbol with a digit
94 /// or parameter text is shown
96 /// Returns attribute object referenced by feature
97 /// \param theFeature a feature
98 /// \param theAttrName an attribute name
99 SKETCHERPRS_EXPORT AttributePtr getAttribute(ModelAPI_Feature* theFeature,
100 const std::string& theAttrName);
102 /// Returns result object referenced by feature
103 /// \param theFeature a feature
104 /// \param theAttrName an attribute name
105 SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
106 const std::string& theAttrName);
108 /// Returns shape from result object (or NULL)
109 /// \param theObject a result object
110 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
113 /// Returns point from a line feature
114 /// \param theFeature a line feature
115 /// \param theAttrName an attribute of the point
116 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
117 const std::string& theAttrName);
120 /// Returns point projected on a line
121 /// \param theLine a line
122 /// \param thePoint a projecting point
123 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
124 const FeaturePtr theLine,
125 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
127 SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
128 const std::string& theAttribute);
130 /// Obtain the point object from specified constraint parameter
131 /// \param theData a data object
132 /// \param theAttribute an attribute name
133 /// \param thePlane a projection plane (sketcher plane)
134 SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
135 const std::string& theAttribute,
136 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
138 /// Collect all sketch points which are not connected with other entities.
139 /// \param theSketch sketch feature
140 /// \return list of results of SketchPlugin_Point features
141 SKETCHERPRS_EXPORT std::list<ResultPtr> getFreePoints(const CompositeFeaturePtr& theSketch);
143 /// Returns value of dimension arrows size
144 SKETCHERPRS_EXPORT double getArrowSize();
146 /// Set value of dimension arrows size
147 /// \param theSize a size value
148 SKETCHERPRS_EXPORT void setArrowSize(double theSize);
150 /// Returns default value of dimension arrows size
151 SKETCHERPRS_EXPORT int getDefaultArrowSize();
153 /// Returns value of dimension arrows size set in preferences
154 SKETCHERPRS_EXPORT int getConfigArrowSize();
156 /// Set value of dimension text height
157 /// \param theHeight a height value
158 SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
160 /// Returns value of dimension text height
161 SKETCHERPRS_EXPORT double getTextHeight();
163 /// Returns default value of dimension text height
164 SKETCHERPRS_EXPORT double getDefaultTextHeight();
166 /// Returns value of dimension text height set in preferences
167 SKETCHERPRS_EXPORT double getConfigTextHeight();
169 /// Get flayout distance of the dimension constraint
170 /// \param theConstraint a dimension constraint object
171 SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
173 /// Compute anchor pint for radius dimension
174 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
175 const ModelAPI_Feature* theConstraint,
176 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
178 /// Throws an exception(in debug mode) and sends a signal about necessity to hide the object
179 /// \param theFeature a feature where AIS presentation is empty
180 /// \param theError a debug error information
181 SKETCHERPRS_EXPORT void sendEmptyPresentationError(ModelAPI_Feature* theFeature,
182 const std::string theError);
184 SKETCHERPRS_EXPORT void setPixelRatio(int theRatio);
186 SKETCHERPRS_EXPORT int pixelRatio();