From c7faeeabea2457214c453312a254f2d83b28af61 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 5 Oct 2021 09:50:36 +0200 Subject: [PATCH] pcb_calculator rework: move electrical spacing panel to its own files panel_electrical_spacing_xx --- pcb_calculator/CMakeLists.txt | 5 +- .../dialogs/panel_electrical_spacing.h | 45 ++ .../dialogs/panel_electrical_spacing_base.cpp | 135 ++++ .../dialogs/panel_electrical_spacing_base.fbp | 613 ++++++++++++++++++ .../dialogs/panel_electrical_spacing_base.h | 64 ++ .../dialogs/pcb_calculator_frame_base.cpp | 114 +--- .../dialogs/pcb_calculator_frame_base.fbp | 565 +--------------- .../dialogs/pcb_calculator_frame_base.h | 14 +- ...alues.cpp => panel_electrical_spacing.cpp} | 66 +- pcb_calculator/pcb_calculator_frame.cpp | 13 +- pcb_calculator/pcb_calculator_frame.h | 6 - 11 files changed, 920 insertions(+), 720 deletions(-) create mode 100644 pcb_calculator/dialogs/panel_electrical_spacing.h create mode 100644 pcb_calculator/dialogs/panel_electrical_spacing_base.cpp create mode 100644 pcb_calculator/dialogs/panel_electrical_spacing_base.fbp create mode 100644 pcb_calculator/dialogs/panel_electrical_spacing_base.h rename pcb_calculator/{electrical_spacing_values.cpp => panel_electrical_spacing.cpp} (69%) diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index 28eee1bac7..971e7e2ea1 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -11,14 +11,14 @@ set( PCB_CALCULATOR_SRCS eserie.cpp board_classes_values.cpp common_data.cpp - electrical_spacing_values.cpp params_read_write.cpp pcb_calculator_frame.cpp pcb_calculator_settings.cpp datafile_read_write.cpp panel_attenuators.cpp - panel_regulator.cpp panel_color_code.cpp + panel_electrical_spacing.cpp + panel_regulator.cpp panel_track_width.cpp panel_via_size.cpp transline_ident.cpp @@ -41,6 +41,7 @@ set( PCB_CALCULATOR_SRCS dialogs/panel_color_code_base.cpp dialogs/panel_via_size_base.cpp dialogs/panel_track_width_base.cpp + dialogs/panel_electrical_spacing_base.cpp ../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found) ) diff --git a/pcb_calculator/dialogs/panel_electrical_spacing.h b/pcb_calculator/dialogs/panel_electrical_spacing.h new file mode 100644 index 0000000000..517ae2fdaa --- /dev/null +++ b/pcb_calculator/dialogs/panel_electrical_spacing.h @@ -0,0 +1,45 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 3 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef PANEL_ELECTRICAL_SPACING_H +#define PANEL_ELECTRICAL_SPACING_H + +#include "panel_electrical_spacing_base.h" + +class PCB_CALCULATOR_SETTINGS; + + +class PANEL_ELECTRICAL_SPACING : public PANEL_ELECTRICAL_SPACING_BASE +{ +public: + 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 ); + void SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ); + + void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) override; + void OnElectricalSpacingRefresh( wxCommandEvent& event ) override; + void ElectricalSpacingUpdateData( double aUnitScale ); +}; + +#endif \ No newline at end of file diff --git a/pcb_calculator/dialogs/panel_electrical_spacing_base.cpp b/pcb_calculator/dialogs/panel_electrical_spacing_base.cpp new file mode 100644 index 0000000000..5d0d5c8ee5 --- /dev/null +++ b/pcb_calculator/dialogs/panel_electrical_spacing_base.cpp @@ -0,0 +1,135 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "widgets/unit_selector.h" + +#include "panel_electrical_spacing_base.h" + +/////////////////////////////////////////////////////////////////////////// + +PANEL_ELECTRICAL_SPACING_BASE::PANEL_ELECTRICAL_SPACING_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) +{ + wxBoxSizer* bSizerElectricalClearance; + bSizerElectricalClearance = new wxBoxSizer( wxHORIZONTAL ); + + wxBoxSizer* bLeftSizerElectricalClearance; + bLeftSizerElectricalClearance = new wxBoxSizer( wxVERTICAL ); + + wxArrayString m_ElectricalSpacingUnitsSelectorChoices; + m_ElectricalSpacingUnitsSelector = new UNIT_SELECTOR_LEN( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ElectricalSpacingUnitsSelectorChoices, 0 ); + m_ElectricalSpacingUnitsSelector->SetSelection( -1 ); + m_ElectricalSpacingUnitsSelector->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT, false, wxEmptyString ) ); + + bLeftSizerElectricalClearance->Add( m_ElectricalSpacingUnitsSelector, 0, wxEXPAND|wxALL, 10 ); + + m_staticline2 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bLeftSizerElectricalClearance->Add( m_staticline2, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); + + m_staticText891 = new wxStaticText( this, wxID_ANY, _("Voltage > 500 V:"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText891->Wrap( -1 ); + bLeftSizerElectricalClearance->Add( m_staticText891, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_ElectricalSpacingVoltage = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizerElectricalClearance->Add( m_ElectricalSpacingVoltage, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_buttonElectSpacingRefresh = new wxButton( this, wxID_ANY, _("Update Values"), wxDefaultPosition, wxDefaultSize, 0 ); + bLeftSizerElectricalClearance->Add( m_buttonElectSpacingRefresh, 0, wxEXPAND|wxALL, 5 ); + + + bSizerElectricalClearance->Add( bLeftSizerElectricalClearance, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + + m_electricalSpacingSizer = new wxBoxSizer( wxVERTICAL ); + + m_staticTextElectricalSpacing = new wxStaticText( this, wxID_ANY, _("Note: Values are minimal values (from IPC 2221)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextElectricalSpacing->Wrap( -1 ); + m_staticTextElectricalSpacing->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); + + m_electricalSpacingSizer->Add( m_staticTextElectricalSpacing, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 ); + + m_gridElectricalSpacingValues = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_gridElectricalSpacingValues->CreateGrid( 10, 7 ); + m_gridElectricalSpacingValues->EnableEditing( false ); + m_gridElectricalSpacingValues->EnableGridLines( true ); + m_gridElectricalSpacingValues->EnableDragGridSize( false ); + m_gridElectricalSpacingValues->SetMargins( 0, 0 ); + + // Columns + m_gridElectricalSpacingValues->SetColSize( 0, 100 ); + m_gridElectricalSpacingValues->SetColSize( 1, 100 ); + m_gridElectricalSpacingValues->SetColSize( 2, 100 ); + m_gridElectricalSpacingValues->SetColSize( 3, 100 ); + m_gridElectricalSpacingValues->SetColSize( 4, 100 ); + m_gridElectricalSpacingValues->SetColSize( 5, 100 ); + m_gridElectricalSpacingValues->SetColSize( 6, 100 ); + m_gridElectricalSpacingValues->EnableDragColMove( false ); + m_gridElectricalSpacingValues->EnableDragColSize( true ); + m_gridElectricalSpacingValues->SetColLabelSize( 30 ); + m_gridElectricalSpacingValues->SetColLabelValue( 0, _("B1") ); + m_gridElectricalSpacingValues->SetColLabelValue( 1, _("B2") ); + m_gridElectricalSpacingValues->SetColLabelValue( 2, _("B3") ); + m_gridElectricalSpacingValues->SetColLabelValue( 3, _("B4") ); + m_gridElectricalSpacingValues->SetColLabelValue( 4, _("A5") ); + m_gridElectricalSpacingValues->SetColLabelValue( 5, _("A6") ); + m_gridElectricalSpacingValues->SetColLabelValue( 6, _("A7") ); + m_gridElectricalSpacingValues->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); + + // Rows + m_gridElectricalSpacingValues->SetRowSize( 0, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 1, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 2, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 3, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 4, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 5, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 6, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 7, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 8, 24 ); + m_gridElectricalSpacingValues->SetRowSize( 9, 24 ); + m_gridElectricalSpacingValues->EnableDragRowSize( false ); + m_gridElectricalSpacingValues->SetRowLabelSize( 100 ); + m_gridElectricalSpacingValues->SetRowLabelValue( 0, _("0 .. 15 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 1, _("16 .. 30 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 2, _("31 .. 50 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 3, _("51 .. 100 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 4, _("101 .. 150 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 5, _("151 .. 170 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 6, _("171 .. 250 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 7, _("251 .. 300 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 8, _("301 .. 500 V") ); + m_gridElectricalSpacingValues->SetRowLabelValue( 9, _(" > 500 V") ); + m_gridElectricalSpacingValues->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER ); + + // Label Appearance + + // Cell Defaults + m_gridElectricalSpacingValues->SetDefaultCellAlignment( wxALIGN_CENTER, wxALIGN_TOP ); + m_electricalSpacingSizer->Add( m_gridElectricalSpacingValues, 0, wxALL, 5 ); + + m_staticText88 = new wxStaticText( this, wxID_ANY, _("* B1 - Internal Conductors\n* B2 - External Conductors, uncoated, sea level to 3050 m\n* B3 - External Conductors, uncoated, over 3050 m\n* B4 - External Conductors, with permanent polymer coating (any elevation)\n* A5 - External Conductors, with conformal coating over assembly (any elevation)\n* A6 - External Component lead/termination, uncoated\n* A7 - External Component lead termination, with conformal coating (any elevation)"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText88->Wrap( -1 ); + m_electricalSpacingSizer->Add( m_staticText88, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + + bSizerElectricalClearance->Add( m_electricalSpacingSizer, 1, wxEXPAND|wxLEFT, 20 ); + + + this->SetSizer( bSizerElectricalClearance ); + this->Layout(); + + // Connect Events + m_ElectricalSpacingUnitsSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_ELECTRICAL_SPACING_BASE::OnElectricalSpacingUnitsSelection ), NULL, this ); + m_buttonElectSpacingRefresh->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ELECTRICAL_SPACING_BASE::OnElectricalSpacingRefresh ), NULL, this ); +} + +PANEL_ELECTRICAL_SPACING_BASE::~PANEL_ELECTRICAL_SPACING_BASE() +{ + // Disconnect Events + m_ElectricalSpacingUnitsSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_ELECTRICAL_SPACING_BASE::OnElectricalSpacingUnitsSelection ), NULL, this ); + m_buttonElectSpacingRefresh->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PANEL_ELECTRICAL_SPACING_BASE::OnElectricalSpacingRefresh ), NULL, this ); + +} diff --git a/pcb_calculator/dialogs/panel_electrical_spacing_base.fbp b/pcb_calculator/dialogs/panel_electrical_spacing_base.fbp new file mode 100644 index 0000000000..6cbc7e3ead --- /dev/null +++ b/pcb_calculator/dialogs/panel_electrical_spacing_base.fbp @@ -0,0 +1,613 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + panel_electrical_spacing_base + 1000 + none + + 1 + panel_electrical_spacing_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + PANEL_ELECTRICAL_SPACING_BASE + + 500,300 + ; ; forward_declare + + + + wxTAB_TRAVERSAL + + + bSizerElectricalClearance + wxHORIZONTAL + none + + 5 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT + 0 + + + bLeftSizerElectricalClearance + wxVERTICAL + none + + 10 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,90,91,-1,70,0 + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_ElectricalSpacingUnitsSelector + 1 + + + protected + 1 + + Resizable + -1 + 1 + + + UNIT_SELECTOR_LEN; widgets/unit_selector.h + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnElectricalSpacingUnitsSelection + + + + 10 + wxEXPAND|wxTOP|wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline2 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + + 0 + + + + + + + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Voltage > 500 V: + 0 + + 0 + + + 0 + + 1 + m_staticText891 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 0 + + 0 + + 1 + m_ElectricalSpacingVoltage + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + 5 + wxEXPAND|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + + 0 + 0 + + Dock + 0 + Left + 1 + + 1 + + + 0 + 0 + wxID_ANY + Update Values + + 0 + + 0 + + + 0 + + 1 + m_buttonElectSpacingRefresh + 1 + + + protected + 1 + + + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnElectricalSpacingRefresh + + + + + + 20 + wxEXPAND|wxLEFT + 1 + + + m_electricalSpacingSizer + wxVERTICAL + protected + + 5 + wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + ,93,92,-1,70,0 + 0 + 0 + wxID_ANY + Note: Values are minimal values (from IPC 2221) + 0 + + 0 + + + 0 + + 1 + m_staticTextElectricalSpacing + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_CENTER + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTER + 30 + "B1" "B2" "B3" "B4" "A5" "A6" "A7" + wxALIGN_CENTER + 7 + 100,100,100,100,100,100,100 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 0 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + m_gridElectricalSpacingValues + 1 + + + protected + 1 + + Resizable + wxALIGN_RIGHT + 100 + "0 .. 15 V" "16 .. 30 V" "31 .. 50 V" "51 .. 100 V" "101 .. 150 V" "151 .. 170 V" "171 .. 250 V" "251 .. 300 V" "301 .. 500 V" " > 500 V" + wxALIGN_CENTER + 24,24,24,24,24,24,24,24,24,24 + 10 + 1 + + + 0 + + + + + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + * B1 - Internal Conductors * B2 - External Conductors, uncoated, sea level to 3050 m * B3 - External Conductors, uncoated, over 3050 m * B4 - External Conductors, with permanent polymer coating (any elevation) * A5 - External Conductors, with conformal coating over assembly (any elevation) * A6 - External Component lead/termination, uncoated * A7 - External Component lead termination, with conformal coating (any elevation) + 0 + + 0 + + + 0 + + 1 + m_staticText88 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + diff --git a/pcb_calculator/dialogs/panel_electrical_spacing_base.h b/pcb_calculator/dialogs/panel_electrical_spacing_base.h new file mode 100644 index 0000000000..18487813e9 --- /dev/null +++ b/pcb_calculator/dialogs/panel_electrical_spacing_base.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +class UNIT_SELECTOR_LEN; + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class PANEL_ELECTRICAL_SPACING_BASE +/////////////////////////////////////////////////////////////////////////////// +class PANEL_ELECTRICAL_SPACING_BASE : public wxPanel +{ + private: + + protected: + UNIT_SELECTOR_LEN* m_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; + + // Virtual event handlers, overide them in your derived class + virtual void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) { event.Skip(); } + virtual void OnElectricalSpacingRefresh( wxCommandEvent& event ) { event.Skip(); } + + + public: + + 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 ); + ~PANEL_ELECTRICAL_SPACING_BASE(); + +}; + diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp index 9e75406a6d..f302f5e5c9 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp @@ -678,115 +678,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_Notebook->AddPage( m_panelViaSize, _("Via Size"), false ); m_panelTrackWidth = new PANEL_TRACK_WIDTH( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_Notebook->AddPage( m_panelTrackWidth, _("Track Width"), false ); - m_panelElectricalSpacing = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - wxBoxSizer* bSizerElectricalClearance; - bSizerElectricalClearance = new wxBoxSizer( wxHORIZONTAL ); - - wxBoxSizer* bLeftSizerElectricalClearance; - bLeftSizerElectricalClearance = new wxBoxSizer( wxVERTICAL ); - - wxArrayString m_ElectricalSpacingUnitsSelectorChoices; - m_ElectricalSpacingUnitsSelector = new UNIT_SELECTOR_LEN( m_panelElectricalSpacing, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ElectricalSpacingUnitsSelectorChoices, 0 ); - m_ElectricalSpacingUnitsSelector->SetSelection( -1 ); - m_ElectricalSpacingUnitsSelector->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT, false, wxEmptyString ) ); - - bLeftSizerElectricalClearance->Add( m_ElectricalSpacingUnitsSelector, 0, wxEXPAND|wxALL, 10 ); - - m_staticline2 = new wxStaticLine( m_panelElectricalSpacing, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bLeftSizerElectricalClearance->Add( m_staticline2, 0, wxEXPAND|wxTOP|wxBOTTOM, 10 ); - - m_staticText891 = new wxStaticText( m_panelElectricalSpacing, wxID_ANY, _("Voltage > 500 V:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText891->Wrap( -1 ); - bLeftSizerElectricalClearance->Add( m_staticText891, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_ElectricalSpacingVoltage = new wxTextCtrl( m_panelElectricalSpacing, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); - bLeftSizerElectricalClearance->Add( m_ElectricalSpacingVoltage, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - m_buttonElectSpacingRefresh = new wxButton( m_panelElectricalSpacing, wxID_ANY, _("Update Values"), wxDefaultPosition, wxDefaultSize, 0 ); - bLeftSizerElectricalClearance->Add( m_buttonElectSpacingRefresh, 0, wxEXPAND|wxALL, 5 ); - - - bSizerElectricalClearance->Add( bLeftSizerElectricalClearance, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); - - m_electricalSpacingSizer = new wxBoxSizer( wxVERTICAL ); - - m_staticTextElectricalSpacing = new wxStaticText( m_panelElectricalSpacing, wxID_ANY, _("Note: Values are minimal values (from IPC 2221)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextElectricalSpacing->Wrap( -1 ); - m_staticTextElectricalSpacing->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - m_electricalSpacingSizer->Add( m_staticTextElectricalSpacing, 0, wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT, 5 ); - - m_gridElectricalSpacingValues = new wxGrid( m_panelElectricalSpacing, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); - - // Grid - m_gridElectricalSpacingValues->CreateGrid( 10, 7 ); - m_gridElectricalSpacingValues->EnableEditing( false ); - m_gridElectricalSpacingValues->EnableGridLines( true ); - m_gridElectricalSpacingValues->EnableDragGridSize( false ); - m_gridElectricalSpacingValues->SetMargins( 0, 0 ); - - // Columns - m_gridElectricalSpacingValues->SetColSize( 0, 100 ); - m_gridElectricalSpacingValues->SetColSize( 1, 100 ); - m_gridElectricalSpacingValues->SetColSize( 2, 100 ); - m_gridElectricalSpacingValues->SetColSize( 3, 100 ); - m_gridElectricalSpacingValues->SetColSize( 4, 100 ); - m_gridElectricalSpacingValues->SetColSize( 5, 100 ); - m_gridElectricalSpacingValues->SetColSize( 6, 100 ); - m_gridElectricalSpacingValues->EnableDragColMove( false ); - m_gridElectricalSpacingValues->EnableDragColSize( true ); - m_gridElectricalSpacingValues->SetColLabelSize( 30 ); - m_gridElectricalSpacingValues->SetColLabelValue( 0, _("B1") ); - m_gridElectricalSpacingValues->SetColLabelValue( 1, _("B2") ); - m_gridElectricalSpacingValues->SetColLabelValue( 2, _("B3") ); - m_gridElectricalSpacingValues->SetColLabelValue( 3, _("B4") ); - m_gridElectricalSpacingValues->SetColLabelValue( 4, _("A5") ); - m_gridElectricalSpacingValues->SetColLabelValue( 5, _("A6") ); - m_gridElectricalSpacingValues->SetColLabelValue( 6, _("A7") ); - m_gridElectricalSpacingValues->SetColLabelAlignment( wxALIGN_CENTER, wxALIGN_CENTER ); - - // Rows - m_gridElectricalSpacingValues->SetRowSize( 0, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 1, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 2, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 3, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 4, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 5, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 6, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 7, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 8, 24 ); - m_gridElectricalSpacingValues->SetRowSize( 9, 24 ); - m_gridElectricalSpacingValues->EnableDragRowSize( false ); - m_gridElectricalSpacingValues->SetRowLabelSize( 100 ); - m_gridElectricalSpacingValues->SetRowLabelValue( 0, _("0 .. 15 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 1, _("16 .. 30 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 2, _("31 .. 50 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 3, _("51 .. 100 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 4, _("101 .. 150 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 5, _("151 .. 170 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 6, _("171 .. 250 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 7, _("251 .. 300 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 8, _("301 .. 500 V") ); - m_gridElectricalSpacingValues->SetRowLabelValue( 9, _(" > 500 V") ); - m_gridElectricalSpacingValues->SetRowLabelAlignment( wxALIGN_RIGHT, wxALIGN_CENTER ); - - // Label Appearance - - // Cell Defaults - m_gridElectricalSpacingValues->SetDefaultCellAlignment( wxALIGN_CENTER, wxALIGN_TOP ); - m_electricalSpacingSizer->Add( m_gridElectricalSpacingValues, 0, wxALL, 5 ); - - m_staticText88 = new wxStaticText( m_panelElectricalSpacing, wxID_ANY, _("* B1 - Internal Conductors\n* B2 - External Conductors, uncoated, sea level to 3050 m\n* B3 - External Conductors, uncoated, over 3050 m\n* B4 - External Conductors, with permanent polymer coating (any elevation)\n* A5 - External Conductors, with conformal coating over assembly (any elevation)\n* A6 - External Component lead/termination, uncoated\n* A7 - External Component lead termination, with conformal coating (any elevation)"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText88->Wrap( -1 ); - m_electricalSpacingSizer->Add( m_staticText88, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - bSizerElectricalClearance->Add( m_electricalSpacingSizer, 1, wxEXPAND|wxLEFT, 20 ); - - - m_panelElectricalSpacing->SetSizer( bSizerElectricalClearance ); - m_panelElectricalSpacing->Layout(); - bSizerElectricalClearance->Fit( m_panelElectricalSpacing ); + m_panelElectricalSpacing = new PANEL_ELECTRICAL_SPACING( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_Notebook->AddPage( m_panelElectricalSpacing, _("Electrical Spacing"), false ); m_panelBoardClass = new wxPanel( m_Notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizerBoardClass; @@ -898,8 +790,6 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow m_SynthetizeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSynthetize ), NULL, this ); m_bpButtonSynthetize->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSynthetize ), NULL, this ); m_buttonTransLineReset->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTransLineResetButtonClick ), NULL, this ); - m_ElectricalSpacingUnitsSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingUnitsSelection ), NULL, this ); - m_buttonElectSpacingRefresh->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingRefresh ), NULL, this ); m_BoardClassesUnitsSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnBoardClassesUnitsSelection ), NULL, this ); } @@ -922,8 +812,6 @@ PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE() m_SynthetizeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSynthetize ), NULL, this ); m_bpButtonSynthetize->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTranslineSynthetize ), NULL, this ); m_buttonTransLineReset->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnTransLineResetButtonClick ), NULL, this ); - m_ElectricalSpacingUnitsSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingUnitsSelection ), NULL, this ); - m_buttonElectSpacingRefresh->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnElectricalSpacingRefresh ), NULL, this ); m_BoardClassesUnitsSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnBoardClassesUnitsSelection ), NULL, this ); } diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp index 2d38d264b0..df468b6738 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp @@ -7824,11 +7824,11 @@ wxTAB_TRAVERSAL - + Electrical Spacing 0 - + 1 1 1 @@ -7873,571 +7873,12 @@ Resizable 1 - + PANEL_ELECTRICAL_SPACING; panel_electrical_spacing.h; Not forward_declare 0 wxTAB_TRAVERSAL - - - bSizerElectricalClearance - wxHORIZONTAL - none - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxLEFT - 0 - - - bLeftSizerElectricalClearance - wxVERTICAL - none - - 10 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,91,-1,70,0 - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_ElectricalSpacingUnitsSelector - 1 - - - protected - 1 - - Resizable - -1 - 1 - - - UNIT_SELECTOR_LEN; widgets/unit_selector.h - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnElectricalSpacingUnitsSelection - - - - 10 - wxEXPAND|wxTOP|wxBOTTOM - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_staticline2 - 1 - - - protected - 1 - - Resizable - 1 - - wxLI_HORIZONTAL - - 0 - - - - - - - - 5 - wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Voltage > 500 V: - 0 - - 0 - - - 0 - - 1 - m_staticText891 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - 0 - - 0 - - 1 - m_ElectricalSpacingVoltage - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - 5 - wxEXPAND|wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - - 1 - 0 - 1 - - 1 - - 0 - 0 - - Dock - 0 - Left - 1 - - 1 - - - 0 - 0 - wxID_ANY - Update Values - - 0 - - 0 - - - 0 - - 1 - m_buttonElectSpacingRefresh - 1 - - - protected - 1 - - - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnElectricalSpacingRefresh - - - - - - 20 - wxEXPAND|wxLEFT - 1 - - - m_electricalSpacingSizer - wxVERTICAL - protected - - 5 - wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,93,92,-1,70,0 - 0 - 0 - wxID_ANY - Note: Values are minimal values (from IPC 2221) - 0 - - 0 - - - 0 - - 1 - m_staticTextElectricalSpacing - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - 0 - 0 - - - - 1 - - - wxALIGN_CENTER - - wxALIGN_TOP - 0 - 1 - wxALIGN_CENTER - 30 - "B1" "B2" "B3" "B4" "A5" "A6" "A7" - wxALIGN_CENTER - 7 - 100,100,100,100,100,100,100 - - 1 - 0 - Dock - 0 - Left - 0 - 1 - 0 - 0 - 0 - 1 - - 1 - - - 1 - 0 - 0 - wxID_ANY - - - - 0 - 0 - - 0 - - - 0 - - 1 - m_gridElectricalSpacingValues - 1 - - - protected - 1 - - Resizable - wxALIGN_RIGHT - 100 - "0 .. 15 V" "16 .. 30 V" "31 .. 50 V" "51 .. 100 V" "101 .. 150 V" "151 .. 170 V" "171 .. 250 V" "251 .. 300 V" "301 .. 500 V" " > 500 V" - wxALIGN_CENTER - 24,24,24,24,24,24,24,24,24,24 - 10 - 1 - - - 0 - - - - - - - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - * B1 - Internal Conductors * B2 - External Conductors, uncoated, sea level to 3050 m * B3 - External Conductors, uncoated, over 3050 m * B4 - External Conductors, with permanent polymer coating (any elevation) * A5 - External Conductors, with conformal coating over assembly (any elevation) * A6 - External Component lead/termination, uncoated * A7 - External Component lead termination, with conformal coating (any elevation) - 0 - - 0 - - - 0 - - 1 - m_staticText88 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.h b/pcb_calculator/dialogs/pcb_calculator_frame_base.h index 4ab60ec3b0..e7caff747a 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.h +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.h @@ -20,6 +20,7 @@ class UNIT_SELECTOR_RESISTOR; #include "panel_color_code.h" #include "panel_via_size.h" #include "panel_track_width.h" +#include "panel_electrical_spacing.h" #include "kiway_player.h" #include #include @@ -176,16 +177,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER wxButton* m_buttonTransLineReset; PANEL_VIA_SIZE* m_panelViaSize; PANEL_TRACK_WIDTH* m_panelTrackWidth; - wxPanel* m_panelElectricalSpacing; - UNIT_SELECTOR_LEN* m_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; + PANEL_ELECTRICAL_SPACING* m_panelElectricalSpacing; wxPanel* m_panelBoardClass; UNIT_SELECTOR_LEN* m_BoardClassesUnitsSelector; wxStaticText* m_staticTextBrdClass; @@ -204,8 +196,6 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER virtual void OnTranslineAnalyse( wxCommandEvent& event ) { event.Skip(); } virtual void OnTranslineSynthetize( wxCommandEvent& event ) { event.Skip(); } virtual void OnTransLineResetButtonClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) { event.Skip(); } - virtual void OnElectricalSpacingRefresh( wxCommandEvent& event ) { event.Skip(); } virtual void OnBoardClassesUnitsSelection( wxCommandEvent& event ) { event.Skip(); } diff --git a/pcb_calculator/electrical_spacing_values.cpp b/pcb_calculator/panel_electrical_spacing.cpp similarity index 69% rename from pcb_calculator/electrical_spacing_values.cpp rename to pcb_calculator/panel_electrical_spacing.cpp index e91309578d..b02a602f3a 100644 --- a/pcb_calculator/electrical_spacing_values.cpp +++ b/pcb_calculator/panel_electrical_spacing.cpp @@ -2,11 +2,11 @@ * This program source code file is part of KICAD, a free EDA CAD application. * * Copyright (C) 2011 jean-pierre.charras - * Copyright (C) 2011 Kicad Developers, see change_log.txt for contributors. + * Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 + * as published by the Free Software Foundation; either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -14,21 +14,27 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . */ -#include +/* see + * http://www.desmith.net/NMdS/Electronics/TraceWidth.html + * http://www.ultracad.com/articles/pcbtemp.pdf + * for more info + */ -#include "pcb_calculator_frame.h" +#include +#include "pcb_calculator_settings.h" +#include +#include #include "units_scales.h" 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; + #define VALUE_COUNT 7 #define CLASS_COUNT 10 @@ -98,22 +104,54 @@ static double clist[CLASS_COUNT][VALUE_COUNT] = // These last values are used to calculate spacing for voltage > 500V // there are not the spacing { 0.0025 * UNIT_MM, 0.005 * UNIT_MM, 0.025 * UNIT_MM, 0.00305 * UNIT_MM, - 0.00305 * UNIT_MM, 0.00305 * UNIT_MM, 0.00305 * UNIT_MM }, // > 500V + 0.00305 * UNIT_MM, 0.00305 * UNIT_MM, 0.00305 * UNIT_MM }, // > 500V }; -void PCB_CALCULATOR_FRAME::OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) +PANEL_ELECTRICAL_SPACING::PANEL_ELECTRICAL_SPACING( wxWindow* parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + long style, const wxString& name ) : + PANEL_ELECTRICAL_SPACING_BASE( parent, id, pos, size, style, name ) +{ + // Autosize the row label column to be sure label are not truncated + m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE ); +} + + +PANEL_ELECTRICAL_SPACING::~PANEL_ELECTRICAL_SPACING() +{ +} + + +void PANEL_ELECTRICAL_SPACING::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) +{ + aCfg->m_Electrical.spacing_units = m_ElectricalSpacingUnitsSelector->GetSelection(); + aCfg->m_Electrical.spacing_voltage = m_ElectricalSpacingVoltage->GetValue(); +} + + +void PANEL_ELECTRICAL_SPACING::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) +{ + m_ElectricalSpacingUnitsSelector->SetSelection( aCfg->m_Electrical.spacing_units ); + m_ElectricalSpacingVoltage->SetValue( aCfg->m_Electrical.spacing_voltage ); + + ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); +} + + + +void PANEL_ELECTRICAL_SPACING::OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) { ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); } -void PCB_CALCULATOR_FRAME::OnElectricalSpacingRefresh( wxCommandEvent& event ) +void PANEL_ELECTRICAL_SPACING::OnElectricalSpacingRefresh( wxCommandEvent& event ) { ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); } -void PCB_CALCULATOR_FRAME::ElectricalSpacingUpdateData( double aUnitScale ) +void PANEL_ELECTRICAL_SPACING::ElectricalSpacingUpdateData( double aUnitScale ) { wxString txt; double voltage = 500.0; // to calculate values at V > 500V diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index 9fd5094d29..9a48144752 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -78,8 +78,6 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : BoardClassesUpdateData( m_BoardClassesUnitsSelector->GetUnitScale() ); - ElectricalSpacingUpdateData( m_ElectricalSpacingUnitsSelector->GetUnitScale() ); - // Give an icon wxIcon icon; wxIconBundle icon_bundle; @@ -95,7 +93,6 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : // Autosize the row label column to be sure label are not truncated m_gridClassesValuesDisplay->SetRowLabelSize( wxGRID_AUTOSIZE ); - m_gridElectricalSpacingValues->SetRowLabelSize( wxGRID_AUTOSIZE ); GetSizer()->SetSizeHints( this ); @@ -234,16 +231,12 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg ) // color panel config: m_panelColorCode->LoadSettings( cfg ); - // Electrical panel config - m_ElectricalSpacingUnitsSelector->SetSelection( cfg->m_Electrical.spacing_units ); - m_ElectricalSpacingVoltage->SetValue( cfg->m_Electrical.spacing_voltage ); - for( TRANSLINE_IDENT* transline : m_transline_list ) transline->ReadConfig(); m_panelViaSize->LoadSettings( cfg ); - m_panelTrackWidth->LoadSettings( cfg ); + m_panelElectricalSpacing->LoadSettings( cfg ); } @@ -263,14 +256,12 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg ) cfg->m_TransLine.type = m_currTransLineType; cfg->m_BoardClassUnits = m_BoardClassesUnitsSelector->GetSelection(); - cfg->m_Electrical.spacing_units = m_ElectricalSpacingUnitsSelector->GetSelection(); - cfg->m_Electrical.spacing_voltage = m_ElectricalSpacingVoltage->GetValue(); - m_panelRegulators->Regulators_WriteConfig( cfg ); m_panelAttenuators->SaveSettings( cfg ); m_panelColorCode->SaveSettings( cfg ); m_panelViaSize->SaveSettings( cfg ); m_panelTrackWidth->SaveSettings( cfg ); + m_panelElectricalSpacing->SaveSettings( cfg ); } diff --git a/pcb_calculator/pcb_calculator_frame.h b/pcb_calculator/pcb_calculator_frame.h index b84ab5862e..ec14c3fd6d 100644 --- a/pcb_calculator/pcb_calculator_frame.h +++ b/pcb_calculator/pcb_calculator_frame.h @@ -116,12 +116,6 @@ private: */ void OnESeriesSelection( wxCommandEvent& event ) override; - - // Electrical spacing panel: - void OnElectricalSpacingUnitsSelection( wxCommandEvent& event ) override; - void OnElectricalSpacingRefresh( wxCommandEvent& event ) override; - void ElectricalSpacingUpdateData( double aUnitScale ); - /** * Called on new transmission line selection. */