Pcbnew, Ruler tool: protect unit display against erroneous translation of \"

A only one char is very hard to translate outside a context, so avoid to use it.

Remove also 2 "FIX ME" lines, now useless.

Fixes: lp:1817354
https://bugs.launchpad.net/kicad/+bug/1817354
This commit is contained in:
jean-pierre charras 2019-02-22 20:47:55 +01:00
parent c4fe6785ad
commit 99153950ec
2 changed files with 6 additions and 35 deletions

View File

@ -33,28 +33,6 @@ double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha( bool aDeemph )
} }
static wxString getDimensionUnit( EDA_UNITS_T aUnits )
{
switch( aUnits )
{
case INCHES:
return _( "\"" );
case MILLIMETRES:
return _( "mm" );
case DEGREES:
return _( "deg" );
case UNSCALED_UNITS:
break;
// no default: handle all cases
}
return wxEmptyString;
}
static wxString formatPreviewDimension( double aVal, EDA_UNITS_T aUnits ) static wxString formatPreviewDimension( double aVal, EDA_UNITS_T aUnits )
{ {
int precision = 4; int precision = 4;
@ -66,12 +44,15 @@ static wxString formatPreviewDimension( double aVal, EDA_UNITS_T aUnits )
case MILLIMETRES: case MILLIMETRES:
precision = 2; // 10um precision = 2; // 10um
break; break;
case INCHES: case INCHES:
precision = 4; // 1mil precision = 4; // 0.1mil
break; break;
case DEGREES: case DEGREES:
precision = 1; // 0.1deg (limit of formats anyway) precision = 1; // 0.1deg
break; break;
case UNSCALED_UNITS: case UNSCALED_UNITS:
break; break;
} }
@ -80,7 +61,7 @@ static wxString formatPreviewDimension( double aVal, EDA_UNITS_T aUnits )
wxString str = wxString::Format( fmtStr, To_User_Unit( aUnits, aVal ) ); wxString str = wxString::Format( fmtStr, To_User_Unit( aUnits, aVal ) );
const wxString symbol = getDimensionUnit( aUnits ); const wxString symbol = GetAbbreviatedUnitsLabel( aUnits, false );
if( symbol.size() ) if( symbol.size() )
str << " " << symbol; str << " " << symbol;

View File

@ -53,12 +53,6 @@ static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor,
double degs = RAD2DECIDEG( -aRulerVec.Angle() ); double degs = RAD2DECIDEG( -aRulerVec.Angle() );
cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, DEGREES ) ); cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), degs, DEGREES ) );
for( auto& str: cursorStrings )
{
// FIXME: remove spaces that choke OpenGL lp:1668455
str.erase( std::remove( str.begin(), str.end(), ' ' ), str.end() );
}
auto temp = aRulerVec; auto temp = aRulerVec;
DrawTextNextToCursor( aView, aCursor, -temp, cursorStrings ); DrawTextNextToCursor( aView, aCursor, -temp, cursorStrings );
} }
@ -174,10 +168,6 @@ void drawTicksAlongLine( KIGFX::VIEW *aView, const VECTOR2D& aOrigin,
if( drawLabel ) if( drawLabel )
{ {
wxString label = DimensionLabel( "", tickSpace * i, aUnits ); wxString label = DimensionLabel( "", tickSpace * i, aUnits );
// FIXME: spaces choke OpenGL lp:1668455
label.erase( std::remove( label.begin(), label.end(), ' ' ), label.end() );
gal->BitmapText( label, tickPos + labelOffset, labelAngle ); gal->BitmapText( label, tickPos + labelOffset, labelAngle );
} }
} }