ADDED: pcb_calculator cable size

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9298
This commit is contained in:
Fabien Corona 2022-06-16 22:04:45 +00:00 committed by Seth Hillbrand
parent b912bef2f6
commit 69f25f35a8
12 changed files with 3117 additions and 11 deletions

View File

@ -18,6 +18,8 @@ set( PCB_CALCULATOR_SRCS
calculator_panels/panel_attenuators_base.cpp calculator_panels/panel_attenuators_base.cpp
calculator_panels/panel_board_class.cpp calculator_panels/panel_board_class.cpp
calculator_panels/panel_board_class_base.cpp calculator_panels/panel_board_class_base.cpp
calculator_panels/panel_cable_size.cpp
calculator_panels/panel_cable_size_base.cpp
calculator_panels/panel_color_code.cpp calculator_panels/panel_color_code.cpp
calculator_panels/panel_color_code_base.cpp calculator_panels/panel_color_code_base.cpp
calculator_panels/panel_electrical_spacing.cpp calculator_panels/panel_electrical_spacing.cpp

View File

@ -0,0 +1,402 @@
/*
* 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.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <calculator_panels/panel_cable_size.h>
#include <pcb_calculator_settings.h>
#include <string_utils.h>
#include <widgets/unit_selector.h>
#define M2_to_MM2 1000000.0
#define COPPER_RESISTIVITY 1.72e-8 // ohm meter
#define VACCUM_PERMEABILITY 1.256637e-6
#define RELATIVE_PERMEABILITY 1
CABLE_SIZE_ENTRY::CABLE_SIZE_ENTRY( wxString aName, double aRadius )
{
m_name = aName;
m_radius = aRadius;
}
PANEL_CABLE_SIZE::PANEL_CABLE_SIZE( wxWindow* parent, wxWindowID id, const wxPoint& pos,
const wxSize& size, long style, const wxString& name ) :
PANEL_CABLE_SIZE_BASE( parent, id, pos, size, style, name )
{
m_entries.clear();
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG0000" ), 0.005842 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG000" ), 0.00520192 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG00" ), 0.00463296 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG0" ), 0.00412623 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG1" ), 0.00367411 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG2" ), 0.00327152 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG3" ), 0.00291338 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG4" ), 0.00259461 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG5" ), 0.00231013 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG6" ), 0.00205740 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG7" ), 0.00183261 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG8" ), 0.00163195 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG9" ), 0.00145288 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG10" ), 0.00129413 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG11" ), 0.00115189 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG12" ), 0.00102616 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG13" ), 0.0009144 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG14" ), 0.00081407 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG15" ), 0.00072517 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG16" ), 0.00064516 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG17" ), 0.00057531 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG18" ), 0.00051181 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG19" ), 0.00045593 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG20" ), 0.0004046 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG21" ), 0.00036195 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG22" ), 0.00032258 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG23" ), 0.00028702 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG24" ), 0.00025527 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG25" ), 0.00022773 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG26" ), 0.00020193 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG27" ), 0.00018034 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG28" ), 0.00016002 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG29" ), 0.00014351 ) );
m_entries.push_back( CABLE_SIZE_ENTRY( _( "AWG30" ), 0.000127 ) );
for( CABLE_SIZE_ENTRY entry : m_entries )
{
m_sizeChoice->Append( entry.m_name );
}
}
void PANEL_CABLE_SIZE::OnUpdateUnit( wxCommandEvent& aEvent )
{
printAll();
}
PANEL_CABLE_SIZE::~PANEL_CABLE_SIZE()
{
}
void PANEL_CABLE_SIZE::SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg )
{
aCfg->m_cableSize.diameterUnit = m_diameterUnit->GetSelection();
aCfg->m_cableSize.linResUnit = m_linResistanceUnit->GetSelection();
aCfg->m_cableSize.frequencyUnit = m_frequencyUnit->GetSelection();
aCfg->m_cableSize.lengthUnit = m_lengthUnit->GetSelection();
}
void PANEL_CABLE_SIZE::LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg )
{
m_diameterUnit->SetSelection( aCfg->m_cableSize.diameterUnit );
m_linResistanceUnit->SetSelection( aCfg->m_cableSize.linResUnit );
m_frequencyUnit->SetSelection( aCfg->m_cableSize.frequencyUnit );
m_lengthUnit->SetSelection( aCfg->m_cableSize.lengthUnit );
}
void PANEL_CABLE_SIZE::OnSizeChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
int index = m_sizeChoice->GetSelection();
wxString str;
if( ( index >= 0 ) && ( index < m_entries.size() ) )
{
value = m_entries.at( index ).m_radius;
updateAll( value );
}
}
}
void PANEL_CABLE_SIZE::OnDiameterChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
m_updatingDiameter = true;
double value;
if( m_diameterCtrl->GetValue().ToDouble( &value ) )
{
updateAll( value / 2 * m_diameterUnit->GetUnitScale() );
m_sizeChoice->SetSelection( -1 );
}
m_updatingDiameter = false;
}
}
void PANEL_CABLE_SIZE::OnLinResistanceChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
m_updatingLinResistance = true;
double value;
if( m_linResistanceCtrl->GetValue().ToDouble( &value ) )
{
updateAll( sqrt( COPPER_RESISTIVITY / ( value * m_linResistanceUnit->GetUnitScale() )
/ M_PI ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingLinResistance = false;
}
}
void PANEL_CABLE_SIZE::OnAreaChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
m_updatingArea = true;
double value;
if( m_areaCtrl->GetValue().ToDouble( &value ) )
{
updateAll( sqrt( value / M_PI / M2_to_MM2 ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingArea = false;
}
}
void PANEL_CABLE_SIZE::OnFrequencyChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
m_updatingFrequency = true;
double value;
if( m_frequencyCtrl->GetValue().ToDouble( &value ) )
{
updateAll( sqrt( COPPER_RESISTIVITY / value / m_frequencyUnit->GetUnitScale() / M_PI
/ VACCUM_PERMEABILITY / RELATIVE_PERMEABILITY ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingFrequency = false;
}
}
void PANEL_CABLE_SIZE::OnAmpacityChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
m_updatingAmpacity = true;
double value;
if( m_AmpacityCtrl->GetValue().ToDouble( &value ) )
{
// Based on the 700 circular mils per amp rule of the thumb
// The long number is the sq m to circular mils conversion
updateAll( sqrt( value * 700 / 1973525241.77 / M_PI ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingAmpacity = false;
}
}
void PANEL_CABLE_SIZE::OnCurrentChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
m_updatingCurrent = true;
if( m_currentCtrl->GetValue().ToDouble( &value ) )
{
m_current = value;
updateApplication();
}
m_updatingCurrent = false;
}
}
void PANEL_CABLE_SIZE::OnLengthChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
m_updatingLength = true;
if( m_lengthCtrl->GetValue().ToDouble( &value ) )
{
m_length = value * m_lengthUnit->GetUnitScale();
updateApplication();
}
m_updatingLength = false;
}
}
void PANEL_CABLE_SIZE::OnResistanceChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
m_updatingResistance = true;
if( m_resistanceCtrl->GetValue().ToDouble( &value ) )
{
updateAll( sqrt( COPPER_RESISTIVITY / value * m_length / M_PI ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingResistance = false;
}
}
void PANEL_CABLE_SIZE::OnVDropChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
m_updatingRVdrop = true;
if( m_vDropCtrl->GetValue().ToDouble( &value ) )
{
updateAll( sqrt( COPPER_RESISTIVITY / value * m_length * m_current / M_PI ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingRVdrop = false;
}
}
void PANEL_CABLE_SIZE::OnPowerChange( wxCommandEvent& aEvent )
{
if( !m_updatingUI )
{
double value;
m_updatingPower = true;
if( m_powerCtrl->GetValue().ToDouble( &value ) )
{
updateAll(
sqrt( COPPER_RESISTIVITY / value * m_length * m_current * m_current / M_PI ) );
m_sizeChoice->SetSelection( -1 );
}
m_updatingPower = false;
}
}
void PANEL_CABLE_SIZE::printAll()
{
m_updatingUI = true;
wxString value;
if( !m_updatingDiameter )
{
value = wxString( "" ) << m_diameter / m_diameterUnit->GetUnitScale();
m_diameterCtrl->SetValue( value );
}
if( !m_updatingArea )
{
value = wxString( "" ) << m_area * M2_to_MM2;
m_areaCtrl->SetValue( value );
}
if( !m_updatingAmpacity )
{
value = wxString( "" ) << m_ampacity;
m_AmpacityCtrl->SetValue( value );
}
if( !m_updatingFrequency )
{
value = wxString( "" ) << m_maxFrequency / m_frequencyUnit->GetUnitScale();
m_frequencyCtrl->SetValue( value );
}
if( !m_updatingLinResistance )
{
value = wxString( "" ) << m_linearResistance / m_linResistanceUnit->GetUnitScale();
m_linResistanceCtrl->SetValue( value );
}
if( !m_updatingLength )
{
value = wxString( "" ) << m_length / m_lengthUnit->GetUnitScale();
m_lengthCtrl->SetValue( value );
}
if( !m_updatingCurrent )
{
value = wxString( "" ) << m_current;
m_currentCtrl->SetValue( value );
}
if( !m_updatingResistance )
{
value = wxString( "" ) << m_resistance;
m_resistanceCtrl->SetValue( value );
}
if( !m_updatingRVdrop )
{
value = wxString( "" ) << m_voltageDrop;
m_vDropCtrl->SetValue( value );
}
if( !m_updatingPower )
{
value = wxString( "" ) << m_dissipatedPower;
m_powerCtrl->SetValue( value );
}
m_updatingUI = false;
}
void PANEL_CABLE_SIZE::updateAll( double aRadius )
{
// Update wire properties
m_diameter = aRadius * 2;
m_area = M_PI * aRadius * aRadius;
m_linearResistance = COPPER_RESISTIVITY / m_area;
// max frequency is when skin depth = radius
m_maxFrequency = COPPER_RESISTIVITY
/ ( M_PI * aRadius * aRadius * VACCUM_PERMEABILITY * RELATIVE_PERMEABILITY );
// Based on the 700 circular mils per amp rule of the thumb
// The long number is the sq m to circular mils conversion
m_ampacity = ( m_area * 1973525241.77 ) / 700;
// Update application-specific values
m_resistance = m_linearResistance * m_length;
m_voltageDrop = m_resistance * m_current;
m_dissipatedPower = m_voltageDrop * m_current;
printAll();
}
void PANEL_CABLE_SIZE::updateApplication()
{
m_resistance = m_linearResistance * m_length;
m_voltageDrop = m_resistance * m_current;
m_dissipatedPower = m_voltageDrop * m_current;
printAll();
}

View File

@ -0,0 +1,104 @@
/*
* 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.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef PANEL_CABLE_SIZE_H
#define PANEL_CABLE_SIZE_H
#include "panel_cable_size_base.h"
#include <vector>
class PCB_CALCULATOR_SETTINGS;
class CABLE_SIZE_ENTRY
{
public:
CABLE_SIZE_ENTRY( wxString aName, double aRadius );
wxString m_name;
double m_radius; // stored in m
};
class PANEL_CABLE_SIZE : public PANEL_CABLE_SIZE_BASE
{
public:
PANEL_CABLE_SIZE( wxWindow* parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_CABLE_SIZE();
// Methods from CALCULATOR_PANEL that must be overriden
void LoadSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override;
void SaveSettings( PCB_CALCULATOR_SETTINGS* aCfg ) override;
void ThemeChanged() override{};
void OnSizeChange( wxCommandEvent& aEvent );
void OnUpdateUnit( wxCommandEvent& aEvent );
void OnDiameterChange( wxCommandEvent& aEvent );
void OnAreaChange( wxCommandEvent& aEvent );
void OnLinResistanceChange( wxCommandEvent& aEvent );
void OnFrequencyChange( wxCommandEvent& aEvent );
void OnAmpacityChange( wxCommandEvent& aEvent );
void OnCurrentChange( wxCommandEvent& aEvent );
void OnLengthChange( wxCommandEvent& aEvent );
void OnResistanceChange( wxCommandEvent& aEvent );
void OnVDropChange( wxCommandEvent& aEvent );
void OnPowerChange( wxCommandEvent& aEvent );
private:
bool m_updatingUI;
bool m_updatingDiameter;
bool m_updatingArea;
bool m_updatingLinResistance;
bool m_updatingFrequency;
bool m_updatingAmpacity;
bool m_updatingCurrent;
bool m_updatingLength;
bool m_updatingResistance;
bool m_updatingRVdrop;
bool m_updatingPower;
void updateAll( double aRadius );
void updateApplication();
void printAll();
bool m_imperial;
std::vector<CABLE_SIZE_ENTRY> m_entries;
void onParameterUpdate( wxCommandEvent& aEvent );
// Stored in normalized units
double m_diameter;
double m_current;
double m_length;
double m_area;
double m_linearResistance;
double m_maxFrequency;
double m_resistance;
double m_voltageDrop;
double m_dissipatedPower;
double m_ampacity;
/*
void updateRow( int aRow, bool aInit=false );
void updateRows();
void OnUpdateLength();
*/
};
#endif

View File

@ -0,0 +1,222 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "widgets/unit_selector.h"
#include "panel_cable_size_base.h"
///////////////////////////////////////////////////////////////////////////
PANEL_CABLE_SIZE_BASE::PANEL_CABLE_SIZE_BASE( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : CALCULATOR_PANEL( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizer6;
bSizer6 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizer9;
bSizer9 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Wire properties") ), wxVERTICAL );
wxGridSizer* gSizer1;
gSizer1 = new wxGridSizer( 0, 3, 0, 0 );
m_staticText162 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Standard Size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText162->Wrap( -1 );
gSizer1->Add( m_staticText162, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
wxArrayString m_sizeChoiceChoices;
m_sizeChoice = new wxChoice( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_sizeChoiceChoices, 0 );
m_sizeChoice->SetSelection( 0 );
gSizer1->Add( m_sizeChoice, 0, wxALL|wxEXPAND, 5 );
gSizer1->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText16 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Diameter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16->Wrap( -1 );
gSizer1->Add( m_staticText16, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_diameterCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_diameterCtrl, 0, wxALL|wxEXPAND, 5 );
wxArrayString m_diameterUnitChoices;
m_diameterUnit = new UNIT_SELECTOR_LEN( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_diameterUnitChoices, 0 );
m_diameterUnit->SetSelection( 0 );
gSizer1->Add( m_diameterUnit, 0, wxALL, 5 );
m_staticText161 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Area:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText161->Wrap( -1 );
gSizer1->Add( m_staticText161, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_areaCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_areaCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticText1641 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("mm^2"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1641->Wrap( -1 );
gSizer1->Add( m_staticText1641, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
m_staticText16411 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Linear resistance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16411->Wrap( -1 );
gSizer1->Add( m_staticText16411, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_linResistanceCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_linResistanceCtrl, 0, wxALL|wxEXPAND, 5 );
wxArrayString m_linResistanceUnitChoices;
m_linResistanceUnit = new UNIT_SELECTOR_LINEAR_RESISTANCE( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_linResistanceUnitChoices, 0 );
m_linResistanceUnit->SetSelection( 0 );
gSizer1->Add( m_linResistanceUnit, 0, wxALL, 5 );
m_staticText164 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Frequency for 100% skin depth:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText164->Wrap( -1 );
gSizer1->Add( m_staticText164, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_frequencyCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_frequencyCtrl, 0, wxALL|wxEXPAND, 5 );
wxArrayString m_frequencyUnitChoices;
m_frequencyUnit = new UNIT_SELECTOR_FREQUENCY( sbSizer1->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_frequencyUnitChoices, 0 );
m_frequencyUnit->SetSelection( 0 );
gSizer1->Add( m_frequencyUnit, 0, wxALL, 5 );
m_staticText1642 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("Ampacity:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1642->Wrap( -1 );
gSizer1->Add( m_staticText1642, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_AmpacityCtrl = new wxTextCtrl( sbSizer1->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer1->Add( m_AmpacityCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticText16421 = new wxStaticText( sbSizer1->GetStaticBox(), wxID_ANY, _("A"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16421->Wrap( -1 );
gSizer1->Add( m_staticText16421, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
sbSizer1->Add( gSizer1, 0, wxALL, 5 );
bSizer4->Add( sbSizer1, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer12;
sbSizer12 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Application") ), wxVERTICAL );
wxGridSizer* gSizer12;
gSizer12 = new wxGridSizer( 0, 3, 0, 0 );
m_staticText163 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("Current:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText163->Wrap( -1 );
gSizer12->Add( m_staticText163, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_currentCtrl = new wxTextCtrl( sbSizer12->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer12->Add( m_currentCtrl, 1, wxALL|wxEXPAND, 5 );
m_staticText = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("A"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText->Wrap( -1 );
gSizer12->Add( m_staticText, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT|wxALL, 5 );
m_staticText1612 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("Length:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1612->Wrap( -1 );
gSizer12->Add( m_staticText1612, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_lengthCtrl = new wxTextCtrl( sbSizer12->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer12->Add( m_lengthCtrl, 1, wxALL|wxEXPAND, 5 );
wxArrayString m_lengthUnitChoices;
m_lengthUnit = new UNIT_SELECTOR_LEN_CABLE( sbSizer12->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_lengthUnitChoices, 0 );
m_lengthUnit->SetSelection( 0 );
gSizer12->Add( m_lengthUnit, 0, wxALL, 5 );
m_staticText16121 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("Resistance:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16121->Wrap( -1 );
gSizer12->Add( m_staticText16121, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_resistanceCtrl = new wxTextCtrl( sbSizer12->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer12->Add( m_resistanceCtrl, 1, wxALL|wxEXPAND, 5 );
m_staticText161211 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("ohm"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText161211->Wrap( -1 );
gSizer12->Add( m_staticText161211, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText161212 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("Voltage drop:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText161212->Wrap( -1 );
gSizer12->Add( m_staticText161212, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_vDropCtrl = new wxTextCtrl( sbSizer12->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer12->Add( m_vDropCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticText1612121 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("mV"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1612121->Wrap( -1 );
gSizer12->Add( m_staticText1612121, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_staticText1612122 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("Dissipated power:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText1612122->Wrap( -1 );
gSizer12->Add( m_staticText1612122, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxALL, 5 );
m_powerCtrl = new wxTextCtrl( sbSizer12->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
gSizer12->Add( m_powerCtrl, 0, wxALL|wxEXPAND, 5 );
m_staticText16121211 = new wxStaticText( sbSizer12->GetStaticBox(), wxID_ANY, _("mW"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText16121211->Wrap( -1 );
gSizer12->Add( m_staticText16121211, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
sbSizer12->Add( gSizer12, 0, wxALL, 5 );
bSizer4->Add( sbSizer12, 1, wxALL|wxEXPAND, 5 );
bSizer9->Add( bSizer4, 1, wxEXPAND, 5 );
bSizer6->Add( bSizer9, 0, wxEXPAND, 5 );
this->SetSizer( bSizer6 );
this->Layout();
// Connect Events
m_sizeChoice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnSizeChange ), NULL, this );
m_diameterCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnDiameterChange ), NULL, this );
m_diameterUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_areaCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnAreaChange ), NULL, this );
m_linResistanceCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnLinResistanceChange ), NULL, this );
m_linResistanceUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_frequencyCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnFrequencyChange ), NULL, this );
m_frequencyUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_AmpacityCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnAmpacityChange ), NULL, this );
m_currentCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnCurrentChange ), NULL, this );
m_lengthCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnLengthChange ), NULL, this );
m_lengthUnit->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_resistanceCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnResistanceChange ), NULL, this );
m_vDropCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnVDropChange ), NULL, this );
m_powerCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnPowerChange ), NULL, this );
}
PANEL_CABLE_SIZE_BASE::~PANEL_CABLE_SIZE_BASE()
{
// Disconnect Events
m_sizeChoice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnSizeChange ), NULL, this );
m_diameterCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnDiameterChange ), NULL, this );
m_diameterUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_areaCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnAreaChange ), NULL, this );
m_linResistanceCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnLinResistanceChange ), NULL, this );
m_linResistanceUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_frequencyCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnFrequencyChange ), NULL, this );
m_frequencyUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_AmpacityCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnAmpacityChange ), NULL, this );
m_currentCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnCurrentChange ), NULL, this );
m_lengthCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnLengthChange ), NULL, this );
m_lengthUnit->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnUpdateUnit ), NULL, this );
m_resistanceCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnResistanceChange ), NULL, this );
m_vDropCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnVDropChange ), NULL, this );
m_powerCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( PANEL_CABLE_SIZE_BASE::OnPowerChange ), NULL, this );
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,97 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#pragma once
#include <wx/artprov.h>
#include <wx/xrc/xmlres.h>
#include <wx/intl.h>
class UNIT_SELECTOR_FREQUENCY;
class UNIT_SELECTOR_LEN;
class UNIT_SELECTOR_LEN_CABLE;
class UNIT_SELECTOR_LINEAR_RESISTANCE;
#include "calculator_panels/calculator_panel.h"
#include <wx/string.h>
#include <wx/stattext.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/choice.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/panel.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class PANEL_CABLE_SIZE_BASE
///////////////////////////////////////////////////////////////////////////////
class PANEL_CABLE_SIZE_BASE : public CALCULATOR_PANEL
{
private:
protected:
wxStaticText* m_staticText162;
wxChoice* m_sizeChoice;
wxStaticText* m_staticText16;
wxTextCtrl* m_diameterCtrl;
UNIT_SELECTOR_LEN* m_diameterUnit;
wxStaticText* m_staticText161;
wxTextCtrl* m_areaCtrl;
wxStaticText* m_staticText1641;
wxStaticText* m_staticText16411;
wxTextCtrl* m_linResistanceCtrl;
UNIT_SELECTOR_LINEAR_RESISTANCE* m_linResistanceUnit;
wxStaticText* m_staticText164;
wxTextCtrl* m_frequencyCtrl;
UNIT_SELECTOR_FREQUENCY* m_frequencyUnit;
wxStaticText* m_staticText1642;
wxTextCtrl* m_AmpacityCtrl;
wxStaticText* m_staticText16421;
wxStaticText* m_staticText163;
wxTextCtrl* m_currentCtrl;
wxStaticText* m_staticText;
wxStaticText* m_staticText1612;
wxTextCtrl* m_lengthCtrl;
UNIT_SELECTOR_LEN_CABLE* m_lengthUnit;
wxStaticText* m_staticText16121;
wxTextCtrl* m_resistanceCtrl;
wxStaticText* m_staticText161211;
wxStaticText* m_staticText161212;
wxTextCtrl* m_vDropCtrl;
wxStaticText* m_staticText1612121;
wxStaticText* m_staticText1612122;
wxTextCtrl* m_powerCtrl;
wxStaticText* m_staticText16121211;
// Virtual event handlers, override them in your derived class
virtual void OnSizeChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDiameterChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnUpdateUnit( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAreaChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnLinResistanceChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnFrequencyChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnAmpacityChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCurrentChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnLengthChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnResistanceChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnVDropChange( wxCommandEvent& event ) { event.Skip(); }
virtual void OnPowerChange( wxCommandEvent& event ) { event.Skip(); }
public:
PANEL_CABLE_SIZE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 677,453 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );
~PANEL_CABLE_SIZE_BASE();
};

View File

@ -35,6 +35,7 @@
#include <calculator_panels/panel_attenuators.h> #include <calculator_panels/panel_attenuators.h>
#include <calculator_panels/panel_board_class.h> #include <calculator_panels/panel_board_class.h>
#include <calculator_panels/panel_cable_size.h>
#include <calculator_panels/panel_color_code.h> #include <calculator_panels/panel_color_code.h>
#include <calculator_panels/panel_electrical_spacing.h> #include <calculator_panels/panel_electrical_spacing.h>
#include <calculator_panels/panel_eserie.h> #include <calculator_panels/panel_eserie.h>
@ -86,6 +87,9 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
_( "Via Size" ) ); _( "Via Size" ) );
AddCalculator( new PANEL_TRACK_WIDTH( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ), AddCalculator( new PANEL_TRACK_WIDTH( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ),
_( "Track Width" ) ); _( "Track Width" ) );
AddCalculator( new PANEL_CABLE_SIZE( m_treebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
wxTAB_TRAVERSAL ),
_( "Cable Size" ) );
m_treebook->AddPage( nullptr, _( "High speed" ) ); m_treebook->AddPage( nullptr, _( "High speed" ) );

View File

@ -34,16 +34,9 @@ const int pcbCalculatorSchemaVersion = 0;
PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() : PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() :
APP_SETTINGS_BASE( "pcb_calculator", pcbCalculatorSchemaVersion ), APP_SETTINGS_BASE( "pcb_calculator", pcbCalculatorSchemaVersion ), m_Attenuators(),
m_Attenuators(), m_BoardClassUnits( 0 ), m_ColorCodeTolerance( 0 ), m_Electrical(), m_LastPage( 0 ),
m_BoardClassUnits( 0 ), m_Regulators(), m_cableSize(), m_TrackWidth(), m_TransLine(), m_ViaSize()
m_ColorCodeTolerance( 0 ),
m_Electrical(),
m_LastPage( 0 ),
m_Regulators(),
m_TrackWidth(),
m_TransLine(),
m_ViaSize()
{ {
// Build settings: // Build settings:
m_params.emplace_back( new PARAM<int>( "board_class_units", &m_BoardClassUnits, 0 ) ); m_params.emplace_back( new PARAM<int>( "board_class_units", &m_BoardClassUnits, 0 ) );
@ -94,6 +87,16 @@ PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() :
m_params.emplace_back( new PARAM<int>( "regulators.last_param", &m_Regulators.last_param, 0 ) ); m_params.emplace_back( new PARAM<int>( "regulators.last_param", &m_Regulators.last_param, 0 ) );
m_params.emplace_back(
new PARAM<int>( "cable_size.diameterUnit", &m_cableSize.diameterUnit, 0 ) );
m_params.emplace_back( new PARAM<int>( "cable_size.linResUnit", &m_cableSize.linResUnit, 0 ) );
m_params.emplace_back(
new PARAM<int>( "cable_size.frequencyUnit", &m_cableSize.frequencyUnit, 0 ) );
m_params.emplace_back( new PARAM<int>( "cable_size.lengthUnit", &m_cableSize.lengthUnit, 0 ) );
m_params.emplace_back( new PARAM<wxString>( "track_width.current", m_params.emplace_back( new PARAM<wxString>( "track_width.current",
&m_TrackWidth.current, "1.0" ) ); &m_TrackWidth.current, "1.0" ) );

View File

@ -62,6 +62,14 @@ public:
int last_param; int last_param;
}; };
struct CABLE_SIZE
{
int diameterUnit;
int linResUnit;
int frequencyUnit;
int lengthUnit;
};
struct TRACK_WIDTH struct TRACK_WIDTH
{ {
wxString current; wxString current;
@ -139,6 +147,8 @@ public:
REGULATORS m_Regulators; REGULATORS m_Regulators;
CABLE_SIZE m_cableSize;
TRACK_WIDTH m_TrackWidth; TRACK_WIDTH m_TrackWidth;
TRANSMISSION_LINE m_TransLine; TRANSMISSION_LINE m_TransLine;

View File

@ -28,11 +28,14 @@
#ifndef UNITS_SCALES_H #ifndef UNITS_SCALES_H
#define UNITS_SCALES_H #define UNITS_SCALES_H
#define UNIT_MM 1e-3 // mm to meter #define UNIT_KM 1e3 // km to meter
#define UNIT_M 1 // m to meter
#define UNIT_CM 1e-2 // cm to meter #define UNIT_CM 1e-2 // cm to meter
#define UNIT_MM 1e-3 // mm to meter
#define UNIT_MICRON 1e-6 // um to meter #define UNIT_MICRON 1e-6 // um to meter
#define UNIT_INCH (1e-2*2.54) // inch 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_MIL (1e-5*2.54) // mil (or thou) to meter
#define UNIT_FEET 0.3048 // feet to meter
#define UNIT_OZSQFT (34.40*UNIT_MICRON) // 1 oz/ft^2 is 34.30 microns nominal, 30.90 minimum #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_GHZ 1e9
@ -45,4 +48,9 @@
#define UNIT_OHM 1.0 // Ohm to Ohm #define UNIT_OHM 1.0 // Ohm to Ohm
#define UNIT_KOHM 1e3 // KOhm to Ohm #define UNIT_KOHM 1e3 // KOhm to Ohm
#define UNIT_OHM_PER_METER 1.0 // Ohm per meter to Ohm per meter
#define UNIT_OHM_PER_KILOMETER 1e-3 // Ohm per kilometer to Ohm per meter
#define UNIT_OHM_PER_FEET 3.28084 // Ohm per feet to Ohm per meter
#define UNIT_OHM_PER_1000FEET 3280.84 // Ohm per feet to Ohm per meter
#endif // UNITS_SCALES_H #endif // UNITS_SCALES_H

View File

@ -171,3 +171,64 @@ double UNIT_SELECTOR_RESISTOR::GetUnitScale()
return 1.0; return 1.0;
} }
UNIT_SELECTOR_LINEAR_RESISTANCE::UNIT_SELECTOR_LINEAR_RESISTANCE( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style )
: UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( wxT( "Ω/m" ) );
Append( wxT( "Ω/km" ) );
Append( wxT( "Ω/ft" ) );
Append( wxT( "Ω/1000ft" ) );
}
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units ( ohm )
*/
double UNIT_SELECTOR_LINEAR_RESISTANCE::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_OHM_PER_METER; break;
case 1: return UNIT_OHM_PER_KILOMETER; break;
case 2: return UNIT_OHM_PER_FEET; break;
case 3: return UNIT_OHM_PER_1000FEET; break;
}
return 1.0;
}
UNIT_SELECTOR_LEN_CABLE::UNIT_SELECTOR_LEN_CABLE( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices, long style ) :
UNIT_SELECTOR( parent, id, pos, size, choices, style )
{
Append( _( "cm" ) );
Append( _( "m" ) );
Append( _( "km" ) );
Append( _( "inch" ) );
Append( _( "feet" ) );
}
/*
* Function GetUnitScale
* return the scaling factor to convert users units
* to normalized units (meter)
*/
double UNIT_SELECTOR_LEN_CABLE::GetUnitScale()
{
switch( GetCurrentSelection() )
{
case 0: return UNIT_CM; break;
case 1: return UNIT_M; break;
case 2: return UNIT_KM; break;
case 3: return UNIT_INCH; break;
case 4: return UNIT_FEET; break;
}
return 1.0;
}

View File

@ -129,5 +129,35 @@ public:
double GetUnitScale() override; double GetUnitScale() override;
}; };
class UNIT_SELECTOR_LINEAR_RESISTANCE : public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_LINEAR_RESISTANCE( 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 ( ohm/m )
*/
double GetUnitScale() override;
};
class UNIT_SELECTOR_LEN_CABLE : public UNIT_SELECTOR
{
public:
UNIT_SELECTOR_LEN_CABLE( 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 ( ohm/m )
*/
double GetUnitScale() override;
};
#endif // UNIT_SELECTOR_H #endif // UNIT_SELECTOR_H