mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +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,7 +18,6 @@
|
||||
#include <GeomTools.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
#include <Message_ProgressSentry.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <Standard_OutOfRange.hxx>
|
||||
@@ -172,7 +171,8 @@ void TopTools_LocationSet::Dump(Standard_OStream& OS) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_LocationSet::Write(Standard_OStream& OS) const
|
||||
void TopTools_LocationSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress) const
|
||||
{
|
||||
|
||||
std::streamsize prec = OS.precision(15);
|
||||
@@ -181,7 +181,7 @@ void TopTools_LocationSet::Write(Standard_OStream& OS) const
|
||||
OS << "Locations " << nbLoc << "\n";
|
||||
|
||||
//OCC19559
|
||||
Message_ProgressSentry PS(GetProgress(), "Locations", 0, nbLoc, 1);
|
||||
Message_ProgressSentry PS(theProgress, "Locations", 0, nbLoc, 1);
|
||||
for (i = 1; i <= nbLoc && PS.More(); i++, PS.Next()) {
|
||||
TopLoc_Location L = myMap(i);
|
||||
|
||||
@@ -246,7 +246,7 @@ static void ReadTrsf(gp_Trsf& T,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_LocationSet::Read(Standard_IStream& IS)
|
||||
void TopTools_LocationSet::Read (Standard_IStream& IS, const Handle(Message_ProgressIndicator) &theProgress)
|
||||
{
|
||||
myMap.Clear();
|
||||
|
||||
@@ -266,7 +266,7 @@ void TopTools_LocationSet::Read(Standard_IStream& IS)
|
||||
gp_Trsf T;
|
||||
|
||||
//OCC19559
|
||||
Message_ProgressSentry PS(GetProgress(), "Locations", 0, nbLoc, 1);
|
||||
Message_ProgressSentry PS(theProgress, "Locations", 0, nbLoc, 1);
|
||||
for (i = 1; i <= nbLoc&& PS.More(); i++, PS.Next()) {
|
||||
Standard_Integer typLoc;
|
||||
IS >> typLoc;
|
||||
@@ -290,25 +290,3 @@ void TopTools_LocationSet::Read(Standard_IStream& IS)
|
||||
if (!L.IsIdentity()) myMap.Add(L);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Message_ProgressIndicator) TopTools_LocationSet::GetProgress() const
|
||||
{
|
||||
return myProgress;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_LocationSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
|
||||
{
|
||||
myProgress = PR;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -25,7 +25,8 @@
|
||||
#include <Standard_Integer.hxx>
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
class Message_ProgressIndicator;
|
||||
#include <Message_ProgressIndicator.hxx>
|
||||
|
||||
class Standard_OutOfRange;
|
||||
class TopLoc_Location;
|
||||
|
||||
@@ -37,7 +38,7 @@ class TopLoc_Location;
|
||||
//!
|
||||
//! It can create Locations.
|
||||
//!
|
||||
//! It can be write and read from a stream.
|
||||
//! It can be written and read from a stream.
|
||||
class TopTools_LocationSet
|
||||
{
|
||||
public:
|
||||
@@ -66,39 +67,17 @@ public:
|
||||
|
||||
//! Writes the content of me on the stream <OS> in a
|
||||
//! format that can be read back by Read.
|
||||
Standard_EXPORT void Write (Standard_OStream& OS) const;
|
||||
Standard_EXPORT void Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL) const;
|
||||
|
||||
//! Reads the content of me from the stream <IS>. me
|
||||
//! is first cleared.
|
||||
Standard_EXPORT void Read (Standard_IStream& IS);
|
||||
|
||||
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
|
||||
|
||||
Standard_EXPORT Handle(Message_ProgressIndicator) GetProgress() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
Standard_EXPORT void Read (Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator)& theProgress = NULL);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
TopLoc_IndexedMapOfLocation myMap;
|
||||
Handle(Message_ProgressIndicator) myProgress;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _TopTools_LocationSet_HeaderFile
|
||||
|
@@ -443,7 +443,8 @@ void TopTools_ShapeSet::Dump(Standard_OStream& OS)const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::Write(Standard_OStream& OS)
|
||||
void TopTools_ShapeSet::Write (Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress)
|
||||
{
|
||||
// always use C locale for writing shapes
|
||||
std::locale anOldLocale = OS.imbue (std::locale::classic());
|
||||
@@ -460,33 +461,20 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
|
||||
//-----------------------------------------
|
||||
// write the locations
|
||||
//-----------------------------------------
|
||||
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 10, "Locations" );
|
||||
myLocations.SetProgress(myProgress);
|
||||
myLocations.Write(OS);
|
||||
if ( !myProgress.IsNull() ) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
}
|
||||
|
||||
if (!myProgress.IsNull() && myProgress->UserBreak()) {
|
||||
OS << "Interrupted by the user\n";
|
||||
OS.imbue (anOldLocale);
|
||||
Message_ProgressSentry aPS(theProgress, "Writing Shapes", 0, 3, 1);
|
||||
myLocations.Write(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
}
|
||||
aPS.Next();
|
||||
|
||||
//-----------------------------------------
|
||||
// write the geometry
|
||||
//-----------------------------------------
|
||||
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 75, "Geometry" );
|
||||
WriteGeometry(OS);
|
||||
if ( !myProgress.IsNull() ) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
}
|
||||
WriteGeometry(OS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
|
||||
//-----------------------------------------
|
||||
// write the shapes
|
||||
@@ -498,10 +486,8 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
|
||||
|
||||
// subshapes are written first
|
||||
//OCC19559
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 15, "Shapes" );
|
||||
Message_ProgressSentry PS(myProgress, "Shapes", 0, nbShapes, 1);
|
||||
for (i = 1; i <= nbShapes && PS.More(); i++, PS.Next()) {
|
||||
Message_ProgressSentry aPSinner(theProgress, "Shapes", 0, nbShapes, 1);
|
||||
for (i = 1; i <= nbShapes && aPSinner.More(); i++, aPSinner.Next()) {
|
||||
const TopoDS_Shape& S = myShapes(i);
|
||||
|
||||
// Type
|
||||
@@ -542,14 +528,6 @@ void TopTools_ShapeSet::Write(Standard_OStream& OS)
|
||||
OS << "\n";
|
||||
OS.precision(prec);
|
||||
OS.imbue (anOldLocale);
|
||||
|
||||
PS.Relieve();
|
||||
if (!myProgress.IsNull()) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
if (myProgress->UserBreak())
|
||||
OS << "Interrupted by the user\n";
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
@@ -597,7 +575,7 @@ static TopAbs_ShapeEnum ReadShapeEnum(Standard_IStream& IS)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
void TopTools_ShapeSet::Read (Standard_IStream& IS, const Handle(Message_ProgressIndicator) &theProgress)
|
||||
{
|
||||
// always use C locale for reading shapes
|
||||
std::locale anOldLocale = IS.imbue (std::locale::classic());
|
||||
@@ -634,38 +612,18 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
//-----------------------------------------
|
||||
|
||||
//OCC19559
|
||||
if (!myProgress.IsNull() && myProgress->UserBreak()) {
|
||||
std::cout << "Interrupted by the user"<<std::endl;
|
||||
// on remet le LC_NUMERIC a la precedente valeur
|
||||
IS.imbue (anOldLocale);
|
||||
Message_ProgressSentry aPS(theProgress, "Reading", 0, 10, 3);
|
||||
myLocations.Read(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
}
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 10, "Locations" );
|
||||
myLocations.SetProgress(myProgress);
|
||||
myLocations.Read(IS);
|
||||
if ( !myProgress.IsNull() ) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
}
|
||||
//OCC19559
|
||||
if (!myProgress.IsNull() && myProgress->UserBreak()) {
|
||||
std::cout << "Interrupted by the user"<<std::endl;
|
||||
// on remet le LC_NUMERIC a la precedente valeur
|
||||
IS.imbue (anOldLocale);
|
||||
return;
|
||||
}
|
||||
|
||||
aPS.Next();
|
||||
//-----------------------------------------
|
||||
// read the geometry
|
||||
//-----------------------------------------
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 75, "Geometry" );
|
||||
ReadGeometry(IS);
|
||||
if ( !myProgress.IsNull() ) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
}
|
||||
ReadGeometry(IS, theProgress);
|
||||
if (!aPS.More())
|
||||
return;
|
||||
aPS.Next();
|
||||
|
||||
//-----------------------------------------
|
||||
// read the shapes
|
||||
@@ -684,9 +642,8 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
IS >> nbShapes;
|
||||
|
||||
//OCC19559
|
||||
if ( !myProgress.IsNull() )
|
||||
myProgress->NewScope ( 15, "Shapes" );
|
||||
Message_ProgressSentry PS(myProgress, "Shapes", 0, nbShapes, 1);
|
||||
|
||||
Message_ProgressSentry PS(theProgress, "Shapes", 0, nbShapes, 1);
|
||||
for (i = 1; i <= nbShapes && PS.More(); i++, PS.Next() ) {
|
||||
TopoDS_Shape S;
|
||||
|
||||
@@ -726,11 +683,6 @@ void TopTools_ShapeSet::Read(Standard_IStream& IS)
|
||||
|
||||
myShapes.Add(S);
|
||||
}
|
||||
if (!myProgress.IsNull()) {
|
||||
myProgress->EndScope();
|
||||
myProgress->Show();
|
||||
}
|
||||
|
||||
// on remet le LC_NUMERIC a la precedente valeur
|
||||
IS.imbue (anOldLocale);
|
||||
}
|
||||
@@ -758,8 +710,7 @@ void TopTools_ShapeSet::Dump(const TopoDS_Shape& S,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::Write(const TopoDS_Shape& S,
|
||||
Standard_OStream& OS)const
|
||||
void TopTools_ShapeSet::Write (const TopoDS_Shape& S, Standard_OStream& OS)const
|
||||
{
|
||||
if (S.IsNull()) OS << "*";
|
||||
else {
|
||||
@@ -774,8 +725,7 @@ void TopTools_ShapeSet::Write(const TopoDS_Shape& S,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::Read(TopoDS_Shape& S,
|
||||
Standard_IStream& IS)const
|
||||
void TopTools_ShapeSet::Read (TopoDS_Shape& S, Standard_IStream& IS)const
|
||||
{
|
||||
Read(S,IS,myShapes.Extent());
|
||||
}
|
||||
@@ -849,7 +799,8 @@ void TopTools_ShapeSet::DumpGeometry(Standard_OStream&) const
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::WriteGeometry(Standard_OStream&)
|
||||
void TopTools_ShapeSet::WriteGeometry (Standard_OStream&,
|
||||
const Handle(Message_ProgressIndicator) &)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -859,7 +810,8 @@ void TopTools_ShapeSet::WriteGeometry(Standard_OStream&)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::ReadGeometry(Standard_IStream&)
|
||||
void TopTools_ShapeSet::ReadGeometry (Standard_IStream&,
|
||||
const Handle(Message_ProgressIndicator) &)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -880,8 +832,7 @@ void TopTools_ShapeSet::DumpGeometry(const TopoDS_Shape&,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::WriteGeometry(const TopoDS_Shape&,
|
||||
Standard_OStream&)const
|
||||
void TopTools_ShapeSet::WriteGeometry (const TopoDS_Shape&, Standard_OStream&)const
|
||||
{
|
||||
}
|
||||
|
||||
@@ -891,9 +842,7 @@ void TopTools_ShapeSet::WriteGeometry(const TopoDS_Shape&,
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::ReadGeometry(const TopAbs_ShapeEnum,
|
||||
Standard_IStream& ,
|
||||
TopoDS_Shape&)
|
||||
void TopTools_ShapeSet::ReadGeometry (const TopAbs_ShapeEnum, Standard_IStream&, TopoDS_Shape&)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -931,25 +880,3 @@ Standard_Integer TopTools_ShapeSet::NbShapes() const
|
||||
{
|
||||
return myShapes.Extent();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Message_ProgressIndicator) TopTools_ShapeSet::GetProgress() const
|
||||
{
|
||||
return myProgress;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetProgress
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void TopTools_ShapeSet::SetProgress(const Handle(Message_ProgressIndicator)& PR)
|
||||
{
|
||||
myProgress = PR;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -27,14 +27,14 @@
|
||||
#include <Standard_OStream.hxx>
|
||||
#include <Standard_IStream.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
class Message_ProgressIndicator;
|
||||
|
||||
class TopoDS_Shape;
|
||||
class TopTools_LocationSet;
|
||||
class TCollection_AsciiString;
|
||||
|
||||
|
||||
//! A ShapeSets contains a Shape and all its
|
||||
//! sub-shapes and locations. It can be dump, write
|
||||
//! sub-shapes and locations. It can be dumped, written
|
||||
//! and read.
|
||||
//!
|
||||
//! Methods to handle the geometry can be redefined.
|
||||
@@ -44,7 +44,6 @@ public:
|
||||
|
||||
DEFINE_STANDARD_ALLOC
|
||||
|
||||
|
||||
//! Builds an empty ShapeSet.
|
||||
Standard_EXPORT TopTools_ShapeSet();
|
||||
|
||||
@@ -109,7 +108,9 @@ public:
|
||||
//! Write the type.
|
||||
//! calls WriteGeometry(S).
|
||||
//! Write the flags, the subshapes.
|
||||
Standard_EXPORT virtual void Write (Standard_OStream& OS);
|
||||
Standard_EXPORT virtual void Write
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Reads the content of me from the stream <IS>. me
|
||||
//! is first cleared.
|
||||
@@ -123,7 +124,9 @@ public:
|
||||
//! Reads the type.
|
||||
//! calls ReadGeometry(T,S).
|
||||
//! Reads the flag, the subshapes.
|
||||
Standard_EXPORT virtual void Read (Standard_IStream& IS);
|
||||
Standard_EXPORT virtual void Read
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Dumps on <OS> the shape <S>. Dumps the
|
||||
//! orientation, the index of the TShape and the index
|
||||
@@ -146,10 +149,14 @@ public:
|
||||
|
||||
//! Writes the geometry of me on the stream <OS> in a
|
||||
//! format that can be read back by Read.
|
||||
Standard_EXPORT virtual void WriteGeometry (Standard_OStream& OS);
|
||||
Standard_EXPORT virtual void WriteGeometry
|
||||
(Standard_OStream& OS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Reads the geometry of me from the stream <IS>.
|
||||
Standard_EXPORT virtual void ReadGeometry (Standard_IStream& IS);
|
||||
Standard_EXPORT virtual void ReadGeometry
|
||||
(Standard_IStream& IS,
|
||||
const Handle(Message_ProgressIndicator) &theProgress = NULL);
|
||||
|
||||
//! Dumps the geometry of <S> on the stream <OS>.
|
||||
Standard_EXPORT virtual void DumpGeometry (const TopoDS_Shape& S, Standard_OStream& OS) const;
|
||||
@@ -176,40 +183,16 @@ public:
|
||||
|
||||
//! Returns number of shapes read from file.
|
||||
Standard_EXPORT Standard_Integer NbShapes() const;
|
||||
|
||||
Standard_EXPORT void SetProgress (const Handle(Message_ProgressIndicator)& PR);
|
||||
|
||||
Standard_EXPORT Handle(Message_ProgressIndicator) GetProgress() const;
|
||||
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
//! Reads from <IS> a shape and returns it in S.
|
||||
//! <NbShapes> is the number of tshapes in the set.
|
||||
Standard_EXPORT void Read (TopoDS_Shape& S, Standard_IStream& IS, const Standard_Integer NbShapes) const;
|
||||
|
||||
|
||||
TopTools_IndexedMapOfShape myShapes;
|
||||
TopTools_LocationSet myLocations;
|
||||
Standard_Integer myFormatNb;
|
||||
Handle(Message_ProgressIndicator) myProgress;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // _TopTools_ShapeSet_HeaderFile
|
||||
|
Reference in New Issue
Block a user