2014-10-23 17:53:38 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2011-2014 Jean-Pierre Charras
|
2021-02-27 15:48:09 +00:00
|
|
|
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-10-23 17:53:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2019-05-01 18:57:59 +00:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2014-10-23 17:53:38 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2019-05-01 18:57:59 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-10-23 17:53:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-08-12 05:21:36 +00:00
|
|
|
/**
|
|
|
|
* @file UnitSelector.cpp
|
|
|
|
* a wxChoiceBox to select units in Pcb_Calculator
|
|
|
|
*/
|
|
|
|
|
2020-10-13 01:01:25 +00:00
|
|
|
#include "unit_selector.h"
|
|
|
|
#include "units_scales.h"
|
2011-08-12 05:21:36 +00:00
|
|
|
|
2014-10-23 17:53:38 +00:00
|
|
|
UNIT_SELECTOR_LEN::UNIT_SELECTOR_LEN( wxWindow *parent, wxWindowID id,
|
2011-08-12 05:21:36 +00:00
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
const wxArrayString& choices, long style )
|
|
|
|
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
|
|
|
|
{
|
2014-10-23 17:53:38 +00:00
|
|
|
Append( _( "mm" ) );
|
|
|
|
Append( _( "um" ) );
|
|
|
|
Append( _( "cm" ) );
|
|
|
|
Append( _( "mil" ) );
|
|
|
|
Append( _( "inch" ) );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2011-08-12 05:21:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function GetUnitScale
|
|
|
|
* return the scaling factor to convert users units
|
2016-01-06 00:04:45 +00:00
|
|
|
* to normalized units (meter)
|
2011-08-12 05:21:36 +00:00
|
|
|
*/
|
|
|
|
double UNIT_SELECTOR_LEN::GetUnitScale()
|
|
|
|
{
|
|
|
|
switch( GetCurrentSelection() )
|
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
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;
|
2011-08-12 05:21:36 +00:00
|
|
|
}
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-06 00:04:45 +00:00
|
|
|
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 )
|
|
|
|
{
|
2021-02-15 15:59:19 +00:00
|
|
|
Append( wxT( "mm" ) );
|
|
|
|
Append( wxT( "µm" ) );
|
|
|
|
Append( wxT( "cm" ) );
|
|
|
|
Append( wxT( "mil" ) );
|
|
|
|
Append( wxT( "inch" ) );
|
|
|
|
Append( wxT( "oz/ft²" ) );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2016-01-06 00:04:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
UNIT_SELECTOR_FREQUENCY::UNIT_SELECTOR_FREQUENCY( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
const wxArrayString& choices, long style ):
|
|
|
|
UNIT_SELECTOR( parent, id, pos, size, choices, style )
|
2011-08-12 05:21:36 +00:00
|
|
|
{
|
2014-10-23 17:53:38 +00:00
|
|
|
Append( _( "GHz" ) );
|
|
|
|
Append( _( "MHz" ) );
|
2020-10-20 19:29:53 +00:00
|
|
|
Append( _( "kHz" ) );
|
2014-10-23 17:53:38 +00:00
|
|
|
Append( _( "Hz" ) );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2011-08-12 05:21:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function GetUnitScale
|
|
|
|
* return the scaling factor to convert users units
|
|
|
|
* to normalized units (herz )
|
|
|
|
*/
|
|
|
|
double UNIT_SELECTOR_FREQUENCY::GetUnitScale()
|
|
|
|
{
|
|
|
|
switch( GetCurrentSelection() )
|
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
case 0: return UNIT_GHZ;
|
|
|
|
case 1: return UNIT_MHZ;
|
|
|
|
case 2: return UNIT_KHZ;
|
|
|
|
case 3: return 1.0;
|
2011-08-12 05:21:36 +00:00
|
|
|
}
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-09 18:09:58 +00:00
|
|
|
UNIT_SELECTOR_ANGLE::UNIT_SELECTOR_ANGLE( wxWindow *parent, wxWindowID id,
|
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
const wxArrayString& choices, long style ) :
|
|
|
|
UNIT_SELECTOR( parent, id, pos, size, choices, style )
|
2011-08-12 05:21:36 +00:00
|
|
|
{
|
2021-02-13 22:28:43 +00:00
|
|
|
Append( _( "rad" ) );
|
|
|
|
Append( _( "deg" ) );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2011-08-12 05:21:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Function GetUnitScale
|
|
|
|
* return the scaling factor to convert users units
|
|
|
|
* to normalized units ( radian )
|
|
|
|
*/
|
|
|
|
double UNIT_SELECTOR_ANGLE::GetUnitScale()
|
|
|
|
{
|
|
|
|
switch( GetCurrentSelection() )
|
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
case 0: return UNIT_RADIAN; break;
|
|
|
|
case 1: return UNIT_DEGREE; break;
|
2011-08-12 05:21:36 +00:00
|
|
|
}
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-10-23 17:53:38 +00:00
|
|
|
UNIT_SELECTOR_RESISTOR::UNIT_SELECTOR_RESISTOR( wxWindow *parent, wxWindowID id,
|
2011-08-12 05:21:36 +00:00
|
|
|
const wxPoint& pos, const wxSize& size,
|
|
|
|
const wxArrayString& choices, long style )
|
|
|
|
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
|
|
|
|
{
|
2021-02-27 15:48:09 +00:00
|
|
|
Append( wxT( "Ω" ) );
|
|
|
|
Append( wxT( "kΩ" ) );
|
2017-11-02 20:41:29 +00:00
|
|
|
}
|
2011-08-12 05:21:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Function GetUnitScale
|
|
|
|
* return the scaling factor to convert users units
|
|
|
|
* to normalized units ( ohm )
|
|
|
|
*/
|
|
|
|
double UNIT_SELECTOR_RESISTOR::GetUnitScale()
|
|
|
|
{
|
|
|
|
switch( GetCurrentSelection() )
|
|
|
|
{
|
2013-12-09 18:09:58 +00:00
|
|
|
case 0: return UNIT_OHM; break;
|
|
|
|
case 1: return UNIT_KOHM; break;
|
2011-08-12 05:21:36 +00:00
|
|
|
}
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|