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 class GeomDataAPI_Point2D;
22 //#define MyTextHeight 20
24 namespace SketcherPrs_Tools {
26 /// Enumeration with modes for activation of selection custom presentations
28 /// Start of enumeration
31 /// Selection mode for all constraints exclude dimensions
34 /// Selection mode for whole dimension
37 /// Selection mode for line of dimension
40 /// Selection mode foe text of dimension
46 ANGLE_DIRECT, ///< Angle from the first line to the second line
47 ANGLE_SUPPLEMENTARY, ///< Additional angle to the angle from first to second line
48 ANGLE_BACKWARD ///< Angle from the second line to the first line
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);
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);
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);
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);
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);
82 SKETCHERPRS_EXPORT FeaturePtr getFeatureLine(DataPtr theData,
83 const std::string& theAttribute);
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);
93 /// Returns value of dimension arrows size
94 SKETCHERPRS_EXPORT double getArrowSize();
96 /// Set value of dimension arrows size
97 /// \param theSize a size value
98 SKETCHERPRS_EXPORT void setArrowSize(double theSize);
100 /// Returns default value of dimension arrows size
101 SKETCHERPRS_EXPORT int getDefaultArrowSize();
103 /// Set value of dimension text height
104 /// \param theHeight a height value
105 SKETCHERPRS_EXPORT void setTextHeight(double theHeight);
107 /// Returns value of dimension text height
108 SKETCHERPRS_EXPORT double getTextHeight();
110 /// Returns default value of dimension text height
111 SKETCHERPRS_EXPORT double getDefaultTextHeight();
113 /// Get flayout distance of the dimension constraint
114 /// \param theConstraint a dimension constraint object
115 SKETCHERPRS_EXPORT double getFlyoutDistance(const ModelAPI_Feature* theConstraint);
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);
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);