Salome HOME
Updated copyright comment
[modules/shaper.git] / src / PartSetPlugin / PartSetPlugin_Part.h
index 0f921727129f03036314e6d9531f8d53df209728..bfd1efbe5ea5befe836f27d9662b0f20741e485b 100644 (file)
@@ -1,33 +1,57 @@
-// File:        PartSetPlugin_Part.h
-// Created:     27 Mar 2014
-// Author:      Mikhail PONIKAROV
+// Copyright (C) 2014-2024  CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
-#ifndef PartSetPlugin_Part_HeaderFile
-#define PartSetPlugin_Part_HeaderFile
+#ifndef PartSetPlugin_Part_H_
+#define PartSetPlugin_Part_H_
 
 #include "PartSetPlugin.h"
-#include <ModelAPI_Feature.h>
-
-/// Part kind
-const std::string PARTSET_PART_KIND("Part");
-
-/// part reference attribute
-const std::string PART_ATTR_DOC_REF = "PartDocument";
+#include <ModelAPI_CompositeFeature.h>
 
 /**\class PartSetPlugin_Part
- * \ingroup DataModel
+ * \ingroup Plugins
  * \brief Feature for creation of the new part in PartSet.
+ * All sub-features are sub-elements of composite feature.
  */
-class PartSetPlugin_Part: public ModelAPI_Feature
+class PartSetPlugin_Part : public ModelAPI_CompositeFeature
 {
-public:
+ public:
+  /// Part kind
+  inline static const std::string& ID()
+  {
+    static const std::string MY_PART_KIND("Part");
+    return MY_PART_KIND;
+  }
   /// Returns the kind of a feature
-  PARTSETPLUGIN_EXPORT virtual const std::string& getKind() 
-  {static std::string MY_KIND = PARTSET_PART_KIND; return MY_KIND;}
+  PARTSETPLUGIN_EXPORT virtual const std::string& getKind()
+  {
+    static std::string MY_KIND = PartSetPlugin_Part::ID();
+    return MY_KIND;
+  }
 
+//LCOV_EXCL_START
   /// Returns to which group in the document must be added feature
-  PARTSETPLUGIN_EXPORT virtual const std::string& getGroup() 
-  {static std::string MY_GROUP = "Parts"; return MY_GROUP;}
+  PARTSETPLUGIN_EXPORT virtual const std::string& getGroup()
+  {
+    static std::string MY_GROUP = "Parts";
+    return MY_GROUP;
+  }
+//LCOV_EXCL_STOP
 
   /// Creates a new part document if needed
   PARTSETPLUGIN_EXPORT virtual void execute();
@@ -35,13 +59,35 @@ public:
   /// Request for initialization of data model of the feature: adding all attributes
   PARTSETPLUGIN_EXPORT virtual void initAttributes();
 
-  PARTSETPLUGIN_EXPORT virtual boost::shared_ptr<ModelAPI_Document> documentToAdd();
+  /// Part must be added only to PartSet
+  PARTSETPLUGIN_EXPORT virtual const std::string& documentToAdd();
+
+  // composite feature methods
+
+  /// Adds feature to its document
+  virtual std::shared_ptr<ModelAPI_Feature> addFeature(std::string theID);
+
+  /// Returns the number of sub-features of the document
+  virtual int numberOfSubs(bool forTree = false) const;
 
-  /// Returns true if this feature must be displayed in the history (top level of Part tree)
-  PARTSETPLUGIN_EXPORT virtual bool isInHistory() {return false;}
+  /// Returns the sub-feature by zero-base index
+  virtual std::shared_ptr<ModelAPI_Feature> subFeature(const int theIndex, bool forTree = false);
+
+  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
+  virtual int subFeatureId(const int theIndex) const;
+
+  /// Returns true if feature or reuslt belong to this composite feature as subs
+  virtual bool isSub(ObjectPtr theObject) const;
+
+  /// This method to inform that sub-feature is removed and must be removed from the internal data
+  /// structures of the owner (the remove from the document will be done outside just after)
+  virtual void removeFeature(std::shared_ptr<ModelAPI_Feature> theFeature) {}
 
   /// Use plugin manager for features creation
   PartSetPlugin_Part();
+
+  /// Just removes all features of the part without touching the document data (to be able undo)
+  PARTSETPLUGIN_EXPORT virtual void erase();
 };
 
 #endif