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