X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModel%2FModel_Document.h;h=1dec08f14434d02d8557ee83fd2b936cb8f6dabe;hb=06e7f5859095193fc7f498bd89a7d28009794f53;hp=45b0923adb3599403f46e18ec8ae1972fcf2157d;hpb=87bb3bb183012fd6ad662c785e575fff56897905;p=modules%2Fshaper.git diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 45b0923ad..1dec08f14 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // 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 +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #ifndef Model_Document_H_ @@ -57,6 +56,17 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual bool load( const char* theDirName, const char* theFileName, DocumentPtr theThis); + //! Loads the OCAF document from the file into the current document. + //! All the features are added after the active feature. + //! \param theFileName name of the file to import + //! \param theImported list of features imported from the file + //! \param theCheckOnly verify the document does not contain unappropriate features + //! (useful for import to PartSet), but do not import it + //! \returns true if file was loaded successfully + MODEL_EXPORT virtual bool importPart(const char* theFileName, + std::list >& theImported, + bool theCheckOnly = false); + //! Saves the OCAF document to the file. //! \param theDirName directory where the document will be saved //! \param theFileName a name of the document file to store @@ -65,6 +75,12 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual bool save( const char* theDirName, const char* theFileName, std::list& theResults); + //! Export the list of features to the file + //! \param theFilename path to save the file + //! \param theExportFeatures list of features to export + MODEL_EXPORT virtual bool save(const char* theFilename, + const std::list >& theExportFeatures) const; + //! Removes document data //! \param theForever if it is false, document is just hidden //! (to keep possibility make it back on Undo/Redo) @@ -90,6 +106,8 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual bool canRedo(); //! Redoes last operation MODEL_EXPORT virtual void redo(); + //! Clears undo/redo lists + MODEL_EXPORT virtual void clearUndoRedo(); //! Adds to the document the new feature of the given feature id //! \param theID creates feature and puts it in the document @@ -111,14 +129,15 @@ class Model_Document : public ModelAPI_Document MODEL_EXPORT virtual void removeFeature(FeaturePtr theFeature); //! Moves the feature to make it after the given one in the history. - MODEL_EXPORT virtual void moveFeature(FeaturePtr theMoved, FeaturePtr theAfterThis); + MODEL_EXPORT virtual void moveFeature( + FeaturePtr theMoved, FeaturePtr theAfterThis, const bool theSplit = false); //! Returns the first found object in the group by the object name //! \param theGroupID group that contains an object //! \param theName name of the object to search //! \returns null if such object is not found MODEL_EXPORT virtual std::shared_ptr objectByName( - const std::string& theGroupID, const std::string& theName); + const std::string& theGroupID, const std::wstring& theName); //! Returns the object index in the group. Object must be visible. Otherwise returns -1. //! \param theObject object of this document @@ -256,18 +275,20 @@ class Model_Document : public ModelAPI_Document void setExecuteFeatures(const bool theFlag); //! Registers the name of the shape for the topological naming needs - void addNamingName(const TDF_Label theLabel, std::string theName); + void addNamingName(const TDF_Label theLabel, std::wstring theName); //! Updates the name of some object - void changeNamingName(std::string theOldName, const std::string theNewName, + void changeNamingName(std::wstring theOldName, const std::wstring theNewName, const TDF_Label& theLabel); //! Returns the label, keeper of the name for the topological naming needs - TDF_Label findNamingName(std::string theName, ResultPtr theContext); + TDF_Label findNamingName(std::wstring theName, ResultPtr theContext); //! Returns the number of the name in the history relatively to the given object (by label). //! Start from 1 (this object). int numberOfNameInHistory(const ObjectPtr& theNameObject, const TDF_Label& theStartFrom); //! Returns the result by name of the result (names of results must be unique, used for naming //! selection by name. - ResultPtr findByName(std::string& theName, std::string& theSubShapeName, bool& theUniqueContext); + ResultPtr findByName(std::wstring& theName, + std::wstring& theSubShapeName, + bool& theUniqueContext); ///! Returns all features of the document including the hidden features which are not in ///! history. Not very fast method, for calling once, not in big cycles. @@ -300,6 +321,14 @@ class Model_Document : public ModelAPI_Document /// Just removes all features without touching the document data (to be able undo) MODEL_EXPORT virtual void eraseAllFeatures(); + /// Returns the next (from the history point of view) feature, any: invisible or disabled + /// \param theCurrent previous to the resulting feature + /// \param theReverse if it is true, iterates in reversed order (next becomes previous) + MODEL_EXPORT virtual std::shared_ptr nextFeature( + std::shared_ptr theCurrent, const bool theReverse = false) const; + + //! Erases the document structure. + ~Model_Document(); protected: //! Returns (creates if needed) the general label @@ -391,6 +420,7 @@ class Model_Document : public ModelAPI_Document friend class Model_AttributeRefList; friend class Model_AttributeRefAttrList; friend class Model_AttributeSelection; + friend class Model_AttributeSelectionList; friend class Model_ResultPart; friend class Model_ResultBody; friend class Model_ResultConstruction; @@ -427,7 +457,7 @@ class Model_Document : public ModelAPI_Document //! Optimization for finding the shape-label by topological naming names //! The name -> list of labels where this name is appeared (the last created name is last here) - std::map > myNamingNames; + std::map > myNamingNames; //! If it is true, features are not executed on update (on abort, undo, redo) bool myExecuteFeatures;