1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-19 13:40:49 +03:00

0031353: TDocStd_Application does not have api to set progress indicator

Add support of Message_ProgressIndicator in BinTools classes.

Add support of Message_ProgressIndicator with possibility of user break in methods of opening and saving TDocStd_Application.

Add tests of ProgressIndicator in TDocStd_Applacation.
This commit is contained in:
akaftasev
2020-03-02 15:29:34 +03:00
committed by bugmaster
parent d27293d9bf
commit 6d8f9f4a49
75 changed files with 1364 additions and 1094 deletions

View File

@@ -15,6 +15,7 @@
#include <Message_Messenger.hxx>
#include <Message_ProgressSentry.hxx>
#include <Storage_Schema.hxx>
#include <TColStd_MapOfTransient.hxx>
#include <TDF_Attribute.hxx>
@@ -60,11 +61,12 @@ static TColStd_MapOfTransient& UnsuppTypesMap ()
void XmlMDF::FromTo (const Handle(TDF_Data)& theData,
XmlObjMgt_Element& theElement,
XmlObjMgt_SRelocationTable& theRelocTable,
const Handle(XmlMDF_ADriverTable)& theDrivers)
const Handle(XmlMDF_ADriverTable)& theDrivers,
const Handle(Message_ProgressIndicator)& theProgress)
{
UnsuppTypesMap().Clear();
// Standard_Integer count =
WriteSubTree(theData->Root(), theElement, theRelocTable, theDrivers);
WriteSubTree(theData->Root(), theElement, theRelocTable, theDrivers, theProgress);
UnsuppTypesMap().Clear();
}
@@ -76,7 +78,8 @@ Standard_Integer XmlMDF::WriteSubTree
(const TDF_Label& theLabel,
XmlObjMgt_Element& theElement,
XmlObjMgt_SRelocationTable& theRelocTable,
const Handle(XmlMDF_ADriverTable)& theDrivers)
const Handle(XmlMDF_ADriverTable)& theDrivers,
const Handle(Message_ProgressIndicator)& theProgress)
{
XmlObjMgt_Document aDoc = theElement.getOwnerDocument();
@@ -128,10 +131,16 @@ Standard_Integer XmlMDF::WriteSubTree
// write sub-labels
TDF_ChildIterator itr2 (theLabel);
for ( ; itr2.More(); itr2.Next())
Standard_Real child_count = 0;
for (; itr2.More(); ++child_count, itr2.Next())
{
}
itr2.Initialize(theLabel);
Message_ProgressSentry aPS(theProgress, "Writing sub-tree", 0, child_count, 1);
for ( ; itr2.More() && aPS.More(); itr2.Next(), aPS.Next())
{
const TDF_Label& aChildLab = itr2.Value();
count += WriteSubTree(aChildLab, aLabElem, theRelocTable, theDrivers);
count += WriteSubTree(aChildLab, aLabElem, theRelocTable, theDrivers, theProgress);
}
if (count > 0 || TDocStd_Owner::GetDocument(theLabel.Data())->EmptyLabelsSavingMode())
@@ -141,7 +150,6 @@ Standard_Integer XmlMDF::WriteSubTree
// set attribute "tag"
aLabElem.setAttribute (::TagString(), theLabel.Tag());
}
return count;
}
@@ -152,7 +160,8 @@ Standard_Integer XmlMDF::WriteSubTree
Standard_Boolean XmlMDF::FromTo (const XmlObjMgt_Element& theElement,
Handle(TDF_Data)& theData,
XmlObjMgt_RRelocationTable& theRelocTable,
const Handle(XmlMDF_ADriverTable)& theDrivers)
const Handle(XmlMDF_ADriverTable)& theDrivers,
const Handle(Message_ProgressIndicator)& theProgress)
{
TDF_Label aRootLab = theData->Root();
XmlMDF_MapOfDriver aDriverMap;
@@ -167,7 +176,7 @@ Standard_Boolean XmlMDF::FromTo (const XmlObjMgt_Element& theElement,
if ( anElem.getNodeName().equals (::LabelString()) )
{
Standard_Integer subcount =
ReadSubTree(anElem, aRootLab, theRelocTable, aDriverMap);
ReadSubTree(anElem, aRootLab, theRelocTable, aDriverMap, theProgress);
// check for error
if (subcount < 0)
return Standard_False;
@@ -188,7 +197,8 @@ Standard_Boolean XmlMDF::FromTo (const XmlObjMgt_Element& theElement,
Standard_Integer XmlMDF::ReadSubTree (const XmlObjMgt_Element& theElement,
const TDF_Label& theLabel,
XmlObjMgt_RRelocationTable& theRelocTable,
const XmlMDF_MapOfDriver& theDriverMap)
const XmlMDF_MapOfDriver& theDriverMap,
const Handle(Message_ProgressIndicator)& theProgress)
{
// Extraction of the driver subset.
Standard_Integer count = 0;
@@ -196,6 +206,7 @@ Standard_Integer XmlMDF::ReadSubTree (const XmlObjMgt_Element& theElement,
//XmlObjMgt_Element anElem = (const XmlObjMgt_Element &) theElement.getFirstChild();
LDOM_Node theNode = theElement.getFirstChild();
XmlObjMgt_Element anElem = (const XmlObjMgt_Element &) theNode;
Message_ProgressSentry aPS(theProgress, "Reading sub-tree", 0, 2, 1, true);
while ( !anElem.isNull() )
{
if ( anElem.getNodeType() == LDOM_Node::ELEMENT_NODE )
@@ -217,7 +228,7 @@ Standard_Integer XmlMDF::ReadSubTree (const XmlObjMgt_Element& theElement,
// read sub-tree
Standard_Integer subcount =
ReadSubTree(anElem, aLab, theRelocTable, theDriverMap);
ReadSubTree(anElem, aLab, theRelocTable, theDriverMap, theProgress);
// check for error
if (subcount == -1)
return -1;
@@ -305,6 +316,10 @@ Standard_Integer XmlMDF::ReadSubTree (const XmlObjMgt_Element& theElement,
//anElem = (const XmlObjMgt_Element &) anElem.getNextSibling();
LDOM_Node theNode1 = anElem.getNextSibling();
anElem = (const XmlObjMgt_Element &) theNode1;
if (!aPS.More())
return -1;
aPS.Next();
}
// AfterRetrieval

View File

@@ -26,6 +26,9 @@
#include <Standard_Boolean.hxx>
#include <XmlObjMgt_RRelocationTable.hxx>
#include <XmlMDF_MapOfDriver.hxx>
#include <Message_ProgressIndicator.hxx>
class TDF_Data;
class XmlMDF_ADriverTable;
class TDF_Label;
@@ -58,38 +61,45 @@ public:
DEFINE_STANDARD_ALLOC
//! Translates a transient <aSource> into a persistent
//! <aTarget>.
Standard_EXPORT static void FromTo (const Handle(TDF_Data)& aSource, XmlObjMgt_Element& aTarget, XmlObjMgt_SRelocationTable& aReloc, const Handle(XmlMDF_ADriverTable)& aDrivers);
Standard_EXPORT static void FromTo (const Handle(TDF_Data)& aSource,
XmlObjMgt_Element& aTarget,
XmlObjMgt_SRelocationTable& aReloc,
const Handle(XmlMDF_ADriverTable)& aDrivers,
const Handle(Message_ProgressIndicator)& theProgress = NULL);
//! Translates a persistent <aSource> into a transient
//! <aTarget>.
//! Returns True if completed successfully (False on error)
Standard_EXPORT static Standard_Boolean FromTo (const XmlObjMgt_Element& aSource, Handle(TDF_Data)& aTarget, XmlObjMgt_RRelocationTable& aReloc, const Handle(XmlMDF_ADriverTable)& aDrivers);
Standard_EXPORT static Standard_Boolean FromTo
(const XmlObjMgt_Element& aSource,
Handle(TDF_Data)& aTarget, XmlObjMgt_RRelocationTable& aReloc,
const Handle(XmlMDF_ADriverTable)& aDrivers,
const Handle(Message_ProgressIndicator)& theProgress = NULL);
//! Adds the attribute storage drivers to <aDriverSeq>.
Standard_EXPORT static void AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable, const Handle(Message_Messenger)& theMessageDriver);
protected:
Standard_EXPORT static void AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
const Handle(Message_Messenger)& theMessageDriver);
private:
Standard_EXPORT static Standard_Integer WriteSubTree
(const TDF_Label& theLabel,
XmlObjMgt_Element& theElement,
XmlObjMgt_SRelocationTable& aReloc,
const Handle(XmlMDF_ADriverTable)& aDrivers,
const Handle(Message_ProgressIndicator)& theProgress = NULL);
Standard_EXPORT static Standard_Integer WriteSubTree (const TDF_Label& theLabel, XmlObjMgt_Element& theElement, XmlObjMgt_SRelocationTable& aReloc, const Handle(XmlMDF_ADriverTable)& aDrivers);
Standard_EXPORT static Standard_Integer ReadSubTree
(const XmlObjMgt_Element& theElement,
const TDF_Label& theLabel,
XmlObjMgt_RRelocationTable& aReloc,
const XmlMDF_MapOfDriver& aDrivers,
const Handle(Message_ProgressIndicator)& theProgress = NULL);
Standard_EXPORT static Standard_Integer ReadSubTree (const XmlObjMgt_Element& theElement, const TDF_Label& theLabel, XmlObjMgt_RRelocationTable& aReloc, const XmlMDF_MapOfDriver& aDrivers);
Standard_EXPORT static void CreateDrvMap (const Handle(XmlMDF_ADriverTable)& aDriverTable, XmlMDF_MapOfDriver& anAsciiDriverMap);
Standard_EXPORT static void CreateDrvMap (const Handle(XmlMDF_ADriverTable)& aDriverTable,
XmlMDF_MapOfDriver& anAsciiDriverMap);
friend class XmlMDF_ADriver;
friend class XmlMDF_TagSourceDriver;
@@ -98,10 +108,4 @@ friend class XmlMDF_ADriverTable;
};
#endif // _XmlMDF_HeaderFile