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 }
void SetAttenuator(unsigned aIdx)
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
std::vector< ATTENUATOR * > m_AttenuatorList
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)
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
wxBitmapButton * m_bpButtonCalcAtt
const char * name
Definition: DXF_plotter.cpp:56
ATTENUATOR * m_CurrAttenuator

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 }
std::vector< ATTENUATOR * > m_AttenuatorList

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 }
void SetAttenuator(unsigned aIdx)
std::vector< ATTENUATOR * > m_AttenuatorList

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 SetAttenuator(unsigned aIdx)
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 144 of file panel_attenuators.cpp.

145 {
149 }
virtual bool Calculate()
Calculates the values of components in attenuator.
ATTENUATOR * m_CurrAttenuator

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 }
std::vector< ATTENUATOR * > m_AttenuatorList

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 }
std::vector< ATTENUATOR * > m_AttenuatorList
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
ATTENUATOR * m_CurrAttenuator

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, 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 }
wxStaticBitmap * m_attenuatorBitmap
wxFont GetInfoFont(wxWindow *aWindow)
Definition: ui_common.cpp:144
BITMAPS m_SchBitmapName
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
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
wxBitmapButton * m_bpButtonCalcAtt
void ThemeChanged()
Definition: html_window.cpp:63
ATTENUATOR * m_CurrAttenuator

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 165 of file panel_attenuators.cpp.

166 {
168 
169  wxString msg;
170 
171  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Attenuation );
172  m_AttValueCtrl->SetValue( msg );
174 
176 
178  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zin );
179  else
180  msg.Clear();
181 
182  m_ZinValueCtrl->SetValue( msg );
183 
184  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_Zout );
185  m_ZoutValueCtrl->SetValue( msg );
186 
188  {
189  if( m_CurrAttenuator->m_FormulaName->StartsWith( "<!" ) )
190  {
192  }
193  else
194  {
195  wxString html_txt;
196  ConvertMarkdown2Html( wxGetTranslation( *m_CurrAttenuator->m_FormulaName ), html_txt );
197  m_panelAttFormula->SetPage( html_txt );
198  }
199  }
200  else
201  {
202  m_panelAttFormula->SetPage( wxEmptyString );
203  }
204 }
wxStaticBitmap * m_attenuatorBitmap
bool m_Attenuation_Enable
BITMAPS m_SchBitmapName
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
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
wxString * m_FormulaName
ATTENUATOR * m_CurrAttenuator
double m_Attenuation

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 207 of file panel_attenuators.cpp.

208 {
209  wxString msg;
210 
211  m_Attenuator_Messages->SetPage( wxEmptyString );
212 
214  {
215  msg.Printf( _( "Attenuation more than %f dB" ),
217  m_Attenuator_Messages->AppendToPage( wxT( "<br><b>Error!</b></br><br><em>" ) );
219  m_Attenuator_Messages->AppendToPage( wxT( "</em></br>" ) );
220 
221  // Display -- as resistor values:
222  msg = wxT( "--" );
223  m_Att_R1_Value->SetValue( msg );
224  m_Att_R2_Value->SetValue( msg );
225 
226  if( m_CurrAttenuator->m_ResultCount >= 3 )
227  m_Att_R3_Value->SetValue( msg );
228 
229  return;
230  }
231 
232  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R1 );
233  m_Att_R1_Value->SetValue( msg );
234  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R2 );
235  m_Att_R2_Value->SetValue( msg );
236 
238  {
239  m_Att_R3_Value->SetValue( wxEmptyString );
240  }
241  else
242  {
243  msg.Printf( wxT( "%g" ), m_CurrAttenuator->m_R3 );
244  m_Att_R3_Value->SetValue( msg );
245  }
246 }
bool AppendToPage(const wxString &aSource)
Definition: html_window.cpp:57
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
#define _(s)
ATTENUATOR * m_CurrAttenuator

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 }
wxStaticBitmap * m_attenuatorBitmap
BITMAPS m_SchBitmapName
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
ATTENUATOR * m_CurrAttenuator

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: