Salome HOME
d83e21cceb25894ab2b64b1709dd815a6d6ba239
[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
14 /**\class SketchPlugin_Feature
15  * \ingroup DataModel
16  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
17  * an interface to create the sketch feature preview.
18  */
19 class SketchPlugin_Feature: public ModelAPI_Feature
20 {
21 public:
22   /// Returns the sketch preview
23   /// \param theSketch the owner of this feature
24   /// \return the built preview
25   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
26
27   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
28   /// \param theFeature sub-feature
29   SKETCHPLUGIN_EXPORT virtual const void addSub(
30     const boost::shared_ptr<ModelAPI_Feature>& theFeature) = 0;
31
32   /// Returns true if this feature must be displayed in the history (top level of Part tree)
33   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
34
35 protected:
36   /// Set the shape to the internal preview field
37   /// \param theShape a preview shape
38   void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
39   /// Return the shape from the internal preview field
40   /// \return theShape a preview shape
41   const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
42   /// Sets the higher-level feature for the sub-feature (sketch for line)
43   void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
44   /// Returns the sketch of this feature
45   SketchPlugin_Sketch* sketch() {return mySketch;}
46   /// initializes mySketch
47   SketchPlugin_Feature();
48   /// Sets the data manager of an object and here initializes mySketch field
49   SKETCHPLUGIN_EXPORT virtual void setData(boost::shared_ptr<ModelAPI_Data> theData);
50
51   friend class SketchPlugin_Sketch;
52
53 private:
54   boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
55   SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
56 };
57
58 #endif