1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Tools.h
4 // Created: 10 March 2015
5 // Author: Vitaly SMETANNIKOV
7 #ifndef SketcherPrs_Tools_H
8 #define SketcherPrs_Tools_H
10 #include "SketcherPrs.h"
11 #include <GeomAPI_Shape.h>
12 #include <GeomAPI_Pnt2d.h>
13 #include <GeomAPI_Ax3.h>
14 #include <ModelAPI_Object.h>
15 #include <ModelAPI_Attribute.h>
16 #include <ModelAPI_Feature.h>
19 #include <Events_Loop.h>
20 #include <Events_Message.h>
22 class GeomDataAPI_Point2D;
25 //#define MyTextHeight 20
27 /// Message that document (Part, PartSet) was created
28 class SketcherPrs_ParameterStyleMessage : public Events_Message
32 ParameterValue, /// using symbol with the parameter value
33 ParameterText /// using parameter text
37 /// Creates an empty message
38 SKETCHERPRS_EXPORT SketcherPrs_ParameterStyleMessage(const Events_ID theID,
39 const void* theSender = 0)
40 : Events_Message(theID, theSender) {}
41 /// The virtual destructor
42 SKETCHERPRS_EXPORT virtual ~SketcherPrs_ParameterStyleMessage() {}
43 /// Static. Returns EventID of the message.
44 SKETCHERPRS_EXPORT static Events_ID eventId()
46 static const char * MY_EVENT_PARAMETER_STYLE_ID("ParameterStyle");
47 return Events_Loop::eventByName(MY_EVENT_PARAMETER_STYLE_ID);
49 /// Returns a document stored in the message
50 SKETCHERPRS_EXPORT ParameterStyle style() const { return myStyle; }
51 /// Sets a document to the message
52 SKETCHERPRS_EXPORT void setStyle(ParameterStyle theStyle) { myStyle = theStyle; }
54 ParameterStyle myStyle; /// style of the parameter visualization
57 namespace SketcherPrs_Tools {
59 /// Enumeration with modes for activation of selection custom presentations
61 /// Start of enumeration
64 /// Selection mode for all constraints exclude dimensions
67 /// Selection mode for whole dimension
70 /// Selection mode for line of dimension
73 /// Selection mode foe text of dimension
79 ANGLE_DIRECT, ///< Angle from the first line to the second line
80 ANGLE_COMPLEMENTARY, ///< Additional angle to the angle from first to second line
81 ANGLE_BACKWARD ///< Angle from the second line to the first line
84 /// Event ID about expression visual state has been changed, the symbol with a digit
85 /// or parameter text is shown
87 /// Returns attribute object referenced by feature
88 /// \param theFeature a feature
89 /// \param theAttrName an attribute name
90 SKETCHERPRS_EXPORT AttributePtr getAttribute(ModelAPI_Feature* theFeature,
91 const std::string& theAttrName);
93 /// Returns result object referenced by feature
94 /// \param theFeature a feature
95 /// \param theAttrName an attribute name
96 SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
97 const std::string& theAttrName);
99 /// Returns shape from result object (or NULL)
100 /// \param theObject a result object
101 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
104 /// Returns point from a line feature
105 /// \param theFeature a line feature
106 /// \param theAttrName an attribute of the point
107 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
108 const std::string& theAttrName);
111 /// Returns point projected on a line
112 /// \param theLine a line
113 /// \param thePoint a projecting point
114 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
115 const FeaturePtr theLine,
116 const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
118 SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
119 const std::string& theAttribute);
121 /// Obtain the point object from specified constraint parameter
122 /// \param theData a data object
123 /// \param theAttribute an attribute name
124 /// \param thePlane a projection plane (sketcher plane)
125 SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
126 const std::string& theAttribute,
127 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
129 /// Returns value of dimension arrows size
130 SKETCHERPRS_EXPORT double getArrowSize();
132 /// Set value of dimension arrows size
133 /// \param theSize a size value
134 SKETCHERPRS_EXPORT void setArrowSize(double theSize);
136 /// Returns default value of dimension arrows size
137 SKETCHERPRS_EXPORT int getDefaultArrowSize();
139 /// Set value of dimension text height
140 /// \param theHeight a height value
141 SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
143 /// Returns value of dimension text height
144 SKETCHERPRS_EXPORT double getTextHeight();
146 /// Returns default value of dimension text height
147 SKETCHERPRS_EXPORT double getDefaultTextHeight();
149 /// Get flayout distance of the dimension constraint
150 /// \param theConstraint a dimension constraint object
151 SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
153 /// Compute anchor pint for radius dimension
154 SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
155 const ModelAPI_Feature* theConstraint,
156 const std::shared_ptr<GeomAPI_Ax3>& thePlane);
158 /// Display/hide sigma symbol in the dimension presentation
159 /// \param theDimension a dimension constraint
160 /// \param theToDisplay a boolean value
161 SKETCHERPRS_EXPORT void setDisplaySpecialSymbol(AIS_Dimension* theDimension,
162 const bool& theToDisplay);
164 /// Display the parameter value instead of dimention digit
165 /// \param theDimension a dimension constraint
166 /// \param theParameter a parameter value
167 /// \param theToDisplay a boolean value
168 SKETCHERPRS_EXPORT void setDisplayParameter(AIS_Dimension* theDimension,
169 const std::string& theParameter,
170 const bool& theToDisplay);
172 /// Sends event about expression visualization type is changed for dimension presentations
173 /// Sends event to redisplay all sub-features of composite feature
174 /// \param theState a new state
175 SKETCHERPRS_EXPORT void sendExpressionShownEvent(const bool& theState);