]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Added removeFolder high level API level and make folders correctly refreshed in the...
authormpv <mpv@opencascade.com>
Fri, 23 Aug 2019 12:34:52 +0000 (15:34 +0300)
committervsv <vsv@opencascade.com>
Wed, 6 Nov 2019 08:22:44 +0000 (11:22 +0300)
src/ModelHighAPI/ModelHighAPI_Folder.cpp
src/ModelHighAPI/ModelHighAPI_Folder.h
src/PythonAPI/model/services/__init__.py
src/PythonAddons/macros/compoundVertices/feature.py

index 3640677a3a0b12de0009c615a7e44f95c51acd0a..b47d4b48de92e3235940c80389119d77aea5c0cc 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_Document.h>
+#include <ModelAPI_Events.h>
 
 //--------------------------------------------------------------------------------------
 
@@ -109,5 +110,13 @@ std::shared_ptr<ModelHighAPI_Folder> addFolder(const std::shared_ptr<ModelAPI_Do
   AttributeReferencePtr aLastFeatAttr = aFolder->reference(ModelAPI_Folder::LAST_FEATURE_ID());
   fillAttribute(theLastFeature.feature(), aLastFeatAttr);
 
+  // to update the folder state in the Object Browser
+  theDoc->updateHistory(ModelAPI_Feature::group());
+
   return std::shared_ptr<ModelHighAPI_Folder>(new ModelHighAPI_Folder(aFolder));
 }
+
+void removeFolder(std::shared_ptr<ModelHighAPI_Folder>& theFolder)
+{
+  theFolder->folder()->document()->removeFolder(theFolder->folder());
+}
index 66fe99b3c9c95676f903819dcee2c91a4113aa10..2f99aabf82d865f95c571897f3a24e5c9a705aaa 100644 (file)
@@ -46,6 +46,7 @@ public:
 
   static std::string ID() { return ModelAPI_Folder::ID(); }
   virtual std::string getID() { return ID(); }
+  const std::shared_ptr<ModelAPI_Folder>& folder() const {return myFolder;}
 
   /// First feature reference
   std::shared_ptr<ModelAPI_AttributeReference> firstFeature() const
@@ -63,6 +64,11 @@ public:
   MODELHIGHAPI_EXPORT
   std::string name() const;
 
+  /// To update the folder state
+  /// \param isForce start execution of feature instead of sending events
+  //MODELHIGHAPI_EXPORT void execute();
+
+
   /// Dump wrapped feature
   MODELHIGHAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const;
 
@@ -90,5 +96,10 @@ MODELHIGHAPI_EXPORT
 std::shared_ptr<ModelHighAPI_Folder> addFolder(const std::shared_ptr<ModelAPI_Document>& theDoc,
                                                const ModelHighAPI_Reference& theFirstFeature,
                                                const ModelHighAPI_Reference& theLastFeature);
+/**\ingroup CPPHighAPI
+* \brief Removes Folder feature
+*/
+MODELHIGHAPI_EXPORT
+void removeFolder(std::shared_ptr<ModelHighAPI_Folder>& theFolder);
 //--------------------------------------------------------------------------------------
 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_FOLDER_H_ */
index 74336295962a41229c49f67cea7f8897398c6b6d..d585c1891f9f763f7c72b283abf3af3268d7c1f0 100644 (file)
@@ -26,6 +26,6 @@ from ModelHighAPI import apply as do
 from ModelHighAPI import updateFeatures
 from ModelHighAPI import undo, redo
 from ModelHighAPI import reset
-from ModelHighAPI import addFolder
+from ModelHighAPI import addFolder, removeFolder
 from ModelHighAPI import ModelHighAPI_Selection as selection
 from ModelHighAPI import checkPythonDump as checkPythonDump
index 0f2189c1ec2a7c6e18e10d804438f9c59e8fd807..224a21313e08fda23a1a246923c2b4c85e8a9034 100644 (file)
@@ -65,7 +65,7 @@ class compoundVertices(model.Feature):
                 for feature in self.lfeatures:
                    part.removeFeature(feature.feature())
                 self.lfeatures = []
-                #part.removeFeature(self.folder.feature())
+                model.removeFolder(self.folder)
 
             from os.path import basename
             filename = basename(filepath)