#include <TePDIPIManager.hpp>
Definition at line 43 of file TePDIPIManager.hpp.
Public Member Functions | |
| bool | Increment () |
| void | Reset (const std::string &message=std::string(), unsigned long int tsteps=0) |
| TePDIPIManager (const std::string &message=std::string(), unsigned long int tsteps=0, bool enabled=false) | |
| void | Toggle (bool enabled) |
| bool | Update (unsigned long int step) |
| bool | wasCanceled () |
| ~TePDIPIManager () | |
Protected Member Functions | |
| bool | updateProgressInterface () const |
Protected Attributes | |
| unsigned long int | curr_step_ |
| bool | enabled_ |
| TePDIPIManagerGlobalSettings & | global_settings_ |
| std::string | message_ |
| TeProgressBase * | prog_intef_ptr_ |
| unsigned long int | total_steps_ |
Private Member Functions | |
| const TePDIPIManager & | operator= (const TePDIPIManager &) |
| TePDIPIManager (const TePDIPIManager &) | |
| TePDIPIManager::TePDIPIManager | ( | const std::string & | message = std::string(), |
|
| unsigned long int | tsteps = 0, |
|||
| bool | enabled = false | |||
| ) |
Default Constructor
| message | Progress window message (label). | |
| tsteps | Progress window total steps. | |
| enabled | Flag to enable ( true ) or disable ( false ). |
Definition at line 12 of file TePDIPIManager.cpp.
References curr_step_, enabled_, TeProgress::instance(), message_, prog_intef_ptr_, Toggle(), and total_steps_.
00014 : global_settings_( TePDIPIManagerGlobalSettings::instance() ) 00015 { 00016 enabled_ = false; 00017 total_steps_ = tsteps; 00018 curr_step_ = 0; 00019 prog_intef_ptr_ = TeProgress::instance(); 00020 message_ = message; 00021 00022 if( enabled ) { 00023 Toggle( true ); 00024 } 00025 }
| TePDIPIManager::~TePDIPIManager | ( | ) |
Default Destructor
Definition at line 33 of file TePDIPIManager.cpp.
References Toggle().
00034 { 00035 Toggle( false ); 00036 }
| TePDIPIManager::TePDIPIManager | ( | const TePDIPIManager & | ) | [private] |
Alternative Constructor
Definition at line 27 of file TePDIPIManager.cpp.
00028 : global_settings_( TePDIPIManagerGlobalSettings::instance() ) 00029 { 00030 }
| bool TePDIPIManager::Increment | ( | ) | [inline] |
Incriments the the current progress by one step.
Definition at line 81 of file TePDIPIManager.hpp.
Referenced by TePDIMMIOMatching::bicubicResampleMatrix(), TePDIMMIOMatching::calcCCorrelationMtx(), TePDIKMeansClas::classifyPixels(), TePDIArithmetic::execBinaryOperator(), TePDIMMIOMatching::extractLocalMaximas(), TePDIParallelSegmenter::flushBlock(), TePDIOFMatching::gaussianSmoothing(), TePDIKMeansClas::GenerateClassificationParameters(), TePDIMallatWavelets::GenerateLevel(), TePDIOFMatching::generateLSSurface(), TePDIUtils::getBandMinMaxValues(), TePDIOFMatching::getMaximaPoints(), TePDIPrincoMixModelStrategy::Implementation(), TePDIAlgorithm::IncProgInt(), initialize_segments(), TePDIKMeansClas::kmeans(), TePDIOFMatching::loadImage(), TePDIMMIOMatching::loadImage(), TePDIMIMatching::loadImage(), TePDICorrelationMatching::loadImage(), TePDIUtils::loadRaster(), loadRaster(), TePDIOFMatching::locateBestFeaturesMatching(), TePDIMMIOMatching::matchFeatures(), TePDIMallatWavelets::Recompose(), TePDIHistogram::reset(), TePDISAMClassifier::SegThread::run(), TePDICorrelationMatching::CorrThread::run(), TePDIWiSpeRFusion::RunImplementation(), TePDIVenturaFusion::RunImplementation(), TePDITPMosaic::RunImplementation(), TePDIParallelSegmenter::RunImplementation(), TePDIMMIOMatching::RunImplementation(), TePDIMIMatching::RunImplementation(), TePDIIHSWaveletFusion::RunImplementation(), TePDIIHSFusion::RunImplementation(), TePDIGeoMosaic::RunImplementation(), TePDIGeneralizedIHSFusion::RunImplementation(), TePDIEMClas::RunImplementation(), TePDICorrelationMatching::RunImplementation(), TePDIArithmetic::RunImplementation(), TePDIPrincipalComponents::RunImplementation_direct(), TePDIPrincipalComponents::RunImplementation_inverse(), TePDIWaveletAtrous::RunImplementation_recompose(), TePDIColorTransform::RunRgb2Ihs(), segmentation(), TePDIHistogram::Set16BitH(), TePDIHistogram::Set8BitH(), TePDIHistogram::SetH(), TePDIHistogram::SetPaletteBasedH(), TePDIUtils::TeRaster2Geotiff(), TePDIUtils::TeRaster2Jpeg(), TePDIUtils::TeRaster2RGBGeotiff(), TePDIJointHistogram::updateFloat(), and write_segments().
00082 { 00083 return Update( (int)( curr_step_ + 1 ) ); 00084 };
| const TePDIPIManager& TePDIPIManager::operator= | ( | const TePDIPIManager & | ) | [inline, private] |
| void TePDIPIManager::Reset | ( | const std::string & | message = std::string(), |
|
| unsigned long int | tsteps = 0 | |||
| ) |
Reset the current instance state.
| message | Message (label). | |
| tsteps | Total steps. |
Definition at line 164 of file TePDIPIManager.cpp.
References curr_step_, enabled_, message_, Toggle(), and total_steps_.
Referenced by TePDIArithmetic::ResetState(), TePDIWiSpeRFusion::RunImplementation(), TePDIIHSWaveletFusion::RunImplementation(), TePDIGeneralizedIHSFusion::RunImplementation(), TePDIArithmetic::RunImplementation(), and TePDIAlgorithm::StartProgInt().
00166 { 00167 bool old_enabled_state = enabled_; 00168 00169 Toggle( false ); 00170 00171 total_steps_ = tsteps; 00172 curr_step_ = 0; 00173 message_ = message; 00174 00175 if( old_enabled_state ) { 00176 Toggle( true ); 00177 } 00178 }
| void TePDIPIManager::Toggle | ( | bool | enabled | ) |
Enable / Disable the current progress interface manager.
| enabled | Flag to enable ( true ) or disable ( false ). |
Definition at line 39 of file TePDIPIManager.cpp.
References TePDIPIManagerGlobalSettings::active_manager_instances_, TePDIPIManagerGlobalSettings::curr_message_, curr_step_, TePDIPIManagerGlobalSettings::curr_step_, enabled_, global_settings_, TeMutex::lock(), TePDIPIManagerGlobalSettings::lock_, message_, prog_intef_ptr_, TePDIPIManagerGlobalSettings::total_steps_, total_steps_, TeMutex::unLock(), and updateProgressInterface().
Referenced by TePDIKMeansClas::classifyPixels(), TePDIHistogram::Discretize(), TePDIKMeansClas::GenerateClassificationParameters(), TePDIMallatWavelets::GenerateLevel(), TePDIPrincoMixModelStrategy::Implementation(), initialize_segments(), TePDIKMeansClas::kmeans(), TePDIMallatWavelets::Recompose(), Reset(), TePDIWiSpeRFusion::RunImplementation(), TePDIVenturaFusion::RunImplementation(), TePDIIHSWaveletFusion::RunImplementation(), TePDIEMClas::RunImplementation(), TePDIArithmetic::RunImplementation(), TePDIPrincipalComponents::RunImplementation_direct(), TePDIPrincipalComponents::RunImplementation_inverse(), TePDIAlgorithm::StartProgInt(), TePDIAlgorithm::StopProgInt(), TePDIPIManager(), TePDIAlgorithm::ToggleProgInt(), write_segments(), and ~TePDIPIManager().
00040 { 00041 if( prog_intef_ptr_ ) 00042 { 00043 if( ( ! enabled_ ) && enabled && ( total_steps_ > 0 ) ) { 00044 /* Need to enable this instance */ 00045 00046 global_settings_.lock_.lock(); 00047 00048 if( global_settings_.active_manager_instances_ == 0 ) { 00049 /* No instance has control */ 00050 00051 global_settings_.total_steps_ = total_steps_; 00052 global_settings_.curr_step_ = curr_step_; 00053 /* keeping global_settings.curr_prop_step_ */ 00054 global_settings_.active_manager_instances_ = 1; 00055 global_settings_.curr_message_ = message_; 00056 } else { 00057 /* More instances are controling */ 00058 00059 global_settings_.total_steps_ += total_steps_; 00060 global_settings_.curr_step_ += curr_step_; 00061 /* Keeping global_settings.curr_prop_step_ */ 00062 global_settings_.active_manager_instances_ += 1; 00063 global_settings_.curr_message_.clear(); 00064 } 00065 00066 enabled_ = true; 00067 00068 updateProgressInterface(); 00069 00070 global_settings_.lock_.unLock(); 00071 } if( enabled_ && ( ! enabled ) ) { 00072 /* Need to disable this instance */ 00073 00074 global_settings_.lock_.lock(); 00075 00076 if( global_settings_.active_manager_instances_ == 1 ) { 00077 /* Just this instance has control */ 00078 00079 global_settings_.total_steps_ = 0; 00080 global_settings_.curr_step_ = 0; 00081 /* keeping global_settings.curr_prop_step_ */ 00082 global_settings_.active_manager_instances_ = 0; 00083 global_settings_.curr_message_.clear(); 00084 } else { 00085 /* More instance are controling */ 00086 00087 /* keeping global_settings.total_steps_ */ 00088 global_settings_.curr_step_ += ( total_steps_ - curr_step_ ); 00089 /* keeping global_settings.curr_prop_step_ */ 00090 global_settings_.active_manager_instances_ -= 1; 00091 } 00092 00093 enabled_ = false; 00094 00095 updateProgressInterface(); 00096 00097 global_settings_.lock_.unLock(); 00098 } 00099 } 00100 }
Update the current progress interface to the supplied step.
| step | Current step. |
Definition at line 137 of file TePDIPIManager.cpp.
References TePDIPIManagerGlobalSettings::curr_step_, curr_step_, enabled_, global_settings_, TeMutex::lock(), TePDIPIManagerGlobalSettings::lock_, prog_intef_ptr_, total_steps_, TeMutex::unLock(), and updateProgressInterface().
Referenced by TePDIHistogram::Discretize(), main(), TePDIRegGrowSeg::RunImplementation(), and TePDIAlgorithm::UpdateProgInt().
00138 { 00139 if( step > total_steps_ ) { 00140 step = total_steps_; 00141 } 00142 00143 if( enabled_ && prog_intef_ptr_ && ( step > curr_step_ ) ) 00144 { 00145 global_settings_.lock_.lock(); 00146 00147 /* keeping global_settings.total_steps_ */ 00148 global_settings_.curr_step_ += ( step - curr_step_ ); 00149 /* keeping global_settings.curr_prop_step_ */ 00150 /* keeping global_settings.active_manager_instances_ */ 00151 00152 curr_step_ = step; 00153 00154 bool return_value = updateProgressInterface(); 00155 00156 global_settings_.lock_.unLock(); 00157 00158 return return_value; 00159 } else { 00160 return false; 00161 } 00162 }
| bool TePDIPIManager::updateProgressInterface | ( | ) | const [protected] |
Updates the progress interface with the new settings.
| settings | The new progress interface manager to be applied. | |
| prog_intef_ptr | Progres interface pointer. |
Definition at line 103 of file TePDIPIManager.cpp.
References TePDIPIManagerGlobalSettings::active_manager_instances_, TePDIPIManagerGlobalSettings::curr_message_, TePDIPIManagerGlobalSettings::curr_prop_step_, TePDIPIManagerGlobalSettings::curr_step_, global_settings_, prog_intef_ptr_, TeProgressBase::reset(), TeProgressBase::setMessage(), TeProgressBase::setProgress(), TeProgressBase::setTotalSteps(), TePDIPIManagerGlobalSettings::total_steps_, and TeProgressBase::wasCancelled().
Referenced by Toggle(), and Update().
00104 { 00105 if( prog_intef_ptr_->wasCancelled() ) { 00106 if( global_settings_.active_manager_instances_ == 0 ) { 00107 prog_intef_ptr_->reset(); 00108 return false; 00109 } else { 00110 return true; 00111 } 00112 } else { 00113 if( global_settings_.active_manager_instances_ == 0 ) 00114 { 00115 global_settings_.curr_prop_step_ = 0; 00116 prog_intef_ptr_->reset(); 00117 } else { 00118 unsigned long int new_prop_step = (unsigned long int) 00119 ( 100.0 * 00120 ( ((double)global_settings_.curr_step_) / 00121 ( (double)global_settings_.total_steps_ ) ) ); 00122 00123 if( new_prop_step > global_settings_.curr_prop_step_ ) { 00124 prog_intef_ptr_->setMessage( global_settings_.curr_message_ ); 00125 prog_intef_ptr_->setTotalSteps( 100 ); 00126 prog_intef_ptr_->setProgress( new_prop_step ); 00127 00128 global_settings_.curr_prop_step_ = new_prop_step; 00129 } 00130 } 00131 00132 return false; 00133 } 00134 }
| bool TePDIPIManager::wasCanceled | ( | ) | [inline] |
Returns true if the progress was canceled.
Definition at line 99 of file TePDIPIManager.hpp.
00100 { 00101 return ( prog_intef_ptr_ ? prog_intef_ptr_->wasCancelled() : false ); 00102 };
unsigned long int TePDIPIManager::curr_step_ [protected] |
The current step.
Definition at line 119 of file TePDIPIManager.hpp.
Referenced by Reset(), TePDIPIManager(), TePDIPIManagerGlobalSettings::TePDIPIManagerGlobalSettings(), Toggle(), and Update().
bool TePDIPIManager::enabled_ [protected] |
A flag indicating if the PI manager is enabled.
Definition at line 102 of file TePDIPIManager.hpp.
Referenced by Reset(), TePDIPIManager(), Toggle(), and Update().
A reference to the global settings instance.
Definition at line 124 of file TePDIPIManager.hpp.
Referenced by Toggle(), Update(), and updateProgressInterface().
std::string TePDIPIManager::message_ [protected] |
The progress interface message (label).
Definition at line 135 of file TePDIPIManager.hpp.
Referenced by Reset(), TePDIPIManager(), and Toggle().
TeProgressBase* TePDIPIManager::prog_intef_ptr_ [protected] |
A pointer to the active progress instance.
Definition at line 130 of file TePDIPIManager.hpp.
Referenced by TePDIPIManager(), Toggle(), Update(), and updateProgressInterface().
unsigned long int TePDIPIManager::total_steps_ [protected] |
The total steps number.
Definition at line 114 of file TePDIPIManager.hpp.
Referenced by Reset(), TePDIPIManager(), TePDIPIManagerGlobalSettings::TePDIPIManagerGlobalSettings(), Toggle(), and Update().
1.5.3