KiCad PCB EDA Suite
PANEL_WAVELENGTH Class Reference

#include <panel_wavelength.h>

Inheritance diagram for PANEL_WAVELENGTH:
PANEL_WAVELENGTH_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_WAVELENGTH (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_WAVELENGTH ()
 
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 OnFrequencyChange (wxCommandEvent &event) override
 
void OnPeriodChange (wxCommandEvent &event) override
 
void OnWavelengthVacuumChange (wxCommandEvent &event) override
 
void OnWavelengthMediumChange (wxCommandEvent &event) override
 
void OnPermittivityChange (wxCommandEvent &event) override
 
void OnPermeabilityChange (wxCommandEvent &event) override
 
void OnButtonPermittivity (wxCommandEvent &event) override
 

Protected Attributes

wxStaticText * m_staticText18
 
wxTextCtrl * m_frequencyCtrl
 
UNIT_SELECTOR_FREQUENCYm_frequencyUnit
 
wxStaticText * m_staticText181
 
wxTextCtrl * m_periodCtrl
 
UNIT_SELECTOR_TIMEm_periodUnit
 
wxStaticText * m_staticText1811
 
wxTextCtrl * m_wavelengthVacuumCtrl
 
UNIT_SELECTOR_LEN_CABLEm_wavelengthVacuumUnit
 
wxStaticText * m_staticText18111
 
wxTextCtrl * m_wavelengthMediumCtrl
 
UNIT_SELECTOR_LEN_CABLEm_wavelengthMediumUnit
 
wxStaticText * m_staticText181112
 
wxTextCtrl * m_speedCtrl
 
UNIT_SELECTOR_SPEEDm_speedUnit
 
wxStaticText * m_staticText181111
 
wxTextCtrl * m_permittivityCtrl
 
wxButton * m_button1
 
wxStaticText * m_staticText42
 
wxTextCtrl * m_permeabilityCtrl
 

Private Member Functions

void update (double aFrequency)
 
void updateUnits (wxCommandEvent &aEvent) override
 

Private Attributes

double m_permittivity = 1
 
double m_permeability = 1
 
double m_frequency = 1
 
bool m_updatingFrequency = false
 
bool m_updatingPeriod = false
 
bool m_updatingWavelengthVacuum = false
 
bool m_updatingWavelengthMedium = false
 
bool m_updatingSpeed = false
 
bool m_updatingUI = false
 

Detailed Description

Definition at line 27 of file panel_wavelength.h.

Constructor & Destructor Documentation

◆ PANEL_WAVELENGTH()

PANEL_WAVELENGTH::PANEL_WAVELENGTH ( 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 31 of file panel_wavelength.cpp.

32 :
33 PANEL_WAVELENGTH_BASE( parent, id, pos, size, style, name )
34{
35 // Set the min size of wxTextCtrls showing long values
36 wxString msg( wxT( "1.234567890E+99" ) );
37 wxClientDC dc( m_speedCtrl );
38 wxSize txt_size = dc.GetTextExtent( msg );
39 m_speedCtrl->SetMinSize( txt_size );
40 Layout();
41}
const char * name
Definition: DXF_plotter.cpp:56
PANEL_WAVELENGTH_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(538, 453), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)

References PANEL_WAVELENGTH_BASE::m_speedCtrl.

◆ ~PANEL_WAVELENGTH()

PANEL_WAVELENGTH::~PANEL_WAVELENGTH ( )
inline

Definition at line 33 of file panel_wavelength.h.

33{};

Member Function Documentation

◆ LoadSettings()

void PANEL_WAVELENGTH::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 57 of file panel_wavelength.cpp.

58{
59 m_frequencyUnit->SetSelection( aCfg->m_wavelength.frequencyUnit );
60 m_periodUnit->SetSelection( aCfg->m_wavelength.periodUnit );
63 m_speedUnit->SetSelection( aCfg->m_wavelength.speedUnit );
64
68
69 wxString value;
70 value = wxString( "" ) << m_permittivity;
71 m_permittivityCtrl->SetValue( value );
72 value = wxString( "" ) << m_permeability;
73 m_permeabilityCtrl->SetValue( value );
74
76}
UNIT_SELECTOR_FREQUENCY * m_frequencyUnit
UNIT_SELECTOR_TIME * m_periodUnit
UNIT_SELECTOR_LEN_CABLE * m_wavelengthVacuumUnit
UNIT_SELECTOR_LEN_CABLE * m_wavelengthMediumUnit
UNIT_SELECTOR_SPEED * m_speedUnit
void update(double aFrequency)

References PCB_CALCULATOR_SETTINGS::WAVELENGTH::frequency, PCB_CALCULATOR_SETTINGS::WAVELENGTH::frequencyUnit, m_frequency, PANEL_WAVELENGTH_BASE::m_frequencyUnit, PANEL_WAVELENGTH_BASE::m_periodUnit, m_permeability, PANEL_WAVELENGTH_BASE::m_permeabilityCtrl, m_permittivity, PANEL_WAVELENGTH_BASE::m_permittivityCtrl, PANEL_WAVELENGTH_BASE::m_speedUnit, PCB_CALCULATOR_SETTINGS::m_wavelength, PANEL_WAVELENGTH_BASE::m_wavelengthMediumUnit, PANEL_WAVELENGTH_BASE::m_wavelengthVacuumUnit, PCB_CALCULATOR_SETTINGS::WAVELENGTH::periodUnit, PCB_CALCULATOR_SETTINGS::WAVELENGTH::permeability, PCB_CALCULATOR_SETTINGS::WAVELENGTH::permittivity, PCB_CALCULATOR_SETTINGS::WAVELENGTH::speedUnit, update(), PCB_CALCULATOR_SETTINGS::WAVELENGTH::wavelengthMediumUnit, and PCB_CALCULATOR_SETTINGS::WAVELENGTH::wavelengthVacuumUnit.

◆ OnButtonPermittivity()

void PANEL_WAVELENGTH::OnButtonPermittivity ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 247 of file panel_wavelength.cpp.

248{
249 wxArrayString list = StandardRelativeDielectricConstantList();
250 list.Add( "" ); // Add an empty line for no selection
251
252 // Find the previous choice index:
253 wxString prevChoiceStr = m_permittivityCtrl->GetValue();
254 int prevChoice = 0;
255 findMatch( list, prevChoiceStr, prevChoice );
256
257 int index = wxGetSingleChoiceIndex( wxEmptyString, _( "Relative Dielectric Constants" ), list,
258 prevChoice );
259
260 if( index >= 0 && !list.Item( index ).IsEmpty() )
261 {
262 m_permittivityCtrl->SetValue( list.Item( index ).BeforeFirst( ' ' ) );
263 // wx automatically calls onPermittivity()
264 }
265}
wxArrayString StandardRelativeDielectricConstantList()
Definition: common_data.cpp:28
#define _(s)
bool findMatch(wxArrayString &aList, const wxString &aValue, int &aIdx)

References _, findMatch(), PANEL_WAVELENGTH_BASE::m_permittivityCtrl, and StandardRelativeDielectricConstantList().

◆ OnFrequencyChange()

void PANEL_WAVELENGTH::OnFrequencyChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 132 of file panel_wavelength.cpp.

133{
134 double value;
135
136 if( m_updatingUI )
137 {
138 return;
139 }
140
141 wxString input = m_frequencyCtrl->GetValue();
142
143 if( input.ToDouble( &value ) )
144 {
145 if( value > 0 )
146 {
147 m_updatingFrequency = true;
148 update( value * m_frequencyUnit->GetUnitScale() );
149 }
150 }
151}
double GetUnitScale() override
Function GetUnitScale.

References UNIT_SELECTOR_FREQUENCY::GetUnitScale(), PANEL_WAVELENGTH_BASE::m_frequencyCtrl, PANEL_WAVELENGTH_BASE::m_frequencyUnit, m_updatingFrequency, m_updatingUI, and update().

◆ OnPeriodChange()

void PANEL_WAVELENGTH::OnPeriodChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 153 of file panel_wavelength.cpp.

154{
155 double value;
156
157 if( m_updatingUI )
158 {
159 return;
160 }
161
162 wxString input = m_periodCtrl->GetValue();
163
164 if( input.ToDouble( &value ) )
165 {
166 if( value > 0 )
167 {
168 m_updatingPeriod = true;
169 update( 1 / ( value * m_periodUnit->GetUnitScale() ) );
170 }
171 }
172}
double GetUnitScale() override
Function GetUnitScale.

References UNIT_SELECTOR_TIME::GetUnitScale(), PANEL_WAVELENGTH_BASE::m_periodCtrl, PANEL_WAVELENGTH_BASE::m_periodUnit, m_updatingPeriod, m_updatingUI, and update().

◆ OnPermeabilityChange()

void PANEL_WAVELENGTH::OnPermeabilityChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 232 of file panel_wavelength.cpp.

233{
234 double value;
235 wxString input = m_permeabilityCtrl->GetValue();
236
237 if( input.ToDouble( &value ) )
238 {
239 if( value >= 1 )
240 {
241 m_permeability = value;
243 }
244 }
245}

References m_frequency, m_permeability, PANEL_WAVELENGTH_BASE::m_permeabilityCtrl, and update().

◆ OnPermittivityChange()

void PANEL_WAVELENGTH::OnPermittivityChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 217 of file panel_wavelength.cpp.

218{
219 double value;
220 wxString input = m_permittivityCtrl->GetValue();
221
222 if( input.ToDouble( &value ) )
223 {
224 if( value >= 1 )
225 {
226 m_permittivity = value;
228 }
229 }
230}

References m_frequency, m_permittivity, PANEL_WAVELENGTH_BASE::m_permittivityCtrl, and update().

◆ OnWavelengthMediumChange()

void PANEL_WAVELENGTH::OnWavelengthMediumChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 196 of file panel_wavelength.cpp.

197{
198 if( m_updatingUI )
199 {
200 return;
201 }
202
203 double value;
204 wxString input = m_wavelengthMediumCtrl->GetValue();
205
206 if( input.ToDouble( &value ) )
207 {
208 if( value > 0 )
209 {
212 update( SPEED_LIGHT / value / sqrt( m_permittivity * m_permeability ) );
213 }
214 }
215};
double GetUnitScale() override
Function GetUnitScale.
#define SPEED_LIGHT

References UNIT_SELECTOR_LEN_CABLE::GetUnitScale(), m_permeability, m_permittivity, m_updatingUI, m_updatingWavelengthMedium, PANEL_WAVELENGTH_BASE::m_wavelengthMediumCtrl, PANEL_WAVELENGTH_BASE::m_wavelengthMediumUnit, SPEED_LIGHT, and update().

◆ OnWavelengthVacuumChange()

void PANEL_WAVELENGTH::OnWavelengthVacuumChange ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 174 of file panel_wavelength.cpp.

175{
176 if( m_updatingUI )
177 {
178 return;
179 }
180
181 double value;
182 wxString input = m_wavelengthVacuumCtrl->GetValue();
183
184 if( input.ToDouble( &value ) )
185 {
186 if( value > 0 )
187 {
190 update( SPEED_LIGHT / value );
191 }
192 }
193};

References UNIT_SELECTOR_LEN_CABLE::GetUnitScale(), m_updatingUI, m_updatingWavelengthVacuum, PANEL_WAVELENGTH_BASE::m_wavelengthVacuumCtrl, PANEL_WAVELENGTH_BASE::m_wavelengthVacuumUnit, SPEED_LIGHT, and update().

◆ SaveSettings()

void PANEL_WAVELENGTH::SaveSettings ( PCB_CALCULATOR_SETTINGS aCfg)
overridevirtual

◆ ThemeChanged()

void PANEL_WAVELENGTH::ThemeChanged ( )
inlineoverridevirtual

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 38 of file panel_wavelength.h.

38{};

◆ update()

void PANEL_WAVELENGTH::update ( double  aFrequency)
private

Definition at line 84 of file panel_wavelength.cpp.

85{
86 m_updatingUI = true;
87 wxString value;
88
90 {
91 value = wxString( "" ) << aFrequency / m_frequencyUnit->GetUnitScale();
92 m_frequencyCtrl->SetValue( value );
93 }
94
95 if( !m_updatingPeriod )
96 {
97 value = wxString( "" ) << 1 / aFrequency / m_periodUnit->GetUnitScale();
98 m_periodCtrl->SetValue( value );
99 }
100
102 {
103 value = wxString( "" ) << SPEED_LIGHT / aFrequency / m_wavelengthVacuumUnit->GetUnitScale();
104 m_wavelengthVacuumCtrl->SetValue( value );
105 }
106
108 {
109 value = wxString( "" ) << SPEED_LIGHT / aFrequency / sqrt( m_permittivity * m_permeability )
111 m_wavelengthMediumCtrl->SetValue( value );
112 }
113
114 if( !m_updatingSpeed )
115 {
116 value = wxString( "" ) << SPEED_LIGHT / sqrt( m_permittivity * m_permeability )
118 m_speedCtrl->SetValue( value );
119 }
120
121 m_frequency = aFrequency;
122
123 m_updatingFrequency = false;
124 m_updatingPeriod = false;
127 m_updatingSpeed = false;
128
129 m_updatingUI = false;
130}
double GetUnitScale() override
Function GetUnitScale.

References UNIT_SELECTOR_FREQUENCY::GetUnitScale(), UNIT_SELECTOR_LEN_CABLE::GetUnitScale(), UNIT_SELECTOR_SPEED::GetUnitScale(), UNIT_SELECTOR_TIME::GetUnitScale(), m_frequency, PANEL_WAVELENGTH_BASE::m_frequencyCtrl, PANEL_WAVELENGTH_BASE::m_frequencyUnit, PANEL_WAVELENGTH_BASE::m_periodCtrl, PANEL_WAVELENGTH_BASE::m_periodUnit, m_permeability, m_permittivity, PANEL_WAVELENGTH_BASE::m_speedCtrl, PANEL_WAVELENGTH_BASE::m_speedUnit, m_updatingFrequency, m_updatingPeriod, m_updatingSpeed, m_updatingUI, m_updatingWavelengthMedium, m_updatingWavelengthVacuum, PANEL_WAVELENGTH_BASE::m_wavelengthMediumCtrl, PANEL_WAVELENGTH_BASE::m_wavelengthMediumUnit, PANEL_WAVELENGTH_BASE::m_wavelengthVacuumCtrl, PANEL_WAVELENGTH_BASE::m_wavelengthVacuumUnit, and SPEED_LIGHT.

Referenced by LoadSettings(), OnFrequencyChange(), OnPeriodChange(), OnPermeabilityChange(), OnPermittivityChange(), OnWavelengthMediumChange(), OnWavelengthVacuumChange(), and updateUnits().

◆ updateUnits()

void PANEL_WAVELENGTH::updateUnits ( wxCommandEvent &  aEvent)
overrideprivatevirtual

Reimplemented from PANEL_WAVELENGTH_BASE.

Definition at line 78 of file panel_wavelength.cpp.

79{
81}

References m_frequency, and update().

Member Data Documentation

◆ m_button1

wxButton* PANEL_WAVELENGTH_BASE::m_button1
protectedinherited

◆ m_frequency

double PANEL_WAVELENGTH::m_frequency = 1
private

◆ m_frequencyCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_frequencyCtrl
protectedinherited

◆ m_frequencyUnit

◆ m_periodCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_periodCtrl
protectedinherited

◆ m_periodUnit

◆ m_permeability

double PANEL_WAVELENGTH::m_permeability = 1
private

◆ m_permeabilityCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_permeabilityCtrl
protectedinherited

◆ m_permittivity

double PANEL_WAVELENGTH::m_permittivity = 1
private

◆ m_permittivityCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_permittivityCtrl
protectedinherited

◆ m_speedCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_speedCtrl
protectedinherited

◆ m_speedUnit

◆ m_staticText18

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText18
protectedinherited

◆ m_staticText181

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText181
protectedinherited

◆ m_staticText1811

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText1811
protectedinherited

◆ m_staticText18111

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText18111
protectedinherited

◆ m_staticText181111

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText181111
protectedinherited

◆ m_staticText181112

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText181112
protectedinherited

◆ m_staticText42

wxStaticText* PANEL_WAVELENGTH_BASE::m_staticText42
protectedinherited

◆ m_updatingFrequency

bool PANEL_WAVELENGTH::m_updatingFrequency = false
private

Definition at line 56 of file panel_wavelength.h.

Referenced by OnFrequencyChange(), and update().

◆ m_updatingPeriod

bool PANEL_WAVELENGTH::m_updatingPeriod = false
private

Definition at line 57 of file panel_wavelength.h.

Referenced by OnPeriodChange(), and update().

◆ m_updatingSpeed

bool PANEL_WAVELENGTH::m_updatingSpeed = false
private

Definition at line 60 of file panel_wavelength.h.

Referenced by update().

◆ m_updatingUI

bool PANEL_WAVELENGTH::m_updatingUI = false
private

◆ m_updatingWavelengthMedium

bool PANEL_WAVELENGTH::m_updatingWavelengthMedium = false
private

Definition at line 59 of file panel_wavelength.h.

Referenced by OnWavelengthMediumChange(), and update().

◆ m_updatingWavelengthVacuum

bool PANEL_WAVELENGTH::m_updatingWavelengthVacuum = false
private

Definition at line 58 of file panel_wavelength.h.

Referenced by OnWavelengthVacuumChange(), and update().

◆ m_wavelengthMediumCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_wavelengthMediumCtrl
protectedinherited

◆ m_wavelengthMediumUnit

◆ m_wavelengthVacuumCtrl

wxTextCtrl* PANEL_WAVELENGTH_BASE::m_wavelengthVacuumCtrl
protectedinherited

◆ m_wavelengthVacuumUnit


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