1 // File: PartSet_Tools.h
2 // Created: 28 Apr 2014
3 // Author: Natalia ERMOLAEVA
5 #ifndef PartSet_Tools_H
6 #define PartSet_Tools_H
14 #include <ModelAPI_Feature.h>
16 #include <boost/shared_ptr.hpp>
20 class Handle_V3d_View;
22 class GeomDataAPI_Point2D;
23 class PartSet_FeaturePrs;
27 * \brief The operation for the sketch feature creation
29 class PARTSET_EXPORT PartSet_Tools
32 /// Converts the 2D screen point to the 3D point on the view according to the point of view
33 /// \param thePoint a screen point
34 /// \param theView a 3D view
35 static gp_Pnt convertClickToPoint(QPoint thePoint, Handle_V3d_View theView);
37 /// \brief Converts the 3D point to the projected coodinates on the sketch plane.
38 /// \param thePoint the 3D point in the viewer
39 /// \param theSketch the sketch feature
40 /// \param theX the X coordinate
41 /// \param theY the Y coordinate
42 static void convertTo2D(const gp_Pnt& thePoint, FeaturePtr theSketch,
43 Handle(V3d_View) theView, double& theX, double& theY);
45 /// \brief Converts the 2D projected coodinates on the sketch plane to the 3D point.
46 /// \param theX the X coordinate
47 /// \param theY the Y coordinate
48 /// \param theSketch the sketch feature
49 /// \param thePoint the 3D point in the viewer
50 static void convertTo3D(const double theX, const double theY, FeaturePtr theSketch,
53 /// Creates the feature presentation
54 /// \param theKind a feature kind
55 /// \param theSketch the sketch of the feature
56 /// \param theFeature the feature
57 static boost::shared_ptr<PartSet_FeaturePrs> createFeaturePrs(const std::string& theKind,
59 FeaturePtr theFeature = FeaturePtr());
61 /// Returns a feature that is under the mouse point
62 /// \param thePoint a screen point
63 /// \param theView a 3D view
64 /// \param theSketch the sketch feature
65 /// \param theFeatures the list of selected presentations
66 static FeaturePtr nearestFeature(QPoint thePoint, Handle_V3d_View theView, FeaturePtr theSketch,
67 const std::list<XGUI_ViewerPrs>& theFeatures);
69 /// \brief Move the feature.
70 /// \param theFeature the source feature
71 /// \param theDeltaX the delta for X coordinate is moved
72 /// \param theDeltaY the delta for Y coordinate is moved
73 static void moveFeature(FeaturePtr theFeature, double theDeltaX, double theDeltaY);
75 /// Returns pointer to the root document.
76 static boost::shared_ptr<ModelAPI_Document> document();
78 /// \brief Save the point to the feature. If the attribute is 2D geometry point, it is filled.
79 /// \param theFeature the feature
80 /// \param theX the horizontal coordinate
81 /// \param theY the vertical coordinate
82 /// \param theAttribute the feature attribute
83 static void setFeaturePoint(FeaturePtr theFeature, double theX, double theY,
84 const std::string& theAttribute);
86 /// \brief Save the double to the feature. If the attribute is double, it is filled.
87 /// \param theFeature the feature
88 /// \param theValue the horizontal coordinate
89 /// \param theAttribute the feature attribute
90 static void setFeatureValue(FeaturePtr theFeature, double theX, const std::string& theAttribute);
92 /// \brief Returns the feature double value if it is.
93 /// \param theFeature the feature
94 /// \param theAttribute the feature attribute
95 /// \param theValue the horizontal coordinate
96 /// \returns the state whether the value is correct
97 static bool featureValue(FeaturePtr theFeature, const std::string& theAttribute,
100 /// Creates a constraint on two points
101 /// \param thePoint1 the first point
102 /// \param thePoint1 the second point
103 static void createConstraint(FeaturePtr theSketch,
104 boost::shared_ptr<GeomDataAPI_Point2D> thePoint1,
105 boost::shared_ptr<GeomDataAPI_Point2D> thePoint2);
107 /// Find a point in the line with given coordinates
108 /// \param theFeature the line feature
109 /// \param theX the horizontal point coordinate
110 /// \param theY the vertical point coordinate
111 static boost::shared_ptr<GeomDataAPI_Point2D> findPoint(FeaturePtr theFeature, double theX,
115 /// Return the distance between the feature and the point
116 /// \param theFeature feature object
117 /// \param theX the horizontal coordinate of the point
118 /// \param theX the vertical coordinate of the point
119 static double distanceToPoint(FeaturePtr theFeature, double theX, double theY);