KiCad PCB EDA Suite
PANEL_E_SERIES Class Reference

#include <panel_eseries.h>

Inheritance diagram for PANEL_E_SERIES:
PANEL_E_SERIES_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_E_SERIES (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_E_SERIES ()
 
void LoadSettings (PCB_CALCULATOR_SETTINGS *aCfg) override
 Load the settings into the panel. More...
 
void SaveSettings (PCB_CALCULATOR_SETTINGS *aCfg) override
 Save the settings from the panel. More...
 
void ThemeChanged () override
 Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appropriate for the new theme. More...
 
void OnCalculateESeries (wxCommandEvent &event) override
 Called on calculate button and executes all E-series calculations. More...
 
void OnESeriesSelection (wxCommandEvent &event) override
 Radio Buttons to select the E-series for the resistor calculator. More...
 

Protected Attributes

wxStaticText * m_ESrequired
 
wxTextCtrl * m_ResRequired
 
wxStaticText * m_reqResUnits
 
wxStaticText * m_ESrequired1
 
wxTextCtrl * m_ResExclude1
 
wxStaticText * m_exclude1Units
 
wxStaticText * m_ESrequired11
 
wxTextCtrl * m_ResExclude2
 
wxStaticText * m_exclude2Units
 
wxStaticLine * m_staticline6
 
wxRadioButton * m_e1
 
wxRadioButton * m_e3
 
wxRadioButton * m_e6
 
wxRadioButton * m_e12
 
wxRadioButton * m_e24
 
wxStaticText * m_ESeriesSimpleSolution
 
wxTextCtrl * m_ESeries_Sol2R
 
wxStaticText * m_ESeriesSimpleErr
 
wxTextCtrl * m_ESeriesError2R
 
wxStaticText * m_ESeriesSimplePercent
 
wxStaticText * m_ESeries3RSolution1
 
wxTextCtrl * m_ESeries_Sol3R
 
wxStaticText * m_ESeriesAltErr
 
wxTextCtrl * m_ESeriesError3R
 
wxStaticText * m_ESeriesAltPercent
 
wxStaticText * m_ESeries4RSolution
 
wxTextCtrl * m_ESeries_Sol4R
 
wxStaticText * m_ESeriesAltErr1
 
wxTextCtrl * m_ESeriesError4R
 
wxStaticText * m_ESeriesAltPercent1
 
wxStaticLine * m_staticline7
 
wxButton * m_buttonEScalculate
 
HTML_WINDOWm_panelESeriesHelp
 

Private Attributes

E_SERIES m_eSeries
 

Detailed Description

Definition at line 29 of file panel_eseries.h.

Constructor & Destructor Documentation

◆ PANEL_E_SERIES()

PANEL_E_SERIES::PANEL_E_SERIES ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxTAB_TRAVERSAL,
const wxString &  name = wxEmptyString 
)

Definition at line 39 of file panel_eseries.cpp.

40 :
41 PANEL_E_SERIES_BASE( parent, id, pos, size, style, name )
42{
43 m_reqResUnits->SetLabel( wxT( "kΩ" ) );
44 m_exclude1Units->SetLabel( wxT( "kΩ" ) );
45 m_exclude2Units->SetLabel( wxT( "kΩ" ) );
46
47 wxSize minSize = m_ResRequired->GetMinSize();
48 int minWidth = m_ResRequired->GetTextExtent( wxT( "XXX.XXX" ) ).GetWidth();
49
50 m_ResRequired->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
51 m_ResExclude1->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
52 m_ResExclude2->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
53
54 minSize = m_ESeriesError2R->GetMinSize();
55 minWidth = m_ESeriesError2R->GetTextExtent( wxT( "XX" ) + _( "Exact" ) ).GetWidth();
56
57 m_ESeriesError2R->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
58 m_ESeriesError3R->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
59 m_ESeriesError4R->SetMinSize( wxSize( minWidth, minSize.GetHeight() ) );
60
61 // show markdown formula explanation in lower help panel
62 wxString msg;
63 ConvertMarkdown2Html( wxGetTranslation( eseries_help ), msg );
65
66 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
67 GetSizer()->SetSizeHints( this );
68}
const char * name
Definition: DXF_plotter.cpp:56
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
wxTextCtrl * m_ESeriesError4R
wxTextCtrl * m_ESeriesError3R
HTML_WINDOW * m_panelESeriesHelp
PANEL_E_SERIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxTextCtrl * m_ResExclude1
wxTextCtrl * m_ResExclude2
wxStaticText * m_exclude2Units
wxStaticText * m_reqResUnits
wxStaticText * m_exclude1Units
wxTextCtrl * m_ResRequired
wxTextCtrl * m_ESeriesError2R
const int minSize
Push and Shove router track width and via size dialog.
#define _(s)
wxString eseries_help
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)

References _, ConvertMarkdown2Html(), eseries_help, PANEL_E_SERIES_BASE::m_ESeriesError2R, PANEL_E_SERIES_BASE::m_ESeriesError3R, PANEL_E_SERIES_BASE::m_ESeriesError4R, PANEL_E_SERIES_BASE::m_exclude1Units, PANEL_E_SERIES_BASE::m_exclude2Units, PANEL_E_SERIES_BASE::m_panelESeriesHelp, PANEL_E_SERIES_BASE::m_reqResUnits, PANEL_E_SERIES_BASE::m_ResExclude1, PANEL_E_SERIES_BASE::m_ResExclude2, PANEL_E_SERIES_BASE::m_ResRequired, minSize, and HTML_WINDOW::SetPage().

◆ ~PANEL_E_SERIES()

PANEL_E_SERIES::~PANEL_E_SERIES ( )

Definition at line 71 of file panel_eseries.cpp.

72{
73}

Member Function Documentation

◆ LoadSettings()

void PANEL_E_SERIES::LoadSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Load the settings into the panel.

Parameters
aCfgis the settings structure to load from

Implements CALCULATOR_PANEL.

Definition at line 88 of file panel_eseries.cpp.

89{
90}

◆ OnCalculateESeries()

void PANEL_E_SERIES::OnCalculateESeries ( wxCommandEvent &  event)
overridevirtual

Called on calculate button and executes all E-series calculations.

Reimplemented from PANEL_E_SERIES_BASE.

Definition at line 93 of file panel_eseries.cpp.

94{
95 double reqr; // required resistor stored in local copy
96 double error, err3 = 0;
97 wxString es, fs; // error and formula strings
98
99 wxBusyCursor dummy;
100
101 reqr = ( 1000 * DoubleFromString( m_ResRequired->GetValue() ) );
102 m_eSeries.SetRequiredValue( reqr ); // keep a local copy of required resistor value
103 m_eSeries.NewCalc(); // assume all values available
104 /*
105 * Exclude itself. For the case, a value from the available series is found as required value,
106 * the calculator assumes this value needs a replacement for the reason of being not available.
107 * Two further exclude values can be entered to exclude and are skipped as not being available.
108 * All values entered in KiloOhms are converted to Ohm for internal calculation
109 */
110 m_eSeries.Exclude( 1000 * DoubleFromString( m_ResRequired->GetValue()));
111 m_eSeries.Exclude( 1000 * DoubleFromString( m_ResExclude1->GetValue()));
112 m_eSeries.Exclude( 1000 * DoubleFromString( m_ResExclude2->GetValue()));
113
114 try
115 {
117 }
118 catch (std::out_of_range const& exc)
119 {
120 wxString msg;
121 msg << "Internal error: " << exc.what();
122
123 wxMessageBox( msg );
124 return;
125 }
126
127 fs = m_eSeries.GetResults()[S2R].e_name; // show 2R solution formula string
128 m_ESeries_Sol2R->SetValue( fs );
129 error = reqr + m_eSeries.GetResults()[S2R].e_value; // absolute value of solution
130 error = ( reqr / error - 1 ) * 100; // error in percent
131
132 if( error )
133 {
134 if( std::abs( error ) < 0.01 )
135 es.Printf( "<%.2f", 0.01 );
136 else
137 es.Printf( "%+.2f",error);
138 }
139 else
140 {
141 es = _( "Exact" );
142 }
143
144 m_ESeriesError2R->SetValue( es ); // anyway show 2R error string
145
146 if( m_eSeries.GetResults()[S3R].e_use ) // if 3R solution available
147 {
148 err3 = reqr + m_eSeries.GetResults()[S3R].e_value; // calculate the 3R
149 err3 = ( reqr / err3 - 1 ) * 100; // error in percent
150
151 if( err3 )
152 {
153 if( std::abs( err3 ) < 0.01 )
154 es.Printf( "<%.2f", 0.01 );
155 else
156 es.Printf( "%+.2f",err3);
157 }
158 else
159 {
160 es = _( "Exact" );
161 }
162
163 m_ESeriesError3R->SetValue( es ); // show 3R error string
164 fs = m_eSeries.GetResults()[S3R].e_name;
165 m_ESeries_Sol3R->SetValue( fs ); // show 3R formula string
166 }
167 else // nothing better than 2R found
168 {
169 fs = _( "Not worth using" );
170 m_ESeries_Sol3R->SetValue( fs );
171 m_ESeriesError3R->SetValue( wxEmptyString );
172 }
173
174 fs = wxEmptyString;
175
176 if( m_eSeries.GetResults()[S4R].e_use ) // show 4R solution if available
177 {
178 fs = m_eSeries.GetResults()[S4R].e_name;
179
180 error = reqr + m_eSeries.GetResults()[S4R].e_value; // absolute value of solution
181 error = ( reqr / error - 1 ) * 100; // error in percent
182
183 if( error )
184 es.Printf( "%+.2f",error );
185 else
186 es = _( "Exact" );
187
188 m_ESeriesError4R->SetValue( es );
189 }
190 else // no 4R solution
191 {
192 fs = _( "Not worth using" );
193 es = wxEmptyString;
194 m_ESeriesError4R->SetValue( es );
195 }
196
197 m_ESeries_Sol4R->SetValue( fs );
198}
void Exclude(double aValue)
If any value of the selected E-series not available, it can be entered as an exclude value.
Definition: eseries.cpp:145
void Calculate()
called on calculate button to execute all the 2R, 3R and 4R calculations
Definition: eseries.cpp:333
void NewCalc()
initialize next calculation and erase results from previous calculation
Definition: eseries.cpp:232
void SetRequiredValue(double aValue)
Definition: eseries.h:116
const std::array< R_DATA, S4R+1 > & GetResults()
Definition: eseries.h:119
wxTextCtrl * m_ESeries_Sol2R
wxTextCtrl * m_ESeries_Sol3R
wxTextCtrl * m_ESeries_Sol4R
E_SERIES m_eSeries
Definition: panel_eseries.h:55
@ S3R
Definition: eseries.h:67
@ S2R
Definition: eseries.h:67
@ S4R
Definition: eseries.h:67
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:418
double DoubleFromString(const wxString &TextValue)
std::vector< FAB_LAYER_COLOR > dummy

References _, std::abs(), E_SERIES::Calculate(), DoubleFromString(), dummy, E_SERIES::Exclude(), E_SERIES::GetResults(), m_eSeries, PANEL_E_SERIES_BASE::m_ESeries_Sol2R, PANEL_E_SERIES_BASE::m_ESeries_Sol3R, PANEL_E_SERIES_BASE::m_ESeries_Sol4R, PANEL_E_SERIES_BASE::m_ESeriesError2R, PANEL_E_SERIES_BASE::m_ESeriesError3R, PANEL_E_SERIES_BASE::m_ESeriesError4R, PANEL_E_SERIES_BASE::m_ResExclude1, PANEL_E_SERIES_BASE::m_ResExclude2, PANEL_E_SERIES_BASE::m_ResRequired, E_SERIES::NewCalc(), S2R, S3R, S4R, and E_SERIES::SetRequiredValue().

◆ OnESeriesSelection()

void PANEL_E_SERIES::OnESeriesSelection ( wxCommandEvent &  event)
overridevirtual

Radio Buttons to select the E-series for the resistor calculator.

Parameters
eventcontains the radio button state.

Reimplemented from PANEL_E_SERIES_BASE.

Definition at line 201 of file panel_eseries.cpp.

202{
203 if( event.GetEventObject() == m_e1 )
205 else if( event.GetEventObject() == m_e3 )
207 else if( event.GetEventObject() == m_e12 )
209 else if( event.GetEventObject() == m_e24 )
211 else
213}
void SetSeries(uint32_t aSeries)
Interface for CheckBox, RadioButton, RequriedResistor and calculated Results.
Definition: eseries.h:115
wxRadioButton * m_e12
wxRadioButton * m_e24
wxRadioButton * m_e1
wxRadioButton * m_e3
@ E6
Definition: eseries.h:62
@ E3
Definition: eseries.h:62
@ E24
Definition: eseries.h:62
@ E1
Definition: eseries.h:62
@ E12
Definition: eseries.h:62

References E1, E12, E24, E3, E6, PANEL_E_SERIES_BASE::m_e1, PANEL_E_SERIES_BASE::m_e12, PANEL_E_SERIES_BASE::m_e24, PANEL_E_SERIES_BASE::m_e3, m_eSeries, and E_SERIES::SetSeries().

◆ SaveSettings()

void PANEL_E_SERIES::SaveSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Save the settings from the panel.

Parameters
aCfgis the settings structure to save to

Implements CALCULATOR_PANEL.

Definition at line 83 of file panel_eseries.cpp.

84{
85}

◆ ThemeChanged()

void PANEL_E_SERIES::ThemeChanged ( )
overridevirtual

Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appropriate for the new theme.

Implements CALCULATOR_PANEL.

Definition at line 76 of file panel_eseries.cpp.

77{
78 // Update the HTML window with the help text
80}
void ThemeChanged()
Definition: html_window.cpp:63

References PANEL_E_SERIES_BASE::m_panelESeriesHelp, and HTML_WINDOW::ThemeChanged().

Member Data Documentation

◆ m_buttonEScalculate

wxButton* PANEL_E_SERIES_BASE::m_buttonEScalculate
protectedinherited

◆ m_e1

wxRadioButton* PANEL_E_SERIES_BASE::m_e1
protectedinherited

◆ m_e12

wxRadioButton* PANEL_E_SERIES_BASE::m_e12
protectedinherited

◆ m_e24

wxRadioButton* PANEL_E_SERIES_BASE::m_e24
protectedinherited

◆ m_e3

wxRadioButton* PANEL_E_SERIES_BASE::m_e3
protectedinherited

◆ m_e6

wxRadioButton* PANEL_E_SERIES_BASE::m_e6
protectedinherited

◆ m_eSeries

E_SERIES PANEL_E_SERIES::m_eSeries
private

Definition at line 55 of file panel_eseries.h.

Referenced by OnCalculateESeries(), and OnESeriesSelection().

◆ m_ESeries3RSolution1

wxStaticText* PANEL_E_SERIES_BASE::m_ESeries3RSolution1
protectedinherited

Definition at line 64 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeries4RSolution

wxStaticText* PANEL_E_SERIES_BASE::m_ESeries4RSolution
protectedinherited

Definition at line 69 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeries_Sol2R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeries_Sol2R
protectedinherited

◆ m_ESeries_Sol3R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeries_Sol3R
protectedinherited

◆ m_ESeries_Sol4R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeries_Sol4R
protectedinherited

◆ m_ESeriesAltErr

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesAltErr
protectedinherited

Definition at line 66 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesAltErr1

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesAltErr1
protectedinherited

Definition at line 71 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesAltPercent

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesAltPercent
protectedinherited

Definition at line 68 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesAltPercent1

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesAltPercent1
protectedinherited

Definition at line 73 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesError2R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeriesError2R
protectedinherited

◆ m_ESeriesError3R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeriesError3R
protectedinherited

◆ m_ESeriesError4R

wxTextCtrl* PANEL_E_SERIES_BASE::m_ESeriesError4R
protectedinherited

◆ m_ESeriesSimpleErr

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesSimpleErr
protectedinherited

Definition at line 61 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesSimplePercent

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesSimplePercent
protectedinherited

Definition at line 63 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESeriesSimpleSolution

wxStaticText* PANEL_E_SERIES_BASE::m_ESeriesSimpleSolution
protectedinherited

Definition at line 59 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESrequired

wxStaticText* PANEL_E_SERIES_BASE::m_ESrequired
protectedinherited

Definition at line 44 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESrequired1

wxStaticText* PANEL_E_SERIES_BASE::m_ESrequired1
protectedinherited

Definition at line 47 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_ESrequired11

wxStaticText* PANEL_E_SERIES_BASE::m_ESrequired11
protectedinherited

Definition at line 50 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_exclude1Units

wxStaticText* PANEL_E_SERIES_BASE::m_exclude1Units
protectedinherited

◆ m_exclude2Units

wxStaticText* PANEL_E_SERIES_BASE::m_exclude2Units
protectedinherited

◆ m_panelESeriesHelp

HTML_WINDOW* PANEL_E_SERIES_BASE::m_panelESeriesHelp
protectedinherited

◆ m_reqResUnits

wxStaticText* PANEL_E_SERIES_BASE::m_reqResUnits
protectedinherited

◆ m_ResExclude1

wxTextCtrl* PANEL_E_SERIES_BASE::m_ResExclude1
protectedinherited

◆ m_ResExclude2

wxTextCtrl* PANEL_E_SERIES_BASE::m_ResExclude2
protectedinherited

◆ m_ResRequired

wxTextCtrl* PANEL_E_SERIES_BASE::m_ResRequired
protectedinherited

◆ m_staticline6

wxStaticLine* PANEL_E_SERIES_BASE::m_staticline6
protectedinherited

Definition at line 53 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().

◆ m_staticline7

wxStaticLine* PANEL_E_SERIES_BASE::m_staticline7
protectedinherited

Definition at line 74 of file panel_eseries_base.h.

Referenced by PANEL_E_SERIES_BASE::PANEL_E_SERIES_BASE().


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