KiCad PCB EDA Suite
PANEL_TRACK_WIDTH Class Reference

#include <panel_track_width.h>

Inheritance diagram for PANEL_TRACK_WIDTH:
PANEL_TRACK_WIDTH_BASE CALCULATOR_PANEL

Public Member Functions

 PANEL_TRACK_WIDTH (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
 
 ~PANEL_TRACK_WIDTH ()
 
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 OnTWParametersChanged (wxCommandEvent &event) override
 Update the calculations the user changes the general parameters. More...
 
void OnTWCalculateFromCurrent (wxCommandEvent &event) override
 Update the calculations when the user changes the desired maximum current. More...
 
void OnTWCalculateFromExtWidth (wxCommandEvent &event) override
 Update the calculations when the user changes the desired external trace width. More...
 
void OnTWCalculateFromIntWidth (wxCommandEvent &event) override
 Update the calculations when the user changes the desired internal trace width. More...
 
void OnTWResetButtonClick (wxCommandEvent &event) override
 Update the calculations when the user clicks the reset button. More...
 
double TWCalculateWidth (double aCurrent, double aThickness, double aDeltaT_C, bool aUseInternalLayer)
 Calculate track width required based on given current and temperature rise. More...
 
double TWCalculateCurrent (double aWidth, double aThickness, double aDeltaT_C, bool aUseInternalLayer)
 Calculate maximum current based on given width and temperature rise. More...
 
void TWDisplayValues (double aCurrent, double aExtWidth, double aIntWidth, double aExtThickness, double aIntThickness)
 Display the results of a calculation (including resulting values such as the resistance and power loss). More...
 
void TWUpdateModeDisplay ()
 Update the fields to show whether the maximum current, external trace width, or internal trace width is currently the controlling parameter. More...
 

Protected Attributes

wxStaticText * m_staticTextCurrent
 
wxTextCtrl * m_TrackCurrentValue
 
wxStaticText * m_staticText62
 
wxStaticText * m_staticText63
 
wxTextCtrl * m_TrackDeltaTValue
 
wxStaticText * m_trackTempUnits
 
wxStaticText * m_staticText66
 
wxTextCtrl * m_TrackLengthValue
 
UNIT_SELECTOR_LENm_TW_CuLength_choiceUnit
 
wxStaticText * m_staticText103
 
wxTextCtrl * m_TWResistivity
 
wxStaticText * m_resistivityUnits
 
HTML_WINDOWm_htmlWinFormulas
 
wxStaticText * m_staticTextExtWidth
 
wxTextCtrl * m_ExtTrackWidthValue
 
UNIT_SELECTOR_LENm_TW_ExtTrackWidth_choiceUnit
 
wxStaticText * m_staticText65
 
wxTextCtrl * m_ExtTrackThicknessValue
 
UNIT_SELECTOR_THICKNESSm_ExtTrackThicknessUnit
 
wxStaticLine * m_staticline3
 
wxStaticLine * m_staticline4
 
wxStaticLine * m_staticline5
 
wxStaticText * m_staticTextArea
 
wxStaticText * m_ExtTrackAreaValue
 
wxStaticText * m_extTrackAreaUnitLabel
 
wxStaticText * m_staticText651
 
wxStaticText * m_ExtTrackResistValue
 
wxStaticText * m_extTrackResUnits
 
wxStaticText * m_staticText661
 
wxStaticText * m_ExtTrackVDropValue
 
wxStaticText * m_staticText83
 
wxStaticText * m_staticText79
 
wxStaticText * m_ExtTrackLossValue
 
wxStaticText * m_staticText791
 
wxStaticText * m_staticTextIntWidth
 
wxTextCtrl * m_IntTrackWidthValue
 
UNIT_SELECTOR_LENm_TW_IntTrackWidth_choiceUnit
 
wxStaticText * m_staticText652
 
wxTextCtrl * m_IntTrackThicknessValue
 
UNIT_SELECTOR_THICKNESSm_IntTrackThicknessUnit
 
wxStaticLine * m_staticline8
 
wxStaticLine * m_staticline9
 
wxStaticLine * m_staticline10
 
wxStaticText * m_staticTextArea1
 
wxStaticText * m_IntTrackAreaValue
 
wxStaticText * m_intTrackAreaUnitLabel
 
wxStaticText * m_staticText6511
 
wxStaticText * m_IntTrackResistValue
 
wxStaticText * m_intTrackResUnits
 
wxStaticText * m_staticText6611
 
wxStaticText * m_IntTrackVDropValue
 
wxStaticText * m_staticText831
 
wxStaticText * m_staticText792
 
wxStaticText * m_IntTrackLossValue
 
wxStaticText * m_staticText7911
 
wxButton * m_buttonTrackWidthReset
 

Private Types

enum  { TW_MASTER_CURRENT , TW_MASTER_EXT_WIDTH , TW_MASTER_INT_WIDTH }
 

Private Attributes

enum PANEL_TRACK_WIDTH:: { ... }  m_TWMode
 
bool m_TWNested
 

Detailed Description

Definition at line 28 of file panel_track_width.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
TW_MASTER_CURRENT 
TW_MASTER_EXT_WIDTH 
TW_MASTER_INT_WIDTH 

Definition at line 93 of file panel_track_width.h.

94 { // calculations:
95 TW_MASTER_CURRENT, // the maximum current,
96 TW_MASTER_EXT_WIDTH, // the external trace width,
97 TW_MASTER_INT_WIDTH // or the internal trace width?
98 } m_TWMode;
enum PANEL_TRACK_WIDTH::@38 m_TWMode

Constructor & Destructor Documentation

◆ PANEL_TRACK_WIDTH()

PANEL_TRACK_WIDTH::PANEL_TRACK_WIDTH ( 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 48 of file panel_track_width.cpp.

50 :
51 PANEL_TRACK_WIDTH_BASE( parent, id, pos, size, style, name ),
53 m_TWNested( false )
54{
55 m_trackTempUnits->SetLabel( wxT( "°C" ) );
56 m_resistivityUnits->SetLabel( wxT( "Ω⋅m" ) );
57
58 m_extTrackResUnits->SetLabel( wxT( "Ω" ) );
59 m_intTrackResUnits->SetLabel( wxT( "Ω" ) );
60
61 m_staticText63->SetLabel( _( "Temperature rise" ) + wxT( " (ΔT):" ) );
62
63 // Needed on wxWidgets 3.0 to ensure sizers are correctly set
64 GetSizer()->SetSizeHints( this );
65}
const char * name
Definition: DXF_plotter.cpp:56
PANEL_TRACK_WIDTH_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(623, 457), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
#define _(s)

References _, PANEL_TRACK_WIDTH_BASE::m_extTrackResUnits, PANEL_TRACK_WIDTH_BASE::m_intTrackResUnits, PANEL_TRACK_WIDTH_BASE::m_resistivityUnits, PANEL_TRACK_WIDTH_BASE::m_staticText63, and PANEL_TRACK_WIDTH_BASE::m_trackTempUnits.

◆ ~PANEL_TRACK_WIDTH()

PANEL_TRACK_WIDTH::~PANEL_TRACK_WIDTH ( )

Definition at line 68 of file panel_track_width.cpp.

69{
70}

Member Function Documentation

◆ LoadSettings()

void PANEL_TRACK_WIDTH::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 446 of file panel_track_width.cpp.

447{
448 // Disable calculations while we initialise.
449 m_TWNested = true;
450
451 // Read parameter values.
452 m_TrackCurrentValue->SetValue( aCfg->m_TrackWidth.current );
453 m_TrackDeltaTValue->SetValue( aCfg->m_TrackWidth.delta_tc );
454 m_TrackLengthValue->SetValue( aCfg->m_TrackWidth.track_len );
456#if 0 // the IPC formula is valid for copper traces, so we do not currently adjust the resistivity
457 m_TWResistivity->SetValue( aCfg->m_TrackWidth.resistivity );
458#else
460#endif
469
470 if( tracks_width_versus_current_formula.StartsWith( "<!" ) )
472 else
473 {
474 wxString html_txt;
475 ConvertMarkdown2Html( wxGetTranslation( tracks_width_versus_current_formula ), html_txt );
476 m_htmlWinFormulas->SetPage( html_txt );
477 }
478
479 // Make sure the correct master mode is displayed.
481
482 // Enable calculations and perform the initial one.
483 m_TWNested = false;
484
485 wxCommandEvent dummy;
487}
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
UNIT_SELECTOR_THICKNESS * m_IntTrackThicknessUnit
UNIT_SELECTOR_LEN * m_TW_IntTrackWidth_choiceUnit
UNIT_SELECTOR_THICKNESS * m_ExtTrackThicknessUnit
UNIT_SELECTOR_LEN * m_TW_ExtTrackWidth_choiceUnit
UNIT_SELECTOR_LEN * m_TW_CuLength_choiceUnit
void TWUpdateModeDisplay()
Update the fields to show whether the maximum current, external trace width, or internal trace width ...
void OnTWParametersChanged(wxCommandEvent &event) override
Update the calculations the user changes the general parameters.
const double copper_resistivity
wxString tracks_width_versus_current_formula
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
Definition: sch_symbol.cpp:74
void ConvertMarkdown2Html(const wxString &aMarkdownInput, wxString &aHtmlOutput)

References ConvertMarkdown2Html(), copper_resistivity, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::current, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::delta_tc, dummy(), PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_thickness, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_thickness_units, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_width, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_width_units, Format(), PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_thickness, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_thickness_units, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_width, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_width_units, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_htmlWinFormulas, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, PANEL_TRACK_WIDTH_BASE::m_TrackLengthValue, PCB_CALCULATOR_SETTINGS::m_TrackWidth, PANEL_TRACK_WIDTH_BASE::m_TW_CuLength_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_ExtTrackWidth_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_IntTrackWidth_choiceUnit, m_TWNested, PANEL_TRACK_WIDTH_BASE::m_TWResistivity, OnTWParametersChanged(), PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::resistivity, HTML_WINDOW::SetPage(), PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::track_len, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::track_len_units, tracks_width_versus_current_formula, and TWUpdateModeDisplay().

◆ OnTWCalculateFromCurrent()

void PANEL_TRACK_WIDTH::OnTWCalculateFromCurrent ( wxCommandEvent &  event)
overridevirtual

Update the calculations when the user changes the desired maximum current.

Reimplemented from PANEL_TRACK_WIDTH_BASE.

Definition at line 108 of file panel_track_width.cpp.

109{
110 // Setting the calculated values generates further events. Stop them.
111 if( m_TWNested )
112 {
113 event.StopPropagation();
114 return;
115 }
116
117 m_TWNested = true;
118
119 // Update state.
121 {
124 }
125
126 // Prepare parameters:
127 double current = std::abs( DoubleFromString( m_TrackCurrentValue->GetValue() ) );
128 double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
129 double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
130 double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
131
132 // Normalize by units.
133 extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
134 intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
135
136 // Calculate the widths.
137 double extTrackWidth = TWCalculateWidth( current, extThickness, deltaT_C, false );
138 double intTrackWidth = TWCalculateWidth( current, intThickness, deltaT_C, true );
139
140 // Update the display.
141 TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
142
143 // Re-enable the events.
144 m_TWNested = false;
145}
double TWCalculateWidth(double aCurrent, double aThickness, double aDeltaT_C, bool aUseInternalLayer)
Calculate track width required based on given current and temperature rise.
void TWDisplayValues(double aCurrent, double aExtWidth, double aIntWidth, double aExtThickness, double aIntThickness)
Display the results of a calculation (including resulting values such as the resistance and power los...
double GetUnitScale() override
Function GetUnitScale.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:401
double DoubleFromString(const wxString &TextValue)

References std::abs(), DoubleFromString(), UNIT_SELECTOR_THICKNESS::GetUnitScale(), PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, m_TWMode, m_TWNested, TW_MASTER_CURRENT, TWCalculateWidth(), TWDisplayValues(), and TWUpdateModeDisplay().

Referenced by OnTWParametersChanged().

◆ OnTWCalculateFromExtWidth()

void PANEL_TRACK_WIDTH::OnTWCalculateFromExtWidth ( wxCommandEvent &  event)
overridevirtual

Update the calculations when the user changes the desired external trace width.

Reimplemented from PANEL_TRACK_WIDTH_BASE.

Definition at line 148 of file panel_track_width.cpp.

149{
150 // Setting the calculated values generates further events. Stop them.
151 if( m_TWNested )
152 {
153 event.StopPropagation();
154 return;
155 }
156 m_TWNested = true;
157
158 // Update state.
160 {
163 }
164
165 // Load parameters.
166 double current;
167 double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
168 double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
169 double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
170 double extTrackWidth = std::abs( DoubleFromString( m_ExtTrackWidthValue->GetValue() ) );
171 double intTrackWidth;
172
173 // Normalize units.
174 extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
175 intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
177
178 // Calculate the maximum current.
179 current = TWCalculateCurrent( extTrackWidth, extThickness, deltaT_C, false );
180
181 // And now calculate the corresponding internal width.
182 intTrackWidth = TWCalculateWidth( current, intThickness, deltaT_C, true );
183
184 // Update the display.
185 TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
186
187 // Re-enable the events.
188 m_TWNested = false;
189}
double TWCalculateCurrent(double aWidth, double aThickness, double aDeltaT_C, bool aUseInternalLayer)
Calculate maximum current based on given width and temperature rise.
double GetUnitScale() override
Function GetUnitScale.

References std::abs(), DoubleFromString(), UNIT_SELECTOR_LEN::GetUnitScale(), UNIT_SELECTOR_THICKNESS::GetUnitScale(), PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, PANEL_TRACK_WIDTH_BASE::m_TW_ExtTrackWidth_choiceUnit, m_TWMode, m_TWNested, TW_MASTER_EXT_WIDTH, TWCalculateCurrent(), TWCalculateWidth(), TWDisplayValues(), and TWUpdateModeDisplay().

Referenced by OnTWParametersChanged().

◆ OnTWCalculateFromIntWidth()

void PANEL_TRACK_WIDTH::OnTWCalculateFromIntWidth ( wxCommandEvent &  event)
overridevirtual

Update the calculations when the user changes the desired internal trace width.

Reimplemented from PANEL_TRACK_WIDTH_BASE.

Definition at line 192 of file panel_track_width.cpp.

193{
194 // Setting the calculated values generates further events. Stop them.
195 if( m_TWNested )
196 {
197 event.StopPropagation();
198 return;
199 }
200
201 m_TWNested = true;
202
203 // Update state.
205 {
208 }
209
210 // Load parameters.
211 double current;
212 double extThickness = std::abs( DoubleFromString( m_ExtTrackThicknessValue->GetValue() ) );
213 double intThickness = std::abs( DoubleFromString( m_IntTrackThicknessValue->GetValue() ) );
214 double deltaT_C = std::abs( DoubleFromString( m_TrackDeltaTValue->GetValue() ) );
215 double extTrackWidth;
216 double intTrackWidth = std::abs( DoubleFromString( m_IntTrackWidthValue->GetValue() ) );
217
218 // Normalize units.
219 extThickness *= m_ExtTrackThicknessUnit->GetUnitScale();
220 intThickness *= m_IntTrackThicknessUnit->GetUnitScale();
222
223 // Calculate the maximum current.
224 current = TWCalculateCurrent( intTrackWidth, intThickness, deltaT_C, true );
225
226 // And now calculate the corresponding external width.
227 extTrackWidth = TWCalculateWidth( current, extThickness, deltaT_C, false );
228
229 // Update the display.
230 TWDisplayValues( current, extTrackWidth, intTrackWidth, extThickness, intThickness );
231
232 // Re-enable the events.
233 m_TWNested = false;
234}

References std::abs(), DoubleFromString(), UNIT_SELECTOR_LEN::GetUnitScale(), UNIT_SELECTOR_THICKNESS::GetUnitScale(), PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, PANEL_TRACK_WIDTH_BASE::m_TW_IntTrackWidth_choiceUnit, m_TWMode, m_TWNested, TW_MASTER_INT_WIDTH, TWCalculateCurrent(), TWCalculateWidth(), TWDisplayValues(), and TWUpdateModeDisplay().

Referenced by OnTWParametersChanged().

◆ OnTWParametersChanged()

void PANEL_TRACK_WIDTH::OnTWParametersChanged ( wxCommandEvent &  event)
overridevirtual

Update the calculations the user changes the general parameters.

Reimplemented from PANEL_TRACK_WIDTH_BASE.

Definition at line 97 of file panel_track_width.cpp.

98{
99 switch(m_TWMode)
100 {
101 case TW_MASTER_CURRENT: OnTWCalculateFromCurrent( event ); break;
104 }
105}
void OnTWCalculateFromIntWidth(wxCommandEvent &event) override
Update the calculations when the user changes the desired internal trace width.
void OnTWCalculateFromCurrent(wxCommandEvent &event) override
Update the calculations when the user changes the desired maximum current.
void OnTWCalculateFromExtWidth(wxCommandEvent &event) override
Update the calculations when the user changes the desired external trace width.

References m_TWMode, OnTWCalculateFromCurrent(), OnTWCalculateFromExtWidth(), OnTWCalculateFromIntWidth(), TW_MASTER_CURRENT, TW_MASTER_EXT_WIDTH, and TW_MASTER_INT_WIDTH.

Referenced by LoadSettings().

◆ OnTWResetButtonClick()

void PANEL_TRACK_WIDTH::OnTWResetButtonClick ( wxCommandEvent &  event)
overridevirtual

Update the calculations when the user clicks the reset button.

Reimplemented from PANEL_TRACK_WIDTH_BASE.

Definition at line 237 of file panel_track_width.cpp.

238{
239 // Note: a wxString:Format( "%g", xx) is used to use local separator in floats
240
241 // Init main parameters:
242 m_TrackCurrentValue->SetValue( wxString::Format( "%g", 1.0 ) );
243 m_TrackDeltaTValue->SetValue( wxString::Format( "%g", 10.0 ) );
244 m_TrackLengthValue->SetValue( wxString::Format( "%g", 20.0 ) );
245 m_TW_CuLength_choiceUnit->SetSelection( 0 );
247
248 // m_ExtTrackWidthValue is not reinitialized: it will be calculated from previous parameters
249 m_TW_ExtTrackWidth_choiceUnit->SetSelection( 0 );
250 m_ExtTrackThicknessValue->SetValue( wxString::Format( "%g", 0.035 ) );
251 m_ExtTrackThicknessUnit->SetSelection( 0 );
252
253 // m_IntTrackWidthValue is not reinitialized: it will be calculated from previous parameters
254 m_TW_IntTrackWidth_choiceUnit->SetSelection( 0 );
255 m_IntTrackThicknessValue->SetValue( wxString::Format( "%g", 0.035 ) );
256 m_IntTrackThicknessUnit->SetSelection( 0 );
257}

References copper_resistivity, Format(), PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, PANEL_TRACK_WIDTH_BASE::m_TrackLengthValue, PANEL_TRACK_WIDTH_BASE::m_TW_CuLength_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_ExtTrackWidth_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_IntTrackWidth_choiceUnit, and PANEL_TRACK_WIDTH_BASE::m_TWResistivity.

◆ SaveSettings()

void PANEL_TRACK_WIDTH::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 79 of file panel_track_width.cpp.

References PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::current, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::delta_tc, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_thickness, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_thickness_units, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_width, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::ext_track_width_units, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_thickness, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_thickness_units, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_width, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::int_track_width_units, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_ExtTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessUnit, PANEL_TRACK_WIDTH_BASE::m_IntTrackThicknessValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, PANEL_TRACK_WIDTH_BASE::m_TrackDeltaTValue, PANEL_TRACK_WIDTH_BASE::m_TrackLengthValue, PCB_CALCULATOR_SETTINGS::m_TrackWidth, PANEL_TRACK_WIDTH_BASE::m_TW_CuLength_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_ExtTrackWidth_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_IntTrackWidth_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TWResistivity, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::resistivity, PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::track_len, and PCB_CALCULATOR_SETTINGS::TRACK_WIDTH::track_len_units.

◆ ThemeChanged()

void PANEL_TRACK_WIDTH::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 73 of file panel_track_width.cpp.

74{
76}
void ThemeChanged()
Definition: html_window.cpp:63

References PANEL_TRACK_WIDTH_BASE::m_htmlWinFormulas, and HTML_WINDOW::ThemeChanged().

◆ TWCalculateCurrent()

double PANEL_TRACK_WIDTH::TWCalculateCurrent ( double  aWidth,
double  aThickness,
double  aDeltaT_C,
bool  aUseInternalLayer 
)

Calculate maximum current based on given width and temperature rise.

Definition at line 429 of file panel_track_width.cpp.

431{
432 // Appropriate scale for requested layer.
433 double scale = aUseInternalLayer ? 0.024 : 0.048;
434
435 // Convert thickness and width to mils.
436 aThickness /= UNIT_MIL;
437 aWidth /= UNIT_MIL;
438
439 double area = aThickness * aWidth;
440 double current = scale * pow( aDeltaT_C, 0.44 ) * pow( area, 0.725 );
441
442 return current;
443}
const int scale
#define UNIT_MIL
Definition: units_scales.h:37

References scale, and UNIT_MIL.

Referenced by OnTWCalculateFromExtWidth(), and OnTWCalculateFromIntWidth().

◆ TWCalculateWidth()

double PANEL_TRACK_WIDTH::TWCalculateWidth ( double  aCurrent,
double  aThickness,
double  aDeltaT_C,
bool  aUseInternalLayer 
)

Calculate track width required based on given current and temperature rise.

Definition at line 406 of file panel_track_width.cpp.

408{
409 // Appropriate scale for requested layer.
410 double scale = aUseInternalLayer ? 0.024 : 0.048;
411
412 // aThickness is given in normalize units (in meters) and we need mil
413 aThickness /= UNIT_MIL;
414
415 /* formula is Imax = scale * dT^0.44 * A^0.725
416 * or
417 * log(Imax) = log(scale) + 0.44*log(dT) +(0.725*(log(aThickness) + log(trackWidth))
418 * log(trackWidth) * 0.725 = log(Imax) - log(scale) - 0.44*log(dT) - 0.725*log(aThickness)
419 */
420 double dtmp = log( aCurrent ) - log( scale ) - 0.44 * log( aDeltaT_C ) - 0.725 * log( aThickness );
421 dtmp /= 0.725;
422 double trackWidth = exp( dtmp );
423
424 trackWidth *= UNIT_MIL; // We are using normalize units (sizes in meters) and we have mil
425 return trackWidth; // in meters
426}

References scale, and UNIT_MIL.

Referenced by OnTWCalculateFromCurrent(), OnTWCalculateFromExtWidth(), and OnTWCalculateFromIntWidth().

◆ TWDisplayValues()

void PANEL_TRACK_WIDTH::TWDisplayValues ( double  aCurrent,
double  aExtWidth,
double  aIntWidth,
double  aExtThickness,
double  aIntThickness 
)

Display the results of a calculation (including resulting values such as the resistance and power loss).

Definition at line 260 of file panel_track_width.cpp.

262{
263 wxString msg;
264
265 // Show the current.
267 {
268 msg.Printf( wxT( "%g" ), aCurrent );
269 m_TrackCurrentValue->SetValue( msg );
270 }
271
272 // Load scale factors to convert into output units.
273 double extScale = m_TW_ExtTrackWidth_choiceUnit->GetUnitScale();
274 double intScale = m_TW_IntTrackWidth_choiceUnit->GetUnitScale();
275
276 // Display the widths.
278 {
279 msg.Printf( wxT( "%g" ), aExtWidth / extScale );
280 m_ExtTrackWidthValue->SetValue( msg );
281 }
282
284 {
285 msg.Printf( wxT( "%g" ), aIntWidth / intScale );
286 m_IntTrackWidthValue->SetValue( msg );
287 }
288
289 // Display cross-sectional areas.
290 msg.Printf( wxT( "%g" ), (aExtWidth * aExtThickness) / (extScale * extScale) );
291 m_ExtTrackAreaValue->SetLabel( msg );
292 msg.Printf( wxT( "%g" ), (aIntWidth * aIntThickness) / (intScale * intScale) );
293 m_IntTrackAreaValue->SetLabel( msg );
294
295 // Show area units.
296 wxString strunit = m_TW_ExtTrackWidth_choiceUnit->GetUnitName();
297 msg = strunit + wxT( "²" );
298 m_extTrackAreaUnitLabel->SetLabel( msg );
300 msg = strunit + wxT( "²" );
301 m_intTrackAreaUnitLabel->SetLabel( msg );
302
303 // Load resistivity and length of traces.
304 double rho = std::abs( DoubleFromString( m_TWResistivity->GetValue() ) );
305 double trackLen = std::abs( DoubleFromString( m_TrackLengthValue->GetValue() ) );
307
308 // Calculate resistance.
309 double extResistance = ( rho * trackLen ) / ( aExtWidth * aExtThickness );
310 double intResistance = ( rho * trackLen ) / ( aIntWidth * aIntThickness );
311
312 // Display resistance.
313 msg.Printf( wxT( "%g" ), extResistance );
314 m_ExtTrackResistValue->SetLabel( msg );
315 msg.Printf( wxT( "%g" ), intResistance );
316 m_IntTrackResistValue->SetLabel( msg );
317
318 // Display voltage drop along trace.
319 double extV = extResistance * aCurrent;
320 msg.Printf( wxT( "%g" ), extV );
321 m_ExtTrackVDropValue->SetLabel( msg );
322 double intV = intResistance * aCurrent;
323 msg.Printf( wxT( "%g" ), intV );
324 m_IntTrackVDropValue->SetLabel( msg );
325
326 // And power loss.
327 msg.Printf( wxT( "%g" ), extV * aCurrent );
328 m_ExtTrackLossValue->SetLabel( msg );
329 msg.Printf( wxT( "%g" ), intV * aCurrent );
330 m_IntTrackLossValue->SetLabel( msg );
331}
wxStaticText * m_IntTrackResistValue
wxStaticText * m_ExtTrackResistValue
wxStaticText * m_intTrackAreaUnitLabel
wxStaticText * m_extTrackAreaUnitLabel
wxString GetUnitName()
Definition: unit_selector.h:51

References std::abs(), DoubleFromString(), UNIT_SELECTOR::GetUnitName(), UNIT_SELECTOR_LEN::GetUnitScale(), PANEL_TRACK_WIDTH_BASE::m_extTrackAreaUnitLabel, PANEL_TRACK_WIDTH_BASE::m_ExtTrackAreaValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackLossValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackResistValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackVDropValue, PANEL_TRACK_WIDTH_BASE::m_ExtTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_intTrackAreaUnitLabel, PANEL_TRACK_WIDTH_BASE::m_IntTrackAreaValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackLossValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackResistValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackVDropValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, PANEL_TRACK_WIDTH_BASE::m_TrackLengthValue, PANEL_TRACK_WIDTH_BASE::m_TW_CuLength_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_ExtTrackWidth_choiceUnit, PANEL_TRACK_WIDTH_BASE::m_TW_IntTrackWidth_choiceUnit, m_TWMode, PANEL_TRACK_WIDTH_BASE::m_TWResistivity, TW_MASTER_CURRENT, TW_MASTER_EXT_WIDTH, and TW_MASTER_INT_WIDTH.

Referenced by OnTWCalculateFromCurrent(), OnTWCalculateFromExtWidth(), and OnTWCalculateFromIntWidth().

◆ TWUpdateModeDisplay()

void PANEL_TRACK_WIDTH::TWUpdateModeDisplay ( )

Update the fields to show whether the maximum current, external trace width, or internal trace width is currently the controlling parameter.

Definition at line 334 of file panel_track_width.cpp.

335{
336 wxFont labelfont;
337 wxFont controlfont;
338
339 // Set the font weight of the current.
340 labelfont = m_staticTextCurrent->GetFont();
341 controlfont = m_TrackCurrentValue->GetFont();
342
344 {
345 labelfont.SetWeight( wxFONTWEIGHT_BOLD );
346 controlfont.SetWeight( wxFONTWEIGHT_BOLD );
347 }
348 else
349 {
350 labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
351 controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
352 }
353
354 m_staticTextCurrent->SetFont( labelfont );
355 m_TrackCurrentValue->SetFont( controlfont );
356
357 // Set the font weight of the external track width.
358 labelfont = m_staticTextExtWidth->GetFont();
359 controlfont = m_ExtTrackWidthValue->GetFont();
360
362 {
363 labelfont.SetWeight( wxFONTWEIGHT_BOLD );
364 controlfont.SetWeight( wxFONTWEIGHT_BOLD );
365 }
366 else
367 {
368 labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
369 controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
370 }
371
372 m_staticTextExtWidth->SetFont( labelfont );
373 m_ExtTrackWidthValue->SetFont( controlfont );
374
375 // Set the font weight of the internal track width.
376 labelfont = m_staticTextIntWidth->GetFont();
377 controlfont = m_IntTrackWidthValue->GetFont();
378
380 {
381 labelfont.SetWeight( wxFONTWEIGHT_BOLD );
382 controlfont.SetWeight( wxFONTWEIGHT_BOLD );
383 }
384 else
385 {
386 labelfont.SetWeight( wxFONTWEIGHT_NORMAL );
387 controlfont.SetWeight( wxFONTWEIGHT_NORMAL );
388 }
389
390 m_staticTextIntWidth->SetFont( labelfont );
391 m_IntTrackWidthValue->SetFont( controlfont );
392
393 // Text sizes have changed when the font weight was changes
394 // So, run the page layout to reflect the changes
395 GetSizer()->Layout();
396}

References PANEL_TRACK_WIDTH_BASE::m_ExtTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_IntTrackWidthValue, PANEL_TRACK_WIDTH_BASE::m_staticTextCurrent, PANEL_TRACK_WIDTH_BASE::m_staticTextExtWidth, PANEL_TRACK_WIDTH_BASE::m_staticTextIntWidth, PANEL_TRACK_WIDTH_BASE::m_TrackCurrentValue, m_TWMode, TW_MASTER_CURRENT, TW_MASTER_EXT_WIDTH, and TW_MASTER_INT_WIDTH.

Referenced by LoadSettings(), OnTWCalculateFromCurrent(), OnTWCalculateFromExtWidth(), and OnTWCalculateFromIntWidth().

Member Data Documentation

◆ m_buttonTrackWidthReset

wxButton* PANEL_TRACK_WIDTH_BASE::m_buttonTrackWidthReset
protectedinherited

◆ m_extTrackAreaUnitLabel

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_extTrackAreaUnitLabel
protectedinherited

◆ m_ExtTrackAreaValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_ExtTrackAreaValue
protectedinherited

◆ m_ExtTrackLossValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_ExtTrackLossValue
protectedinherited

◆ m_ExtTrackResistValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_ExtTrackResistValue
protectedinherited

◆ m_extTrackResUnits

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_extTrackResUnits
protectedinherited

◆ m_ExtTrackThicknessUnit

◆ m_ExtTrackThicknessValue

◆ m_ExtTrackVDropValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_ExtTrackVDropValue
protectedinherited

◆ m_ExtTrackWidthValue

◆ m_htmlWinFormulas

HTML_WINDOW* PANEL_TRACK_WIDTH_BASE::m_htmlWinFormulas
protectedinherited

◆ m_intTrackAreaUnitLabel

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_intTrackAreaUnitLabel
protectedinherited

◆ m_IntTrackAreaValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_IntTrackAreaValue
protectedinherited

◆ m_IntTrackLossValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_IntTrackLossValue
protectedinherited

◆ m_IntTrackResistValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_IntTrackResistValue
protectedinherited

◆ m_intTrackResUnits

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_intTrackResUnits
protectedinherited

◆ m_IntTrackThicknessUnit

◆ m_IntTrackThicknessValue

◆ m_IntTrackVDropValue

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_IntTrackVDropValue
protectedinherited

◆ m_IntTrackWidthValue

◆ m_resistivityUnits

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_resistivityUnits
protectedinherited

◆ m_staticline10

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline10
protectedinherited

◆ m_staticline3

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline3
protectedinherited

◆ m_staticline4

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline4
protectedinherited

◆ m_staticline5

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline5
protectedinherited

◆ m_staticline8

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline8
protectedinherited

◆ m_staticline9

wxStaticLine* PANEL_TRACK_WIDTH_BASE::m_staticline9
protectedinherited

◆ m_staticText103

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText103
protectedinherited

◆ m_staticText62

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText62
protectedinherited

◆ m_staticText63

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText63
protectedinherited

◆ m_staticText65

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText65
protectedinherited

◆ m_staticText651

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText651
protectedinherited

◆ m_staticText6511

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText6511
protectedinherited

◆ m_staticText652

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText652
protectedinherited

◆ m_staticText66

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText66
protectedinherited

◆ m_staticText661

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText661
protectedinherited

◆ m_staticText6611

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText6611
protectedinherited

◆ m_staticText79

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText79
protectedinherited

◆ m_staticText791

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText791
protectedinherited

◆ m_staticText7911

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText7911
protectedinherited

◆ m_staticText792

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText792
protectedinherited

◆ m_staticText83

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText83
protectedinherited

◆ m_staticText831

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticText831
protectedinherited

◆ m_staticTextArea

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticTextArea
protectedinherited

◆ m_staticTextArea1

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticTextArea1
protectedinherited

◆ m_staticTextCurrent

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticTextCurrent
protectedinherited

◆ m_staticTextExtWidth

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticTextExtWidth
protectedinherited

◆ m_staticTextIntWidth

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_staticTextIntWidth
protectedinherited

◆ m_TrackCurrentValue

◆ m_TrackDeltaTValue

◆ m_TrackLengthValue

wxTextCtrl* PANEL_TRACK_WIDTH_BASE::m_TrackLengthValue
protectedinherited

◆ m_trackTempUnits

wxStaticText* PANEL_TRACK_WIDTH_BASE::m_trackTempUnits
protectedinherited

◆ m_TW_CuLength_choiceUnit

◆ m_TW_ExtTrackWidth_choiceUnit

◆ m_TW_IntTrackWidth_choiceUnit

◆ 

◆ m_TWNested

bool PANEL_TRACK_WIDTH::m_TWNested
private

◆ m_TWResistivity

wxTextCtrl* PANEL_TRACK_WIDTH_BASE::m_TWResistivity
protectedinherited

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