KiCad PCB EDA Suite
PANEL_ELECTRICAL_SPACING Class Reference

#include <panel_electrical_spacing.h>

Inheritance diagram for PANEL_ELECTRICAL_SPACING:
PANEL_ELECTRICAL_SPACING_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_ELECTRICAL_SPACING (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_ELECTRICAL_SPACING ()
 
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 OnElectricalSpacingUnitsSelection (wxCommandEvent &event) override
 
void OnElectricalSpacingRefresh (wxCommandEvent &event) override
 
void ElectricalSpacingUpdateData (double aUnitScale)
 

Protected Attributes

UNIT_SELECTOR_LENm_ElectricalSpacingUnitsSelector
 
wxStaticLine * m_staticline2
 
wxStaticText * m_staticText891
 
wxTextCtrl * m_ElectricalSpacingVoltage
 
wxButton * m_buttonElectSpacingRefresh
 
wxBoxSizer * m_electricalSpacingSizer
 
wxStaticText * m_staticTextElectricalSpacing
 
wxGrid * m_gridElectricalSpacingValues
 
wxStaticText * m_staticText88
 

Detailed Description

Definition at line 28 of file panel_electrical_spacing.h.

Constructor & Destructor Documentation

◆ PANEL_ELECTRICAL_SPACING()

PANEL_ELECTRICAL_SPACING::PANEL_ELECTRICAL_SPACING ( 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 111 of file panel_electrical_spacing.cpp.

113  :
114  PANEL_ELECTRICAL_SPACING_BASE( parent, id, pos, size, style, name )
115 {
116  // Autosize the row label column to be sure label are not truncated
117  m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE );
118 
119  // Needed on wxWidgets 3.0 to ensure sizers are correctly set
120  GetSizer()->SetSizeHints( this );
121 }
PANEL_ELECTRICAL_SPACING_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)
const char * name
Definition: DXF_plotter.cpp:56

References PANEL_ELECTRICAL_SPACING_BASE::m_gridElectricalSpacingValues.

◆ ~PANEL_ELECTRICAL_SPACING()

PANEL_ELECTRICAL_SPACING::~PANEL_ELECTRICAL_SPACING ( )

Definition at line 124 of file panel_electrical_spacing.cpp.

125 {
126 }

Member Function Documentation

◆ ElectricalSpacingUpdateData()

void PANEL_ELECTRICAL_SPACING::ElectricalSpacingUpdateData ( double  aUnitScale)

Definition at line 163 of file panel_electrical_spacing.cpp.

164 {
165  wxString txt;
166  double voltage = 500.0; // to calculate values at V > 500V
167  txt = m_ElectricalSpacingVoltage->GetValue();
168 
169  if( ! txt.IsEmpty() )
170  voltage = DoubleFromString(txt);
171 
172  if( voltage < 500.0 )
173  voltage = 500.0;
174 
175  txt.Printf( wxT( "%g" ), voltage );
176  m_ElectricalSpacingVoltage->SetValue( txt );
177 
178  for( int ii = 0; ii < CLASS_COUNT-1; ii++ )
179  {
180  for( int jj = 0; jj < VALUE_COUNT; jj++ )
181  {
182  txt.Printf( wxT( "%g" ), clist[ii][jj] / aUnitScale );
183  m_gridElectricalSpacingValues->SetCellValue( ii, jj, txt );
184  }
185  }
186 
187  for( int jj = 0; jj < VALUE_COUNT; jj++ )
188  {
189  double spacing = clist[CLASS_COUNT-2][jj];
190  double spacing_extra = clist[CLASS_COUNT-1][jj];
191  spacing += spacing_extra * ( voltage - 500.0 );
192  txt.Printf( wxT( "%g" ), spacing / aUnitScale );
193  m_gridElectricalSpacingValues->SetCellValue( CLASS_COUNT-1, jj, txt );
194  }
195 
196  m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE );
197 }
static double clist[CLASS_COUNT][VALUE_COUNT]
double DoubleFromString(const wxString &TextValue)
#define VALUE_COUNT
#define CLASS_COUNT

References CLASS_COUNT, clist, DoubleFromString(), PANEL_ELECTRICAL_SPACING_BASE::m_ElectricalSpacingVoltage, PANEL_ELECTRICAL_SPACING_BASE::m_gridElectricalSpacingValues, and VALUE_COUNT.

Referenced by LoadSettings(), OnElectricalSpacingRefresh(), and OnElectricalSpacingUnitsSelection().

◆ LoadSettings()

void PANEL_ELECTRICAL_SPACING::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 142 of file panel_electrical_spacing.cpp.

References ElectricalSpacingUpdateData(), UNIT_SELECTOR_LEN::GetUnitScale(), PCB_CALCULATOR_SETTINGS::m_Electrical, PANEL_ELECTRICAL_SPACING_BASE::m_ElectricalSpacingUnitsSelector, PANEL_ELECTRICAL_SPACING_BASE::m_ElectricalSpacingVoltage, PCB_CALCULATOR_SETTINGS::ELECTRICAL::spacing_units, and PCB_CALCULATOR_SETTINGS::ELECTRICAL::spacing_voltage.

◆ OnElectricalSpacingRefresh()

void PANEL_ELECTRICAL_SPACING::OnElectricalSpacingRefresh ( wxCommandEvent &  event)
overridevirtual

◆ OnElectricalSpacingUnitsSelection()

void PANEL_ELECTRICAL_SPACING::OnElectricalSpacingUnitsSelection ( wxCommandEvent &  event)
overridevirtual

◆ SaveSettings()

◆ ThemeChanged()

void PANEL_ELECTRICAL_SPACING::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 129 of file panel_electrical_spacing.cpp.

130 {
131  // TODO: Only the grid needs updating, but it isn't done automatically (https://trac.wxwidgets.org/ticket/19279)
132 }

Member Data Documentation

◆ m_buttonElectSpacingRefresh

wxButton* PANEL_ELECTRICAL_SPACING_BASE::m_buttonElectSpacingRefresh
protectedinherited

◆ m_electricalSpacingSizer

wxBoxSizer* PANEL_ELECTRICAL_SPACING_BASE::m_electricalSpacingSizer
protectedinherited

◆ m_ElectricalSpacingUnitsSelector

◆ m_ElectricalSpacingVoltage

wxTextCtrl* PANEL_ELECTRICAL_SPACING_BASE::m_ElectricalSpacingVoltage
protectedinherited

◆ m_gridElectricalSpacingValues

wxGrid* PANEL_ELECTRICAL_SPACING_BASE::m_gridElectricalSpacingValues
protectedinherited

◆ m_staticline2

wxStaticLine* PANEL_ELECTRICAL_SPACING_BASE::m_staticline2
protectedinherited

◆ m_staticText88

wxStaticText* PANEL_ELECTRICAL_SPACING_BASE::m_staticText88
protectedinherited

◆ m_staticText891

wxStaticText* PANEL_ELECTRICAL_SPACING_BASE::m_staticText891
protectedinherited

◆ m_staticTextElectricalSpacing

wxStaticText* PANEL_ELECTRICAL_SPACING_BASE::m_staticTextElectricalSpacing
protectedinherited

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