mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-08 14:17:06 +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:
@@ -18,6 +18,7 @@
|
||||
#include <CDM_Document.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
#include <LDOM_DocumentType.hxx>
|
||||
#include <LDOM_LDOMImplementation.hxx>
|
||||
#include <LDOM_XmlWriter.hxx>
|
||||
@@ -92,7 +93,8 @@ void XmlLDrivers_DocumentStorageDriver::AddNamespace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDocument,
|
||||
const TCollection_ExtendedString& theFileName)
|
||||
const TCollection_ExtendedString& theFileName,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
myFileName = theFileName;
|
||||
|
||||
@@ -101,7 +103,7 @@ void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)&
|
||||
|
||||
if (aFileStream.is_open() && aFileStream.good())
|
||||
{
|
||||
Write (theDocument, aFileStream);
|
||||
Write (theDocument, aFileStream, theProgress);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -120,8 +122,9 @@ void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)&
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_EXPORT void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDocument,
|
||||
Standard_OStream& theOStream)
|
||||
void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_Document)& theDocument,
|
||||
Standard_OStream& theOStream,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
Handle(Message_Messenger) aMessageDriver = theDocument->Application()->MessageDriver();
|
||||
::take_time (~0, " +++++ Start STORAGE procedures ++++++", aMessageDriver);
|
||||
@@ -132,7 +135,7 @@ Standard_EXPORT void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_
|
||||
// Fill the document with data
|
||||
XmlObjMgt_Element anElement = aDOMDoc.getDocumentElement();
|
||||
|
||||
if (WriteToDomDocument (theDocument, anElement) == Standard_False) {
|
||||
if (WriteToDomDocument (theDocument, anElement, theProgress) == Standard_False) {
|
||||
|
||||
LDOM_XmlWriter aWriter;
|
||||
aWriter.SetIndentation(1);
|
||||
@@ -164,8 +167,10 @@ Standard_EXPORT void XmlLDrivers_DocumentStorageDriver::Write (const Handle(CDM_
|
||||
// data to XML, this method should be reimplemented avoiding step 3
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Handle(CDM_Document)& theDocument,
|
||||
XmlObjMgt_Element& theElement)
|
||||
Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument
|
||||
(const Handle(CDM_Document)& theDocument,
|
||||
XmlObjMgt_Element& theElement,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
SetIsError(Standard_False);
|
||||
Handle(Message_Messenger) aMessageDriver =
|
||||
@@ -320,14 +325,21 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
aCommentsElem.appendChild (aCItem);
|
||||
XmlObjMgt::SetExtendedString (aCItem, aComments(i));
|
||||
}
|
||||
|
||||
Message_ProgressSentry aPS(theProgress, "Writing", 0, 2, 1);
|
||||
// 2a. Write document contents
|
||||
Standard_Integer anObjNb = 0;
|
||||
{
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS
|
||||
anObjNb = MakeDocument(theDocument, theElement);
|
||||
anObjNb = MakeDocument(theDocument, theElement, theProgress);
|
||||
if (!aPS.More())
|
||||
{
|
||||
SetIsError(Standard_True);
|
||||
SetStoreStatus(PCDM_SS_UserBreak);
|
||||
return IsError();
|
||||
}
|
||||
aPS.Next();
|
||||
}
|
||||
catch (Standard_Failure const& anException)
|
||||
{
|
||||
@@ -353,8 +365,15 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
myRelocTable.Clear();
|
||||
|
||||
// 4. Write Shapes section
|
||||
if(WriteShapeSection(theElement))
|
||||
if (WriteShapeSection(theElement, theProgress))
|
||||
::take_time (0, " +++ Fin DOM data for Shapes : ", aMessageDriver);
|
||||
if (!aPS.More())
|
||||
{
|
||||
SetIsError(Standard_True);
|
||||
SetStoreStatus(PCDM_SS_UserBreak);
|
||||
return IsError();
|
||||
}
|
||||
aPS.Next();
|
||||
return IsError();
|
||||
}
|
||||
|
||||
@@ -364,7 +383,8 @@ Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteToDomDocument (const Ha
|
||||
//=======================================================================
|
||||
Standard_Integer XmlLDrivers_DocumentStorageDriver::MakeDocument
|
||||
(const Handle(CDM_Document)& theTDoc,
|
||||
XmlObjMgt_Element& theElement)
|
||||
XmlObjMgt_Element& theElement,
|
||||
const Handle(Message_ProgressIndicator)& theProgress)
|
||||
{
|
||||
TCollection_ExtendedString aMessage;
|
||||
Handle(TDocStd_Document) TDOC = Handle(TDocStd_Document)::DownCast(theTDoc);
|
||||
@@ -385,7 +405,7 @@ Standard_Integer XmlLDrivers_DocumentStorageDriver::MakeDocument
|
||||
if (myDrivers.IsNull()) myDrivers = AttributeDrivers (aMessageDriver);
|
||||
|
||||
// Retrieve from DOM_Document
|
||||
XmlMDF::FromTo (aTDF, theElement, myRelocTable, myDrivers);
|
||||
XmlMDF::FromTo (aTDF, theElement, myRelocTable, myDrivers, theProgress);
|
||||
#ifdef OCCT_DEBUGXML
|
||||
aMessage = "First step successfull";
|
||||
aMessageDriver -> Send (aMessage.ToExtString(), Message_Warning);
|
||||
@@ -446,7 +466,8 @@ static void take_time (const Standard_Integer isReset, const char * aHeader,
|
||||
//purpose : defines WriteShapeSection
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlLDrivers_DocumentStorageDriver::WriteShapeSection
|
||||
(XmlObjMgt_Element& /*theElement*/)
|
||||
(XmlObjMgt_Element& /*theElement*/,
|
||||
const Handle(Message_ProgressIndicator)& /*theProgress*/)
|
||||
{
|
||||
// empty; should be redefined in subclasses
|
||||
return Standard_False;
|
||||
|
Reference in New Issue
Block a user