KiCad PCB EDA Suite
PANEL_ATTENUATORS Class Reference

#include <panel_attenuators.h>

Inheritance diagram for PANEL_ATTENUATORS:
PANEL_ATTENUATORS_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_ATTENUATORS (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_ATTENUATORS ()
 
wxRadioBox * GetAttenuatorsSelector ()
 
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 UpdateUI ()
 
void OnAttenuatorSelection (wxCommandEvent &event) override
 
void SetAttenuator (unsigned aIdx)
 
void OnCalculateAttenuator (wxCommandEvent &event) override
 
void TransfPanelDataToAttenuator ()
 
void TransfAttenuatorDataToPanel ()
 
void TransfAttenuatorResultsToPanel ()
 

Public Attributes

ATTENUATORm_CurrAttenuator
 
std::vector< ATTENUATOR * > m_AttenuatorList
 

Protected Attributes

wxRadioBox * m_AttenuatorsSelection
 
wxStaticBitmap * m_attenuatorBitmap
 
wxStaticText * m_attenuationLabel
 
wxTextCtrl * m_AttValueCtrl
 
wxStaticText * m_attUnit
 
wxStaticText * m_attenuationZinLabel
 
wxTextCtrl * m_ZinValueCtrl
 
wxStaticText * m_attZinUnit
 
wxStaticText * m_ZoutLabel
 
wxTextCtrl * m_ZoutValueCtrl
 
wxStaticText * m_attZoutUnit
 
wxButton * m_buttonAlcAtt
 
wxBitmapButton * m_bpButtonCalcAtt
 
wxStaticText * m_attenuatorR1Label
 
wxTextCtrl * m_Att_R1_Value
 
wxStaticText * m_attR1Unit
 
wxStaticText * m_attenuatorR2Label
 
wxTextCtrl * m_Att_R2_Value
 
wxStaticText * m_attR2Unit
 
wxStaticText * m_attenuatorR3Label
 
wxTextCtrl * m_Att_R3_Value
 
wxStaticText * m_attR3Unit
 
wxStaticText * m_staticTextAttMsg
 
HTML_WINDOWm_Attenuator_Messages
 
HTML_WINDOWm_panelAttFormula
 

Detailed Description

Definition at line 30 of file panel_attenuators.h.

Constructor & Destructor Documentation

◆ PANEL_ATTENUATORS()

PANEL_ATTENUATORS::PANEL_ATTENUATORS ( 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 36 of file panel_attenuators.cpp.

38 :
39 PANEL_ATTENUATORS_BASE( parent, id, pos, size, style, name )
40{
41 m_CurrAttenuator = nullptr;
43
44 // Populate attenuator list ordered like in dialog menu list
45 m_AttenuatorList.push_back( new ATTENUATOR_PI() );
46 m_AttenuatorList.push_back( new ATTENUATOR_TEE() );
47 m_AttenuatorList.push_back( new ATTENUATOR_BRIDGE() );
48 m_AttenuatorList.push_back( new ATTENUATOR_SPLITTER() );
50 SetAttenuator( 0 ); // Ensure an attenuator and especially its bitmap are set
51
52 m_staticTextAttMsg->SetFont( KIUI::GetInfoFont( this ).Italic() );
53
54 m_attZinUnit->SetLabel( wxT( "Ω" ) );
55 m_attZoutUnit->SetLabel( wxT( "Ω" ) );
56 m_attR1Unit->SetLabel( wxT( "Ω" ) );
57 m_attR2Unit->SetLabel( wxT( "Ω" ) );
58 m_attR3Unit->SetLabel( wxT( "Ω" ) );
59
60 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
61 GetSizer()->SetSizeHints( this );
62}
const char * name
Definition: DXF_plotter.cpp:56
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
PANEL_ATTENUATORS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxBitmapButton * m_bpButtonCalcAtt
void SetAttenuator(unsigned aIdx)
ATTENUATOR * m_CurrAttenuator
std::vector< ATTENUATOR * > m_AttenuatorList
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144

References KIUI::GetInfoFont(), KiBitmap(), m_AttenuatorList, PANEL_ATTENUATORS_BASE::m_attR1Unit, PANEL_ATTENUATORS_BASE::m_attR2Unit, PANEL_ATTENUATORS_BASE::m_attR3Unit, PANEL_ATTENUATORS_BASE::m_attZinUnit, PANEL_ATTENUATORS_BASE::m_attZoutUnit, PANEL_ATTENUATORS_BASE::m_bpButtonCalcAtt, m_CurrAttenuator, PANEL_ATTENUATORS_BASE::m_staticTextAttMsg, SetAttenuator(), and small_down.

◆ ~PANEL_ATTENUATORS()

PANEL_ATTENUATORS::~PANEL_ATTENUATORS ( )

Definition at line 65 of file panel_attenuators.cpp.

66{
67 for( ATTENUATOR* attenuator : m_AttenuatorList )
68 delete attenuator;
69}

References m_AttenuatorList.

Member Function Documentation

◆ GetAttenuatorsSelector()

wxRadioBox * PANEL_ATTENUATORS::GetAttenuatorsSelector ( )
inline

◆ LoadSettings()

void PANEL_ATTENUATORS::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 99 of file panel_attenuators.cpp.

100{
101 wxASSERT( aCfg );
102
103 for( ATTENUATOR* attenuator : m_AttenuatorList )
104 attenuator->ReadConfig();
105
106 m_AttenuatorsSelection->SetSelection( aCfg->m_Attenuators.type );
107 SetAttenuator( m_AttenuatorsSelection->GetSelection() );
108}

References m_AttenuatorList, PCB_CALCULATOR_SETTINGS::m_Attenuators, PANEL_ATTENUATORS_BASE::m_AttenuatorsSelection, SetAttenuator(), and PCB_CALCULATOR_SETTINGS::ATTENUATORS::type.

◆ OnAttenuatorSelection()

void PANEL_ATTENUATORS::OnAttenuatorSelection ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_ATTENUATORS_BASE.

Definition at line 123 of file panel_attenuators.cpp.

124{
125 SetAttenuator( (unsigned) event.GetSelection() );
126 Refresh();
127}
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...

References Refresh(), and SetAttenuator().

◆ OnCalculateAttenuator()

void PANEL_ATTENUATORS::OnCalculateAttenuator ( wxCommandEvent &  event)
overridevirtual

Reimplemented from PANEL_ATTENUATORS_BASE.

Definition at line 150 of file panel_attenuators.cpp.

151{
155}
virtual bool Calculate()
Calculates the values of components in attenuator.

References ATTENUATOR::Calculate(), m_CurrAttenuator, TransfAttenuatorResultsToPanel(), and TransfPanelDataToAttenuator().

◆ SaveSettings()

void PANEL_ATTENUATORS::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 111 of file panel_attenuators.cpp.

112{
113 wxASSERT( aCfg );
114
115 aCfg->m_Attenuators.type = m_AttenuatorsSelection->GetSelection();
116
117 for( ATTENUATOR* attenuator : m_AttenuatorList )
118 attenuator->WriteConfig();
119}

References m_AttenuatorList, PCB_CALCULATOR_SETTINGS::m_Attenuators, PANEL_ATTENUATORS_BASE::m_AttenuatorsSelection, and PCB_CALCULATOR_SETTINGS::ATTENUATORS::type.

◆ SetAttenuator()

void PANEL_ATTENUATORS::SetAttenuator ( unsigned  aIdx)

Definition at line 130 of file panel_attenuators.cpp.

131{
132 if( aIdx >=m_AttenuatorList.size() )
133 aIdx = m_AttenuatorList.size() - 1;
134
137 m_Attenuator_Messages->SetPage( wxEmptyString );
138 m_Att_R1_Value->SetValue( wxEmptyString );
139 m_Att_R2_Value->SetValue( wxEmptyString );
140 m_Att_R3_Value->SetValue( wxEmptyString );
141
142 // Disable R3 for bridget T attenuator only
143 bool enable = aIdx != 2;
144 m_attenuatorR3Label->Enable( enable );
145 m_Att_R3_Value->Enable( enable );
146 m_attR3Unit->Enable( enable );
147}
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38

References PANEL_ATTENUATORS_BASE::m_Att_R1_Value, PANEL_ATTENUATORS_BASE::m_Att_R2_Value, PANEL_ATTENUATORS_BASE::m_Att_R3_Value, PANEL_ATTENUATORS_BASE::m_Attenuator_Messages, m_AttenuatorList, PANEL_ATTENUATORS_BASE::m_attenuatorR3Label, PANEL_ATTENUATORS_BASE::m_attR3Unit, m_CurrAttenuator, HTML_WINDOW::SetPage(), and TransfAttenuatorDataToPanel().

Referenced by LoadSettings(), OnAttenuatorSelection(), and PANEL_ATTENUATORS().

◆ ThemeChanged()

void PANEL_ATTENUATORS::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 72 of file panel_attenuators.cpp.

73{
74 // Update the bitmaps
77
78 // Update the font
79 m_staticTextAttMsg->SetFont( KIUI::GetInfoFont( this ).Italic() );
80
81 // Update the HTML windows
84
85 Layout();
86 Refresh();
87}
BITMAPS m_SchBitmapName
void ThemeChanged()
Definition: html_window.cpp:63
wxStaticBitmap * m_attenuatorBitmap

References KIUI::GetInfoFont(), KiBitmap(), PANEL_ATTENUATORS_BASE::m_Attenuator_Messages, PANEL_ATTENUATORS_BASE::m_attenuatorBitmap, PANEL_ATTENUATORS_BASE::m_bpButtonCalcAtt, m_CurrAttenuator, PANEL_ATTENUATORS_BASE::m_panelAttFormula, ATTENUATOR::m_SchBitmapName, PANEL_ATTENUATORS_BASE::m_staticTextAttMsg, Refresh(), small_down, and HTML_WINDOW::ThemeChanged().

◆ TransfAttenuatorDataToPanel()

void PANEL_ATTENUATORS::TransfAttenuatorDataToPanel ( )

Definition at line 171 of file panel_attenuators.cpp.

172{
174
175 wxString msg;
176
177 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Attenuation );
178 m_AttValueCtrl->SetValue( msg );
180
182
184 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zin );
185 else
186 msg.Clear();
187
188 m_ZinValueCtrl->SetValue( msg );
189
190 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zout );
191 m_ZoutValueCtrl->SetValue( msg );
192
194 {
195 if( m_CurrAttenuator->m_FormulaName->StartsWith( "<!" ) )
196 {
198 }
199 else
200 {
201 wxString html_txt;
202 ConvertMarkdown2Html( wxGetTranslation( *m_CurrAttenuator->m_FormulaName ), html_txt );
203 m_panelAttFormula->SetPage( html_txt );
204 }
205 }
206 else
207 {
208 m_panelAttFormula->SetPage( wxEmptyString );
209 }
210}
wxString * m_FormulaName
bool m_Attenuation_Enable
double m_Attenuation
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)

References ConvertMarkdown2Html(), KiBitmap(), ATTENUATOR::m_Attenuation, ATTENUATOR::m_Attenuation_Enable, PANEL_ATTENUATORS_BASE::m_attenuatorBitmap, PANEL_ATTENUATORS_BASE::m_AttValueCtrl, m_CurrAttenuator, ATTENUATOR::m_FormulaName, PANEL_ATTENUATORS_BASE::m_panelAttFormula, ATTENUATOR::m_SchBitmapName, ATTENUATOR::m_Zin, ATTENUATOR::m_Zin_Enable, PANEL_ATTENUATORS_BASE::m_ZinValueCtrl, ATTENUATOR::m_Zout, PANEL_ATTENUATORS_BASE::m_ZoutValueCtrl, and HTML_WINDOW::SetPage().

Referenced by SetAttenuator().

◆ TransfAttenuatorResultsToPanel()

void PANEL_ATTENUATORS::TransfAttenuatorResultsToPanel ( )

Definition at line 213 of file panel_attenuators.cpp.

214{
215 wxString msg;
216
217 m_Attenuator_Messages->SetPage( wxEmptyString );
218
220 {
221 msg.Printf( _( "Attenuation more than %f dB" ),
223 m_Attenuator_Messages->AppendToPage( wxT( "<br><b>Error!</b></br><br><em>" ) );
225 m_Attenuator_Messages->AppendToPage( wxT( "</em></br>" ) );
226
227 // Display -- as resistor values:
228 msg = wxT( "--" );
229 m_Att_R1_Value->SetValue( msg );
230 m_Att_R2_Value->SetValue( msg );
231
233 m_Att_R3_Value->SetValue( msg );
234
235 return;
236 }
237
238 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R1 );
239 m_Att_R1_Value->SetValue( msg );
240 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R2 );
241 m_Att_R2_Value->SetValue( msg );
242
244 {
245 m_Att_R3_Value->SetValue( wxEmptyString );
246 }
247 else
248 {
249 msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R3 );
250 m_Att_R3_Value->SetValue( msg );
251 }
252}
bool AppendToPage(const wxString &aSource)
Definition: html_window.cpp:57
#define _(s)

References _, HTML_WINDOW::AppendToPage(), PANEL_ATTENUATORS_BASE::m_Att_R1_Value, PANEL_ATTENUATORS_BASE::m_Att_R2_Value, PANEL_ATTENUATORS_BASE::m_Att_R3_Value, PANEL_ATTENUATORS_BASE::m_Attenuator_Messages, m_CurrAttenuator, ATTENUATOR::m_Error, ATTENUATOR::m_MinimumATT, ATTENUATOR::m_R1, ATTENUATOR::m_R2, ATTENUATOR::m_R3, ATTENUATOR::m_ResultCount, and HTML_WINDOW::SetPage().

Referenced by OnCalculateAttenuator().

◆ TransfPanelDataToAttenuator()

void PANEL_ATTENUATORS::TransfPanelDataToAttenuator ( )

◆ UpdateUI()

void PANEL_ATTENUATORS::UpdateUI ( )

Definition at line 90 of file panel_attenuators.cpp.

91{
93
94 m_attenuatorBitmap->GetParent()->Layout();
95 m_attenuatorBitmap->GetParent()->Refresh();
96}

References KiBitmap(), PANEL_ATTENUATORS_BASE::m_attenuatorBitmap, m_CurrAttenuator, and ATTENUATOR::m_SchBitmapName.

Referenced by PCB_CALCULATOR_FRAME::OnUpdateUI().

Member Data Documentation

◆ m_Att_R1_Value

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_Att_R1_Value
protectedinherited

◆ m_Att_R2_Value

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_Att_R2_Value
protectedinherited

◆ m_Att_R3_Value

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_Att_R3_Value
protectedinherited

◆ m_attenuationLabel

wxStaticText* PANEL_ATTENUATORS_BASE::m_attenuationLabel
protectedinherited

◆ m_attenuationZinLabel

wxStaticText* PANEL_ATTENUATORS_BASE::m_attenuationZinLabel
protectedinherited

◆ m_Attenuator_Messages

HTML_WINDOW* PANEL_ATTENUATORS_BASE::m_Attenuator_Messages
protectedinherited

◆ m_attenuatorBitmap

wxStaticBitmap* PANEL_ATTENUATORS_BASE::m_attenuatorBitmap
protectedinherited

◆ m_AttenuatorList

std::vector<ATTENUATOR*> PANEL_ATTENUATORS::m_AttenuatorList

◆ m_attenuatorR1Label

wxStaticText* PANEL_ATTENUATORS_BASE::m_attenuatorR1Label
protectedinherited

◆ m_attenuatorR2Label

wxStaticText* PANEL_ATTENUATORS_BASE::m_attenuatorR2Label
protectedinherited

◆ m_attenuatorR3Label

wxStaticText* PANEL_ATTENUATORS_BASE::m_attenuatorR3Label
protectedinherited

◆ m_AttenuatorsSelection

wxRadioBox* PANEL_ATTENUATORS_BASE::m_AttenuatorsSelection
protectedinherited

◆ m_attR1Unit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attR1Unit
protectedinherited

◆ m_attR2Unit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attR2Unit
protectedinherited

◆ m_attR3Unit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attR3Unit
protectedinherited

◆ m_attUnit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attUnit
protectedinherited

◆ m_AttValueCtrl

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_AttValueCtrl
protectedinherited

◆ m_attZinUnit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attZinUnit
protectedinherited

◆ m_attZoutUnit

wxStaticText* PANEL_ATTENUATORS_BASE::m_attZoutUnit
protectedinherited

◆ m_bpButtonCalcAtt

wxBitmapButton* PANEL_ATTENUATORS_BASE::m_bpButtonCalcAtt
protectedinherited

◆ m_buttonAlcAtt

wxButton* PANEL_ATTENUATORS_BASE::m_buttonAlcAtt
protectedinherited

◆ m_CurrAttenuator

◆ m_panelAttFormula

HTML_WINDOW* PANEL_ATTENUATORS_BASE::m_panelAttFormula
protectedinherited

◆ m_staticTextAttMsg

wxStaticText* PANEL_ATTENUATORS_BASE::m_staticTextAttMsg
protectedinherited

◆ m_ZinValueCtrl

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_ZinValueCtrl
protectedinherited

◆ m_ZoutLabel

wxStaticText* PANEL_ATTENUATORS_BASE::m_ZoutLabel
protectedinherited

◆ m_ZoutValueCtrl

wxTextCtrl* PANEL_ATTENUATORS_BASE::m_ZoutValueCtrl
protectedinherited

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