#include <Interface_Static.hxx>
#include <Message.hxx>
#include <Message_Messenger.hxx>
-#include <Message_ProgressSentry.hxx>
+#include <Message_ProgressScope.hxx>
#include <STEPControl_ActorWrite.hxx>
#include <STEPControl_Controller.hxx>
#include <STEPControl_Reader.hxx>
//purpose :
//=======================================================================
-static Standard_Integer stepread (Draw_Interpretor& di/*theCommands*/, Standard_Integer argc, const char** argv)
+static Standard_Integer stepread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
di << "Use: stepread [file] [f or r (type of model full or reduced)]\n";
// Progress indicator
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- progress->SetScale ( 0, 100, 1 );
- progress->Show();
+ Message_ProgressScope aPSRoot (progress->Start(), "Reading", 100);
STEPControl_Reader sr (XSDRAW::Session(),Standard_False);
TCollection_AsciiString fnom,rnom;
di<<" -- Names of variables BREP-DRAW prefixed by : "<<rnom.ToCString()<<"\n";
IFSelect_ReturnStatus readstat = IFSelect_RetVoid;
- progress->NewScope ( 20, "Loading" ); // On average loading takes 20%
- progress->Show();
+ aPSRoot.SetName("Loading");
+ progress->Show(aPSRoot);
Standard_Boolean fromtcl = Standard_False;
Standard_Boolean aFullMode = Standard_False;
if (modfic) readstat = sr.ReadFile (fnom.ToCString());
else if (XSDRAW::Session()->NbStartingEntities() > 0) readstat = IFSelect_RetDone;
- progress->EndScope();
- progress->Show();
+ aPSRoot.Next(20); // On average loading takes 20%
+ if (aPSRoot.UserBreak())
+ return 1;
if (readstat != IFSelect_RetDone) {
if (modfic) di<<"Could not read file "<<fnom.ToCString()<<" , abandon\n";
return 1;
}
-
// nom = "." -> fichier deja lu
Standard_Integer i, num, nbs, modepri = 1;
if (fromtcl) modepri = 4;
if (modepri == 2) {
std::cout<<"Root N0 : "<<std::flush; std::cin>>num;
}
+ aPSRoot.SetName("Translation");
+ progress->Show(aPSRoot);
- progress->NewScope ( 80, "Translation" );
- progress->Show();
- sr.WS()->TransferReader()->TransientProcess()->SetProgress ( progress );
-
- if (!sr.TransferRoot (num)) di<<"Transfer root n0 "<<num<<" : no result\n";
+ if (!sr.TransferRoot (num, aPSRoot.Next(80)))
+ di<<"Transfer root n0 "<<num<<" : no result\n";
else {
nbs = sr.NbShapes();
char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
TopoDS_Shape sh = sr.Shape(nbs);
DBRep::Set (shname,sh);
}
-
- sr.WS()->TransferReader()->TransientProcess()->SetProgress ( 0 );
- progress->EndScope();
- progress->Show();
+ if (aPSRoot.UserBreak())
+ return 1;
}
else if (modepri == 3) {
std::cout<<"Entity : "<<std::flush; num = XSDRAW::GetEntityNumber();
- if (!sr.TransferOne (num)) di<<"Transfer entity n0 "<<num<<" : no result\n";
+ if (!sr.TransferOne (num))
+ di<<"Transfer entity n0 "<<num<<" : no result\n";
else {
nbs = sr.NbShapes();
char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),num);
di<<"Nb entities selected : "<<nbl<<"\n";
if (nbl == 0) continue;
- progress->NewScope ( 80, "Translation" );
- progress->Show();
- sr.WS()->TransferReader()->TransientProcess()->SetProgress ( progress );
+ aPSRoot.SetName("Translation");
+ progress->Show(aPSRoot);
- Message_ProgressSentry PSentry ( progress, "Root", 0, nbl, 1 );
- for (ill = 1; ill <= nbl && PSentry.More(); ill ++, PSentry.Next()) {
+ Message_ProgressScope aPS(aPSRoot.Next(80), "Root", nbl);
+ for (ill = 1; ill <= nbl && aPS.More(); ill++) {
num = sr.Model()->Number(list->Value(ill));
if (num == 0) continue;
- if (!sr.TransferOne(num)) di<<"Transfer entity n0 "<<num<<" : no result\n";
+ if (!sr.TransferOne(num, aPS.Next()))
+ di<<"Transfer entity n0 "<<num<<" : no result\n";
else {
nbs = sr.NbShapes();
char shname[30]; Sprintf (shname,"%s_%d",rnom.ToCString(),nbs);
DBRep::Set (shname,sh);
}
}
- sr.WS()->TransferReader()->TransientProcess()->SetProgress ( 0 );
- progress->EndScope();
- progress->Show();
+ if (aPSRoot.UserBreak())
+ return 1;
}
else di<<"Unknown mode n0 "<<modepri<<"\n";
}
Standard_Integer nbavant = (stepmodel.IsNull() ? 0 : stepmodel->NbEntities());
Handle(Draw_ProgressIndicator) progress = new Draw_ProgressIndicator ( di, 1 );
- progress->NewScope(90,"Translating");
- progress->Show();
- sw.WS()->TransferWriter()->FinderProcess()->SetProgress(progress);
+ Message_ProgressScope aPSRoot (progress->Start(), "Translating", 100);
+ progress->Show(aPSRoot);
- Standard_Integer stat = sw.Transfer (shape,mode);
+ Standard_Integer stat = sw.Transfer (shape, mode, Standard_True, aPSRoot.Next(90));
if (stat == IFSelect_RetDone)
{
di << "Translation: OK\n";
di << "Error: translation failed, status = " << stat << "\n";
}
- sw.WS()->TransferWriter()->FinderProcess()->SetProgress(0);
- progress->EndScope();
- progress->Show();
- progress->NewScope(10,"Writing");
- progress->Show();
+ if (aPSRoot.UserBreak())
+ return 1;
+ aPSRoot.SetName("Writing");
+ progress->Show(aPSRoot);
// Que s est-il passe
stepmodel = sw.Model();
default : di<<"Error: File "<<nomfic<<" written with fail messages\n"; break;
}
- progress->EndScope();
- progress->Show();
-
return 0;
}
//=======================================================================