]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_Sketch.h
Salome HOME
Sketch line feature based on points attributes
[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   /// 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);
49
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();
53
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);
57
58   /// Use plugin manager for features creation
59   SketchPlugin_Sketch();
60 protected:
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;
68 };
69
70 #endif