mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0024164: Optimization of OCAF document closing
OCAF document closing redesign. added 2 test scripts. removed commented method. added missed Draw commands.
This commit is contained in:
@@ -98,6 +98,7 @@
|
||||
#include <TDataStd_ListIteratorOfListOfByte.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfReal.hxx>
|
||||
#include <TDataStd_ReferenceArray.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : DDataStd_SetInteger
|
||||
@@ -2595,6 +2596,67 @@ static Standard_Integer DDataStd_GetNDRealArray (Draw_Interpretor& di,
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetRefArray (DF, entry , From, To, elmt1, elmt2, ...
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_SetRefArray (Draw_Interpretor& di,
|
||||
Standard_Integer,
|
||||
const char** arg)
|
||||
{
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
DDF::AddLabel(DF, arg[2], label);
|
||||
|
||||
Standard_Integer From = Draw::Atoi(arg[3]), To = Draw::Atoi( arg[4] ), j;
|
||||
di << "RefArray with bounds from = " << From << " to = " << To << "\n";
|
||||
|
||||
Handle(TDataStd_ReferenceArray) A = TDataStd_ReferenceArray::Set(label, From, To);
|
||||
|
||||
j = 5;
|
||||
for(Standard_Integer i = From; i<=To; i++) {
|
||||
TDF_Label aRefLabel;
|
||||
DDF::AddLabel(DF, arg[j], aRefLabel);
|
||||
A->SetValue(i, aRefLabel);
|
||||
j++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : GetRefArray (DF, entry )
|
||||
//=======================================================================
|
||||
static Standard_Integer DDataStd_GetRefArray (Draw_Interpretor& di,
|
||||
Standard_Integer,
|
||||
const char** arg)
|
||||
{
|
||||
|
||||
Handle(TDF_Data) DF;
|
||||
if (!DDF::GetDF(arg[1],DF)) return 1;
|
||||
TDF_Label label;
|
||||
if( !DDF::FindLabel(DF, arg[2], label) ) {
|
||||
di << "No label for entry" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
Handle(TDataStd_ReferenceArray) A;
|
||||
if ( !label.FindAttribute(TDataStd_ReferenceArray::GetID(), A) ) {
|
||||
di << "There is no TDataStd_ReferenceArray under label" << "\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
for(Standard_Integer i = A->Lower(); i<=A->Upper(); i++){
|
||||
const TDF_Label& aLabel = A->Value(i);
|
||||
TCollection_AsciiString entry;
|
||||
TDF_Tool::Entry(aLabel, entry);
|
||||
di << entry.ToCString();
|
||||
if(i<A->Upper())
|
||||
di<<" ";
|
||||
}
|
||||
di<<"\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BasicCommands
|
||||
//purpose :
|
||||
@@ -2636,6 +2698,10 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
"SetExtStringArray (DF, entry, isDelta, From, To, elmt1, elmt2, ... )",
|
||||
__FILE__, DDataStd_SetExtStringArray, g);
|
||||
|
||||
theCommands.Add ("SetRefArray",
|
||||
"SetRefArray (DF, entry, From, To, lab1, lab2,.. )",
|
||||
__FILE__, DDataStd_SetRefArray, g);
|
||||
|
||||
theCommands.Add ("SetIntPackedMap",
|
||||
"SetIntPackedMap (DF, entry, isDelta, key1, key2, ... )",
|
||||
__FILE__, DDataStd_SetIntPackedMap, g);
|
||||
@@ -2703,6 +2769,10 @@ void DDataStd::BasicCommands (Draw_Interpretor& theCommands)
|
||||
"GetExtStringArray (DF, entry )",
|
||||
__FILE__, DDataStd_GetExtStringArray, g);
|
||||
|
||||
theCommands.Add ("GetRefArray",
|
||||
"GetRefArray (DF, entry )",
|
||||
__FILE__, DDataStd_GetRefArray, g);
|
||||
|
||||
theCommands.Add ("GetIntPackedMap",
|
||||
"GetIntPackedMap (DF, entry )",
|
||||
__FILE__, DDataStd_GetIntPackedMap, g);
|
||||
|
@@ -163,6 +163,7 @@ void TDocStd_Application::Close(const Handle(TDocStd_Document)& aDoc)
|
||||
Handle(TDocStd_Document) emptyDoc;
|
||||
Owner->SetDocument(emptyDoc);
|
||||
}
|
||||
aDoc->BeforeClose();
|
||||
CDF_Application::Close(aDoc);
|
||||
}
|
||||
#endif
|
||||
|
@@ -49,7 +49,7 @@ uses Data from TDF,
|
||||
|
||||
is
|
||||
|
||||
Destroy (me : mutable) is redefined protected;
|
||||
-- Destroy (me : mutable) is redefined protected;
|
||||
---Purpose: Will Abort any execution, clear fields
|
||||
---C++: alias ~
|
||||
|
||||
@@ -319,7 +319,10 @@ is
|
||||
ModificationMode (me) returns Boolean from Standard;
|
||||
---Purpose: returns True if changes allowed only inside transactions
|
||||
---C++: inline
|
||||
|
||||
|
||||
BeforeClose(me : mutable) is virtual;
|
||||
---Purpose: Prepares document for closing
|
||||
|
||||
fields
|
||||
|
||||
---Purpose: storage format
|
||||
|
@@ -70,23 +70,6 @@ Handle(TDocStd_Document) TDocStd_Document::Get (const TDF_Label& acces)
|
||||
return TDocStd_Owner::GetDocument(acces.Data());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Destroy
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDocStd_Document::Destroy()
|
||||
{
|
||||
SetModificationMode(Standard_False);
|
||||
myData->Root().ForgetAllAttributes(Standard_True);
|
||||
myUndoTransaction.Abort();
|
||||
if(!myUndoFILO.IsEmpty())
|
||||
myUndoFILO.Clear();
|
||||
ClearUndos();
|
||||
myData.Nullify();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : TDocStd_Document
|
||||
//purpose :
|
||||
@@ -911,3 +894,15 @@ void TDocStd_Document::RemoveFirstUndo() {
|
||||
myUndos.RemoveFirst();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BeforeClose
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void TDocStd_Document::BeforeClose()
|
||||
{
|
||||
SetModificationMode(Standard_False);
|
||||
AbortTransaction();
|
||||
if(myIsNestedTransactionMode)
|
||||
myUndoFILO.Clear();
|
||||
ClearUndos();
|
||||
}
|
||||
|
Reference in New Issue
Block a user