KiCad PCB EDA Suite
STATUS_TEXT_REPORTER Class Reference
Inheritance diagram for STATUS_TEXT_REPORTER:
PROGRESS_REPORTER_BASE PROGRESS_REPORTER

Public Member Functions

 STATUS_TEXT_REPORTER (std::function< void(const wxString)> aStatusCallback)
 
void SetTitle (const wxString &aTitle) override
 Change the title displayed on the window caption. More...
 
void Report (const wxString &aMessage) override
 Display aMessage in the progress bar dialog. More...
 
void Cancel ()
 
void SetNumPhases (int aNumPhases) override
 Set the number of phases. More...
 
void AddPhases (int aNumPhases) override
 
virtual void BeginPhase (int aPhase) override
 Initialize the aPhase virtual zone of the dialog progress bar. More...
 
virtual void AdvancePhase () override
 Use the next available virtual zone of the dialog progress bar. More...
 
virtual void AdvancePhase (const wxString &aMessage) override
 Use the next available virtual zone of the dialog progress bar and updates the message. More...
 
virtual void SetCurrentProgress (double aProgress) override
 Set the progress value to aProgress (0..1). More...
 
void SetMaxProgress (int aMaxProgress) override
 Fix the value that gives the 100 percent progress bar length (inside the current virtual zone). More...
 
void AdvanceProgress () override
 Increment the progress bar length (inside the current virtual zone). More...
 
bool KeepRefreshing (bool aWait=false) override
 Update the UI dialog. More...
 
bool IsCancelled () const override
 

Protected Member Functions

int currentProgress () const
 

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
 
std::atomic_bool m_messageChanged
 

Private Member Functions

bool updateUI () override
 

Private Attributes

const std::function< void(const wxString)> m_statusCallback
 
wxString m_title
 
wxString m_report
 

Detailed Description

Definition at line 62 of file pcm.cpp.

Constructor & Destructor Documentation

◆ STATUS_TEXT_REPORTER()

STATUS_TEXT_REPORTER::STATUS_TEXT_REPORTER ( std::function< void(const wxString)>  aStatusCallback)
inline

Definition at line 65 of file pcm.cpp.

65 :
66 PROGRESS_REPORTER_BASE( 1 ), m_statusCallback( aStatusCallback )
67 {
68 }
PROGRESS_REPORTER_BASE(int aNumPhases)
const std::function< void(const wxString)> m_statusCallback
Definition: pcm.cpp:90

Member Function Documentation

◆ AddPhases()

void PROGRESS_REPORTER_BASE::AddPhases ( int  aNumPhases)
overridevirtualinherited

Implements PROGRESS_REPORTER.

Definition at line 98 of file progress_reporter_base.cpp.

99{
100 m_numPhases += aNumPhases;
101}

References PROGRESS_REPORTER_BASE::m_numPhases.

◆ AdvancePhase() [1/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( )
overridevirtualinherited

Use the next available virtual zone of the dialog progress bar.

Implements PROGRESS_REPORTER.

Reimplemented in DIALOG_PCM_PROGRESS.

Definition at line 50 of file progress_reporter_base.cpp.

51{
52 m_phase.fetch_add( 1 );
53 m_progress.store( 0 );
54}

References PROGRESS_REPORTER_BASE::m_phase, and PROGRESS_REPORTER_BASE::m_progress.

Referenced by DIALOG_PCM_PROGRESS::AdvancePhase(), DIALOG_ERC::AdvancePhase(), PROGRESS_REPORTER_BASE::AdvancePhase(), DIALOG_DRC::AdvancePhase(), and DIALOG_ERC::testErc().

◆ AdvancePhase() [2/2]

void PROGRESS_REPORTER_BASE::AdvancePhase ( const wxString &  aMessage)
overridevirtualinherited

Use the next available virtual zone of the dialog progress bar and updates the message.

Implements PROGRESS_REPORTER.

Reimplemented in DIALOG_ERC, and DIALOG_DRC.

Definition at line 57 of file progress_reporter_base.cpp.

58{
60 Report( aMessage );
61}
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
virtual void Report(const wxString &aMessage) override
Display aMessage in the progress bar dialog.

References PROGRESS_REPORTER_BASE::AdvancePhase(), and PROGRESS_REPORTER_BASE::Report().

◆ AdvanceProgress()

void PROGRESS_REPORTER_BASE::AdvanceProgress ( )
overridevirtualinherited

Increment the progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 86 of file progress_reporter_base.cpp.

87{
88 m_progress.fetch_add( 1 );
89}

References PROGRESS_REPORTER_BASE::m_progress.

◆ BeginPhase()

void PROGRESS_REPORTER_BASE::BeginPhase ( int  aPhase)
overridevirtualinherited

Initialize the aPhase virtual zone of the dialog progress bar.

Implements PROGRESS_REPORTER.

Definition at line 43 of file progress_reporter_base.cpp.

44{
45 m_phase.store( aPhase );
46 m_progress.store( 0 );
47}

References PROGRESS_REPORTER_BASE::m_phase, and PROGRESS_REPORTER_BASE::m_progress.

◆ Cancel()

void STATUS_TEXT_REPORTER::Cancel ( )
inline

Definition at line 81 of file pcm.cpp.

81{ m_cancelled.store( true ); }

References PROGRESS_REPORTER_BASE::m_cancelled.

◆ currentProgress()

int PROGRESS_REPORTER_BASE::currentProgress ( ) const
protectedinherited

Definition at line 104 of file progress_reporter_base.cpp.

105{
106 double current = ( 1.0 / (double) m_numPhases ) *
107 ( (double) m_phase + ( (double) m_progress.load() / (double) m_maxProgress ) );
108
109 return (int)( current * 1000 );
110}

References PROGRESS_REPORTER_BASE::m_maxProgress, PROGRESS_REPORTER_BASE::m_numPhases, PROGRESS_REPORTER_BASE::m_phase, and PROGRESS_REPORTER_BASE::m_progress.

Referenced by WX_PROGRESS_REPORTER::updateUI(), and GAUGE_PROGRESS_REPORTER::updateUI().

◆ IsCancelled()

bool PROGRESS_REPORTER_BASE::IsCancelled ( ) const
inlineoverridevirtualinherited

Implements PROGRESS_REPORTER.

Definition at line 108 of file progress_reporter_base.h.

108{ return m_cancelled; }

References PROGRESS_REPORTER_BASE::m_cancelled.

Referenced by SYMBOL_EDIT_FRAME::SYMBOL_EDIT_FRAME().

◆ KeepRefreshing()

bool PROGRESS_REPORTER_BASE::KeepRefreshing ( bool  aWait = false)
overridevirtualinherited

Update the UI dialog.

Warning
This should only be called from the main thread.
Returns
false if the user clicked Cancel.

Implements PROGRESS_REPORTER.

Definition at line 113 of file progress_reporter_base.cpp.

114{
115 if( aWait )
116 {
117 while( m_progress.load() < m_maxProgress && m_maxProgress > 0 )
118 {
119 if( !updateUI() )
120 {
121 m_cancelled.store( true );
122 return false;
123 }
124
125 wxMilliSleep( 33 /* 30 FPS refresh rate */ );
126 }
127
128 return true;
129 }
130 else
131 {
132 if( !updateUI() )
133 {
134 m_cancelled.store( true );
135 return false;
136 }
137
138 return true;
139 }
140}
virtual bool updateUI()=0

References PROGRESS_REPORTER_BASE::m_cancelled, PROGRESS_REPORTER_BASE::m_maxProgress, PROGRESS_REPORTER_BASE::m_progress, and PROGRESS_REPORTER_BASE::updateUI().

◆ Report()

void STATUS_TEXT_REPORTER::Report ( const wxString &  aMessage)
inlineoverridevirtual

Display aMessage in the progress bar dialog.

Reimplemented from PROGRESS_REPORTER_BASE.

Definition at line 76 of file pcm.cpp.

77 {
78 m_report = wxString::Format( wxT( ": %s" ), aMessage );
79 }
wxString m_report
Definition: pcm.cpp:93
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), and m_report.

◆ SetCurrentProgress()

void PROGRESS_REPORTER_BASE::SetCurrentProgress ( double  aProgress)
overridevirtualinherited

Set the progress value to aProgress (0..1).

Implements PROGRESS_REPORTER.

Reimplemented in CONSOLE_PROGRESS_REPORTER, and CONSOLE_PROGRESS_REPORTER.

Definition at line 79 of file progress_reporter_base.cpp.

80{
81 m_maxProgress.store( 1000 );
82 m_progress.store( (int) ( aProgress * 1000.0 ) );
83}

References PROGRESS_REPORTER_BASE::m_maxProgress, and PROGRESS_REPORTER_BASE::m_progress.

Referenced by DIALOG_ERC::AdvancePhase(), DIALOG_DRC::AdvancePhase(), and CONSOLE_PROGRESS_REPORTER::SetCurrentProgress().

◆ SetMaxProgress()

void PROGRESS_REPORTER_BASE::SetMaxProgress ( int  aMaxProgress)
overridevirtualinherited

Fix the value that gives the 100 percent progress bar length (inside the current virtual zone).

Implements PROGRESS_REPORTER.

Definition at line 73 of file progress_reporter_base.cpp.

74{
75 m_maxProgress.store( aMaxProgress );
76}

References PROGRESS_REPORTER_BASE::m_maxProgress.

◆ SetNumPhases()

void PROGRESS_REPORTER_BASE::SetNumPhases ( int  aNumPhases)
overridevirtualinherited

Set the number of phases.

Implements PROGRESS_REPORTER.

Definition at line 92 of file progress_reporter_base.cpp.

93{
94 m_numPhases = aNumPhases;
95}

References PROGRESS_REPORTER_BASE::m_numPhases.

Referenced by DIALOG_PCM_PROGRESS::OnCancelClicked().

◆ SetTitle()

void STATUS_TEXT_REPORTER::SetTitle ( const wxString &  aTitle)
inlineoverridevirtual

Change the title displayed on the window caption.

Has meaning only for some reporters. Does nothing for others.

Warning
This should only be called from the main thread.

Reimplemented from PROGRESS_REPORTER_BASE.

Definition at line 70 of file pcm.cpp.

71 {
72 m_title = aTitle;
73 m_report = wxT( "" );
74 }
wxString m_title
Definition: pcm.cpp:92

References m_report, and m_title.

◆ updateUI()

bool STATUS_TEXT_REPORTER::updateUI ( )
inlineoverrideprivatevirtual

Implements PROGRESS_REPORTER_BASE.

Definition at line 84 of file pcm.cpp.

85 {
87 return true;
88 }

References Format(), m_report, m_statusCallback, and m_title.

Member Data Documentation

◆ m_cancelled

◆ m_maxProgress

◆ m_messageChanged

std::atomic_bool PROGRESS_REPORTER_BASE::m_messageChanged
protectedinherited

◆ m_mutex

std::mutex PROGRESS_REPORTER_BASE::m_mutex
mutableprotectedinherited

◆ m_numPhases

std::atomic_int PROGRESS_REPORTER_BASE::m_numPhases
protectedinherited

◆ m_phase

std::atomic_int PROGRESS_REPORTER_BASE::m_phase
protectedinherited

◆ m_progress

◆ m_report

wxString STATUS_TEXT_REPORTER::m_report
private

Definition at line 93 of file pcm.cpp.

Referenced by Report(), SetTitle(), and updateUI().

◆ m_rptMessage

wxString PROGRESS_REPORTER_BASE::m_rptMessage
protectedinherited

◆ m_statusCallback

const std::function<void( const wxString )> STATUS_TEXT_REPORTER::m_statusCallback
private

Definition at line 90 of file pcm.cpp.

Referenced by updateUI().

◆ m_title

wxString STATUS_TEXT_REPORTER::m_title
private

Definition at line 92 of file pcm.cpp.

Referenced by SetTitle(), and updateUI().


The documentation for this class was generated from the following file: