Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SketchSolver
[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 #include <GeomAPI_AISObject.h>
12
13 class SketchPlugin_Sketch;
14 class GeomAPI_Pnt2d;
15 class Handle_AIS_InteractiveObject;
16
17 /**\class SketchPlugin_Feature
18  * \ingroup DataModel
19  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
20  * an interface to create the sketch feature preview.
21  */
22 class SketchPlugin_Feature: public ModelAPI_Feature
23 {
24 public:
25   /// Returns the sketch preview
26   /// \param theSketch the owner of this feature
27   /// \return the built preview
28   SKETCHPLUGIN_EXPORT virtual const boost::shared_ptr<GeomAPI_Shape>& preview() = 0;
29
30   /// Returns the AIS preview
31   SKETCHPLUGIN_EXPORT virtual boost::shared_ptr<GeomAPI_AISObject> getAISObject(
32                                 boost::shared_ptr<GeomAPI_AISObject> thePrevious) = 0;
33
34   /// Adds sub-feature of the higher level feature (sub-element of the sketch)
35   /// \param theFeature sub-feature
36   SKETCHPLUGIN_EXPORT virtual const void addSub(
37     const FeaturePtr& theFeature) = 0;
38
39   /// Returns true if this feature must be displayed in the history (top level of Part tree)
40   SKETCHPLUGIN_EXPORT virtual bool isInHistory() {return false;}
41
42   /// Moves the feature
43   /// \param theDeltaX the delta for X coordinate is moved
44   /// \param theDeltaY the delta for Y coordinate is moved
45   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
46
47   /// Return the distance between the feature and the point
48   /// \param thePoint the point
49   virtual double distanceToPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
50
51 protected:
52   /// Set the shape to the internal preview field
53   /// \param theShape a preview shape
54   void setPreview(const boost::shared_ptr<GeomAPI_Shape>& theShape); ///< the preview shape
55   /// Return the shape from the internal preview field
56   /// \return theShape a preview shape
57   const boost::shared_ptr<GeomAPI_Shape>& getPreview() const;
58   /// Common method for other features to produce AIS shape
59   boost::shared_ptr<GeomAPI_AISObject> prepareAISShape(
60                       boost::shared_ptr<GeomAPI_AISObject> thePrevious);
61   /// Sets the higher-level feature for the sub-feature (sketch for line)
62   void setSketch(SketchPlugin_Sketch* theSketch) {mySketch = theSketch;}
63   /// Returns the sketch of this feature
64   SketchPlugin_Sketch* sketch();
65   /// initializes mySketch
66   SketchPlugin_Feature();
67
68   friend class SketchPlugin_Sketch;
69
70 private:
71   boost::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
72   SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
73 };
74
75 #endif