Handle mils in property panel

This commit is contained in:
Roberto Fernandez Bautista 2022-05-11 22:30:25 +01:00 committed by Jon Evans
parent fe7e665236
commit 7208ceb5f1
1 changed files with 11 additions and 2 deletions

View File

@ -31,8 +31,8 @@
#include <widgets/color_swatch.h> #include <widgets/color_swatch.h>
// reg-ex describing a signed valid value with a unit // reg-ex describing a signed valid value with a unit
static const wxChar REGEX_SIGNED_DISTANCE[] = wxT( "([-+]?[0-9]+[\\.?[0-9]*) *(mm|in)*" ); static const wxChar REGEX_SIGNED_DISTANCE[] = wxT( "([-+]?[0-9]+[\\.?[0-9]*) *(mm|in|mils)*" );
static const wxChar REGEX_UNSIGNED_DISTANCE[] = wxT( "([0-9]+[\\.?[0-9]*) *(mm|in)*" ); static const wxChar REGEX_UNSIGNED_DISTANCE[] = wxT( "([0-9]+[\\.?[0-9]*) *(mm|in|mils)*" );
wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty ) wxPGProperty* PGPropertyFactory( const PROPERTY_BASE* aProperty )
{ {
@ -162,6 +162,8 @@ bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString&
unit = EDA_UNITS::MILLIMETRES; unit = EDA_UNITS::MILLIMETRES;
else if( unitText == "in" ) else if( unitText == "in" )
unit = EDA_UNITS::INCHES; unit = EDA_UNITS::INCHES;
else if( unitText == "mils" )
unit = EDA_UNITS::MILS;
else else
unit = PROPERTY_MANAGER::Instance().GetUnits(); unit = PROPERTY_MANAGER::Instance().GetUnits();
@ -175,6 +177,10 @@ bool PGPROPERTY_DISTANCE::StringToDistance( wxVariant& aVariant, const wxString&
newValueIU = Mils2iu( value * 1000.0 ); newValueIU = Mils2iu( value * 1000.0 );
break; break;
case EDA_UNITS::MILS:
newValueIU = Mils2iu( value );
break;
case EDA_UNITS::MILLIMETRES: case EDA_UNITS::MILLIMETRES:
newValueIU = Millimeter2iu( value ); newValueIU = Millimeter2iu( value );
break; break;
@ -208,6 +214,9 @@ wxString PGPROPERTY_DISTANCE::DistanceToString( wxVariant& aVariant, int aArgFla
case EDA_UNITS::INCHES: case EDA_UNITS::INCHES:
return wxString::Format( wxT( "%g in" ), Iu2Mils( aVariant.GetLong() ) / 1000.0 ); return wxString::Format( wxT( "%g in" ), Iu2Mils( aVariant.GetLong() ) / 1000.0 );
case EDA_UNITS::MILS:
return wxString::Format( wxT( "%g mils" ), Iu2Mils( aVariant.GetLong() ) );
case EDA_UNITS::MILLIMETRES: case EDA_UNITS::MILLIMETRES:
return wxString::Format( wxT( "%g mm" ), Iu2Millimeter( aVariant.GetLong() ) ); return wxString::Format( wxT( "%g mm" ), Iu2Millimeter( aVariant.GetLong() ) );