KiCad PCB EDA Suite
LIN_SCALE< parent > Class Template Reference
Inheritance diagram for LIN_SCALE< parent >:

Public Member Functions

 LIN_SCALE (wxString name, wxString unit, int flags)
 
void formatLabels () override
 

Private Attributes

const wxString m_unit
 

Detailed Description

template<typename parent>
class LIN_SCALE< parent >

Definition at line 133 of file sim_plot_panel.cpp.

Constructor & Destructor Documentation

◆ LIN_SCALE()

template<typename parent >
LIN_SCALE< parent >::LIN_SCALE ( wxString  name,
wxString  unit,
int  flags 
)
inline

Definition at line 136 of file sim_plot_panel.cpp.

136: parent( name, flags ), m_unit( unit ){};
const char * name
Definition: DXF_plotter.cpp:56
const wxString m_unit

Member Function Documentation

◆ formatLabels()

template<typename parent >
void LIN_SCALE< parent >::formatLabels ( )
inlineoverride

Definition at line 138 of file sim_plot_panel.cpp.

139 {
140 double maxVis = parent::AbsVisibleMaxValue();
141
142 wxString suffix;
143 int power, digits = 0;
144 int constexpr DIGITS = 3;
145
146 getSISuffix( maxVis, m_unit, power, suffix );
147
148 double sf = pow( 10.0, power );
149
150 for( auto& l : parent::TickLabels() )
151 {
152 int k = countDecimalDigits( l.pos / sf, DIGITS );
153
154 digits = std::max( digits, k );
155 }
156
157 for( auto& l : parent::TickLabels() )
158 {
159 l.label = formatFloat( l.pos / sf, digits ) + suffix;
160 l.visible = true;
161 }
162 }
static void getSISuffix(double x, const wxString &unit, int &power, wxString &suffix)
static int countDecimalDigits(double x, int maxDigits)
static wxString formatFloat(double x, int nDigits)

References countDecimalDigits(), formatFloat(), getSISuffix(), and LIN_SCALE< parent >::m_unit.

Member Data Documentation

◆ m_unit

template<typename parent >
const wxString LIN_SCALE< parent >::m_unit
private

Definition at line 165 of file sim_plot_panel.cpp.

Referenced by LIN_SCALE< parent >::formatLabels().


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