Salome HOME
Code alignment.
[modules/hydro.git] / src / HYDROData / HYDROData_Document.cxx
index 3960c4a4f3d545dceaf7e599220713ae636bc56f..bfc30b84ba90d77b320a9068f3e17ab53af411ba 100644 (file)
@@ -4,6 +4,8 @@
 
 #include <TDataStd_Integer.hxx>
 
+#include <TDF_Delta.hxx>
+
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Document,MMgt_TShared)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Document,MMgt_TShared)
 
@@ -129,10 +131,26 @@ void HYDROData_Document::StartOperation()
   myDoc->NewCommand();
 }
 
-void HYDROData_Document::CommitOperation()
+void HYDROData_Document::CommitOperation(const TCollection_ExtendedString& theName)
 {
-  myDoc->CommitCommand();
+  if( !myDoc->CommitCommand() ) // it means that there were no modifications done
+  {
+    myDoc->NewCommand();
+    NewID(); // workaround: do something just to modify the document
+    myDoc->CommitCommand();
+  }
   myTransactionsAfterSave++;
+
+  if( theName.Length() != 0 )
+  {
+    const TDF_DeltaList& aList = GetUndos();
+    if( !aList.IsEmpty() )
+    {
+      Handle(TDF_Delta) aDelta = aList.Last();
+      if( !aDelta.IsNull() )
+        aDelta->SetName( theName );
+    }
+  }
 }
 
 void HYDROData_Document::AbortOperation()
@@ -155,6 +173,16 @@ bool HYDROData_Document::CanUndo()
   return myDoc->GetAvailableUndos() > 0;
 }
 
+const TDF_DeltaList& HYDROData_Document::GetUndos()
+{
+  return myDoc->GetUndos();
+}
+
+void HYDROData_Document::ClearUndos()
+{
+  return myDoc->ClearUndos();
+}
+
 void HYDROData_Document::Undo()
 {
   myDoc->Undo();
@@ -166,6 +194,16 @@ bool HYDROData_Document::CanRedo()
   return myDoc->GetAvailableRedos() > 0;
 }
 
+const TDF_DeltaList& HYDROData_Document::GetRedos()
+{
+  return myDoc->GetRedos();
+}
+
+void HYDROData_Document::ClearRedos()
+{
+  return myDoc->ClearRedos();
+}
+
 void HYDROData_Document::Redo()
 {
   myDoc->Redo();