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 392 of file eserie.cpp.

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

References _, std::abs(), 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 500 of file eserie.cpp.

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

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: