|
||||
File indexing completed on 2025-01-18 10:05:21
0001 // Created on: 1999-04-07 0002 // Created by: Denis PASCAL 0003 // Copyright (c) 1999 Matra Datavision 0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS 0005 // 0006 // This file is part of Open CASCADE Technology software library. 0007 // 0008 // This library is free software; you can redistribute it and/or modify it under 0009 // the terms of the GNU Lesser General Public License version 2.1 as published 0010 // by the Free Software Foundation, with special exception defined in the file 0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0012 // distribution for complete text of the license and disclaimer of any warranty. 0013 // 0014 // Alternatively, this file may be used under the terms of Open CASCADE 0015 // commercial license or contractual agreement. 0016 0017 #ifndef _TDocStd_Document_HeaderFile 0018 #define _TDocStd_Document_HeaderFile 0019 0020 #include <Standard.hxx> 0021 0022 #include <Standard_Integer.hxx> 0023 #include <TDF_Transaction.hxx> 0024 #include <TDF_DeltaList.hxx> 0025 #include <CDM_Document.hxx> 0026 #include <TDF_LabelMap.hxx> 0027 #include <TDocStd_FormatVersion.hxx> 0028 class TDF_Data; 0029 class TDF_Delta; 0030 class TDF_Label; 0031 class TCollection_AsciiString; 0032 class TDocStd_CompoundDelta; 0033 0034 0035 class TDocStd_Document; 0036 DEFINE_STANDARD_HANDLE(TDocStd_Document, CDM_Document) 0037 0038 //! The contents of a TDocStd_Application, a 0039 //! document is a container for a data framework 0040 //! composed of labels and attributes. As such, 0041 //! TDocStd_Document is the entry point into the data framework. 0042 //! To gain access to the data, you create a document as follows: 0043 //! Handle(TDocStd_Document) MyDF = new TDocStd_Document 0044 //! The document also allows you to manage: 0045 //! - modifications, providing Undo and Redo functions. 0046 //! - command transactions. 0047 //! Warning: The only data saved is the framework (TDF_Data) 0048 class TDocStd_Document : public CDM_Document 0049 { 0050 0051 public: 0052 0053 0054 //! Will Abort any execution, clear fields 0055 //! returns the document which contains <L>. raises an 0056 //! exception if the document is not found. 0057 Standard_EXPORT static Handle(TDocStd_Document) Get (const TDF_Label& L); 0058 0059 //! Constructs a document object defined by the 0060 //! string astorageformat. 0061 //! If a document is created outside of an application using this constructor, it must be 0062 //! managed by a Handle. Otherwise memory problems could appear: call of TDocStd_Owner::GetDocument 0063 //! creates a Handle(TDocStd_Document), so, releasing it will produce a crash. 0064 Standard_EXPORT TDocStd_Document(const TCollection_ExtendedString& astorageformat); 0065 0066 //! the document is saved in a file. 0067 Standard_EXPORT Standard_Boolean IsSaved() const; 0068 0069 //! returns True if document differs from the state of last saving. 0070 //! this method have to be called only working in the transaction mode 0071 Standard_Boolean IsChanged() const; 0072 0073 //! This method have to be called to show document that it has been saved 0074 void SetSaved(); 0075 0076 //! Say to document what it is not saved. 0077 //! Use value, returned earlier by GetSavedTime(). 0078 void SetSavedTime (const Standard_Integer theTime); 0079 0080 //! Returns value of <mySavedTime> to be used later in SetSavedTime() 0081 Standard_Integer GetSavedTime() const; 0082 0083 //! raise if <me> is not saved. 0084 Standard_EXPORT TCollection_ExtendedString GetName() const; 0085 0086 //! returns the OS path of the file, in which one <me> is 0087 //! saved. Raise an exception if <me> is not saved. 0088 Standard_EXPORT TCollection_ExtendedString GetPath() const; 0089 0090 Standard_EXPORT void SetData (const Handle(TDF_Data)& data); 0091 0092 Standard_EXPORT Handle(TDF_Data) GetData() const; 0093 0094 //! Returns the main label in this data framework. 0095 //! By definition, this is the label with the entry 0:1. 0096 Standard_EXPORT TDF_Label Main() const; 0097 0098 //! Returns True if the main label has no attributes 0099 Standard_EXPORT Standard_Boolean IsEmpty() const; 0100 0101 //! Returns False if the document has been modified 0102 //! but not recomputed. 0103 Standard_EXPORT Standard_Boolean IsValid() const; 0104 0105 //! Notify the label as modified, the Document becomes UnValid. 0106 //! returns True if <L> has been notified as modified. 0107 Standard_EXPORT void SetModified (const TDF_Label& L); 0108 0109 //! Remove all modifications. After this call The document 0110 //! becomesagain Valid. 0111 Standard_EXPORT void PurgeModified(); 0112 0113 //! Returns the labels which have been modified in 0114 //! this document. 0115 Standard_EXPORT const TDF_LabelMap& GetModified() const; 0116 0117 //! Launches a new command. This command may be undone. 0118 Standard_EXPORT void NewCommand(); 0119 0120 //! returns True if a Command transaction is open in the curret . 0121 Standard_EXPORT Standard_Boolean HasOpenCommand() const; 0122 0123 //! Opens a new command transaction in this document. 0124 //! You can use HasOpenCommand to see whether a command is already open. 0125 //! Exceptions 0126 //! Standard_DomainError if a command is already open in this document. 0127 Standard_EXPORT void OpenCommand(); 0128 0129 //! Commits documents transactions and fills the 0130 //! transaction manager with documents that have 0131 //! been changed during the transaction. 0132 //! If no command transaction is open, nothing is done. 0133 //! Returns True if a new delta has been added to myUndos. 0134 Standard_EXPORT Standard_Boolean CommitCommand(); 0135 0136 //! Abort the Command transaction. Does nothing If there is 0137 //! no Command transaction open. 0138 Standard_EXPORT void AbortCommand(); 0139 0140 //! The current limit on the number of undos 0141 Standard_EXPORT Standard_Integer GetUndoLimit() const; 0142 0143 //! Set the limit on the number of Undo Delta stored 0 0144 //! will disable Undo on the document A negative value 0145 //! means no limit. Note that by default Undo is disabled. 0146 //! Enabling it will take effect with the next call to 0147 //! NewCommand. Of course this limit is the same for Redo 0148 Standard_EXPORT void SetUndoLimit (const Standard_Integer L); 0149 0150 //! Remove all stored Undos and Redos 0151 Standard_EXPORT void ClearUndos(); 0152 0153 //! Remove all stored Redos 0154 Standard_EXPORT void ClearRedos(); 0155 0156 //! Returns the number of undos stored in this 0157 //! document. If this figure is greater than 0, the method Undo 0158 //! can be used. 0159 Standard_EXPORT Standard_Integer GetAvailableUndos() const; 0160 0161 //! Will UNDO one step, returns False if no undo was 0162 //! done (Undos == 0). 0163 //! Otherwise, true is returned and one step in the 0164 //! list of undoes is undone. 0165 Standard_EXPORT Standard_Boolean Undo(); 0166 0167 //! Returns the number of redos stored in this 0168 //! document. If this figure is greater than 0, the method Redo 0169 //! can be used. 0170 Standard_EXPORT Standard_Integer GetAvailableRedos() const; 0171 0172 //! Will REDO one step, returns False if no redo was 0173 //! done (Redos == 0). 0174 //! Otherwise, true is returned, and one step in the list of redoes is done again. 0175 Standard_EXPORT Standard_Boolean Redo(); 0176 0177 Standard_EXPORT const TDF_DeltaList& GetUndos() const; 0178 0179 Standard_EXPORT const TDF_DeltaList& GetRedos() const; 0180 0181 //! Removes the first undo in the list of document undos. 0182 //! It is used in the application when the undo limit is exceed. 0183 Standard_EXPORT void RemoveFirstUndo(); 0184 0185 //! Initializes the procedure of delta compaction 0186 //! Returns false if there is no delta to compact 0187 //! Marks the last delta as a "from" delta 0188 Standard_EXPORT Standard_Boolean InitDeltaCompaction(); 0189 0190 //! Performs the procedure of delta compaction 0191 //! Makes all deltas starting from "from" delta 0192 //! till the last one to be one delta. 0193 Standard_EXPORT Standard_Boolean PerformDeltaCompaction(); 0194 0195 //! Set modifications on labels impacted by external 0196 //! references to the entry. The document becomes invalid 0197 //! and must be recomputed. 0198 Standard_EXPORT void UpdateReferences (const TCollection_AsciiString& aDocEntry); 0199 0200 //! Recompute if the document was not valid and propagate 0201 //! the reccorded modification. 0202 Standard_EXPORT void Recompute(); 0203 0204 //! This method Update will be called 0205 //! to signal the end of the modified references list. 0206 //! The document should be recomputed and 0207 //! UpdateFromDocuments should be called. Update should 0208 //! returns True in case of success, false otherwise. In 0209 //! case of Failure, additional information can be given in 0210 //! ErrorString. 0211 //! Update the document by propagation 0212 //! ================================== 0213 //! Update the document from internal stored 0214 //! modifications. If you want to undoing this 0215 //! operation, please call NewCommand before. 0216 //! to change format (advanced programming) 0217 //! ================ 0218 Standard_EXPORT virtual void Update (const Handle(CDM_Document)& aToDocument, const Standard_Integer aReferenceIdentifier, const Standard_Address aModifContext) Standard_OVERRIDE; 0219 0220 Standard_EXPORT virtual TCollection_ExtendedString StorageFormat() const Standard_OVERRIDE; 0221 0222 //! Sets saving mode for empty labels. If Standard_True, empty labels will be saved. 0223 void SetEmptyLabelsSavingMode (const Standard_Boolean isAllowed); 0224 0225 //! Returns saving mode for empty labels. 0226 Standard_Boolean EmptyLabelsSavingMode() const; 0227 0228 //! methods for the nested transaction mode 0229 Standard_EXPORT virtual void ChangeStorageFormat (const TCollection_ExtendedString& newStorageFormat); 0230 0231 //! Sets nested transaction mode if isAllowed == Standard_True 0232 void SetNestedTransactionMode (const Standard_Boolean isAllowed = Standard_True); 0233 0234 //! Returns Standard_True if mode is set 0235 Standard_Boolean IsNestedTransactionMode() const; 0236 0237 //! if theTransactionOnly is True changes is denied outside transactions 0238 void SetModificationMode (const Standard_Boolean theTransactionOnly); 0239 0240 //! returns True if changes allowed only inside transactions 0241 Standard_Boolean ModificationMode() const; 0242 0243 //! Prepares document for closing 0244 Standard_EXPORT virtual void BeforeClose(); 0245 0246 //! Returns version of the format to be used to store the document 0247 Standard_EXPORT TDocStd_FormatVersion StorageFormatVersion() const; 0248 0249 //! Sets version of the format to be used to store the document 0250 Standard_EXPORT void ChangeStorageFormatVersion(const TDocStd_FormatVersion theVersion); 0251 0252 //! Returns current storage format version of the document. 0253 Standard_EXPORT static TDocStd_FormatVersion CurrentStorageFormatVersion(); 0254 0255 //! Dumps the content of me into the stream 0256 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; 0257 0258 0259 0260 0261 DEFINE_STANDARD_RTTIEXT(TDocStd_Document,CDM_Document) 0262 0263 protected: 0264 0265 0266 //! Returns Standard_True done 0267 Standard_EXPORT virtual Standard_Boolean CommitTransaction(); 0268 0269 Standard_EXPORT virtual void AbortTransaction(); 0270 0271 //! methods for protection of changes outside transactions 0272 Standard_EXPORT virtual void OpenTransaction(); 0273 0274 TCollection_ExtendedString myStorageFormat; 0275 TDF_DeltaList myUndos; 0276 TDF_DeltaList myRedos; 0277 0278 0279 private: 0280 0281 0282 //! Appends delta to the first delta in the myUndoFILO 0283 //! private methods 0284 //! =============== 0285 Standard_EXPORT static void AppendDeltaToTheFirst (const Handle(TDocStd_CompoundDelta)& theDelta1, const Handle(TDF_Delta)& theDelta2); 0286 0287 Handle(TDF_Data) myData; 0288 Standard_Integer myUndoLimit; 0289 TDF_Transaction myUndoTransaction; 0290 Handle(TDF_Delta) myFromUndo; 0291 Handle(TDF_Delta) myFromRedo; 0292 Standard_Integer mySaveTime; 0293 Standard_Boolean myIsNestedTransactionMode; 0294 TDF_DeltaList myUndoFILO; 0295 Standard_Boolean myOnlyTransactionModification; 0296 Standard_Boolean mySaveEmptyLabels; 0297 TDocStd_FormatVersion myStorageFormatVersion; 0298 0299 }; 0300 0301 0302 #include <TDocStd_Document.lxx> 0303 0304 0305 0306 0307 0308 #endif // _TDocStd_Document_HeaderFile
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |