1 // Created on: 2008-06-25
2 // Created by: data exchange team
3 // Copyright (c) 2008-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Draw_ProgressIndicator_HeaderFile
17 #define _Draw_ProgressIndicator_HeaderFile
19 #include <Standard.hxx>
21 #include <Message_ProgressIndicator.hxx>
22 #include <Draw_Interpretor.hxx>
24 class Draw_ProgressIndicator;
25 DEFINE_STANDARD_HANDLE(Draw_ProgressIndicator, Message_ProgressIndicator)
27 //! Implements ProgressIndicator (interface provided by Message)
28 //! for DRAW, with possibility to output to TCL window
30 class Draw_ProgressIndicator : public Message_ProgressIndicator
36 //! Creates a progress indicator and remembers pointer to Draw_Interpretor
38 //! @param theUpdateThreshold defines minimal progress (in percents) between
39 //! updates of the indicator (non-forced updates of the progress bar will be
40 //! disabled until that progress is reached since last update).
41 Standard_EXPORT Draw_ProgressIndicator(const Draw_Interpretor& di, Standard_Real theUpdateThreshold = 1.);
43 //! Destructor; calls Reset()
44 Standard_EXPORT ~Draw_ProgressIndicator();
46 //! Sets tcl output mode (on/off).
47 Standard_EXPORT void SetTclMode (const Standard_Boolean theTclMode);
49 //! Gets tcl output mode (on/off).
50 Standard_EXPORT Standard_Boolean GetTclMode() const;
52 //! Sets console output mode (on/off).
53 //! If it is on then progress is shown in the standard output.
54 Standard_EXPORT void SetConsoleMode(const Standard_Boolean theMode);
56 //! Gets console output mode (on/off)
57 Standard_EXPORT Standard_Boolean GetConsoleMode() const;
59 //! Sets graphical output mode (on/off)
60 Standard_EXPORT void SetGraphMode (const Standard_Boolean theGraphMode);
62 //! Gets graphical output mode (on/off)
63 Standard_EXPORT Standard_Boolean GetGraphMode() const;
65 //! Clears/erases opened TCL windows if any
66 //! and sets myBreak to False
67 Standard_EXPORT virtual void Reset() Standard_OVERRIDE;
69 //! Defines method Show of Progress Indicator
70 Standard_EXPORT virtual void Show (const Message_ProgressScope& theScope,
71 const Standard_Boolean force = Standard_True) Standard_OVERRIDE;
73 //! Redefines method UserBreak of Progress Indicator
74 Standard_EXPORT virtual Standard_Boolean UserBreak() Standard_OVERRIDE;
76 //! Get/Set default value for tcl mode
77 Standard_EXPORT static Standard_Boolean& DefaultTclMode();
79 //! Get/Set default value for console mode
80 Standard_EXPORT static Standard_Boolean& DefaultConsoleMode();
82 //! Get/Set default value for graph mode
83 Standard_EXPORT static Standard_Boolean& DefaultGraphMode();
85 //! Internal method for implementation of UserBreak mechanism;
86 //! note that it uses static variable and thus not thread-safe!
87 Standard_EXPORT static Standard_Address& StopIndicator();
89 DEFINE_STANDARD_RTTIEXT(Draw_ProgressIndicator,Message_ProgressIndicator)
92 Standard_Boolean myTclMode;
93 Standard_Boolean myConsoleMode;
94 Standard_Boolean myGraphMode;
95 Draw_Interpretor* myDraw;
96 Standard_Boolean myShown;
97 Standard_Boolean myBreak;
98 Standard_Real myUpdateThreshold;
99 Standard_Real myLastPosition;
100 Standard_Size myStartTime;
101 Standard_ThreadId myGuiThreadId;
104 #endif // _Draw_ProgressIndicator_HeaderFile