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>
13 /// Origin point of the sketcher in 3D space
14 const std::string SKETCH_ATTR_ORIGIN("Origin");
15 /// Vector X inside of the sketch plane
16 const std::string SKETCH_ATTR_DIRX("DirX");
17 /// Vector Y inside of the sketch plane
18 const std::string SKETCH_ATTR_DIRY("DirY");
19 /// Vector Z, normal to the sketch plane
20 const std::string SKETCH_ATTR_NORM("Norm");
22 /**\class SketchPlugin_Sketch
24 * \brief Feature for creation of the new part in PartSet.
26 class SketchPlugin_Sketch: public SketchPlugin_Feature
29 /// Returns the kind of a feature
30 SKETCHPLUGIN_EXPORT virtual const std::string& getKind()
31 {static std::string MY_KIND = "Sketch"; return MY_KIND;}
33 /// Returns to which group in the document must be added feature
34 SKETCHPLUGIN_EXPORT virtual const std::string& getGroup()
35 {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
37 /// Creates a new part document if needed
38 SKETCHPLUGIN_EXPORT virtual void execute();
40 /// Request for initialization of data model of the feature: adding all attributes
41 SKETCHPLUGIN_EXPORT virtual void initAttributes();
43 /// Returns the sketch preview
44 SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
46 /// Sets the sketch as active. All features and features previews
47 /// will be connected to this sketch.
48 SKETCHPLUGIN_EXPORT static void setActive(boost::shared_ptr<SketchPlugin_Sketch> theSketch);
50 /// Returns the currently active sketch. All features and features previews
51 /// will be connected to this sketch.
52 SKETCHPLUGIN_EXPORT static boost::shared_ptr<SketchPlugin_Sketch> active();
54 /// Converts a 2D sketch space point into point in 3D space
55 SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
56 const double theX, const double theY);
58 /// Use plugin manager for features creation
59 SketchPlugin_Sketch();
61 /// Creates a plane and append it to the list
62 /// \param theX the X normal value
63 /// \param theY the Y normal value
64 /// \param theZ the Z normal value
65 /// \param theShapes the list of result shapes
66 void addPlane(double theX, double theY, double theZ,
67 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;