FreeCAD

Форк
0
/
ProgressIndicator.cpp 
85 строк · 3.1 Кб
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

28
using namespace Part;
29
/*!
30
  \code
31
  #include <XSControl_WorkSession.hxx>
32
  #include <Transfer_TransientProcess.hxx>
33

34
  STEPControl_Reader aReader;
35
  Handle(Message_ProgressIndicator) pi = new ProgressIndicator(100);
36

37
  pi->NewScope(20, "Loading STEP file...");
38
  pi->Show();
39
  aReader.ReadFile("myfile.stp");
40
  pi->EndScope();
41

42
  Handle(StepData_StepModel) Model = aReader.StepModel();
43
  pi->NewScope(80, "Translating...");
44
  pi->Show();
45
  aReader.WS()->MapReader()->SetProgress(pi);
46
  Standard_Integer nbr = aReader.NbRootsForTransfer();
47
  for ( Standard_Integer n = 1; n<= nbr; n++) {
48
    ...
49
  }
50

51
  pi->EndScope();
52
  \endcode
53
 */
54

55
#if OCC_VERSION_HEX < 0x070500
56
ProgressIndicator::ProgressIndicator (int theMaxVal)
57
  : myProgress(new Base::SequencerLauncher("", theMaxVal))
58
{
59
    SetScale (0, theMaxVal, 1);
60
}
61

62
ProgressIndicator::~ProgressIndicator ()
63
{
64
}
65

66
Standard_Boolean ProgressIndicator::Show (const Standard_Boolean theForce)
67
{
68
    if (theForce) {
69
        Handle(TCollection_HAsciiString) aName = GetScope(1).GetName(); //current step
70
        if (!aName.IsNull())
71
            myProgress->setText (aName->ToCString());
72
    }
73

74
    Standard_Real aPc = GetPosition(); //always within [0,1]
75
    int aVal = (int)(aPc * myProgress->numberOfSteps());
76
    myProgress->setProgress (aVal);
77

78
    return Standard_True;
79
}
80

81
Standard_Boolean ProgressIndicator::UserBreak()
82
{
83
    return myProgress->wasCanceled();
84
}
85
#endif
86

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.