// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <TDocStd_Document.ixx>
+#include <TDocStd_Document.hxx>
-#include <TDocStd.hxx>
-
-#include <TDocStd_XLink.hxx>
-#include <TDocStd_XLinkIterator.hxx>
-#include <TDocStd_Application.hxx>
-
-#include <TDocStd_Context.hxx>
-#include <TCollection_ExtendedString.hxx>
+#include <CDM_Document.hxx>
+#include <CDM_MetaData.hxx>
+#include <Standard_Dump.hxx>
+#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
-#include <TDF_AttributeIterator.hxx>
-#include <TDF_ListIteratorOfDeltaList.hxx>
-#include <TDF_AttributeList.hxx>
-#include <TDF_ListIteratorOfAttributeList.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <TDF_AttributeDelta.hxx>
#include <TDF_AttributeDeltaList.hxx>
-#include <TDF_ListIteratorOfAttributeDeltaList.hxx>
-#include <TDF_Label.hxx>
+#include <TDF_AttributeIterator.hxx>
+#include <TDF_AttributeList.hxx>
+#include <TDF_Data.hxx>
#include <TDF_Delta.hxx>
+#include <TDF_IDMap.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_ListIteratorOfAttributeDeltaList.hxx>
+#include <TDF_ListIteratorOfAttributeList.hxx>
+#include <TDF_ListIteratorOfDeltaList.hxx>
#include <TDF_Reference.hxx>
+#include <TDocStd.hxx>
+#include <TDocStd_Application.hxx>
#include <TDocStd_CompoundDelta.hxx>
-#include <TDocStd_Owner.hxx>
-#include <TDocStd_Modified.hxx>
-
-#include <TDF_IDMap.hxx>
+#include <TDocStd_Context.hxx>
#include <TDocStd_LabelIDMapDataMap.hxx>
+#include <TDocStd_Modified.hxx>
+#include <TDocStd_Owner.hxx>
+#include <TDocStd_XLink.hxx>
+#include <TDocStd_XLinkIterator.hxx>
-#include <CDM_MetaData.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Document,CDM_Document)
// List should have a RemoveLast...
#define TDocStd_List_RemoveLast(theList) \
Handle(TDocStd_Document) TDocStd_Document::Get (const TDF_Label& acces)
{
- return TDocStd_Owner::GetDocument(acces.Data());
+ // avoid creation of Handle(TDF_Data) during TDF_Data destruction
+ if (acces.Root().HasAttribute()) {
+ return TDocStd_Owner::GetDocument(acces.Data());
+ }
+ return Handle(TDocStd_Document)();
}
//=======================================================================
//=======================================================================
-TDocStd_Document::TDocStd_Document(const TCollection_ExtendedString& aStorageFormat) :
+TDocStd_Document::TDocStd_Document(const TCollection_ExtendedString& aStorageFormat) :
myStorageFormat(aStorageFormat),
myData (new TDF_Data()),
myUndoLimit(0),
+myUndoTransaction ("UNDO"),
mySaveTime(0),
-myIsNestedTransactionMode(0)
+myIsNestedTransactionMode(0),
+mySaveEmptyLabels(Standard_False)
{
- TDF_Transaction* pTr = new TDF_Transaction (myData,"UNDO");
- myUndoTransaction = *pTr; delete pTr;
+ myUndoTransaction.Initialize (myData);
TDocStd_Owner::SetDocument(myData,this);
#ifdef SRN_DELTA_COMPACT
- myFromUndo.Nullify();
+ myFromUndo.Nullify();
myFromRedo.Nullify();
#endif
}
void TDocStd_Document::SetData (const Handle(TDF_Data)& D)
{
myData = D;
- TDF_Transaction* pTr = new TDF_Transaction(myData,"UNDO");
- myUndoTransaction = *pTr; delete pTr;
+ myUndoTransaction.Initialize (myData);
}
//=======================================================================
{
#ifdef OCCT_DEBUG_TRANS
if (myUndoTransaction.IsOpen() && myData->Transaction() > 1) {
- Standard_DomainError::Raise ("NewCommand : many open transactions");
+ throw Standard_DomainError("NewCommand : many open transactions");
}
#endif
OpenTransaction();
#ifdef OCCT_DEBUG_TRANS
- cout<<"End NewCommand"<<endl;
+ std::cout<<"End NewCommand"<<std::endl;
#endif
}
void TDocStd_Document::OpenCommand ()
{
if (!myIsNestedTransactionMode && myUndoTransaction.IsOpen()) {
- Standard_DomainError::Raise("TDocStd_Document::OpenCommand : already open");
+ throw Standard_DomainError("TDocStd_Document::OpenCommand : already open");
}
OpenTransaction();
// if (myUndoLimit != 0) myUndoTransaction.Open();
// Apply the Undo
// should test the applicability before.
#ifdef OCCT_DEBUG_DELTA
- cout<<"DF before Undo =================================="<<endl; TDF_Tool::DeepDump(cout,myData);
+ std::cout<<"DF before Undo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
#endif
Handle(TDF_Delta) D = myData->Undo(myUndos.Last(),Standard_True);
D->SetName(myUndos.Last()->Name());
#ifdef OCCT_DEBUG_DELTA
- cout<<"DF after Undo =================================="<<endl; TDF_Tool::DeepDump(cout,myData);
+ std::cout<<"DF after Undo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
#endif
// Push the redo
myRedos.Prepend(D);
// Apply the Redo
#ifdef OCCT_DEBUG_DELTA
- cout<<"DF before Redo =================================="<<endl; TDF_Tool::DeepDump(cout,myData);
+ std::cout<<"DF before Redo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
#endif
Handle(TDF_Delta) D = myData->Undo(myRedos.First(),Standard_True);
D->SetName(myRedos.First()->Name());
#ifdef OCCT_DEBUG_DELTA
- cout<<"DF after Redo =================================="<<endl; TDF_Tool::DeepDump(cout,myData);
+ std::cout<<"DF after Redo =================================="<<std::endl; TDF_Tool::DeepDump(std::cout,myData);
#endif
// Push the redo of the redo as an undo (got it !)
myUndos.Append(D);
myUndoFILO.Clear();
ClearUndos();
}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void TDocStd_Document::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, CDM_Document)
+
+ OCCT_DUMP_FIELD_VALUE_STRING (theOStream, myStorageFormat)
+
+ for (TDF_DeltaList::Iterator anUndoIt (myUndos); anUndoIt.More(); anUndoIt.Next())
+ {
+ const Handle(TDF_Delta)& anUndo = anUndoIt.Value();
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anUndo.get())
+ }
+
+ for (TDF_DeltaList::Iterator aRedoIt (myRedos); aRedoIt.More(); aRedoIt.Next())
+ {
+ const Handle(TDF_Delta)& aRedo = aRedoIt.Value();
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, aRedo.get())
+ }
+
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myData.get())
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myUndoLimit)
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myUndoTransaction)
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFromUndo.get())
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myFromRedo.get())
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySaveTime)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsNestedTransactionMode)
+
+ for (TDF_DeltaList::Iterator anUndoFILOIt (myUndoFILO); anUndoFILOIt.More(); anUndoFILOIt.Next())
+ {
+ const Handle(TDF_Delta)& anUndoFILO = anUndoFILOIt.Value();
+ OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, anUndoFILO.get())
+ }
+
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOnlyTransactionModification)
+ OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, mySaveEmptyLabels)
+}