PLearn 0.1
|
Public Member Functions | |
PlideProgressPlugin (PythonCodeSnippet *python) | |
virtual | ~PlideProgressPlugin () |
Destructor releases all pending progress bars from GUI. | |
virtual void | addProgressBar (ProgressBar *pb) |
Try to allocate a GUI element for progress bar. | |
virtual void | killProgressBar (ProgressBar *pb) |
Release the allocated GUI element for progress bar. | |
virtual void | update (ProgressBar *pb, unsigned long newpos) |
Update GUI element if there's one associated with progress bar. | |
Protected Attributes | |
PythonCodeSnippet * | m_python |
Python environment for execution. | |
map< ProgressBar *, int > | m_progress_ids |
Map from the progress bar to a GUI id for transmitting the update. |
PLearn::PlideProgressPlugin::PlideProgressPlugin | ( | PythonCodeSnippet * | python | ) | [inline] |
PLearn::PlideProgressPlugin::~PlideProgressPlugin | ( | ) | [virtual] |
Destructor releases all pending progress bars from GUI.
Definition at line 98 of file Plide.cc.
References PLASSERT.
{ PLASSERT( m_python ); for (map<ProgressBar*, int>::const_iterator it = m_progress_ids.begin(), end = m_progress_ids.end() ; it != end ; ++it) { // Don't call killProgressBar since iterators might be invalidated m_python->invoke("ReleaseProgressBar", int(it->second)); } m_progress_ids.clear(); }
void PLearn::PlideProgressPlugin::addProgressBar | ( | ProgressBar * | pb | ) | [virtual] |
Try to allocate a GUI element for progress bar.
Reimplemented from PLearn::ProgressBarPlugin.
Definition at line 110 of file Plide.cc.
References PLASSERT, and PLearn::ProgressBar::title.
{ PLASSERT( pb && m_python ); if (m_progress_ids.find(pb) == m_progress_ids.end()) { m_progress_ids[pb] = m_python->invoke("AllocateProgressBar", pb->title).as<int>(); } }
void PLearn::PlideProgressPlugin::killProgressBar | ( | ProgressBar * | pb | ) | [virtual] |
Release the allocated GUI element for progress bar.
Reimplemented from PLearn::ProgressBarPlugin.
Definition at line 119 of file Plide.cc.
References PLASSERT.
{ PLASSERT( pb && m_python ); map<ProgressBar*, int>::iterator found = m_progress_ids.find(pb); if (found != m_progress_ids.end()) { m_python->invoke("ReleaseProgressBar", int(found->second)); m_progress_ids.erase(found); } }
void PLearn::PlideProgressPlugin::update | ( | ProgressBar * | pb, |
unsigned long | newpos | ||
) | [virtual] |
Update GUI element if there's one associated with progress bar.
Definition at line 129 of file Plide.cc.
References PLearn::ProgressBar::maxpos, and PLASSERT.
{ PLASSERT( pb && m_python ); map<ProgressBar*, int>::const_iterator found = m_progress_ids.find(pb); if (found != m_progress_ids.end()) { int progress_id = found->second; double fraction = double(newpos) / double(pb->maxpos); m_python->invoke("ProgressUpdate", progress_id, fraction); } }
map<ProgressBar*, int> PLearn::PlideProgressPlugin::m_progress_ids [protected] |
PythonCodeSnippet* PLearn::PlideProgressPlugin::m_python [protected] |