From: mpv Date: Fri, 23 Aug 2019 12:34:52 +0000 (+0300) Subject: Added removeFolder high level API level and make folders correctly refreshed in the... X-Git-Tag: V9_4_0a2~7^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4e332d92c56137fad9e98bf47a6c47ff5f7d3d2a;p=modules%2Fshaper.git Added removeFolder high level API level and make folders correctly refreshed in the Object Browser even without transaction end. --- diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.cpp b/src/ModelHighAPI/ModelHighAPI_Folder.cpp index 3640677a3..b47d4b48d 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Folder.cpp @@ -24,6 +24,7 @@ #include #include +#include //-------------------------------------------------------------------------------------- @@ -109,5 +110,13 @@ std::shared_ptr addFolder(const std::shared_ptrreference(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(new ModelHighAPI_Folder(aFolder)); } + +void removeFolder(std::shared_ptr& theFolder) +{ + theFolder->folder()->document()->removeFolder(theFolder->folder()); +} diff --git a/src/ModelHighAPI/ModelHighAPI_Folder.h b/src/ModelHighAPI/ModelHighAPI_Folder.h index 66fe99b3c..2f99aabf8 100644 --- a/src/ModelHighAPI/ModelHighAPI_Folder.h +++ b/src/ModelHighAPI/ModelHighAPI_Folder.h @@ -46,6 +46,7 @@ public: static std::string ID() { return ModelAPI_Folder::ID(); } virtual std::string getID() { return ID(); } + const std::shared_ptr& folder() const {return myFolder;} /// First feature reference std::shared_ptr 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 addFolder(const std::shared_ptr& theDoc, const ModelHighAPI_Reference& theFirstFeature, const ModelHighAPI_Reference& theLastFeature); +/**\ingroup CPPHighAPI +* \brief Removes Folder feature +*/ +MODELHIGHAPI_EXPORT +void removeFolder(std::shared_ptr& theFolder); //-------------------------------------------------------------------------------------- #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_FOLDER_H_ */ diff --git a/src/PythonAPI/model/services/__init__.py b/src/PythonAPI/model/services/__init__.py index 743362959..d585c1891 100644 --- a/src/PythonAPI/model/services/__init__.py +++ b/src/PythonAPI/model/services/__init__.py @@ -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 diff --git a/src/PythonAddons/macros/compoundVertices/feature.py b/src/PythonAddons/macros/compoundVertices/feature.py index 0f2189c1e..224a21313 100644 --- a/src/PythonAddons/macros/compoundVertices/feature.py +++ b/src/PythonAddons/macros/compoundVertices/feature.py @@ -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)