kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #04934
Unit parser patch
A little useful feature: even if the default unit can be changed between
inches and mm, the industry is crazy enough to force us with mixed
design. For example I routinely use imperial units for track size and
clearance, but drilling is strictly a metric issue...
So I added a little parser to recognize a suffix specification in the
unit text boxes... so you can put in things like:
1in (1 inch)
1" (idem)
25th (25 thou)
25mi (25 mils, the same)
6mm (6 mm, obviously)
The rules are: spaces between the number and the unit are accepted, only
the first two letters are significant.
As a bonus, it also recognize the period (.) as a decimal point
substituting it with the correct locale character (there was a wishlist
for it, IIRC). Most useful for number pad fans :D
--
Lorenzo Marcantonio
Logos Srl
=== modified file 'common/base_screen.cpp'
--- common/base_screen.cpp 2010-04-08 14:22:01 +0000
+++ common/base_screen.cpp 2010-07-08 11:56:20 +0000
@@ -435,22 +435,17 @@
}
-void BASE_SCREEN::AddGrid( const wxRealPoint& size, int units, int id )
+void BASE_SCREEN::AddGrid( const wxRealPoint& size, bool metric, int id )
{
double x, y;
wxRealPoint new_size;
GRID_TYPE new_grid;
- if( units == MILLIMETRE )
+ if( metric == MILLIMETRE )
{
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
{
x = size.x;
=== modified file 'common/common.cpp'
--- common/common.cpp 2010-06-09 06:17:04 +0000
+++ common/common.cpp 2010-07-09 08:52:04 +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 */
+bool g_UnitMetric; // true if working in mm
/* Draw color for moving objects: */
int g_GhostColor;
@@ -222,12 +222,12 @@
}
-wxString ReturnUnitSymbol( int aUnits, const wxString& formatString )
+wxString ReturnUnitSymbol( bool metric, const wxString& formatString )
{
wxString tmp;
wxString label;
- switch( aUnits )
+ switch( metric )
{
case INCHES:
tmp = _( "\"" );
@@ -236,10 +236,6 @@
case MILLIMETRE:
tmp = _( "mm" );
break;
-
- default:
- tmp = _( "??" );
- break;
}
if( formatString.IsEmpty() )
@@ -251,11 +247,11 @@
}
-wxString GetUnitsLabel( int aUnits )
+wxString GetUnitsLabel( bool metric )
{
wxString label;
- switch( aUnits )
+ switch( metric )
{
case INCHES:
label = _( "inches" );
@@ -264,25 +260,17 @@
case MILLIMETRE:
label = _( "millimeters" );
break;
-
- case CENTIMETRE:
- label = _( "centimeters" );
- break;
-
- default:
- label = _( "Unknown" );
- break;
}
return label;
}
-wxString GetAbbreviatedUnitsLabel( int aUnits )
+wxString GetAbbreviatedUnitsLabel( bool metric )
{
wxString label;
- switch( aUnits )
+ switch( metric )
{
case INCHES:
label = _( "in" );
@@ -291,14 +279,6 @@
case MILLIMETRE:
label = _( "mm" );
break;
-
- case CENTIMETRE:
- label = _( "cm" );
- break;
-
- default:
- label = _( "??" );
- break;
}
return label;
@@ -309,10 +289,10 @@
* 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, bool metric )
{
wxString msg = Stext.GetLabel();
- msg += ReturnUnitSymbol( Units );
+ msg += ReturnUnitSymbol( metric );
Stext.SetLabel( msg );
}
@@ -355,25 +335,20 @@
* @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( bool metric, 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( metric, (double) aValue,
+ aInternal_Unit );
+ StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) :
+ wxT( "%.3f" ),
+ value_to_print );
if( aAdd_unit_symbol )
- switch( aUnits )
+ switch( metric )
{
case INCHES:
StringValue += _( " \"" );
@@ -382,9 +357,6 @@
case MILLIMETRE:
StringValue += _( " mm" );
break;
-
- default:
- break;
}
return StringValue;
@@ -398,17 +370,41 @@
* Value = text
* Internal_Unit = units per inch for computed value
*/
-int ReturnValueFromString( int Units, const wxString& TextValue,
+int ReturnValueFromString( bool metric, 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("\"")) {
+ metric = false;
+ } else if (unit == wxT("mm")) {
+ metric = true;
+ } else if (unit == wxT("mi") || unit == wxT("th")) { /* Mils or thous */
+ metric = false;
+ dtmp /= 1000;
+ }
+ Value = From_User_Unit( metric, dtmp, Internal_Unit );
return Value;
}
=== modified file 'common/drawframe.cpp'
--- common/drawframe.cpp 2010-04-08 14:22:01 +0000
+++ common/drawframe.cpp 2010-07-09 07:08:46 +0000
@@ -73,7 +73,7 @@
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_Metric = INTERNAL_UNIT_TYPE; // Internal unit = inch
m_CursorShape = 0;
m_LastGridSizeId = 0;
m_DrawGrid = true; // hide/Show grid. default = show
=== modified file 'common/wxwineda.cpp'
--- common/wxwineda.cpp 2009-11-23 15:16:50 +0000
+++ common/wxwineda.cpp 2010-07-09 08:03:56 +0000
@@ -89,12 +89,12 @@
const wxString& Title,
const wxString& TextToEdit,
int textsize,
- int units,
+ bool metric,
wxBoxSizer* BoxSizer,
int framelen,
int internal_unit )
{
- m_Units = units;
+ m_Metric = metric;
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_Metric );
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_Metric, 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, bool metric,
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( metric, 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_Metric, textSize );
m_FrameSize->SetValue( value );
}
@@ -180,15 +180,11 @@
int WinEDA_GraphicTextCtrl::ParseSize( const wxString& sizeText,
- int internalUnit, int units )
+ int internalUnit, bool metric )
{
int textsize;
- double dtmp;
-
- sizeText.ToDouble( &dtmp );
-
- textsize = (int) From_User_Unit( units, dtmp, internalUnit );
+ textsize = ReturnValueFromString( metric, 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_Metric );
}
@@ -219,19 +215,19 @@
WinEDA_PositionCtrl::WinEDA_PositionCtrl( wxWindow* parent,
const wxString& title,
const wxPoint& pos_to_edit,
- int units,
+ bool metric,
wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString text;
- m_Units = units;
+ m_Metric = metric;
m_Internal_Unit = internal_unit;
if( title.IsEmpty() )
text = _( "Pos " );
else
text = title;
- text += _( "X" ) + ReturnUnitSymbol( m_Units );
+ text += _( "X" ) + ReturnUnitSymbol( m_Metric );
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_Metric );
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_Metric, m_FramePosX->GetValue(), m_Internal_Unit );
+ coord.y = ReturnValueFromString( m_Metric, 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_Metric, 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_Metric, 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,
+ bool metric, wxBoxSizer* BoxSizer,
int internal_unit ) :
WinEDA_PositionCtrl( parent, title,
wxPoint( size_to_edit.x, size_to_edit.y ),
- units, BoxSizer, internal_unit )
+ metric, 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, bool metric, wxBoxSizer* BoxSizer,
int internal_unit )
{
wxString label = title;
- m_Units = units;
+ m_Metric = metric;
m_Internal_Unit = internal_unit;
m_Value = value;
- label += ReturnUnitSymbol( m_Units );
+ label += ReturnUnitSymbol( m_Metric );
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_Metric, 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_Metric, 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_Metric, 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-08 11:50:02 +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( MILLIMETRE, tmp.m_Size.x, m_InternalUnits );
if( tmp.m_Id == ID_POPUP_GRID_USER )
{
=== 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 07:31:28 +0000
@@ -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_UnitMetric, posXTextCtrl->GetValue(),
+ EESCHEMA_INTERNAL_UNIT );
+ field.m_Pos.y = ReturnValueFromString( g_UnitMetric, posYTextCtrl->GetValue(),
+ EESCHEMA_INTERNAL_UNIT );
return true;
}
=== 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 07:30:46 +0000
@@ -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_UnitMetric, posXTextCtrl->GetValue(),
+ EESCHEMA_INTERNAL_UNIT );
+ field.m_Pos.y = ReturnValueFromString( g_UnitMetric, 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/eeschema_config.cpp'
--- eeschema/eeschema_config.cpp 2010-06-17 16:30:10 +0000
+++ eeschema/eeschema_config.cpp 2010-07-08 13:13:22 +0000
@@ -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_BOOL( wxT( "Unite" ),
+ &g_UnitMetric, true ) );
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ),
&g_LayerDescr.LayerColor[LAYER_WIRE],
GREEN ) );
=== modified file 'gerbview/gerbview_config.h'
--- gerbview/gerbview_config.h 2010-02-03 14:05:17 +0000
+++ gerbview/gerbview_config.h 2010-07-08 13:31:18 +0000
@@ -33,11 +33,11 @@
&g_DrillFilenameExt
);
-static PARAM_CFG_INT UnitCfg // Units; 0 inches, 1 mm
+static PARAM_CFG_BOOL UnitCfg // Units; 0 inches, 1 mm
(
wxT("Unite"),
&g_UnitMetric,
- FALSE
+ TRUE
);
static PARAM_CFG_INT GerberScaleCfg // default scale; 0 2.3, 1 3.4
=== 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-08 12:05:49 +0000
@@ -327,7 +327,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, bool metric, int id );
/**
=== modified file 'include/common.h'
--- include/common.h 2010-05-17 20:35:46 +0000
+++ include/common.h 2010-07-08 12:02:15 +0000
@@ -75,9 +75,8 @@
#define ON 1
#define OFF 0
-#define INCHES 0
-#define MILLIMETRE 1
-#define CENTIMETRE 2
+#define INCHES false
+#define MILLIMETRE true
#if defined(KICAD_GOST)
#define LEFTMARGIN 800 /* 20mm */
@@ -181,7 +180,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 bool g_UnitMetric; // display units is metric
/* Draw color for moving objects: */
extern int g_GhostColor;
@@ -309,7 +308,7 @@
* the format string must contain the %s format specifier.
* @return The formatted units symbol.
*/
-wxString ReturnUnitSymbol( int aUnits = g_UnitMetric,
+wxString ReturnUnitSymbol( bool metric = g_UnitMetric,
const wxString& aFormatString = _( " (%s):" ) );
/**
@@ -321,10 +320,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( bool metric );
+wxString GetAbbreviatedUnitsLabel( bool metric = g_UnitMetric );
-int ReturnValueFromString( int Units, const wxString& TextValue,
+int ReturnValueFromString( bool metric, const wxString& TextValue,
int Internal_Unit );
/** Function ReturnStringFromValue
@@ -337,12 +336,12 @@
* @return a wxString what contains value and optionally the symbol unit (like
* 2.000 mm)
*/
-wxString ReturnStringFromValue( int aUnits,
+wxString ReturnStringFromValue( bool metric,
int aValue,
int aInternal_Unit,
bool aAdd_unit_symbol = false );
-void AddUnitSymbol( wxStaticText& Stext, int Units = g_UnitMetric );
+void AddUnitSymbol( wxStaticText& Stext, bool metric = g_UnitMetric );
/* Add string " (mm):" or " ("):" to the static text Stext.
* Used in dialog boxes for entering values depending on selected units */
=== modified file 'include/wxstruct.h'
--- include/wxstruct.h 2010-04-08 14:22:01 +0000
+++ include/wxstruct.h 2010-07-09 07:03:05 +0000
@@ -22,7 +22,7 @@
#define SAFE_DELETE( p ) delete (p); (p) = NULL;
#endif
-#define INTERNAL_UNIT_TYPE 0 // Internal unit = inch
+#define INTERNAL_UNIT_TYPE false // Internal unit = inch
#ifndef EESCHEMA_INTERNAL_UNIT
#define EESCHEMA_INTERNAL_UNIT 1000
@@ -169,7 +169,7 @@
// = 1000 for eeschema, = 10000
// for PCBnew and Gerbview
- int m_UnitType; // Internal Unit type (0 = inch)
+ bool m_Metric; // 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 +567,8 @@
class WinEDA_GraphicTextCtrl
{
public:
- int m_Units, m_Internal_Unit;
+ bool m_Metric;
+ int m_Internal_Unit;
wxTextCtrl* m_FrameText;
wxTextCtrl* m_FrameSize;
@@ -577,7 +578,7 @@
public:
WinEDA_GraphicTextCtrl( wxWindow* parent, const wxString& Title,
const wxString& TextToEdit, int textsize,
- int units, wxBoxSizer* BoxSizer, int framelen = 200,
+ bool metric, wxBoxSizer* BoxSizer, int framelen = 200,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_GraphicTextCtrl();
@@ -595,10 +596,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, bool metric, int textSize );
static int ParseSize( const wxString& sizeText, int internalUnit,
- int units );
+ bool metric );
};
@@ -609,7 +610,8 @@
class WinEDA_PositionCtrl
{
public:
- int m_Units, m_Internal_Unit;
+ bool m_Metric;
+ int m_Internal_Unit;
wxPoint m_Pos_To_Edit;
wxTextCtrl* m_FramePosX;
@@ -620,7 +622,7 @@
public:
WinEDA_PositionCtrl( wxWindow* parent, const wxString& title,
const wxPoint& pos_to_edit,
- int units, wxBoxSizer* BoxSizer,
+ bool metric, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_PositionCtrl();
@@ -640,7 +642,7 @@
public:
WinEDA_SizeCtrl( wxWindow* parent, const wxString& title,
const wxSize& size_to_edit,
- int units, wxBoxSizer* BoxSizer,
+ bool metric, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_SizeCtrl() { }
@@ -654,7 +656,7 @@
class WinEDA_ValueCtrl
{
public:
- int m_Units;
+ bool m_Metric;
int m_Value;
wxTextCtrl* m_ValueCtrl;
private:
@@ -663,7 +665,7 @@
public:
WinEDA_ValueCtrl( wxWindow* parent, const wxString& title, int value,
- int units, wxBoxSizer* BoxSizer,
+ bool metric, wxBoxSizer* BoxSizer,
int internal_unit = EESCHEMA_INTERNAL_UNIT );
~WinEDA_ValueCtrl();
=== 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_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_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/pcbnew_config.cpp'
--- pcbnew/pcbnew_config.cpp 2010-04-23 14:46:00 +0000
+++ pcbnew/pcbnew_config.cpp 2010-07-09 06:23:17 +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_BOOL( true, wxT( "Unite" ), &g_UnitMetric, TRUE ) );
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-08 11:59:39 +0000
@@ -156,7 +156,7 @@
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( MILLIMETRE, g_pcb_plot_options.HPGL_Pen_Speed, 1 );
m_HPGLPenSpeedOpt->AppendText( msg );
// Set units and value for HPGL pen overlay.
@@ -447,7 +447,7 @@
g_pcb_plot_options.HPGL_Pen_Diam = tmp;
msg = m_HPGLPenSpeedOpt->GetValue();
- tmp = ReturnValueFromString( CENTIMETRE, msg, 1 );
+ tmp = ReturnValueFromString( MILLIMETRE, msg, 1 );
g_pcb_plot_options.HPGL_Pen_Speed = tmp;
msg = m_HPGLPenOverlayOpt->GetValue();
Follow ups