From 89c183f041c55f57a029e2eda9f958c7c65ebe7f Mon Sep 17 00:00:00 2001 From: Jon Neal Date: Tue, 5 Jan 2016 19:04:45 -0500 Subject: [PATCH] Add a new dropdown type that has oz/ft^2 for the pcb track width calculator. --- pcb_calculator/UnitSelector.cpp | 38 ++++++++++++++++++- pcb_calculator/UnitSelector.h | 17 ++++++++- .../dialogs/pcb_calculator_frame_base.cpp | 6 +-- .../dialogs/pcb_calculator_frame_base.fbp | 4 +- .../dialogs/pcb_calculator_frame_base.h | 7 ++-- pcb_calculator/units_scales.h | 3 +- 6 files changed, 63 insertions(+), 12 deletions(-) diff --git a/pcb_calculator/UnitSelector.cpp b/pcb_calculator/UnitSelector.cpp index ddf26aeb20..06b3768628 100644 --- a/pcb_calculator/UnitSelector.cpp +++ b/pcb_calculator/UnitSelector.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras - * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 @@ -46,7 +46,7 @@ UNIT_SELECTOR_LEN::UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id, /* * Function GetUnitScale * return the scaling factor to convert users units - * to normalized units (meter ) + * to normalized units (meter) */ double UNIT_SELECTOR_LEN::GetUnitScale() { @@ -62,6 +62,40 @@ double UNIT_SELECTOR_LEN::GetUnitScale() } +UNIT_SELECTOR_THICKNESS::UNIT_SELECTOR_THICKNESS( wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices, long style ) + : UNIT_SELECTOR( parent, id, pos, size, choices, style ) +{ + Append( _( "mm" ) ); + Append( _( "um" ) ); + Append( _( "cm" ) ); + Append( _( "mil" ) ); + Append( _( "inch" ) ); + Append( _( "oz/ft^2" ) ); +}; + + +/* + * Function GetUnitScale + * return the scaling factor to convert users units + * to normalized units (meter) including copper oz/ft^2 + */ +double UNIT_SELECTOR_THICKNESS::GetUnitScale() +{ + switch( GetCurrentSelection() ) + { + case 0: return UNIT_MM; break; + case 1: return UNIT_MICRON; break; + case 2: return UNIT_CM; break; + case 3: return UNIT_MIL; break; + case 4: return UNIT_INCH; break; + case 5: return UNIT_OZSQFT; break; + } + return 1.0; +} + + UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const wxArrayString& choices, long style ): diff --git a/pcb_calculator/UnitSelector.h b/pcb_calculator/UnitSelector.h index e8ea45d2a9..d5adea0602 100644 --- a/pcb_calculator/UnitSelector.h +++ b/pcb_calculator/UnitSelector.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras - * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 @@ -73,6 +73,21 @@ public: virtual double GetUnitScale(); }; +class UNIT_SELECTOR_THICKNESS: public UNIT_SELECTOR +{ +public: + UNIT_SELECTOR_THICKNESS( wxWindow *parent, wxWindowID id, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices, long style = 0 ); + + /** + * Function GetUnitScale + * @return the scaling factor to convert users units + * to normalized units (meter) including oz/ft^2 + */ + virtual double GetUnitScale(); +}; + class UNIT_SELECTOR_FREQUENCY: public UNIT_SELECTOR { public: diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp index 5ba848f949..59c7e95322 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version Aug 23 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -362,7 +362,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow fgSizerTW_Results->Add( m_ExtTrackThicknessValue, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); wxArrayString m_ExtTrackThicknessUnitChoices; - m_ExtTrackThicknessUnit = new UNIT_SELECTOR_LEN( sbSizerTW_Result->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ExtTrackThicknessUnitChoices, 0 ); + m_ExtTrackThicknessUnit = new UNIT_SELECTOR_THICKNESS( sbSizerTW_Result->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_ExtTrackThicknessUnitChoices, 0 ); m_ExtTrackThicknessUnit->SetSelection( 0 ); fgSizerTW_Results->Add( m_ExtTrackThicknessUnit, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); @@ -451,7 +451,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow fgSizerTW_Results1->Add( m_IntTrackThicknessValue, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 ); wxArrayString m_IntTrackThicknessUnitChoices; - m_IntTrackThicknessUnit = new UNIT_SELECTOR_LEN( sbSizerTW_Result1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_IntTrackThicknessUnitChoices, 0 ); + m_IntTrackThicknessUnit = new UNIT_SELECTOR_THICKNESS( sbSizerTW_Result1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_IntTrackThicknessUnitChoices, 0 ); m_IntTrackThicknessUnit->SetSelection( 0 ); fgSizerTW_Results1->Add( m_IntTrackThicknessUnit, 0, wxALL, 5 ); diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp index 3cf27fd505..8ddf2f2ae7 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.fbp @@ -5032,7 +5032,7 @@ 1 - UNIT_SELECTOR_LEN; UnitSelector.h + UNIT_SELECTOR_THICKNESS; UnitSelector.h 0 @@ -6584,7 +6584,7 @@ 1 - UNIT_SELECTOR_LEN; UnitSelector.h + UNIT_SELECTOR_THICKNESS; UnitSelector.h 0 diff --git a/pcb_calculator/dialogs/pcb_calculator_frame_base.h b/pcb_calculator/dialogs/pcb_calculator_frame_base.h index ff718f42aa..7152c44e2b 100644 --- a/pcb_calculator/dialogs/pcb_calculator_frame_base.h +++ b/pcb_calculator/dialogs/pcb_calculator_frame_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 17 2015) +// C++ code generated with wxFormBuilder (version Aug 23 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -16,6 +16,7 @@ class UNIT_SELECTOR_ANGLE; class UNIT_SELECTOR_FREQUENCY; class UNIT_SELECTOR_LEN; class UNIT_SELECTOR_RESISTOR; +class UNIT_SELECTOR_THICKNESS; #include "kiway_player.h" #include @@ -110,7 +111,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER UNIT_SELECTOR_LEN* m_TW_ExtTrackWidth_choiceUnit; wxStaticText* m_staticText65; wxTextCtrl* m_ExtTrackThicknessValue; - UNIT_SELECTOR_LEN* m_ExtTrackThicknessUnit; + UNIT_SELECTOR_THICKNESS* m_ExtTrackThicknessUnit; wxStaticText* m_staticTextArea; wxStaticText* m_ExtTrackAreaValue; wxStaticText* m_ExtTrackAreaUnitLabel; @@ -128,7 +129,7 @@ class PCB_CALCULATOR_FRAME_BASE : public KIWAY_PLAYER UNIT_SELECTOR_LEN* m_TW_IntTrackWidth_choiceUnit; wxStaticText* m_staticText652; wxTextCtrl* m_IntTrackThicknessValue; - UNIT_SELECTOR_LEN* m_IntTrackThicknessUnit; + UNIT_SELECTOR_THICKNESS* m_IntTrackThicknessUnit; wxStaticText* m_staticTextArea1; wxStaticText* m_IntTrackAreaValue; wxStaticText* m_IntTrackAreaUnitLabel; diff --git a/pcb_calculator/units_scales.h b/pcb_calculator/units_scales.h index f694a83b3d..3d996a7210 100644 --- a/pcb_calculator/units_scales.h +++ b/pcb_calculator/units_scales.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2011-2014 Jean-Pierre Charras - * Copyright (C) 2004-2014 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2016 KiCad Developers, see change_log.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 @@ -37,6 +37,7 @@ #define UNIT_MICRON 1e-6 // um to meter #define UNIT_INCH (1e-2*2.54) // inch to meter #define UNIT_MIL (1e-5*2.54) // mil (or thou) to meter +#define UNIT_OZSQFT (34.40*UNIT_MICRON) // 1 oz/ft^2 is 34.30 microns nominal, 30.90 minimum #define UNIT_GHZ 1e9 #define UNIT_MHZ 1e6