Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.h
1 // File:        SketchPlugin_Feature.h
2 // Created:     27 Mar 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef SketchPlugin_Feature_HeaderFile
6 #define SketchPlugin_Feature_HeaderFile
7
8 #include "SketchPlugin.h"
9 #include <ModelAPI_Feature.h>
10 #include <GeomAPI_Shape.h>
11
12 class SketchPlugin_Sketch;
13 class GeomAPI_Pnt2d;
14 class Handle_AIS_InteractiveObject;
15
16 /**\class SketchPlugin_Feature
17  * \ingroup DataModel
18  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
19  * an interface to create the sketch feature preview.
20  */
21 class SketchPlugin_Feature: public ModelAPI_Feature
22 {
23 public:
24   /// Returns the sketch preview
25   /// \param theSketch the owner of this feature
26   /// \return the built preview
27   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
28
29   /// Returns the AIS preview
30   SKETCHPLUGIN_EXPORT virtual Handle_AIS_InteractiveObject getAISShape(Handle_AIS_InteractiveObject thePrevious);
31
32   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
33   /// \param theFeature sub-feature
34   SKETCHPLUGIN_EXPORT virtual const void addSub(
35     const FeaturePtr& theFeature) = 0;
36
37   /// Returns true if this feature must be displayed in the history (top level of Part tree)
38   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
39
40   /// Moves the feature
41   /// \param theDeltaX the delta for X coordinate is moved
42   /// \param theDeltaY the delta for Y coordinate is moved
43   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
44
45   /// Return the distance between the feature and the point
46   /// \param thePoint the point
47   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
48
49 protected:
50   /// Set the shape to the internal preview field
51   /// \param theShape a preview shape
52   void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
53   /// Return the shape from the internal preview field
54   /// \return theShape a preview shape
55   const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
56   /// Sets the higher-level feature for the sub-feature (sketch for line)
57   void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
58   /// Returns the sketch of this feature
59   SketchPlugin_Sketch* sketch();
60   /// initializes mySketch
61   SketchPlugin_Feature();
62
63   friend class SketchPlugin_Sketch;
64
65 private:
66   boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
67   SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
68 };
69
70 #endif