Units cleanup.
It's 2021. Time to move beyond ASCII. This also makes spacing of units consistent (space before abbreviated units, no space before symbolic units).
This commit is contained in:
parent
56665b9ca7
commit
28b279cb2d
|
@ -247,7 +247,7 @@ wxString PANEL_PREVIEW_3D_MODEL::formatScaleValue( double aValue )
|
||||||
|
|
||||||
wxString PANEL_PREVIEW_3D_MODEL::formatRotationValue( double aValue )
|
wxString PANEL_PREVIEW_3D_MODEL::formatRotationValue( double aValue )
|
||||||
{
|
{
|
||||||
return wxString::Format( "%.2f %s", aValue, GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
return wxString::Format( "%.2f%s", aValue, GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ wxString PANEL_PREVIEW_3D_MODEL::formatOffsetValue( double aValue )
|
||||||
if( m_userUnits == EDA_UNITS::INCHES )
|
if( m_userUnits == EDA_UNITS::INCHES )
|
||||||
aValue /= 25.4f;
|
aValue /= 25.4f;
|
||||||
|
|
||||||
return wxString::Format( "%.4f %s", aValue, GetAbbreviatedUnitsLabel( m_userUnits ) );
|
return wxString::Format( "%.4f%s", aValue, GetAbbreviatedUnitsLabel( m_userUnits ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -179,10 +179,7 @@ wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitLab
|
||||||
text.Printf( format, value );
|
text.Printf( format, value );
|
||||||
|
|
||||||
if( aAddUnitLabel )
|
if( aAddUnitLabel )
|
||||||
{
|
|
||||||
text += " ";
|
|
||||||
text += GetAbbreviatedUnitsLabel( aUnits, aType );
|
text += GetAbbreviatedUnitsLabel( aUnits, aType );
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
@ -219,13 +216,11 @@ wxString StringFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol,
|
||||||
value_to_print = To_User_Unit( aUnits, value_to_print );
|
value_to_print = To_User_Unit( aUnits, value_to_print );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char buf[50];
|
||||||
char buf[50];
|
|
||||||
int len;
|
|
||||||
|
|
||||||
if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 )
|
if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 )
|
||||||
{
|
{
|
||||||
len = sprintf( buf, "%.10f", value_to_print );
|
int len = sprintf( buf, "%.10f", value_to_print );
|
||||||
|
|
||||||
while( --len > 0 && buf[len] == '0' )
|
while( --len > 0 && buf[len] == '0' )
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
@ -238,41 +233,15 @@ wxString StringFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( aUnits == EDA_UNITS::MILS )
|
if( aUnits == EDA_UNITS::MILS )
|
||||||
len = sprintf( buf, "%.7g", value_to_print );
|
sprintf( buf, "%.7g", value_to_print );
|
||||||
else
|
else
|
||||||
len = sprintf( buf, "%.10g", value_to_print );
|
sprintf( buf, "%.10g", value_to_print );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString stringValue( buf, wxConvUTF8 );
|
wxString stringValue( buf, wxConvUTF8 );
|
||||||
|
|
||||||
if( aAddUnitSymbol )
|
if( aAddUnitSymbol )
|
||||||
{
|
stringValue += GetAbbreviatedUnitsLabel( aUnits, aType );
|
||||||
switch( aUnits )
|
|
||||||
{
|
|
||||||
case EDA_UNITS::MILLIMETRES:
|
|
||||||
stringValue += wxT( " mm" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EDA_UNITS::DEGREES:
|
|
||||||
stringValue += wxT( " deg" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EDA_UNITS::MILS:
|
|
||||||
stringValue += wxT( " mils" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EDA_UNITS::INCHES:
|
|
||||||
stringValue += wxT( " in" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EDA_UNITS::PERCENT:
|
|
||||||
stringValue += wxT( "%" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EDA_UNITS::UNSCALED:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return stringValue;
|
return stringValue;
|
||||||
}
|
}
|
||||||
|
@ -420,64 +389,30 @@ long long int ValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString GetAbbreviatedUnitsLabel( EDA_UNITS aUnit, EDA_DATA_TYPE aType )
|
wxString GetAbbreviatedUnitsLabel( EDA_UNITS aUnits, EDA_DATA_TYPE aType )
|
||||||
{
|
{
|
||||||
switch( aUnit )
|
wxString label;
|
||||||
|
|
||||||
|
switch( aUnits )
|
||||||
{
|
{
|
||||||
case EDA_UNITS::MILLIMETRES:
|
case EDA_UNITS::MILLIMETRES: label = wxT( " mm" ); break;
|
||||||
switch( aType )
|
case EDA_UNITS::DEGREES: label = wxT( "°" ); break;
|
||||||
{
|
case EDA_UNITS::MILS: label = wxT( " mils" ); break;
|
||||||
default:
|
case EDA_UNITS::INCHES: label = wxT( " in" ); break;
|
||||||
wxASSERT( 0 );
|
case EDA_UNITS::PERCENT: label = wxT( "%" ); break;
|
||||||
KI_FALLTHROUGH;
|
case EDA_UNITS::UNSCALED: break;
|
||||||
case EDA_DATA_TYPE::DISTANCE:
|
default: UNIMPLEMENTED_FOR( "Unknown units" ); break;
|
||||||
return _( "mm" );
|
|
||||||
case EDA_DATA_TYPE::AREA:
|
|
||||||
return _( "sq. mm" );
|
|
||||||
case EDA_DATA_TYPE::VOLUME:
|
|
||||||
return _( "cu. mm" );
|
|
||||||
}
|
|
||||||
|
|
||||||
case EDA_UNITS::MILS:
|
|
||||||
switch( aType )
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wxASSERT( 0 );
|
|
||||||
KI_FALLTHROUGH;
|
|
||||||
case EDA_DATA_TYPE::DISTANCE:
|
|
||||||
return _( "mils" );
|
|
||||||
case EDA_DATA_TYPE::AREA:
|
|
||||||
return _( "sq. mils" );
|
|
||||||
case EDA_DATA_TYPE::VOLUME:
|
|
||||||
return _( "cu. mils" );
|
|
||||||
}
|
|
||||||
|
|
||||||
case EDA_UNITS::INCHES:
|
|
||||||
switch( aType )
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wxASSERT( 0 );
|
|
||||||
KI_FALLTHROUGH;
|
|
||||||
case EDA_DATA_TYPE::DISTANCE:
|
|
||||||
return _( "in" );
|
|
||||||
case EDA_DATA_TYPE::AREA:
|
|
||||||
return _( "sq. in" );
|
|
||||||
case EDA_DATA_TYPE::VOLUME:
|
|
||||||
return _( "cu. in" );
|
|
||||||
}
|
|
||||||
|
|
||||||
case EDA_UNITS::PERCENT:
|
|
||||||
return _( "%" );
|
|
||||||
|
|
||||||
case EDA_UNITS::UNSCALED:
|
|
||||||
return wxEmptyString;
|
|
||||||
|
|
||||||
case EDA_UNITS::DEGREES:
|
|
||||||
return _( "deg" );
|
|
||||||
|
|
||||||
default:
|
|
||||||
return wxT( "??" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch( aType )
|
||||||
|
{
|
||||||
|
case EDA_DATA_TYPE::VOLUME: label += wxT( "³" ); break;
|
||||||
|
case EDA_DATA_TYPE::AREA: label += wxT( "²" ); break;
|
||||||
|
case EDA_DATA_TYPE::DISTANCE: break;
|
||||||
|
default: UNIMPLEMENTED_FOR( "Unknown measurement" ); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal, ED
|
||||||
str << wxString::Format( fmtStr, To_User_Unit( aUnits, aVal ) );
|
str << wxString::Format( fmtStr, To_User_Unit( aUnits, aVal ) );
|
||||||
|
|
||||||
if( aIncludeUnits )
|
if( aIncludeUnits )
|
||||||
str << " " << GetAbbreviatedUnitsLabel( aUnits );
|
str << GetAbbreviatedUnitsLabel( aUnits );
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindo
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_unitLabel )
|
if( m_unitLabel )
|
||||||
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
|
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
|
||||||
|
|
||||||
m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
|
m_valueCtrl->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( UNIT_BINDER::onSetFocus ),
|
||||||
nullptr, this );
|
nullptr, this );
|
||||||
|
@ -94,7 +94,7 @@ void UNIT_BINDER::SetUnits( EDA_UNITS aUnits )
|
||||||
m_units = aUnits;
|
m_units = aUnits;
|
||||||
|
|
||||||
if( m_unitLabel )
|
if( m_unitLabel )
|
||||||
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
|
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ void UNIT_BINDER::SetDataType( EDA_DATA_TYPE aDataType )
|
||||||
m_dataType = aDataType;
|
m_dataType = aDataType;
|
||||||
|
|
||||||
if( m_unitLabel )
|
if( m_unitLabel )
|
||||||
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
|
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ void UNIT_BINDER::SetValue( const wxString& aValue )
|
||||||
m_eval.Clear();
|
m_eval.Clear();
|
||||||
|
|
||||||
if( m_unitLabel )
|
if( m_unitLabel )
|
||||||
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
|
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ void UNIT_BINDER::ChangeValue( const wxString& aValue )
|
||||||
m_eval.Clear();
|
m_eval.Clear();
|
||||||
|
|
||||||
if( m_unitLabel )
|
if( m_unitLabel )
|
||||||
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ) );
|
m_unitLabel->SetLabel( GetAbbreviatedUnitsLabel( m_units, m_dataType ).Trim( false ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -720,12 +720,10 @@ void DIALOG_PLOT::applyPlotSettings()
|
||||||
m_widthAdjustMaxValue ) )
|
m_widthAdjustMaxValue ) )
|
||||||
{
|
{
|
||||||
m_trackWidthCorrection.SetValue( m_PSWidthAdjust );
|
m_trackWidthCorrection.SetValue( m_PSWidthAdjust );
|
||||||
msg.Printf( _( "Width correction constrained. "
|
msg.Printf( _( "Width correction constrained. The width correction value must be in the"
|
||||||
"The reasonable width correction value must be in a range of "
|
" range of [%s; %s] for the current design rules." ),
|
||||||
" [%s; %s] (%s) for current design rules." ),
|
StringFromValue( GetUserUnits(), m_widthAdjustMinValue, true ),
|
||||||
StringFromValue( GetUserUnits(), m_widthAdjustMinValue, false ),
|
StringFromValue( GetUserUnits(), m_widthAdjustMaxValue, true ) );
|
||||||
StringFromValue( GetUserUnits(), m_widthAdjustMaxValue, false ),
|
|
||||||
GetAbbreviatedUnitsLabel( GetUserUnits() ) );
|
|
||||||
reporter.Report( msg, RPT_SEVERITY_WARNING );
|
reporter.Report( msg, RPT_SEVERITY_WARNING );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 CERN
|
* Copyright (C) 2015 CERN
|
||||||
* Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
|
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
|
@ -298,7 +298,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
|
||||||
m_netSelector->Disable();
|
m_netSelector->Disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
|
m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ).Trim( false ) );
|
||||||
|
|
||||||
int viaSelection = wxNOT_FOUND;
|
int viaSelection = wxNOT_FOUND;
|
||||||
|
|
||||||
|
@ -341,7 +341,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
|
||||||
|
|
||||||
if( m_tracks )
|
if( m_tracks )
|
||||||
{
|
{
|
||||||
m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
|
m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ).Trim( false ) );
|
||||||
|
|
||||||
int widthSelection = wxNOT_FOUND;
|
int widthSelection = wxNOT_FOUND;
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,10 @@ FP_TEXT_GRID_TABLE::FP_TEXT_GRID_TABLE( PCB_BASE_FRAME* aFrame ) :
|
||||||
|
|
||||||
if( g_menuOrientations.IsEmpty() )
|
if( g_menuOrientations.IsEmpty() )
|
||||||
{
|
{
|
||||||
g_menuOrientations.push_back(
|
g_menuOrientations.push_back( "0" + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
||||||
wxT( "0 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
g_menuOrientations.push_back( "90" + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
||||||
g_menuOrientations.push_back(
|
g_menuOrientations.push_back( "-90" + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
||||||
wxT( "90 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
g_menuOrientations.push_back( "180" + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
||||||
g_menuOrientations.push_back(
|
|
||||||
wxT( "-90 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
|
||||||
g_menuOrientations.push_back(
|
|
||||||
wxT( "180 " ) + GetAbbreviatedUnitsLabel( EDA_UNITS::DEGREES ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_orientationColAttr = new wxGridCellAttr;
|
m_orientationColAttr = new wxGridCellAttr;
|
||||||
|
|
|
@ -319,7 +319,7 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
|
||||||
EDA_UNITS units;
|
EDA_UNITS units;
|
||||||
|
|
||||||
GetUnits( units );
|
GetUnits( units );
|
||||||
aList.emplace_back( _( "Units" ), GetAbbreviatedUnitsLabel( units ) );
|
aList.emplace_back( _( "Units" ), GetAbbreviatedUnitsLabel( units ).Trim( false ) );
|
||||||
|
|
||||||
ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
|
ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();
|
||||||
units = aFrame->GetUserUnits();
|
units = aFrame->GetUserUnits();
|
||||||
|
|
|
@ -622,10 +622,7 @@ static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLab
|
||||||
text.Printf( format, To_User_Unit( aUnits, aValue ) );
|
text.Printf( format, To_User_Unit( aUnits, aValue ) );
|
||||||
|
|
||||||
if( aIncludeLabel )
|
if( aIncludeLabel )
|
||||||
{
|
|
||||||
text += " ";
|
|
||||||
text += GetAbbreviatedUnitsLabel( aUnits, EDA_DATA_TYPE::DISTANCE );
|
text += GetAbbreviatedUnitsLabel( aUnits, EDA_DATA_TYPE::DISTANCE );
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue