![]() |
KiCad PCB EDA Suite
|
A progress reporter for use in multi-threaded environments. More...
#include <progress_reporter.h>
Public Member Functions | |
PROGRESS_REPORTER (int aNumPhases) | |
PROGRESS_REPORTER (const PROGRESS_REPORTER &)=delete | |
virtual | ~PROGRESS_REPORTER () |
void | SetNumPhases (int aNumPhases) |
sets the number of phases More... | |
void | AddPhases (int aNumPhases) |
virtual void | BeginPhase (int aPhase) |
initialize the aPhase virtual zone of the dialog progress bar More... | |
virtual void | AdvancePhase () |
Uses the next vailable virtual zone of the dialog progress bar. More... | |
virtual void | AdvancePhase (const wxString &aMessage) |
Uses the next vailable virtual zone of the dialog progress bar and updates the message. More... | |
virtual void | Report (const wxString &aMessage) |
Display aMessage in the progress bar dialog. More... | |
virtual void | SetCurrentProgress (double aProgress) |
Set the progress value to aProgress (0..1) More... | |
void | SetMaxProgress (int aMaxProgress) |
Fix the value thar gives the 100 precent progress bar length (inside the current virtual zone) More... | |
void | AdvanceProgress () |
Increment the progress bar length (inside the current virtual zone) More... | |
bool | KeepRefreshing (bool aWait=false) |
Update the UI dialog. More... | |
virtual void | SetTitle (const wxString &aTitle) |
change the title displayed on the window caption MUST only be called from the main thread. More... | |
bool | IsCancelled () const |
Protected Member Functions | |
int | currentProgress () const |
virtual bool | updateUI ()=0 |
Protected Attributes | |
wxString | m_rptMessage |
std::mutex | m_mutex |
std::atomic_int | m_phase |
std::atomic_int | m_numPhases |
std::atomic_int | m_progress |
std::atomic_int | m_maxProgress |
std::atomic_bool | m_cancelled |
A progress reporter for use in multi-threaded environments.
The various advancement and message methods can be called from sub-threads. The KeepRefreshing method MUST be called only from the main thread (primarily a MSW requirement, which won't allow access to UI objects allocated from a separate thread).
Definition at line 43 of file progress_reporter.h.
PROGRESS_REPORTER::PROGRESS_REPORTER | ( | int | aNumPhases | ) |
Definition at line 29 of file progress_reporter.cpp.
|
delete |
|
inlinevirtual |
Definition at line 50 of file progress_reporter.h.
void PROGRESS_REPORTER::AddPhases | ( | int | aNumPhases | ) |
|
virtual |
Uses the next vailable virtual zone of the dialog progress bar.
Definition at line 46 of file progress_reporter.cpp.
References m_phase, and m_progress.
Referenced by DIALOG_ERC::AdvancePhase(), AdvancePhase(), DIALOG_DRC::AdvancePhase(), ZONE_FILLER::Fill(), FOOTPRINT_LIST_IMPL::ReadFootprintFiles(), DRC_ENGINE::ReportPhase(), DRC_TOOL::RunTests(), DIALOG_ERC::testErc(), and SYMBOL_ASYNC_LOADER::worker().
|
virtual |
Uses the next vailable virtual zone of the dialog progress bar and updates the message.
Reimplemented in DIALOG_DRC, and DIALOG_ERC.
Definition at line 53 of file progress_reporter.cpp.
References AdvancePhase(), and Report().
void PROGRESS_REPORTER::AdvanceProgress | ( | ) |
Increment the progress bar length (inside the current virtual zone)
Definition at line 79 of file progress_reporter.cpp.
References m_progress.
Referenced by AR_AUTOPLACER::AutoplaceFootprints(), ZONE_FILLER::Fill(), FOOTPRINT_LIST_IMPL::joinWorkers(), and FOOTPRINT_LIST_IMPL::loader_job().
|
virtual |
initialize the aPhase virtual zone of the dialog progress bar
Definition at line 39 of file progress_reporter.cpp.
References m_phase, and m_progress.
|
protected |
Definition at line 97 of file progress_reporter.cpp.
References m_maxProgress, m_numPhases, m_phase, and m_progress.
Referenced by WX_PROGRESS_REPORTER::updateUI(), and GAUGE_PROGRESS_REPORTER::updateUI().
|
inline |
Definition at line 110 of file progress_reporter.h.
References m_cancelled.
Referenced by ZONE_FILLER::computeRawFilledArea(), ZONE_FILLER::Fill(), ZONE_FILLER::fillSingleZone(), SYMBOL_LIBRARY_MANAGER::Preload(), and CN_CONNECTIVITY_ALGO::SearchClusters().
bool PROGRESS_REPORTER::KeepRefreshing | ( | bool | aWait = false | ) |
Update the UI dialog.
MUST only be called from the main thread. Returns false if the user clicked Cancel.
Definition at line 106 of file progress_reporter.cpp.
References m_cancelled, m_maxProgress, m_progress, and updateUI().
Referenced by AR_AUTOPLACER::AutoplaceFootprints(), ZONE_FILLER::Fill(), FOOTPRINT_LIST_IMPL::joinWorkers(), SYMBOL_LIBRARY_MANAGER::Preload(), FOOTPRINT_LIST_IMPL::ReadFootprintFiles(), DRC_ENGINE::ReportPhase(), DRC_ENGINE::ReportProgress(), reportProgress(), and CN_CONNECTIVITY_ALGO::searchConnections().
|
virtual |
Display aMessage in the progress bar dialog.
Reimplemented in DIALOG_ERC.
Definition at line 60 of file progress_reporter.cpp.
References m_mutex, and m_rptMessage.
Referenced by AdvancePhase(), AR_AUTOPLACER::AutoplaceFootprints(), ZONE_FILLER::Fill(), and FOOTPRINT_LIST_IMPL::ReadFootprintFiles().
|
virtual |
Set the progress value to aProgress (0..1)
Reimplemented in CONSOLE_PROGRESS_REPORTER.
Definition at line 72 of file progress_reporter.cpp.
References m_maxProgress, and m_progress.
Referenced by DIALOG_ERC::AdvancePhase(), DIALOG_DRC::AdvancePhase(), DRC_ENGINE::ReportProgress(), reportProgress(), and CONSOLE_PROGRESS_REPORTER::SetCurrentProgress().
void PROGRESS_REPORTER::SetMaxProgress | ( | int | aMaxProgress | ) |
Fix the value thar gives the 100 precent progress bar length (inside the current virtual zone)
Definition at line 67 of file progress_reporter.cpp.
References m_maxProgress.
Referenced by AR_AUTOPLACER::AutoplaceFootprints(), ZONE_FILLER::Fill(), FOOTPRINT_LIST_IMPL::ReadFootprintFiles(), and CN_CONNECTIVITY_ALGO::searchConnections().
void PROGRESS_REPORTER::SetNumPhases | ( | int | aNumPhases | ) |
sets the number of phases
Definition at line 85 of file progress_reporter.cpp.
References m_numPhases.
|
inlinevirtual |
change the title displayed on the window caption MUST only be called from the main thread.
Has meaning only for some reporters. Do nothing for others
Reimplemented in WX_PROGRESS_REPORTER.
Definition at line 108 of file progress_reporter.h.
Referenced by AR_AUTOPLACER::AutoplaceFootprints().
|
protectedpure virtual |
Implemented in GAUGE_PROGRESS_REPORTER, WX_PROGRESS_REPORTER, CONSOLE_PROGRESS_REPORTER, DIALOG_DRC, and DIALOG_ERC.
Referenced by KeepRefreshing().
|
protected |
Definition at line 124 of file progress_reporter.h.
Referenced by IsCancelled(), KeepRefreshing(), DIALOG_ERC::OnCancelClick(), DIALOG_ERC::OnRunERCClick(), and DIALOG_ERC::updateUI().
|
protected |
Definition at line 123 of file progress_reporter.h.
Referenced by currentProgress(), KeepRefreshing(), SetCurrentProgress(), SetMaxProgress(), DIALOG_DRC::updateUI(), and CONSOLE_PROGRESS_REPORTER::updateUI().
|
mutableprotected |
Definition at line 119 of file progress_reporter.h.
Referenced by Report(), and WX_PROGRESS_REPORTER::updateUI().
|
protected |
Definition at line 121 of file progress_reporter.h.
Referenced by AddPhases(), currentProgress(), and SetNumPhases().
|
protected |
Definition at line 120 of file progress_reporter.h.
Referenced by AdvancePhase(), BeginPhase(), and currentProgress().
|
protected |
Definition at line 122 of file progress_reporter.h.
Referenced by AdvancePhase(), AdvanceProgress(), BeginPhase(), currentProgress(), KeepRefreshing(), SetCurrentProgress(), DIALOG_DRC::updateUI(), and CONSOLE_PROGRESS_REPORTER::updateUI().
|
protected |
Definition at line 118 of file progress_reporter.h.
Referenced by Report(), CONSOLE_PROGRESS_REPORTER::updateUI(), and WX_PROGRESS_REPORTER::updateUI().