]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketcherPrs/SketcherPrs_Tools.h
Salome HOME
365961fcbcc32a6ee143a7bfea3d34f7d1ba61c9
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Tools.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Tools.h
4 // Created:     10 March 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #ifndef SketcherPrs_Tools_H
8 #define SketcherPrs_Tools_H
9
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>
17 #include <string>
18
19 #include <Events_Loop.h>
20 #include <Events_Message.h>
21
22 // PORTING_TO_SALOME_8
23 //class Handle_Prs3d_DimensionAspect;
24
25 class GeomDataAPI_Point2D;
26 class AIS_Dimension;
27
28 //#define MyTextHeight 20
29
30 /// Message that style of visualization of parameter is changed.
31 /// It will be shown as expression or value
32 class SketcherPrs_ParameterStyleMessage : public Events_Message
33 {
34 public:
35   /// \enum ParameterStyle lists styles of parameter
36   enum ParameterStyle {
37     ParameterValue, ///< using symbol with the parameter value
38     ParameterText ///< using parameter text
39   };
40
41 public:
42   /// Creates an empty message
43   SKETCHERPRS_EXPORT SketcherPrs_ParameterStyleMessage(const Events_ID theID,
44                                                     const void* theSender = 0)
45   : Events_Message(theID, theSender) {}
46   /// The virtual destructor
47   SKETCHERPRS_EXPORT virtual ~SketcherPrs_ParameterStyleMessage() {}
48   /// Static. Returns EventID of the message.
49   SKETCHERPRS_EXPORT static Events_ID eventId()
50   {
51     static const char * MY_EVENT_PARAMETER_STYLE_ID("ParameterStyle");
52     return Events_Loop::eventByName(MY_EVENT_PARAMETER_STYLE_ID);
53   }
54   /// Returns a document stored in the message
55   SKETCHERPRS_EXPORT ParameterStyle style() const { return myStyle; }
56   /// Sets a document to the message
57   SKETCHERPRS_EXPORT void setStyle(ParameterStyle theStyle) { myStyle = theStyle; }
58 private:
59   ParameterStyle myStyle; /// style of the parameter visualization
60 };
61
62 namespace SketcherPrs_Tools {
63
64   /// Enumeration with modes for activation of selection custom presentations
65   enum SelectionModes {
66     /// Start of enumeration
67     Sel_Mode_First = 100,
68
69     /// Selection mode for all constraints exclude dimensions
70     Sel_Constraint,
71
72     /// Selection mode for whole dimension
73     Sel_Dimension_All,
74
75     /// Selection mode for line of dimension
76     Sel_Dimension_Line,
77
78     /// Selection mode for text of dimension
79     Sel_Dimension_Text,
80
81     /// Selectiom mode for faces selection on sketch
82     Sel_Sketch_Face,
83
84     /// Selectiom mode for wires selection on sketch
85     Sel_Sketch_Wire
86   };
87
88   /// Type of angle
89   enum AngleType{
90     ANGLE_DIRECT,   ///< Angle from the first line to the second line
91     ANGLE_COMPLEMENTARY,  ///< Additional angle to the angle from first to second line
92     ANGLE_BACKWARD ///< Angle from the second line to the first line
93   };
94
95   /// Event ID about expression visual state has been changed, the symbol with a digit
96   /// or parameter text is shown
97
98   /// Returns attribute object referenced by feature
99   /// \param theFeature a feature
100   /// \param theAttrName an attribute name
101   SKETCHERPRS_EXPORT AttributePtr getAttribute(ModelAPI_Feature* theFeature,
102                                                const std::string& theAttrName);
103
104   /// Returns result object referenced by feature
105   /// \param theFeature a feature
106   /// \param theAttrName an attribute name
107   SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
108                                          const std::string& theAttrName);
109
110   /// Returns shape from result object (or NULL)
111   /// \param theObject a result object
112   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
113
114
115   /// Returns point from a line feature
116   /// \param theFeature a line feature
117   /// \param theAttrName an attribute of the point
118   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
119                                           const std::string& theAttrName);
120
121
122   /// Returns point projected on a line
123   /// \param theLine  a line
124   /// \param thePoint a projecting point
125   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
126                         const FeaturePtr theLine,
127                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
128
129   SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
130                                                const std::string& theAttribute);
131
132   /// Obtain the point object from specified constraint parameter
133   /// \param theData a data object
134   /// \param theAttribute an attribute name
135   /// \param thePlane a projection plane (sketcher plane)
136   SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
137                                                const std::string& theAttribute,
138                                                const std::shared_ptr<GeomAPI_Ax3>& thePlane);
139
140   /// Returns value of dimension arrows size
141   SKETCHERPRS_EXPORT double getArrowSize();
142
143   /// Set value of dimension arrows size
144   /// \param theSize a size value
145   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
146
147   /// Returns default value of dimension arrows size
148   SKETCHERPRS_EXPORT int getDefaultArrowSize();
149
150   /// Set value of dimension text height
151   /// \param theHeight a height value
152   SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
153
154   /// Returns value of dimension text height
155   SKETCHERPRS_EXPORT double getTextHeight();
156
157   /// Returns default value of dimension text height
158   SKETCHERPRS_EXPORT double getDefaultTextHeight();
159
160   /// Get flayout distance of the dimension constraint
161   /// \param theConstraint a dimension constraint object
162   SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
163
164   /// Compute anchor pint for radius dimension
165   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
166                                               const ModelAPI_Feature* theConstraint,
167                                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
168
169   /// Sends event about expression visualization type is changed for dimension presentations
170   /// Sends event to redisplay all sub-features of composite feature
171   /// \param theState a new state
172   SKETCHERPRS_EXPORT void sendExpressionShownEvent(const bool& theState);
173
174   /// Creates an aspect to be shown in length/radius dimension presentations
175   /// \return an instance of aspect
176   //SKETCHERPRS_EXPORT Handle_Prs3d_DimensionAspect createDimensionAspect();
177
178   /// Update variable aspect parameters (depending on viewer scale)
179   /// \param theDimAspect an aspect to be changed
180   /// \param theDimValue an arrow value
181   /// \param theTextSize an arrow value
182   //SKETCHERPRS_EXPORT void updateArrows(Handle_Prs3d_DimensionAspect theDimAspect,
183   //                                     double theDimValue, double theTextSize);
184
185   /// Throws an exception(in debug mode) and sends a signal about necessity to hide the object
186   /// \param theFeature a feature where AIS presentation is empty
187   /// \param theError a debug error information
188   SKETCHERPRS_EXPORT void sendEmptyPresentationError(ModelAPI_Feature* theFeature,
189                                                      const std::string theError);
190 };
191
192 #endif