1 // Copyright (C) 2014-2024 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 SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
31 //--------------------------------------------------------------------------------------
32 class ModelAPI_Feature;
33 class ModelAPI_Result;
34 class ModelHighAPI_Selection;
35 class ModelHighAPI_Dumper;
39 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
40 //--------------------------------------------------------------------------------------
41 /**\class ModelHighAPI_Interface
43 * \brief Base class for feature interfaces
45 class ModelHighAPI_Interface
50 explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
53 virtual ~ModelHighAPI_Interface();
55 /// Return ModelAPI_Feature
57 std::shared_ptr<ModelAPI_Feature> feature() const;
59 /// If feature is composite return intefrace for sub-feature by zero-based index,
60 /// or empty pointer if feature not composite or does not have sub-feature with such index.
62 std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
64 /// Shortcut for feature()->getKind()
66 const std::string& getKind() const;
68 /// Shortcut for feature()->execute()
69 /// \param isForce start execution of feature instead of sending events
71 void execute(bool isForce = false);
73 /// Shortcut for feature()->data()->setName()
75 void setName(const std::wstring& theName);
77 /// Shortcut for feature()->data()->name()
79 std::wstring name() const;
81 /// Return firts object of the feature
83 virtual ModelHighAPI_Selection result() const;
85 /// Return all objects of the feature
87 virtual std::list<ModelHighAPI_Selection> results() const;
89 /// Return default result. Default implementation feature()->lastResult()
91 virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
93 /// Throw exception to event loop
95 void throwException(const std::string & theDescription);
97 /// Return name of getter for specified attribute
99 const std::string& attributeGetter(const std::string& theAttrName);
101 /// Dump wrapped feature
103 virtual void dump(ModelHighAPI_Dumper& /*theDumper*/) const {}
105 /// Returns all the vertices produced by this feature
106 MODELHIGHAPI_EXPORT virtual ListOfShape
107 vertices(const bool theOnlyUnique = false);
109 /// Returns all the edges produced by this feature
110 MODELHIGHAPI_EXPORT virtual ListOfShape
111 edges(const bool theOnlyUnique = false);
113 /// Returns all the wires produced by this feature
114 MODELHIGHAPI_EXPORT virtual ListOfShape
115 wires(const bool theOnlyUnique = false);
117 /// Returns all the faces produced by this feature
118 MODELHIGHAPI_EXPORT virtual ListOfShape
119 faces(const bool theOnlyUnique = false);
121 /// Returns all the shells produced by this feature
122 MODELHIGHAPI_EXPORT virtual ListOfShape
123 shells(const bool theOnlyUnique = false);
125 /// Returns all the solids produced by this feature
126 MODELHIGHAPI_EXPORT virtual ListOfShape
127 solids(const bool theOnlyUnique = false);
130 std::shared_ptr<ModelAPI_Feature> myFeature; ///< feature of this interface
132 std::map<std::string, std::string> myAttrGetter; ///< names of attributes and their getters
135 //! Pointer on Interface object
136 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
138 //--------------------------------------------------------------------------------------
139 //--------------------------------------------------------------------------------------
140 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */