← Back to team overview

kicad-developers team mailing list archive

Unit parser

 

I reworked the patch. Now the unit type is an enum so it's better error
checked than the previous int/boolean mixup, anyway.

The only thing I'm not still satisfied is the 3d properties... shouldn't
the boxes here *unitless*? There is no sense in attaching a unit to
a geometric transformation like scaling and at most 'degrees' for the
rotation fields... translation could be attached a significative unit,
but it seems it wasn't handled correctly (well, maybe they were cm, but
where cm comes from? IIRC our unit for 3d is imperial, anyway). I'd
suggest to look in these before committing (I never used them so
I really have no idea about their 'correct' meaning)

--
Lorenzo Marcantonio
Logos Srl
=== modified file '3d-viewer/3d_aux.cpp'
--- 3d-viewer/3d_aux.cpp	2009-11-04 20:46:53 +0000
+++ 3d-viewer/3d_aux.cpp	2010-07-09 14:30:05 +0000
@@ -183,7 +183,7 @@
  * 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;

=== modified file '3d-viewer/3d_struct.h'
--- 3d-viewer/3d_struct.h	2009-11-04 20:46:53 +0000
+++ 3d-viewer/3d_struct.h	2010-07-09 14:36:45 +0000
@@ -123,7 +123,7 @@
 
 public:
     WinEDA_VertexCtrl( wxWindow* parent, const wxString& title,
-                       wxBoxSizer* BoxSizer, int units, int internal_unit );
+                       wxBoxSizer* BoxSizer, UserUnitType units, int internal_unit );
 
     ~WinEDA_VertexCtrl();
 

=== modified file 'common/base_screen.cpp'
--- common/base_screen.cpp	2010-04-08 14:22:01 +0000
+++ common/base_screen.cpp	2010-07-12 07:43:47 +0000
@@ -435,26 +435,24 @@
 }
 
 
-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();

=== modified file 'common/common.cpp'
--- common/common.cpp	2010-06-09 06:17:04 +0000
+++ common/common.cpp	2010-07-12 07:48:33 +0000
@@ -81,8 +81,8 @@
 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;
@@ -222,23 +222,22 @@
 }
 
 
-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;
     }
 
@@ -251,26 +250,22 @@
 }
 
 
-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;
     }
 
@@ -278,26 +273,21 @@
 }
 
 
-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;
     }
 
@@ -309,10 +299,11 @@
  * 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 );
 }
@@ -320,11 +311,11 @@
 
 /*
  * 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 );
 }
@@ -332,14 +323,14 @@
 
 /*
  * 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;
 }
@@ -355,35 +346,30 @@
  * @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;
         }
 
@@ -398,17 +384,51 @@
  *  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;
 }
@@ -450,34 +470,46 @@
  * 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;
-
-    if( is_metric )
-        value = val * 25.4 / internal_unit_value;
-    else
-        value = val / internal_unit_value;
-
-    return value;
+    switch( aUnit )
+    {
+    case MILLIMETRES:
+        return val * 25.4 / internal_unit_value;
+
+    case INCHES:
+        return val / internal_unit_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 );
 }
@@ -644,13 +676,19 @@
  */
 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;

=== modified file 'common/dialog_page_settings.cpp'
--- common/dialog_page_settings.cpp	2010-03-14 10:34:40 +0000
+++ common/dialog_page_settings.cpp	2010-07-12 07:50:38 +0000
@@ -81,24 +81,36 @@
     msg.Printf(format, m_Screen->m_ScreenNumber);
     m_TextSheetNumber->SetLabel(msg);
 
-    if( g_UnitMetric )
-    {
-        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);
-    }
+    switch( g_UserUnit )
+    {
+    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 @@
     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
-    {
-        g_Sheet_user.m_Size.x = (int)( UserSizeX * 1000 );
-        g_Sheet_user.m_Size.y = (int)( UserSizeY * 1000 );
+    switch( g_UserUnit )
+    {
+    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 )

=== modified file 'common/drawframe.cpp'
--- common/drawframe.cpp	2010-04-08 14:22:01 +0000
+++ common/drawframe.cpp	2010-07-12 07:52:13 +0000
@@ -73,7 +73,6 @@
     m_Print_Sheet_Ref     = TRUE;   // TRUE to print reference sheet.
     m_Draw_Auxiliary_Axis = FALSE;  // TRUE draw auxilary axis.
     m_Draw_Grid_Axis = FALSE;  // TRUE to draw the grid axis
-    m_UnitType            = INTERNAL_UNIT_TYPE;    // Internal unit = inch
     m_CursorShape         = 0;
     m_LastGridSizeId      = 0;
     m_DrawGrid            = true;   // hide/Show grid. default = show
@@ -335,18 +334,18 @@
 {
     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;
     }
 
@@ -611,45 +610,68 @@
     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 );
 }
 

=== modified file 'common/wxwineda.cpp'
--- common/wxwineda.cpp	2009-11-23 15:16:50 +0000
+++ common/wxwineda.cpp	2010-07-09 16:04:04 +0000
@@ -89,12 +89,12 @@
                                                 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 @@
 
     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 @@
 }
 
 
-wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, int units,
+wxString WinEDA_GraphicTextCtrl::FormatSize( int internalUnit, UserUnitType aUnit,
                                              int textSize )
 {
     wxString value;
@@ -147,7 +147,7 @@
         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( 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 @@
 
 
 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::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 @@
 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 @@
         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 @@
 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 @@
     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 @@
 /*******************/
 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 @@
 /* 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      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 @@
 
     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 );
 }
 

=== modified file 'common/zoom.cpp'
--- common/zoom.cpp	2010-04-08 14:22:01 +0000
+++ common/zoom.cpp	2010-07-12 07:53:46 +0000
@@ -236,8 +236,8 @@
         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 )
             {
@@ -245,12 +245,22 @@
             }
             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 )

=== modified file 'cvpcb/class_DisplayFootprintsFrame.cpp'
--- cvpcb/class_DisplayFootprintsFrame.cpp	2010-04-16 16:28:35 +0000
+++ cvpcb/class_DisplayFootprintsFrame.cpp	2010-07-12 07:54:46 +0000
@@ -252,10 +252,9 @@
     {
         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 @@
         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;
 

=== modified file 'eeschema/class_BodyItem_Text.cpp'
--- eeschema/class_BodyItem_Text.cpp	2010-03-16 12:05:47 +0000
+++ eeschema/class_BodyItem_Text.cpp	2010-07-09 16:41:18 +0000
@@ -363,7 +363,7 @@
 
     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 );

=== modified file 'eeschema/class_pin.cpp'
--- eeschema/class_pin.cpp	2010-06-24 18:31:43 +0000
+++ eeschema/class_pin.cpp	2010-07-09 16:43:51 +0000
@@ -1647,7 +1647,7 @@
     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 );
 

=== modified file 'eeschema/classes_body_items.cpp'
--- eeschema/classes_body_items.cpp	2010-06-13 16:55:22 +0000
+++ eeschema/classes_body_items.cpp	2010-07-09 16:48:22 +0000
@@ -526,7 +526,7 @@
 
     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 );
@@ -787,12 +787,12 @@
 
     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 );
 
@@ -1016,7 +1016,7 @@
 
     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 );
 }
@@ -1267,7 +1267,7 @@
 
     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 );
@@ -1685,7 +1685,7 @@
 
     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 );
@@ -2056,7 +2056,7 @@
 
     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 );

=== modified file 'eeschema/dialog_SVG_print.cpp'
--- eeschema/dialog_SVG_print.cpp	2010-04-20 11:23:59 +0000
+++ eeschema/dialog_SVG_print.cpp	2010-07-09 17:34:47 +0000
@@ -100,9 +100,9 @@
 
     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 @@
     }
 
     m_DialogPenWidth->SetValue(
-        ReturnStringFromValue( g_UnitMetric, g_DrawDefaultLineThickness,
+        ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness,
                                m_Parent->m_InternalUnits ) );
 }
 

=== modified file 'eeschema/dialog_edit_component_in_schematic.cpp'
--- eeschema/dialog_edit_component_in_schematic.cpp	2010-06-30 13:08:50 +0000
+++ eeschema/dialog_edit_component_in_schematic.cpp	2010-07-09 16:52:19 +0000
@@ -91,17 +91,17 @@
     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 @@
 
     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 @@
         // 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 @@
     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 @@
     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;
 }

=== modified file 'eeschema/dialog_edit_label.cpp'
--- eeschema/dialog_edit_label.cpp	2010-03-30 10:10:33 +0000
+++ eeschema/dialog_edit_label.cpp	2010-07-09 18:09:35 +0000
@@ -140,11 +140,11 @@
 
     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 @@
 
     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();

=== modified file 'eeschema/dialog_edit_libentry_fields_in_lib.cpp'
--- eeschema/dialog_edit_libentry_fields_in_lib.cpp	2010-06-17 16:30:10 +0000
+++ eeschema/dialog_edit_libentry_fields_in_lib.cpp	2010-07-09 17:28:05 +0000
@@ -157,17 +157,17 @@
     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 @@
     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 @@
         // 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 @@
     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 @@
     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 );

=== modified file 'eeschema/edit_graphic_bodyitem_text.cpp'
--- eeschema/edit_graphic_bodyitem_text.cpp	2010-02-18 20:07:29 +0000
+++ eeschema/edit_graphic_bodyitem_text.cpp	2010-07-09 17:34:58 +0000
@@ -56,7 +56,7 @@
 
     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 @@
     }
     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 @@
     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;

=== modified file 'eeschema/eeschema_config.cpp'
--- eeschema/eeschema_config.cpp	2010-06-17 16:30:10 +0000
+++ eeschema/eeschema_config.cpp	2010-07-10 07:29:23 +0000
@@ -189,9 +189,9 @@
                 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 @@
     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 @@
     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 ) );

=== modified file 'eeschema/find.cpp'
--- eeschema/find.cpp	2010-06-11 18:34:20 +0000
+++ eeschema/find.cpp	2010-07-09 17:34:52 +0000
@@ -67,8 +67,8 @@
 
         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 );

=== modified file 'eeschema/pinedit.cpp'
--- eeschema/pinedit.cpp	2010-03-04 09:32:51 +0000
+++ eeschema/pinedit.cpp	2010-07-09 17:51:01 +0000
@@ -81,7 +81,7 @@
 
     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 @@
                                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 @@
     }
 
     /* 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();

=== modified file 'eeschema/plothpgl.cpp'
--- eeschema/plothpgl.cpp	2009-12-02 21:44:03 +0000
+++ eeschema/plothpgl.cpp	2010-07-09 17:34:53 +0000
@@ -492,11 +492,11 @@
 
     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 @@
     {
         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 @@
     {
         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 );

=== modified file 'eeschema/plotps.cpp'
--- eeschema/plotps.cpp	2009-12-02 21:44:03 +0000
+++ eeschema/plotps.cpp	2010-07-09 18:09:37 +0000
@@ -255,7 +255,7 @@
     m_DefaultLineSizeCtrl = new WinEDA_ValueCtrl( this,
                                                   _( "Default Line Width" ),
                                                   g_DrawDefaultLineThickness,
-                                                  g_UnitMetric,
+                                                  g_UserUnit,
                                                   m_DefaultLineSizeCtrlSizer,
                                                   EESCHEMA_INTERNAL_UNIT );
 }

=== modified file 'eeschema/schframe.cpp'
--- eeschema/schframe.cpp	2010-05-17 20:35:46 +0000
+++ eeschema/schframe.cpp	2010-07-12 07:06:24 +0000
@@ -563,10 +563,10 @@
 
 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();
 }
 

=== modified file 'eeschema/sheet.cpp'
--- eeschema/sheet.cpp	2010-06-24 18:31:43 +0000
+++ eeschema/sheet.cpp	2010-07-09 17:51:35 +0000
@@ -43,14 +43,14 @@
 
     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 @@
             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 );
 

=== modified file 'eeschema/sheetlab.cpp'
--- eeschema/sheetlab.cpp	2010-06-24 18:31:43 +0000
+++ eeschema/sheetlab.cpp	2010-07-09 17:34:55 +0000
@@ -87,7 +87,7 @@
     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

=== modified file 'eeschema/symbdraw.cpp'
--- eeschema/symbdraw.cpp	2010-04-06 14:09:52 +0000
+++ eeschema/symbdraw.cpp	2010-07-09 17:34:57 +0000
@@ -68,9 +68,9 @@
 
     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 @@
         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();

=== modified file 'eeschema/tool_sch.cpp'
--- eeschema/tool_sch.cpp	2010-07-01 06:24:12 +0000
+++ eeschema/tool_sch.cpp	2010-07-10 07:29:25 +0000
@@ -294,13 +294,13 @@
         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;

=== modified file 'gerbview/gerberframe.cpp'
--- gerbview/gerberframe.cpp	2010-05-17 20:35:46 +0000
+++ gerbview/gerberframe.cpp	2010-07-10 07:29:26 +0000
@@ -286,10 +286,10 @@
     {
         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 );

=== modified file 'gerbview/gerbview_config.h'
--- gerbview/gerbview_config.h	2010-02-03 14:05:17 +0000
+++ gerbview/gerbview_config.h	2010-07-10 07:29:27 +0000
@@ -36,8 +36,8 @@
 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

=== modified file 'gerbview/hotkeys.cpp'
--- gerbview/hotkeys.cpp	2010-01-20 18:59:46 +0000
+++ gerbview/hotkeys.cpp	2010-07-10 07:29:28 +0000
@@ -131,7 +131,7 @@
         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:

=== modified file 'gerbview/options.cpp'
--- gerbview/options.cpp	2010-02-03 17:38:32 +0000
+++ gerbview/options.cpp	2010-07-10 07:29:28 +0000
@@ -46,12 +46,12 @@
         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 @@
     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 @@
 {
     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;

=== modified file 'include/base_struct.h'
--- include/base_struct.h	2010-04-23 09:54:40 +0000
+++ include/base_struct.h	2010-07-09 15:35:42 +0000
@@ -15,7 +15,6 @@
 
 #endif
 
-
 /* Id for class identification, at run time */
 enum KICAD_T {
     NOT_USED = -1,          // the 3d code uses this value

=== modified file 'include/class_base_screen.h'
--- include/class_base_screen.h	2010-04-08 14:22:01 +0000
+++ include/class_base_screen.h	2010-07-09 18:39:40 +0000
@@ -12,6 +12,7 @@
 #include "base_struct.h"
 #include "class_undoredo_container.h"
 #include "block_commande.h"
+#include "common.h"
 
 
 // Forward declarations:
@@ -327,7 +328,7 @@
     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 );
 
 
     /**

=== modified file 'include/common.h'
--- include/common.h	2010-05-17 20:35:46 +0000
+++ include/common.h	2010-07-12 06:13:37 +0000
@@ -15,7 +15,6 @@
 class WinEDAListBox;
 class WinEDA_DrawPanel;
 
-
 /* Flag for special keys */
 #define GR_KB_RIGHTSHIFT 0x10000000                 /* Keybd states: right
                                                      * shift key depressed */
@@ -75,9 +74,11 @@
 #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 */
@@ -181,7 +182,7 @@
 // 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 unit
 
 /* Draw color for moving objects: */
 extern int          g_GhostColor;
@@ -309,7 +310,7 @@
  *                        the format string must contain the %s format specifier.
  * @return The formatted units symbol.
  */
-wxString        ReturnUnitSymbol( int aUnits                    = g_UnitMetric,
+wxString        ReturnUnitSymbol( UserUnitType aUnit = g_UserUnit,
                                   const wxString& aFormatString = _( " (%s):" ) );
 
 /**
@@ -321,10 +322,10 @@
  * @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
@@ -337,12 +338,12 @@
  * @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 */
@@ -350,7 +351,7 @@
                                       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 );
@@ -362,16 +363,15 @@
  * 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();

=== modified file 'include/wxBasePcbFrame.h'
--- include/wxBasePcbFrame.h	2010-06-14 20:16:47 +0000
+++ include/wxBasePcbFrame.h	2010-07-10 07:31:17 +0000
@@ -58,7 +58,7 @@
     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;

=== modified file 'include/wxstruct.h'
--- include/wxstruct.h	2010-04-08 14:22:01 +0000
+++ include/wxstruct.h	2010-07-09 15:58:19 +0000
@@ -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 @@
                                             // = 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_Grid_Axis;     /* TRUE to show grid axis. */
     bool         m_Draw_Sheet_Ref;          // TRUE to show frame references
@@ -567,7 +565,8 @@
 class WinEDA_GraphicTextCtrl
 {
 public:
-    int           m_Units, m_Internal_Unit;
+    UserUnitType  m_UserUnit;
+    int           m_Internal_Unit;
 
     wxTextCtrl*   m_FrameText;
     wxTextCtrl*   m_FrameSize;
@@ -577,7 +576,7 @@
 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();
@@ -595,10 +594,10 @@
      * 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 );
 };
 
 
@@ -609,7 +608,8 @@
 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;
@@ -620,7 +620,7 @@
 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();
@@ -640,7 +640,7 @@
 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() { }
@@ -654,7 +654,7 @@
 class WinEDA_ValueCtrl
 {
 public:
-    int           m_Units;
+    UserUnitType  m_UserUnit;
     int           m_Value;
     wxTextCtrl*   m_ValueCtrl;
 private:
@@ -663,7 +663,7 @@
 
 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();

=== modified file 'pcbnew/basepcbframe.cpp'
--- pcbnew/basepcbframe.cpp	2010-05-01 12:46:33 +0000
+++ pcbnew/basepcbframe.cpp	2010-07-12 07:58:20 +0000
@@ -66,7 +66,7 @@
     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 @@
         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 @@
 
     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 @@
     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 );

=== modified file 'pcbnew/dialog_SVG_print.cpp'
--- pcbnew/dialog_SVG_print.cpp	2010-04-20 15:56:47 +0000
+++ pcbnew/dialog_SVG_print.cpp	2010-07-09 18:09:50 +0000
@@ -95,9 +95,9 @@
     }
 
     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 @@
 
     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 ) );
 }
 

=== modified file 'pcbnew/dialog_copper_zones.cpp'
--- pcbnew/dialog_copper_zones.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/dialog_copper_zones.cpp	2010-07-09 17:52:26 +0000
@@ -62,14 +62,14 @@
 
     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 @@
         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 @@
 
     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 @@
 
     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,

=== modified file 'pcbnew/dialog_design_rules.cpp'
--- pcbnew/dialog_design_rules.cpp	2010-04-29 09:06:01 +0000
+++ pcbnew/dialog_design_rules.cpp	2010-07-09 18:09:40 +0000
@@ -156,15 +156,15 @@
     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 @@
 
     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 @@
     // 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 @@
 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 @@
         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 @@
         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 @@
 
     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 @@
         }
 
         // 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 @@
             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 @@
         }
 
         // 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 @@
             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 @@
         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 @@
         if( tvalue.IsEmpty() )
             continue;
 
-        int viadia = ReturnValueFromString( g_UnitMetric,
+        int viadia = ReturnValueFromString( g_UserUnit,
                                        tvalue,
                                        m_Parent->m_InternalUnits );
         if( viadia < minViaDia )

=== modified file 'pcbnew/dialog_edit_module_for_BoardEditor.cpp'
--- pcbnew/dialog_edit_module_for_BoardEditor.cpp	2010-05-03 15:24:54 +0000
+++ pcbnew/dialog_edit_module_for_BoardEditor.cpp	2010-07-12 06:49:09 +0000
@@ -57,11 +57,11 @@
 {
     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 @@
     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 @@
 
     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 );
 }
 

=== modified file 'pcbnew/dialog_edit_module_for_Modedit.cpp'
--- pcbnew/dialog_edit_module_for_Modedit.cpp	2010-05-16 14:05:04 +0000
+++ pcbnew/dialog_edit_module_for_Modedit.cpp	2010-07-12 06:48:56 +0000
@@ -123,21 +123,21 @@
     // 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;

=== modified file 'pcbnew/dialog_edit_module_text.cpp'
--- pcbnew/dialog_edit_module_text.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/dialog_edit_module_text.cpp	2010-07-09 17:57:08 +0000
@@ -156,17 +156,17 @@
 
 
     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 @@
         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 )

=== modified file 'pcbnew/dialog_general_options.cpp'
--- pcbnew/dialog_general_options.cpp	2010-05-01 09:22:12 +0000
+++ pcbnew/dialog_general_options.cpp	2010-07-10 07:29:31 +0000
@@ -38,7 +38,7 @@
 
     /* 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::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 @@
         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();

=== modified file 'pcbnew/dialog_global_edit_tracks_and_vias.cpp'
--- pcbnew/dialog_global_edit_tracks_and_vias.cpp	2009-11-13 17:08:05 +0000
+++ pcbnew/dialog_global_edit_tracks_and_vias.cpp	2010-07-09 18:09:43 +0000
@@ -72,56 +72,56 @@
 
     // 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" );

=== modified file 'pcbnew/dialog_graphic_item_properties.cpp'
--- pcbnew/dialog_graphic_item_properties.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/dialog_graphic_item_properties.cpp	2010-07-09 18:09:44 +0000
@@ -181,27 +181,27 @@
         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);

=== modified file 'pcbnew/dialog_graphic_items_options_base.cpp'
--- pcbnew/dialog_graphic_items_options_base.cpp	2010-02-24 15:33:03 +0000
+++ pcbnew/dialog_graphic_items_options_base.cpp	2010-07-09 06:42:08 +0000
@@ -95,7 +95,7 @@
 	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.") );

 	


=== modified file 'pcbnew/dialog_graphic_items_options_base.fbp'
--- pcbnew/dialog_graphic_items_options_base.fbp	2010-02-24 15:33:03 +0000
+++ pcbnew/dialog_graphic_items_options_base.fbp	2010-07-09 06:42:16 +0000
@@ -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>


=== modified file 'pcbnew/dialog_mask_clearance.cpp'
--- pcbnew/dialog_mask_clearance.cpp	2010-01-31 20:01:46 +0000
+++ pcbnew/dialog_mask_clearance.cpp	2010-07-09 18:09:49 +0000
@@ -38,8 +38,8 @@
 {
     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,

=== modified file 'pcbnew/dialog_pad_properties.cpp'
--- pcbnew/dialog_pad_properties.cpp	2010-04-23 14:46:00 +0000
+++ pcbnew/dialog_pad_properties.cpp	2010-07-09 18:00:15 +0000
@@ -123,21 +123,21 @@
         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 );

=== modified file 'pcbnew/dialog_pcb_text_properties.cpp'
--- pcbnew/dialog_pcb_text_properties.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/dialog_pcb_text_properties.cpp	2010-07-09 18:09:46 +0000
@@ -112,17 +112,17 @@
 
     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,

=== modified file 'pcbnew/dialog_plot_base.cpp'
--- pcbnew/dialog_plot_base.cpp	2010-02-24 15:33:03 +0000
+++ pcbnew/dialog_plot_base.cpp	2010-07-09 06:42:41 +0000
@@ -171,7 +171,7 @@
 	

 	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.") );

 	


=== modified file 'pcbnew/dialog_plot_base.fbp'
--- pcbnew/dialog_plot_base.fbp	2010-02-24 15:33:03 +0000
+++ pcbnew/dialog_plot_base.fbp	2010-07-09 06:42:45 +0000
@@ -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>


=== modified file 'pcbnew/dialog_print_using_printer.cpp'
--- pcbnew/dialog_print_using_printer.cpp	2010-04-22 17:47:10 +0000
+++ pcbnew/dialog_print_using_printer.cpp	2010-07-09 18:09:48 +0000
@@ -258,9 +258,9 @@
         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 @@
     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 )

=== modified file 'pcbnew/dialog_print_using_printer_base.cpp'
--- pcbnew/dialog_print_using_printer_base.cpp	2010-04-22 17:47:10 +0000
+++ pcbnew/dialog_print_using_printer_base.cpp	2010-07-09 06:42:50 +0000
@@ -75,7 +75,7 @@
 	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.") );

 	


=== modified file 'pcbnew/dialog_print_using_printer_base.fbp'
--- pcbnew/dialog_print_using_printer_base.fbp	2010-04-22 17:47:10 +0000
+++ pcbnew/dialog_print_using_printer_base.fbp	2010-07-09 06:42:54 +0000
@@ -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>


=== modified file 'pcbnew/dimension.cpp'
--- pcbnew/dimension.cpp	2010-04-23 09:54:40 +0000
+++ pcbnew/dimension.cpp	2010-07-09 17:52:08 +0000
@@ -114,11 +114,11 @@
 
     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 );

=== modified file 'pcbnew/drc.cpp'
--- pcbnew/drc.cpp	2010-04-08 11:33:43 +0000
+++ pcbnew/drc.cpp	2010-07-09 18:02:00 +0000
@@ -317,7 +317,7 @@
 
     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 )

=== modified file 'pcbnew/hotkeys.cpp'
--- pcbnew/hotkeys.cpp	2010-06-18 07:51:32 +0000
+++ pcbnew/hotkeys.cpp	2010-07-10 07:29:32 +0000
@@ -365,7 +365,7 @@
         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:
@@ -723,7 +723,7 @@
         break;
 
     case HK_SWITCH_UNITS:
-        g_UnitMetric = (g_UnitMetric == INCHES) ? MILLIMETRE : INCHES;
+        g_UserUnit = (g_UserUnit == INCHES) ? MILLIMETRES : INCHES;
         break;
 
     case HK_ZOOM_IN:

=== modified file 'pcbnew/mirepcb.cpp'
--- pcbnew/mirepcb.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/mirepcb.cpp	2010-07-10 07:29:33 +0000
@@ -105,13 +105,13 @@
     // 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

=== modified file 'pcbnew/modeditoptions.cpp'
--- pcbnew/modeditoptions.cpp	2010-02-01 21:23:27 +0000
+++ pcbnew/modeditoptions.cpp	2010-07-10 07:29:34 +0000
@@ -27,11 +27,11 @@
         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;

=== modified file 'pcbnew/moduleframe.cpp'
--- pcbnew/moduleframe.cpp	2010-07-01 08:23:21 +0000
+++ pcbnew/moduleframe.cpp	2010-07-10 09:09:46 +0000
@@ -181,7 +181,7 @@
     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 );
@@ -354,10 +354,10 @@
     {
         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 );

=== modified file 'pcbnew/muonde.cpp'
--- pcbnew/muonde.cpp	2010-02-19 13:23:58 +0000
+++ pcbnew/muonde.cpp	2010-07-09 18:09:56 +0000
@@ -220,7 +220,7 @@
     }
 
     /* 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 @@
     }
 
     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 @@
     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 @@
     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 );

=== modified file 'pcbnew/onrightclick.cpp'
--- pcbnew/onrightclick.cpp	2010-06-18 07:51:32 +0000
+++ pcbnew/onrightclick.cpp	2010-07-09 18:09:58 +0000
@@ -837,7 +837,7 @@
 
     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 @@
     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 )

=== modified file 'pcbnew/pcbframe.cpp'
--- pcbnew/pcbframe.cpp	2010-05-05 06:45:20 +0000
+++ pcbnew/pcbframe.cpp	2010-07-10 09:09:47 +0000
@@ -306,7 +306,7 @@
     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 )

=== modified file 'pcbnew/pcbnew_config.cpp'
--- pcbnew/pcbnew_config.cpp	2010-04-23 14:46:00 +0000
+++ pcbnew/pcbnew_config.cpp	2010-07-10 07:29:37 +0000
@@ -302,7 +302,7 @@
                                                    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" ),

=== modified file 'pcbnew/pcbplot.cpp'
--- pcbnew/pcbplot.cpp	2010-02-24 15:33:03 +0000
+++ pcbnew/pcbplot.cpp	2010-07-12 06:47:47 +0000
@@ -151,22 +151,22 @@
 
 
     // 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 @@
     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;
 

=== modified file 'pcbnew/set_grid.cpp'
--- pcbnew/set_grid.cpp	2010-02-12 12:52:26 +0000
+++ pcbnew/set_grid.cpp	2010-07-10 09:19:15 +0000
@@ -21,15 +21,15 @@
     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

=== modified file 'pcbnew/tool_modedit.cpp'
--- pcbnew/tool_modedit.cpp	2010-07-01 08:23:21 +0000
+++ pcbnew/tool_modedit.cpp	2010-07-12 08:02:08 +0000
@@ -298,15 +298,25 @@
     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
         {

=== modified file 'pcbnew/tool_pcb.cpp'
--- pcbnew/tool_pcb.cpp	2010-07-01 06:24:12 +0000
+++ pcbnew/tool_pcb.cpp	2010-07-12 08:03:02 +0000
@@ -621,22 +621,39 @@
     // 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" );

=== modified file 'pcbnew/toolbars_update_user_interface.cpp'
--- pcbnew/toolbars_update_user_interface.cpp	2010-04-17 10:45:00 +0000
+++ pcbnew/toolbars_update_user_interface.cpp	2010-07-12 07:09:33 +0000
@@ -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 @@
     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 @@
                                             _( "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 );

=== modified file 'pcbnew/zones_non_copper_type_functions.cpp'
--- pcbnew/zones_non_copper_type_functions.cpp	2009-07-30 11:04:07 +0000
+++ pcbnew/zones_non_copper_type_functions.cpp	2010-07-09 18:08:47 +0000
@@ -81,8 +81,8 @@
 
     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 @@
 {
     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,


Follow ups