Salome HOME
Merge branch 'master' into Dev_1.1.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        SketchPlugin_Feature.h
4 // Created:     27 Mar 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef SketchPlugin_Feature_H_
8 #define SketchPlugin_Feature_H_
9
10 #include "SketchPlugin.h"
11 #include <ModelAPI_CompositeFeature.h>
12 #include <GeomAPI_Shape.h>
13 #include <GeomAPI_AISObject.h>
14 #include <ModelAPI_Document.h>
15 #include <ModelAPI_AttributeSelection.h>
16 #include <ModelAPI_AttributeBoolean.h>
17
18 #include <Config_PropManager.h>
19
20 class SketchPlugin_Sketch;
21 class GeomAPI_Pnt2d;
22 class Handle_AIS_InteractiveObject;
23
24 /**\class SketchPlugin_Feature
25  * \ingroup Plugins
26  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
27  * an interface to create the sketch feature preview.
28  */
29 class SketchPlugin_Feature : public ModelAPI_Feature
30 {
31  public:
32   /// Returns true if this feature must be displayed in the history (top level of Part tree)
33   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
34   {
35     return false;
36   }
37
38   /// Returns true of the feature is created basing on the external shape of not-this-sketch object
39   SKETCHPLUGIN_EXPORT virtual bool isExternal() const
40   {
41     return false;
42   }
43
44   /// Moves the feature
45   /// \param theDeltaX the delta for X coordinate is moved
46   /// \param theDeltaY the delta for Y coordinate is moved
47   SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) = 0;
48
49   /// Return the distance between the feature and the point
50   /// \param thePoint the point
51   virtual double distanceToPoint(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint) = 0;
52
53   /// Construction result is allways recomuted on the fly
54   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
55
56   /// Returns true is sketch element is under the rigid constraint
57   SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
58
59   /// Returns the sketch of this feature
60   SketchPlugin_Sketch* sketch();
61 protected:
62   /// Sets the higher-level feature for the sub-feature (sketch for line)
63   void setSketch(SketchPlugin_Sketch* theSketch)
64   {
65     mySketch = theSketch;
66   }
67   /// initializes mySketch
68   SketchPlugin_Feature();
69
70   friend class SketchPlugin_Sketch;
71
72  private:
73   std::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
74   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
75 };
76
77 #endif