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 /// Sketch feature kind
15 const std::string SKETCH_KIND("Sketch");
17 /// Origin point of the sketcher in 3D space
18 const std::string SKETCH_ATTR_ORIGIN("Origin");
19 /// Vector X inside of the sketch plane
20 const std::string SKETCH_ATTR_DIRX("DirX");
21 /// Vector Y inside of the sketch plane
22 const std::string SKETCH_ATTR_DIRY("DirY");
23 /// Vector Z, normal to the sketch plane
24 const std::string SKETCH_ATTR_NORM("Norm");
25 /// All features of this sketch (list of references)
26 const std::string SKETCH_ATTR_FEATURES("Features");
28 /**\class SketchPlugin_Sketch
30 * \brief Feature for creation of the new part in PartSet.
32 class SketchPlugin_Sketch: public SketchPlugin_Feature
35 /// Returns the kind of a feature
36 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
37 {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;}
39 /// Returns to which group in the document must be added feature
40 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
41 {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
43 /// Creates a new part document if needed
44 SKETCHPLUGIN_EXPORT virtual void execute();
46 /// Request for initialization of data model of the feature: adding all attributes
47 SKETCHPLUGIN_EXPORT virtual void initAttributes();
49 /// Returns the sketch preview
50 SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
52 /// Returns the sketch preview
53 SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
55 /// Adds sub-feature of the higher level feature (sub-element of the sketch)
56 /// \param theFeature sub-feature
57 SKETCHPLUGIN_EXPORT virtual const void addSub(
58 const FeaturePtr& theFeature);
61 /// \param theDeltaX the delta for X coordinate is moved
62 /// \param theDeltaY the delta for Y coordinate is moved
63 SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
65 /// Return the distance between the feature and the point
66 /// \param thePoint the point
67 virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
69 /// Converts a 2D sketch space point into point in 3D space
70 SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
71 const double theX, const double theY);
73 /// Returns true if this feature must be displayed in the history (top level of Part tree)
74 SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;}
76 /// Use plugin manager for features creation
77 SketchPlugin_Sketch();
79 /// Returns the basis plane for the sketch
80 boost::shared_ptr<GeomAPI_Pln> plane();
82 /// Creates a plane and append it to the list
83 /// \param theX the X normal value
84 /// \param theY the Y normal value
85 /// \param theZ the Z normal value
86 /// \param theShapes the list of result shapes
87 void addPlane(double theX, double theY, double theZ,
88 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
90 /// Checks whether the plane is set in the sketch.
91 /// \returns the boolean state