From 8513ca974c28d76d9f74a7dc96601d98e66e87fd Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 13 May 2021 10:35:23 +0200 Subject: [PATCH] Pcb_calculator: track width tool: make resistivity value read only. The formula used to calculate the track width is valid only for copper tracks. So the resistivity value displayed in the panel is only for info, and cannot be modified. --- pcb_calculator/dialogs/pcb_calculator_frame_base.cpp | 8 ++++---- pcb_calculator/dialogs/pcb_calculator_frame_base.fbp | 8 ++++---- pcb_calculator/tracks_width_versus_current.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp index ba352d081b..f6b6e0ebe8 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp @@ -253,7 +253,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_panelRegulators->SetSizer( bSizerMainReg ); m_panelRegulators->Layout(); bSizerMainReg->Fit( m_panelRegulators ); - m_Notebook->AddPage( m_panelRegulators, _("Regulators"), false ); + m_Notebook->AddPage( m_panelRegulators, _("Regulators"), true ); m_panelAttenuators = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerAtt; bSizerAtt = new wxBoxSizer( wxHORIZONTAL ); @@ -1488,7 +1488,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_panelViaSize->SetSizer( bSizerViaSize ); m_panelViaSize->Layout(); bSizerViaSize->Fit( m_panelViaSize ); - m_Notebook->AddPage( m_panelViaSize, _("Via Size"), true ); + m_Notebook->AddPage( m_panelViaSize, _("Via Size"), false ); m_panelTrackWidth = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerTrackWidth; bSizerTrackWidth = new wxBoxSizer( wxHORIZONTAL ); @@ -1539,11 +1539,11 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_TW_CuLength_choiceUnit->SetSelection( 0 ); fgSizerTWprms->Add( m_TW_CuLength_choiceUnit, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT, 5 ); - m_staticText103 = new wxStaticText( sbSizerTW_Prms->GetStaticBox(), wxID_ANY, _("Resistivity:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText103 = new wxStaticText( sbSizerTW_Prms->GetStaticBox(), wxID_ANY, _("Copper resistivity:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText103->Wrap( -1 ); fgSizerTWprms->Add( m_staticText103, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxBOTTOM, 5 ); - m_TWResistivity = new wxTextCtrl( sbSizerTW_Prms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_TWResistivity = new wxTextCtrl( sbSizerTW_Prms->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY ); fgSizerTWprms->Add( m_TWResistivity, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_resistivityUnits = new wxStaticText( sbSizerTW_Prms->GetStaticBox(), wxID_ANY, _("ohm-meter"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp index c85b11e7e1..59ce5f47dd 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp @@ -144,7 +144,7 @@ Regulators - 0 + 1 1 1 @@ -12443,7 +12443,7 @@ Via Size - 1 + 0 1 1 @@ -17331,7 +17331,7 @@ 0 0 wxID_ANY - Resistivity: + Copper resistivity: 0 0 @@ -17410,7 +17410,7 @@ Resizable 1 - + wxTE_READONLY 0 diff --git a/pcb_calculator/tracks_width_versus_current.cpp b/pcb_calculator/tracks_width_versus_current.cpp index 6fd0c9f5da..31aa5a246d 100644 --- a/pcb_calculator/tracks_width_versus_current.cpp +++ b/pcb_calculator/tracks_width_versus_current.cpp @@ -41,6 +41,8 @@ wxString tracks_width_versus_current_formula = extern double DoubleFromString( const wxString& TextValue ); +// The IPC2221 formula used to calculate track width is valid only for copper material +const double copper_resistivity = 1.72e-8; void PCB_CALCULATOR_FRAME::writeTrackWidthConfig() { @@ -216,7 +218,7 @@ void PCB_CALCULATOR_FRAME::OnTWResetButtonClick( wxCommandEvent& event ) m_TrackDeltaTValue->SetValue( wxString::Format( "%g", 10.0 ) ); m_TrackLengthValue->SetValue( wxString::Format( "%g", 20.0 ) ); m_TW_CuLength_choiceUnit->SetSelection( 0 ); - m_TWResistivity->SetValue( wxString::Format( "%g", 1.72e-8 ) ); + m_TWResistivity->SetValue( wxString::Format( "%g", copper_resistivity ) ); m_ExtTrackWidthValue->SetValue( wxString::Format( "%g", 0.2 ) ); m_TW_ExtTrackWidth_choiceUnit->SetSelection( 0 ); m_ExtTrackThicknessValue->SetValue( wxString::Format( "%g", 0.035 ) ); @@ -429,7 +431,11 @@ void PCB_CALCULATOR_FRAME::initTrackWidthPanel() m_TrackDeltaTValue->SetValue( cfg->m_TrackWidth.delta_tc ); m_TrackLengthValue->SetValue( cfg->m_TrackWidth.track_len ); m_TW_CuLength_choiceUnit->SetSelection( cfg->m_TrackWidth.track_len_units ); +#if 0 // the IPC formula is valid for copper traces, so we do not currently adjust the resistivity m_TWResistivity->SetValue( cfg->m_TrackWidth.resistivity ); +#else + m_TWResistivity->SetValue( wxString::Format( "%g", copper_resistivity ) ); +#endif m_ExtTrackWidthValue->SetValue( cfg->m_TrackWidth.ext_track_width ); m_TW_ExtTrackWidth_choiceUnit->SetSelection( cfg->m_TrackWidth.ext_track_width_units ); m_ExtTrackThicknessValue->SetValue( cfg->m_TrackWidth.ext_track_thickness );