Salome HOME
Sub-features of sketcher support
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Sketch.h
1 // File:        SketchPlugin_Sketch.h
2 // Created:     27 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef SketchPlugin_Sketch_HeaderFile
6 #define SketchPlugin_Sketch_HeaderFile
7
8 #include "SketchPlugin.h"
9 #include <SketchPlugin_Feature.h>
10 #include <GeomAPI_Pnt.h>
11 #include <list>
12
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");
21
22 /**\class SketchPlugin_Sketch
23  * \ingroup DataModel
24  * \brief Feature for creation of the new part in PartSet.
25  */
26 class SketchPlugin_Sketch: public SketchPlugin_Feature
27 {
28 public:
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;}
32
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;}
36
37   /// Creates a new part document if needed
38  SKETCHPLUGIN_EXPORT virtual void execute();
39
40   /// Request for initialization of data model of the feature: adding all attributes
41  SKETCHPLUGIN_EXPORT virtual void initAttributes();
42
43   /// Returns the sketch preview
44   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
45
46   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
47   /// \param theFeature sub-feature
48   SKETCHPLUGIN_EXPORT virtual const void addSub(
49     const boost::shared_ptr<ModelAPI_Feature>& theFeature);
50
51   /// Converts a 2D sketch space point into point in 3D space
52   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
53     const double theX, const double theY);
54
55   /// Use plugin manager for features creation
56   SketchPlugin_Sketch();
57 protected:
58   /// Creates a plane and append it to the list
59   /// \param theX the X normal value
60   /// \param theY the Y normal value
61   /// \param theZ the Z normal value
62   /// \param theShapes the list of result shapes
63   void addPlane(double theX, double theY, double theZ,
64                 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
65 };
66
67 #endif