Salome HOME
Composite Feature implementation. Sketch now is Composite.
[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_H_
6 #define SketchPlugin_Feature_H_
7
8 #include "SketchPlugin.h"
9 #include <ModelAPI_CompositeFeature.h>
10 #include <GeomAPI_Shape.h>
11 #include <GeomAPI_AISObject.h>
12 #include <ModelAPI_Document.h>
13
14 class SketchPlugin_Sketch;
15 class GeomAPI_Pnt2d;
16 class Handle_AIS_InteractiveObject;
17
18 /**\class SketchPlugin_Feature
19  * \ingroup DataModel
20  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
21  * an interface to create the sketch feature preview.
22  */
23 class SketchPlugin_Feature : public ModelAPI_Feature
24 {
25  public:
26   /// Simple creation of interactive object by the result of the object
27   static AISObjectPtr simpleAISObject(boost::shared_ptr<ModelAPI_Result> theRes,
28                                       AISObjectPtr thePrevious);
29
30   /// Returns true if this feature must be displayed in the history (top level of Part tree)
31   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
32   {
33     return false;
34   }
35
36   /// Moves the feature
37   /// \param theDeltaX the delta for X coordinate is moved
38   /// \param theDeltaY the delta for Y coordinate is moved
39   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
40
41   /// Return the distance between the feature and the point
42   /// \param thePoint the point
43   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
44
45   /// Construction result is allways recomuted on the fly
46   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
47
48 protected:
49   /// Sets the higher-level feature for the sub-feature (sketch for line)
50   void setSketch(SketchPlugin_Sketch* theSketch)
51   {
52     mySketch = theSketch;
53   }
54   /// Returns the sketch of this feature
55   SketchPlugin_Sketch* sketch();
56   /// initializes mySketch
57   SketchPlugin_Feature();
58
59   friend class SketchPlugin_Sketch;
60
61  private:
62   boost::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
63   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
64 };
65
66 #endif