Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ItkProgressObserver.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef ITK_PROGRESS_OBSERVER
27 #define ITK_PROGRESS_OBSERVER
28 
29 // -- Core image component stuff
30 #include "Application.h"
31 
32 // -- itk stuff
33 #include <itkCommand.h>
34 #include <itkProcessObject.h>
35 
36 namespace camitk
37 {
38 
47 class ItkProgressObserver : public itk::Command
48 {
49  public:
51  typedef itk::Command Superclass;
52  typedef itk::SmartPointer<Self> Pointer;
53  itkNewMacro(Self);
54 
55  protected:
57 
58  public:
59  void Execute(itk::Object *caller, const itk::EventObject & event);
60  void Execute(const itk::Object * object, const itk::EventObject & event);
61  void Reset();
62  void SetCoef(double coef);
63  void SetStartValue(double startValue);
64 
65  private :
66  double compteur;
67  double coef;
68  double startValue;
69 };
70 
71 
73  coef = 1.0;
74  compteur = 0.0;
75  startValue = 0.0;
76  // update the progress bar if there is one!
78 }
79 
80 inline void ItkProgressObserver::Execute(itk::Object *caller, const itk::EventObject & event) {
81  Execute((const itk::Object *)caller, event);
82 }
83 
84 inline void ItkProgressObserver::Execute(const itk::Object * object, const itk::EventObject & event) {
85  const itk::ProcessObject * filter =
86  dynamic_cast< const itk::ProcessObject * >(object);
87  if (! itk::ProgressEvent().CheckEvent(&event))
88  {
89  return;
90  }
91  compteur = filter->GetProgress();
92  // update the progress bar if there is one!
94 }
95 
97  compteur = 0.0;
98  startValue = 0.0;
99  // update the progress bar if there is one!
101 }
102 
103 inline void ItkProgressObserver::SetCoef(double coef) {
104  this->coef = coef;
105 }
106 
107 inline void ItkProgressObserver::SetStartValue(double startValue) {
108  this->startValue = startValue;
109 }
110 
111 }
112 
113 #endif //ITK_PROGRESS_OBSERVER
void Reset()
Definition: ItkProgressObserver.h:96
void SetCoef(double coef)
Definition: ItkProgressObserver.h:103
Definition: Action.h:40
double compteur
Definition: ItkProgressObserver.h:66
ItkProgressObserver()
Definition: ItkProgressObserver.h:72
Allows showing a progress bar when using ITK methods.
Definition: ItkProgressObserver.h:47
itk::Command Superclass
Definition: ItkProgressObserver.h:51
ItkProgressObserver Self
Definition: ItkProgressObserver.h:50
itk::SmartPointer< Self > Pointer
Definition: ItkProgressObserver.h:52
static void setProgressBarValue(int)
set the progress bar value, value should be in [0..100].
double coef
Definition: ItkProgressObserver.h:67
double startValue
Definition: ItkProgressObserver.h:68
void SetStartValue(double startValue)
Definition: ItkProgressObserver.h:107
void Execute(itk::Object *caller, const itk::EventObject &event)
Definition: ItkProgressObserver.h:80