When importing legacy PCB dimension: Use automatic dimension when Unit couldn't be determined
This commit is contained in:
parent
bb8a3a7fdc
commit
a87550a2c6
|
@ -65,7 +65,7 @@ int EDA_UNIT_UTILS::Mils2mm( double aVal )
|
|||
}
|
||||
|
||||
|
||||
void EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits )
|
||||
bool EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits )
|
||||
{
|
||||
wxString buf( aTextValue.Strip( wxString::both ) );
|
||||
unsigned brk_point = 0;
|
||||
|
@ -92,6 +92,9 @@ void EDA_UNIT_UTILS::FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS
|
|||
aUnits = EDA_UNITS::INCHES;
|
||||
else if( unit == wxT( "de" ) || unit == wxT( "ra" ) ) // "deg" or "rad"
|
||||
aUnits = EDA_UNITS::DEGREES;
|
||||
else
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -67,8 +67,9 @@ namespace EDA_UNIT_UTILS
|
|||
|
||||
/**
|
||||
* Writes any unit info found in the string to aUnits.
|
||||
* @return true - when unit was found, false - when unit could not be determined
|
||||
*/
|
||||
void FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits );
|
||||
bool FetchUnitsFromString( const wxString& aTextValue, EDA_UNITS& aUnits );
|
||||
|
||||
/**
|
||||
* Get the units string for a given units type.
|
||||
|
|
|
@ -3226,8 +3226,11 @@ PCB_DIMENSION_BASE* PCB_PARSER::parseDIMENSION( BOARD_ITEM* aParent, bool aInFP
|
|||
|
||||
if( isLegacyDimension )
|
||||
{
|
||||
EDA_UNITS units = EDA_UNITS::INCHES;
|
||||
EDA_UNIT_UTILS::FetchUnitsFromString( text->GetText(), units );
|
||||
EDA_UNITS units = EDA_UNITS::MILLIMETRES;
|
||||
|
||||
if( !EDA_UNIT_UTILS::FetchUnitsFromString( text->GetText(), units ) )
|
||||
dim->SetAutoUnits( true ); //Not determined => use automatic units
|
||||
|
||||
dim->SetUnits( units );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue