Clean up units infrastructure after g_UserUnit removal.

Fixes: lp:1538239
* https://bugs.launchpad.net/kicad/+bug/1538239

(cherry picked from commit 96d7178)
This commit is contained in:
Jeff Young 2018-06-17 14:50:49 +01:00
parent aab97c8385
commit d5e88f574f
15 changed files with 118 additions and 526 deletions

View File

@ -262,7 +262,7 @@ set( COMMON_SRCS
eda_dde.cpp
eda_doc.cpp
eda_pattern_match.cpp
eda_graphic_text_ctrl.cpp
eda_size_ctrl.cpp
env_paths.cpp
exceptions.cpp
executable_names.cpp

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 CERN
* Copyright (C) 1992-2011 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 1992-2018 KiCad Developers, see change_log.txt for contributors.
*
*
* This program is free software; you can redistribute it and/or
@ -121,13 +121,6 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue, bool aUseMils )
* could truncate the actual value
*/
// JEY TODO: retire this in favour of MessageTextFromValue()....
wxString CoordinateToString( int aValue, bool aUseMils )
{
return MessageTextFromValue( g_UserUnit, aValue, aUseMils );
}
// A lower-precision (for readability) version of StringFromValue()
wxString MessageTextFromValue( EDA_UNITS_T aUnits, int aValue, bool aUseMils )
{
@ -282,15 +275,6 @@ wxString StringFromValue( EDA_UNITS_T aUnits, int aValue, bool aAddUnitSymbol, b
}
// JEY TODO: remove
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue )
{
wxString msg = StringFromValue( g_UserUnit, aValue );
aTextCtr.SetValue( msg );
}
double From_User_Unit( EDA_UNITS_T aUnits, double aValue, bool aUseMils )
{
switch( aUnits )
@ -390,31 +374,6 @@ int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMi
}
// JEY TODO: remove
int ValueFromString( const wxString& aTextValue )
{
int value;
value = ValueFromString( g_UserUnit, aTextValue);
return value;
}
// JEY TODO: remove; use a UNIT_BINDER instead
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
int value;
wxString msg = aTextCtr.GetValue();
NUMERIC_EVALUATOR eval( g_UserUnit );
if( eval.Process( msg ) )
msg = eval.Result();
value = ValueFromString( g_UserUnit, msg );
return value;
}
/**
* Function AngleToStringDegrees
* is a helper to convert the \a double \a aAngle (in internal unit)
@ -431,38 +390,6 @@ wxString AngleToStringDegrees( double aAngle )
}
wxString ReturnUnitSymbol( EDA_UNITS_T aUnit, const wxString& formatString )
{
wxString tmp;
wxString label;
switch( aUnit )
{
case INCHES:
tmp = _( "\"" );
break;
case MILLIMETRES:
tmp = _( "mm" );
break;
case UNSCALED_UNITS:
break;
case DEGREES:
wxASSERT( false );
break;
}
if( formatString.IsEmpty() )
return tmp;
label.Printf( formatString, GetChars( tmp ) );
return label;
}
wxString GetUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils )
{
switch( aUnit )
@ -512,12 +439,3 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils )
}
}
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
{
wxString msg = Stext.GetLabel();
msg += ReturnUnitSymbol( aUnit );
Stext.SetLabel( msg );
}

View File

@ -54,7 +54,6 @@ using KIGFX::COLOR4D;
* application class.
*/
EDA_UNITS_T g_UserUnit;
COLOR4D g_GhostColor;

View File

@ -370,13 +370,11 @@ void EDA_DRAW_FRAME::OnSelectUnits( wxCommandEvent& aEvent )
{
if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_MM && m_UserUnits != MILLIMETRES )
{
g_UserUnit = MILLIMETRES; // JEY TODO: double-up while in transition...
m_UserUnits = MILLIMETRES;
unitsChangeRefresh();
}
else if( aEvent.GetId() == ID_TB_OPTIONS_SELECT_UNIT_INCH && m_UserUnits != INCHES )
{
g_UserUnit = INCHES; // JEY TODO: double-up while in transition...
m_UserUnits = INCHES;
unitsChangeRefresh();
}
@ -791,8 +789,6 @@ void EDA_DRAW_FRAME::LoadSettings( wxConfigBase* aCfg )
else
SetUserUnits( MILLIMETRES );
g_UserUnit = GetUserUnits(); // JEY TODO: double-up while in transition
// Read show/hide grid entry
bool btmp;
if( aCfg->Read( baseCfgName + ShowGridEntryKeyword, &btmp ) )

View File

@ -1,324 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2011 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
* 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, 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
*/
/**
* @file eda_graphic_text_ctrl.cpp
*/
#include <fctsys.h>
#include <eda_base_frame.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <macros.h>
/*******************************************************/
/* Class to edit a graphic + text size in INCHES or MM */
/*******************************************************/
EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
const wxString& Title,
const wxString& TextToEdit,
int textsize,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer,
int framelen )
{
m_UserUnit = user_unit;
m_Title = NULL;
m_Title = new wxStaticText( parent, -1, Title );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
BoxSizer->Add( m_FrameText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
if( !Title.IsEmpty() )
{
wxString msg;
msg.Printf( _( "Size%s" ), GetChars( ReturnUnitSymbol( m_UserUnit ) ) );
wxStaticText* text = new wxStaticText( parent, -1, msg );
BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
}
wxString value = FormatSize( m_UserUnit, textsize );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) );
BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL()
{
/* no, these are deleted by the BoxSizer
delete m_FrameText;
delete m_Title;
*/
}
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize )
{
// Limiting the size of the text of reasonable values.
if( textSize < 10 )
textSize = 10;
if( textSize > 3000 )
textSize = 3000;
return StringFromValue( aUnit, textSize );
}
void EDA_GRAPHIC_TEXT_CTRL::SetTitle( const wxString& title )
{
m_Title->SetLabel( title );
}
void EDA_GRAPHIC_TEXT_CTRL::SetValue( const wxString& value )
{
m_FrameText->SetValue( value );
}
void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize )
{
wxString value = FormatSize( m_UserUnit, textSize );
m_FrameSize->SetValue( value );
}
const wxString EDA_GRAPHIC_TEXT_CTRL::GetText() const
{
wxString text = m_FrameText->GetValue();
return text;
}
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUnit )
{
int textsize;
textsize = ValueFromString( aUnit, sizeText );
// Limit to reasonable size
if( textsize < 10 )
textsize = 10;
if( textsize > 3000 )
textsize = 3000;
return textsize;
}
int EDA_GRAPHIC_TEXT_CTRL::GetTextSize()
{
return ParseSize( m_FrameSize->GetValue(), m_UserUnit );
}
void EDA_GRAPHIC_TEXT_CTRL::Enable( bool state )
{
m_FrameText->Enable( state );
}
/********************************************************/
/* Class to display and edit a coordinated INCHES or MM */
/********************************************************/
EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer )
{
wxString text;
m_UserUnit = user_unit;
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
text += _( "X" ) + ReturnUnitSymbol( m_UserUnit );
m_TextX = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
text += _( "Y" ) + ReturnUnitSymbol( m_UserUnit );
m_TextY = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
SetValue( pos_to_edit.x, pos_to_edit.y );
}
EDA_POSITION_CTRL::~EDA_POSITION_CTRL()
{
delete m_TextX;
delete m_TextY;
delete m_FramePosX;
delete m_FramePosY;
}
/* Returns (in internal units) to coordinate between (in user units)
*/
wxPoint EDA_POSITION_CTRL::GetValue()
{
wxPoint coord;
coord.x = ValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ValueFromString( m_UserUnit, m_FramePosY->GetValue() );
return coord;
}
void EDA_POSITION_CTRL::Enable( bool x_win_on, bool y_win_on )
{
m_FramePosX->Enable( x_win_on );
m_FramePosY->Enable( y_win_on );
}
void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
{
wxString msg;
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.x );
m_FramePosX->Clear();
m_FramePosX->SetValue( msg );
msg = StringFromValue( m_UserUnit, m_Pos_To_Edit.y );
m_FramePosY->Clear();
m_FramePosY->SetValue( msg );
}
/*******************/
/* EDA_SIZE_CTRL */
/*******************/
EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit, EDA_UNITS_T aUnit,
wxBoxSizer* aBoxSizer ) :
EDA_POSITION_CTRL( parent, title, wxPoint( size_to_edit.x, size_to_edit.y ),
aUnit, aBoxSizer )
{
}
wxSize EDA_SIZE_CTRL::GetValue()
{
wxPoint pos = EDA_POSITION_CTRL::GetValue();
wxSize size;
size.x = pos.x;
size.y = pos.y;
return size;
}
/**************************************************************/
/* Class to display and edit a dimension INCHES, MM, or other */
/**************************************************************/
EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title,
int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer )
{
wxString label = title;
m_UserUnit = user_unit;
m_Value = value;
label += ReturnUnitSymbol( m_UserUnit );
m_Text = new wxStaticText( parent, -1, label );
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxString stringvalue = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
0,
wxGROW | wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxBOTTOM,
5 );
}
EDA_VALUE_CTRL::~EDA_VALUE_CTRL()
{
delete m_ValueCtrl;
delete m_Text;
}
int EDA_VALUE_CTRL::GetValue()
{
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ValueFromString( m_UserUnit, txtvalue );
return coord;
}
void EDA_VALUE_CTRL::SetValue( int new_value )
{
wxString buffer;
m_Value = new_value;
buffer = StringFromValue( m_UserUnit, m_Value );
m_ValueCtrl->SetValue( buffer );
}
void EDA_VALUE_CTRL::Enable( bool enbl )
{
m_ValueCtrl->Enable( enbl );
m_Text->Enable( enbl );
}

104
common/eda_size_ctrl.cpp Normal file
View File

@ -0,0 +1,104 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2018 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
* 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, 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
*/
#include <fctsys.h>
#include <eda_base_frame.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <macros.h>
/********************************************************/
/* Class to display and edit a coordinated INCHES or MM */
/********************************************************/
EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& aPos,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer )
{
m_UserUnit = user_unit;
m_TextX = new wxStaticText( parent, -1, title + _( " X:" ) );
BoxSizer->Add( m_TextX, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosX = new wxTextCtrl( parent, -1, wxEmptyString, wxDefaultPosition );
BoxSizer->Add( m_FramePosX, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_TextY = new wxStaticText( parent, -1, title + _( " Y:" ) );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
BoxSizer->Add( m_FramePosY, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
SetValue( aPos.x, aPos.y );
}
EDA_POSITION_CTRL::~EDA_POSITION_CTRL()
{
delete m_TextX;
delete m_TextY;
delete m_FramePosX;
delete m_FramePosY;
}
/* Returns (in internal units) to coordinate between (in user units)
*/
wxPoint EDA_POSITION_CTRL::GetValue()
{
return wxPoint( ValueFromString( m_UserUnit, m_FramePosX->GetValue() ),
ValueFromString( m_UserUnit, m_FramePosY->GetValue() ) );
}
void EDA_POSITION_CTRL::Enable( bool x_win_on, bool y_win_on )
{
m_FramePosX->Enable( x_win_on );
m_FramePosY->Enable( y_win_on );
}
void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
{
m_FramePosX->SetValue( StringFromValue( m_UserUnit, x_value, true ) );
m_FramePosY->SetValue( StringFromValue( m_UserUnit, y_value, true ) );
}
/*******************/
/* EDA_SIZE_CTRL */
/*******************/
EDA_SIZE_CTRL::EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& aSize,
EDA_UNITS_T aUnit, wxBoxSizer* aBoxSizer ) :
EDA_POSITION_CTRL( parent, title, wxPoint( aSize.x, aSize.y ), aUnit, aBoxSizer )
{
}
wxSize EDA_SIZE_CTRL::GetValue()
{
wxPoint pos = EDA_POSITION_CTRL::GetValue();
return wxSize( pos.x, pos.y );
}

View File

@ -28,7 +28,7 @@ TEXT_CTRL_EVAL::TEXT_CTRL_EVAL( wxWindow* aParent, wxWindowID aId, const
wxString& aValue, const wxPoint& aPos, const wxSize& aSize, long aStyle,
const wxValidator& aValidator, const wxString& aName )
: wxTextCtrl( aParent, aId, aValue, aPos, aSize, aStyle | wxTE_PROCESS_ENTER, aValidator, aName ),
m_eval( g_UserUnit )
m_eval( UNSCALED_UNITS )
{
Connect( wxEVT_SET_FOCUS,
wxFocusEventHandler( TEXT_CTRL_EVAL::onTextFocusGet ), NULL, this );

View File

@ -56,7 +56,6 @@ bool PANEL_EESCHEMA_SETTINGS::TransferDataToWindow()
bool PANEL_EESCHEMA_SETTINGS::TransferDataFromWindow()
{
m_frame->SetUserUnits( m_choiceUnits->GetSelection() == 0 ? INCHES : MILLIMETRES );
g_UserUnit = m_frame->GetUserUnits(); // JEY TODO: double-up while in transition...
int textSize = ValueFromString( INCHES, m_textSizeCtrl->GetValue(), true );

View File

@ -133,15 +133,6 @@ wxString MessageTextFromValue( EDA_UNITS_T aUnits, int aValue, bool aUseMils = f
wxString StringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false,
bool aUseMils = false );
/**
* Function PutValueInLocalUnits
* converts \a aValue from internal units to user units and append the units notation
* (mm or ")then inserts the string an \a aTextCtrl.
*
* This function is used in dialog boxes for entering values depending on selected units.
*/
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue );
/**
* Return in internal units the value "val" given in a real unit
* such as "in", "mm" or "deg"
@ -171,24 +162,6 @@ double DoubleValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue,
*/
int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMils = false );
/**
* Convert the number Value in a string according to the internal units
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
*/
int ValueFromTextCtrl( const wxTextCtrl& aTextCtr );
/**
* Returns the units symbol.
*
* @param aUnits - Units requested.
* @param aFormatString - A formatting string to embed the units symbol into. Note:
* the format string must contain the %s format specifier.
* @return The formatted units symbol.
*/
// TODO: remove default value for aUnits
wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
const wxString& aFormatString = " (%s):" );
/**
* Get a human readable units string.
*
@ -199,10 +172,7 @@ wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
* @return The human readable units string.
*/
wxString GetUnitsLabel( EDA_UNITS_T aUnits, bool aUseMils = false );
// TODO: remove default value for aUnits
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit, bool aUseMils = false );
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit, bool aUseMils = false );
// TODO: remove (units should either be in textControl or handled by UNIT_BINDER)
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit );
#endif // _BASE_UNITS_H_

View File

@ -163,8 +163,6 @@ enum EDA_UNITS_T {
};
extern EDA_UNITS_T g_UserUnit; ///< display units
/// Draw color for moving objects.
extern KIGFX::COLOR4D g_GhostColor;

View File

@ -108,46 +108,6 @@ private:
};
/**
* Class EDA_GRAPHIC_TEXT_CTRL
* is a custom text edit control to edit/enter Kicad dimensions ( INCHES or MM )
*/
class EDA_GRAPHIC_TEXT_CTRL
{
public:
EDA_UNITS_T m_UserUnit;
wxTextCtrl* m_FrameText;
wxTextCtrl* m_FrameSize;
private:
wxStaticText* m_Title;
public:
EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title,
const wxString& TextToEdit, int textsize,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200 );
~EDA_GRAPHIC_TEXT_CTRL();
const wxString GetText() const;
int GetTextSize();
void Enable( bool state );
void SetTitle( const wxString& title );
void SetFocus() { m_FrameText->SetFocus(); }
void SetValue( const wxString& value );
void SetValue( int value );
/**
* Function FormatSize
* formats a string containing the size in the desired units.
*/
static wxString FormatSize( EDA_UNITS_T user_unit, int textSize );
static int ParseSize( const wxString& sizeText, EDA_UNITS_T user_unit );
};
/**************************************************************************/
/* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */
/* dialog boxes, */
@ -156,10 +116,10 @@ class EDA_POSITION_CTRL
{
public:
EDA_UNITS_T m_UserUnit;
wxPoint m_Pos_To_Edit;
wxTextCtrl* m_FramePosX;
wxTextCtrl* m_FramePosY;
private:
wxStaticText* m_TextX, * m_TextY;
@ -190,32 +150,5 @@ public:
};
/****************************************************************/
/* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */
/****************************************************************/
class EDA_VALUE_CTRL
{
public:
EDA_UNITS_T m_UserUnit;
int m_Value;
wxTextCtrl* m_ValueCtrl;
private:
wxStaticText* m_Text;
public:
EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
~EDA_VALUE_CTRL();
int GetValue();
void SetValue( int new_value );
void Enable( bool enbl );
void SetToolTip( const wxString& text )
{
m_ValueCtrl->SetToolTip( text );
}
};
#endif // DIALOG_HELPERS_H_

View File

@ -55,8 +55,7 @@ as key. This can be used to restore the input string of a text entry field.
Unit conversion
The evaluator uses a default unit and constants can be specified with a unit.
As long as no units are used the default unit is not relevant. The default
unit is taken from the global (Kicad) variable g_UserUnit.
As long as no units are used the default unit is not relevant.
Supported units are millimeters (mm), Mil (mil) and inch (")
eval.process("1\"");

View File

@ -62,7 +62,6 @@ bool PANEL_MODEDIT_SETTINGS::TransferDataFromWindow()
displ_opts->m_DisplayPolarCood = m_PolarDisplay->GetSelection() != 0;
m_frame->SetUserUnits( m_UnitsSelection->GetSelection() == 0 ? INCHES : MILLIMETRES );
g_UserUnit = m_frame->GetUserUnits(); // JEY TODO: double-up while in transition...
// Editing options
m_frame->Settings().m_use45DegreeGraphicSegments = m_Segments_45_Only_Ctrl->GetValue();

View File

@ -73,7 +73,6 @@ bool PANEL_PCBNEW_SETTINGS::TransferDataFromWindow()
displ_opts->m_DisplayPolarCood = m_PolarDisplay->GetSelection() != 0;
m_Frame->SetUserUnits( m_UnitsSelection->GetSelection() == 0 ? INCHES : MILLIMETRES );
g_UserUnit = m_Frame->GetUserUnits(); // JEY TODO: double-up while in transition...
m_Frame->SetRotationAngle( wxRound( 10.0 * wxAtof( m_RotationAngle->GetValue() ) ) );

View File

@ -216,9 +216,11 @@ protected:
void update() override
{
const BOARD_DESIGN_SETTINGS &bds = m_frame.GetBoard()->GetDesignSettings();
bool useIndex = !bds.m_UseConnectedTrackWidth && !bds.UseCustomTrackViaSize();
wxString msg;
EDA_UNITS_T units = m_frame.GetUserUnits();
BOARD_DESIGN_SETTINGS& bds = m_frame.GetBoard()->GetDesignSettings();
bool useIndex = !bds.m_UseConnectedTrackWidth &&
!bds.UseCustomTrackViaSize();
wxString msg;
Clear();
@ -246,7 +248,7 @@ protected:
if( i == 0 )
msg = _( "Track netclass width" );
else
msg = _( "Track " ) + MessageTextFromValue( g_UserUnit, width, true );
msg = _( "Track " ) + MessageTextFromValue( units, width, true );
int menuIdx = ID_POPUP_PCB_SELECT_WIDTH1 + i;
Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
@ -263,10 +265,10 @@ protected:
msg = _( "Via netclass values" );
else
{
msg = _( "Via " ) + MessageTextFromValue( g_UserUnit, via.m_Diameter, true );
msg = _( "Via " ) + MessageTextFromValue( units, via.m_Diameter, true );
if( via.m_Drill > 0 )
msg << _(", drill " ) << MessageTextFromValue( g_UserUnit, via.m_Drill, true );
msg << _(", drill " ) << MessageTextFromValue( units, via.m_Drill, true );
}
int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i;