Simplify code.

This commit is contained in:
Jeff Young 2023-01-27 22:41:05 +00:00
parent 7ca951c89a
commit f5f98f0174
15 changed files with 65 additions and 101 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -23,9 +23,8 @@
#include <widgets/unit_selector.h>
#include <units_scales.h>
PANEL_BOARD_CLASS::PANEL_BOARD_CLASS( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_BOARD_CLASS::PANEL_BOARD_CLASS( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_BOARD_CLASS_BASE( parent, id, pos, size, style, name )
{
// Autosize the row label column to be sure label are not truncated

View File

@ -1,7 +1,7 @@
/*
* 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.
* Copyright (C) 1992-2023 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
@ -29,9 +29,8 @@ class PANEL_BOARD_CLASS : public PANEL_BOARD_CLASS_BASE
{
public:
PANEL_BOARD_CLASS( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_BOARD_CLASS();
// Methods from CALCULATOR_PANEL that must be overridden

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -23,9 +23,8 @@
#include <pcb_calculator_settings.h>
PANEL_COLOR_CODE::PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_COLOR_CODE::PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_COLOR_CODE_BASE( parent, id, pos, size, style, name )
{
ToleranceSelection( m_rbToleranceSelection->GetSelection() );

View File

@ -28,9 +28,8 @@ class PANEL_COLOR_CODE : public PANEL_COLOR_CODE_BASE
{
public:
PANEL_COLOR_CODE( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_COLOR_CODE();
void OnToleranceSelection( wxCommandEvent& event ) override;

View File

@ -1,7 +1,7 @@
/*
* 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.
* Copyright (C) 1992-2023 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
@ -29,9 +29,9 @@ 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 );
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_ELECTRICAL_SPACING();
// Methods from CALCULATOR_PANEL that must be overridden

View File

@ -33,8 +33,9 @@ CORROSION_TABLE_ENTRY::CORROSION_TABLE_ENTRY( const wxString& aName, const wxStr
m_potential = aPotential;
}
PANEL_GALVANIC_CORROSION::PANEL_GALVANIC_CORROSION( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_GALVANIC_CORROSION::PANEL_GALVANIC_CORROSION( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_GALVANIC_CORROSION_BASE( parent, id, pos, size, style, name )
{
m_entries.clear();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2011 jean-pierre.charras
* Copyright (C) 1992-2021 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -18,9 +18,6 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//#include <macros.h>
#include <wx/choicdlg.h>
#include <wx/filedlg.h>
#include <wx/msgdlg.h>
@ -37,9 +34,8 @@ extern double DoubleFromString( const wxString& TextValue );
static const wxString DataFileNameExt( wxT( "pcbcalc" ) );
PANEL_REGULATOR::PANEL_REGULATOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_REGULATOR::PANEL_REGULATOR( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_REGULATOR_BASE( parent, id, pos, size, style, name ),
m_RegulatorListChanged( false )
{
@ -155,11 +151,11 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
wxString fullfilename = GetDataFilename();
wxString wildcard;
wildcard.Printf( _("PCB Calculator data file" ) + wxT( " (*.%s)|*.%s"),
wildcard.Printf( _( "PCB Calculator data file" ) + wxT( " (*.%s)|*.%s" ),
DataFileNameExt, DataFileNameExt );
wxFileDialog dlg( this, _("Select PCB Calculator Data File"),
wxEmptyString, fullfilename, wildcard, wxFD_OPEN );
wxFileDialog dlg( this, _( "Select PCB Calculator Data File" ), wxEmptyString, fullfilename,
wildcard, wxFD_OPEN );
if( dlg.ShowModal() == wxID_CANCEL )
return;
@ -190,7 +186,7 @@ void PANEL_REGULATOR::OnDataFileSelection( wxCommandEvent& event )
else
{
wxString msg;
msg.Printf( _("Unable to read data file '%s'."), fullfilename );
msg.Printf( _( "Unable to read data file '%s'." ), fullfilename );
wxMessageBox( msg );
}
}
@ -218,7 +214,7 @@ void PANEL_REGULATOR::OnAddRegulator( wxCommandEvent& event )
}
else
{
wxMessageBox( _("This regulator is already in list. Aborted") );
wxMessageBox( _( "This regulator is already in list. Aborted" ) );
delete new_item;
}
}
@ -250,7 +246,7 @@ void PANEL_REGULATOR::OnEditRegulator( wxCommandEvent& event )
void PANEL_REGULATOR::OnRemoveRegulator( wxCommandEvent& event )
{
wxString name = wxGetSingleChoice( _("Remove Regulator"), wxEmptyString,
wxString name = wxGetSingleChoice( _( "Remove Regulator" ), wxEmptyString,
m_RegulatorList.GetRegList() );
if( name.IsEmpty() )
return;
@ -335,7 +331,7 @@ void PANEL_REGULATOR::RegulatorsSolve()
// Some tests:
if( vout < vref && id != 2 )
{
m_RegulMessage->SetLabel( _("Vout must be greater than vref" ) );
m_RegulMessage->SetLabel( _( "Vout must be greater than vref" ) );
return;
}
@ -347,7 +343,7 @@ void PANEL_REGULATOR::RegulatorsSolve()
if( ( r1 < 0 && id != 0 ) || ( r2 <= 0 && id != 1 ) )
{
m_RegulMessage->SetLabel( _("Incorrect value for R1 R2" ) );
m_RegulMessage->SetLabel( _( "Incorrect value for R1 R2" ) );
return;
}

View File

@ -28,8 +28,7 @@ class PANEL_REGULATOR : public PANEL_REGULATOR_BASE
{
public:
PANEL_REGULATOR( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_REGULATOR();

View File

@ -1,7 +1,7 @@
/*
* 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.
* Copyright (C) 1992-2023 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
@ -31,9 +31,9 @@ class PANEL_RF_ATTENUATORS : public PANEL_RF_ATTENUATORS_BASE
{
public:
PANEL_RF_ATTENUATORS( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_RF_ATTENUATORS();
wxRadioBox* GetAttenuatorsSelector() { return m_AttenuatorsSelection; }

View File

@ -29,9 +29,8 @@ class PANEL_TRACK_WIDTH : public PANEL_TRACK_WIDTH_BASE
{
public:
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 );
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_TRACK_WIDTH();
// Methods from CALCULATOR_PANEL that must be overridden

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2011 jean-pierre.charras
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -26,9 +26,8 @@
#include <widgets/std_bitmap_button.h>
PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name ) :
PANEL_TRANSLINE::PANEL_TRANSLINE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_TRANSLINE_BASE( parent, id, pos, size, style, name ),
m_currTransLine( nullptr ),
m_currTransLineType( DEFAULT_TYPE )

View File

@ -1,7 +1,7 @@
/*
* 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.
* Copyright (C) 1992-2023 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
@ -31,8 +31,7 @@ class PANEL_TRANSLINE : public PANEL_TRANSLINE_BASE
{
public:
PANEL_TRANSLINE( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_TRANSLINE();

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2022 Kicad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -29,9 +29,8 @@ class PANEL_VIA_SIZE : public PANEL_VIA_SIZE_BASE
{
public:
PANEL_VIA_SIZE( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_VIA_SIZE();
// Methods from CALCULATOR_PANEL that must be overridden

View File

@ -1,5 +1,5 @@
// Do not edit this file, it is autogenerated by CMake from the .md file
_HKI( "You can use the this calculator to check if a small track can handle a large current for a short period of time.<br>\n"
_HKI( "You can use this calculator to check if a small track can handle a large current for a short period of time.<br>\n"
"This tool allows you to design a track fuse but should be used as an estimate only.\n"
"\n"
"The calculator estimates the energy required to heat the wire up<br>\n"

View File

@ -2,7 +2,7 @@
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2015 jean-pierre.charras
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2023 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
@ -17,7 +17,6 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <wx/menu.h>
#include <wx/msgdlg.h>
#include <wx/treebook.h>
#include <wx/sizer.h>
@ -28,7 +27,6 @@
#include <bitmap_store.h>
#include <geometry/shape_poly_set.h>
#include <kiface_base.h>
#include <attenuators/attenuator_classes.h>
#include <pcb_calculator_frame.h>
#include <pcb_calculator_settings.h>
@ -49,12 +47,9 @@
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
KIWAY_PLAYER( aParent, wxID_ANY,
_( "Calculator Tools" ), // Window title
wxDefaultPosition,
wxSize( 646,361 ), // Default size
wxDEFAULT_FRAME_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxTAB_TRAVERSAL,
wxT( "calculator_tools" ) ), // Window name
KIWAY_PLAYER( aParent, wxID_ANY, _( "Calculator Tools" ), wxDefaultPosition, wxSize( 646, 361 ),
wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER|wxFULL_REPAINT_ON_RESIZE|wxTAB_TRAVERSAL,
wxT( "calculator_tools" ) ),
m_lastNotebookPage( -1 )
{
SHAPE_POLY_SET dummy; // A ugly trick to force the linker to include
@ -64,59 +59,40 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SetSizeHints( wxDefaultSize, wxDefaultSize );
m_mainSizer = new wxBoxSizer( wxVERTICAL );
m_treebook = new wxTreebook( this, wxID_ANY );
m_treebook->SetFont( KIUI::GetControlFont( this ) );
m_mainSizer->Add( m_treebook, 1, wxEXPAND | wxLEFT | wxTOP, 0 );
SetSizer( m_mainSizer );
Layout();
Centre( wxBOTH );
m_treebook->AddPage( nullptr, _( "General system design" ) );
AddCalculator( new PANEL_REGULATOR( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Regulators" ) );
AddCalculator( new PANEL_REGULATOR( m_treebook ), _( "Regulators" ) );
m_treebook->AddPage( nullptr, _( "Power, current and isolation" ) );
AddCalculator( new PANEL_ELECTRICAL_SPACING( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Electrical Spacing" ) );
AddCalculator( new PANEL_VIA_SIZE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Via Size" ) );
AddCalculator( new PANEL_TRACK_WIDTH( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Track Width" ) );
AddCalculator( new PANEL_FUSING_CURRENT( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL ),
_( "Fusing Current" ) );
AddCalculator( new PANEL_CABLE_SIZE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL ),
_( "Cable Size" ) );
AddCalculator( new PANEL_ELECTRICAL_SPACING( m_treebook ), _( "Electrical Spacing" ) );
AddCalculator( new PANEL_VIA_SIZE( m_treebook ), _( "Via Size" ) );
AddCalculator( new PANEL_TRACK_WIDTH( m_treebook ), _( "Track Width" ) );
AddCalculator( new PANEL_FUSING_CURRENT( m_treebook ), _( "Fusing Current" ) );
AddCalculator( new PANEL_CABLE_SIZE( m_treebook ), _( "Cable Size" ) );
m_treebook->AddPage( nullptr, _( "High speed" ) );
AddCalculator( new PANEL_WAVELENGTH( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL ),
_( "Wavelength" ) );
AddCalculator( new PANEL_RF_ATTENUATORS( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "RF Attenuators" ) );
AddCalculator( new PANEL_TRANSLINE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Transmission Lines") );
AddCalculator( new PANEL_WAVELENGTH( m_treebook ), _( "Wavelength" ) );
AddCalculator( new PANEL_RF_ATTENUATORS( m_treebook ), _( "RF Attenuators" ) );
AddCalculator( new PANEL_TRANSLINE( m_treebook ), _( "Transmission Lines") );
m_treebook->AddPage( nullptr, _( "Memo" ) );
AddCalculator( new PANEL_E_SERIES( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "E-Series" ) );
AddCalculator( new PANEL_COLOR_CODE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Color Code" ) );
AddCalculator( new PANEL_BOARD_CLASS( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_("Board Classes") );
AddCalculator( new PANEL_GALVANIC_CORROSION( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Galvanic Corrosion" ) );
AddCalculator( new PANEL_E_SERIES( m_treebook ), _( "E-Series" ) );
AddCalculator( new PANEL_COLOR_CODE( m_treebook ), _( "Color Code" ) );
AddCalculator( new PANEL_BOARD_CLASS( m_treebook ), _("Board Classes") );
AddCalculator( new PANEL_GALVANIC_CORROSION( m_treebook ), _( "Galvanic Corrosion" ) );
LoadSettings( config() );
@ -212,7 +188,7 @@ void PCB_CALCULATOR_FRAME::OnUpdateUI( wxUpdateUIEvent& event )
// Kick all the things that wxWidgets can't seem to redraw on its own.
// This is getting seriously ridiculous....
PANEL_TRANSLINE* translinePanel = GetCalculator<PANEL_TRANSLINE>();
PANEL_RF_ATTENUATORS* attenPanel = GetCalculator<PANEL_RF_ATTENUATORS>();
PANEL_RF_ATTENUATORS* attenPanel = GetCalculator<PANEL_RF_ATTENUATORS>();
PANEL_VIA_SIZE* viaSizePanel = GetCalculator<PANEL_VIA_SIZE>();
PANEL_REGULATOR* regulPanel = GetCalculator<PANEL_REGULATOR>();
PANEL_ELECTRICAL_SPACING* elecSpacingPanel = GetCalculator<PANEL_ELECTRICAL_SPACING>();
@ -304,7 +280,7 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
m_treebook->ChangeSelection( cfg->m_LastPage );
for( auto& panel : m_panels )
for( CALCULATOR_PANEL* panel : m_panels )
panel->LoadSettings( cfg );
}
@ -323,7 +299,7 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
{
cfg->m_LastPage = m_treebook->GetSelection();
for( auto& panel : m_panels )
for( CALCULATOR_PANEL* panel : m_panels )
panel->SaveSettings( cfg );
}