FreeCAD
1/***************************************************************************
2* Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net> *
3* *
4* This file is part of the FreeCAD CAx development system. *
5* *
6* This library is free software; you can redistribute it and/or *
7* modify it under the terms of the GNU Library General Public *
8* License as published by the Free Software Foundation; either *
9* version 2 of the License, or (at your option) any later version. *
10* *
11* This library is distributed in the hope that it will be useful, *
12* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14* GNU Library General Public License for more details. *
15* *
16* You should have received a copy of the GNU Library General Public *
17* License along with this library; see the file COPYING.LIB. If not, *
18* write to the Free Software Foundation, Inc., 59 Temple Place, *
19* Suite 330, Boston, MA 02111-1307, USA *
20* *
21***************************************************************************/
22
23#include "PreCompiled.h"24
25#include "ProgressIndicator.h"26
27
28using namespace Part;29/*!
30\code
31#include <XSControl_WorkSession.hxx>
32#include <Transfer_TransientProcess.hxx>
33
34STEPControl_Reader aReader;
35Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
36
37pi->NewScope(20, "Loading STEP file...");
38pi->Show();
39aReader.ReadFile("myfile.stp");
40pi->EndScope();
41
42Handle(StepData_StepModel) Model = aReader.StepModel();
43pi->NewScope(80, "Translating...");
44pi->Show();
45aReader.WS()->MapReader()->SetProgress(pi);
46Standard_Integer nbr = aReader.NbRootsForTransfer();
47for ( Standard_Integer n = 1; n<= nbr; n++) {
48...
49}
50
51pi->EndScope();
52\endcode
53*/
54
55#if OCC_VERSION_HEX < 0x07050056ProgressIndicator::ProgressIndicator (int theMaxVal)57: myProgress(new Base::SequencerLauncher("", theMaxVal))58{
59SetScale (0, theMaxVal, 1);60}
61
62ProgressIndicator::~ProgressIndicator ()63{
64}
65
66Standard_Boolean ProgressIndicator::Show (const Standard_Boolean theForce)67{
68if (theForce) {69Handle(TCollection_HAsciiString) aName = GetScope(1).GetName(); //current step70if (!aName.IsNull())71myProgress->setText (aName->ToCString());72}73
74Standard_Real aPc = GetPosition(); //always within [0,1]75int aVal = (int)(aPc * myProgress->numberOfSteps());76myProgress->setProgress (aVal);77
78return Standard_True;79}
80
81Standard_Boolean ProgressIndicator::UserBreak()82{
83return myProgress->wasCanceled();84}
85#endif86