| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkLightProcessObject.cxx.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:41 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
DEF |
=========================================================================*/ |
| 17 |
|
#include "itkLightProcessObject.h" |
| 18 |
|
#include "itkCommand.h" |
| 19 |
|
#include "itkEventObject.h" |
| 20 |
|
|
| 21 |
|
namespace itk |
| 22 |
|
{ |
| 23 |
|
|
| 24 |
|
/** |
| 25 |
IND |
**** Instantiate object with no start, end, or progress methods. |
| 26 |
IND |
****/ |
| 27 |
|
LightProcessObject |
| 28 |
|
::LightProcessObject() |
| 29 |
|
{ |
| 30 |
|
m_AbortGenerateData = false; |
| 31 |
|
m_Progress = 0.0; |
| 32 |
|
} |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
/** |
| 36 |
IND |
**** Destructor for the LightProcessObject class. We've got to |
| 37 |
IND |
**** UnRegister() the use of any input classes. |
| 38 |
IND |
****/ |
| 39 |
|
LightProcessObject |
| 40 |
|
::~LightProcessObject() |
| 41 |
|
{} |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
/** |
| 45 |
IND |
**** Update the progress of the process object. If a ProgressMethod exists, |
| 46 |
IND |
**** executes it. Then set the Progress ivar to amount. The parameter amount |
| 47 |
IND |
**** should range between (0,1). |
| 48 |
IND |
****/ |
| 49 |
|
void |
| 50 |
|
LightProcessObject |
| 51 |
|
::UpdateProgress(float amount) |
| 52 |
|
{ |
| 53 |
|
m_Progress = amount; |
| 54 |
|
this->InvokeEvent( ProgressEvent() ); |
| 55 |
|
} |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
/** |
| 59 |
IND |
**** |
| 60 |
IND |
****/ |
| 61 |
|
void |
| 62 |
|
LightProcessObject |
| 63 |
|
::PrintSelf(std::ostream& os, Indent indent) const |
| 64 |
|
{ |
| 65 |
|
Superclass::PrintSelf(os,indent); |
| 66 |
|
|
| 67 |
LEN |
os << indent << "AbortGenerateData: " << (m_AbortGenerateData ? "On\n" : "Off\n"); |
| 68 |
|
os << indent << "Progress: " << m_Progress << "\n"; |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
/** |
| 73 |
|
* |
| 74 |
|
*/ |
| 75 |
|
void |
| 76 |
|
LightProcessObject |
| 77 |
|
::UpdateOutputData() |
| 78 |
|
{ |
| 79 |
|
|
| 80 |
|
this->InvokeEvent( StartEvent() ); |
| 81 |
|
|
| 82 |
|
/** |
| 83 |
IND |
****** GenerateData this object - we have not aborted yet, and our progress |
| 84 |
IND |
****** before we start to execute is 0.0. |
| 85 |
IND |
******/ |
| 86 |
|
m_AbortGenerateData = 0; |
| 87 |
|
m_Progress = 0.0; |
| 88 |
|
|
| 89 |
|
this->GenerateData(); |
| 90 |
|
|
| 91 |
|
/** |
| 92 |
IND |
****** If we ended due to aborting, push the progress up to 1.0 (since |
| 93 |
|
* it probably didn't end there) |
| 94 |
IND |
******/ |
| 95 |
|
if ( !m_AbortGenerateData ) |
| 96 |
|
{ |
| 97 |
|
this->UpdateProgress(1.0); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
// Notify end event observers |
| 101 |
|
this->InvokeEvent( EndEvent() ); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
} // end namespace itk |
| 105 |
|
|