Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into BR_coding_rules
[modules/shaper.git] / src / ModelAPI / ModelAPI_CompositeFeature.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_CompositeFeature.h
4 // Created:     20 Oct 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef MODELAPI_COMPOSITEFEATURE_H_
8 #define MODELAPI_COMPOSITEFEATURE_H_
9
10 #include "ModelAPI.h"
11 #include "ModelAPI_Feature.h"
12
13 /**\class ModelAPI_CompositeFeature
14  * \ingroup DataModel
15  * \brief Feature that consists of other features: like sketcher
16  * with edges inside. It just allows to add a feature to this feature only
17  * instead of adding in both document and this feature.
18  */
19 class ModelAPI_CompositeFeature : public ModelAPI_Feature
20 {
21 public:
22   MODELAPI_EXPORT virtual ~ModelAPI_CompositeFeature();
23
24   /// Adds feature to the sketch and to its document
25   virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID) = 0;
26
27   /// Returns the number of sub-elements
28   virtual int numberOfSubs(bool forTree = false) const = 0;
29
30   /// Returns the sub-feature by zero-base index
31   virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex,
32                                                        bool forTree = false) = 0;
33
34   /// Returns the sub-feature unique identifier in this composite feature by zero-base index
35   virtual int subFeatureId(const int theIndex) const = 0;
36
37   /// Returns true if feature or result belong to this composite feature as subs
38   virtual bool isSub(ObjectPtr theObject) const = 0;
39
40   /// This method to inform that sub-feature is removed and must be removed from the internal data
41   /// structures of the owner (the remove from the document will be done outside just after)
42   virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) = 0;
43
44   /// Exchanges IDs of two given features: needed for more correct naming in some cases (issue 769)
45   MODELAPI_EXPORT virtual void exchangeIDs(std::shared_ptr<ModelAPI_Feature> theFeature1,
46     std::shared_ptr<ModelAPI_Feature> theFeature2);
47
48   /// in addition removes all subs
49   MODELAPI_EXPORT virtual void erase();
50 };
51
52 //! Pointer on the composite feature object
53 typedef std::shared_ptr<ModelAPI_CompositeFeature> CompositeFeaturePtr;
54
55 #endif