Computer Assited Medical Intervention Tool Kit  version 5.0
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-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
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 
46 class ItkProgressObserver : public itk::Command {
47 public:
48  typedef ItkProgressObserver Self;
49  typedef itk::Command Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
52 
53 protected:
55 
56 public:
57  void Execute(itk::Object* caller, const itk::EventObject& event);
58  void Execute(const itk::Object* object, const itk::EventObject& event);
59  void Reset();
60  void SetCoef(double coef);
61  void SetStartValue(double startValue);
62 
63 private :
64  double compteur;
65  double coef;
66  double startValue;
67 };
68 
69 
71  coef = 1.0;
72  compteur = 0.0;
73  startValue = 0.0;
74  // update the progress bar if there is one!
76 }
77 
78 inline void ItkProgressObserver::Execute(itk::Object* caller, const itk::EventObject& event) {
79  Execute((const itk::Object*)caller, event);
80 }
81 
82 inline void ItkProgressObserver::Execute(const itk::Object* object, const itk::EventObject& event) {
83  const itk::ProcessObject* filter =
84  dynamic_cast< const itk::ProcessObject* >(object);
85  if (! itk::ProgressEvent().CheckEvent(&event)) {
86  return;
87  }
88  compteur = filter->GetProgress();
89  // update the progress bar if there is one!
91 }
92 
94  compteur = 0.0;
95  startValue = 0.0;
96  // update the progress bar if there is one!
98 }
99 
100 inline void ItkProgressObserver::SetCoef(double coef) {
101  this->coef = coef;
102 }
103 
104 inline void ItkProgressObserver::SetStartValue(double startValue) {
105  this->startValue = startValue;
106 }
107 
108 }
109 
110 #endif //ITK_PROGRESS_OBSERVER
camitk::ItkProgressObserver::itkNewMacro
itkNewMacro(Self)
camitk::ItkProgressObserver::coef
double coef
Definition: ItkProgressObserver.h:111
camitk::ItkProgressObserver::startValue
double startValue
Definition: ItkProgressObserver.h:112
camitk::Application::setProgressBarValue
static void setProgressBarValue(int)
set the progress bar value, value should be in [0..100].
Definition: Application.cpp:374
camitk::ItkProgressObserver::Pointer
itk::SmartPointer< Self > Pointer
Definition: ItkProgressObserver.h:96
camitk::ItkProgressObserver::Superclass
itk::Command Superclass
Definition: ItkProgressObserver.h:95
camitk::ItkProgressObserver::Self
ItkProgressObserver Self
Definition: ItkProgressObserver.h:94
camitk::ItkProgressObserver::Execute
void Execute(itk::Object *caller, const itk::EventObject &event)
Definition: ItkProgressObserver.h:101
camitk::ItkProgressObserver::Reset
void Reset()
Definition: ItkProgressObserver.h:116
camitk::ItkProgressObserver::ItkProgressObserver
ItkProgressObserver()
Definition: ItkProgressObserver.h:93
camitk::ItkProgressObserver::SetStartValue
void SetStartValue(double startValue)
Definition: ItkProgressObserver.h:127
camitk::ItkProgressObserver::SetCoef
void SetCoef(double coef)
Definition: ItkProgressObserver.h:123
camitk::ItkProgressObserver::compteur
double compteur
Definition: ItkProgressObserver.h:110
Application.h
camitk
Definition: Action.cpp:35