1 // Created on: 2002-02-22
2 // Created by: Andrey BETENEV
3 // Copyright (c) 2002-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 _Message_ProgressSentry_HeaderFile
17 #define _Message_ProgressSentry_HeaderFile
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
23 #include <Standard_Boolean.hxx>
24 #include <Standard_CString.hxx>
25 #include <Standard_Real.hxx>
26 class Message_ProgressIndicator;
27 class TCollection_HAsciiString;
30 //! This class is a tool allowing to manage opening/closing
31 //! scopes in the ProgressIndicator in convenient and safe way.
33 //! Its main features are:
34 //! - Set all parameters for the current scale on the given
35 //! ProgressIndicator and open a new scope at one line
36 //! - Iterator-like interface to opening next scopes and
37 //! check for user break
38 //! - Automatic scope closing in destructor
39 //! - Safe for NULL ProgressIndicator (just does nothing)
41 //! Example of usage in nested process:
44 //! Handle(Draw_ProgressIndicator) aProgress = ...;
47 //! Message_ProgressSentry anOuter (aProgress, "Outer", 0, nbOuter, 1);
48 //! for (int i = 0; i < nbOuter && anOuter.More(); i++, anOuter.Next())
51 //! Message_ProgressSentry anInner (aProgress, "Inner", 0, nbInner, 1);
52 //! for (int j = 0; j < nbInner && anInner.More(); j++, anInner.Next())
59 class Message_ProgressSentry
66 Standard_EXPORT Message_ProgressSentry(const Handle(Message_ProgressIndicator)& PI, const Standard_CString name, const Standard_Real min, const Standard_Real max, const Standard_Real step, const Standard_Boolean isInf = Standard_False, const Standard_Real newScopeSpan = 0.0);
68 //! Creates an instance of ProgressSentry attaching it to
69 //! the specified ProgressIndicator, selects parameters of
70 //! the current scale, and opens a new scope with specified
71 //! span (equal to step by default)
72 Standard_EXPORT Message_ProgressSentry(const Handle(Message_ProgressIndicator)& PI, const Handle(TCollection_HAsciiString)& name, const Standard_Real min, const Standard_Real max, const Standard_Real step, const Standard_Boolean isInf = Standard_False, const Standard_Real newScopeSpan = 0.0);
74 //! Moves progress indicator to the end of the current scale
75 //! and relieves sentry from its duty. Methods other than Show()
76 //! will do nothing after this one is called.
78 ~Message_ProgressSentry()
83 void Next (const Standard_CString name = 0) const;
85 void Next (const Standard_Real span, const Standard_CString name = 0) const;
87 //! Closes current scope and opens next one
88 //! with either specified or default span
89 void Next (const Standard_Real span, const Handle(TCollection_HAsciiString)& name) const;
91 //! Returns False if ProgressIndicator signals UserBreak
92 Standard_Boolean More() const;
94 //! Forces update of progress indicator display
110 Handle(Message_ProgressIndicator) myProgress;
111 Standard_Boolean myActive;
117 #include <Message_ProgressSentry.lxx>
123 #endif // _Message_ProgressSentry_HeaderFile