KiCad PCB EDA Suite
PANEL_E_SERIE Class Reference

#include <panel_eserie.h>

Inheritance diagram for PANEL_E_SERIE:
PANEL_E_SERIE_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_E_SERIE (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_E_SERIE ()
 
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-serie 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_ESerieSimpleSolution
 
wxTextCtrl * m_ESeries_Sol2R
 
wxStaticText * m_ESeriesSimpleErr
 
wxTextCtrl * m_ESeriesError2R
 
wxStaticText * m_ESeriesSimplePercent
 
wxStaticText * m_ESerie3RSolution1
 
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
 

Detailed Description

Definition at line 28 of file panel_eserie.h.

Constructor & Destructor Documentation

◆ PANEL_E_SERIE()

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

◆ ~PANEL_E_SERIE()

PANEL_E_SERIE::~PANEL_E_SERIE ( )

Member Function Documentation

◆ LoadSettings()

void PANEL_E_SERIE::LoadSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Load the settings into the panel.

Parameters
aCfgis the settings structure to load from

Implements CALCULATOR_PANEL.

◆ OnCalculateESeries()

void PANEL_E_SERIE::OnCalculateESeries ( wxCommandEvent &  event)
overridevirtual

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

Reimplemented from PANEL_E_SERIE_BASE.

Definition at line 393 of file eserie.cpp.

394 {
395  double reqr; // required resistor stored in local copy
396  double error, err3 = 0;
397  wxString es, fs; // error and formula strings
398 
399  wxBusyCursor dummy;
400 
401  reqr = ( 1000 * DoubleFromString( m_ResRequired->GetValue() ) );
402  r.SetRequiredValue( reqr ); // keep a local copy of required resistor value
403  r.NewCalc(); // assume all values available
404  /*
405  * Exclude itself. For the case, a value from the available series is found as required value,
406  * the calculator assumes this value needs a replacement for the reason of being not available.
407  * Two further exclude values can be entered to exclude and are skipped as not being available.
408  * All values entered in KiloOhms are converted to Ohm for internal calculation
409  */
410  r.Exclude( 1000 * DoubleFromString( m_ResRequired->GetValue()));
411  r.Exclude( 1000 * DoubleFromString( m_ResExclude1->GetValue()));
412  r.Exclude( 1000 * DoubleFromString( m_ResExclude2->GetValue()));
413 
414  try
415  {
416  r.Calculate();
417  }
418  catch (std::out_of_range const& exc)
419  {
420  wxString msg;
421  msg << "Internal error: " << exc.what();
422 
423  wxMessageBox( msg );
424  return;
425  }
426 
427  fs = r.GetResults()[S2R].e_name; // show 2R solution formula string
428  m_ESeries_Sol2R->SetValue( fs );
429  error = reqr + r.GetResults()[S2R].e_value; // absolute value of solution
430  error = ( reqr / error - 1 ) * 100; // error in percent
431 
432  if( error )
433  {
434  if( std::abs( error ) < 0.01 )
435  es.Printf( "<%.2f", 0.01 );
436  else
437  es.Printf( "%+.2f",error);
438  }
439  else
440  {
441  es = _( "Exact" );
442  }
443 
444  m_ESeriesError2R->SetValue( es ); // anyway show 2R error string
445 
446  if( r.GetResults()[S3R].e_use ) // if 3R solution available
447  {
448  err3 = reqr + r.GetResults()[S3R].e_value; // calculate the 3R
449  err3 = ( reqr / err3 - 1 ) * 100; // error in percent
450 
451  if( err3 )
452  {
453  if( std::abs( err3 ) < 0.01 )
454  es.Printf( "<%.2f", 0.01 );
455  else
456  es.Printf( "%+.2f",err3);
457  }
458  else
459  {
460  es = _( "Exact" );
461  }
462 
463  m_ESeriesError3R->SetValue( es ); // show 3R error string
464  fs = r.GetResults()[S3R].e_name;
465  m_ESeries_Sol3R->SetValue( fs ); // show 3R formula string
466  }
467  else // nothing better than 2R found
468  {
469  fs = _( "Not worth using" );
470  m_ESeries_Sol3R->SetValue( fs );
471  m_ESeriesError3R->SetValue( wxEmptyString );
472  }
473 
474  fs = wxEmptyString;
475 
476  if( r.GetResults()[S4R].e_use ) // show 4R solution if available
477  {
478  fs = r.GetResults()[S4R].e_name;
479 
480  error = reqr + r.GetResults()[S4R].e_value; // absolute value of solution
481  error = ( reqr / error - 1 ) * 100; // error in percent
482 
483  if( error )
484  es.Printf( "%+.2f",error );
485  else
486  es = _( "Exact" );
487 
488  m_ESeriesError4R->SetValue( es );
489  }
490  else // no 4R solution
491  {
492  fs = _( "Not worth using" );
493  es = wxEmptyString;
494  m_ESeriesError4R->SetValue( es );
495  }
496 
497  m_ESeries_Sol4R->SetValue( fs );
498 }
void NewCalc()
initialize next calculation and erase results from previous calculation
Definition: eserie.cpp:238
void SetRequiredValue(double aValue)
Definition: eserie.h:115
Definition: eserie.h:66
wxTextCtrl * m_ESeries_Sol2R
double DoubleFromString(const wxString &TextValue)
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:72
void Calculate()
called on calculate button to execute all the 2R, 3R and 4R calculations
Definition: eserie.cpp:338
const std::array< R_DATA, S4R+1 > & GetResults()
Definition: eserie.h:118
wxTextCtrl * m_ESeries_Sol4R
wxTextCtrl * m_ResExclude2
Definition: eserie.h:66
#define _(s)
void Exclude(double aValue)
If any value of the selected E-serie not available, it can be entered as an exclude value.
Definition: eserie.cpp:150
E_SERIE r
Definition: eserie.cpp:41
wxTextCtrl * m_ESeriesError2R
wxTextCtrl * m_ESeriesError3R
Definition: eserie.h:66
wxTextCtrl * m_ESeries_Sol3R
wxTextCtrl * m_ResExclude1
wxTextCtrl * m_ESeriesError4R
wxTextCtrl * m_ResRequired

References _, E_SERIE::Calculate(), DoubleFromString(), dummy(), E_SERIE::Exclude(), E_SERIE::GetResults(), PANEL_E_SERIE_BASE::m_ESeries_Sol2R, PANEL_E_SERIE_BASE::m_ESeries_Sol3R, PANEL_E_SERIE_BASE::m_ESeries_Sol4R, PANEL_E_SERIE_BASE::m_ESeriesError2R, PANEL_E_SERIE_BASE::m_ESeriesError3R, PANEL_E_SERIE_BASE::m_ESeriesError4R, PANEL_E_SERIE_BASE::m_ResExclude1, PANEL_E_SERIE_BASE::m_ResExclude2, PANEL_E_SERIE_BASE::m_ResRequired, E_SERIE::NewCalc(), r, S2R, S3R, S4R, and E_SERIE::SetRequiredValue().

◆ OnESeriesSelection()

void PANEL_E_SERIE::OnESeriesSelection ( wxCommandEvent &  event)
overridevirtual

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

Parameters
eventcontains the radio button state.

Reimplemented from PANEL_E_SERIE_BASE.

Definition at line 501 of file eserie.cpp.

502 {
503  if( event.GetEventObject() == m_e1 )
504  r.SetSeries( E1 );
505  else if( event.GetEventObject() == m_e3 )
506  r.SetSeries( E3 );
507  else if( event.GetEventObject() == m_e12 )
508  r.SetSeries( E12 );
509  else if( event.GetEventObject() == m_e24 )
510  r.SetSeries( E24 );
511  else
512  r.SetSeries( E6 );
513 }
Definition: eserie.h:61
wxRadioButton * m_e12
void SetSeries(uint32_t aSeries)
Interface for CheckBox, RadioButton, RequriedResistor and calculated Results.
Definition: eserie.h:114
Definition: eserie.h:61
wxRadioButton * m_e3
Definition: eserie.h:61
wxRadioButton * m_e1
E_SERIE r
Definition: eserie.cpp:41
Definition: eserie.h:61
Definition: eserie.h:61
wxRadioButton * m_e24

References E1, E12, E24, E3, E6, PANEL_E_SERIE_BASE::m_e1, PANEL_E_SERIE_BASE::m_e12, PANEL_E_SERIE_BASE::m_e24, PANEL_E_SERIE_BASE::m_e3, r, and E_SERIE::SetSeries().

◆ SaveSettings()

void PANEL_E_SERIE::SaveSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

Save the settings from the panel.

Parameters
aCfgis the settings structure to save to

Implements CALCULATOR_PANEL.

◆ ThemeChanged()

void PANEL_E_SERIE::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.

Member Data Documentation

◆ m_buttonEScalculate

wxButton* PANEL_E_SERIE_BASE::m_buttonEScalculate
protectedinherited

◆ m_e1

wxRadioButton* PANEL_E_SERIE_BASE::m_e1
protectedinherited

◆ m_e12

wxRadioButton* PANEL_E_SERIE_BASE::m_e12
protectedinherited

◆ m_e24

wxRadioButton* PANEL_E_SERIE_BASE::m_e24
protectedinherited

◆ m_e3

wxRadioButton* PANEL_E_SERIE_BASE::m_e3
protectedinherited

◆ m_e6

wxRadioButton* PANEL_E_SERIE_BASE::m_e6
protectedinherited

◆ m_ESerie3RSolution1

wxStaticText* PANEL_E_SERIE_BASE::m_ESerie3RSolution1
protectedinherited

Definition at line 64 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeries4RSolution

wxStaticText* PANEL_E_SERIE_BASE::m_ESeries4RSolution
protectedinherited

Definition at line 69 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeries_Sol2R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeries_Sol2R
protectedinherited

◆ m_ESeries_Sol3R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeries_Sol3R
protectedinherited

◆ m_ESeries_Sol4R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeries_Sol4R
protectedinherited

◆ m_ESeriesAltErr

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesAltErr
protectedinherited

Definition at line 66 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesAltErr1

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesAltErr1
protectedinherited

Definition at line 71 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesAltPercent

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesAltPercent
protectedinherited

Definition at line 68 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesAltPercent1

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesAltPercent1
protectedinherited

Definition at line 73 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesError2R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeriesError2R
protectedinherited

◆ m_ESeriesError3R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeriesError3R
protectedinherited

◆ m_ESeriesError4R

wxTextCtrl* PANEL_E_SERIE_BASE::m_ESeriesError4R
protectedinherited

◆ m_ESerieSimpleSolution

wxStaticText* PANEL_E_SERIE_BASE::m_ESerieSimpleSolution
protectedinherited

Definition at line 59 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesSimpleErr

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesSimpleErr
protectedinherited

Definition at line 61 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESeriesSimplePercent

wxStaticText* PANEL_E_SERIE_BASE::m_ESeriesSimplePercent
protectedinherited

Definition at line 63 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESrequired

wxStaticText* PANEL_E_SERIE_BASE::m_ESrequired
protectedinherited

Definition at line 44 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESrequired1

wxStaticText* PANEL_E_SERIE_BASE::m_ESrequired1
protectedinherited

Definition at line 47 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ESrequired11

wxStaticText* PANEL_E_SERIE_BASE::m_ESrequired11
protectedinherited

Definition at line 50 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_exclude1Units

wxStaticText* PANEL_E_SERIE_BASE::m_exclude1Units
protectedinherited

Definition at line 49 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_exclude2Units

wxStaticText* PANEL_E_SERIE_BASE::m_exclude2Units
protectedinherited

Definition at line 52 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_panelESeriesHelp

HTML_WINDOW* PANEL_E_SERIE_BASE::m_panelESeriesHelp
protectedinherited

Definition at line 76 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_reqResUnits

wxStaticText* PANEL_E_SERIE_BASE::m_reqResUnits
protectedinherited

Definition at line 46 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_ResExclude1

wxTextCtrl* PANEL_E_SERIE_BASE::m_ResExclude1
protectedinherited

◆ m_ResExclude2

wxTextCtrl* PANEL_E_SERIE_BASE::m_ResExclude2
protectedinherited

◆ m_ResRequired

wxTextCtrl* PANEL_E_SERIE_BASE::m_ResRequired
protectedinherited

◆ m_staticline6

wxStaticLine* PANEL_E_SERIE_BASE::m_staticline6
protectedinherited

Definition at line 53 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().

◆ m_staticline7

wxStaticLine* PANEL_E_SERIE_BASE::m_staticline7
protectedinherited

Definition at line 74 of file panel_eserie_base.h.

Referenced by PANEL_E_SERIE_BASE::PANEL_E_SERIE_BASE().


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