Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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_H_
6 #define SketchPlugin_Sketch_H_
7
8 #include "SketchPlugin.h"
9 #include <SketchPlugin_Feature.h>
10 #include <GeomAPI_Pnt.h>
11 #include <GeomAPI_Pln.h>
12 #include <GeomAPI_IPresentable.h>
13 #include <list>
14
15 /**\class SketchPlugin_Sketch
16  * \ingroup DataModel
17  * \brief Feature for creation of the new part in PartSet.
18  */
19 class SketchPlugin_Sketch: public SketchPlugin_Feature, public GeomAPI_IPresentable
20 {
21 public:
22   /// Sketch feature kind
23   inline static const std::string& ID()
24   {
25     static const std::string MY_SKETCH_ID("Sketch");
26     return MY_SKETCH_ID;
27   }
28   /// Origin point of the sketcher in 3D space
29   inline static const std::string& ORIGIN_ID()
30   {
31     static const std::string MY_ORIGIN_ID("Origin");
32     return MY_ORIGIN_ID;
33   }
34   /// Vector X inside of the sketch plane
35   inline static const std::string& DIRX_ID()
36   {
37     static const std::string MY_DIRX_ID("DirX");
38     return MY_DIRX_ID;
39   }
40   /// Vector Y inside of the sketch plane
41   inline static const std::string& DIRY_ID()
42   {
43     static const std::string MY_DIRY_ID("DirY");
44     return MY_DIRY_ID;
45   }
46   /// Vector Z, normal to the sketch plane
47   inline static const std::string& NORM_ID()
48   {
49     static const std::string MY_NORM_ID("Norm");
50     return MY_NORM_ID;
51   }
52   /// All features of this sketch (list of references)
53   inline static const std::string& FEATURES_ID()
54   {
55     static const std::string MY_FEATURES_ID("Features");
56     return MY_FEATURES_ID;
57   }
58
59   /// Returns the kind of a feature
60   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
61   {static std::string MY_KIND = SketchPlugin_Sketch::ID(); return MY_KIND;}
62
63   /// Creates a new part document if needed
64   SKETCHPLUGIN_EXPORT virtual void execute();
65
66   /// Request for initialization of data model of the feature: adding all attributes
67   SKETCHPLUGIN_EXPORT virtual void initAttributes();
68
69   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
70   /// \param theFeature sub-feature
71   SKETCHPLUGIN_EXPORT virtual const void addSub(
72     const FeaturePtr& theFeature);
73
74   /// Moves the feature
75   /// \param theDeltaX the delta for X coordinate is moved
76   /// \param theDeltaY the delta for Y coordinate is moved
77   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
78
79   /// Return the distance between the feature and the point
80   /// \param thePoint the point
81   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
82
83   /// Converts a 2D sketch space point into point in 3D space
84   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
85     const double theX, const double theY);
86
87   /// Returns true if this feature must be displayed in the history (top level of Part tree)
88   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;}
89
90   /// Use plugin manager for features creation
91   SketchPlugin_Sketch();
92
93   /// Returns the basis plane for the sketch
94   boost::shared_ptr<GeomAPI_Pln> plane();
95
96   virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
97                             boost::shared_ptr<GeomAPI_AISObject> thePrevious);
98
99 protected:
100   /// Creates a plane and append it to the list
101   /// \param theX the X normal value
102   /// \param theY the Y normal value
103   /// \param theZ the Z normal value
104   /// \param theShapes the list of result shapes
105   //void addPlane(double theX, double theY, double theZ,
106   //              std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
107
108   /// Checks whether the plane is set in the sketch.
109   /// \returns the boolean state
110   bool isPlaneSet();
111 };
112
113 #endif