Commit bc14e66d authored by Dick Hollenbeck's avatar Dick Hollenbeck

A little useful feature: even if the default unit can be changed between

inches and mm, the industry is crazy enough to force us with mixed
design. For example I routinely use imperial units for track size and
clearance, but drilling is strictly a metric issue...

So I added a little parser to recognize a suffix specification in the
unit text boxes... so you can put in things like:
1in (1 inch)
1" (idem)
25th (25 thou)
25mi (25 mils, the same)
6mm (6 mm, obviously)

The rules are: spaces between the number and the unit are accepted, only
the first two letters are significant.

As a bonus, it also recognize the period (.) as a decimal point
substituting it with the correct locale character (there was a wishlist
for it, IIRC). Most useful for number pad fans :D 
parent 428ecb53
......@@ -183,7 +183,7 @@ Info_3D_Visu::~Info_3D_Visu()
* units */
WinEDA_VertexCtrl::WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer,
int units, int internal_unit )
UserUnitType units, int internal_unit )
{
wxString text;
wxStaticText* msgtitle;
......
......@@ -123,7 +123,7 @@ private:
public:
WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer, int units, int internal_unit );
wxBoxSizer* BoxSizer, UserUnitType units, int internal_unit );
~WinEDA_VertexCtrl();
......
......@@ -443,26 +443,24 @@ void BASE_SCREEN::AddGrid( const wxRealPoint& size, int id )
}
void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
void BASE_SCREEN::AddGrid( const wxRealPoint& size, UserUnitType aUnit, int id )
{
double x, y;
wxRealPoint new_size;
GRID_TYPE new_grid;
if( units == MILLIMETRE )
switch( aUnit )
{
case MILLIMETRES:
x = size.x / 25.4;
y = size.y / 25.4;
}
else if( units == CENTIMETRE )
{
x = size.x / 2.54;
y = size.y / 2.54;
}
else
{
break;
case INCHES:
case UNSCALED_UNITS:
x = size.x;
y = size.y;
break;
}
new_size.x = x * GetInternalUnits();
......
......@@ -80,8 +80,8 @@ int g_KeyPressed;
wxString g_Prj_Default_Config_FullFilename;
wxString g_Prj_Config_LocalFilename;
// Handle the preferred editor for browsing report files:
int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
/* Current user unit of measure */
UserUnitType g_UserUnit;
/* Draw color for moving objects: */
int g_GhostColor;
......@@ -221,23 +221,22 @@ Ki_PageDescr::Ki_PageDescr( const wxSize& size,
}
wxString ReturnUnitSymbol( int aUnits, const wxString& formatString )
wxString ReturnUnitSymbol( UserUnitType aUnit, const wxString& formatString )
{
wxString tmp;
wxString label;
switch( aUnits )
switch( aUnit )
{
case INCHES:
tmp = _( "\"" );
break;
case MILLIMETRE:
case MILLIMETRES:
tmp = _( "mm" );
break;
default:
tmp = _( "??" );
case UNSCALED_UNITS:
break;
}
......@@ -250,26 +249,22 @@ wxString ReturnUnitSymbol( int aUnits, const wxString& formatString )
}
wxString GetUnitsLabel( int aUnits )
wxString GetUnitsLabel( UserUnitType aUnit )
{
wxString label;
switch( aUnits )
switch( aUnit )
{
case INCHES:
label = _( "inches" );
break;
case MILLIMETRE:
case MILLIMETRES:
label = _( "millimeters" );
break;
case CENTIMETRE:
label = _( "centimeters" );
break;
default:
label = _( "Unknown" );
case UNSCALED_UNITS:
label = _( "units" );
break;
}
......@@ -277,26 +272,21 @@ wxString GetUnitsLabel( int aUnits )
}
wxString GetAbbreviatedUnitsLabel( int aUnits )
wxString GetAbbreviatedUnitsLabel( UserUnitType aUnit )
{
wxString label;
switch( aUnits )
switch( aUnit )
{
case INCHES:
label = _( "in" );
break;
case MILLIMETRE:
case MILLIMETRES:
label = _( "mm" );
break;
case CENTIMETRE:
label = _( "cm" );
break;
default:
label = _( "??" );
case UNSCALED_UNITS:
break;
}
......@@ -308,10 +298,11 @@ wxString GetAbbreviatedUnitsLabel( int aUnits )
* Add string " (mm):" or " ("):" to the static text Stext.
* Used in dialog boxes for entering values depending on selected units
*/
void AddUnitSymbol( wxStaticText& Stext, int Units )
void AddUnitSymbol( wxStaticText& Stext, UserUnitType aUnit )
{
wxString msg = Stext.GetLabel();
msg += ReturnUnitSymbol( Units );
msg += ReturnUnitSymbol( aUnit );
Stext.SetLabel( msg );
}
......@@ -319,11 +310,11 @@ void AddUnitSymbol( wxStaticText& Stext, int Units )
/*
* Convert the number Value in a string according to the internal units
* and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
*/
void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
{
wxString msg = ReturnStringFromValue( g_UnitMetric, Value, Internal_Unit );
wxString msg = ReturnStringFromValue( g_UserUnit, Value, Internal_Unit );
TextCtr.SetValue( msg );
}
......@@ -331,14 +322,14 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit )
/*
* Convert the Value in the wxTextCtrl TextCtrl in an integer,
* according to the internal units and the selected unit (g_UnitMetric)
* according to the internal units and the selected unit (g_UserUnit)
*/
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
{
int value;
wxString msg = TextCtr.GetValue();
value = ReturnValueFromString( g_UnitMetric, msg, Internal_Unit );
value = ReturnValueFromString( g_UserUnit, msg, Internal_Unit );
return value;
}
......@@ -354,35 +345,30 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit )
* @return a wxString what contains value and optionally the symbol unit
* (like 2.000 mm)
*/
wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
wxString ReturnStringFromValue( UserUnitType aUnit, int aValue, int aInternal_Unit,
bool aAdd_unit_symbol )
{
wxString StringValue;
double value_to_print;
if( aUnits >= CENTIMETRE )
StringValue << aValue;
else
{
value_to_print = To_User_Unit( (bool) aUnits, (double) aValue,
aInternal_Unit );
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) :
wxT( "%.3f" ),
value_to_print );
}
value_to_print = To_User_Unit( aUnit, aValue, aInternal_Unit );
/* Yet another 'if pcbnew' :( */
StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) :
wxT( "%.3f" ),
value_to_print );
if( aAdd_unit_symbol )
switch( aUnits )
switch( aUnit )
{
case INCHES:
StringValue += _( " \"" );
break;
case MILLIMETRE:
case MILLIMETRES:
StringValue += _( " mm" );
break;
default:
case UNSCALED_UNITS:
break;
}
......@@ -397,17 +383,51 @@ wxString ReturnStringFromValue( int aUnits, int aValue, int aInternal_Unit,
* Value = text
* Internal_Unit = units per inch for computed value
*/
int ReturnValueFromString( int Units, const wxString& TextValue,
int ReturnValueFromString( UserUnitType aUnit, const wxString& TextValue,
int Internal_Unit )
{
int Value;
double dtmp = 0;
TextValue.ToDouble( &dtmp );
if( Units >= CENTIMETRE )
Value = wxRound( dtmp );
else
Value = From_User_Unit( (bool) Units, dtmp, Internal_Unit );
/* 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 ) );
/* 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) ) )
{
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;
}
......@@ -449,34 +469,46 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter )
* Function To_User_Unit
* Convert in inch or mm the variable "val" (double)given in internal units
* @return the converted value, in double
* @param is_metric : true if the result must be returned in mm , false if inches
* @param aUnit : user measure unit
* @param val : double : the given value
* @param internal_unit_value = internal units per inch
*/
double To_User_Unit( bool is_metric, double val, int internal_unit_value )
double To_User_Unit( UserUnitType aUnit, double val, int internal_unit_value )
{
double value;
switch( aUnit )
{
case MILLIMETRES:
return val * 25.4 / internal_unit_value;
if( is_metric )
value = val * 25.4 / internal_unit_value;
else
value = val / internal_unit_value;
case INCHES:
return val / internal_unit_value;
return value;
default:
return val;
}
}
/*
* Return in internal units the value "val" given in inch or mm
*/
int From_User_Unit( bool is_metric, double val, int internal_unit_value )
int From_User_Unit( UserUnitType aUnit, double val, int internal_unit_value )
{
double value;
if( is_metric )
switch( aUnit )
{
case MILLIMETRES:
value = val * internal_unit_value / 25.4;
else
break;
case INCHES:
value = val * internal_unit_value;
break;
case UNSCALED_UNITS:
value = val;
}
return wxRound( value );
}
......@@ -654,13 +686,19 @@ int GetTimeStamp()
*/
const wxString& valeur_param( int valeur, wxString& buf_texte )
{
if( g_UnitMetric )
switch( g_UserUnit )
{
case MILLIMETRES:
buf_texte.Printf( wxT( "%3.3f mm" ), valeur * 0.00254 );
}
else
{
break;
case INCHES:
buf_texte.Printf( wxT( "%2.4f \"" ), valeur * 0.0001 );
break;
case UNSCALED_UNITS:
buf_texte.Printf( wxT( "%d" ), valeur );
break;
}
return buf_texte;
......
......@@ -81,24 +81,36 @@ void DIALOG_PAGES_SETTINGS::initDialog()
msg.Printf(format, m_Screen->m_ScreenNumber);
m_TextSheetNumber->SetLabel(msg);
if( g_UnitMetric )
switch( g_UserUnit )
{
UserSizeX = (double)g_Sheet_user.m_Size.x * 25.4 / 1000;
UserSizeY = (double)g_Sheet_user.m_Size.y * 25.4 / 1000;
msg.Printf( wxT("%.2f"), UserSizeX );
m_TextUserSizeX->SetValue(msg);
msg.Printf( wxT("%.2f"), UserSizeY );
m_TextUserSizeY->SetValue(msg);
}
else
{
UserSizeX = (double)g_Sheet_user.m_Size.x / 1000;
UserSizeY = (double)g_Sheet_user.m_Size.y / 1000;
msg.Printf( wxT("%.3f"), UserSizeX );
m_TextUserSizeX->SetValue(msg);
msg.Printf( wxT("%.3f"), UserSizeY );
m_TextUserSizeY->SetValue(msg);
case MILLIMETRES:
UserSizeX = (double) g_Sheet_user.m_Size.x * 25.4 / 1000;
UserSizeY = (double) g_Sheet_user.m_Size.y * 25.4 / 1000;
msg.Printf( wxT( "%.2f" ), UserSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.2f" ), UserSizeY );
m_TextUserSizeY->SetValue( msg );
break;
case INCHES:
UserSizeX = (double) g_Sheet_user.m_Size.x / 1000;
UserSizeY = (double) g_Sheet_user.m_Size.y / 1000;
msg.Printf( wxT( "%.3f" ), UserSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%.3f" ), UserSizeY );
m_TextUserSizeY->SetValue( msg );
break;
case UNSCALED_UNITS:
UserSizeX = g_Sheet_user.m_Size.x;
UserSizeY = g_Sheet_user.m_Size.y;
msg.Printf( wxT( "%f" ), UserSizeX );
m_TextUserSizeX->SetValue( msg );
msg.Printf( wxT( "%f" ), UserSizeY );
m_TextUserSizeY->SetValue( msg );
break;
}
// Set validators
m_PageSizeBox->SetValidator( wxGenericValidator(& m_CurrentSelection) );
m_TextRevision->SetValidator( wxTextValidator(wxFILTER_NONE, & m_Screen->m_Revision) );
......@@ -185,15 +197,22 @@ void DIALOG_PAGES_SETTINGS::SavePageSettings(wxCommandEvent& event)
m_SelectedSheet = SheetList[ii];
m_Screen->m_CurrentSheetDesc = m_SelectedSheet;
if( g_UnitMetric )
{
g_Sheet_user.m_Size.x = (int)( UserSizeX * 1000 / 25.4 );
g_Sheet_user.m_Size.y = (int)( UserSizeY * 1000 / 25.4 );
}
else
switch( g_UserUnit )
{
g_Sheet_user.m_Size.x = (int)( UserSizeX * 1000 );
g_Sheet_user.m_Size.y = (int)( UserSizeY * 1000 );
case MILLIMETRES:
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 / 25.4 );
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 / 25.4 );
break;
case INCHES:
g_Sheet_user.m_Size.x = (int) ( UserSizeX * 1000 );
g_Sheet_user.m_Size.y = (int) ( UserSizeY * 1000 );
break;
case UNSCALED_UNITS:
g_Sheet_user.m_Size.x = (int) ( UserSizeX );
g_Sheet_user.m_Size.y = (int) ( UserSizeY );
break;
}
if( g_Sheet_user.m_Size.x < 6000 )
......
......@@ -72,7 +72,6 @@ WinEDA_DrawFrame::WinEDA_DrawFrame( wxWindow* father, int idtype,
m_Draw_Sheet_Ref = FALSE; // TRUE to display reference sheet.
m_Print_Sheet_Ref = TRUE; // TRUE to print reference sheet.
m_Draw_Auxiliary_Axis = FALSE; // TRUE draw auxilary axis.
m_UnitType = INTERNAL_UNIT_TYPE; // Internal unit = inch
m_CursorShape = 0;
m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show
......@@ -334,18 +333,18 @@ void WinEDA_DrawFrame::DisplayUnitsMsg()
{
wxString msg;
switch( g_UnitMetric )
switch( g_UserUnit )
{
case INCHES:
msg = _( "Inch" );
msg = _( "Inches" );
break;
case MILLIMETRE:
case MILLIMETRES:
msg += _( "mm" );
break;
default:
msg += _( "??" );
msg += _( "Units" );
break;
}
......@@ -610,45 +609,68 @@ void WinEDA_DrawFrame::UpdateStatusBar()
SetStatusText( Line, 1 );
/* Display absolute coordinates: */
double dXpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.x,
double dXpos = To_User_Unit( g_UserUnit, screen->m_Curseur.x,
m_InternalUnits );
double dYpos = To_User_Unit( g_UnitMetric, screen->m_Curseur.y,
double dYpos = To_User_Unit( g_UserUnit, screen->m_Curseur.y,
m_InternalUnits );
/*
* Converting from inches to mm can give some coordinates due to
* float point precision rounding errors, like 1.999 or 2.001 so
* round to the nearest drawing precision required by the application.
*/
if ( g_UnitMetric )
if ( g_UserUnit == MILLIMETRES )
{
dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
dYpos = RoundTo0( dYpos, (double)( m_InternalUnits / 10 ) );
}
if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
Line.Printf( g_UnitMetric ? wxT( "X %.2f Y %.2f" ) :
wxT( "X %.3f Y %.3f" ), dXpos, dYpos );
else
Line.Printf( g_UnitMetric ? wxT( "X %.3f Y %.3f" ) :
wxT( "X %.4f Y %.4f" ), dXpos, dYpos );
/* The following sadly is an if eeschema/if pcbnew */
wxString formatter;
switch( g_UserUnit )
{
case INCHES:
if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
{
formatter = wxT( "X %.3f Y %.3f" );
}
else
{
formatter = wxT( "X %.4f Y %.4f" );
}
break;
case MILLIMETRES:
if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
{
formatter = wxT( "X %.2f Y %.2f" );
}
else
{
formatter = wxT( "X %.3f Y %.3f" );
}
break;
case UNSCALED_UNITS:
formatter = wxT( "X %f Y %f" );
break;
}
Line.Printf( formatter, dXpos, dYpos );
SetStatusText( Line, 2 );
/* Display relative coordinates: */
dx = screen->m_Curseur.x - screen->m_O_Curseur.x;
dy = screen->m_Curseur.y - screen->m_O_Curseur.y;
dXpos = To_User_Unit( g_UnitMetric, dx, m_InternalUnits );
dYpos = To_User_Unit( g_UnitMetric, dy, m_InternalUnits );
if ( g_UnitMetric )
dXpos = To_User_Unit( g_UserUnit, dx, m_InternalUnits );
dYpos = To_User_Unit( g_UserUnit, dy, m_InternalUnits );
if( g_UserUnit == MILLIMETRES )
{
dXpos = RoundTo0( dXpos, (double)( m_InternalUnits / 10 ) );
dYpos = RoundTo0( dYpos, (double)( m_InternalUnits / 10 ) );
dXpos = RoundTo0( dXpos, (double) ( m_InternalUnits / 10 ) );
dYpos = RoundTo0( dYpos, (double) ( m_InternalUnits / 10 ) );
}
if( m_InternalUnits == EESCHEMA_INTERNAL_UNIT )
Line.Printf( g_UnitMetric ? wxT( "X %.2f Y %.2f" ) :
wxT( "X %.3f Y %.3f" ), dXpos, dYpos );
else
Line.Printf( g_UnitMetric ? wxT( "x %.3f y %.3f" ) :
wxT( "x %.4f y %.4f" ), dXpos, dYpos );
/* We already decided the formatter above */
Line.Printf( formatter, dXpos, dYpos );
SetStatusText( Line, 3 );
}
......
......@@ -89,12 +89,12 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
const wxString& Title,
const wxString& TextToEdit,
int textsize,
int units,
UserUnitType user_unit,
wxBoxSizer* BoxSizer,
int framelen,
int internal_unit )
{
m_Units = units;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
m_Title = NULL;
......@@ -109,14 +109,14 @@ WinEDA_GraphicTextCtrl::WinEDA_GraphicTextCtrl( wxWindow* parent,
if( !Title.IsEmpty() )
{
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_Units );
wxString msg = _( "Size" ) + ReturnUnitSymbol( m_UserUnit );
wxStaticText* text = new wxStaticText( parent, -1, msg );
BoxSizer->Add( text, 0,
wxGROW | wxLEFT | wxRIGHT | wxADJUST_MINSIZE, 5 );
}
wxString value = FormatSize( m_Internal_Unit, m_Units, textsize );
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textsize );
m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition,
wxSize( 70, -1 ) );
......@@ -134,7 +134,7 @@ WinEDA_GraphicTextCtrl::~WinEDA_GraphicTextCtrl()
}
wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, int units,
wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, UserUnitType aUnit,
int textSize )
{
wxString value;
......@@ -147,7 +147,7 @@ wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, int units,
textSize = 3000;
value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ),
To_User_Unit( units, textSize, internalUnit ) );
To_User_Unit( aUnit, textSize, internalUnit ) );
return value;
}
......@@ -167,7 +167,7 @@ void WinEDA_GraphicTextCtrl::SetValue( const wxString& value )
void WinEDA_GraphicTextCtrl::SetValue( int textSize )
{
wxString value = FormatSize( m_Internal_Unit, m_Units, textSize );
wxString value = FormatSize( m_Internal_Unit, m_UserUnit, textSize );
m_FrameSize->SetValue( value );
}
......@@ -180,15 +180,11 @@ wxString WinEDA_GraphicTextCtrl::GetText()
int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText,
int internalUnit, int units )
int internalUnit, UserUnitType aUnit )
{
int textsize;
double dtmp;
sizeText.ToDouble( &dtmp );
textsize = (int) From_User_Unit( units, dtmp, internalUnit );
textsize = ReturnValueFromString( aUnit, sizeText, internalUnit );
// Limit to reasonable size
if( textsize < 10 )
......@@ -203,7 +199,7 @@ int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText,
int WinEDA_GraphicTextCtrl::GetTextSize()
{
return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_Units );
return ParseSize( m_FrameSize->GetValue(), m_Internal_Unit, m_UserUnit );
}
......@@ -219,19 +215,19 @@ void WinEDA_GraphicTextCtrl::Enable( bool state )
WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
int units,
UserUnitType user_unit,
wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString text;
m_Units = units;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
text += _( "X" ) + ReturnUnitSymbol( m_Units );
text += _( "X" ) + ReturnUnitSymbol( m_UserUnit );
m_TextX = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextX, 0,
......@@ -246,7 +242,7 @@ WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
text = _( "Pos " );
else
text = title;
text += _( "Y" ) + ReturnUnitSymbol( m_Units );
text += _( "Y" ) + ReturnUnitSymbol( m_UserUnit );
m_TextY = new wxStaticText( parent, -1, text );
BoxSizer->Add( m_TextY, 0,
......@@ -274,12 +270,9 @@ WinEDA_PositionCtrl::~WinEDA_PositionCtrl()
wxPoint WinEDA_PositionCtrl::GetValue()
{
wxPoint coord;
double value = 0;
m_FramePosX->GetValue().ToDouble( &value );
coord.x = From_User_Unit( m_Units, value, m_Internal_Unit );
m_FramePosY->GetValue().ToDouble( &value );
coord.y = From_User_Unit( m_Units, value, m_Internal_Unit );
coord.x = ReturnValueFromString( m_UserUnit, m_FramePosX->GetValue(), m_Internal_Unit );
coord.y = ReturnValueFromString( m_UserUnit, m_FramePosY->GetValue(), m_Internal_Unit );
return coord;
}
......@@ -299,11 +292,11 @@ void WinEDA_PositionCtrl::SetValue( int x_value, int y_value )
m_Pos_To_Edit.x = x_value;
m_Pos_To_Edit.y = y_value;
msg = ReturnStringFromValue( m_Units, m_Pos_To_Edit.x, m_Internal_Unit );
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.x, m_Internal_Unit );
m_FramePosX->Clear();
m_FramePosX->SetValue( msg );
msg = ReturnStringFromValue( m_Units, m_Pos_To_Edit.y, m_Internal_Unit );
msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.y, m_Internal_Unit );
m_FramePosY->Clear();
m_FramePosY->SetValue( msg );
}
......@@ -314,11 +307,11 @@ void WinEDA_PositionCtrl::SetValue( int x_value, int y_value )
/*******************/
WinEDA_SizeCtrl::WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
int units, wxBoxSizer* BoxSizer,
UserUnitType aUnit, wxBoxSizer* BoxSizer,
int internal_unit ) :
WinEDA_PositionCtrl( parent, title,
wxPoint( size_to_edit.x, size_to_edit.y ),
units, BoxSizer, internal_unit )
aUnit, BoxSizer, internal_unit )
{
}
......@@ -338,22 +331,22 @@ wxSize WinEDA_SizeCtrl::GetValue()
/* Class to display and edit a dimension INCHES, MM, or other */
/**************************************************************/
WinEDA_ValueCtrl::WinEDA_ValueCtrl( wxWindow* parent, const wxString& title,
int value, int units, wxBoxSizer* BoxSizer,
int value, UserUnitType user_unit, wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString label = title;
m_Units = units;
m_UserUnit = user_unit;
m_Internal_Unit = internal_unit;
m_Value = value;
label += ReturnUnitSymbol( m_Units );
label += ReturnUnitSymbol( m_UserUnit );
m_Text = new wxStaticText( parent, -1, label );
BoxSizer->Add( m_Text, 0,
wxGROW | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE, 5 );
wxString stringvalue = ReturnStringFromValue( m_Units, m_Value,
wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value,
m_Internal_Unit );
m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue );
......@@ -376,7 +369,7 @@ int WinEDA_ValueCtrl::GetValue()
int coord;
wxString txtvalue = m_ValueCtrl->GetValue();
coord = ReturnValueFromString( m_Units, txtvalue, m_Internal_Unit );
coord = ReturnValueFromString( m_UserUnit, txtvalue, m_Internal_Unit );
return coord;
}
......@@ -387,7 +380,7 @@ void WinEDA_ValueCtrl::SetValue( int new_value )
m_Value = new_value;
buffer = ReturnStringFromValue( m_Units, m_Value, m_Internal_Unit );
buffer = ReturnStringFromValue( m_UserUnit, m_Value, m_Internal_Unit );
m_ValueCtrl->SetValue( buffer );
}
......
......@@ -235,8 +235,8 @@ void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu )
for( unsigned i = 0; i < screen->m_GridList.GetCount(); i++ )
{
tmp = screen->m_GridList[i];
double gridValueInch = To_User_Unit( 0, tmp.m_Size.x, m_InternalUnits );
double gridValue_mm = To_User_Unit( 1, tmp.m_Size.x, m_InternalUnits );
double gridValueInch = To_User_Unit( INCHES, tmp.m_Size.x, m_InternalUnits );
double gridValue_mm = To_User_Unit( MILLIMETRES, tmp.m_Size.x, m_InternalUnits );
if( tmp.m_Id == ID_POPUP_GRID_USER )
{
......@@ -244,12 +244,22 @@ void WinEDA_DrawFrame::AddMenuZoomAndGrid( wxMenu* MasterMenu )
}
else
{
if( g_UnitMetric == 0 ) // inches
switch( g_UserUnit )
{
case INCHES:
msg.Printf( wxT( "%.1f mils, (%.3f mm)" ),
gridValueInch * 1000, gridValue_mm );
else
break;
case MILLIMETRES:
msg.Printf( wxT( "%.3f mm, (%.1f mils)" ),
gridValue_mm, gridValueInch * 1000 );
break;
case UNSCALED_UNITS:
msg = wxT( "???" );
break;
}
}
gridMenu->Append( tmp.m_Id, msg, wxEmptyString, true );
if( grid == tmp.m_Size )
......
......@@ -252,10 +252,9 @@ void DISPLAY_FOOTPRINTS_FRAME::SetToolbars()
{
m_OptionsToolBar->ToggleTool(
ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric ==
MILLIMETRE ? TRUE : false );
g_UserUnit == MILLIMETRES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : false );
g_UserUnit == INCHES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
......@@ -342,12 +341,12 @@ void DISPLAY_FOOTPRINTS_FRAME::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
g_UserUnit = MILLIMETRES;
UpdateStatusBar();
break;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
g_UnitMetric = INCHES;
g_UserUnit = INCHES;
UpdateStatusBar();
break;
......
......@@ -363,7 +363,7 @@ void LIB_TEXT::DisplayInfo( WinEDA_DrawFrame* frame )
LIB_DRAW_ITEM::DisplayInfo( frame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
frame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
......
......@@ -1647,7 +1647,7 @@ void LIB_PIN::DisplayInfo( WinEDA_DrawFrame* frame )
frame->AppendMsgPanel( _( "Visible" ), Text, DARKGREEN );
/* Display pin length */
Text = ReturnStringFromValue( g_UnitMetric, m_PinLen,
Text = ReturnStringFromValue( g_UserUnit, m_PinLen,
EESCHEMA_INTERNAL_UNIT, true );
frame->AppendMsgPanel( _( "Length" ), Text, MAGENTA );
......
......@@ -530,7 +530,7 @@ void LIB_ARC::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
......@@ -791,12 +791,12 @@ void LIB_CIRCLE::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
msg = ReturnStringFromValue( g_UnitMetric, m_Radius,
msg = ReturnStringFromValue( g_UserUnit, m_Radius,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Radius" ), msg, RED );
......@@ -1020,7 +1020,7 @@ void LIB_RECTANGLE::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width, EESCHEMA_INTERNAL_UNIT, true );
msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
}
......@@ -1271,7 +1271,7 @@ void LIB_SEGMENT::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
......@@ -1689,7 +1689,7 @@ void LIB_POLYLINE::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel(_( "Line width" ), msg, BLUE );
......@@ -2060,7 +2060,7 @@ void LIB_BEZIER::DisplayInfo( WinEDA_DrawFrame* aFrame )
LIB_DRAW_ITEM::DisplayInfo( aFrame );
msg = ReturnStringFromValue( g_UnitMetric, m_Width,
msg = ReturnStringFromValue( g_UserUnit, m_Width,
EESCHEMA_INTERNAL_UNIT, true );
aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE );
......
......@@ -100,9 +100,9 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event )
m_ModeColorOption->SetSelection(s_PlotBlackAndWhite);
AddUnitSymbol(* m_TextPenWidth, g_UnitMetric );
AddUnitSymbol(* m_TextPenWidth, g_UserUnit );
m_DialogPenWidth->SetValue(
ReturnStringFromValue(g_UnitMetric, g_DrawDefaultLineThickness,
ReturnStringFromValue(g_UserUnit, g_DrawDefaultLineThickness,
m_Parent->m_InternalUnits ) );
m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref );
if (GetSizer())
......@@ -128,7 +128,7 @@ void DIALOG_SVG_PRINT::SetPenWidth()
}
m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, g_DrawDefaultLineThickness,
ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness,
m_Parent->m_InternalUnits ) );
}
......
......@@ -91,17 +91,17 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( wxWindow
columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( 1, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit );
textSizeLabel->SetLabel( label );
label = _( "Pos " );
label += _( "X" );
label += ReturnUnitSymbol( g_UnitMetric );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UnitMetric );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
copySelectedFieldToPanel();
......@@ -599,7 +599,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
textSizeTextCtrl->SetValue(
WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT,
g_UnitMetric, field.m_Size.x ) );
g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero = -m_Cmp->m_Pos; // relative zero
......@@ -623,11 +623,11 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel()
// top of each other.
}
wxString coordText = ReturnStringFromValue( g_UnitMetric, coord.x,
wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x,
EESCHEMA_INTERNAL_UNIT );
posXTextCtrl->SetValue( coordText );
coordText = ReturnStringFromValue( g_UnitMetric, coord.y,
coordText = ReturnStringFromValue( g_UserUnit, coord.y,
EESCHEMA_INTERNAL_UNIT );
posYTextCtrl->SetValue( coordText );
}
......@@ -667,7 +667,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize(
textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UnitMetric );
textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.y = field.m_Size.x;
int style = m_StyleRadioBox->GetSelection();
......@@ -681,15 +681,10 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToSelectedField()
else
field.m_Bold = false;
double value;
posXTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.x = From_User_Unit( g_UnitMetric, value,
EESCHEMA_INTERNAL_UNIT );
posYTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.y = From_User_Unit( g_UnitMetric, value,
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
return true;
}
......
......@@ -140,11 +140,11 @@ void DialogLabelEditor::InitDialog()
m_TextStyle->SetSelection( style );
wxString units = ReturnUnitSymbol( g_UnitMetric, wxT( "(%s)" ) );
wxString units = ReturnUnitSymbol( g_UserUnit, wxT( "(%s)" ) );
msg = _( "H" ) + units + _( " x W" ) + units;
m_staticSizeUnits->SetLabel( msg );
msg = ReturnStringFromValue( g_UnitMetric, m_CurrentText->m_Size.x,
msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->m_Size.x,
m_Parent->m_InternalUnits );
m_TextSize->SetValue( msg );
......@@ -206,7 +206,7 @@ void DialogLabelEditor::TextPropertiesAccept( wxCommandEvent& aEvent )
m_CurrentText->SetSchematicTextOrientation( m_TextOrient->GetSelection() );
text = m_TextSize->GetValue();
value = ReturnValueFromString( g_UnitMetric, text, m_Parent->m_InternalUnits );
value = ReturnValueFromString( g_UserUnit, text, m_Parent->m_InternalUnits );
m_CurrentText->m_Size.x = m_CurrentText->m_Size.y = value;
if( m_TextShape )
m_CurrentText->m_Shape = m_TextShape->GetSelection();
......
......@@ -157,17 +157,17 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog( wxInitDialogEvent& event
columnLabel.SetText( _( "Value" ) );
fieldListCtrl->InsertColumn( COLUMN_TEXT, columnLabel );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UnitMetric );
wxString label = _( "Size" ) + ReturnUnitSymbol( g_UserUnit );
textSizeLabel->SetLabel( label );
label = _( "Pos " );
label += _( "X" );
label += ReturnUnitSymbol( g_UnitMetric );
label += ReturnUnitSymbol( g_UserUnit );
posXLabel->SetLabel( label );
label = _( "Pos " );
label += _( "Y" );
label += ReturnUnitSymbol( g_UnitMetric );
label += ReturnUnitSymbol( g_UserUnit );
posYLabel->SetLabel( label );
InitBuffers();
......@@ -638,7 +638,7 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
fieldValueTextCtrl->SetValue( field.m_Text );
textSizeTextCtrl->SetValue(
WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, g_UnitMetric, field.m_Size.x ) );
WinEDA_GraphicTextCtrl::FormatSize( EESCHEMA_INTERNAL_UNIT, g_UserUnit, field.m_Size.x ) );
wxPoint coord = field.m_Pos;
wxPoint zero;
......@@ -659,13 +659,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel()
// top of each other.
}
wxString coordText = ReturnStringFromValue( g_UnitMetric, coord.x, EESCHEMA_INTERNAL_UNIT );
wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x, EESCHEMA_INTERNAL_UNIT );
posXTextCtrl->SetValue( coordText );
// 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
NEGATE( coord.y );
coordText = ReturnStringFromValue( g_UnitMetric, coord.y, EESCHEMA_INTERNAL_UNIT );
coordText = ReturnStringFromValue( g_UserUnit, coord.y, EESCHEMA_INTERNAL_UNIT );
posYTextCtrl->SetValue( coordText );
}
......@@ -719,7 +719,7 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
setRowItem( fieldNdx, field ); // update fieldListCtrl
field.m_Size.x = WinEDA_GraphicTextCtrl::ParseSize(
textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UnitMetric );
textSizeTextCtrl->GetValue(), EESCHEMA_INTERNAL_UNIT, g_UserUnit );
field.m_Size.y = field.m_Size.x;
......@@ -734,14 +734,11 @@ bool DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copyPanelToSelectedField()
else
field.m_Bold = false;
double value;
posXTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.x = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
posYTextCtrl->GetValue().ToDouble( &value );
field.m_Pos.y = From_User_Unit( g_UnitMetric, value, EESCHEMA_INTERNAL_UNIT );
field.m_Pos.x = ReturnValueFromString( g_UserUnit, posXTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
field.m_Pos.y = ReturnValueFromString( g_UserUnit, posYTextCtrl->GetValue(),
EESCHEMA_INTERNAL_UNIT );
// 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
NEGATE( field.m_Pos.y );
......
......@@ -56,7 +56,7 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
if ( m_GraphicText )
{
msg = ReturnStringFromValue(g_UnitMetric, m_GraphicText->m_Size.x,
msg = ReturnStringFromValue(g_UserUnit, m_GraphicText->m_Size.x,
m_Parent->m_InternalUnits);
m_TextSize->SetValue( msg );
m_TextValue->SetValue( m_GraphicText->m_Text );
......@@ -109,7 +109,7 @@ void Dialog_BodyGraphicText_Properties::InitDialog( )
}
else
{
msg = ReturnStringFromValue( g_UnitMetric, m_Parent->m_textSize,
msg = ReturnStringFromValue( g_UserUnit, m_Parent->m_textSize,
m_Parent->m_InternalUnits );
m_TextSize->SetValue( msg );
......@@ -148,7 +148,7 @@ void Dialog_BodyGraphicText_Properties::OnOkClick( wxCommandEvent& event )
m_Parent->m_textOrientation =
m_Orient->GetValue() ? TEXT_ORIENT_VERT : TEXT_ORIENT_HORIZ;
wxString msg = m_TextSize->GetValue();
m_Parent->m_textSize = ReturnValueFromString( g_UnitMetric, msg,
m_Parent->m_textSize = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Parent->m_drawSpecificConvert = m_CommonConvert->GetValue() ? false : true;
m_Parent->m_drawSpecificUnit = m_CommonUnit->GetValue() ? false : true;
......
......@@ -189,9 +189,9 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
grid_list.Index( GetBaseScreen()->GetGrid() ) );
units.Add( GetUnitsLabel( INCHES ) );
units.Add( GetUnitsLabel( MILLIMETRE ) );
units.Add( GetUnitsLabel( MILLIMETRES ) );
dlg.SetUnits( units, g_UnitMetric );
dlg.SetUnits( units, g_UserUnit );
dlg.SetGridSizes( grid_list, GetBaseScreen()->GetGridId() );
dlg.SetLineWidth( g_DrawDefaultLineThickness );
dlg.SetTextSize( g_DefaultTextLabelSize );
......@@ -220,7 +220,7 @@ void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
if( dlg.ShowModal() == wxID_CANCEL )
return;
g_UnitMetric = dlg.GetUnitsSelection();
g_UserUnit = (UserUnitType)dlg.GetUnitsSelection();
GetBaseScreen()->SetGrid(
grid_list[ (size_t) dlg.GetGridSelection() ].m_Size );
......@@ -495,8 +495,8 @@ PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetConfigurationSettings( void )
if( !m_configSettings.empty() )
return m_configSettings;
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Unite" ),
&g_UnitMetric, 0, 0, 1 ) );
m_configSettings.push_back( new PARAM_CFG_INT( wxT( "Unite" ),
(int*)&g_UserUnit, 0 ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ),
&g_LayerDescr.LayerColor[LAYER_WIRE],
GREEN ) );
......
......@@ -67,8 +67,8 @@ void WinEDA_SchematicFrame::OnFindDrcMarker( wxFindDialogEvent& event )
wxString path = sheetFoundIn->Path();
wxString units = GetAbbreviatedUnitsLabel();
double x = To_User_Unit( g_UnitMetric, (double) lastMarker->m_Pos.x, m_InternalUnits );
double y = To_User_Unit( g_UnitMetric, (double) lastMarker->m_Pos.y, m_InternalUnits );
double x = To_User_Unit( g_UserUnit, (double) lastMarker->m_Pos.x, m_InternalUnits );
double y = To_User_Unit( g_UserUnit, (double) lastMarker->m_Pos.y, m_InternalUnits );
msg.Printf( _( "Design rule check marker found in sheet %s at %0.3f%s, %0.3f%s" ),
GetChars( path ), x, GetChars( units ), y, GetChars( units) );
SetStatusText( msg );
......
......@@ -81,7 +81,7 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
DIALOG_LIB_EDIT_PIN dlg( this );
wxString units = GetUnitsLabel( g_UnitMetric );
wxString units = GetUnitsLabel( g_UserUnit );
dlg.SetOrientationList( LIB_PIN::GetOrientationNames(),
LIB_PIN::GetOrientationSymbols() );
dlg.SetOrientation( LIB_PIN::GetOrientationCodeIndex( pin->m_Orient ) );
......@@ -92,16 +92,16 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
LIB_PIN::GetElectricalTypeSymbols());
dlg.SetElectricalType( pin->m_PinType );
dlg.SetName( pin->m_PinName );
dlg.SetNameTextSize( ReturnStringFromValue( g_UnitMetric,
dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit,
pin->m_PinNameSize,
m_InternalUnits ) );
dlg.SetNameTextSizeUnits( units );
dlg.SetNumber( pin->GetNumber() );
dlg.SetNumberTextSize( ReturnStringFromValue( g_UnitMetric,
dlg.SetNumberTextSize( ReturnStringFromValue( g_UserUnit,
pin->m_PinNumSize,
m_InternalUnits ) );
dlg.SetNumberTextSizeUnits( units );
dlg.SetLength( ReturnStringFromValue( g_UnitMetric, pin->m_PinLen,
dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->m_PinLen,
m_InternalUnits ) );
dlg.SetLengthUnits( units );
dlg.SetAddToAllParts( pin->m_Unit == 0 );
......@@ -129,14 +129,14 @@ void WinEDA_LibeditFrame::OnEditPin( wxCommandEvent& event )
}
/* Save the pin properties to use for the next new pin. */
LastPinNameSize = ReturnValueFromString( g_UnitMetric,
LastPinNameSize = ReturnValueFromString( g_UserUnit,
dlg.GetNameTextSize(),
m_InternalUnits );
LastPinNumSize = ReturnValueFromString( g_UnitMetric,
LastPinNumSize = ReturnValueFromString( g_UserUnit,
dlg.GetNumberTextSize(),
m_InternalUnits );
LastPinOrient = LIB_PIN::GetOrientationCode( dlg.GetOrientation() );
LastPinLength = ReturnValueFromString( g_UnitMetric, dlg.GetLength(),
LastPinLength = ReturnValueFromString( g_UserUnit, dlg.GetLength(),
m_InternalUnits );
LastPinShape = LIB_PIN::GetStyleCode( dlg.GetStyle() );
LastPinType = dlg.GetElectricalType();
......
......@@ -492,11 +492,11 @@ void WinEDA_PlotHPGLFrame::SetPageOffsetValue()
if( HPGL_SizeSelect != PAGE_DEFAULT )
{
msg = ReturnStringFromValue( g_UnitMetric,
msg = ReturnStringFromValue( g_UserUnit,
Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x,
EESCHEMA_INTERNAL_UNIT );
m_PlotOrgPosition_X->SetValue( msg );
msg = ReturnStringFromValue( g_UnitMetric,
msg = ReturnStringFromValue( g_UserUnit,
Plot_sheet_list[HPGL_SizeSelect]-> m_Offset.y,
EESCHEMA_INTERNAL_UNIT );
m_PlotOrgPosition_Y->SetValue( msg );
......@@ -525,10 +525,10 @@ void WinEDA_PlotHPGLFrame::AcceptPlotOffset( wxCommandEvent& event )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x =
ReturnValueFromString( g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT );
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
msg = m_PlotOrgPosition_Y->GetValue();
Plot_sheet_list[HPGL_SizeSelect]->m_Offset.y =
ReturnValueFromString( g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT );
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
}
}
......@@ -574,10 +574,10 @@ void WinEDA_PlotHPGLFrame::HPGL_Plot( wxCommandEvent& event )
{
wxString msg = m_PlotOrgPosition_X->GetValue();
Plot_sheet_list[HPGL_SizeSelect]->m_Offset.x =
ReturnValueFromString( g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT );
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
msg = m_PlotOrgPosition_Y->GetValue();
Plot_sheet_list[HPGL_SizeSelect]->m_Offset.y =
ReturnValueFromString( g_UnitMetric, msg, EESCHEMA_INTERNAL_UNIT );
ReturnValueFromString( g_UserUnit, msg, EESCHEMA_INTERNAL_UNIT );
}
Plot_Schematic_HPGL( Select_PlotAll, HPGL_SizeSelect );
......
......@@ -255,7 +255,7 @@ void WinEDA_PlotPSFrame::CreateControls()
m_DefaultLineSizeCtrl = new WinEDA_ValueCtrl( this,
_( "Default Line Width" ),
g_DrawDefaultLineThickness,
g_UnitMetric,
g_UserUnit,
m_DefaultLineSizeCtrlSizer,
EESCHEMA_INTERNAL_UNIT );
}
......
......@@ -563,10 +563,10 @@ void WinEDA_SchematicFrame::OnUpdateSelectCursor( wxUpdateUIEvent& event )
void WinEDA_SchematicFrame::OnUpdateUnits( wxUpdateUIEvent& event )
{
bool is_metric = g_UnitMetric == MILLIMETRE ? true : false;
bool is_metric = ( g_UserUnit == MILLIMETRES ) ? true : false;
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, is_metric );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, !is_metric );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM, g_UserUnit == MILLIMETRES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH, g_UserUnit == INCHES );
DisplayUnitsMsg();
}
......
......@@ -43,14 +43,14 @@ bool WinEDA_SchematicFrame::EditSheet( SCH_SHEET* aSheet, wxDC* aDC )
DIALOG_SCH_SHEET_PROPS dlg( this );
wxString units = GetUnitsLabel( g_UnitMetric );
wxString units = GetUnitsLabel( g_UserUnit );
dlg.SetFileName( aSheet->GetFileName() );
dlg.SetFileNameTextSize( ReturnStringFromValue( g_UnitMetric,
dlg.SetFileNameTextSize( ReturnStringFromValue( g_UserUnit,
aSheet->m_FileNameSize,
m_InternalUnits ) );
dlg.SetFileNameTextSizeUnits( units );
dlg.SetSheetName( aSheet->m_SheetName );
dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UnitMetric,
dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UserUnit,
aSheet->m_SheetNameSize,
m_InternalUnits ) );
dlg.SetSheetNameTextSizeUnits( units );
......@@ -109,12 +109,12 @@ structures and cannot be undone.\nOk to continue renaming?" );
else
SaveCopyInUndoList( aSheet, UR_CHANGED );
aSheet->m_FileNameSize = ReturnValueFromString( g_UnitMetric,
aSheet->m_FileNameSize = ReturnValueFromString( g_UserUnit,
dlg.GetFileNameTextSize(),
m_InternalUnits );
aSheet->m_SheetName = dlg.GetSheetName();
aSheet->m_SheetNameSize = ReturnValueFromString( g_UnitMetric,
aSheet->m_SheetNameSize = ReturnValueFromString( g_UserUnit,
dlg.GetSheetNameTextSize(),
m_InternalUnits );
......
......@@ -87,7 +87,7 @@ WinEDA_PinSheetPropertiesFrame::WinEDA_PinSheetPropertiesFrame(
m_TextWin = new WinEDA_GraphicTextCtrl( this, _( "Text:" ),
m_CurrentPinSheet->m_Text,
m_CurrentPinSheet->m_Size.x,
g_UnitMetric, LeftBoxSizer, 200 );
g_UserUnit, LeftBoxSizer, 200 );
// Display shape selection :
#define NBSHAPES 5
......
......@@ -68,9 +68,9 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
DIALOG_LIB_EDIT_DRAW_ITEM dialog( this, DrawItem->m_typeName );
dialog.SetWidthUnits( ReturnUnitSymbol( g_UnitMetric ) );
dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) );
wxString val = ReturnStringFromValue( g_UnitMetric, m_drawLineWidth,
wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth,
m_InternalUnits );
dialog.SetWidth( val );
dialog.SetApplyToAllUnits( !m_drawSpecificUnit );
......@@ -85,7 +85,7 @@ void WinEDA_LibeditFrame::EditGraphicSymbol( wxDC* DC, LIB_DRAW_ITEM* DrawItem )
return;
val = dialog.GetWidth();
m_drawLineWidth = ReturnValueFromString( g_UnitMetric, val,
m_drawLineWidth = ReturnValueFromString( g_UserUnit, val,
m_InternalUnits );
m_drawSpecificConvert = !dialog.GetApplyToAllConversions();
m_drawSpecificUnit = !dialog.GetApplyToAllUnits();
......
......@@ -294,13 +294,13 @@ void WinEDA_SchematicFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
g_UserUnit = MILLIMETRES;
UpdateStatusBar();
DrawPanel->Refresh();
break;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
g_UnitMetric = INCHES;
g_UserUnit = INCHES;
UpdateStatusBar();
DrawPanel->Refresh();
break;
......
......@@ -286,10 +286,10 @@ void WinEDA_GerberFrame::SetToolbars()
{
m_OptionsToolBar->ToggleTool(
ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric ==
MILLIMETRE ? TRUE : FALSE );
g_UserUnit ==
MILLIMETRES ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : FALSE );
g_UserUnit == INCHES ? TRUE : FALSE );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
......
......@@ -36,8 +36,8 @@ static PARAM_CFG_WXSTRING DrillExtBufCfg
static PARAM_CFG_INT UnitCfg // Units; 0 inches, 1 mm
(
wxT("Unite"),
&g_UnitMetric,
FALSE
(int*)&g_UserUnit,
MILLIMETRES
);
static PARAM_CFG_INT GerberScaleCfg // default scale; 0 2.3, 1 3.4
......
......@@ -131,7 +131,7 @@ void WinEDA_GerberFrame::OnHotKey( wxDC* DC, int hotkey,
break;
case HK_SWITCH_UNITS:
g_UnitMetric = (g_UnitMetric == INCHES ) ? MILLIMETRE : INCHES;
g_UserUnit = (g_UserUnit == INCHES ) ? MILLIMETRES : INCHES;
break;
case HK_SWITCH_TRACK_DISPLAY_MODE:
......
......@@ -46,12 +46,12 @@ void WinEDA_GerberFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
g_UserUnit = MILLIMETRES;
UpdateStatusBar();
break;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
g_UnitMetric = INCHES;
g_UserUnit = INCHES;
UpdateStatusBar();
break;
......@@ -206,7 +206,7 @@ WinEDA_GerberGeneralOptionsFrame::WinEDA_GerberGeneralOptionsFrame(
m_BoxUnits = new wxRadioBox( this, -1, _( "Units" ), wxDefaultPosition,
wxDefaultSize,
2, list_units, 1 );
m_BoxUnits->SetSelection( g_UnitMetric ? 1 : 0 );
m_BoxUnits->SetSelection( g_UserUnit ? 1 : 0 );
LeftBoxSizer->Add( m_BoxUnits, 0, wxGROW | wxALL, 5 );
/* Selection of cursor shape */
......@@ -242,7 +242,7 @@ void WinEDA_GerberGeneralOptionsFrame::OnOkClick( wxCommandEvent& event )
{
DisplayOpt.DisplayPolarCood =
(m_PolarDisplay->GetSelection() == 0) ? FALSE : TRUE;
g_UnitMetric = (m_BoxUnits->GetSelection() == 0) ? 0 : 1;
g_UserUnit = (m_BoxUnits->GetSelection() == 0) ? INCHES : MILLIMETRES;
m_Parent->m_CursorShape = m_CursorShape->GetSelection();
g_Default_GERBER_Format =
(m_GerberDefaultScale->GetSelection() == 0) ? 23 : 34;
......
......@@ -15,7 +15,6 @@ extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt );
#endif
/* Id for class identification, at run time */
enum KICAD_T {
NOT_USED = -1, // the 3d code uses this value
......
......@@ -12,6 +12,7 @@
#include "base_struct.h"
#include "class_undoredo_container.h"
#include "block_commande.h"
#include "common.h"
// Forward declarations:
......@@ -325,7 +326,7 @@ public:
void SetGridList( GridArray& sizelist );
void AddGrid( const GRID_TYPE& grid );
void AddGrid( const wxRealPoint& size, int id );
void AddGrid( const wxRealPoint& size, int units, int id );
void AddGrid( const wxRealPoint& size, UserUnitType aUnit, int id );
/**
......
......@@ -15,7 +15,6 @@ class WinEDA_DrawFrame;
class WinEDAListBox;
class WinEDA_DrawPanel;
/* Flag for special keys */
#define GR_KB_RIGHTSHIFT 0x10000000 /* Keybd states: right
* shift key depressed */
......@@ -78,9 +77,11 @@ enum pseudokeys {
#define ON 1
#define OFF 0
#define INCHES 0
#define MILLIMETRE 1
#define CENTIMETRE 2
enum UserUnitType {
INCHES = 0,
MILLIMETRES = 1,
UNSCALED_UNITS = 2
};
#if defined(KICAD_GOST)
#define LEFTMARGIN 800 /* 20mm */
......@@ -184,7 +185,7 @@ extern wxString g_Prj_Default_Config_FullFilename;
// Name of local configuration file. (<curr projet>.pro)
extern wxString g_Prj_Config_LocalFilename;
extern int g_UnitMetric; // display units mm = 1, inches = 0, cm = 2
extern UserUnitType g_UserUnit; ///< display units
/* Draw color for moving objects: */
extern int g_GhostColor;
......@@ -324,10 +325,10 @@ wxString ReturnUnitSymbol( int aUnits = g_UnitMetric,
* @param aUnits - The units text to return.
* @return The human readable units string.
*/
wxString GetUnitsLabel( int aUnits );
wxString GetAbbreviatedUnitsLabel( int aUnits = g_UnitMetric );
wxString GetUnitsLabel( UserUnitType aUnit );
wxString GetAbbreviatedUnitsLabel( UserUnitType aUnit = g_UserUnit );
int ReturnValueFromString( int Units, const wxString& TextValue,
int ReturnValueFromString( UserUnitType aUnit, const wxString& TextValue,
int Internal_Unit );
/** Function ReturnStringFromValue
......@@ -340,12 +341,12 @@ int ReturnValueFromString( int Units, const wxString& TextValue,
* @return a wxString what contains value and optionally the symbol unit (like
* 2.000 mm)
*/
wxString ReturnStringFromValue( int aUnits,
wxString ReturnStringFromValue( UserUnitType aUnit,
int aValue,
int aInternal_Unit,
bool aAdd_unit_symbol = false );
void AddUnitSymbol( wxStaticText& Stext, int Units = g_UnitMetric );
void AddUnitSymbol( wxStaticText& Stext, UserUnitType aUnit = g_UserUnit );
/* Add string " (mm):" or " ("):" to the static text Stext.
* Used in dialog boxes for entering values depending on selected units */
......@@ -353,7 +354,7 @@ void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value,
int Internal_Unit );
/* Convert the number Value in a string according to the internal units
* and the selected unit (g_UnitMetric) and put it in the wxTextCtrl TextCtrl
* and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl
**/
int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr,
int Internal_Unit );
......@@ -365,16 +366,15 @@ wxArrayString* wxStringSplit( wxString txt, wxChar splitter );
* Function To_User_Unit
* Convert in inch or mm the variable "val" (double)given in internal units
* @return the converted value, in double
* @param is_metric : true if the result must be returned in mm , false if
* inches
* @param aUnit : user unit to be converted to
* @param val : double : the given value
* @param internal_unit_value = internal units per inch
*/
double To_User_Unit( bool is_metric,
double To_User_Unit( UserUnitType aUnit,
double val,
int internal_unit_value );
int From_User_Unit( bool is_metric,
int From_User_Unit( UserUnitType aUnit,
double val,
int internal_unit_value );
wxString GenDate();
......
......@@ -58,7 +58,7 @@ public:
int m_DisplayModText; // How to display module texts (line/ filled / sketch)
bool m_DisplayPcbTrackFill; /* FALSE : tracks are show in sketch mode,
* TRUE = filled */
int m_UserGridUnits;
UserUnitType m_UserGridUnit;
wxRealPoint m_UserGridSize;
WinEDA3D_DrawFrame* m_Draw3DFrame;
......
......@@ -16,14 +16,13 @@
#include <wx/aui/aui.h>
#include "colors.h"
#include "common.h"
//C++ guarantees that operator delete checks its argument for null-ness
#ifndef SAFE_DELETE
#define SAFE_DELETE( p ) delete (p); (p) = NULL;
#endif
#define INTERNAL_UNIT_TYPE 0 // Internal unit = inch
#ifndef EESCHEMA_INTERNAL_UNIT
#define EESCHEMA_INTERNAL_UNIT 1000
#endif
......@@ -169,7 +168,6 @@ public:
// = 1000 for eeschema, = 10000
// for PCBnew and Gerbview
int m_UnitType; // Internal Unit type (0 = inch)
bool m_Draw_Axis; // TRUE to show X and Y axis
bool m_Draw_Sheet_Ref; // TRUE to show frame references
......@@ -566,7 +564,8 @@ public:
class WinEDA_GraphicTextCtrl
{
public:
int m_Units, m_Internal_Unit;
UserUnitType m_UserUnit;
int m_Internal_Unit;
wxTextCtrl* m_FrameText;
wxTextCtrl* m_FrameSize;
......@@ -576,7 +575,7 @@ private:
public:
WinEDA_GraphicTextCtrl( wxWindow* parent, const wxString& Title,
const wxString& TextToEdit, int textsize,
int units, wxBoxSizer* BoxSizer, int framelen = 200,
UserUnitType user_unit, wxBoxSizer* BoxSizer, int framelen = 200,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_GraphicTextCtrl();
......@@ -594,10 +593,10 @@ public:
* Function FormatSize
* formats a string containing the size in the desired units.
*/
static wxString FormatSize( int internalUnit, int units, int textSize );
static wxString FormatSize( int internalUnit, UserUnitType user_unit, int textSize );
static int ParseSize( const wxString& sizeText, int internalUnit,
int units );
UserUnitType user_unit );
};
......@@ -608,7 +607,8 @@ public:
class WinEDA_PositionCtrl
{
public:
int m_Units, m_Internal_Unit;
UserUnitType m_UserUnit;
int m_Internal_Unit;
wxPoint m_Pos_To_Edit;
wxTextCtrl* m_FramePosX;
......@@ -619,7 +619,7 @@ private:
public:
WinEDA_PositionCtrl( wxWindow* parent, const wxString& title,
const wxPoint& pos_to_edit,
int units, wxBoxSizer* BoxSizer,
UserUnitType user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_PositionCtrl();
......@@ -639,7 +639,7 @@ class WinEDA_SizeCtrl : public WinEDA_PositionCtrl
public:
WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
int units, wxBoxSizer* BoxSizer,
UserUnitType user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_SizeCtrl() { }
......@@ -653,7 +653,7 @@ public:
class WinEDA_ValueCtrl
{
public:
int m_Units;
UserUnitType m_UserUnit;
int m_Value;
wxTextCtrl* m_ValueCtrl;
private:
......@@ -662,7 +662,7 @@ private:
public:
WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, int value,
int units, wxBoxSizer* BoxSizer,
UserUnitType user_unit, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_ValueCtrl();
......
......@@ -66,7 +66,7 @@ WinEDA_BasePcbFrame::WinEDA_BasePcbFrame( wxWindow* father,
m_ModuleEditFrame = NULL; // Frame for footprint edition
m_UserGridSize = wxRealPoint( 100.0, 100.0 );
m_UserGridUnits = INCHES;
m_UserGridUnit = INCHES;
m_Collector = new GENERAL_COLLECTOR();
}
......@@ -340,9 +340,23 @@ void WinEDA_BasePcbFrame::UpdateStatusBar()
theta = theta * 180.0 / M_PI;
ro = sqrt( ( (double) dx * dx ) + ( (double) dy * dy ) );
Line.Printf( g_UnitMetric ? wxT( "Ro %.3f Th %.1f" ) :
wxT( "Ro %.4f Th %.1f" ),
To_User_Unit( g_UnitMetric, ro, m_InternalUnits ),
wxString formatter;
switch( g_UserUnit )
{
case INCHES:
formatter = wxT( "Ro %.4f Th %.1f" );
break;
case MILLIMETRES:
formatter = wxT( "Ro %.3f Th %.1f" );
break;
case UNSCALED_UNITS:
formatter = wxT( "Ro %f Th %f" );
break;
}
Line.Printf( formatter, To_User_Unit( g_UserUnit, ro, m_InternalUnits ),
theta );
// overwrite the absolute cartesian coordinates
......@@ -378,7 +392,7 @@ void WinEDA_BasePcbFrame::LoadSettings()
cfg->Read( m_FrameName + UserGridSizeXEntry, &m_UserGridSize.x, 0.01 );
cfg->Read( m_FrameName + UserGridSizeYEntry, &m_UserGridSize.y, 0.01 );
cfg->Read( m_FrameName + UserGridUnitsEntry, &m_UserGridUnits,
cfg->Read( m_FrameName + UserGridUnitsEntry, (long*)&m_UserGridUnit,
( long )INCHES );
cfg->Read( m_FrameName + DisplayPadFillEntry, &m_DisplayPadFill, true );
cfg->Read( m_FrameName + DisplayViaFillEntry, &m_DisplayViaFill, true );
......@@ -409,7 +423,7 @@ void WinEDA_BasePcbFrame::SaveSettings()
WinEDA_DrawFrame::SaveSettings();
cfg->Write( m_FrameName + UserGridSizeXEntry, m_UserGridSize.x );
cfg->Write( m_FrameName + UserGridSizeYEntry, m_UserGridSize.y );
cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnits );
cfg->Write( m_FrameName + UserGridUnitsEntry, ( long )m_UserGridUnit );
cfg->Write( m_FrameName + DisplayPadFillEntry, m_DisplayPadFill );
cfg->Write( m_FrameName + DisplayViaFillEntry, m_DisplayViaFill );
cfg->Write( m_FrameName + DisplayPadNumberEntry, m_DisplayPadNum );
......
......@@ -95,9 +95,9 @@ void DIALOG_SVG_PRINT::initDialog( )
}
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenDefaultSize,
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize,
m_Parent->m_InternalUnits ) );
m_Print_Frame_Ref_Ctrl->SetValue( s_Parameters.m_Print_Sheet_Ref );
......@@ -177,7 +177,7 @@ void DIALOG_SVG_PRINT::SetPenWidth()
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize;
m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenDefaultSize,
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize,
m_Parent->m_InternalUnits ) );
}
......
......@@ -62,14 +62,14 @@ void dialog_copper_zone::initDialog( )
m_FillModeCtrl->SetSelection( m_Zone_Setting->m_FillMode ? 1 : 0 );
AddUnitSymbol( *m_ClearanceValueTitle, g_UnitMetric );
msg = ReturnStringFromValue( g_UnitMetric,
AddUnitSymbol( *m_ClearanceValueTitle, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneClearance,
m_Parent->m_InternalUnits );
m_ZoneClearanceCtrl->SetValue( msg );
AddUnitSymbol( *m_MinThicknessValueTitle, g_UnitMetric );
msg = ReturnStringFromValue( g_UnitMetric,
AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneMinThickness,
m_Parent->m_InternalUnits );
m_ZoneMinThicknessCtrl->SetValue( msg );
......@@ -101,8 +101,8 @@ void dialog_copper_zone::initDialog( )
m_CopperWidthValue->Enable( true );
}
AddUnitSymbol( *m_AntipadSizeText, g_UnitMetric );
AddUnitSymbol( *m_CopperBridgeWidthText, g_UnitMetric );
AddUnitSymbol( *m_AntipadSizeText, g_UserUnit );
AddUnitSymbol( *m_CopperBridgeWidthText, g_UserUnit );
PutValueInLocalUnits( *m_AntipadSizeValue,
m_Zone_Setting->m_ThermalReliefGapValue,
PCB_INTERNAL_UNIT );
......@@ -266,7 +266,7 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
wxString txtvalue = m_ZoneClearanceCtrl->GetValue();
m_Zone_Setting->m_ZoneClearance =
ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits );
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->m_InternalUnits );
// Test if this is a reasonnable value for this parameter
// A too large value can hang pcbnew
......@@ -279,7 +279,7 @@ bool dialog_copper_zone::AcceptOptions( bool aPromptForErrors, bool aUseExportab
txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_Zone_Setting->m_ZoneMinThickness =
ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits );
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->m_InternalUnits );
if( m_Zone_Setting->m_ZoneMinThickness < 10 )
{
DisplayError( this,
......
......@@ -156,15 +156,15 @@ void DIALOG_DESIGN_RULES::PrintCurrentSettings( )
m_MessagesList->AppendToPage(_("<b>Current general settings:</b><br>") );
// Display min values:
value = ReturnStringFromValue( g_UnitMetric, m_BrdSettings->m_TrackMinWidth, internal_units, true );
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_TrackMinWidth, internal_units, true );
msg.Printf(_("Minimum value for tracks width: <b>%s</b><br>\n"), GetChars( value ) );
m_MessagesList->AppendToPage(msg);
value = ReturnStringFromValue( g_UnitMetric, m_BrdSettings->m_ViasMinSize, internal_units, true );
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_ViasMinSize, internal_units, true );
msg.Printf(_("Minimum value for vias diameter: <b>%s</b><br>\n"), GetChars( value ) );
m_MessagesList->AppendToPage(msg);
value = ReturnStringFromValue( g_UnitMetric, m_BrdSettings->m_MicroViasMinSize, internal_units, true );
value = ReturnStringFromValue( g_UserUnit, m_BrdSettings->m_MicroViasMinSize, internal_units, true );
msg.Printf(_("Minimum value for microvias diameter: <b>%s</b><br>\n"), GetChars( value ) );
m_MessagesList->AppendToPage(msg);
......@@ -264,18 +264,18 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists()
for( unsigned ii = 0; ii < m_TracksWidthList.size(); ii++ )
{
msg = ReturnStringFromValue( g_UnitMetric, m_TracksWidthList[ii], Internal_Unit, false );
msg = ReturnStringFromValue( g_UserUnit, m_TracksWidthList[ii], Internal_Unit, false );
m_gridTrackWidthList->SetCellValue( ii, 0, msg );
}
for( unsigned ii = 0; ii < m_ViasDimensionsList.size(); ii++ )
{
msg = ReturnStringFromValue( g_UnitMetric, m_ViasDimensionsList[ii].m_Diameter,
msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Diameter,
Internal_Unit, false );
m_gridViaSizeList->SetCellValue( ii, 0, msg );
if( m_ViasDimensionsList[ii].m_Drill > 0 )
{
msg = ReturnStringFromValue( g_UnitMetric, m_ViasDimensionsList[ii].m_Drill,
msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Drill,
Internal_Unit, false );
m_gridViaSizeList->SetCellValue( ii, 1, msg );
}
......@@ -425,22 +425,22 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units )
// label is netclass name
grid->SetRowLabelValue( row, nc->GetName() );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetClearance(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetClearance(), units );
grid->SetCellValue( row, GRID_CLEARANCE, msg );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetTrackWidth(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetTrackWidth(), units );
grid->SetCellValue( row, GRID_TRACKSIZE, msg );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetViaDiameter(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDiameter(), units );
grid->SetCellValue( row, GRID_VIASIZE, msg );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetViaDrill(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDrill(), units );
grid->SetCellValue( row, GRID_VIADRILL, msg );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetuViaDiameter(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDiameter(), units );
grid->SetCellValue( row, GRID_uVIASIZE, msg );
msg = ReturnStringFromValue( g_UnitMetric, nc->GetuViaDrill(), units );
msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDrill(), units );
grid->SetCellValue( row, GRID_uVIADRILL, msg );
}
......@@ -474,7 +474,7 @@ void DIALOG_DESIGN_RULES::InitRulesList()
static void gridRow2class( wxGrid* grid, int row, NETCLASS* nc, int units )
{
#define MYCELL(col) \
ReturnValueFromString( g_UnitMetric, grid->GetCellValue( row, col ), units )
ReturnValueFromString( g_UserUnit, grid->GetCellValue( row, col ), units )
nc->SetClearance( MYCELL( GRID_CLEARANCE ) );
nc->SetTrackWidth( MYCELL( GRID_TRACKSIZE ) );
......@@ -568,7 +568,7 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard( )
msg = m_gridTrackWidthList->GetCellValue( row, 0 );
if( msg.IsEmpty() )
continue;
int value = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
m_TracksWidthList.push_back( value);
}
// Sort new list by by increasing value
......@@ -581,13 +581,13 @@ void DIALOG_DESIGN_RULES::CopyDimensionsListsToBoard( )
msg = m_gridViaSizeList->GetCellValue( row, 0 );
if( msg.IsEmpty() )
continue;
int value = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
int value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
VIA_DIMENSION via_dim;
via_dim.m_Diameter = value;
msg = m_gridViaSizeList->GetCellValue( row, 1 );
if( ! msg.IsEmpty() )
{
value = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
value = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
via_dim.m_Drill = value;
}
m_ViasDimensionsList.push_back( via_dim);
......@@ -913,7 +913,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
for( int row = 0; row < m_grid->GetNumberRows(); row++ )
{
int tracksize = ReturnValueFromString( g_UnitMetric,
int tracksize = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_TRACKSIZE ),
m_Parent->m_InternalUnits );
if( tracksize < minTrackWidth )
......@@ -926,7 +926,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
}
// Test vias
int viadia = ReturnValueFromString( g_UnitMetric,
int viadia = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_VIASIZE ),
m_Parent->m_InternalUnits );
......@@ -939,7 +939,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
m_MessagesList->AppendToPage( msg );
}
int viadrill = ReturnValueFromString( g_UnitMetric,
int viadrill = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_VIADRILL ),
m_Parent->m_InternalUnits );
if( viadrill >= viadia )
......@@ -961,7 +961,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
}
// Test Micro vias
int muviadia = ReturnValueFromString( g_UnitMetric,
int muviadia = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_uVIASIZE ),
m_Parent->m_InternalUnits );
......@@ -974,7 +974,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
m_MessagesList->AppendToPage( msg );
}
int muviadrill = ReturnValueFromString( g_UnitMetric,
int muviadrill = ReturnValueFromString( g_UserUnit,
m_grid->GetCellValue( row, GRID_uVIADRILL ),
m_Parent->m_InternalUnits );
if( muviadrill >= muviadia )
......@@ -1003,7 +1003,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
if( tvalue.IsEmpty() )
continue;
int tracksize = ReturnValueFromString( g_UnitMetric,
int tracksize = ReturnValueFromString( g_UserUnit,
tvalue,
m_Parent->m_InternalUnits );
if( tracksize < minTrackWidth )
......@@ -1030,7 +1030,7 @@ bool DIALOG_DESIGN_RULES::TestDataValidity()
if( tvalue.IsEmpty() )
continue;
int viadia = ReturnValueFromString( g_UnitMetric,
int viadia = ReturnValueFromString( g_UserUnit,
tvalue,
m_Parent->m_InternalUnits );
if( viadia < minViaDia )
......
......@@ -57,11 +57,11 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
{
PutValueInLocalUnits( *m_ModPositionX,
m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT );
AddUnitSymbol( *XPositionStatic, g_UnitMetric );
AddUnitSymbol( *XPositionStatic, g_UserUnit );
PutValueInLocalUnits( *m_ModPositionY,
m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT );
AddUnitSymbol( *YPositionStatic, g_UnitMetric );
AddUnitSymbol( *YPositionStatic, g_UserUnit );
m_LayerCtrl->SetSelection(
(m_CurrentModule->GetLayer() == LAYER_N_BACK) ? 1 : 0 );
......@@ -100,9 +100,9 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties()
m_OrientValue->Enable( select );
// Initialize dialog relative to masks clearances
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
int internalUnit = m_Parent->m_InternalUnits;
PutValueInLocalUnits( *m_NetClearanceValueCtrl,
......@@ -263,17 +263,17 @@ void DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties()
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ),
BoxSizer, 2, 1 );
BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ),
BoxSizer, 2, 1 );
BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ),
BoxSizer, 2, 1 );
BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
}
......
......@@ -123,21 +123,21 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties()
// Initialize 3D parameters
wxBoxSizer* BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, 2, 1 );
m_3D_Scale = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Scale:" ), BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, 2, 1 );
m_3D_Offset = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Offset:" ), BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
BoxSizer = new wxBoxSizer( wxVERTICAL );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, 2, 1 );
m_3D_Rotation = new WinEDA_VertexCtrl( m_Panel3D, _( "Shape Rotation:" ), BoxSizer, UNSCALED_UNITS, 1 );
m_Sizer3DValues->Add( BoxSizer, 0, wxGROW | wxALL, 5 );
// Initialize dialog relative to masks clearances
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
wxString msg;
int internalUnit = m_Parent->m_InternalUnits;
......
......@@ -156,17 +156,17 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
msg = m_TxtPosCtrlX->GetValue();
m_CurrentTextMod->m_Pos0.x = ReturnValueFromString( g_UnitMetric, msg,
m_CurrentTextMod->m_Pos0.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_TxtPosCtrlY->GetValue();
m_CurrentTextMod->m_Pos0.y = ReturnValueFromString( g_UnitMetric, msg,
m_CurrentTextMod->m_Pos0.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_TxtSizeCtrlX->GetValue();
m_CurrentTextMod->m_Size.x = ReturnValueFromString( g_UnitMetric, msg,
m_CurrentTextMod->m_Size.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_TxtSizeCtrlY->GetValue();
m_CurrentTextMod->m_Size.y = ReturnValueFromString( g_UnitMetric, msg,
m_CurrentTextMod->m_Size.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
// Test for a reasonnable size:
......@@ -176,7 +176,7 @@ void DialogEditModuleText::OnOkClick( wxCommandEvent& event )
m_CurrentTextMod->m_Size.y = TEXTS_MIN_SIZE;
msg = m_TxtWidthCtlr->GetValue();
int width = ReturnValueFromString( g_UnitMetric, msg, m_Parent->m_InternalUnits );
int width = ReturnValueFromString( g_UserUnit, msg, m_Parent->m_InternalUnits );
// Test for a reasonnable width:
if( width <= 1 )
......
......@@ -38,7 +38,7 @@ void Dialog_GeneralOptions::init()
/* Set display options */
m_PolarDisplay->SetSelection( DisplayOpt.DisplayPolarCood ? 1 : 0 );
m_UnitsSelection->SetSelection( g_UnitMetric ? 1 : 0 );
m_UnitsSelection->SetSelection( g_UserUnit ? 1 : 0 );
m_CursorShape->SetSelection( m_Parent->m_CursorShape ? 1 : 0 );
wxString timevalue;
......@@ -69,13 +69,13 @@ void Dialog_GeneralOptions::OnCancelClick( wxCommandEvent& event )
void Dialog_GeneralOptions::OnOkClick( wxCommandEvent& event )
{
int ii;
UserUnitType ii;
DisplayOpt.DisplayPolarCood =
( m_PolarDisplay->GetSelection() == 0 ) ? FALSE : true;
ii = g_UnitMetric;
g_UnitMetric = ( m_UnitsSelection->GetSelection() == 0 ) ? 0 : 1;
if( ii != g_UnitMetric )
ii = g_UserUnit;
g_UserUnit = ( m_UnitsSelection->GetSelection() == 0 ) ? INCHES : MILLIMETRES;
if( ii != g_UserUnit )
m_Parent->ReCreateAuxiliaryToolbar();
m_Parent->m_CursorShape = m_CursorShape->GetSelection();
......@@ -132,11 +132,11 @@ void WinEDA_PcbFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
g_UserUnit = MILLIMETRES;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
g_UnitMetric = INCHES;
g_UserUnit = INCHES;
m_TrackAndViasSizesList_Changed = true;
UpdateStatusBar();
ReCreateAuxiliaryToolbar();
......
......@@ -72,56 +72,56 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::MyInit()
// Display current values, and current netclass values:
int value = netclass->GetTrackWidth(); // Display track width
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
m_gridDisplayCurrentSettings->SetCellValue( 0, 0, msg );
if( board->m_TrackWidthSelector )
{
value = board->GetCurrentTrackWidth();
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
}
else
msg = _( "Default" );
m_gridDisplayCurrentSettings->SetCellValue( 1, 0, msg );
value = netclass->GetViaDiameter(); // Display via diameter
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
m_gridDisplayCurrentSettings->SetCellValue( 0, 1, msg );
if( board->m_ViaSizeSelector )
{
value = board->GetCurrentViaSize();
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
}
else
msg = _( "Default" );
m_gridDisplayCurrentSettings->SetCellValue( 1, 1, msg );
value = netclass->GetViaDrill(); // Display via drill
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
m_gridDisplayCurrentSettings->SetCellValue( 0, 2, msg );
value = board->GetCurrentViaDrill();
if( value >= 0 )
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
else
msg = _( "Default" );
m_gridDisplayCurrentSettings->SetCellValue( 1, 2, msg );
value = netclass->GetuViaDiameter(); // Display micro via diameter
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
m_gridDisplayCurrentSettings->SetCellValue( 0, 3, msg );
#if 0 // Currently we use always the default netclass value
value = board->GetCurrentMicroViaSize();
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
#endif
msg = _( "Default" );
m_gridDisplayCurrentSettings->SetCellValue( 1, 3, msg );
value = netclass->GetuViaDrill(); // Display micro via drill
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
m_gridDisplayCurrentSettings->SetCellValue( 0, 4, msg );
#if 0 // Currently we use always the default netclass value
value = board->GetCurrentMicroViaDrill();
if( value >= 0 )
msg = ReturnStringFromValue( g_UnitMetric, value, Internal_Unit, true );
msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true );
else
#endif
msg = _( "Default" );
......
......@@ -181,27 +181,27 @@ void DialogGraphicItemProperties::OnOkClick( wxCommandEvent& event )
m_Item->Draw( m_Parent->DrawPanel, m_DC, GR_XOR );
msg = m_Center_StartXCtrl->GetValue();
m_Item->m_Start.x = ReturnValueFromString( g_UnitMetric, msg,
m_Item->m_Start.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_Center_StartYCtrl->GetValue();
m_Item->m_Start.y = ReturnValueFromString( g_UnitMetric, msg,
m_Item->m_Start.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_EndX_Radius_Ctrl->GetValue();
m_Item->m_End.x = ReturnValueFromString( g_UnitMetric, msg,
m_Item->m_End.x = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_EndY_Ctrl->GetValue();
m_Item->m_End.y = ReturnValueFromString( g_UnitMetric, msg,
m_Item->m_End.y = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_ThicknessCtrl->GetValue();
m_Item->m_Width = ReturnValueFromString( g_UnitMetric, msg,
m_Item->m_Width = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
msg = m_DefaultThicknessCtrl->GetValue();
int thickness = ReturnValueFromString( g_UnitMetric, msg,
int thickness = ReturnValueFromString( g_UserUnit, msg,
m_Parent->m_InternalUnits );
m_Item->SetLayer( m_LayerSelection->GetCurrentSelection() + FIRST_NO_COPPER_LAYER);
......
......@@ -95,7 +95,7 @@ DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE::DIALOG_GRAPHIC_ITEMS_OPTIONS_BASE( wxWindow*
wxStaticBoxSizer* sbSizerRight;
sbSizerRight = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("General:") ), wxVERTICAL );
m_DefaultPenSizeTitle = new wxStaticText( this, wxID_ANY, _("Default pen size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_DefaultPenSizeTitle = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 );
m_DefaultPenSizeTitle->Wrap( -1 );
m_DefaultPenSizeTitle->SetToolTip( _("Pen size used to draw items that have no pen size specified.\nUsed mainly to draw items in sketch mode.") );
......
......@@ -1090,7 +1090,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Default pen size:</property>
<property name="label">Default pen size</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_DefaultPenSizeTitle</property>
......
......@@ -38,8 +38,8 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit()
{
SetFocus();
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
int Internal_Unit = m_Parent->m_InternalUnits;
PutValueInLocalUnits( *m_SolderMaskMarginCtrl,
......
......@@ -123,21 +123,21 @@ void DIALOG_PAD_PROPERTIES::InitDialog( )
pad = &g_Pad_Master;
// Display current unit name in dialog:
m_PadPosX_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadPosY_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadDrill_X_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadDrill_Y_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeSizeX_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeSizeY_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeOffsetX_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeOffsetY_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeDeltaX_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadShapeDeltaY_Unit->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_PadPosX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadPosY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadDrill_X_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadDrill_Y_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeSizeX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeSizeY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeOffsetY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeDeltaX_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_PadShapeDeltaY_Unit->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
// Display current pad masks clearances units
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UnitMetric ) );
m_NetClearanceUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) );
// Display current pad parameters units:
PutValueInLocalUnits( *m_PadPosition_X_Ctrl, pad->m_Pos.x, internalUnits );
......
......@@ -112,17 +112,17 @@ WinEDA_TextPCBPropertiesFrame::WinEDA_TextPCBPropertiesFrame( WinEDA_PcbFrame* p
m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
TextPCB->m_Size,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
m_TxtWidthCtlr = new WinEDA_ValueCtrl( this, _( "Width" ),
TextPCB->m_Width,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
m_TxtPosCtrl = new WinEDA_PositionCtrl( this, _( "Position" ),
TextPCB->m_Pos,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
m_SelLayerBox = new WinEDAChoiceBox( this, ID_TEXTPCB_SELECT_LAYER,
......
......@@ -171,7 +171,7 @@ DIALOG_PLOT_BASE::DIALOG_PLOT_BASE( wxWindow* parent, wxWindowID id, const wxStr
bButtonsSizer->Add( m_PlotNoViaOnMaskOpt, 0, wxALL, 5 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Default pen size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6 = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText6->Wrap( -1 );
m_staticText6->SetToolTip( _("Pen size used to draw items that have no pen size specified.\nUsed mainly to draw items in sketch mode.") );
......
......@@ -1368,7 +1368,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Default pen size:</property>
<property name="label">Default pen size</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_staticText6</property>
......
......@@ -258,9 +258,9 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( )
m_ModeColorOption->SetSelection( 0 );
s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness;
AddUnitSymbol( *m_TextPenWidth, g_UnitMetric );
AddUnitSymbol( *m_TextPenWidth, g_UserUnit );
m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenDefaultSize, m_Parent->m_InternalUnits ) );
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, m_Parent->m_InternalUnits ) );
// Create scale adjust option
......@@ -429,7 +429,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth()
g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize;
m_DialogPenWidth->SetValue(
ReturnStringFromValue( g_UnitMetric, s_Parameters.m_PenDefaultSize, m_Parent->m_InternalUnits ) );
ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, m_Parent->m_InternalUnits ) );
}
void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event )
......
......@@ -75,7 +75,7 @@ DIALOG_PRINT_USING_PRINTER_base::DIALOG_PRINT_USING_PRINTER_base( wxWindow* pare
wxStaticBoxSizer* sbOptionsSizer;
sbOptionsSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Options:") ), wxVERTICAL );
m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size:"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextPenWidth = new wxStaticText( this, wxID_ANY, _("Default pen size"), wxDefaultPosition, wxDefaultSize, 0 );
m_TextPenWidth->Wrap( -1 );
m_TextPenWidth->SetToolTip( _("Pen size used to draw items that have no pen size specified.\nUsed mainly to draw items in sketch mode.") );
......
......@@ -490,7 +490,7 @@
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Default pen size:</property>
<property name="label">Default pen size</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_TextPenWidth</property>
......
......@@ -114,11 +114,11 @@ DIMENSION_EDITOR_DIALOG::DIMENSION_EDITOR_DIALOG( WinEDA_PcbFrame* parent,
m_TxtSizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ),
Dimension->m_Text->m_Size,
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
m_TxtWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
Dimension->m_Width,
g_UnitMetric, LeftBoxSizer, m_Parent->m_InternalUnits );
g_UserUnit, LeftBoxSizer, m_Parent->m_InternalUnits );
wxStaticText* text = new wxStaticText( this, -1, _( "Layer:" ) );
LeftBoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 );
......
......@@ -317,7 +317,7 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg )
const BOARD_DESIGN_SETTINGS& g = *m_pcb->GetBoardDesignSettings();
#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UnitMetric, x, PCB_INTERNAL_UNIT ) )
#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x, PCB_INTERNAL_UNIT ) )
#if 0 // set to 1 when (if...) BOARD_DESIGN_SETTINGS has a m_MinClearance value
if( nc->GetClearance() < g.m_MinClearance )
......
......@@ -365,7 +365,7 @@ void WinEDA_PcbFrame::OnHotKey( wxDC* DC, int hotkey, EDA_BaseStruct* DrawStruct
break;
case HK_SWITCH_UNITS:
g_UnitMetric = (g_UnitMetric == INCHES) ? MILLIMETRE : INCHES;
g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
break;
case HK_SWITCH_TRACK_DISPLAY_MODE:
......@@ -726,7 +726,7 @@ void WinEDA_ModuleEditFrame::OnHotKey( wxDC* DC, int hotkey,
break;
case HK_SWITCH_UNITS:
g_UnitMetric = (g_UnitMetric == INCHES) ? MILLIMETRE : INCHES;
g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
break;
case HK_ZOOM_IN:
......
......@@ -105,13 +105,13 @@ WinEDA_MirePropertiesFrame::WinEDA_MirePropertiesFrame(
// Size:
m_MireSizeCtrl = new WinEDA_ValueCtrl( this, _( "Size" ),
m_MirePcb->m_Size,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
// Width:
m_MireWidthCtrl = new WinEDA_ValueCtrl( this, _( "Width" ),
m_MirePcb->m_Width,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
m_Parent->m_InternalUnits );
// Shape
......
......@@ -27,11 +27,11 @@ void WinEDA_ModuleEditFrame::OnSelectOptionToolbar( wxCommandEvent& event )
break;
case ID_TB_OPTIONS_SELECT_UNIT_MM:
g_UnitMetric = MILLIMETRE;
g_UserUnit = MILLIMETRES;
case ID_TB_OPTIONS_SELECT_UNIT_INCH:
if( id == ID_TB_OPTIONS_SELECT_UNIT_INCH )
g_UnitMetric = INCHES;
g_UserUnit = INCHES;
UpdateStatusBar();
ReCreateAuxiliaryToolbar();
break;
......
......@@ -178,7 +178,7 @@ WinEDA_ModuleEditFrame::WinEDA_ModuleEditFrame( wxWindow* father,
GetScreen()->SetCurItem( NULL );
LoadSettings();
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
......@@ -351,10 +351,10 @@ void WinEDA_ModuleEditFrame::SetToolbars()
{
m_OptionsToolBar->ToggleTool(
ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric ==
MILLIMETRE ? TRUE : false );
g_UserUnit ==
MILLIMETRES ? TRUE : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : false );
g_UserUnit == INCHES ? TRUE : false );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
......
......@@ -220,7 +220,7 @@ MODULE* WinEDA_PcbFrame::Genere_Self( wxDC* DC )
}
/* Enter the desired length. */
if( !g_UnitMetric )
if( !g_UserUnit )
{
fcoeff = 10000.0;
msg.Printf( wxT( "%1.4f" ), Mself.lng / fcoeff );
......@@ -677,7 +677,7 @@ MODULE* WinEDA_PcbFrame::Create_MuWaveComponent( int shape_type )
}
wxString value;
if( g_UnitMetric )
if( g_UserUnit )
{
fcoeff = 10000.0f / 25.4f;
value.Printf( wxT( "%2.4f" ), gap_size / fcoeff );
......@@ -862,7 +862,7 @@ WinEDA_SetParamShapeFrame::WinEDA_SetParamShapeFrame( WinEDA_PcbFrame* parent,
LeftBoxSizer->Add( m_ShapeOptionCtrl, 0, wxGROW | wxALL, 5 );
m_SizeCtrl = new WinEDA_SizeCtrl( this, _( "Size" ), ShapeSize,
g_UnitMetric, LeftBoxSizer,
g_UserUnit, LeftBoxSizer,
PCB_INTERNAL_UNIT );
GetSizer()->Fit( this );
......@@ -1163,7 +1163,7 @@ void WinEDA_PcbFrame::Edit_Gap( wxDC* DC, MODULE* Module )
gap_size = next_pad->m_Pos0.x - pad->m_Pos0.x - pad->m_Size.x;
/* Entrance to the desired length of the gap. */
if( g_UnitMetric )
if( g_UserUnit )
{
fcoeff = 10000.0f / 25.4f;
msg.Printf( wxT( "%2.3f" ), gap_size / fcoeff );
......
......@@ -837,7 +837,7 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard )
for( unsigned ii = 0; ii < aBoard->m_TrackWidthList.size(); ii++ )
{
value = ReturnStringFromValue( g_UnitMetric, aBoard->m_TrackWidthList[ii],
value = ReturnStringFromValue( g_UserUnit, aBoard->m_TrackWidthList[ii],
PCB_INTERNAL_UNIT, true );
msg.Printf( _( "Track %s" ), GetChars( value ) );
if( ii == 0 )
......@@ -857,9 +857,9 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard )
trackwidth_menu->AppendSeparator();
for( unsigned ii = 0; ii < aBoard->m_ViasDimensionsList.size(); ii++ )
{
value = ReturnStringFromValue( g_UnitMetric, aBoard->m_ViasDimensionsList[ii].m_Diameter,
value = ReturnStringFromValue( g_UserUnit, aBoard->m_ViasDimensionsList[ii].m_Diameter,
PCB_INTERNAL_UNIT, true );
wxString drill = ReturnStringFromValue( g_UnitMetric,
wxString drill = ReturnStringFromValue( g_UserUnit,
aBoard->m_ViasDimensionsList[ii].m_Drill,
PCB_INTERNAL_UNIT, true );
if( aBoard->m_ViasDimensionsList[ii].m_Drill <= 0 )
......
......@@ -303,7 +303,7 @@ WinEDA_PcbFrame::WinEDA_PcbFrame( wxWindow* father,
LoadSettings();
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
if( DrawPanel )
......
......@@ -302,7 +302,7 @@ PARAM_CFG_ARRAY& WinEDA_PcbFrame::GetConfigurationSettings()
OPT_VIA_HOLE_END - 1 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "ShowNetNamesMode" ),
&DisplayOpt.DisplayNetNamesMode, 3, 0, 3 ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Unite" ), &g_UnitMetric, FALSE ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Unite" ), (int*)&g_UserUnit, MILLIMETRES ) );
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "SegFill" ),
&DisplayOpt.DisplayPcbTrackFill, TRUE ) );
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "TrackDisplayClearance" ),
......
......@@ -151,22 +151,22 @@ void DIALOG_PLOT::Init_Dialog()
// Set units and value for HPGL pen speed.
AddUnitSymbol( *m_textPenSize, g_UnitMetric );
msg = ReturnStringFromValue( g_UnitMetric, g_pcb_plot_options.HPGL_Pen_Diam, UNITS_MILS );
AddUnitSymbol( *m_textPenSize, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit, g_pcb_plot_options.HPGL_Pen_Diam, UNITS_MILS );
m_HPGLPenSizeOpt->AppendText( msg );
// Set units to cm for standard HPGL pen speed.
msg = ReturnStringFromValue( CENTIMETRE, g_pcb_plot_options.HPGL_Pen_Speed, 1 );
msg = ReturnStringFromValue( UNSCALED_UNITS, g_pcb_plot_options.HPGL_Pen_Speed, 1 );
m_HPGLPenSpeedOpt->AppendText( msg );
// Set units and value for HPGL pen overlay.
AddUnitSymbol( *m_textPenOvr, g_UnitMetric );
msg = ReturnStringFromValue( g_UnitMetric,
AddUnitSymbol( *m_textPenOvr, g_UserUnit );
msg = ReturnStringFromValue( g_UserUnit,
g_pcb_plot_options.HPGL_Pen_Recouvrement,
UNITS_MILS );
m_HPGLPenOverlayOpt->AppendText( msg );
msg = ReturnStringFromValue( g_UnitMetric,
msg = ReturnStringFromValue( g_UserUnit,
g_pcb_plot_options.PlotLine_Width,
PCB_INTERNAL_UNIT );
m_LinesWidth->AppendText( msg );
......@@ -443,19 +443,19 @@ void DIALOG_PLOT::SaveOptPlot( wxCommandEvent& event )
g_pcb_plot_options.DrawViaOnMaskLayer = m_PlotNoViaOnMaskOpt->GetValue();
wxString msg = m_HPGLPenSizeOpt->GetValue();
int tmp = ReturnValueFromString( g_UnitMetric, msg, UNITS_MILS );
int tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
g_pcb_plot_options.HPGL_Pen_Diam = tmp;
msg = m_HPGLPenSpeedOpt->GetValue();
tmp = ReturnValueFromString( CENTIMETRE, msg, 1 );
tmp = ReturnValueFromString( MILLIMETRES, msg, 1 );
g_pcb_plot_options.HPGL_Pen_Speed = tmp;
msg = m_HPGLPenOverlayOpt->GetValue();
tmp = ReturnValueFromString( g_UnitMetric, msg, UNITS_MILS );
tmp = ReturnValueFromString( g_UserUnit, msg, UNITS_MILS );
g_pcb_plot_options.HPGL_Pen_Recouvrement = tmp;
msg = m_LinesWidth->GetValue();
tmp = ReturnValueFromString( g_UnitMetric, msg, PCB_INTERNAL_UNIT );
tmp = ReturnValueFromString( g_UserUnit, msg, PCB_INTERNAL_UNIT );
g_pcb_plot_options.PlotLine_Width = tmp;
g_DrawDefaultLineThickness = g_pcb_plot_options.PlotLine_Width;
......
......@@ -21,15 +21,15 @@ void WinEDA_BasePcbFrame::InstallGridFrame( const wxPoint& pos )
WinEDA_PcbGridFrame dlg( this, pos );
dlg.SetGridSize( m_UserGridSize );
dlg.SetGridUnits( m_UserGridUnits );
dlg.SetGridUnits( m_UserGridUnit );
if( dlg.ShowModal() == wxID_CANCEL )
return;
m_UserGridSize = dlg.GetGridSize();
m_UserGridUnits = dlg.GetGridUnits();
m_UserGridUnit = (UserUnitType)dlg.GetGridUnits();
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnits, ID_POPUP_GRID_USER );
GetScreen()->AddGrid( m_UserGridSize, m_UserGridUnit, ID_POPUP_GRID_USER );
// If the user grid is the current option, recall SetGrid()
// to force new values put in list as current grid value
......
......@@ -293,15 +293,25 @@ void WinEDA_ModuleEditFrame::ReCreateAuxiliaryToolbar()
m_SelGridBox->Clear();
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{
double value = To_User_Unit( g_UnitMetric,
double value = To_User_Unit( g_UserUnit,
GetScreen()->m_GridList[i].m_Size.x,
PCB_INTERNAL_UNIT );
if( GetScreen()->m_GridList[i].m_Id != ID_POPUP_GRID_USER )
{
if( g_UnitMetric == INCHES )
switch( g_UserUnit )
{
case INCHES:
msg.Printf( _( "Grid %.1f" ), value * 1000 );
else
break;
case MILLIMETRES:
msg.Printf( _( "Grid %.3f" ), value );
break;
case UNSCALED_UNITS:
msg.Printf( _( "Grid %f" ), value );
break;
}
}
else
{
......
......@@ -616,22 +616,39 @@ an existing track use its width\notherwise, use current width setting" ),
// Update displayed values
m_SelGridBox->Clear();
wxString format = _( "Grid");
if( g_UnitMetric == INCHES )
switch( g_UserUnit )
{
case INCHES:
format += wxT( " %.1f" );
else
break;
case MILLIMETRES:
format += wxT( " %.3f" );
break;
case UNSCALED_UNITS:
format += wxT( " %f" );
break;
}
for( i = 0; i < GetScreen()->m_GridList.GetCount(); i++ )
{
GRID_TYPE grid = GetScreen()->m_GridList[i];
double value = To_User_Unit( g_UnitMetric, grid.m_Size.x,
double value = To_User_Unit( g_UserUnit, grid.m_Size.x,
m_InternalUnits );
if( grid.m_Id != ID_POPUP_GRID_USER )
{
if( g_UnitMetric == INCHES )
switch( g_UserUnit )
{
case INCHES:
msg.Printf( format.GetData(), value * 1000 );
else
break;
case MILLIMETRES:
case UNSCALED_UNITS:
msg.Printf( format.GetData(), value );
break;
}
}
else
msg = _( "User Grid" );
......
......@@ -19,15 +19,15 @@
#include "class_board_design_settings.h"
/* helper to convert an integer value to a string, using mils or mm
* according to g_UnitMetric value
* according to g_UserUnit value
*/
static wxString ReturnStringValue( int aValue )
{
wxString text;
const wxChar* format;
double value = To_User_Unit( g_UnitMetric, aValue, PCB_INTERNAL_UNIT );
double value = To_User_Unit( g_UserUnit, aValue, PCB_INTERNAL_UNIT );
if( g_UnitMetric == INCHES )
if( g_UserUnit == INCHES )
{
format = wxT( " %.1f" );
value *= 1000;
......@@ -35,7 +35,7 @@ static wxString ReturnStringValue( int aValue )
else
format = wxT( " %.3f" );
text.Printf( format, value );
if( g_UnitMetric == INCHES )
if( g_UserUnit == INCHES )
text += _( " mils" );
else
text += _( " mm" );
......@@ -196,9 +196,9 @@ void WinEDA_PcbFrame::SetToolbars()
_( "Enable design rule checking" ) );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_MM,
g_UnitMetric == MILLIMETRE ? TRUE : false );
g_UserUnit == MILLIMETRES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SELECT_UNIT_INCH,
g_UnitMetric == INCHES ? TRUE : false );
g_UserUnit == INCHES );
m_OptionsToolBar->ToggleTool( ID_TB_OPTIONS_SHOW_POLAR_COORD,
DisplayOpt.DisplayPolarCood );
......
......@@ -81,8 +81,8 @@ void DialogNonCopperZonesEditor::Init()
m_FillModeCtrl->SetSelection( m_Zone_Setting->m_FillMode ? 1 : 0 );
AddUnitSymbol( *m_MinThicknessValueTitle, g_UnitMetric );
wxString msg = ReturnStringFromValue( g_UnitMetric,
AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit );
wxString msg = ReturnStringFromValue( g_UserUnit,
m_Zone_Setting->m_ZoneMinThickness,
m_Parent->m_InternalUnits );
m_ZoneMinThicknessCtrl->SetValue( msg );
......@@ -134,7 +134,7 @@ void DialogNonCopperZonesEditor::OnOkClick( wxCommandEvent& event )
{
wxString txtvalue = m_ZoneMinThicknessCtrl->GetValue();
m_Zone_Setting->m_ZoneMinThickness =
ReturnValueFromString( g_UnitMetric, txtvalue, m_Parent->m_InternalUnits );
ReturnValueFromString( g_UserUnit, txtvalue, m_Parent->m_InternalUnits );
if( m_Zone_Setting->m_ZoneMinThickness < 10 )
{
DisplayError( this,
......
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