When importing legacy PCB dimension: Use automatic dimension when Unit couldn't be determined

This commit is contained in:
Johannes Pfister 2023-02-28 11:59:47 +00:00 committed by Jeff Young
parent bb8a3a7fdc
commit a87550a2c6
3 changed files with 11 additions and 4 deletions

View File

@ -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;
}

View File

@ -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.

View File

@ -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 );
}