1 // File: SketchPlugin_Sketch.h
2 // Created: 27 Mar 2014
3 // Author: Mikhail PONIKAROV
5 #ifndef SketchPlugin_Sketch_HeaderFile
6 #define SketchPlugin_Sketch_HeaderFile
8 #include "SketchPlugin.h"
9 #include <SketchPlugin_Feature.h>
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Pln.h>
14 /**\class SketchPlugin_Sketch
16 * \brief Feature for creation of the new part in PartSet.
18 class SketchPlugin_Sketch: public SketchPlugin_Feature
21 /// Sketch feature kind
22 inline static const std::string& ID()
24 static const std::string MY_SKETCH_ID("Sketch");
27 /// Origin point of the sketcher in 3D space
28 inline static const std::string& ORIGIN_ID()
30 static const std::string MY_ORIGIN_ID("Origin");
33 /// Vector X inside of the sketch plane
34 inline static const std::string& DIRX_ID()
36 static const std::string MY_DIRX_ID("DirX");
39 /// Vector Y inside of the sketch plane
40 inline static const std::string& DIRY_ID()
42 static const std::string MY_DIRY_ID("DirY");
45 /// Vector Z, normal to the sketch plane
46 inline static const std::string& NORM_ID()
48 static const std::string MY_NORM_ID("Norm");
51 /// All features of this sketch (list of references)
52 inline static const std::string& FEATURES_ID()
54 static const std::string MY_FEATURES_ID("Features");
55 return MY_FEATURES_ID;
58 /// Returns the kind of a feature
59 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
60 {static std::string MY_KIND = SketchPlugin_Sketch::ID(); return MY_KIND;}
62 /// Creates a new part document if needed
63 SKETCHPLUGIN_EXPORT virtual void execute();
65 /// Request for initialization of data model of the feature: adding all attributes
66 SKETCHPLUGIN_EXPORT virtual void initAttributes();
68 /// Returns the AIS preview
69 SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
70 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
72 /// Adds sub-feature of the higher level feature (sub-element of the sketch)
73 /// \param theFeature sub-feature
74 SKETCHPLUGIN_EXPORT virtual const void addSub(
75 const FeaturePtr& theFeature);
78 /// \param theDeltaX the delta for X coordinate is moved
79 /// \param theDeltaY the delta for Y coordinate is moved
80 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
82 /// Return the distance between the feature and the point
83 /// \param thePoint the point
84 virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
86 /// Converts a 2D sketch space point into point in 3D space
87 SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
88 const double theX, const double theY);
90 /// Returns true if this feature must be displayed in the history (top level of Part tree)
91 SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;}
93 /// Use plugin manager for features creation
94 SketchPlugin_Sketch();
96 /// Returns the basis plane for the sketch
97 boost::shared_ptr<GeomAPI_Pln> plane();
99 /// Creates a plane and append it to the list
100 /// \param theX the X normal value
101 /// \param theY the Y normal value
102 /// \param theZ the Z normal value
103 /// \param theShapes the list of result shapes
104 void addPlane(double theX, double theY, double theZ,
105 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
107 /// Checks whether the plane is set in the sketch.
108 /// \returns the boolean state