]> SALOME platform Git repositories - modules/shaper.git/blob - src/SketchPlugin/SketchPlugin_Sketch.h
Salome HOME
Making compilable all non-GUI classes
[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 <GeomAPI_Pln.h>
12 #include <list>
13
14 /// Sketch feature kind
15 const std::string SKETCH_KIND("Sketch");
16
17 /// Origin point of the sketcher in 3D space
18 const std::string SKETCH_ATTR_ORIGIN("Origin");
19 /// Vector X inside of the sketch plane
20 const std::string SKETCH_ATTR_DIRX("DirX");
21 /// Vector Y inside of the sketch plane
22 const std::string SKETCH_ATTR_DIRY("DirY");
23 /// Vector Z, normal to the sketch plane
24 const std::string SKETCH_ATTR_NORM("Norm");
25 /// All features of this sketch (list of references)
26 const std::string SKETCH_ATTR_FEATURES("Features");
27
28 /**\class SketchPlugin_Sketch
29  * \ingroup DataModel
30  * \brief Feature for creation of the new part in PartSet.
31  */
32 class SketchPlugin_Sketch: public SketchPlugin_Feature
33 {
34 public:
35   /// Returns the kind of a feature
36   SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
37   {static std::string MY_KIND = SKETCH_KIND; return MY_KIND;}
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 AIS preview
46   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
47                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious);
48
49   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
50   /// \param theFeature sub-feature
51   SKETCHPLUGIN_EXPORT virtual const void addSub(
52     const FeaturePtr& theFeature);
53
54   /// Moves the feature
55   /// \param theDeltaX the delta for X coordinate is moved
56   /// \param theDeltaY the delta for Y coordinate is moved
57   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) {};
58
59   /// Return the distance between the feature and the point
60   /// \param thePoint the point
61   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) { return 0; };
62
63   /// Converts a 2D sketch space point into point in 3D space
64   SKETCHPLUGIN_EXPORT boost::shared_ptr<GeomAPI_Pnt> to3D(
65     const double theX, const double theY);
66
67   /// Returns true if this feature must be displayed in the history (top level of Part tree)
68   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return true;}
69
70   /// Use plugin manager for features creation
71   SketchPlugin_Sketch();
72
73   /// Returns the basis plane for the sketch
74   boost::shared_ptr<GeomAPI_Pln> plane();
75 protected:
76   /// Creates a plane and append it to the list
77   /// \param theX the X normal value
78   /// \param theY the Y normal value
79   /// \param theZ the Z normal value
80   /// \param theShapes the list of result shapes
81   void addPlane(double theX, double theY, double theZ,
82                 std::list<boost::shared_ptr<GeomAPI_Shape> >& theShapes) const;
83
84   /// Checks whether the plane is set in the sketch.
85   /// \returns the boolean state
86   bool isPlaneSet();
87 };
88
89 #endif