Commit 6468805c authored by Wayne Stambaugh's avatar Wayne Stambaugh

More internal unit improvements.

* Move all convert from user to internal units into base_units.cpp.
* Remove internal units parameters from all moved conversion functions.
* Revise all source code that calls the moved conversion functions.
* Remove internal units from all dialog text control helper classes.
parent 5d5eb7d3
......@@ -44,13 +44,19 @@
#if defined( USE_PCBNEW_NANOMETRES )
#define IU_TO_MM( x ) ( x * 1e-6 )
#define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 )
#define MM_TO_IU( x ) ( x * 1e6 )
#define IN_TO_IU( x ) ( ( x * 25.4 ) * 1e6 )
#else
#define IU_TO_MM( x ) ( ( x * 0.0001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.0001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 10000.0 )
#define IN_TO_IU( x ) ( x * 10000.0 )
#endif
#elif defined( EESCHEMA )
#define IU_TO_MM( x ) ( ( x * 0.001 ) * 25.4 )
#define IU_TO_IN( x ) ( x * 0.001 )
#define MM_TO_IU( x ) ( ( x / 25.4 ) * 1000.0 )
#define IN_TO_IU( x ) ( x * 1000.0 )
#else
#error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW."
#endif
......@@ -159,3 +165,99 @@ void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue )
aTextCtr.SetValue( msg );
}
int From_User_Unit( EDA_UNITS_T aUnit, double aValue )
{
double value;
switch( aUnit )
{
case MILLIMETRES:
value = MM_TO_IU( aValue );
break;
case INCHES:
value = IN_TO_IU( aValue );
break;
default:
case UNSCALED_UNITS:
value = aValue;
}
return wxRound( value );
}
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue )
{
int Value;
double dtmp = 0;
// Acquire the 'right' decimal point separator
const struct lconv* lc = localeconv();
wxChar decimal_point = lc->decimal_point[0];
wxString buf( aTextValue.Strip( wxString::both ) );
// Convert the period in decimal point
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
// back to a point as separator, although the separator is the comma
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
// Find the end of the numeric part
unsigned brk_point = 0;
while( brk_point < buf.Len() )
{
wxChar ch = buf[brk_point];
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
{
break;
}
++brk_point;
}
// Extract the numeric part
buf.Left( brk_point ).ToDouble( &dtmp );
// Check the optional unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnits = INCHES;
}
else if( unit == wxT( "mm" ) )
{
aUnits = MILLIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
{
aUnits = INCHES;
dtmp /= 1000;
}
Value = From_User_Unit( aUnits, dtmp );
return Value;
}
int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
{
int value;
wxString msg = aTextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg );
return value;
}
......@@ -253,76 +253,6 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit )
}
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
{
int value;
wxString msg = TextCtr.GetValue();
value = ReturnValueFromString( g_UserUnit, msg, Internal_Unit );
return value;
}
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit )
{
int Value;
double dtmp = 0;
// Acquire the 'right' decimal point separator
const struct lconv* lc = localeconv();
wxChar decimal_point = lc->decimal_point[0];
wxString buf( TextValue.Strip( wxString::both ) );
// Convert the period in decimal point
buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) );
// An ugly fix needed by WxWidgets 2.9.1 that sometimes
// back to a point as separator, although the separator is the comma
// TODO: remove this line if WxWidgets 2.9.2 fixes this issue
buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) );
// Find the end of the numeric part
unsigned brk_point = 0;
while( brk_point < buf.Len() )
{
wxChar ch = buf[brk_point];
if( !( (ch >= '0' && ch <='9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) )
{
break;
}
++brk_point;
}
// Extract the numeric part
buf.Left( brk_point ).ToDouble( &dtmp );
// Check the optional unit designator (2 ch significant)
wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() );
if( unit == wxT( "in" ) || unit == wxT( "\"" ) )
{
aUnit = INCHES;
}
else if( unit == wxT( "mm" ) )
{
aUnit = MILLIMETRES;
}
else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) // Mils or thous
{
aUnit = INCHES;
dtmp /= 1000;
}
Value = From_User_Unit( aUnit, dtmp, Internal_Unit );
return Value;
}
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
{
wxArrayString* list = new wxArrayString();
......@@ -349,33 +279,6 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter )
}
/*
* Return in internal units the value "val" given in inch or mm
*/
int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value )
{
double value;
switch( aUnit )
{
case MILLIMETRES:
value = val * internal_unit_value / 25.4;
break;
case INCHES:
value = val * internal_unit_value;
break;
default:
case UNSCALED_UNITS:
value = val;
}
return wxRound( value );
}
/*
* Return the string date "day month year" like "23 jun 2005"
*/
......
......@@ -41,17 +41,14 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
int textsize,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer,
int framelen,
int internal_unit )
int framelen )
{
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
m_Title = NULL;
m_Title = new wxStaticText( parent, -1, Title );
BoxSizer->Add( m_Title, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FrameText = new wxTextCtrl( parent, -1, TextToEdit );
......@@ -62,14 +59,12 @@ EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent,
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_UserUnit );
wxStaticText* text = new wxStaticText( parent, -1, msg );
BoxSizer->Add( text, 0,
wxGROW | wxLEFT | wxRIGHT, 5 );
BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 );
}
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textsize );
wxString value = FormatSize( m_UserUnit, textsize );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition,
wxSize( 70, -1 ) );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) );
BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
}
......@@ -84,11 +79,8 @@ EDA_GRAPHIC_TEXT_CTRL::~EDA_GRAPHIC_TEXT_CTRL()
}
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit,
int textSize )
wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( EDA_UNITS_T aUnit, int textSize )
{
wxString value;
// Limiting the size of the text of reasonable values.
if( textSize < 10 )
textSize = 10;
......@@ -96,10 +88,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit,
if( textSize > 3000 )
textSize = 3000;
value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
To_User_Unit( aUnit, textSize ) );
return value;
return ReturnStringFromValue( aUnit, textSize );
}
......@@ -117,7 +106,7 @@ void EDA_GRAPHIC_TEXT_CTRL::SetValue( const wxString& value )
void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize )
{
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textSize );
wxString value = FormatSize( m_UserUnit, textSize );
m_FrameSize->SetValue( value );
}
......@@ -129,12 +118,11 @@ const wxString EDA_GRAPHIC_TEXT_CTRL::GetText() const
}
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText,
int internalUnit, EDA_UNITS_T aUnit )
int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText, EDA_UNITS_T aUnit )
{
int textsize;
textsize = ReturnValueFromString( aUnit, sizeText, internalUnit );
textsize = ReturnValueFromString( aUnit, sizeText );
// Limit to reasonable size
if( textsize < 10 )
......@@ -149,7 +137,7 @@ int EDA_GRAPHIC_TEXT_CTRL::ParseSize( const wxString& sizeText,
int EDA_GRAPHIC_TEXT_CTRL::GetTextSize()
{
return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_UserUnit );
return ParseSize( m_FrameSize->GetValue(), m_UserUnit );
}
......@@ -166,13 +154,11 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
EDA_UNITS_T user_unit,
wxBoxSizer* BoxSizer,
int internal_unit )
wxBoxSizer* BoxSizer )
{
wxString text;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Pos " );
......@@ -182,10 +168,8 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
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_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 );
......@@ -198,8 +182,7 @@ EDA_POSITION_CTRL::EDA_POSITION_CTRL( wxWindow* parent,
m_TextY = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextY, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
BoxSizer->Add( m_TextY, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
m_FramePosY = new wxTextCtrl( parent, -1, wxEmptyString );
......@@ -224,8 +207,8 @@ wxPoint EDA_POSITION_CTRL::GetValue()
{
wxPoint coord;
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue(), m_Internal_Unit );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue(), m_Internal_Unit );
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue() );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue() );
return coord;
}
......@@ -259,12 +242,10 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value )
/* 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,
int internal_unit ) :
EDA_POSITION_CTRL( parent, title,
wxPoint( size_to_edit.x, size_to_edit.y ),
aUnit, aBoxSizer, internal_unit )
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 )
{
}
......@@ -284,23 +265,20 @@ wxSize EDA_SIZE_CTRL::GetValue()
/* 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,
int internal_unit )
int value, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer )
{
wxString label = title;
m_UserUnit = user_unit;
m_Internal_Unit = internal_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 );
BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
BoxSizer->Add( m_ValueCtrl,
0,
......@@ -321,7 +299,7 @@ int EDA_VALUE_CTRL::GetValue()
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString( m_UserUnit, txtvalue, m_Internal_Unit );
coord = ReturnValueFromString( m_UserUnit, txtvalue );
return coord;
}
......
......@@ -92,8 +92,7 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
void DIALOG_SVG_PRINT::SetPenWidth()
{
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() );
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DialogPenWidth );
if( g_DrawDefaultLineThickness > WIDTH_MAX_VALUE )
{
......@@ -118,7 +117,7 @@ void DIALOG_SVG_PRINT::PrintSVGDoc( bool aPrintAll, bool aPrint_Sheet_Ref )
SetPenWidth();
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DialogPenWidth, m_Parent->GetInternalUnits() );
ReturnValueFromTextCtrl( *m_DialogPenWidth );
SCH_SCREEN* screen = (SCH_SCREEN*) m_Parent->GetScreen();
......
......@@ -631,8 +631,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
else
fieldValueTextCtrl->Enable( true );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT,
g_UserUnit, field.m_Size.x ) );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero = -m_Cmp->m_Pos; // relative zero
......@@ -711,11 +710,11 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.m_Size.y = field.m_Size.x;
int style = m_StyleRadioBox->GetSelection();
if( (style & 1 ) != 0 )
field.m_Italic = true;
else
......@@ -726,10 +725,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
else
field.m_Bold = false;
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
return true;
}
......
......@@ -261,7 +261,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UserUnit, text, m_Parent->GetInternalUnits() );
value = ReturnValueFromString( g_UserUnit, text );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
......
......@@ -658,8 +658,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
fieldValueTextCtrl->SetValue( field.m_Text );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( EESCHEMA_INTERNAL_UNIT,
g_UserUnit, field.m_Size.x ) );
textSizeTextCtrl->SetValue( EDA_GRAPHIC_TEXT_CTRL::FormatSize( g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero;
......@@ -745,8 +744,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.x = EDA_GRAPHIC_TEXT_CTRL::ParseSize( textSizeTextCtrl->GetValue(), g_UserUnit );
field.m_Size.y = field.m_Size.x;
......@@ -761,10 +759,8 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
else
field.m_Bold = false;
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue() );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue() );
// Note: the Y axis for components in lib is from bottom to top
// and the screen axis is top to bottom: we must change the y coord sign for editing
......
......@@ -133,7 +133,7 @@ void DIALOG_EDIT_ONE_FIELD::TransfertDataToField()
{
m_textorient = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_textsize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
m_textsize = ReturnValueFromString( g_UserUnit, msg );
switch( m_TextHJustificationOpt->GetSelection() )
{
......
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <base_units.h>
#include <libeditframe.h>
#include <class_libentry.h>
#include <lib_pin.h>
......@@ -91,11 +93,11 @@ void DIALOG_LIB_EDIT_PIN::OnPropertiesChange( wxCommandEvent& event )
{
if( ! IsShown() ) // do nothing at init time
return;
int units = ((LIB_EDIT_FRAME*)GetParent())->GetInternalUnits();
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize(), units );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize(), units);
int pinNameSize = ReturnValueFromString( g_UserUnit, GetNameTextSize() );
int pinNumSize = ReturnValueFromString( g_UserUnit, GetPadNameTextSize());
int pinOrient = LIB_PIN::GetOrientationCode( GetOrientation() );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength(), units );
int pinLength = ReturnValueFromString( g_UserUnit, GetLength() );
int pinShape = LIB_PIN::GetStyleCode( GetStyle() );
int pinType = GetElectricalType();
......
......@@ -148,7 +148,7 @@ void DIALOG_LIB_EDIT_TEXT::OnOkClick( wxCommandEvent& event )
Line = m_TextValue->GetValue();
m_parent->m_textOrientation = m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
m_parent->m_textSize = ReturnValueFromString( g_UserUnit, msg );
m_parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
m_parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
......
......@@ -207,19 +207,19 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::AcceptPlotOffset( wxCommandEvent& event )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_PlotOrgPosition_Y->GetValue();
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.y = ReturnValueFromString( g_UserUnit, msg );
}
}
void DIALOG_PLOT_SCHEMATIC_HPGL::SetPenWidth( )
{
g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl,
EESCHEMA_INTERNAL_UNIT);
g_HPGL_Pen_Descr.m_Pen_Diam = ReturnValueFromTextCtrl( *m_penWidthCtrl );
if( g_HPGL_Pen_Descr.m_Pen_Diam > 100 )
g_HPGL_Pen_Descr.m_Pen_Diam = 100;
......@@ -262,11 +262,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::HPGL_Plot( bool aPlotAll )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
s_Offset.x = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_PlotOrgPosition_Y->GetValue();
s_Offset.y = ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
s_Offset.y = ReturnValueFromString( g_UserUnit, msg );
}
Plot_Schematic_HPGL( aPlotAll );
......
......@@ -164,8 +164,8 @@ void DIALOG_PLOT_SCHEMATIC_PS::initOptVars()
m_plot_Sheet_Ref = m_Plot_Sheet_Ref_Ctrl->GetValue();
m_plotColorOpt = m_PlotPSColorOption->GetSelection();
m_pageSizeSelect = m_SizeOption->GetSelection();
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl,
EESCHEMA_INTERNAL_UNIT );
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultLineSizeCtrl );
if( g_DrawDefaultLineThickness < 1 )
g_DrawDefaultLineThickness = 1;
}
......
......@@ -119,10 +119,10 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event )
}
// Save the pin properties to use for the next new pin.
LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize(), m_internalUnits );
LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize(), m_internalUnits );
LastPinNameSize = ReturnValueFromString( g_UserUnit, dlg.GetNameTextSize() );
LastPinNumSize = ReturnValueFromString( g_UserUnit, dlg.GetPadNameTextSize() );
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(), m_internalUnits );
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength() );
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
LastPinType = dlg.GetElectricalType();
LastPinCommonConvert = dlg.GetAddToAllBodyStyles();
......
......@@ -189,13 +189,9 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
else if( loadFromFile )
aSheet->Load( this );
aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit,
dlg.GetFileNameTextSize(),
m_internalUnits ) );
aSheet->SetFileNameSize( ReturnValueFromString( g_UserUnit, dlg.GetFileNameTextSize() ) );
aSheet->SetName( dlg.GetSheetName() );
aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit,
dlg.GetSheetNameTextSize(),
m_internalUnits ) );
aSheet->SetSheetNameSize( ReturnValueFromString( g_UserUnit, dlg.GetSheetNameTextSize() ) );
if( aSheet->GetName().IsEmpty() )
aSheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), aSheet->GetTimeStamp() ) );
......
......@@ -85,8 +85,8 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC )
}
aSheetPin->m_Text = dlg.GetLabelName();
aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight(), m_internalUnits );
aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth(), m_internalUnits );
aSheetPin->m_Size.y = ReturnValueFromString( g_UserUnit, dlg.GetTextHeight() );
aSheetPin->m_Size.x = ReturnValueFromString( g_UserUnit, dlg.GetTextWidth() );
aSheetPin->SetShape( dlg.GetConnectionType() );
if( aDC )
......
......@@ -82,7 +82,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem )
return;
val = dialog.GetWidth();
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val, m_internalUnits );
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val );
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
m_drawSpecificUnit = !dialog.GetApplyToAllUnits();
......
......@@ -93,4 +93,25 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb
*/
void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue );
/**
* Return in internal units the value "val" given in inch or mm
*/
int From_User_Unit( EDA_UNITS_T aUnit, double aValue );
/**
* Function ReturnValueFromeString
* converts \a aTextValue in \a aUnits to internal units used by the application.
*
* @param aUnits The units of \a aTextValue.
* @param aTextValue A reference to a wxString object containing the string to convert.
* @return The string from Value, according to units (inch, mm ...) for display,
*/
int ReturnValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue );
/**
* 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 ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr );
#endif // _BASE_UNITS_H_
......@@ -557,23 +557,8 @@ wxString ReturnUnitSymbol( EDA_UNITS_T aUnits = g_UserUnit,
wxString GetUnitsLabel( EDA_UNITS_T aUnits );
wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit );
/**
* Function ReturnValueFromeString
* @return The string from Value, according to units (inch, mm ...) for display,
* and the initial unit for value
* Unit = display units (INCH, MM ..)
* Value = text
* Internal_Unit = units per inch for computed value
*/
int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit );
void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit );
/* 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 ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit );
/**
* Round to the nearest precision.
*
......@@ -593,11 +578,6 @@ double RoundTo0( double x, double precision );
*/
wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter );
/**
* Return in internal units the value "val" given in inch or mm
*/
int From_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value );
/**
* Function GenDate
* @return A wxString object containing the date in the format "day month year" like
......
......@@ -70,7 +70,6 @@ class EDA_GRAPHIC_TEXT_CTRL
{
public:
EDA_UNITS_T m_UserUnit;
int m_Internal_Unit;
wxTextCtrl* m_FrameText;
wxTextCtrl* m_FrameSize;
......@@ -80,8 +79,7 @@ private:
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,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200 );
~EDA_GRAPHIC_TEXT_CTRL();
......@@ -90,7 +88,7 @@ public:
void Enable( bool state );
void SetTitle( const wxString& title );
void SetFocus() { m_FrameText->SetFocus(); }
void SetFocus() { m_FrameText->SetFocus(); }
void SetValue( const wxString& value );
void SetValue( int value );
......@@ -98,10 +96,9 @@ public:
* Function FormatSize
* formats a string containing the size in the desired units.
*/
static wxString FormatSize( int internalUnit, EDA_UNITS_T user_unit, int textSize );
static wxString FormatSize( EDA_UNITS_T user_unit, int textSize );
static int ParseSize( const wxString& sizeText, int internalUnit,
EDA_UNITS_T user_unit );
static int ParseSize( const wxString& sizeText, EDA_UNITS_T user_unit );
};
......@@ -113,7 +110,6 @@ class EDA_POSITION_CTRL
{
public:
EDA_UNITS_T m_UserUnit;
int m_Internal_Unit;
wxPoint m_Pos_To_Edit;
wxTextCtrl* m_FramePosX;
......@@ -123,9 +119,7 @@ private:
public:
EDA_POSITION_CTRL( wxWindow* parent, const wxString& title,
const wxPoint& pos_to_edit,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
~EDA_POSITION_CTRL();
......@@ -143,9 +137,7 @@ class EDA_SIZE_CTRL : public EDA_POSITION_CTRL
{
public:
EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
const wxSize& size_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
~EDA_SIZE_CTRL() { }
wxSize GetValue();
......@@ -162,13 +154,11 @@ public:
int m_Value;
wxTextCtrl* m_ValueCtrl;
private:
int m_Internal_Unit;
wxStaticText* m_Text;
public:
EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value,
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
~EDA_VALUE_CTRL();
......
......@@ -135,8 +135,7 @@ void DIALOG_SVG_PRINT::initDialog( )
void DIALOG_SVG_PRINT::SetPenWidth()
{
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth,
m_Parent->GetInternalUnits() );
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth );
if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE )
{
......
......@@ -382,8 +382,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
m_settings.m_FillMode = (m_FillModeCtrl->GetSelection() == 0) ? 0 : 1;
wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
m_settings.m_ZoneClearance =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
m_settings.m_ZoneClearance = ReturnValueFromString( g_UserUnit, txtvalue );
// Test if this is a reasonnable value for this parameter
// A too large value can hang Pcbnew
......@@ -395,18 +394,18 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
}
txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_settings.m_ZoneMinThickness =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue );
if( m_settings.m_ZoneMinThickness < 10 )
{
DisplayError( this,
_( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) );
_( "Minimum width must be larger than 0.001\" / 0.0254 mm." ) );
return false;
}
m_settings.SetCornerSmoothingType( m_cornerSmoothingChoice->GetSelection() );
txtvalue = m_cornerSmoothingCtrl->GetValue();
m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() ) );
m_settings.SetCornerRadius( ReturnValueFromString( g_UserUnit, txtvalue ) );
m_settings.m_ZonePriority = m_PriorityLevelCtrl->GetValue();
......@@ -415,11 +414,9 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aPromptForErrors, bool aUseExportab
else
m_settings.m_Zone_45_Only = true;
m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue, PCB_INTERNAL_UNIT );
m_settings.m_ThermalReliefGap = ReturnValueFromTextCtrl( *m_AntipadSizeValue );
m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl(
*m_CopperWidthValue,
PCB_INTERNAL_UNIT );
m_settings.m_ThermalReliefCopperBridge = ReturnValueFromTextCtrl( *m_CopperWidthValue );
m_Config->Write( ZONE_THERMAL_RELIEF_GAP_STRING_KEY, (long) m_settings.m_ThermalReliefGap );
......
......@@ -531,7 +531,7 @@ void DIALOG_DESIGN_RULES::InitRulesList()
static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units )
{
#define MYCELL( col ) \
ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units )
ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ) )
nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
......@@ -595,22 +595,17 @@ void DIALOG_DESIGN_RULES::CopyGlobalRulesToBoard()
m_BrdSettings.m_CurrentViaType = VIA_BLIND_BURIED;
// Update vias minimum values for DRC
m_BrdSettings.m_ViasMinSize =
ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_ViasMinDrill =
ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_ViasMinSize = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl );
m_BrdSettings.m_ViasMinDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl );
m_BrdSettings.m_MicroViasAllowed = m_AllowMicroViaCtrl->GetSelection() == 1;
// Update microvias minimum values for DRC
m_BrdSettings.m_MicroViasMinSize =
ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_MicroViasMinDrill =
ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_MicroViasMinSize = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl );
m_BrdSettings.m_MicroViasMinDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl );
// Update tracks minimum values for DRC
m_BrdSettings.m_TrackMinWidth =
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl );
}
......@@ -625,9 +620,11 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard()
for( int row = 0; row < m_gridTrackWidthList->GetNumberRows(); ++row )
{
msg = m_gridTrackWidthList->GetCellValue( row, 0 );
if( msg.IsEmpty() )
continue;
int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() );
int value = ReturnValueFromString( g_UserUnit, msg );
m_TracksWidthList.push_back( value );
}
......@@ -636,20 +633,25 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard()
// Reinitialize m_TrackWidthList
m_ViasDimensionsList.clear();
for( int row = 0; row < m_gridViaSizeList->GetNumberRows(); ++row )
{
msg = m_gridViaSizeList->GetCellValue( row, 0 );
if( msg.IsEmpty() )
continue;
int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() );
int value = ReturnValueFromString( g_UserUnit, msg );
VIA_DIMENSION via_dim;
via_dim.m_Diameter = value;
msg = m_gridViaSizeList->GetCellValue( row, 1 );
if( !msg.IsEmpty() )
{
value = ReturnValueFromString( g_UserUnit, msg, m_Parent->GetInternalUnits() );
value = ReturnValueFromString( g_UserUnit, msg );
via_dim.m_Drill = value;
}
m_ViasDimensionsList.push_back( via_dim );
}
......@@ -979,54 +981,46 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
wxString msg;
int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl,
m_Parent->GetInternalUnits() );
int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl,
m_Parent->GetInternalUnits() );
int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl,
m_Parent->GetInternalUnits() );
int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl,
m_Parent->GetInternalUnits() );
int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl,
m_Parent->GetInternalUnits() );
int minViaDia = ReturnValueFromTextCtrl( *m_SetViasMinSizeCtrl );
int minViaDrill = ReturnValueFromTextCtrl( *m_SetViasMinDrillCtrl );
int minUViaDia = ReturnValueFromTextCtrl( *m_SetMicroViasMinSizeCtrl );
int minUViaDrill = ReturnValueFromTextCtrl( *m_SetMicroViasMinDrillCtrl );
int minTrackWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl );
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
{
int tracksize = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_TRACKSIZE ),
m_Parent->GetInternalUnits() );
m_grid->GetCellValue( row, GRID_TRACKSIZE ) );
if( tracksize < minTrackWidth )
{
result = false;
msg.Printf( _( "%s: <b>Track Size</b> &lt; <b>Min Track Size</b><br>" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
GetChars( m_grid->GetRowLabelValue( row ) ) );
m_MessagesList->AppendToPage( msg );
}
// Test vias
int viadia = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_VIASIZE ),
m_Parent->GetInternalUnits() );
m_grid->GetCellValue( row, GRID_VIASIZE ) );
if( viadia < minViaDia )
{
result = false;
msg.Printf( _( "%s: <b>Via Diameter</b> &lt; <b>Minimun Via Diameter</b><br>" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
GetChars( m_grid->GetRowLabelValue( row ) ) );
m_MessagesList->AppendToPage( msg );
}
int viadrill = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_VIADRILL ),
m_Parent->GetInternalUnits() );
m_grid->GetCellValue( row, GRID_VIADRILL ) );
if( viadrill >= viadia )
{
result = false;
msg.Printf( _( "%s: <b>Via Drill</b> &ge; <b>Via Dia</b><br>" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
GetChars( m_grid->GetRowLabelValue( row ) ) );
m_MessagesList->AppendToPage( msg );
}
......@@ -1035,28 +1029,26 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
{
result = false;
msg.Printf( _( "%s: <b>Via Drill</b> &lt; <b>Min Via Drill</b><br>" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
GetChars( m_grid->GetRowLabelValue( row ) ) );
m_MessagesList->AppendToPage( msg );
}
// Test Micro vias
int muviadia = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_uVIASIZE ),
m_Parent->GetInternalUnits() );
m_grid->GetCellValue( row, GRID_uVIASIZE ) );
if( muviadia < minUViaDia )
{
result = false;
msg.Printf( _( "%s: <b>MicroVia Diameter</b> &lt; <b>MicroVia Min Diameter</b><br>" ),
GetChars( m_grid->GetRowLabelValue( row ) ) );
GetChars( m_grid->GetRowLabelValue( row ) ) );
m_MessagesList->AppendToPage( msg );
}
int muviadrill = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_uVIADRILL ),
m_Parent->GetInternalUnits() );
m_grid->GetCellValue( row, GRID_uVIADRILL ) );
if( muviadrill >= muviadia )
{
result = false;
......@@ -1084,14 +1076,13 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
if( tvalue.IsEmpty() )
continue;
int tracksize = ReturnValueFromString( g_UserUnit,
tvalue,
m_Parent->GetInternalUnits() );
int tracksize = ReturnValueFromString( g_UserUnit, tvalue );
if( tracksize < minTrackWidth )
{
result = false;
msg.Printf( _( "<b>Extra Track %d Size</b> %s &lt; <b>Min Track Size</b><br>" ),
row + 1, GetChars( tvalue ) );
row + 1, GetChars( tvalue ) );
m_MessagesList->AppendToPage( msg );
}
......@@ -1112,18 +1103,18 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
if( tvalue.IsEmpty() )
continue;
int viadia = ReturnValueFromString( g_UserUnit, tvalue,
m_Parent->GetInternalUnits() );
int viadia = ReturnValueFromString( g_UserUnit, tvalue );
int viadrill = 0;
wxString drlvalue = m_gridViaSizeList->GetCellValue( row, 1 );
if( !drlvalue.IsEmpty() )
viadrill = ReturnValueFromString( g_UserUnit, drlvalue,
m_Parent->GetInternalUnits() );
viadrill = ReturnValueFromString( g_UserUnit, drlvalue );
if( viadia < minViaDia )
{
result = false;
msg.Printf( _( "<b>Extra Via %d Size</b> %s &lt; <b>Min Via Size</b><br>" ),
row + 1, GetChars( tvalue ) );
row + 1, GetChars( tvalue ) );
m_MessagesList->AppendToPage( msg );
}
......@@ -1132,7 +1123,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
{
result = false;
msg.Printf( _( "<b>Extra Via %d Size</b> %s &le; <b> Drill Size</b> %s<br>" ),
row + 1, GetChars( tvalue ), GetChars( drlvalue ) );
row + 1, GetChars( tvalue ), GetChars( drlvalue ) );
m_MessagesList->AppendToPage( msg );
}
......@@ -1142,7 +1133,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
{
result = false;
msg.Printf( _( "<b>Extra Via %d Size</b>%s &gt; <b>1 inch!</b><br>" ),
row + 1, GetChars( tvalue ) );
row + 1, GetChars( tvalue ) );
m_MessagesList->AppendToPage( msg );
}
......
......@@ -29,6 +29,7 @@
#include <fctsys.h>
#include <dialog_drc.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_board_design_settings.h>
......@@ -130,12 +131,9 @@ void DIALOG_DRC_CONTROL::InitValues()
*/
void DIALOG_DRC_CONTROL::SetDrcParmeters( )
{
m_BrdSettings.m_TrackMinWidth =
ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_ViasMinSize =
ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_MicroViasMinSize =
ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_TrackMinWidth = ReturnValueFromTextCtrl( *m_SetTrackMinWidthCtrl );
m_BrdSettings.m_ViasMinSize = ReturnValueFromTextCtrl( *m_SetViaMinSizeCtrl );
m_BrdSettings.m_MicroViasMinSize = ReturnValueFromTextCtrl( *m_SetMicroViakMinSizeCtrl );
m_Parent->GetBoard()->SetDesignSettings( m_BrdSettings );
}
......
......@@ -479,12 +479,9 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
m_CurrentModule->m_Value->Copy( m_ValueCopy );
// Initialize masks clearances
m_CurrentModule->SetLocalClearance(
ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, m_Parent->GetInternalUnits() ) );
m_CurrentModule->SetLocalSolderMaskMargin(
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() ) );
m_CurrentModule->SetLocalSolderPasteMargin(
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() ) );
m_CurrentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
m_CurrentModule->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
m_CurrentModule->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
double dtmp = 0.0;
msg = m_SolderPasteMarginRatioCtrl->GetValue();
......@@ -520,8 +517,8 @@ void DIALOG_MODULE_BOARD_EDITOR::OnOkClick( wxCommandEvent& event )
}
// Set Module Position
modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX, PCB_INTERNAL_UNIT );
modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY, PCB_INTERNAL_UNIT );
modpos.x = ReturnValueFromTextCtrl( *m_ModPositionX );
modpos.y = ReturnValueFromTextCtrl( *m_ModPositionY );
m_CurrentModule->SetPosition( modpos );
if( m_AutoPlaceCtrl->GetSelection() == 1 )
......
......@@ -367,16 +367,11 @@ void DIALOG_MODULE_MODULE_EDITOR::OnOkClick( wxCommandEvent& event )
m_CurrentModule->m_Value->Copy(m_ValueCopy );
// Initialize masks clearances
int internalUnit = m_Parent->GetInternalUnits();
m_CurrentModule->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
m_CurrentModule->SetLocalClearance(
ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl, internalUnit ) );
m_CurrentModule->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
m_CurrentModule->SetLocalSolderMaskMargin(
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, internalUnit ) );
m_CurrentModule->SetLocalSolderPasteMargin(
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, internalUnit ) );
m_CurrentModule->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
double dtmp;
wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp );
......
......@@ -163,19 +163,17 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
wxPoint tmp;
msg = m_TxtPosCtrlX->GetValue();
tmp.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
tmp.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_TxtPosCtrlY->GetValue();
tmp.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
tmp.y = ReturnValueFromString( g_UserUnit, msg );
m_currentText->SetPos0( tmp );
msg = m_TxtSizeCtrlX->GetValue();
m_currentText->m_Size.x = ReturnValueFromString( g_UserUnit, msg,
m_parent->GetInternalUnits() );
m_currentText->m_Size.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_TxtSizeCtrlY->GetValue();
m_currentText->m_Size.y = ReturnValueFromString( g_UserUnit, msg,
m_parent->GetInternalUnits() );
m_currentText->m_Size.y = ReturnValueFromString( g_UserUnit, msg );
// Test for a reasonnable size:
if( m_currentText->m_Size.x< TEXTS_MIN_SIZE )
......@@ -184,7 +182,7 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
m_currentText->m_Size.y = TEXTS_MIN_SIZE;
msg = m_TxtWidthCtlr->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
int width = ReturnValueFromString( g_UserUnit, msg );
// Test for a reasonnable width:
if( width <= 1 )
......
......@@ -199,22 +199,22 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
m_Item->Draw( m_parent->GetCanvas(), m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_Item->SetStartX( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_Center_StartYCtrl->GetValue();
m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_Item->SetStartY( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_EndX_Radius_Ctrl->GetValue();
m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_Item->SetEndX( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_EndY_Ctrl->GetValue();
m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_Item->SetEndY( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_ThicknessCtrl->GetValue();
m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_Item->SetWidth( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
int thickness = ReturnValueFromString( g_UserUnit, msg );
m_Item->SetLayer( m_LayerSelectionCtrl->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
......
......@@ -213,24 +213,24 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::OnOkClick( wxCommandEvent& event )
wxPoint coord;
msg = m_Center_StartXCtrl->GetValue();
coord.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
coord.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_Center_StartYCtrl->GetValue();
coord.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
coord.y = ReturnValueFromString( g_UserUnit, msg );
m_item->SetStart( coord );
m_item->SetStart0( coord );
msg = m_EndX_Radius_Ctrl->GetValue();
coord.x = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
coord.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_EndY_Ctrl->GetValue();
coord.y = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
coord.y = ReturnValueFromString( g_UserUnit, msg );
m_item->SetEnd( coord );
m_item->SetEnd0( coord );
msg = m_ThicknessCtrl->GetValue();
m_item->SetWidth( ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() ));
m_item->SetWidth( ReturnValueFromString( g_UserUnit, msg ) );
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UserUnit, msg, m_parent->GetInternalUnits() );
int thickness = ReturnValueFromString( g_UserUnit, msg );
m_brdSettings.m_ModuleSegmentWidth = thickness;
m_parent->SetDesignSettings( m_brdSettings );
......
......@@ -97,30 +97,20 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues()
void DIALOG_GRAPHIC_ITEMS_OPTIONS::OnOkClick( wxCommandEvent& event )
{
m_brdSettings.m_DrawSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbSegmWidth, PCB_INTERNAL_UNIT );
m_brdSettings.m_EdgeSegmentWidth =
ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth, PCB_INTERNAL_UNIT );
m_brdSettings.m_PcbTextWidth =
ReturnValueFromTextCtrl( *m_OptPcbTextWidth, PCB_INTERNAL_UNIT );
m_brdSettings.m_PcbTextSize.y =
ReturnValueFromTextCtrl( *m_OptPcbTextVSize, PCB_INTERNAL_UNIT );
m_brdSettings.m_PcbTextSize.x =
ReturnValueFromTextCtrl( *m_OptPcbTextHSize, PCB_INTERNAL_UNIT );
m_brdSettings.m_DrawSegmentWidth = ReturnValueFromTextCtrl( *m_OptPcbSegmWidth );
m_brdSettings.m_EdgeSegmentWidth = ReturnValueFromTextCtrl( *m_OptPcbEdgesWidth );
m_brdSettings.m_PcbTextWidth = ReturnValueFromTextCtrl( *m_OptPcbTextWidth );
m_brdSettings.m_PcbTextSize.y = ReturnValueFromTextCtrl( *m_OptPcbTextVSize );
m_brdSettings.m_PcbTextSize.x = ReturnValueFromTextCtrl( *m_OptPcbTextHSize );
m_parent->GetBoard()->SetDesignSettings( m_brdSettings );
m_brdSettings.m_ModuleSegmentWidth =
ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth, PCB_INTERNAL_UNIT );
m_brdSettings.m_ModuleTextWidth =
ReturnValueFromTextCtrl( *m_OptModuleTextWidth, PCB_INTERNAL_UNIT );
m_brdSettings.m_ModuleTextSize.y =
ReturnValueFromTextCtrl( *m_OptModuleTextVSize, PCB_INTERNAL_UNIT );
m_brdSettings.m_ModuleTextSize.x =
ReturnValueFromTextCtrl( *m_OptModuleTextHSize, PCB_INTERNAL_UNIT );
g_DrawDefaultLineThickness =
ReturnValueFromTextCtrl( *m_DefaultPenSizeCtrl, PCB_INTERNAL_UNIT );
m_brdSettings.m_ModuleSegmentWidth = ReturnValueFromTextCtrl( *m_OptModuleEdgesWidth );
m_brdSettings.m_ModuleTextWidth = ReturnValueFromTextCtrl( *m_OptModuleTextWidth );
m_brdSettings.m_ModuleTextSize.y = ReturnValueFromTextCtrl( *m_OptModuleTextVSize );
m_brdSettings.m_ModuleTextSize.x = ReturnValueFromTextCtrl( *m_OptModuleTextHSize );
g_DrawDefaultLineThickness = ReturnValueFromTextCtrl( *m_DefaultPenSizeCtrl );
if( g_DrawDefaultLineThickness < 0 )
g_DrawDefaultLineThickness = 0;
......
......@@ -83,11 +83,9 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit()
void DIALOG_PADS_MASK_CLEARANCE::OnButtonOkClick( wxCommandEvent& event )
{
m_BrdSettings.m_SolderMaskMargin =
ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_SolderMaskMargin = ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl );
m_BrdSettings.m_SolderPasteMargin =
ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl, m_Parent->GetInternalUnits() );
m_BrdSettings.m_SolderPasteMargin = ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl );
double dtmp = 0;
wxString msg = m_SolderPasteMarginRatioCtrl->GetValue();
......
......@@ -848,7 +848,6 @@ void DIALOG_PAD_PROPERTIES::PadPropertiesAccept( wxCommandEvent& event )
bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
{
long padLayerMask;
int internalUnits = m_Parent->GetInternalUnits();
wxString msg;
int x, y;
......@@ -856,16 +855,11 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
aPad->SetShape( CodeShape[m_PadShape->GetSelection()] );
// Read pad clearances values:
aPad->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl,
internalUnits ) );
aPad->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl,
internalUnits ) );
aPad->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl,
internalUnits ) );
aPad->SetThermalWidth( ReturnValueFromTextCtrl( *m_ThermalWidthCtrl,
internalUnits ) );
aPad->SetThermalGap( ReturnValueFromTextCtrl( *m_ThermalGapCtrl,
internalUnits ) );
aPad->SetLocalClearance( ReturnValueFromTextCtrl( *m_NetClearanceValueCtrl ) );
aPad->SetLocalSolderMaskMargin( ReturnValueFromTextCtrl( *m_SolderMaskMarginCtrl ) );
aPad->SetLocalSolderPasteMargin( ReturnValueFromTextCtrl( *m_SolderPasteMarginCtrl ) );
aPad->SetThermalWidth( ReturnValueFromTextCtrl( *m_ThermalWidthCtrl ) );
aPad->SetThermalGap( ReturnValueFromTextCtrl( *m_ThermalGapCtrl ) );
double dtmp = 0.0;
msg = m_SolderPasteMarginRatioCtrl->GetValue();
msg.ToDouble( &dtmp );
......@@ -899,15 +893,15 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
}
// Read pad position:
x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl, internalUnits );
y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl, internalUnits );
x = ReturnValueFromTextCtrl( *m_PadPosition_X_Ctrl );
y = ReturnValueFromTextCtrl( *m_PadPosition_Y_Ctrl );
aPad->SetPosition( wxPoint( x, y ) );
aPad->SetPos0( wxPoint( x, y ) );
// Read pad drill:
x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl, internalUnits );
y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl, internalUnits );
x = ReturnValueFromTextCtrl( *m_PadDrill_X_Ctrl );
y = ReturnValueFromTextCtrl( *m_PadDrill_Y_Ctrl );
if( m_DrillShapeCtrl->GetSelection() == 0 )
{
......@@ -920,24 +914,24 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
aPad->SetDrillSize( wxSize( x, y ) );
// Read pad shape size:
x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl, internalUnits );
y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl, internalUnits );
x = ReturnValueFromTextCtrl( *m_ShapeSize_X_Ctrl );
y = ReturnValueFromTextCtrl( *m_ShapeSize_Y_Ctrl );
if( aPad->GetShape() == PAD_CIRCLE )
y = x;
aPad->SetSize( wxSize( x, y ) );
// Read pad length die
aPad->SetDieLength( ReturnValueFromTextCtrl( *m_LengthDieCtrl, internalUnits ) );
aPad->SetDieLength( ReturnValueFromTextCtrl( *m_LengthDieCtrl ) );
// Read pad shape delta size:
// m_DeltaSize.x or m_DeltaSize.y must be NULL. for a trapezoid.
wxSize delta;
if( m_trapDeltaDirChoice->GetSelection() == 0 )
delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits );
delta.x = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl );
else
delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl, internalUnits );
delta.y = ReturnValueFromTextCtrl( *m_ShapeDelta_Ctrl );
// Test bad values (be sure delta values are not too large)
// remember DeltaSize.x is the Y size variation
......@@ -970,8 +964,8 @@ bool DIALOG_PAD_PROPERTIES::transferDataToPad( D_PAD* aPad )
aPad->SetDelta( delta );
// Read pad shape offset:
x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl, internalUnits );
y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl, internalUnits );
x = ReturnValueFromTextCtrl( *m_ShapeOffset_X_Ctrl );
y = ReturnValueFromTextCtrl( *m_ShapeOffset_Y_Ctrl );
aPad->SetOffset( wxPoint( x, y ) );
double orient_value = 0;
......
......@@ -219,17 +219,13 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event )
}
// Set PCB Text position
newPosition.x = ReturnValueFromString( g_UserUnit, m_PositionXCtrl->GetValue(),
m_Parent->GetInternalUnits() );
newPosition.y = ReturnValueFromString( g_UserUnit, m_PositionYCtrl->GetValue(),
m_Parent->GetInternalUnits() );
newPosition.x = ReturnValueFromString( g_UserUnit, m_PositionXCtrl->GetValue() );
newPosition.y = ReturnValueFromString( g_UserUnit, m_PositionYCtrl->GetValue() );
m_SelectedPCBText->m_Pos = newPosition;
// Check constraints and set PCB Text size
newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue(),
m_Parent->GetInternalUnits() );
newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue(),
m_Parent->GetInternalUnits() );
newSize.x = ReturnValueFromString( g_UserUnit, m_SizeXCtrl->GetValue() );
newSize.y = ReturnValueFromString( g_UserUnit, m_SizeYCtrl->GetValue() );
if( newSize.x < TEXTS_MIN_SIZE )
newSize.x = TEXTS_MIN_SIZE;
......@@ -247,8 +243,7 @@ void DIALOG_PCB_TEXT_PROPERTIES::OnOkClick( wxCommandEvent& event )
// Set the new thickness
m_SelectedPCBText->m_Thickness = ReturnValueFromString( g_UserUnit,
m_ThicknessCtrl->GetValue(),
m_Parent->GetInternalUnits() );
m_ThicknessCtrl->GetValue() );
// Test for acceptable values for thickness and size and clamp if fails
int maxthickness = Clamp_Text_PenSize( m_SelectedPCBText->m_Thickness,
......
......@@ -385,7 +385,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
// Get the new pen width value, and verify min et max value
// NOTE: s_Parameters.m_PenDefaultSize is in internal units
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth, m_parent->GetInternalUnits() );
s_Parameters.m_PenDefaultSize = ReturnValueFromTextCtrl( *m_DialogPenWidth );
if( s_Parameters.m_PenDefaultSize > WIDTH_MAX_VALUE )
{
......
......@@ -144,25 +144,20 @@ void DIALOG_DIMENSION_EDITOR::OnOKClick( wxCommandEvent& event )
// Get new size value:
msg = m_TxtSizeXCtrl->GetValue();
CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->GetInternalUnits() );
CurrentDimension->m_Text.m_Size.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_TxtSizeYCtrl->GetValue();
CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->GetInternalUnits() );
CurrentDimension->m_Text.m_Size.y = ReturnValueFromString( g_UserUnit, msg );
// Get new position value:
// It will be copied later in dimension, because
msg = m_textCtrlPosX->GetValue();
CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->GetInternalUnits() );
CurrentDimension->m_Text.m_Pos.x = ReturnValueFromString( g_UserUnit, msg );
msg = m_textCtrlPosY->GetValue();
CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->GetInternalUnits() );
CurrentDimension->m_Text.m_Pos.y = ReturnValueFromString( g_UserUnit, msg );
// Get new line thickness value:
msg = m_TxtWidthCtrl->GetValue();
int width = ReturnValueFromString( g_UserUnit, msg,
m_Parent->GetInternalUnits() );
int width = ReturnValueFromString( g_UserUnit, msg );
int maxthickness = Clamp_Text_PenSize( width, CurrentDimension->m_Text.m_Size );
if( width > maxthickness )
......
......@@ -246,8 +246,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge )
return; // canceled by user
buffer = dlg.GetValue( );
GetDesignSettings().m_ModuleSegmentWidth =
ReturnValueFromString( g_UserUnit, buffer, GetScreen()->GetInternalUnits() );
GetDesignSettings().m_ModuleSegmentWidth = ReturnValueFromString( g_UserUnit, buffer );
if( aEdge )
{
......
......@@ -103,14 +103,12 @@ TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR( PCB_EDIT_FRAME
// Size:
m_MireSizeCtrl = new EDA_VALUE_CTRL( this, _( "Size" ),
m_Target->GetSize(),
g_UserUnit, LeftBoxSizer,
m_Parent->GetInternalUnits() );
g_UserUnit, LeftBoxSizer );
// Width:
m_MireWidthCtrl = new EDA_VALUE_CTRL( this, _( "Width" ),
m_Target->GetWidth(),
g_UserUnit, LeftBoxSizer,
m_Parent->GetInternalUnits() );
g_UserUnit, LeftBoxSizer );
// Shape
wxString shape_list[2] = { _( "shape +" ), _( "shape X" ) };
......
......@@ -205,7 +205,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC )
return NULL; // canceled by user
msg = dlg.GetValue();
Mself.lng = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
Mself.lng = ReturnValueFromString( g_UserUnit, msg );
// Control values (ii = minimum length)
if( Mself.lng < min_len )
......@@ -621,7 +621,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type )
}
value = dlg.GetValue();
gap_size = ReturnValueFromString( g_UserUnit, value, GetScreen()->GetInternalUnits() );
gap_size = ReturnValueFromString( g_UserUnit, value );
bool abort = false;
......@@ -821,9 +821,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( PCB_EDIT_FRAME* parent,
wxRA_SPECIFY_COLS );
LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize,
g_UserUnit, LeftBoxSizer,
PCB_INTERNAL_UNIT );
m_SizeCtrl = new EDA_SIZE_CTRL( this, _( "Size" ), ShapeSize, g_UserUnit, LeftBoxSizer );
GetSizer()->Fit( this );
GetSizer()->SetSizeHints( this );
......@@ -1094,7 +1092,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule )
return; // cancelled by user
msg = dlg.GetValue();
gap_size = ReturnValueFromString( g_UserUnit, msg, GetScreen()->GetInternalUnits() );
gap_size = ReturnValueFromString( g_UserUnit, msg );
// Updating sizes of pads forming the gap.
int tw = GetBoard()->GetCurrentTrackWidth();
......
......@@ -450,7 +450,7 @@ void DIALOG_PLOT::applyPlotSettings()
// since the values may have been constrained by the setters.
// HPLG pen size
wxString msg = m_HPGLPenSizeOpt->GetValue();
int tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
int tmp = ReturnValueFromString( g_UserUnit, msg );
if( !tempOptions.SetHpglPenDiameter( tmp ) )
{
......@@ -462,7 +462,7 @@ void DIALOG_PLOT::applyPlotSettings()
// HPGL pen speed
msg = m_HPGLPenSpeedOpt->GetValue();
tmp = ReturnValueFromString( UNSCALED_UNITS, msg, 1 );
tmp = ReturnValueFromString( UNSCALED_UNITS, msg );
if( !tempOptions.SetHpglPenSpeed( tmp ) )
{
......@@ -474,7 +474,7 @@ void DIALOG_PLOT::applyPlotSettings()
// HPGL pen overlay
msg = m_HPGLPenOverlayOpt->GetValue();
tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
tmp = ReturnValueFromString( g_UserUnit, msg );
if( !tempOptions.SetHpglPenOverlay( tmp ) )
{
......@@ -486,7 +486,7 @@ void DIALOG_PLOT::applyPlotSettings()
// Default linewidth
msg = m_linesWidth->GetValue();
tmp = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT );
tmp = ReturnValueFromString( g_UserUnit, msg );
if( !tempOptions.SetPlotLineWidth( tmp ) )
{
......@@ -527,7 +527,7 @@ void DIALOG_PLOT::applyPlotSettings()
// PS Width correction
msg = m_PSFineAdjustWidthOpt->GetValue();
tmpDouble = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT );
tmpDouble = ReturnValueFromString( g_UserUnit, msg );
if( !setDouble( &m_PSWidthAdjust, tmpDouble, m_WidthAdjustMinValue, m_WidthAdjustMaxValue ) )
{
......
......@@ -125,8 +125,8 @@ wxPoint DIALOG_SET_GRID::GetGridOrigin()
wxPoint grid;
/* TODO: Some error checking here would be a good thing. */
grid.x = ReturnValueFromTextCtrl( *m_GridOriginXCtrl, m_internalUnits );
grid.y = ReturnValueFromTextCtrl( *m_GridOriginYCtrl, m_internalUnits );
grid.x = ReturnValueFromTextCtrl( *m_GridOriginXCtrl );
grid.y = ReturnValueFromTextCtrl( *m_GridOriginYCtrl );
return grid;
}
......
......@@ -128,8 +128,7 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::OnOkClick( wxCommandEvent& event )
{
wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_settings.m_ZoneMinThickness =
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->GetInternalUnits() );
m_settings.m_ZoneMinThickness = ReturnValueFromString( g_UserUnit, txtvalue );
if( m_settings.m_ZoneMinThickness < 10 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment