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