Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModelAPI / ModelAPI_CompositeFeature.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 MODELAPI_COMPOSITEFEATURE_H_
22 #define MODELAPI_COMPOSITEFEATURE_H_
23
24 #include "ModelAPI.h"
25 #include "ModelAPI_Feature.h"
26
27 /**\class ModelAPI_CompositeFeature
28  * \ingroup DataModel
29  * \brief Feature that consists of other features: like sketcher
30  * with edges inside. It just allows to add a feature to this feature only
31  * instead of adding in both document and this feature.
32  */
33 class ModelAPI_CompositeFeature : public ModelAPI_Feature
34 {
35 public:
36   MODELAPI_EXPORT virtual ~ModelAPI_CompositeFeature();
37
38   /// Adds feature to the sketch and to its document
39   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
40
41   /// Returns the number of sub-elements
42   virtual int numberOfSubs(bool forTree = false) const = 0;
43
44   /// Returns the sub-feature by zero-base index
45   virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex,
46                                                        bool forTree = false) = 0;
47
48   /// Returns the sub-feature unique identifier in this composite feature by zero-base index
49   virtual int subFeatureId(const int theIndex) const = 0;
50
51   /// Returns true if feature or result belong to this composite feature as subs
52   virtual bool isSub(ObjectPtr theObject) const = 0;
53
54   /// This method to inform that sub-feature is removed and must be removed from the internal data
55   /// structures of the owner (the remove from the document will be done outside just after)
56   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
57
58   /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769)
59   MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
60     std::shared_ptr<ModelAPI_Feature> theFeature2);
61
62   /// in addition removes all subs
63   MODELAPI_EXPORT virtual void erase();
64 };
65
66 //! Pointer on the composite feature object
67 typedef std::shared_ptr<ModelAPI_CompositeFeature> CompositeFeaturePtr;
68
69 #endif