Salome HOME
Issue #71: abort all actions inside of the sketch on sketch abort
[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 /// All features of this sketch (list of references)
22 const std::string SKETCH_ATTR_FEATURES("Features");
23
24 /**\class SketchPlugin_Sketch
25  * \ingroup DataModel
26  * \brief Feature for creation of the new part in PartSet.
27  */
28 class SketchPlugin_Sketch: public SketchPlugin_Feature
29 {
30 public:
31   /// Returns the kind of a feature
32  SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
33   {static std::string MY_KIND = "Sketch"; return MY_KIND;}
34
35   /// Returns to which group in the document must be added feature
36  SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
37   {static std::string MY_GROUP = "Construction"; return MY_GROUP;}
38
39   /// Creates a new part document if needed
40  SKETCHPLUGIN_EXPORT virtual void execute();
41
42   /// Request for initialization of data model of the feature: adding all attributes
43  SKETCHPLUGIN_EXPORT virtual void initAttributes();
44
45   /// Returns the sketch preview
46   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview();
47
48   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
49   /// \param theFeature sub-feature
50   SKETCHPLUGIN_EXPORT virtual const void addSub(
51     const boost::shared_ptr<ModelAPI_Feature>& theFeature);
52
53   /// Converts a 2D sketch space point into point in 3D space
54   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
55     const double theX, const double theY);
56
57   /// Returns true if this feature must be displayed in the history (top level of Part tree)
58   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;}
59
60   /// Use plugin manager for features creation
61   SketchPlugin_Sketch();
62 protected:
63   /// Creates a plane and append it to the list
64   /// \param theX the X normal value
65   /// \param theY the Y normal value
66   /// \param theZ the Z normal value
67   /// \param theShapes the list of result shapes
68   void addPlane(double theX, double theY, double theZ,
69                 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
70
71   /// Checks whether the plane is set in the sketch.
72   /// \returns the boolean state
73   bool isPlaneSet();
74 };
75
76 #endif