1 // Copyright (C) 2014-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef SketchPlugin_Feature_H_
21 #define SketchPlugin_Feature_H_
23 #include "SketchPlugin.h"
24 #include <ModelAPI_CompositeFeature.h>
25 #include <GeomAPI_Shape.h>
26 #include <ModelAPI_Document.h>
27 #include <ModelAPI_AttributeSelection.h>
28 #include <ModelAPI_AttributeBoolean.h>
30 #include <Config_PropManager.h>
32 class SketchPlugin_Sketch;
34 /**\class SketchPlugin_Feature
36 * \brief Feature for creation of the new feature in PartSet. This is an abstract class to give
37 * an interface to create the sketch feature preview.
39 class SketchPlugin_Feature : public ModelAPI_Feature
42 /// Returns true if this feature must be displayed in the history (top level of Part tree)
43 SKETCHPLUGIN_EXPORT virtual bool isInHistory()
48 /// Returns true of the feature is created basing on the external shape of not-this-sketch object
49 SKETCHPLUGIN_EXPORT virtual bool isExternal() const
54 /// Returns true if the feature is a copy of other feature
55 SKETCHPLUGIN_EXPORT virtual bool isCopy() const
60 /// Returns true if the feature and the feature results can be displayed
62 SKETCHPLUGIN_EXPORT virtual bool canBeDisplayed() const
67 /// Returns true is sketch element is under the rigid constraint
68 SKETCHPLUGIN_EXPORT virtual bool isFixed() {return false;}
70 /// Returns the sketch of this feature
71 SketchPlugin_Sketch* sketch();
73 /// Sets the higher-level feature for the sub-feature (sketch for line)
74 void setSketch(SketchPlugin_Sketch* theSketch)
78 /// initializes mySketch
79 SketchPlugin_Feature();
81 /// Store current feature of the document if it is not the sub-feature of the current sketch
82 void keepCurrentFeature();
83 /// Restore current feature of the document after adding new feature to the sketch
84 void restoreCurrentFeature();
86 friend class SketchPlugin_Sketch;
89 std::shared_ptr<GeomAPI_Shape> myPreview; ///< the preview shape
90 SketchPlugin_Sketch* mySketch; /// sketch that contains this feature
92 FeaturePtr myCurrentFeature; /// temporary stored current feature