1 // File: SketchPlugin_Sketch.h
2 // Created: 27 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef SketchPlugin_Sketch_H_
6 #define SketchPlugin_Sketch_H_
8 #include "SketchPlugin.h"
9 #include <SketchPlugin_Feature.h>
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Pln.h>
12 #include <GeomAPI_IPresentable.h>
15 /// the plane edge color
16 #define SKETCH_PLANE_COLOR "#700000"
18 /// the plane edge width
19 #define SKETCH_WIDTH "4"
21 /// face of the square-face displayed for selection of general plane
22 #define PLANE_SIZE "200"
24 /**\class SketchPlugin_Sketch
26 * \brief Feature for creation of the new part in PartSet.
28 class SketchPlugin_Sketch : public SketchPlugin_Feature, public GeomAPI_IPresentable
31 /// Sketch feature kind
32 inline static const std::string& ID()
34 static const std::string MY_SKETCH_ID("Sketch");
37 /// Origin point of the sketcher in 3D space
38 inline static const std::string& ORIGIN_ID()
40 static const std::string MY_ORIGIN_ID("Origin");
43 /// Vector X inside of the sketch plane
44 inline static const std::string& DIRX_ID()
46 static const std::string MY_DIRX_ID("DirX");
49 /// Vector Y inside of the sketch plane
50 inline static const std::string& DIRY_ID()
52 static const std::string MY_DIRY_ID("DirY");
55 /// Vector Z, normal to the sketch plane
56 inline static const std::string& NORM_ID()
58 static const std::string MY_NORM_ID("Norm");
61 /// All features of this sketch (list of references)
62 inline static const std::string& FEATURES_ID()
64 static const std::string MY_FEATURES_ID("Features");
65 return MY_FEATURES_ID;
68 /// Returns the kind of a feature
69 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
71 static std::string MY_KIND = SketchPlugin_Sketch::ID();
75 /// Creates a new part document if needed
76 SKETCHPLUGIN_EXPORT virtual void execute();
78 /// Request for initialization of data model of the feature: adding all attributes
79 SKETCHPLUGIN_EXPORT virtual void initAttributes();
81 /// Adds sub-feature of the higher level feature (sub-element of the sketch)
82 /// \param theFeature sub-feature
83 SKETCHPLUGIN_EXPORT virtual const void addSub(const FeaturePtr& theFeature);
86 /// \param theDeltaX the delta for X coordinate is moved
87 /// \param theDeltaY the delta for Y coordinate is moved
88 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY)
93 /// Return the distance between the feature and the point
94 /// \param thePoint the point
95 virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
101 /// Converts a 2D sketch space point into point in 3D space
102 SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(const double theX, const double theY);
104 /// Returns true if this feature must be displayed in the history (top level of Part tree)
105 SKETCHPLUGIN_EXPORT virtual bool isInHistory()
110 /// Use plugin manager for features creation
111 SketchPlugin_Sketch();
113 /// Returns the basis plane for the sketch
114 boost::shared_ptr<GeomAPI_Pln> plane();
116 virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious);
119 /// Creates a plane and append it to the list
120 /// \param theX the X normal value
121 /// \param theY the Y normal value
122 /// \param theZ the Z normal value
123 /// \param theShapes the list of result shapes
124 //void addPlane(double theX, double theY, double theZ,
125 // std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
127 /// Checks whether the plane is set in the sketch.
128 /// \returns the boolean state