Salome HOME
f6f8c3ac7c1c82bd801d822a8a1531226d6c8761
[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 class GeomDataAPI_Point2D;
20 class AIS_Dimension;
21
22 //#define MyTextHeight 20
23
24 namespace SketcherPrs_Tools {
25
26   /// Enumeration with modes for activation of selection custom presentations
27   enum SelectionModes {
28     /// Start of enumeration
29     Sel_Mode_First = 100, 
30   
31     /// Selection mode for all constraints exclude dimensions
32     Sel_Constraint,
33   
34     /// Selection mode for whole dimension
35     Sel_Dimension_All,
36   
37     /// Selection mode for line of dimension
38     Sel_Dimension_Line,
39
40     /// Selection mode foe text of dimension
41     Sel_Dimension_Text
42   };
43
44   /// Type of angle
45   enum AngleType{
46     ANGLE_DIRECT,   ///< Angle from the first line to the second line
47     ANGLE_COMPLEMENTARY,  ///< Additional angle to the angle from first to second line
48     ANGLE_BACKWARD ///< Angle from the second line to the first line
49   };
50
51   /// Returns attribute object referenced by feature
52   /// \param theFeature a feature
53   /// \param theAttrName an attribute name
54   SKETCHERPRS_EXPORT AttributePtr getAttribute(ModelAPI_Feature* theFeature,
55                                                const std::string& theAttrName);
56
57   /// Returns result object referenced by feature
58   /// \param theFeature a feature
59   /// \param theAttrName an attribute name
60   SKETCHERPRS_EXPORT ObjectPtr getResult(ModelAPI_Feature* theFeature,
61                                          const std::string& theAttrName);
62
63   /// Returns shape from result object (or NULL)
64   /// \param theObject a result object
65   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Shape> getShape(ObjectPtr theObject);
66
67
68   /// Returns point from a line feature
69   /// \param theFeature a line feature
70   /// \param theAttrName an attribute of the point
71   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getPoint(ModelAPI_Feature* theFeature,
72                                           const std::string& theAttrName);
73
74
75   /// Returns point projected on a line
76   /// \param theLine  a line
77   /// \param thePoint a projecting point
78   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt2d> getProjectionPoint(
79                         const FeaturePtr theLine,
80                         const std::shared_ptr<GeomAPI_Pnt2d>& thePoint);
81
82   SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
83                                                const std::string& theAttribute);
84
85   /// Obtain the point object from specified constraint parameter
86   /// \param theData a data object
87   /// \param theAttribute an attribute name
88   /// \param thePlane a projection plane (sketcher plane)
89   SKETCHERPRS_EXPORT std::shared_ptr<GeomDataAPI_Point2D> getFeaturePoint(DataPtr theData,
90                                                        const std::string& theAttribute,
91                                                        const std::shared_ptr<GeomAPI_Ax3>& thePlane);
92
93   /// Returns value of dimension arrows size
94   SKETCHERPRS_EXPORT double getArrowSize();
95
96   /// Set value of dimension arrows size
97   /// \param theSize a size value
98   SKETCHERPRS_EXPORT void setArrowSize(double theSize);
99
100   /// Returns default value of dimension arrows size
101   SKETCHERPRS_EXPORT int getDefaultArrowSize();
102
103   /// Set value of dimension text height
104   /// \param theHeight a height value
105   SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
106
107   /// Returns value of dimension text height
108   SKETCHERPRS_EXPORT double getTextHeight();
109
110   /// Returns default value of dimension text height
111   SKETCHERPRS_EXPORT double getDefaultTextHeight();
112
113   /// Get flayout distance of the dimension constraint
114   /// \param theConstraint a dimension constraint object
115   SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
116
117   /// Compute anchor pint for radius dimension
118   SKETCHERPRS_EXPORT std::shared_ptr<GeomAPI_Pnt> getAnchorPoint(
119                                               const ModelAPI_Feature* theConstraint,
120                                               const std::shared_ptr<GeomAPI_Ax3>& thePlane);
121
122   /// Display/hide sigma symbol in the dimension presentation
123   /// \param theDimension a dimension constraint
124   /// \param theToDisplay a boolean value
125   SKETCHERPRS_EXPORT void setDisplaySpecialSymbol(AIS_Dimension* theDimension,
126                                                   const bool& theToDisplay);
127 };
128
129 #endif