Salome HOME
Dimensions move using ModelAPI_ObjectMovedMessage mechanism. Move by deltas is obsole...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Feature.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef SketchPlugin_Feature_H_
22 #define SketchPlugin_Feature_H_
23
24 #include "SketchPlugin.h"
25 #include <ModelAPI_CompositeFeature.h>
26 #include <GeomAPI_Shape.h>
27 #include <ModelAPI_Document.h>
28 #include <ModelAPI_AttributeSelection.h>
29 #include <ModelAPI_AttributeBoolean.h>
30
31 #include <Config_PropManager.h>
32
33 class SketchPlugin_Sketch;
34
35 /**\class SketchPlugin_Feature
36  * \ingroup Plugins
37  * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
38  * an interface to create the sketch feature preview.
39  */
40 class SketchPlugin_Feature : public ModelAPI_Feature
41 {
42  public:
43   /// Returns true if this feature must be displayed in the history (top level of Part tree)
44   SKETCHPLUGIN_EXPORT virtual bool isInHistory()
45   {
46     return false;
47   }
48
49   /// Returns true of the feature is created basing on the external shape of not-this-sketch object
50   SKETCHPLUGIN_EXPORT virtual bool isExternal() const
51   {
52     return false;
53   }
54
55   /// Returns true if the feature is a copy of other feature
56   SKETCHPLUGIN_EXPORT virtual bool isCopy() const
57   {
58     return false;
59   }
60
61   /// Returns true if the feature and the feature results can be displayed
62   /// \return true
63   SKETCHPLUGIN_EXPORT virtual bool canBeDisplayed() const
64   {
65     return true;
66   }
67
68   /// Construction result is allways recomuted on the fly
69   SKETCHPLUGIN_EXPORT virtual bool isPersistentResult() {return false;}
70
71   /// Returns true is sketch element is under the rigid constraint
72   SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
73
74   /// Returns the sketch of this feature
75   SketchPlugin_Sketch* sketch();
76 protected:
77   /// Sets the higher-level feature for the sub-feature (sketch for line)
78   void setSketch(SketchPlugin_Sketch* theSketch)
79   {
80     mySketch = theSketch;
81   }
82   /// initializes mySketch
83   SketchPlugin_Feature();
84
85   friend class SketchPlugin_Sketch;
86
87  private:
88   std::shared_ptr<GeomAPI_Shape> myPreview;  ///< the preview shape
89   SketchPlugin_Sketch* mySketch;  /// sketch that contains this feature
90 };
91
92 #endif