Computer Assited Medical Intervention Tool Kit
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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-2013 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 
39 class ItkProgressObserver : public itk::Command
40 {
41  public:
43  typedef itk::Command Superclass;
44  typedef itk::SmartPointer<Self> Pointer;
46 
47  protected:
49 
50  public:
51  void Execute(itk::Object *caller, const itk::EventObject & event);
52  void Execute(const itk::Object * object, const itk::EventObject & event);
53  void Reset();
54  void SetCoef(double coef);
55  void SetStartValue(double startValue);
56 
57  private :
58  double compteur;
59  double coef;
60  double startValue;
61 };
62 
63 
65  coef = 1.0;
66  compteur = 0.0;
67  startValue = 0.0;
68  // update the progress bar if there is one!
70 }
71 
72 inline void ItkProgressObserver::Execute(itk::Object *caller, const itk::EventObject & event) {
73  Execute((const itk::Object *)caller, event);
74 }
75 
76 inline void ItkProgressObserver::Execute(const itk::Object * object, const itk::EventObject & event) {
77  const itk::ProcessObject * filter =
78  dynamic_cast< const itk::ProcessObject * >(object);
79  if (! itk::ProgressEvent().CheckEvent(&event))
80  {
81  return;
82  }
83  compteur = filter->GetProgress();
84  // update the progress bar if there is one!
86 }
87 
89  compteur = 0.0;
90  startValue = 0.0;
91  // update the progress bar if there is one!
93 }
94 
95 inline void ItkProgressObserver::SetCoef(double coef) {
96  this->coef = coef;
97 }
98 
99 inline void ItkProgressObserver::SetStartValue(double startValue) {
100  this->startValue = startValue;
101 }
102 
103 }
104 
105 #endif //ITK_PROGRESS_OBSERVER