diff --git a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp index 632d2d6690..51257fb9f2 100644 --- a/3d-viewer/dialogs/panel_3D_raytracing_options.cpp +++ b/3d-viewer/dialogs/panel_3D_raytracing_options.cpp @@ -49,12 +49,12 @@ void PANEL_3D_RAYTRACING_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) m_numSamples_Reflections->SetValue( aCfg->m_Render.raytrace_nrsamples_reflections ); m_numSamples_Refractions->SetValue( aCfg->m_Render.raytrace_nrsamples_refractions ); - m_spreadFactor_Shadows->SetValue( StringFromValue( EDA_UNITS::PERCENT, - aCfg->m_Render.raytrace_spread_shadows * 100.0f ) ); - m_spreadFactor_Reflections->SetValue( StringFromValue( EDA_UNITS::PERCENT, - aCfg->m_Render.raytrace_spread_reflections * 100.0f ) ); - m_spreadFactor_Refractions->SetValue( StringFromValue( EDA_UNITS::PERCENT, - aCfg->m_Render.raytrace_spread_refractions * 100.0f ) ); + m_spreadFactor_Shadows->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_shadows * 100.0f ) ); + m_spreadFactor_Reflections->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_reflections * 100.0f ) ); + m_spreadFactor_Refractions->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, EDA_UNITS::PERCENT, aCfg->m_Render.raytrace_spread_refractions * 100.0f ) ); m_recursiveLevel_Reflections->SetValue( aCfg->m_Render.raytrace_recursivelevel_reflections ); m_recursiveLevel_Refractions->SetValue( aCfg->m_Render.raytrace_recursivelevel_refractions ); @@ -70,7 +70,8 @@ void PANEL_3D_RAYTRACING_OPTIONS::loadSettings( EDA_3D_VIEWER_SETTINGS* aCfg ) auto transfer_value = []( wxTextCtrl* aCtrl, int aValue ) { - aCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, aValue ) ); + aCtrl->SetValue( + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, aValue ) ); }; transfer_color( aCfg->m_Render.raytrace_lightColorCamera, m_colourPickerCameraLight ); @@ -136,11 +137,17 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow() cfg->m_Render.raytrace_nrsamples_refractions = m_numSamples_Refractions->GetValue(); cfg->m_Render.raytrace_spread_shadows = - DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Shadows->GetValue() ) / 100.0f; + EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT, + m_spreadFactor_Shadows->GetValue() ) + / 100.0f; cfg->m_Render.raytrace_spread_reflections = - DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Reflections->GetValue() ) / 100.0f; + EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT, + m_spreadFactor_Reflections->GetValue() ) + / 100.0f; cfg->m_Render.raytrace_spread_refractions = - DoubleValueFromString( EDA_UNITS::PERCENT, m_spreadFactor_Refractions->GetValue() ) / 100.0f; + EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::PERCENT, + m_spreadFactor_Refractions->GetValue() ) + / 100.0f; cfg->m_Render.raytrace_recursivelevel_reflections = m_recursiveLevel_Reflections->GetValue(); cfg->m_Render.raytrace_recursivelevel_refractions = m_recursiveLevel_Refractions->GetValue(); @@ -161,7 +168,8 @@ bool PANEL_3D_RAYTRACING_OPTIONS::TransferDataFromWindow() auto get_value = []( wxTextCtrl* aCtrl ) { - return DoubleValueFromString( EDA_UNITS::UNSCALED, aCtrl->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED, + aCtrl->GetValue() ); }; cfg->m_Render.raytrace_lightElevation[0] = get_value( m_lightElevation1 ); diff --git a/3d-viewer/dialogs/panel_preview_3d_model.cpp b/3d-viewer/dialogs/panel_preview_3d_model.cpp index 1ff6144347..535cdffef1 100644 --- a/3d-viewer/dialogs/panel_preview_3d_model.cpp +++ b/3d-viewer/dialogs/panel_preview_3d_model.cpp @@ -222,7 +222,8 @@ void PANEL_PREVIEW_3D_MODEL::loadSettings() */ static double rotationFromString( const wxString& aValue ) { - double rotation = DoubleValueFromString( EDA_UNITS::DEGREES, aValue ); + double rotation = + EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES, aValue ); if( rotation > MAX_ROTATION ) { @@ -319,17 +320,26 @@ void PANEL_PREVIEW_3D_MODEL::updateOrientation( wxCommandEvent &event ) // Write settings back to the parent FP_3DMODEL* modelInfo = &m_parentModelList->at( (unsigned) m_selected ); - modelInfo->m_Scale.x = DoubleValueFromString( EDA_UNITS::UNSCALED, xscale->GetValue() ); - modelInfo->m_Scale.y = DoubleValueFromString( EDA_UNITS::UNSCALED, yscale->GetValue() ); - modelInfo->m_Scale.z = DoubleValueFromString( EDA_UNITS::UNSCALED, zscale->GetValue() ); + modelInfo->m_Scale.x = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::UNSCALED, xscale->GetValue() ); + modelInfo->m_Scale.y = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::UNSCALED, yscale->GetValue() ); + modelInfo->m_Scale.z = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::UNSCALED, zscale->GetValue() ); modelInfo->m_Rotation.x = rotationFromString( xrot->GetValue() ); modelInfo->m_Rotation.y = rotationFromString( yrot->GetValue() ); modelInfo->m_Rotation.z = rotationFromString( zrot->GetValue() ); - modelInfo->m_Offset.x = DoubleValueFromString( m_userUnits, xoff->GetValue() ) / IU_PER_MM; - modelInfo->m_Offset.y = DoubleValueFromString( m_userUnits, yoff->GetValue() ) / IU_PER_MM; - modelInfo->m_Offset.z = DoubleValueFromString( m_userUnits, zoff->GetValue() ) / IU_PER_MM; + modelInfo->m_Offset.x = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, + xoff->GetValue() ) + / pcbIUScale.IU_PER_MM; + modelInfo->m_Offset.y = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, + yoff->GetValue() ) + / pcbIUScale.IU_PER_MM; + modelInfo->m_Offset.z = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, + zoff->GetValue() ) + / pcbIUScale.IU_PER_MM; // Update the dummy footprint for the preview UpdateDummyFootprint( false ); @@ -363,7 +373,7 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementScale( wxSpinEvent& event, double aSign else if( spinCtrl == m_spinZscale ) textCtrl = zscale; - double curr_value = DoubleValueFromString( EDA_UNITS::UNSCALED, textCtrl->GetValue() ); + double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED, textCtrl->GetValue() ); curr_value += ( SCALE_INCREMENT * aSign ); curr_value = std::max( 1/MAX_SCALE, curr_value ); @@ -383,7 +393,8 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementRotation( wxSpinEvent& aEvent, double aS else if( spinCtrl == m_spinZrot ) textCtrl = zrot; - double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ); + double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES, + textCtrl->GetValue() ); curr_value += ( ROTATION_INCREMENT * aSign ); curr_value = std::max( -MAX_ROTATION, curr_value ); @@ -405,7 +416,9 @@ void PANEL_PREVIEW_3D_MODEL::doIncrementOffset( wxSpinEvent& event, double aSign textCtrl = zoff; double step_mm = OFFSET_INCREMENT_MM; - double curr_value_mm = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM; + double curr_value_mm = + EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, textCtrl->GetValue() ) + / pcbIUScale.IU_PER_MM; if( m_userUnits == EDA_UNITS::MILS || m_userUnits == EDA_UNITS::INCHES ) { @@ -432,7 +445,8 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelScale( wxMouseEvent& event ) if( event.GetWheelRotation() >= 0 ) step = -step; - double curr_value = DoubleValueFromString( EDA_UNITS::UNSCALED, textCtrl->GetValue() ); + double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED, + textCtrl->GetValue() ); curr_value += step; curr_value = std::max( 1/MAX_SCALE, curr_value ); @@ -454,7 +468,8 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelRot( wxMouseEvent& event ) if( event.GetWheelRotation() >= 0 ) step = -step; - double curr_value = DoubleValueFromString( EDA_UNITS::DEGREES, textCtrl->GetValue() ); + double curr_value = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::DEGREES, + textCtrl->GetValue() ); curr_value += step; curr_value = std::max( -MAX_ROTATION, curr_value ); @@ -484,7 +499,9 @@ void PANEL_PREVIEW_3D_MODEL::onMouseWheelOffset( wxMouseEvent& event ) if( event.GetWheelRotation() >= 0 ) step_mm = -step_mm; - double curr_value_mm = DoubleValueFromString( m_userUnits, textCtrl->GetValue() ) / IU_PER_MM; + double curr_value_mm = EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, m_userUnits, + textCtrl->GetValue() ) + / pcbIUScale.IU_PER_MM; curr_value_mm += step_mm; curr_value_mm = std::max( -MAX_OFFSET, curr_value_mm ); diff --git a/common/base_units.cpp b/common/base_units.cpp deleted file mode 100644 index 7ef28337bf..0000000000 --- a/common/base_units.cpp +++ /dev/null @@ -1,400 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 CERN - * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. - * - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -/** - * @author Wayne Stambaugh - * @file base_units.cpp - * @brief Code to handle objects that require both schematic and board internal units. - * @note This file is an ugly hack to solve the problem of formatting the base units - * for either schematics or boards in objects that are include in both domains. - * At some point in the future. This code should be rolled back into the - * appropriate object and build with the correct internal unit formatting - * depending on the application. - */ - -#include -#include -#include // for KiROUND -#include - - -#if defined( PCBNEW ) || defined( CVPCB ) || defined( EESCHEMA ) || defined( GERBVIEW ) || defined( PL_EDITOR ) -#define IU_TO_MM( x ) ( x / IU_PER_MM ) -#define IU_TO_IN( x ) ( x / IU_PER_MILS / 1000 ) -#define IU_TO_MILS( x ) ( x / IU_PER_MILS ) -#define MM_TO_IU( x ) ( x * IU_PER_MM ) -#define IN_TO_IU( x ) ( x * IU_PER_MILS * 1000 ) -#define MILS_TO_IU( x ) ( x * IU_PER_MILS ) -#else -#error "Cannot resolve internal units due to no definition of EESCHEMA, CVPCB or PCBNEW." -#endif - - -double To_User_Unit( EDA_UNITS aUnit, double aValue ) -{ - switch( aUnit ) - { - case EDA_UNITS::MILLIMETRES: - return IU_TO_MM( aValue ); - - case EDA_UNITS::MILS: - return IU_TO_MILS( aValue ); - - case EDA_UNITS::INCHES: - return IU_TO_IN( aValue ); - - case EDA_UNITS::DEGREES: - return aValue; - - default: - return aValue; - } -} - - -/** - * Convert a value to a string using double notation. - * - * For readability, the mantissa has 0, 1, 3 or 4 digits, depending on units - * for unit = inch the mantissa has 3 digits (Eeschema) or 4 digits - * for unit = mil the mantissa has 0 digits (Eeschema) or 1 digits - * for unit = mm the mantissa has 3 digits (Eeschema) or 4 digits - * Should be used only to display info in status, - * but not in dialogs, because 4 digits only - * could truncate the actual value - */ - - -// A lower-precision (for readability) version of StringFromValue() -wxString MessageTextFromValue( EDA_UNITS aUnits, int aValue, bool aAddUnitLabel, - EDA_DATA_TYPE aType ) -{ - return MessageTextFromValue( aUnits, double( aValue ), aAddUnitLabel, aType ); -} - - -// A lower-precision (for readability) version of StringFromValue() -wxString MessageTextFromValue( EDA_UNITS aUnits, long long int aValue, bool aAddUnitLabel, - EDA_DATA_TYPE aType ) -{ - return MessageTextFromValue( aUnits, double( aValue ), aAddUnitLabel, aType ); -} - - -wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel ) -{ - if( aAddUnitLabel ) - return wxString::Format( wxT( "%.1f°" ), aValue.AsDegrees() ); - else - return wxString::Format( wxT( "%.1f" ), aValue.AsDegrees() ); -} - - -// A lower-precision (for readability) version of StringFromValue() -wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitLabel, - EDA_DATA_TYPE aType ) -{ - wxString text; - const wxChar* format; - double value = aValue; - - switch( aType ) - { - case EDA_DATA_TYPE::VOLUME: - value = To_User_Unit( aUnits, value ); - // Fall through to continue computation - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::AREA: - value = To_User_Unit( aUnits, value ); - // Fall through to continue computation - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::DISTANCE: - value = To_User_Unit( aUnits, value ); - } - - switch( aUnits ) - { - default: - case EDA_UNITS::MILLIMETRES: -#if defined( EESCHEMA ) - format = wxT( "%.2f" ); -#else - format = wxT( "%.4f" ); -#endif - break; - - case EDA_UNITS::MILS: -#if defined( EESCHEMA ) - format = wxT( "%.0f" ); -#else - format = wxT( "%.2f" ); -#endif - break; - - case EDA_UNITS::INCHES: -#if defined( EESCHEMA ) - format = wxT( "%.3f" ); -#else - format = wxT( "%.4f" ); -#endif - break; - - case EDA_UNITS::DEGREES: - // 3 digits in mantissa should be good for rotation in degree - format = wxT( "%.3f" ); - break; - - case EDA_UNITS::UNSCALED: - format = wxT( "%.0f" ); - break; - } - - text.Printf( format, value ); - - if( aAddUnitLabel ) - text += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType ); - - return text; -} - - -/** - * Convert a value to a string using double notation. - * - * For readability, the mantissa has 3 or more digits, - * the trailing 0 are removed if the mantissa has more than 3 digits - * and some trailing 0 - * This function should be used to display values in dialogs because a value - * entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa - * if displayed in inch to avoid truncation or rounding made just by the printf function. - * otherwise the actual value is rounded when read from dialog and converted - * in internal units, and therefore modified. - */ -wxString StringFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitSymbol, - EDA_DATA_TYPE aType ) -{ - double value_to_print = aValue; - - switch( aType ) - { - case EDA_DATA_TYPE::VOLUME: - value_to_print = To_User_Unit( aUnits, value_to_print ); - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::AREA: - value_to_print = To_User_Unit( aUnits, value_to_print ); - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::DISTANCE: - value_to_print = To_User_Unit( aUnits, value_to_print ); - } - - char buf[50]; - - if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 ) - { - int len = snprintf( buf, sizeof( buf ) - 1, "%.10f", value_to_print ); - - while( --len > 0 && buf[len] == '0' ) - buf[len] = '\0'; - - if( len >= 0 && ( buf[len]=='.' || buf[len]==',' ) ) - buf[len] = '\0'; - } - else - { - snprintf( buf, sizeof( buf ) - 1, "%.10g", value_to_print ); - } - - wxString stringValue( buf, wxConvUTF8 ); - - if( aAddUnitSymbol ) - stringValue += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType ); - - return stringValue; -} - - -double From_User_Unit( EDA_UNITS aUnits, double aValue ) -{ - switch( aUnits ) - { - case EDA_UNITS::MILLIMETRES: - return MM_TO_IU( aValue ); - - case EDA_UNITS::MILS: - return MILS_TO_IU( aValue ); - - case EDA_UNITS::INCHES: - return IN_TO_IU( aValue ); - - default: - case EDA_UNITS::DEGREES: - case EDA_UNITS::UNSCALED: - case EDA_UNITS::PERCENT: - return aValue; - } -} - - -double DoubleValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA_DATA_TYPE aType ) -{ - double dtmp = 0; - - // Acquire the 'right' decimal point separator - const struct lconv* lc = localeconv(); - - wxChar decimal_point = lc->decimal_point[0]; - wxString buf( aTextValue.Strip( wxString::both ) ); - - // Convert any entered decimal point separators to the 'right' one - buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); - buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); - - // Find the end of the numeric part - unsigned brk_point = 0; - - while( brk_point < buf.Len() ) - { - wxChar ch = buf[brk_point]; - - if( !( (ch >= '0' && ch <= '9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) ) - break; - - ++brk_point; - } - - // Extract the numeric part - buf.Left( brk_point ).ToDouble( &dtmp ); - - // Check the optional unit designator (2 ch significant) - wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() ); - - if( aUnits == EDA_UNITS::MILLIMETRES || aUnits == EDA_UNITS::MILS - || aUnits == EDA_UNITS::INCHES ) - { - if( unit == wxT( "mm" ) ) - { - aUnits = EDA_UNITS::MILLIMETRES; - } - else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) - { - aUnits = EDA_UNITS::MILS; - } - else if( unit == wxT( "in" ) || unit == wxT( "\"" ) ) - { - aUnits = EDA_UNITS::INCHES; - } - else if( unit == "oz" ) // 1 oz = 1.37 mils - { - aUnits = EDA_UNITS::MILS; - dtmp *= 1.37; - } - } - else if( aUnits == EDA_UNITS::DEGREES ) - { - if( unit == wxT( "ra" ) ) // Radians - dtmp *= 180.0f / M_PI; - } - - switch( aType ) - { - case EDA_DATA_TYPE::VOLUME: - dtmp = From_User_Unit( aUnits, dtmp ); - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::AREA: - dtmp = From_User_Unit( aUnits, dtmp ); - KI_FALLTHROUGH; - - case EDA_DATA_TYPE::DISTANCE: - dtmp = From_User_Unit( aUnits, dtmp ); - } - - return dtmp; -} - - -long long int ValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, EDA_DATA_TYPE aType ) -{ - double value = DoubleValueFromString( aUnits, aTextValue, aType ); - - return KiROUND( value ); -} - - -std::string FormatInternalUnits( int aValue ) -{ - char buf[50]; - double engUnits = aValue; - int len; - - engUnits /= IU_PER_MM; - - if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 ) - { - len = snprintf( buf, sizeof(buf), "%.10f", engUnits ); - - // Make sure snprintf() didn't fail and the locale numeric separator is correct. - wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr, std::string( "" ) ); - - while( --len > 0 && buf[len] == '0' ) - buf[len] = '\0'; - - if( buf[len] == '.' ) - buf[len] = '\0'; - else - ++len; - } - else - { - len = snprintf( buf, sizeof(buf), "%.10g", engUnits ); - - // Make sure snprintf() didn't fail and the locale numeric separator is correct. - wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr , std::string( "" ) ); - } - - return std::string( buf, len ); -} - - -std::string FormatInternalUnits( const wxPoint& aPoint ) -{ - return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y ); -} - - -std::string FormatInternalUnits( const VECTOR2I& aPoint ) -{ - return FormatInternalUnits( aPoint.x ) + " " + FormatInternalUnits( aPoint.y ); -} - - -std::string FormatInternalUnits( const wxSize& aSize ) -{ - return FormatInternalUnits( aSize.GetWidth() ) + " " + FormatInternalUnits( aSize.GetHeight() ); -} diff --git a/common/dialogs/dialog_grid_settings.cpp b/common/dialogs/dialog_grid_settings.cpp index 3ebccf2083..4e00f4d2ed 100644 --- a/common/dialogs/dialog_grid_settings.cpp +++ b/common/dialogs/dialog_grid_settings.cpp @@ -118,8 +118,10 @@ bool DIALOG_GRID_SETTINGS::TransferDataFromWindow() gridCfg.last_size_idx = m_currentGridCtrl->GetSelection(); m_parent->SetGridOrigin( wxPoint( m_gridOriginX.GetValue(), m_gridOriginY.GetValue() ) ); - gridCfg.user_grid_x = StringFromValue( GetUserUnits(), m_userGridX.GetValue(), true ); - gridCfg.user_grid_y = StringFromValue( GetUserUnits(), m_userGridY.GetValue(), true ); + gridCfg.user_grid_x = EDA_UNIT_UTILS::UI::StringFromValue( m_parent->GetIuScale(), GetUserUnits(), + m_userGridX.GetValue(), true ); + gridCfg.user_grid_y = EDA_UNIT_UTILS::UI::StringFromValue( m_parent->GetIuScale(), GetUserUnits(), + m_userGridY.GetValue(), true ); gridCfg.fast_grid_1 = m_grid1Ctrl->GetSelection(); gridCfg.fast_grid_2 = m_grid2Ctrl->GetSelection(); @@ -148,8 +150,10 @@ bool DIALOG_GRID_SETTINGS::TransferDataToWindow() m_currentGridCtrl->SetSelection( settings->m_Window.grid.last_size_idx ); - m_userGridX.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_x ) ); - m_userGridY.SetValue( ValueFromString( GetUserUnits(), gridCfg.user_grid_y ) ); + m_userGridX.SetValue( EDA_UNIT_UTILS::UI::ValueFromString( m_parent->GetIuScale(), + GetUserUnits(), gridCfg.user_grid_x ) ); + m_userGridY.SetValue( EDA_UNIT_UTILS::UI::ValueFromString( m_parent->GetIuScale(), + GetUserUnits(), gridCfg.user_grid_y ) ); m_gridOriginX.SetValue( m_parent->GetGridOrigin().x ); m_gridOriginY.SetValue( m_parent->GetGridOrigin().y ); diff --git a/common/dialogs/panel_setup_netclasses.cpp b/common/dialogs/panel_setup_netclasses.cpp index af198c246f..96632d7d53 100644 --- a/common/dialogs/panel_setup_netclasses.cpp +++ b/common/dialogs/panel_setup_netclasses.cpp @@ -235,10 +235,11 @@ bool PANEL_SETUP_NETCLASSES::TransferDataToWindow() int row = 0; auto setCell = - [&]( int aRow, int aCol, int aValue ) - { - m_netclassGrid->SetCellValue( aRow, aCol, StringFromValue( units, aValue, true ) ); - }; + [&]( int aRow, int aCol, int aValue ) + { + m_netclassGrid->SetCellValue( aRow, aCol, + EDA_UNIT_UTILS::UI::StringFromValue( m_frame->GetIuScale(), units, aValue, true ) ); + }; auto netclassToGridRow = [&]( int aRow, const std::shared_ptr& nc ) @@ -341,7 +342,7 @@ bool PANEL_SETUP_NETCLASSES::TransferDataFromWindow() auto getCell = [this, units]( int aRow, int aCol ) -> long long int { - return ValueFromString( units, m_netclassGrid->GetCellValue( aRow, aCol ) ); + return EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(),units, m_netclassGrid->GetCellValue( aRow, aCol ) ); }; auto getCellStr = diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index d0695ef5f9..38d1dea24c 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -139,15 +139,19 @@ void DS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, aList.emplace_back( _( "First Page Option" ), msg ); - msg = MessageTextFromValue( EDA_UNITS::UNSCALED, dataItem->m_RepeatCount ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), EDA_UNITS::UNSCALED, + dataItem->m_RepeatCount ); aList.emplace_back( _( "Repeat Count" ), msg ); - msg = MessageTextFromValue( EDA_UNITS::UNSCALED, dataItem->m_IncrementLabel ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), EDA_UNITS::UNSCALED, + dataItem->m_IncrementLabel ); aList.emplace_back( _( "Repeat Label Increment" ), msg ); msg.Printf( wxT( "(%s, %s)" ), - MessageTextFromValue( aFrame->GetUserUnits(), dataItem->m_IncrementVector.x ), - MessageTextFromValue( aFrame->GetUserUnits(), dataItem->m_IncrementVector.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), aFrame->GetUserUnits(), + dataItem->m_IncrementVector.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), aFrame->GetUserUnits(), + dataItem->m_IncrementVector.y ) ); aList.emplace_back( _( "Repeat Position Increment" ), msg ); @@ -380,8 +384,10 @@ bool DS_DRAW_ITEM_RECT::HitTest( const BOX2I& aRect, bool aContained, int aAccur wxString DS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Rectangle, width %s height %s" ), - MessageTextFromValue( aUnits, std::abs( GetStart().x - GetEnd().x ) ), - MessageTextFromValue( aUnits, std::abs( GetStart().y - GetEnd().y ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( drawSheetIUScale, aUnits, + std::abs( GetStart().x - GetEnd().x ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( drawSheetIUScale, aUnits, + std::abs( GetStart().y - GetEnd().y ) ) ); } @@ -413,7 +419,7 @@ bool DS_DRAW_ITEM_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) cons wxString DS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const { return wxString::Format( _( "Line, length %s" ), - MessageTextFromValue( aUnits, EuclideanNorm( GetStart() - GetEnd() ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( drawSheetIUScale, aUnits, EuclideanNorm( GetStart() - GetEnd() ) ) ); } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index 8f7820abcf..ddab07aae1 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -81,8 +81,9 @@ END_EVENT_TABLE() EDA_DRAW_FRAME::EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString & aFrameName ) : - KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ) + long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ) : + KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ), + m_iuScale( aIuScale ) { m_socketServer = nullptr; m_mainToolBar = nullptr; @@ -577,9 +578,10 @@ void EDA_DRAW_FRAME::DisplayGridMsg() { wxString line; - line.Printf( "grid %s", - MessageTextFromValue( GetUserUnits(), GetCanvas()->GetGAL()->GetGridSize().x, - false ) ); + line.Printf( "grid %s", EDA_UNIT_UTILS::UI::MessageTextFromValue( + GetIuScale(), GetUserUnits(), + GetCanvas()->GetGAL()->GetGridSize().x, + false ) ); SetStatusText( line, 4 ); } diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 08730f095c..9ae61d8a0f 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -574,24 +574,24 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetIuScale(), units, GetRadius() ); aList.emplace_back( _( "Radius" ), msg ); break; case SHAPE_T::ARC: aList.emplace_back( shape, _( "Arc" ) ); - msg = MessageTextFromValue( GetArcAngle() ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( GetArcAngle() ); aList.emplace_back( _( "Angle" ), msg ); - msg = MessageTextFromValue( units, GetRadius() ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, GetRadius() ); aList.emplace_back( _( "Radius" ), msg ); break; case SHAPE_T::BEZIER: aList.emplace_back( shape, _( "Curve" ) ); - msg = MessageTextFromValue( units, GetLength() ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, GetLength() ); aList.emplace_back( _( "Length" ), msg ); break; @@ -608,10 +608,12 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetIuScale(), units, + std::abs( GetEnd().x - GetStart().x ) ); aList.emplace_back( _( "Width" ), msg ); - msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( aFrame->GetIuScale(), units, + std::abs( GetEnd().y - GetStart().y ) ); aList.emplace_back( _( "Height" ), msg ); break; @@ -619,13 +621,14 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetIuScale(), units, + GetLineLength( GetStart(), GetEnd() ) ); aList.emplace_back( _( "Length" ), msg ); // angle counter-clockwise from 3'o-clock EDA_ANGLE angle( atan2( (double)( GetStart().y - GetEnd().y ), (double)( GetEnd().x - GetStart().x ) ), RADIANS_T ); - aList.emplace_back( _( "Angle" ), MessageTextFromValue( angle ) ); + aList.emplace_back( _( "Angle" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( angle ) ); break; } @@ -634,7 +637,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetIuScale(), units, aList ); } diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 51a9ae33c2..3b54e9e928 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -87,18 +87,21 @@ GR_TEXT_V_ALIGN_T EDA_TEXT::MapVertJustify( int aVertJustify ) } -EDA_TEXT::EDA_TEXT( int aDefaultSizeIu, const wxString& aText ) : +EDA_TEXT::EDA_TEXT( const EDA_IU_SCALE& aIuScale, const wxString& aText ) : m_text( aText ), + m_IuScale( aIuScale ), m_bounding_box_cache_valid( false ), m_bounding_box_cache_line( -1 ), m_bounding_box_cache_inverted( false ) { - SetTextSize( VECTOR2I( aDefaultSizeIu, aDefaultSizeIu ) ); + SetTextSize( VECTOR2I( EDA_UNIT_UTILS::Mils2IU( m_IuScale, DEFAULT_SIZE_TEXT ), + EDA_UNIT_UTILS::Mils2IU( m_IuScale, DEFAULT_SIZE_TEXT ) ) ); cacheShownText(); } -EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) +EDA_TEXT::EDA_TEXT( const EDA_TEXT& aText ) : + m_IuScale( aText.m_IuScale ) { m_text = aText.m_text; m_shown_text = aText.m_shown_text; @@ -780,8 +783,8 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl // Text size aFormatter->Print( 0, " (size %s %s)", - FormatInternalUnits( GetTextHeight() ).c_str(), - FormatInternalUnits( GetTextWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( m_IuScale, GetTextHeight() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( m_IuScale, GetTextWidth() ).c_str() ); if( GetLineSpacing() != 1.0 ) { @@ -792,7 +795,7 @@ void EDA_TEXT::Format( OUTPUTFORMATTER* aFormatter, int aNestLevel, int aControl if( GetTextThickness() ) { aFormatter->Print( 0, " (thickness %s)", - FormatInternalUnits( GetTextThickness() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( m_IuScale, GetTextThickness() ).c_str() ); } if( IsBold() ) diff --git a/common/eda_units.cpp b/common/eda_units.cpp index d0a3a44d4f..1ebcf0578b 100644 --- a/common/eda_units.cpp +++ b/common/eda_units.cpp @@ -23,6 +23,7 @@ #include #include // for KiROUND +#include #include bool EDA_UNIT_UTILS::IsImperialUnit( EDA_UNITS aUnit ) @@ -133,4 +134,417 @@ std::string EDA_UNIT_UTILS::FormatAngle( const EDA_ANGLE& aAngle ) len = snprintf( temp, sizeof( temp ), "%.10g", aAngle.AsDegrees() ); return std::string( temp, len ); +} + + +std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale, int aValue ) +{ + char buf[50]; + double engUnits = aValue; + int len; + + engUnits /= aIuScale.IU_PER_MM; + + if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 ) + { + len = snprintf( buf, sizeof( buf ), "%.10f", engUnits ); + + // Make sure snprintf() didn't fail and the locale numeric separator is correct. + wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr, std::string( "" ) ); + + while( --len > 0 && buf[len] == '0' ) + buf[len] = '\0'; + + if( buf[len] == '.' ) + buf[len] = '\0'; + else + ++len; + } + else + { + len = snprintf( buf, sizeof( buf ), "%.10g", engUnits ); + + // Make sure snprintf() didn't fail and the locale numeric separator is correct. + wxCHECK( len >= 0 && len < 50 && strchr( buf, ',' ) == nullptr, std::string( "" ) ); + } + + return std::string( buf, len ); +} + + +std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale, + const wxPoint& aPoint ) +{ + return FormatInternalUnits( aIuScale, aPoint.x ) + " " + + FormatInternalUnits( aIuScale, aPoint.y ); +} + + +std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale, + const VECTOR2I& aPoint ) +{ + return FormatInternalUnits( aIuScale, aPoint.x ) + " " + + FormatInternalUnits( aIuScale, aPoint.y ); +} + + +std::string EDA_UNIT_UTILS::FormatInternalUnits( const EDA_IU_SCALE& aIuScale, const wxSize& aSize ) +{ + return FormatInternalUnits( aIuScale, aSize.GetWidth() ) + " " + + FormatInternalUnits( aIuScale, aSize.GetHeight() ); +} + +#define IU_TO_MM( x, scale ) ( x / scale.IU_PER_MM ) +#define IU_TO_IN( x, scale ) ( x / scale.IU_PER_MILS / 1000 ) +#define IU_TO_MILS( x, scale ) ( x / scale.IU_PER_MILS ) +#define MM_TO_IU( x, scale ) ( x * scale.IU_PER_MM ) +#define IN_TO_IU( x, scale ) ( x * scale.IU_PER_MILS * 1000 ) +#define MILS_TO_IU( x, scale ) ( x * scale.IU_PER_MILS ) + +double EDA_UNIT_UTILS::UI::ToUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit, + double aValue ) +{ + switch( aUnit ) + { + case EDA_UNITS::MILLIMETRES: + return IU_TO_MM( aValue, aIuScale ); + + case EDA_UNITS::MILS: + return IU_TO_MILS( aValue, aIuScale ); + + case EDA_UNITS::INCHES: + return IU_TO_IN( aValue, aIuScale ); + + case EDA_UNITS::DEGREES: + return aValue; + + default: + return aValue; + } +} + + +/** + * Convert a value to a string using double notation. + * + * For readability, the mantissa has 3 or more digits, + * the trailing 0 are removed if the mantissa has more than 3 digits + * and some trailing 0 + * This function should be used to display values in dialogs because a value + * entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa + * if displayed in inch to avoid truncation or rounding made just by the printf function. + * otherwise the actual value is rounded when read from dialog and converted + * in internal units, and therefore modified. + */ +wxString EDA_UNIT_UTILS::UI::StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + double aValue, bool aAddUnitSymbol, + EDA_DATA_TYPE aType ) +{ + double value_to_print = aValue; + + switch( aType ) + { + case EDA_DATA_TYPE::VOLUME: + value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print ); + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::AREA: + value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print ); + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::DISTANCE: + value_to_print = ToUserUnit( aIuScale, aUnits, value_to_print ); + } + + char buf[50]; + + if( value_to_print != 0.0 && fabs( value_to_print ) <= 0.0001 ) + { + int len = snprintf( buf, sizeof( buf ) - 1, "%.10f", value_to_print ); + + while( --len > 0 && buf[len] == '0' ) + buf[len] = '\0'; + + if( len >= 0 && ( buf[len] == '.' || buf[len] == ',' ) ) + buf[len] = '\0'; + } + else + { + snprintf( buf, sizeof( buf ) - 1, "%.10g", value_to_print ); + } + + wxString stringValue( buf, wxConvUTF8 ); + + if( aAddUnitSymbol ) + stringValue += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType ); + + return stringValue; +} + + + +/** + * Convert a value to a string using double notation. + * + * For readability, the mantissa has 0, 1, 3 or 4 digits, depending on units + * for unit = inch the mantissa has 3 digits (Eeschema) or 4 digits + * for unit = mil the mantissa has 0 digits (Eeschema) or 1 digits + * for unit = mm the mantissa has 3 digits (Eeschema) or 4 digits + * Should be used only to display info in status, + * but not in dialogs, because 4 digits only + * could truncate the actual value + */ + + +// A lower-precision (for readability) version of StringFromValue() +wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + int aValue, + bool aAddUnitLabel, + EDA_DATA_TYPE aType ) +{ + return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType ); +} + + +// A lower-precision (for readability) version of StringFromValue() +wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + long long int aValue, + bool aAddUnitLabel, + EDA_DATA_TYPE aType ) +{ + return MessageTextFromValue( aIuScale, aUnits, double( aValue ), aAddUnitLabel, aType ); +} + + +wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel ) +{ + if( aAddUnitLabel ) + return wxString::Format( wxT( "%.1f°" ), aValue.AsDegrees() ); + else + return wxString::Format( wxT( "%.1f" ), aValue.AsDegrees() ); +} + + +// A lower-precision (for readability) version of StringFromValue() +wxString EDA_UNIT_UTILS::UI::MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + double aValue, bool aAddUnitLabel, + EDA_DATA_TYPE aType ) +{ + wxString text; + const wxChar* format; + double value = aValue; + + switch( aType ) + { + case EDA_DATA_TYPE::VOLUME: + value = ToUserUnit( aIuScale, aUnits, value ); + // Fall through to continue computation + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::AREA: + value = ToUserUnit( aIuScale, aUnits, value ); + // Fall through to continue computation + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::DISTANCE: + value = ToUserUnit( aIuScale, aUnits, value ); + } + + switch( aUnits ) + { + default: + case EDA_UNITS::MILLIMETRES: +#if defined( EESCHEMA ) + format = wxT( "%.2f" ); +#else + format = wxT( "%.4f" ); +#endif + break; + + case EDA_UNITS::MILS: +#if defined( EESCHEMA ) + format = wxT( "%.0f" ); +#else + format = wxT( "%.2f" ); +#endif + break; + + case EDA_UNITS::INCHES: +#if defined( EESCHEMA ) + format = wxT( "%.3f" ); +#else + format = wxT( "%.4f" ); +#endif + break; + + case EDA_UNITS::DEGREES: + // 3 digits in mantissa should be good for rotation in degree + format = wxT( "%.3f" ); + break; + + case EDA_UNITS::UNSCALED: + format = wxT( "%.0f" ); + break; + } + + text.Printf( format, value ); + + if( aAddUnitLabel ) + text += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, aType ); + + return text; +} + + +double EDA_UNIT_UTILS::UI::FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + double aValue ) +{ + switch( aUnits ) + { + case EDA_UNITS::MILLIMETRES: + return MM_TO_IU( aValue, aIuScale ); + + case EDA_UNITS::MILS: + return MILS_TO_IU( aValue, aIuScale ); + + case EDA_UNITS::INCHES: + return IN_TO_IU( aValue, aIuScale ); + + default: + case EDA_UNITS::DEGREES: + case EDA_UNITS::UNSCALED: + case EDA_UNITS::PERCENT: + return aValue; + } +} + + +double EDA_UNIT_UTILS::UI::DoubleValueFromString( const wxString& aTextValue ) +{ + double dtmp = 0; + + // Acquire the 'right' decimal point separator + const struct lconv* lc = localeconv(); + + wxChar decimal_point = lc->decimal_point[0]; + wxString buf( aTextValue.Strip( wxString::both ) ); + + // Convert any entered decimal point separators to the 'right' one + buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); + buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); + + // Find the end of the numeric part + unsigned brk_point = 0; + + while( brk_point < buf.Len() ) + { + wxChar ch = buf[brk_point]; + + if( !( ( ch >= '0' && ch <= '9' ) || ( ch == decimal_point ) || ( ch == '-' ) + || ( ch == '+' ) ) ) + break; + + ++brk_point; + } + + // Extract the numeric part + buf.Left( brk_point ).ToDouble( &dtmp ); + + return dtmp; +} + + +double EDA_UNIT_UTILS::UI::DoubleValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + const wxString& aTextValue, EDA_DATA_TYPE aType ) +{ + double dtmp = 0; + + // Acquire the 'right' decimal point separator + const struct lconv* lc = localeconv(); + + wxChar decimal_point = lc->decimal_point[0]; + wxString buf( aTextValue.Strip( wxString::both ) ); + + // Convert any entered decimal point separators to the 'right' one + buf.Replace( wxT( "." ), wxString( decimal_point, 1 ) ); + buf.Replace( wxT( "," ), wxString( decimal_point, 1 ) ); + + // Find the end of the numeric part + unsigned brk_point = 0; + + while( brk_point < buf.Len() ) + { + wxChar ch = buf[brk_point]; + + if( !( (ch >= '0' && ch <= '9') || (ch == decimal_point) || (ch == '-') || (ch == '+') ) ) + break; + + ++brk_point; + } + + // Extract the numeric part + buf.Left( brk_point ).ToDouble( &dtmp ); + + // Check the optional unit designator (2 ch significant) + wxString unit( buf.Mid( brk_point ).Strip( wxString::leading ).Left( 2 ).Lower() ); + + if( aUnits == EDA_UNITS::MILLIMETRES || aUnits == EDA_UNITS::MILS + || aUnits == EDA_UNITS::INCHES ) + { + if( unit == wxT( "mm" ) ) + { + aUnits = EDA_UNITS::MILLIMETRES; + } + else if( unit == wxT( "mi" ) || unit == wxT( "th" ) ) + { + aUnits = EDA_UNITS::MILS; + } + else if( unit == wxT( "in" ) || unit == wxT( "\"" ) ) + { + aUnits = EDA_UNITS::INCHES; + } + else if( unit == "oz" ) // 1 oz = 1.37 mils + { + aUnits = EDA_UNITS::MILS; + dtmp *= 1.37; + } + } + else if( aUnits == EDA_UNITS::DEGREES ) + { + if( unit == wxT( "ra" ) ) // Radians + dtmp *= 180.0f / M_PI; + } + + switch( aType ) + { + case EDA_DATA_TYPE::VOLUME: + dtmp = FromUserUnit( aIuScale, aUnits, dtmp ); + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::AREA: + dtmp = FromUserUnit( aIuScale, aUnits, dtmp ); + KI_FALLTHROUGH; + + case EDA_DATA_TYPE::DISTANCE: + dtmp = FromUserUnit( aIuScale, aUnits, dtmp ); + } + + return dtmp; +} + + +long long int EDA_UNIT_UTILS::UI::ValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + const wxString& aTextValue, EDA_DATA_TYPE aType ) +{ + double value = DoubleValueFromString( aIuScale, aUnits, aTextValue, aType ); + + return KiROUND( value ); +} + + +long long int EDA_UNIT_UTILS::UI::ValueFromString( const wxString& aTextValue ) +{ + double value = DoubleValueFromString( aTextValue ); + + return KiROUND( value ); } \ No newline at end of file diff --git a/common/libeval_compiler/libeval_compiler.cpp b/common/libeval_compiler/libeval_compiler.cpp index 59cfe64632..e51a78929e 100644 --- a/common/libeval_compiler/libeval_compiler.cpp +++ b/common/libeval_compiler/libeval_compiler.cpp @@ -1011,7 +1011,7 @@ bool COMPILER::generateUCode( UCODE* aCode, CONTEXT* aPreflightContext ) m_unitResolver->GetSupportedUnitsMessage() ); reportError( CST_CODEGEN, msg, node->srcPos ); - value = DoubleValueFromString( EDA_UNITS::UNSCALED, *node->value.str ); + value = EDA_UNIT_UTILS::UI::DoubleValueFromString( *node->value.str ); } node->SetUop( TR_UOP_PUSH_VALUE, value ); diff --git a/common/preview_items/arc_assistant.cpp b/common/preview_items/arc_assistant.cpp index f0e844bdc4..00099248c1 100644 --- a/common/preview_items/arc_assistant.cpp +++ b/common/preview_items/arc_assistant.cpp @@ -34,9 +34,11 @@ using namespace KIGFX::PREVIEW; -ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS aUnits ) : +ARC_ASSISTANT::ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, const EDA_IU_SCALE& aIuScale, + EDA_UNITS aUnits ) : EDA_ITEM( NOT_USED ), m_constructMan( aManager ), + m_iuScale( aIuScale ), m_units( aUnits ) { } @@ -90,8 +92,9 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const initAngle.Normalize720(); - cursorStrings.push_back( DimensionLabel( "r", m_constructMan.GetRadius(), m_units ) ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), initAngle.AsDegrees(), + cursorStrings.push_back( + DimensionLabel( "r", m_constructMan.GetRadius(), m_iuScale, m_units ) ); + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), initAngle.AsDegrees(), m_iuScale, EDA_UNITS::DEGREES ) ); } else @@ -106,9 +109,9 @@ void ARC_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const preview_ctx.DrawLineWithAngleHighlight( origin, m_constructMan.GetLastPoint(), true ); cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "Δθ" ), subtended.AsDegrees(), - EDA_UNITS::DEGREES ) ); + m_iuScale, EDA_UNITS::DEGREES ) ); cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), endAngle.AsDegrees(), - EDA_UNITS::DEGREES ) ); + m_iuScale, EDA_UNITS::DEGREES ) ); } // place the text next to cursor, on opposite side from radius diff --git a/common/preview_items/preview_utils.cpp b/common/preview_items/preview_utils.cpp index 9c39621bb9..fdb28e8eb6 100644 --- a/common/preview_items/preview_utils.cpp +++ b/common/preview_items/preview_utils.cpp @@ -30,7 +30,8 @@ double KIGFX::PREVIEW::PreviewOverlayDeemphAlpha( bool aDeemph ) } -wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal, EDA_UNITS aUnits, +wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal, + const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, bool aIncludeUnits ) { wxString str; @@ -52,7 +53,7 @@ wxString KIGFX::PREVIEW::DimensionLabel( const wxString& prefix, double aVal, ED case EDA_UNITS::UNSCALED: fmtStr = wxT( "%f" ); break; } - str << wxString::Format( fmtStr, To_User_Unit( aUnits, aVal ) ); + str << wxString::Format( fmtStr, EDA_UNIT_UTILS::UI::ToUserUnit( aIuScale, aUnits, aVal ) ); if( aIncludeUnits ) str << EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits ); diff --git a/common/preview_items/ruler_item.cpp b/common/preview_items/ruler_item.cpp index 500aeffdce..c508a8a2dc 100644 --- a/common/preview_items/ruler_item.cpp +++ b/common/preview_items/ruler_item.cpp @@ -53,7 +53,7 @@ static int getShadowLayer( KIGFX::GAL* aGal ) static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor, - const VECTOR2D& aRulerVec, EDA_UNITS aUnits, + const VECTOR2D& aRulerVec, const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, bool aDrawingDropShadows, bool aFlipX, bool aFlipY ) { // draw the cursor labels @@ -67,13 +67,13 @@ static void drawCursorStrings( KIGFX::VIEW* aView, const VECTOR2D& aCursor, if( aFlipY ) temp.y = -temp.y; - cursorStrings.push_back( DimensionLabel( "x", temp.x, aUnits ) ); - cursorStrings.push_back( DimensionLabel( "y", temp.y, aUnits ) ); + cursorStrings.push_back( DimensionLabel( "x", temp.x, aIuScale, aUnits ) ); + cursorStrings.push_back( DimensionLabel( "y", temp.y, aIuScale, aUnits ) ); - cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aUnits ) ); + cursorStrings.push_back( DimensionLabel( "r", aRulerVec.EuclideanNorm(), aIuScale, aUnits ) ); EDA_ANGLE angle = -EDA_ANGLE( aRulerVec ); - cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(), + cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), angle.AsDegrees(), aIuScale, EDA_UNITS::DEGREES ) ); temp = aRulerVec; @@ -148,7 +148,7 @@ static TICK_FORMAT getTickFormatForScale( double aScale, double& aTickSpace, EDA * @param aMinorTickLen length of minor ticks in IU */ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECTOR2D& aLine, - double aMinorTickLen, EDA_UNITS aUnits, bool aDrawingDropShadows ) + double aMinorTickLen, const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, bool aDrawingDropShadows ) { KIGFX::GAL* gal = aView->GetGAL(); KIFONT::FONT* font = KIFONT::FONT::GetFont(); @@ -220,7 +220,7 @@ void drawTicksAlongLine( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECT if( drawLabel ) { - wxString label = DimensionLabel( "", tickSpace * i, aUnits, false ); + wxString label = DimensionLabel( "", tickSpace * i, aIuScale, aUnits, false ); font->Draw( gal, label, tickPos + labelOffset, labelAttrs ); } } @@ -267,11 +267,12 @@ void drawBacksideTicks( KIGFX::VIEW* aView, const VECTOR2D& aOrigin, const VECTO } -RULER_ITEM::RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& aGeomMgr, EDA_UNITS userUnits, +RULER_ITEM::RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& aGeomMgr, const EDA_IU_SCALE& aIuScale, EDA_UNITS userUnits, bool aFlipX, bool aFlipY ) : EDA_ITEM( NOT_USED ), // Never added to anything - just a preview m_geomMgr( aGeomMgr ), m_userUnits( userUnits ), + m_iuScale( aIuScale ), m_flipX( aFlipX ), m_flipY( aFlipY ) { @@ -330,13 +331,14 @@ void RULER_ITEM::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const VECTOR2D rulerVec( end - origin ); - drawCursorStrings( aView, end, rulerVec, m_userUnits, drawingDropShadows, m_flipX, m_flipY ); + drawCursorStrings( aView, end, rulerVec, m_iuScale, m_userUnits, drawingDropShadows, m_flipX, + m_flipY ); // basic tick size const double minorTickLen = 5.0 / gal->GetWorldScale(); const double majorTickLen = minorTickLen * majorTickLengthFactor; - drawTicksAlongLine( aView, origin, rulerVec, minorTickLen, m_userUnits, drawingDropShadows ); + drawTicksAlongLine( aView, origin, rulerVec, minorTickLen, m_iuScale, m_userUnits, drawingDropShadows ); drawBacksideTicks( aView, origin, rulerVec, majorTickLen, 2, drawingDropShadows ); diff --git a/common/preview_items/two_point_assistant.cpp b/common/preview_items/two_point_assistant.cpp index 2e818d3400..d8da87794d 100644 --- a/common/preview_items/two_point_assistant.cpp +++ b/common/preview_items/two_point_assistant.cpp @@ -30,11 +30,13 @@ using namespace KIGFX::PREVIEW; TWO_POINT_ASSISTANT::TWO_POINT_ASSISTANT( const TWO_POINT_GEOMETRY_MANAGER& aManager, - EDA_UNITS aUnits, GEOM_SHAPE aShape ) : + const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + GEOM_SHAPE aShape ) : EDA_ITEM( NOT_USED ), m_constructMan( aManager ), m_units( aUnits ), - m_shape( aShape ) + m_shape( aShape ), + m_iuScale( aIuScale ) { } @@ -80,21 +82,23 @@ void TWO_POINT_ASSISTANT::ViewDraw( int aLayer, KIGFX::VIEW* aView ) const if( m_shape == GEOM_SHAPE::SEGMENT ) { - cursorStrings.push_back( DimensionLabel( "l", radVec.EuclideanNorm(), m_units ) ); + cursorStrings.push_back( + DimensionLabel( "l", radVec.EuclideanNorm(), m_iuScale, m_units ) ); cursorStrings.push_back( DimensionLabel( wxString::FromUTF8( "θ" ), deltaAngle.AsDegrees(), - EDA_UNITS::DEGREES ) ); + m_iuScale, EDA_UNITS::DEGREES ) ); } else if( m_shape == GEOM_SHAPE::RECT ) { - cursorStrings.push_back( DimensionLabel( "x", std::abs( radVec.x ), m_units ) ); - cursorStrings.push_back( DimensionLabel( "y", std::abs( radVec.y ), m_units ) ); + cursorStrings.push_back( DimensionLabel( "x", std::abs( radVec.x ), m_iuScale, m_units ) ); + cursorStrings.push_back( DimensionLabel( "y", std::abs( radVec.y ), m_iuScale, m_units ) ); } else if( m_shape == GEOM_SHAPE::CIRCLE ) { KIGFX::PREVIEW::DRAW_CONTEXT preview_ctx( *aView ); preview_ctx.DrawLine( origin, end, false ); - cursorStrings.push_back( DimensionLabel( "r", radVec.EuclideanNorm(), m_units ) ); + cursorStrings.push_back( + DimensionLabel( "r", radVec.EuclideanNorm(), m_iuScale, m_units ) ); } // place the text next to cursor, on opposite side from drawing diff --git a/common/rc_item.cpp b/common/rc_item.cpp index 71b93393c4..972243917c 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -44,11 +44,11 @@ wxString RC_ITEM::GetErrorMessage() const } -wxString RC_ITEM::ShowCoord( EDA_UNITS aUnits, const VECTOR2I& aPos ) +wxString RC_ITEM::ShowCoord( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, const VECTOR2I& aPos ) { return wxString::Format( wxT( "@(%s, %s)" ), - MessageTextFromValue( aUnits, aPos.x ), - MessageTextFromValue( aUnits, aPos.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( aIuScale, aUnits, aPos.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( aIuScale, aUnits, aPos.y ) ); } @@ -76,7 +76,7 @@ void RC_ITEM::SetItems( const EDA_ITEM* aItem, const EDA_ITEM* bItem, } -wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity, +wxString RC_ITEM::ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SEVERITY aSeverity, const std::map& aItemMap ) const { wxString severity; @@ -120,9 +120,9 @@ wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity, GetErrorMessage(), GetViolatingRuleDesc(), severity, - ShowCoord( aUnits, mainItem->GetPosition() ), + ShowCoord( aIuScale, aUnits, mainItem->GetPosition() ), mainItem->GetSelectMenuText( aUnits ), - ShowCoord( aUnits, auxItem->GetPosition() ), + ShowCoord( aIuScale, aUnits, auxItem->GetPosition() ), auxItem->GetSelectMenuText( aUnits ) ); } else if( mainItem ) @@ -132,7 +132,7 @@ wxString RC_ITEM::ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity, GetErrorMessage(), GetViolatingRuleDesc(), severity, - ShowCoord( aUnits, mainItem->GetPosition() ), + ShowCoord( aIuScale, aUnits, mainItem->GetPosition() ), mainItem->GetSelectMenuText( aUnits ) ); } else diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index 443b041315..2e67bf11af 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -190,7 +190,8 @@ wxString STROKE_PARAMS::GetLineStyleToken( PLOT_DASH_TYPE aStyle ) } -void STROKE_PARAMS::GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList, +void STROKE_PARAMS::GetMsgPanelInfo( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + std::vector& aList, bool aIncludeStyle, bool aIncludeWidth ) { if( aIncludeStyle ) @@ -211,25 +212,26 @@ void STROKE_PARAMS::GetMsgPanelInfo( EDA_UNITS aUnits, std::vectorPrint( aNestLevel, "(stroke (width %s) (type %s))", - FormatInternalUnits(GetWidth() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( aIuScale, GetWidth() ).c_str(), TO_UTF8( GetLineStyleToken( GetPlotStyle() ) ) ); } else { aFormatter->Print( aNestLevel, "(stroke (width %s) (type %s) (color %d %d %d %s))", - FormatInternalUnits(GetWidth() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( aIuScale, GetWidth() ).c_str(), TO_UTF8( GetLineStyleToken( GetPlotStyle() ) ), KiROUND( GetColor().r * 255.0 ), KiROUND( GetColor().g * 255.0 ), diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index de131af2d0..5543092954 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -59,12 +59,15 @@ void COMMON_TOOLS::Reset( RESET_REASON aReason ) for( const wxString& gridDef : settings.sizes ) { - int gridSize = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridDef ); + int gridSize = (int) EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES, gridDef ); m_grids.emplace_back( gridSize, gridSize ); } - m_grids.emplace_back( ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_x ), - ValueFromString( EDA_UNITS::MILLIMETRES, settings.user_grid_y ) ); + m_grids.emplace_back( + EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES, + settings.user_grid_x ), + EDA_UNIT_UTILS::UI::ValueFromString( m_frame->GetIuScale(), EDA_UNITS::MILLIMETRES, + settings.user_grid_y ) ); OnGridChanged(); } diff --git a/common/tool/grid_menu.cpp b/common/tool/grid_menu.cpp index ee55fc3600..0b7f8331cd 100644 --- a/common/tool/grid_menu.cpp +++ b/common/tool/grid_menu.cpp @@ -94,22 +94,26 @@ void GRID_MENU::BuildChoiceList( wxArrayString* aGridsList, APP_SETTINGS_BASE* a for( const wxString& gridSize : aCfg->m_Window.grid.sizes ) { - int val = (int) ValueFromString( EDA_UNITS::MILLIMETRES, gridSize ); + int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( aParent->GetIuScale(), EDA_UNITS::MILLIMETRES, gridSize ); - msg.Printf( _( "Grid: %s (%s)" ), - MessageTextFromValue( primaryUnit, val ), - MessageTextFromValue( secondaryUnit, val ) ); + msg.Printf( + _( "Grid: %s (%s)" ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), primaryUnit, val ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), secondaryUnit, + val ) ); aGridsList->Add( msg ); } if( !aCfg->m_Window.grid.user_grid_x.empty() ) { - int val = (int) ValueFromString( EDA_UNITS::INCHES, aCfg->m_Window.grid.user_grid_x ); + int val = (int) EDA_UNIT_UTILS::UI::ValueFromString( aParent->GetIuScale(),EDA_UNITS::INCHES, + aCfg->m_Window.grid.user_grid_x ); msg.Printf( _( "User grid: %s (%s)" ), - MessageTextFromValue( primaryUnit, val ), - MessageTextFromValue( secondaryUnit, val ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), primaryUnit, val ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( aParent->GetIuScale(), secondaryUnit, + val ) ); aGridsList->Add( msg ); } diff --git a/common/widgets/unit_binder.cpp b/common/widgets/unit_binder.cpp index 5726649460..6890440e82 100644 --- a/common/widgets/unit_binder.cpp +++ b/common/widgets/unit_binder.cpp @@ -37,12 +37,20 @@ wxDEFINE_EVENT( DELAY_FOCUS, wxCommandEvent ); -UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, +UNIT_BINDER::UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, + wxStaticText* aUnitLabel, bool allowEval ) : + UNIT_BINDER( aParent, aParent->GetIuScale(), aLabel, aValueCtrl, aUnitLabel, allowEval ) +{ +} + +UNIT_BINDER::UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale, + wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool allowEval ) : m_frame( aParent ), m_label( aLabel ), m_valueCtrl( aValueCtrl ), m_unitLabel( aUnitLabel ), + m_iuScale( aIUScale ), m_negativeZero( false ), m_dataType( EDA_DATA_TYPE::DISTANCE ), m_precision( 0 ), @@ -246,12 +254,12 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits ) // TODO: Validate() does not currently support m_dataType being anything other than DISTANCE // Note: aMin and aMax are not always given in internal units - if( GetValue() < From_User_Unit( aUnits, aMin ) ) + if( GetValue() < EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMin ) ) { - double val_min_iu = From_User_Unit( aUnits, aMin ); + double val_min_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMin ); m_errorMessage = wxString::Format( _( "%s must be at least %s." ), valueDescriptionFromLabel( m_label ), - StringFromValue( m_units, val_min_iu, true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, val_min_iu, true ) ); textEntry->SelectAll(); @@ -261,12 +269,12 @@ bool UNIT_BINDER::Validate( double aMin, double aMax, EDA_UNITS aUnits ) return false; } - if( GetValue() > From_User_Unit( aUnits, aMax ) ) + if( GetValue() > EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMax ) ) { - double val_max_iu = From_User_Unit( aUnits, aMax ); + double val_max_iu = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, aUnits, aMax ); m_errorMessage = wxString::Format( _( "%s must be less than %s." ), valueDescriptionFromLabel( m_label ), - StringFromValue( m_units, val_max_iu, true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, val_max_iu, true ) ); textEntry->SelectAll(); @@ -286,9 +294,10 @@ void UNIT_BINDER::SetValue( long long int aValue ) double displayValue = m_originTransforms.ToDisplay( value, m_coordType ); if( displayValue == 0 && m_negativeZero ) - SetValue( wxT( "-" ) + StringFromValue( m_units, displayValue, false, m_dataType ) ); + SetValue( wxT( "-" ) + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue, false, m_dataType ) ); else - SetValue( StringFromValue( m_units, displayValue, false, m_dataType ) ); + SetValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue, + false, m_dataType ) ); } @@ -298,9 +307,12 @@ void UNIT_BINDER::SetDoubleValue( double aValue ) displayValue = setPrecision( displayValue, false ); if( displayValue == 0 && m_negativeZero ) - SetValue( wxT( "-" ) + StringFromValue( m_units, displayValue, false, m_dataType ) ); + SetValue( wxT( "-" ) + + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, + displayValue, false, m_dataType ) ); else - SetValue( StringFromValue( m_units, displayValue, false, m_dataType ) ); + SetValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, displayValue, + false, m_dataType ) ); } @@ -335,9 +347,12 @@ void UNIT_BINDER::ChangeValue( int aValue ) double displayValue = m_originTransforms.ToDisplay( value, m_coordType ); if( displayValue == 0 && m_negativeZero ) - ChangeValue( wxT( "-" ) + StringFromValue( m_units, displayValue, false ) ); + ChangeValue( wxT( "-" ) + + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, + displayValue, false ) ); else - ChangeValue( StringFromValue( m_units, displayValue, false ) ); + ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, + displayValue, false ) ); } @@ -347,9 +362,12 @@ void UNIT_BINDER::ChangeDoubleValue( double aValue ) displayValue = setPrecision( displayValue, false ); if( displayValue == 0 && m_negativeZero ) - ChangeValue( wxT( "-" ) + StringFromValue( m_units, displayValue, false, m_dataType ) ); + ChangeValue( wxT( "-" ) + + EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, + displayValue, false, m_dataType ) ); else - ChangeValue( StringFromValue( m_units, displayValue, false, m_dataType ) ); + ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( m_iuScale, m_units, + displayValue, false, m_dataType ) ); } @@ -400,7 +418,7 @@ long long int UNIT_BINDER::GetValue() return 0; } - long long int displayValue = ValueFromString( m_units, value, m_dataType ); + long long int displayValue = EDA_UNIT_UTILS::UI::ValueFromString( m_iuScale, m_units, value, m_dataType ); return m_originTransforms.FromDisplay( displayValue, m_coordType ); } @@ -410,11 +428,16 @@ double UNIT_BINDER::setPrecision( double aValue, bool aValueUsesUserUnits ) if( m_precision > 1 ) { int scale = pow( 10, m_precision ); - long long tmp = aValueUsesUserUnits ? aValue : To_User_Unit( m_units, aValue ) * scale; + int64_t tmp = aValue; + if( !aValueUsesUserUnits ) + { + tmp = EDA_UNIT_UTILS::UI::ToUserUnit( m_iuScale, m_units, aValue ) * scale; + } + aValue = static_cast( tmp ) / scale; if( !aValueUsesUserUnits ) - aValue = From_User_Unit( m_units, aValue ); + aValue = EDA_UNIT_UTILS::UI::FromUserUnit( m_iuScale, m_units, aValue ); } return aValue; @@ -443,7 +466,8 @@ double UNIT_BINDER::GetDoubleValue() return 0.0; } - double displayValue = DoubleValueFromString( m_units, value, m_dataType ); + double displayValue = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_iuScale, m_units, + value, m_dataType ); displayValue = setPrecision( displayValue, false ); return m_originTransforms.FromDisplay( displayValue, m_coordType ); diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 994eed208b..5e46524640 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -26,7 +26,6 @@ set( CVPCB_DIALOGS ) set( CVPCB_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ${CMAKE_SOURCE_DIR}/pcbnew/board_stackup_manager/stackup_predefined_prms.cpp ${CMAKE_SOURCE_DIR}/pcbnew/footprint_info_impl.cpp auto_associate.cpp diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 5e0837139a..6d27284a5f 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -318,7 +318,6 @@ set( EESCHEMA_SRCS set( EESCHEMA_COMMON_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ) diff --git a/eeschema/dialogs/dialog_annotate.cpp b/eeschema/dialogs/dialog_annotate.cpp index 556f1c8c6d..5ec3161aae 100644 --- a/eeschema/dialogs/dialog_annotate.cpp +++ b/eeschema/dialogs/dialog_annotate.cpp @@ -304,7 +304,7 @@ ANNOTATE_ALGO_T DIALOG_ANNOTATE::GetAnnotateAlgo() int DIALOG_ANNOTATE::GetStartNumber() { - return ValueFromString( EDA_UNITS::UNSCALED, m_textNumberAfter->GetValue() ); + return EDA_UNIT_UTILS::UI::ValueFromString( m_textNumberAfter->GetValue() ); } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 428938f5cb..907ceb5f71 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -983,7 +983,7 @@ bool DIALOG_ERC::writeReport( const wxString& aFullFileName ) default: break; } - msg << marker->GetRCItem()->ShowReport( GetUserUnits(), severity, itemMap ); + msg << marker->GetRCItem()->ShowReport( schIUScale, GetUserUnits(), severity, itemMap ); } } diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 9d6f31f22a..e77322a0d6 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -179,23 +179,28 @@ public: break; case COL_NUMBER_SIZE: - val = StringFromValue( aUserUnits, pin->GetNumberTextSize(), true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits, + pin->GetNumberTextSize(), true ); break; case COL_NAME_SIZE: - val = StringFromValue( aUserUnits, pin->GetNameTextSize(), true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits, + pin->GetNameTextSize(), true ); break; case COL_LENGTH: - val = StringFromValue( aUserUnits, pin->GetLength(), true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits, + pin->GetLength(), true ); break; case COL_POSX: - val = StringFromValue( aUserUnits, pin->GetPosition().x, true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits, + pin->GetPosition().x, true ); break; case COL_POSY: - val = StringFromValue( aUserUnits, -pin->GetPosition().y, true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, aUserUnits, + -pin->GetPosition().y, true ); break; case COL_VISIBLE: @@ -348,25 +353,29 @@ public: break; case COL_NUMBER_SIZE: - pin->SetNumberTextSize( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + pin->SetNumberTextSize( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, m_frame->GetUserUnits(), aValue ) ); break; case COL_NAME_SIZE: - pin->SetNameTextSize( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + pin->SetNameTextSize( EDA_UNIT_UTILS::UI::ValueFromString( + schIUScale, m_frame->GetUserUnits(), aValue ) ); break; case COL_LENGTH: - pin->ChangeLength( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + pin->ChangeLength( EDA_UNIT_UTILS::UI::ValueFromString( + schIUScale, m_frame->GetUserUnits(), aValue ) ); break; case COL_POSX: - pin->SetPosition( wxPoint( ValueFromString( m_frame->GetUserUnits(), aValue ), + pin->SetPosition( wxPoint( EDA_UNIT_UTILS::UI::ValueFromString( + schIUScale, m_frame->GetUserUnits(), aValue ), pin->GetPosition().y ) ); break; case COL_POSY: pin->SetPosition( wxPoint( pin->GetPosition().x, - -ValueFromString( m_frame->GetUserUnits(), aValue ) ) ); + -EDA_UNIT_UTILS::UI::ValueFromString( + schIUScale, m_frame->GetUserUnits(), aValue ) ) ); break; case COL_VISIBLE: @@ -454,12 +463,14 @@ public: break; case COL_NUMBER_SIZE: case COL_NAME_SIZE: - res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) ); + res = cmp( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, lhStr ), + EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, rhStr ) ); break; case COL_LENGTH: case COL_POSX: case COL_POSY: - res = cmp( ValueFromString( units, lhStr ), ValueFromString( units, rhStr ) ); + res = cmp( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, lhStr ), + EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, units, rhStr ) ); break; case COL_VISIBLE: case COL_DEMORGAN: diff --git a/eeschema/dialogs/panel_eeschema_annotation_options.cpp b/eeschema/dialogs/panel_eeschema_annotation_options.cpp index 455c336c40..0a793fe322 100644 --- a/eeschema/dialogs/panel_eeschema_annotation_options.cpp +++ b/eeschema/dialogs/panel_eeschema_annotation_options.cpp @@ -115,8 +115,7 @@ bool PANEL_EESCHEMA_ANNOTATION_OPTIONS::TransferDataFromWindow() if( schFrame ) { SCHEMATIC_SETTINGS& projSettings = schFrame->Schematic().Settings(); - projSettings.m_AnnotateStartNum = - ValueFromString( EDA_UNITS::UNSCALED, m_textNumberAfter->GetValue() ); + projSettings.m_AnnotateStartNum = EDA_UNIT_UTILS::UI::ValueFromString( m_textNumberAfter->GetValue() ); } return true; diff --git a/eeschema/dialogs/panel_eeschema_editing_options.cpp b/eeschema/dialogs/panel_eeschema_editing_options.cpp index 4ea5dd8e88..e7c4bc315c 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.cpp +++ b/eeschema/dialogs/panel_eeschema_editing_options.cpp @@ -32,8 +32,8 @@ PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ) : PANEL_EESCHEMA_EDITING_OPTIONS_BASE( aWindow ), - m_hPitch( aUnitsProvider, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ), - m_vPitch( aUnitsProvider, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits ) + m_hPitch( aUnitsProvider, schIUScale, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ), + m_vPitch( aUnitsProvider, schIUScale, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits ) { // Make the color swatch show "Clear Color" instead m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED ); diff --git a/eeschema/dialogs/panel_eeschema_editing_options.h b/eeschema/dialogs/panel_eeschema_editing_options.h index 2a76bf6518..99c815d3a0 100644 --- a/eeschema/dialogs/panel_eeschema_editing_options.h +++ b/eeschema/dialogs/panel_eeschema_editing_options.h @@ -23,7 +23,7 @@ #include #include "panel_eeschema_editing_options_base.h" -class EDA_BASE_FRAME; +class EDA_DRAW_FRAME; class PANEL_EESCHEMA_EDITING_OPTIONS : public PANEL_EESCHEMA_EDITING_OPTIONS_BASE diff --git a/eeschema/dialogs/panel_setup_formatting.cpp b/eeschema/dialogs/panel_setup_formatting.cpp index e3e2554908..c83a578554 100644 --- a/eeschema/dialogs/panel_setup_formatting.cpp +++ b/eeschema/dialogs/panel_setup_formatting.cpp @@ -100,16 +100,19 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() m_suffixCtrl->ChangeValue( settings.m_IntersheetRefsSuffix ); m_listOwnPage->SetValue( settings.m_IntersheetRefsListOwnPage ); - m_textOffsetRatioCtrl->SetValue( StringFromValue( EDA_UNITS::PERCENT, + m_textOffsetRatioCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, EDA_UNITS::PERCENT, settings.m_TextOffsetRatio * 100.0 ) ); - m_dashLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + schIUScale, EDA_UNITS::UNSCALED, settings.m_DashedLineDashRatio ) ); - m_gapLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + schIUScale, EDA_UNITS::UNSCALED, settings.m_DashedLineGapRatio ) ); - m_labelSizeRatioCtrl->SetValue( StringFromValue( EDA_UNITS::PERCENT, + m_labelSizeRatioCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + schIUScale, EDA_UNITS::PERCENT, settings.m_LabelSizeRatio * 100.0 ) ); return true; @@ -154,17 +157,21 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() settings.m_IntersheetRefsSuffix = m_suffixCtrl->GetValue(); settings.m_IntersheetRefsListOwnPage = m_listOwnPage->GetValue(); - settings.m_TextOffsetRatio = DoubleValueFromString( EDA_UNITS::PERCENT, - m_textOffsetRatioCtrl->GetValue() ) / 100.0; + settings.m_TextOffsetRatio = + EDA_UNIT_UTILS::UI::DoubleValueFromString( schIUScale, EDA_UNITS::PERCENT, + m_textOffsetRatioCtrl->GetValue() ) + / 100.0; - settings.m_DashedLineDashRatio = DoubleValueFromString( EDA_UNITS::UNSCALED, - m_dashLengthCtrl->GetValue() ); + settings.m_DashedLineDashRatio = EDA_UNIT_UTILS::UI::DoubleValueFromString( + schIUScale, EDA_UNITS::UNSCALED, m_dashLengthCtrl->GetValue() ); - settings.m_DashedLineGapRatio = DoubleValueFromString( EDA_UNITS::UNSCALED, - m_gapLengthCtrl->GetValue() ); + settings.m_DashedLineGapRatio = EDA_UNIT_UTILS::UI::DoubleValueFromString( + schIUScale, EDA_UNITS::UNSCALED, m_gapLengthCtrl->GetValue() ); - settings.m_LabelSizeRatio = DoubleValueFromString( EDA_UNITS::PERCENT, - m_labelSizeRatioCtrl->GetValue() ) / 100.0; + settings.m_LabelSizeRatio = + EDA_UNIT_UTILS::UI::DoubleValueFromString( schIUScale, EDA_UNITS::PERCENT, + m_labelSizeRatioCtrl->GetValue() ) + / 100.0; return true; } @@ -189,9 +196,11 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( SCHEMATIC_SETTINGS& aSettings ) wxString labelSizeRatio = wxString::Format( "%f", aSettings.m_LabelSizeRatio * 100.0 ); m_labelSizeRatioCtrl->SetValue( labelSizeRatio ); - m_dashLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + schIUScale, EDA_UNITS::UNSCALED, aSettings.m_DashedLineDashRatio ) ); - m_gapLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( + schIUScale, EDA_UNITS::UNSCALED, aSettings.m_DashedLineGapRatio ) ); } diff --git a/eeschema/dialogs/panel_sym_editing_options.cpp b/eeschema/dialogs/panel_sym_editing_options.cpp index fbdfffb347..17933b18b0 100644 --- a/eeschema/dialogs/panel_sym_editing_options.cpp +++ b/eeschema/dialogs/panel_sym_editing_options.cpp @@ -32,11 +32,11 @@ PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_EDITING_OPTIONS( wxWindow* aWindow, EDA_BASE_FRAME* aUnitsProvider ) : PANEL_SYM_EDITING_OPTIONS_BASE( aWindow ), - m_lineWidth( aUnitsProvider, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ), - m_textSize( aUnitsProvider, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), - m_pinLength( aUnitsProvider, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), - m_pinNameSize( aUnitsProvider, m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ), - m_pinNumberSize( aUnitsProvider, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits ) + m_lineWidth( aUnitsProvider, schIUScale, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ), + m_textSize( aUnitsProvider, schIUScale, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ), + m_pinLength( aUnitsProvider, schIUScale, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ), + m_pinNameSize( aUnitsProvider, schIUScale ,m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ), + m_pinNumberSize( aUnitsProvider, schIUScale, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits ) { m_widthHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() ); } diff --git a/eeschema/dialogs/panel_sym_editing_options.h b/eeschema/dialogs/panel_sym_editing_options.h index 1c0178febd..28f5807562 100644 --- a/eeschema/dialogs/panel_sym_editing_options.h +++ b/eeschema/dialogs/panel_sym_editing_options.h @@ -23,7 +23,7 @@ #include #include "panel_sym_editing_options_base.h" -class EDA_BASE_FRAME; +class EDA_DRAW_FRAME; class PANEL_SYM_EDITING_OPTIONS : public PANEL_SYM_EDITING_OPTIONS_BASE diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index f3e51fe453..cb7b8140ae 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -583,7 +583,7 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) return StringFromBool( field.IsBold() ); case FDC_TEXT_SIZE: - return StringFromValue( m_frame->GetUserUnits(), field.GetTextHeight(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(), field.GetTextHeight(), true ); case FDC_ORIENTATION: if( field.GetTextAngle().IsHorizontal() ) @@ -592,10 +592,12 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) return _( "Vertical" ); case FDC_POSX: - return StringFromValue( m_frame->GetUserUnits(), field.GetTextPos().x, true ); + return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(), + field.GetTextPos().x, true ); case FDC_POSY: - return StringFromValue( m_frame->GetUserUnits(), field.GetTextPos().y, true ); + return EDA_UNIT_UTILS::UI::StringFromValue( schIUScale, m_frame->GetUserUnits(), + field.GetTextPos().y, true ); case FDC_FONT: if( field.GetFont() ) @@ -709,8 +711,9 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue break; case FDC_TEXT_SIZE: - field.SetTextSize( wxSize( ValueFromString( m_frame->GetUserUnits(), aValue ), - ValueFromString( m_frame->GetUserUnits(), aValue ) ) ); + field.SetTextSize( + wxSize( EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, m_frame->GetUserUnits(), aValue ), + EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, m_frame->GetUserUnits(), aValue ) ) ); break; case FDC_ORIENTATION: @@ -728,9 +731,10 @@ void FIELDS_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue pos = field.GetTextPos(); if( aCol == FDC_POSX ) - pos.x = ValueFromString( m_frame->GetUserUnits(), aValue ); + pos.x = EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, m_frame->GetUserUnits(), aValue ); else - pos.y = ValueFromString( m_frame->GetUserUnits(), aValue ); + pos.y = EDA_UNIT_UTILS::UI::ValueFromString( schIUScale, m_frame->GetUserUnits(), + aValue ); field.SetTextPos( pos ); break; diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 76eae1c16b..ee3609b4d1 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -41,7 +41,7 @@ LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId ) : LIB_ITEM( LIB_FIELD_T, aParent ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( schIUScale ) { Init( aId ); } @@ -49,7 +49,7 @@ LIB_FIELD::LIB_FIELD( LIB_SYMBOL* aParent, int aId ) : LIB_FIELD::LIB_FIELD( int aId ) : LIB_ITEM( LIB_FIELD_T, nullptr ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( schIUScale ) { Init( aId ); } @@ -57,7 +57,7 @@ LIB_FIELD::LIB_FIELD( int aId ) : LIB_FIELD::LIB_FIELD( int aId, const wxString& aName ) : LIB_ITEM( LIB_FIELD_T, nullptr ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( schIUScale ) { Init( aId ); m_name = aName; @@ -515,7 +515,7 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), + aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetTextWidth() ) ); switch ( GetHorizJustify() ) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 1c8da16997..59568b1a21 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1092,7 +1092,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), + aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetTextWidth() ) ); switch ( GetHorizJustify() ) diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 3095949f87..ceaf83e541 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -45,7 +45,7 @@ using KIGFX::SCH_RENDER_SETTINGS; LIB_TEXTBOX::LIB_TEXTBOX( LIB_SYMBOL* aParent, int aLineWidth, FILL_T aFillType, const wxString& text ) : LIB_SHAPE( aParent, SHAPE_T::RECT, aLineWidth, aFillType, LIB_TEXTBOX_T ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ), text ) + EDA_TEXT( schIUScale, text ) { SetTextSize( wxSize( Mils2iu( DEFAULT_TEXT_SIZE ), Mils2iu( DEFAULT_TEXT_SIZE ) ) ); SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); @@ -434,15 +434,15 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorm_LocalOrigin; line.Printf( "X %s Y %s", - MessageTextFromValue( GetUserUnits(), cursorPos.x, false ), - MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + cursorPos.x, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), cursorPos.y, false ) ); SetStatusText( line, 2 ); line.Printf( "dx %s dy %s dist %s", - MessageTextFromValue( GetUserUnits(), d.x, false ), - MessageTextFromValue( GetUserUnits(), d.y, false ), - MessageTextFromValue( GetUserUnits(), hypot( d.x, d.y ), false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), d.x, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), d.y, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + hypot( d.x, d.y ), false ) ); SetStatusText( line, 3 ); DisplayGridMsg(); diff --git a/eeschema/sch_bitmap.cpp b/eeschema/sch_bitmap.cpp index 35afd266a8..aaf94307a8 100644 --- a/eeschema/sch_bitmap.cpp +++ b/eeschema/sch_bitmap.cpp @@ -204,8 +204,8 @@ void SCH_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), GetSize().x ) ); - aList.emplace_back( _( "Height" ), MessageTextFromValue( aFrame->GetUserUnits(), GetSize().y ) ); + aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetSize().x ) ); + aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetSize().y ) ); } diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index da7e6556e6..9a178d2b57 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -59,7 +59,7 @@ SCH_FIELD::SCH_FIELD( const VECTOR2I& aPos, int aFieldId, SCH_ITEM* aParent, const wxString& aName ) : SCH_ITEM( aParent, SCH_FIELD_T ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ), wxEmptyString ), + EDA_TEXT( schIUScale, wxEmptyString ), m_id( 0 ), m_name( aName ), m_showName( false ), @@ -725,7 +725,7 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), + aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetTextWidth() ) ); switch ( GetHorizJustify() ) diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index d79d1153a0..33865fc64c 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -853,7 +853,7 @@ void SCH_LABEL_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), + aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetTextWidth() ) ); switch( GetTextSpinStyle() ) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 638d96d3df..7face83abb 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -724,7 +724,7 @@ wxString SCH_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const } return wxString::Format( txtfmt, - MessageTextFromValue( aUnits, EuclideanNorm( m_start - m_end ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, EuclideanNorm( m_start - m_end ) ) ); } @@ -897,7 +897,7 @@ void SCH_LINE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), aList, true, false ); + m_stroke.GetMsgPanelInfo( schIUScale, aFrame->GetUserUnits(), aList, true, false ); SCH_CONNECTION* conn = nullptr; diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 560197a48a..1cd34d8156 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -222,7 +222,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetPinNameOffset() != Mils2iu( DEFAULT_PIN_NAME_OFFSET ) ) aFormatter.Print( 0, " (offset %s)", - FormatInternalUnits( aSymbol->GetPinNameOffset() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSymbol->GetPinNameOffset() ).c_str() ); if( !aSymbol->ShowPinNames() ) aFormatter.Print( 0, " hide" ); @@ -402,8 +402,8 @@ void SCH_SEXPR_PLUGIN_CACHE::saveField( LIB_FIELD* aField, OUTPUTFORMATTER& aFor aFormatter.Quotew( fieldName ).c_str(), aFormatter.Quotew( aField->GetText() ).c_str(), aField->GetId(), - FormatInternalUnits( aField->GetPosition().x ).c_str(), - FormatInternalUnits( aField->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aField->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aField->GetPosition().y ).c_str(), aField->GetTextAngle().AsDegrees() ); if( aField->IsNameShown() ) @@ -427,10 +427,10 @@ void SCH_SEXPR_PLUGIN_CACHE::savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter aFormatter.Print( aNestLevel, "(pin %s %s (at %s %s %s) (length %s)", getPinElectricalTypeToken( aPin->GetType() ), getPinShapeToken( aPin->GetShape() ), - FormatInternalUnits( aPin->GetPosition().x ).c_str(), - FormatInternalUnits( aPin->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( getPinAngle( aPin->GetOrientation() ) ).c_str(), - FormatInternalUnits( aPin->GetLength() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetLength() ).c_str() ); if( !aPin->IsVisible() ) aFormatter.Print( 0, " hide\n" ); @@ -440,13 +440,13 @@ void SCH_SEXPR_PLUGIN_CACHE::savePin( LIB_PIN* aPin, OUTPUTFORMATTER& aFormatter // This follows the EDA_TEXT effects formatting for future expansion. aFormatter.Print( aNestLevel + 1, "(name %s (effects (font (size %s %s))))\n", aFormatter.Quotew( aPin->GetName() ).c_str(), - FormatInternalUnits( aPin->GetNameTextSize() ).c_str(), - FormatInternalUnits( aPin->GetNameTextSize() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetNameTextSize() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetNameTextSize() ).c_str() ); aFormatter.Print( aNestLevel + 1, "(number %s (effects (font (size %s %s))))\n", aFormatter.Quotew( aPin->GetNumber() ).c_str(), - FormatInternalUnits( aPin->GetNumberTextSize() ).c_str(), - FormatInternalUnits( aPin->GetNumberTextSize() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetNumberTextSize() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aPin->GetNumberTextSize() ).c_str() ); for( const std::pair& alt : aPin->GetAlternates() ) @@ -469,8 +469,8 @@ void SCH_SEXPR_PLUGIN_CACHE::saveText( LIB_TEXT* aText, OUTPUTFORMATTER& aFormat aFormatter.Print( aNestLevel, "(text%s %s (at %s %s %g)\n", aText->IsPrivate() ? " private" : "", aFormatter.Quotew( aText->GetText() ).c_str(), - FormatInternalUnits( aText->GetPosition().x ).c_str(), - FormatInternalUnits( aText->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().y ).c_str(), (double) aText->GetTextAngle().AsTenthsOfADegree() ); aText->EDA_TEXT::Format( &aFormatter, aNestLevel, 0 ); @@ -491,13 +491,13 @@ void SCH_SEXPR_PLUGIN_CACHE::saveTextBox( LIB_TEXTBOX* aTextBox, OUTPUTFORMATTER VECTOR2I size = aTextBox->GetEnd() - pos; aFormatter.Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n", - FormatInternalUnits( pos.x ).c_str(), - FormatInternalUnits( pos.y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(), EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(), - FormatInternalUnits( size.x ).c_str(), - FormatInternalUnits( size.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str() ); - aTextBox->GetStroke().Format( &aFormatter, aNestLevel + 1 ); + aTextBox->GetStroke().Format( &aFormatter, schIUScale, aNestLevel + 1 ); aFormatter.Print( 0, "\n" ); formatFill( &aFormatter, aNestLevel + 1, aTextBox->GetFillMode(), aTextBox->GetFillColor() ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 97d661ef85..cd1a5bc6f0 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -686,8 +686,8 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aSheetPa m_out->Print( 0, " (lib_id %s) (at %s %s %s)", m_out->Quotew( aSymbol->GetLibId().Format().wx_str() ).c_str(), - FormatInternalUnits( aSymbol->GetPosition().x ).c_str(), - FormatInternalUnits( aSymbol->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSymbol->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSymbol->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( angle ).c_str() ); bool mirrorX = aSymbol->GetOrientation() & SYM_MIRROR_X; @@ -833,8 +833,8 @@ void SCH_SEXPR_PLUGIN::saveField( SCH_FIELD* aField, int aNestLevel ) m_out->Quotew( fieldName ).c_str(), m_out->Quotew( aField->GetText() ).c_str(), aField->GetId(), - FormatInternalUnits( aField->GetPosition().x ).c_str(), - FormatInternalUnits( aField->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aField->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aField->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( aField->GetTextAngle() ).c_str() ); if( aField->IsNameShown() ) @@ -863,8 +863,8 @@ void SCH_SEXPR_PLUGIN::saveBitmap( SCH_BITMAP* aBitmap, int aNestLevel ) wxCHECK_RET( image != nullptr, "wxImage* is NULL" ); m_out->Print( aNestLevel, "(image (at %s %s)", - FormatInternalUnits( aBitmap->GetPosition().x ).c_str(), - FormatInternalUnits( aBitmap->GetPosition().y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBitmap->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBitmap->GetPosition().y ).c_str() ); if( aBitmap->GetImage()->GetScale() != 1.0 ) m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() ); @@ -907,10 +907,10 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel ) wxCHECK_RET( aSheet != nullptr && m_out != nullptr, "" ); m_out->Print( aNestLevel, "(sheet (at %s %s) (size %s %s)", - FormatInternalUnits( aSheet->GetPosition().x ).c_str(), - FormatInternalUnits( aSheet->GetPosition().y ).c_str(), - FormatInternalUnits( aSheet->GetSize().GetWidth() ).c_str(), - FormatInternalUnits( aSheet->GetSize().GetHeight() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSheet->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSheet->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSheet->GetSize().GetWidth() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aSheet->GetSize().GetHeight() ).c_str() ); if( aSheet->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO ) m_out->Print( 0, " (fields_autoplaced)" ); @@ -921,7 +921,7 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel ) aSheet->GetBorderColor() ); stroke.SetWidth( aSheet->GetBorderWidth() ); - stroke.Format( m_out, aNestLevel + 1 ); + stroke.Format( m_out, schIUScale, aNestLevel + 1 ); m_out->Print( 0, "\n" ); @@ -945,8 +945,8 @@ void SCH_SEXPR_PLUGIN::saveSheet( SCH_SHEET* aSheet, int aNestLevel ) m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)\n", EscapedUTF8( pin->GetText() ).c_str(), getSheetPinShapeToken( pin->GetShape() ), - FormatInternalUnits( pin->GetPosition().x ).c_str(), - FormatInternalUnits( pin->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pin->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pin->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( getSheetPinAngle( pin->GetSide() ) ).c_str() ); pin->Format( m_out, aNestLevel + 1, 0 ); @@ -965,9 +965,9 @@ void SCH_SEXPR_PLUGIN::saveJunction( SCH_JUNCTION* aJunction, int aNestLevel ) wxCHECK_RET( aJunction != nullptr && m_out != nullptr, "" ); m_out->Print( aNestLevel, "(junction (at %s %s) (diameter %s) (color %d %d %d %s)\n", - FormatInternalUnits( aJunction->GetPosition().x ).c_str(), - FormatInternalUnits( aJunction->GetPosition().y ).c_str(), - FormatInternalUnits( aJunction->GetDiameter() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aJunction->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aJunction->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aJunction->GetDiameter() ).c_str(), KiROUND( aJunction->GetColor().r * 255.0 ), KiROUND( aJunction->GetColor().g * 255.0 ), KiROUND( aJunction->GetColor().b * 255.0 ), @@ -984,8 +984,8 @@ void SCH_SEXPR_PLUGIN::saveNoConnect( SCH_NO_CONNECT* aNoConnect, int aNestLevel wxCHECK_RET( aNoConnect != nullptr && m_out != nullptr, "" ); m_out->Print( aNestLevel, "(no_connect (at %s %s) (uuid %s))\n", - FormatInternalUnits( aNoConnect->GetPosition().x ).c_str(), - FormatInternalUnits( aNoConnect->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aNoConnect->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aNoConnect->GetPosition().y ).c_str(), TO_UTF8( aNoConnect->m_Uuid.AsString() ) ); } @@ -1005,12 +1005,12 @@ void SCH_SEXPR_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry, int aNestLev else { m_out->Print( aNestLevel, "(bus_entry (at %s %s) (size %s %s)\n", - FormatInternalUnits( aBusEntry->GetPosition().x ).c_str(), - FormatInternalUnits( aBusEntry->GetPosition().y ).c_str(), - FormatInternalUnits( aBusEntry->GetSize().GetWidth() ).c_str(), - FormatInternalUnits( aBusEntry->GetSize().GetHeight() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBusEntry->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBusEntry->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBusEntry->GetSize().GetWidth() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aBusEntry->GetSize().GetHeight() ).c_str() ); - aBusEntry->GetStroke().Format( m_out, aNestLevel + 1 ); + aBusEntry->GetStroke().Format( m_out, schIUScale, aNestLevel + 1 ); m_out->Print( 0, "\n" ); @@ -1077,12 +1077,12 @@ void SCH_SEXPR_PLUGIN::saveLine( SCH_LINE* aLine, int aNestLevel ) m_out->Print( aNestLevel, "(%s (pts (xy %s %s) (xy %s %s))\n", TO_UTF8( lineType ), - FormatInternalUnits( aLine->GetStartPoint().x ).c_str(), - FormatInternalUnits( aLine->GetStartPoint().y ).c_str(), - FormatInternalUnits( aLine->GetEndPoint().x ).c_str(), - FormatInternalUnits( aLine->GetEndPoint().y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aLine->GetStartPoint().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aLine->GetStartPoint().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aLine->GetEndPoint().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aLine->GetEndPoint().y ).c_str() ); - line_stroke.Format( m_out, aNestLevel + 1 ); + line_stroke.Format( m_out, schIUScale, aNestLevel + 1 ); m_out->Print( 0, "\n" ); m_out->Print( aNestLevel + 1, "(uuid %s)\n", TO_UTF8( aLine->m_Uuid.AsString() ) ); @@ -1107,7 +1107,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) SCH_DIRECTIVE_LABEL* flag = static_cast( aText ); m_out->Print( 0, " (length %s)", - FormatInternalUnits( flag->GetPinLength() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, flag->GetPinLength() ).c_str() ); } EDA_ANGLE angle = aText->GetTextAngle(); @@ -1136,16 +1136,16 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel ) if( aText->GetText().Length() < 50 ) { m_out->Print( 0, " (at %s %s %s)", - FormatInternalUnits( aText->GetPosition().x ).c_str(), - FormatInternalUnits( aText->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( angle ).c_str() ); } else { m_out->Print( 0, "\n" ); m_out->Print( aNestLevel + 1, "(at %s %s %s)", - FormatInternalUnits( aText->GetPosition().x ).c_str(), - FormatInternalUnits( aText->GetPosition().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aText->GetPosition().y ).c_str(), EDA_UNIT_UTILS::FormatAngle( angle ).c_str() ); } @@ -1178,13 +1178,13 @@ void SCH_SEXPR_PLUGIN::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel ) VECTOR2I size = aTextBox->GetEnd() - pos; m_out->Print( aNestLevel + 1, "(at %s %s %s) (size %s %s)\n", - FormatInternalUnits( pos.x ).c_str(), - FormatInternalUnits( pos.y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pos.y ).c_str(), EDA_UNIT_UTILS::FormatAngle( aTextBox->GetTextAngle() ).c_str(), - FormatInternalUnits( size.x ).c_str(), - FormatInternalUnits( size.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, size.y ).c_str() ); - aTextBox->GetStroke().Format( m_out, aNestLevel + 1 ); + aTextBox->GetStroke().Format( m_out, schIUScale, aNestLevel + 1 ); m_out->Print( 0, "\n" ); formatFill( m_out, aNestLevel + 1, aTextBox->GetFillMode(), aTextBox->GetFillColor() ); m_out->Print( 0, "\n" ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp index 0fdf1c3679..e08b222f1b 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin_common.cpp @@ -214,11 +214,11 @@ void formatArc( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aArc, { aFormatter->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s)\n", aIsPrivate ? " private" : "", - FormatInternalUnits( aArc->GetStart() ).c_str(), - FormatInternalUnits( aArc->GetArcMid() ).c_str(), - FormatInternalUnits( aArc->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aArc->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aArc->GetArcMid() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aArc->GetEnd() ).c_str() ); - aStroke.Format( aFormatter, aNestLevel + 1 ); + aStroke.Format( aFormatter, schIUScale, aNestLevel + 1 ); aFormatter->Print( 0, "\n" ); formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor ); aFormatter->Print( 0, "\n" ); @@ -236,11 +236,11 @@ void formatCircle( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aCirc { aFormatter->Print( aNestLevel, "(circle%s (center %s %s) (radius %s)\n", aIsPrivate ? " private" : "", - FormatInternalUnits( aCircle->GetStart().x ).c_str(), - FormatInternalUnits( aCircle->GetStart().y ).c_str(), - FormatInternalUnits( aCircle->GetRadius() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aCircle->GetStart().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aCircle->GetStart().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aCircle->GetRadius() ).c_str() ); - aStroke.Format( aFormatter, aNestLevel + 1 ); + aStroke.Format( aFormatter, schIUScale, aNestLevel + 1 ); aFormatter->Print( 0, "\n" ); formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor ); aFormatter->Print( 0, "\n" ); @@ -258,11 +258,11 @@ void formatRect( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aRect, { aFormatter->Print( aNestLevel, "(rectangle%s (start %s %s) (end %s %s)\n", aIsPrivate ? " private" : "", - FormatInternalUnits( aRect->GetStart().x ).c_str(), - FormatInternalUnits( aRect->GetStart().y ).c_str(), - FormatInternalUnits( aRect->GetEnd().x ).c_str(), - FormatInternalUnits( aRect->GetEnd().y ).c_str() ); - aStroke.Format( aFormatter, aNestLevel + 1 ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aRect->GetStart().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aRect->GetStart().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aRect->GetEnd().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, aRect->GetEnd().y ).c_str() ); + aStroke.Format( aFormatter, schIUScale, aNestLevel + 1 ); aFormatter->Print( 0, "\n" ); formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor ); aFormatter->Print( 0, "\n" ); @@ -285,13 +285,13 @@ void formatBezier( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aBezi aBezier->GetBezierC2(), aBezier->GetEnd() } ) { aFormatter->Print( 0, " (xy %s %s)", - FormatInternalUnits( pt.x ).c_str(), - FormatInternalUnits( pt.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.y ).c_str() ); } aFormatter->Print( 0, ")\n" ); // Closes pts token on same line. - aStroke.Format( aFormatter, aNestLevel + 1 ); + aStroke.Format( aFormatter, schIUScale, aNestLevel + 1 ); aFormatter->Print( 0, "\n" ); formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor ); aFormatter->Print( 0, "\n" ); @@ -319,16 +319,16 @@ void formatPoly( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aPolyLi { aFormatter->Print( 0, "\n" ); aFormatter->Print( aNestLevel + 2, "(xy %s %s)", - FormatInternalUnits( pt.x ).c_str(), - FormatInternalUnits( pt.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.y ).c_str() ); newLine = 0; lineCount += 1; } else { aFormatter->Print( 0, " (xy %s %s)", - FormatInternalUnits( pt.x ).c_str(), - FormatInternalUnits( pt.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( schIUScale, pt.y ).c_str() ); } newLine += 1; @@ -344,7 +344,7 @@ void formatPoly( OUTPUTFORMATTER* aFormatter, int aNestLevel, EDA_SHAPE* aPolyLi aFormatter->Print( aNestLevel + 1, ")\n" ); // Closes pts token with multiple lines. } - aStroke.Format( aFormatter, aNestLevel + 1 ); + aStroke.Format( aFormatter, schIUScale, aNestLevel + 1 ); aFormatter->Print( 0, "\n" ); formatFill( aFormatter, aNestLevel + 1, aFillMode, aFillColor ); aFormatter->Print( 0, "\n" ); diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index de09937afd..1ffc09c982 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -374,16 +374,16 @@ wxString SCH_SHAPE::GetSelectMenuText( EDA_UNITS aUnits ) const { case SHAPE_T::ARC: return wxString::Format( _( "Arc, radius %s" ), - MessageTextFromValue( aUnits, GetRadius() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, GetRadius() ) ); case SHAPE_T::CIRCLE: return wxString::Format( _( "Circle, radius %s" ), - MessageTextFromValue( aUnits, GetRadius() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, GetRadius() ) ); case SHAPE_T::RECT: return wxString::Format( _( "Rectangle, width %s height %s" ), - MessageTextFromValue( aUnits, std::abs( m_start.x - m_end.x ) ), - MessageTextFromValue( aUnits, std::abs( m_start.y - m_end.y ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, std::abs( m_start.x - m_end.x ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, std::abs( m_start.y - m_end.y ) ) ); case SHAPE_T::POLY: return wxString::Format( _( "Polyline, %d points" ), diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 448731a04a..26dd0d1890 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -114,7 +114,7 @@ TEXT_SPIN_STYLE TEXT_SPIN_STYLE::MirrorY() SCH_TEXT::SCH_TEXT( const VECTOR2I& pos, const wxString& text, KICAD_T aType ) : SCH_ITEM( nullptr, aType ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ), text ) + EDA_TEXT( schIUScale, text ) { m_layer = LAYER_NOTES; @@ -498,7 +498,7 @@ void SCH_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), + aList.emplace_back( _( "Text Size" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aFrame->GetUserUnits(), GetTextWidth() ) ); switch( GetTextSpinStyle() ) diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index ed851787bd..51e745fabe 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -45,7 +45,7 @@ using KIGFX::SCH_RENDER_SETTINGS; SCH_TEXTBOX::SCH_TEXTBOX( int aLineWidth, FILL_T aFillType, const wxString& text ) : SCH_SHAPE( SHAPE_T::RECT, aLineWidth, aFillType, SCH_TEXTBOX_T ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ), text ) + EDA_TEXT( schIUScale, text ) { m_layer = LAYER_NOTES; @@ -446,13 +446,13 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aMessages, " of converted." ), next->GetNumber(), nextName, - MessageTextFromValue( aDisplayUnits, next->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -next->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ), pin->GetNumber(), pin->GetName(), - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -130,12 +130,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in units %s and %s of converted." ), next->GetNumber(), nextName, - MessageTextFromValue( aDisplayUnits, next->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -next->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), aSymbol->GetUnitReference( next->GetUnit() ), aSymbol->GetUnitReference( pin->GetUnit() ) ); } @@ -148,12 +148,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " conflicts with pin %s%s at location (%s, %s)." ), next->GetNumber(), nextName, - MessageTextFromValue( aDisplayUnits, next->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -next->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -162,12 +162,12 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in units %s and %s." ), next->GetNumber(), nextName, - MessageTextFromValue( aDisplayUnits, next->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -next->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, next->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -next->GetPosition().y ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), aSymbol->GetUnitReference( next->GetUnit() ), aSymbol->GetUnitReference( pin->GetUnit() ) ); } @@ -242,8 +242,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " of converted." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -251,8 +251,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in unit %c of converted." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1 ); } } @@ -263,8 +263,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, msg.Printf( _( "Info: Hidden power pin %s %s at location (%s, %s)." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -272,8 +272,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in unit %c." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1 ); } } @@ -296,8 +296,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " of converted." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -305,8 +305,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in unit %c of converted." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1 ); } } @@ -317,8 +317,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, msg.Printf( _( "Off grid pin %s %s at location (%s, %s)." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ) ); } else { @@ -326,8 +326,8 @@ void CheckLibSymbol( LIB_SYMBOL* aSymbol, std::vector& aMessages, " in unit %c." ), pin->GetNumber(), pinName, - MessageTextFromValue( aDisplayUnits, pin->GetPosition().x ), - MessageTextFromValue( aDisplayUnits, -pin->GetPosition().y ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, pin->GetPosition().x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aDisplayUnits, -pin->GetPosition().y ), 'A' + pin->GetUnit() - 1 ); } } diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 5978633342..97d81b4d7a 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -73,7 +73,6 @@ set( GERBVIEW_SRCS ) set( GERBVIEW_EXTRA_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ${CMAKE_SOURCE_DIR}/common/widgets/layer_box_selector.cpp ${CMAKE_SOURCE_DIR}/common/lset.cpp ) diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 76adb2ea53..1684fce397 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -661,10 +661,10 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), m_Start.x ); - auto yStart = To_User_Unit( aFrame->GetUserUnits(), m_Start.y ); - auto xEnd = To_User_Unit( aFrame->GetUserUnits(), m_End.x ); - auto yEnd = To_User_Unit( aFrame->GetUserUnits(), m_End.y ); + auto xStart = EDA_UNIT_UTILS::UI::ToUserUnit( gerbIUScale, aFrame->GetUserUnits(), m_Start.x ); + auto yStart = EDA_UNIT_UTILS::UI::ToUserUnit( gerbIUScale, aFrame->GetUserUnits(), m_Start.y ); + auto xEnd = EDA_UNIT_UTILS::UI::ToUserUnit( gerbIUScale, aFrame->GetUserUnits(), m_End.x ); + auto yEnd = EDA_UNIT_UTILS::UI::ToUserUnit( gerbIUScale, aFrame->GetUserUnits(), m_End.y ); if( m_Flashed ) { diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index ff1a54fe1d..e64e74f574 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -58,7 +58,8 @@ GERBVIEW_FRAME::GERBVIEW_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_DRAW_FRAME( aKiway, aParent, FRAME_GERBER, wxT( "GerbView" ), wxDefaultPosition, - wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME ), + wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, GERBVIEW_FRAME_NAME, + gerbIUScale ), m_TextInfo( nullptr ), m_zipFileHistory( DEFAULT_FILE_HISTORY_SIZE, ID_GERBVIEW_ZIP_FILE1, ID_GERBVIEW_ZIP_FILE_LIST_CLEAR, _( "Clear Recent Zip Files" ) ), @@ -899,8 +900,10 @@ void GERBVIEW_FRAME::DisplayGridMsg() wxString line; line.Printf( wxT( "grid X %s Y %s" ), - MessageTextFromValue( m_userUnits, gridSize.x, false ), - MessageTextFromValue( m_userUnits, gridSize.y, false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), m_userUnits, gridSize.x, + false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), m_userUnits, gridSize.y, + false ) ); SetStatusText( line, 4 ); SetStatusText( line, 4 ); @@ -924,16 +927,18 @@ void GERBVIEW_FRAME::UpdateStatusBar() double ro = hypot( v.x, v.y ); line.Printf( wxT( "r %s theta %s" ), - MessageTextFromValue( GetUserUnits(), ro, false ), - MessageTextFromValue( EDA_UNITS::DEGREES, theta.AsDegrees(), false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), ro, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), EDA_UNITS::DEGREES, theta.AsDegrees(), false ) ); SetStatusText( line, 3 ); } // Display absolute coordinates: line.Printf( wxT( "X %s Y %s" ), - MessageTextFromValue( GetUserUnits(), cursorPos.x, false ), - MessageTextFromValue( GetUserUnits(), cursorPos.y, false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + cursorPos.x, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + cursorPos.y, false ) ); SetStatusText( line, 2 ); if( !GetShowPolarCoords() ) @@ -943,9 +948,12 @@ void GERBVIEW_FRAME::UpdateStatusBar() double dYpos = cursorPos.y - GetScreen()->m_LocalOrigin.y; line.Printf( wxT( "dx %s dy %s dist %s" ), - MessageTextFromValue( GetUserUnits(), dXpos, false ), - MessageTextFromValue( GetUserUnits(), dYpos, false ), - MessageTextFromValue( GetUserUnits(), hypot( dXpos, dYpos ), false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), dXpos, + false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), dYpos, + false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + hypot( dXpos, dYpos ), false ) ); SetStatusText( line, 3 ); } diff --git a/gerbview/tools/gerbview_inspection_tool.cpp b/gerbview/tools/gerbview_inspection_tool.cpp index 85380da3f5..fb57cf0ba6 100644 --- a/gerbview/tools/gerbview_inspection_tool.cpp +++ b/gerbview/tools/gerbview_inspection_tool.cpp @@ -205,7 +205,7 @@ int GERBVIEW_INSPECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) bool originSet = false; TWO_POINT_GEOMETRY_MANAGER twoPtMgr; EDA_UNITS units = m_frame->GetUserUnits(); - KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units, false, false ); + KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, gerbIUScale, units, false, false ); std::string tool = *aEvent.GetCommandStr(); m_frame->PushTool( tool ); diff --git a/include/base_units.h b/include/base_units.h index d30dff9506..c53d755561 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -48,117 +48,6 @@ #define INDETERMINATE_STATE _( "-- mixed values --" ) #define INDETERMINATE_ACTION _( "-- leave unchanged --" ) -/** - * Function To_User_Unit - * convert \a aValue in internal units to the appropriate user units defined by \a aUnit. - * - * @return The converted value, in double - * @param aUnit The units to convert \a aValue to. - * @param aValue The value in internal units to convert. - */ -double To_User_Unit( EDA_UNITS aUnit, double aValue ); - -/** - * Function MessageTextFromValue - * is a helper to convert the \a double length \a aValue to a string in inches, - * millimeters, or unscaled units. - * - * Should be used only to display a coordinate in status, but not in dialogs, - * files, etc., because the mantissa of the number displayed has 4 digits max - * for readability. The actual internal value could need up to 8 digits to be - * printed. - * - * Use StringFromValue() instead where precision matters. - * - * @param aUnits The units to show the value in. The unit string is added to the - * message text. - * @param aValue The double value to convert. - * @param aAddUnitLabel If true, adds the unit label to the end of the string - * @param aType Type of the unit being used (e.g. distance, area, etc.) - * @return The converted string for display in user interface elements. - */ -wxString MessageTextFromValue( EDA_UNITS aUnits, double aValue, bool aAddUnitLabel = true, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -wxString MessageTextFromValue( EDA_UNITS aUnits, int aValue, bool aAddUnitLabel = true, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -wxString MessageTextFromValue( EDA_UNITS aUnits, long long int aValue, bool aAddUnitLabel = true, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel = true ); - -/** - * Function StringFromValue - * returns the string from \a aValue according to units (inch, mm ...) for display, - * and the initial unit for value. - * - * For readability, the mantissa has 3 or more digits (max 8 digits), - * the trailing 0 are removed if the mantissa has more than 3 digits - * and some trailing 0 - * This function should be used to display values in dialogs because a value - * entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa - * if displayed in inch to avoid truncation or rounding made just by the printf function. - * otherwise the actual value is rounded when read from dialog and converted - * in internal units, and therefore modified. - * - * @param aUnit = display units (INCHES, MILLIMETRE ..) - * @param aValue = value in Internal_Unit - * @param aAddUnitSymbol = true to add symbol unit to the string value - * @return A wxString object containing value and optionally the symbol unit (like 2.000 mm) - */ -wxString StringFromValue( EDA_UNITS aUnit, double aValue, bool aAddUnitSymbol = false, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -/** - * Return in internal units the value "val" given in a real unit - * such as "in", "mm" or "deg" - */ -double From_User_Unit( EDA_UNITS aUnit, double aValue ); - - -/** - * Function DoubleValueFromString - * converts \a aTextValue to a double - * @warning This utilizes the current locale and will break if decimal formats differ - * - * @param aUnits The units of \a aTextValue. - * @param aTextValue A reference to a wxString object containing the string to convert. - * @return A double representing that value in internal units - */ -double DoubleValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -/** - * Function ValueFromString - * converts \a aTextValue in \a aUnits to internal units used by the application. - * @warning This utilizes the current locale and will break if decimal formats differ - * - * @param aUnits The units of \a aTextValue. - * @param aTextValue A reference to a wxString object containing the string to convert. - * @return The string from Value, according to units (inch, mm ...) for display, - */ -long long int ValueFromString( EDA_UNITS aUnits, const wxString& aTextValue, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); - -/** - * Function FormatInternalUnits - * converts \a aValue from internal units to a string appropriate for writing - * to file. - * - * @note Internal units for board items can be either deci-mils or nanometers depending - * on how KiCad is built. - * - * @param aValue A coordinate value to convert. - * @return A std::string object containing the converted value. - */ -std::string FormatInternalUnits( int aValue ); - -std::string FormatInternalUnits( const wxPoint& aPoint ); - -std::string FormatInternalUnits( const wxSize& aSize ); - -std::string FormatInternalUnits( const VECTOR2I& aPoint ); #endif // _BASE_UNITS_H_ diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index 8deae5e958..7b6d87d308 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -71,6 +71,23 @@ constexpr double PCB_IU_PER_MM = 1e6; // Pcbnew IU is 1 nanometer. constexpr double PL_IU_PER_MM = 1e3; // internal units in micron (should be enough) constexpr double SCH_IU_PER_MM = 1e4; // Schematic internal units 1=100nm + +struct EDA_IU_SCALE +{ + const double IU_PER_MM; + const double IU_PER_MILS; + + constexpr EDA_IU_SCALE( double aIUPerMM ) : + IU_PER_MM( aIUPerMM ), IU_PER_MILS( aIUPerMM * 0.0254 ) + { + } +}; + +constexpr EDA_IU_SCALE gerbIUScale = EDA_IU_SCALE( GERB_IU_PER_MM ); +constexpr EDA_IU_SCALE pcbIUScale = EDA_IU_SCALE( PCB_IU_PER_MM ); +constexpr EDA_IU_SCALE drawSheetIUScale = EDA_IU_SCALE( PL_IU_PER_MM ); +constexpr EDA_IU_SCALE schIUScale = EDA_IU_SCALE( SCH_IU_PER_MM ); + /// Scaling factor to convert mils to internal units. #if defined(PCBNEW) || defined(CVPCB) constexpr double IU_PER_MM = PCB_IU_PER_MM; diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h index ea577962cf..d216b07435 100644 --- a/include/drawing_sheet/ds_draw_item.h +++ b/include/drawing_sheet/ds_draw_item.h @@ -306,7 +306,7 @@ public: bool aItalic = false, bool aBold = false, const KIGFX::COLOR4D& aColor = KIGFX::COLOR4D::UNSPECIFIED ) : DS_DRAW_ITEM_BASE( aPeer, aIndex, WSG_TEXT_T), - EDA_TEXT( 0, aText ) + EDA_TEXT( drawSheetIUScale, aText ) { SetTextPos( aPos ); SetTextSize( aSize ); diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index fe8ce6eb0f..897e1cbb79 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -73,7 +73,7 @@ class EDA_DRAW_FRAME : public KIWAY_PLAYER public: EDA_DRAW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, - const wxString& aFrameName ); + const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ); ~EDA_DRAW_FRAME(); @@ -450,6 +450,8 @@ public: */ void ShowChangedLanguage() override; + const EDA_IU_SCALE& GetIuScale() const { return m_iuScale; } + DECLARE_EVENT_TABLE() protected: @@ -523,6 +525,7 @@ protected: private: BASE_SCREEN* m_currentScreen; ///< current used SCREEN EDA_DRAW_PANEL_GAL* m_canvas; + const EDA_IU_SCALE& m_iuScale; ///< This the frame's interface to setting GAL display options. KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions; diff --git a/include/eda_text.h b/include/eda_text.h index dfdc7c820f..770d85d3ed 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -71,7 +71,7 @@ using KIGFX::COLOR4D; class EDA_TEXT { public: - EDA_TEXT( int aDefaultSizeIu, const wxString& aText = wxEmptyString ); + EDA_TEXT( const EDA_IU_SCALE& aIuScale, const wxString& aText = wxEmptyString ); EDA_TEXT( const EDA_TEXT& aText ); @@ -378,6 +378,8 @@ private: wxString m_shown_text; // Cache of unescaped text for efficient access bool m_shown_text_has_text_var_refs; + std::reference_wrapper m_IuScale; + mutable wxString m_render_cache_text; mutable EDA_ANGLE m_render_cache_angle; mutable VECTOR2I m_render_cache_offset; diff --git a/include/eda_units.h b/include/eda_units.h index b8d6a520e0..afc75f7485 100644 --- a/include/eda_units.h +++ b/include/eda_units.h @@ -27,6 +27,7 @@ #include #include +#include /** * The type of unit. @@ -87,6 +88,133 @@ namespace EDA_UNIT_UTILS * @return std::string object containing the converted angle. */ std::string FormatAngle( const EDA_ANGLE& aAngle ); + + /** + * Converts \a aValue from internal units to a string appropriate for writing + * to file. + * + * @note Internal units for board items can be either deci-mils or nanometers depending + * on how KiCad is built. + * + * @param aValue A coordinate value to convert. + * @return A std::string object containing the converted value. + */ + std::string FormatInternalUnits( const EDA_IU_SCALE& aIuScale, int aValue ); + std::string FormatInternalUnits( const EDA_IU_SCALE& aIuScale, const wxPoint& aPoint ); + std::string FormatInternalUnits( const EDA_IU_SCALE& aIuScale, const wxSize& aSize ); + std::string FormatInternalUnits( const EDA_IU_SCALE& aIuScale, const VECTOR2I& aPoint ); + + constexpr inline int Mils2IU( const EDA_IU_SCALE& aIuScale, int mils ) + { + double x = mils * aIuScale.IU_PER_MILS; + return int( x < 0 ? x - 0.5 : x + 0.5 ); + } + + namespace UI + { + /** + * Function To_User_Unit + * convert \a aValue in internal units to the appropriate user units defined by \a aUnit. + * + * @return The converted value, in double + * @param aUnit The units to convert \a aValue to. + * @param aValue The value in internal units to convert. + */ + double ToUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit, double aValue ); + + /** + * Function StringFromValue + * returns the string from \a aValue according to units (inch, mm ...) for display, + * and the initial unit for value. + * + * For readability, the mantissa has 3 or more digits (max 8 digits), + * the trailing 0 are removed if the mantissa has more than 3 digits + * and some trailing 0 + * This function should be used to display values in dialogs because a value + * entered in mm (for instance 2.0 mm) could need up to 8 digits mantissa + * if displayed in inch to avoid truncation or rounding made just by the printf function. + * otherwise the actual value is rounded when read from dialog and converted + * in internal units, and therefore modified. + * + * @param aUnit = display units (INCHES, MILLIMETRE ..) + * @param aValue = value in Internal_Unit + * @param aAddUnitSymbol = true to add symbol unit to the string value + * @return A wxString object containing value and optionally the symbol unit (like 2.000 mm) + */ + wxString StringFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit, double aValue, + bool aAddUnitSymbol = false, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + /** + * Function MessageTextFromValue + * is a helper to convert the \a double length \a aValue to a string in inches, + * millimeters, or unscaled units. + * + * Should be used only to display a coordinate in status, but not in dialogs, + * files, etc., because the mantissa of the number displayed has 4 digits max + * for readability. The actual internal value could need up to 8 digits to be + * printed. + * + * Use StringFromValue() instead where precision matters. + * + * @param aUnits The units to show the value in. The unit string is added to the + * message text. + * @param aValue The double value to convert. + * @param aAddUnitLabel If true, adds the unit label to the end of the string + * @param aType Type of the unit being used (e.g. distance, area, etc.) + * @return The converted string for display in user interface elements. + */ + wxString MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitLabel = true, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + wxString MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, int aValue, + bool aAddUnitLabel = true, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + wxString MessageTextFromValue( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, long long int aValue, + bool aAddUnitLabel = true, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + wxString MessageTextFromValue( EDA_ANGLE aValue, bool aAddUnitLabel = true ); + + + /** + * Return in internal units the value "val" given in a real unit + * such as "in", "mm" or "deg" + */ + double FromUserUnit( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnit, double aValue ); + + + /** + * Function DoubleValueFromString + * converts \a aTextValue to a double + * @warning This utilizes the current locale and will break if decimal formats differ + * + * @param aUnits The units of \a aTextValue. + * @param aTextValue A reference to a wxString object containing the string to convert. + * @return A double representing that value in internal units + */ + double DoubleValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + const wxString& aTextValue, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + double DoubleValueFromString( const wxString& aTextValue ); + + /** + * Function ValueFromString + * converts \a aTextValue in \a aUnits to internal units used by the application. + * @warning This utilizes the current locale and will break if decimal formats differ + * + * @param aUnits The units of \a aTextValue. + * @param aTextValue A reference to a wxString object containing the string to convert. + * @return The string from Value, according to units (inch, mm ...) for display, + */ + long long int ValueFromString( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + const wxString& aTextValue, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ); + + long long int ValueFromString( const wxString& aTextValue); + } } #endif \ No newline at end of file diff --git a/include/preview_items/arc_assistant.h b/include/preview_items/arc_assistant.h index 27ffa72af3..5a852fab44 100644 --- a/include/preview_items/arc_assistant.h +++ b/include/preview_items/arc_assistant.h @@ -38,7 +38,9 @@ namespace PREVIEW class ARC_ASSISTANT : public EDA_ITEM { public: - ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, EDA_UNITS aUnits ); + ARC_ASSISTANT( const ARC_GEOM_MANAGER& aManager, + const EDA_IU_SCALE& aIuScale, + EDA_UNITS aUnits ); const BOX2I ViewBBox() const override; @@ -69,6 +71,7 @@ namespace PREVIEW private: const ARC_GEOM_MANAGER& m_constructMan; + const EDA_IU_SCALE& m_iuScale; EDA_UNITS m_units; }; } // namespace PREVIEW diff --git a/include/preview_items/preview_utils.h b/include/preview_items/preview_utils.h index 8eaf0da123..ce1935c4da 100644 --- a/include/preview_items/preview_utils.h +++ b/include/preview_items/preview_utils.h @@ -54,7 +54,7 @@ double PreviewOverlayDeemphAlpha( bool aDeemph = true ); * Get a formatted string showing a dimension to a sane precision with an optional prefix and * unit suffix. */ -wxString DimensionLabel( const wxString& prefix, double aVal, EDA_UNITS aUnits, +wxString DimensionLabel( const wxString& prefix, double aVal, const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, bool aIncludeUnits = true ); /** diff --git a/include/preview_items/ruler_item.h b/include/preview_items/ruler_item.h index 4f144ab681..e15abba7e2 100644 --- a/include/preview_items/ruler_item.h +++ b/include/preview_items/ruler_item.h @@ -41,7 +41,7 @@ class TWO_POINT_GEOMETRY_MANAGER; class RULER_ITEM : public EDA_ITEM { public: - RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr, EDA_UNITS userUnits, bool aFlipX, + RULER_ITEM( const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr, const EDA_IU_SCALE& aIuScale, EDA_UNITS userUnits, bool aFlipX, bool aFlipY ); ///< @copydoc EDA_ITEM::ViewBBox() @@ -85,6 +85,7 @@ public: private: const TWO_POINT_GEOMETRY_MANAGER& m_geomMgr; EDA_UNITS m_userUnits; + const EDA_IU_SCALE& m_iuScale; bool m_flipX; bool m_flipY; }; diff --git a/include/preview_items/two_point_assistant.h b/include/preview_items/two_point_assistant.h index e14e0d427c..4946c064b4 100644 --- a/include/preview_items/two_point_assistant.h +++ b/include/preview_items/two_point_assistant.h @@ -50,8 +50,8 @@ enum class GEOM_SHAPE class TWO_POINT_ASSISTANT : public EDA_ITEM { public: - TWO_POINT_ASSISTANT( const TWO_POINT_GEOMETRY_MANAGER& aManager, EDA_UNITS aUnits, - GEOM_SHAPE aShape ); + TWO_POINT_ASSISTANT( const TWO_POINT_GEOMETRY_MANAGER& aManager, const EDA_IU_SCALE& aIuScale, + EDA_UNITS aUnits, GEOM_SHAPE aShape ); const BOX2I ViewBBox() const override; @@ -88,6 +88,7 @@ private: const TWO_POINT_GEOMETRY_MANAGER& m_constructMan; EDA_UNITS m_units; GEOM_SHAPE m_shape; + const EDA_IU_SCALE& m_iuScale; }; } // namespace PREVIEW diff --git a/include/rc_item.h b/include/rc_item.h index a27c437811..d49f094b88 100644 --- a/include/rc_item.h +++ b/include/rc_item.h @@ -129,7 +129,7 @@ public: * * @return wxString - the simple multi-line report text. */ - virtual wxString ShowReport( EDA_UNITS aUnits, SEVERITY aSeverity, + virtual wxString ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SEVERITY aSeverity, const std::map& aItemMap ) const; int GetErrorCode() const { return m_errorCode; } @@ -163,7 +163,8 @@ public: /** * Format a coordinate or position to text. */ - static wxString ShowCoord( EDA_UNITS aUnits, const VECTOR2I& aPos ); + static wxString ShowCoord( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, + const VECTOR2I& aPos ); protected: int m_errorCode; ///< The error code's numeric value diff --git a/include/stroke_params.h b/include/stroke_params.h index b9bd2ee9ec..ce274283fb 100644 --- a/include/stroke_params.h +++ b/include/stroke_params.h @@ -110,9 +110,9 @@ public: || m_color != aOther.m_color; } - void Format( OUTPUTFORMATTER* out, int nestLevel ) const; + void Format( OUTPUTFORMATTER* out, const EDA_IU_SCALE& aIuScale, int nestLevel ) const; - void GetMsgPanelInfo( EDA_UNITS aUnits, std::vector& aList, + void GetMsgPanelInfo( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, std::vector& aList, bool aIncludeStyle = true, bool aIncludeWidth = true ); // Helper functions diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index f3503686d7..0fb03fa5df 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -53,10 +53,13 @@ public: * Can be nullptr. * @param aAllowEval indicates \a aTextInput's content should be eval'ed before storing */ - UNIT_BINDER( EDA_BASE_FRAME* aParent, + UNIT_BINDER( EDA_DRAW_FRAME* aParent, wxStaticText* aLabel, wxWindow* aValueCtrl, wxStaticText* aUnitLabel, bool aAllowEval = true ); + UNIT_BINDER( EDA_BASE_FRAME* aParent, const EDA_IU_SCALE& aIUScale, wxStaticText* aLabel, wxWindow* aValueCtrl, + wxStaticText* aUnitLabel, bool aAllowEval = true ); + ~UNIT_BINDER() override; /** @@ -224,6 +227,7 @@ protected: wxStaticText* m_unitLabel; ///< Can be nullptr ///< Currently used units. + const EDA_IU_SCALE& m_iuScale; EDA_UNITS m_units; bool m_negativeZero; ///< Indicates "-0" should be displayed for 0. EDA_DATA_TYPE m_dataType; diff --git a/include/widgets/widget_save_restore.h b/include/widgets/widget_save_restore.h index 7854cc2487..5bcee8be76 100644 --- a/include/widgets/widget_save_restore.h +++ b/include/widgets/widget_save_restore.h @@ -24,6 +24,7 @@ #ifndef WIDGETS_WIDGET_SAVE_RESTORE__H #define WIDGETS_WIDGET_SAVE_RESTORE__H +#include #include class wxCheckBox; @@ -40,7 +41,7 @@ class EDA_ANGLE; class WIDGET_SAVE_RESTORE { public: - WIDGET_SAVE_RESTORE( bool& aValidFlag ) : + WIDGET_SAVE_RESTORE( const EDA_IU_SCALE& aIuScale, bool& aValidFlag ) : m_valid( aValidFlag ) { } diff --git a/pagelayout_editor/CMakeLists.txt b/pagelayout_editor/CMakeLists.txt index b3217b6253..5f503d479e 100644 --- a/pagelayout_editor/CMakeLists.txt +++ b/pagelayout_editor/CMakeLists.txt @@ -45,7 +45,6 @@ set( PL_EDITOR_SRCS ) set( PL_EDITOR_EXTRA_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ) if( WIN32 ) diff --git a/pagelayout_editor/dialogs/properties_frame.cpp b/pagelayout_editor/dialogs/properties_frame.cpp index 7f899093ce..c8096c07dc 100644 --- a/pagelayout_editor/dialogs/properties_frame.cpp +++ b/pagelayout_editor/dialogs/properties_frame.cpp @@ -148,16 +148,24 @@ void PROPERTIES_FRAME::CopyPrmsFromGeneralToPanel() DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); // Set default parameters - m_defaultLineWidth.SetDoubleValue( From_User_Unit( units, model.m_DefaultLineWidth ) ); + m_defaultLineWidth.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultLineWidth ) ); - m_defaultTextSizeX.SetDoubleValue( From_User_Unit( units, model.m_DefaultTextSize.x ) ); - m_defaultTextSizeY.SetDoubleValue( From_User_Unit( units, model.m_DefaultTextSize.y ) ); - m_defaultTextThickness.SetDoubleValue( From_User_Unit( units, model.m_DefaultTextThickness ) ); + m_defaultTextSizeX.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.x ) ); + m_defaultTextSizeY.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.m_DefaultTextSize.y ) ); + m_defaultTextThickness.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( + drawSheetIUScale,units, model.m_DefaultTextThickness ) ); - m_textLeftMargin.SetDoubleValue( From_User_Unit( units, model.GetLeftMargin() ) ); - m_textRightMargin.SetDoubleValue( From_User_Unit( units, model.GetRightMargin() ) ); - m_textTopMargin.SetDoubleValue( From_User_Unit( units, model.GetTopMargin() ) ); - m_textBottomMargin.SetDoubleValue( From_User_Unit( units, model.GetBottomMargin() ) ); + m_textLeftMargin.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetLeftMargin() ) ); + m_textRightMargin.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetRightMargin() ) ); + m_textTopMargin.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetTopMargin() ) ); + m_textBottomMargin.SetDoubleValue( + EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale,units, model.GetBottomMargin() ) ); } @@ -167,17 +175,25 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToGeneral() DS_DATA_MODEL& model = DS_DATA_MODEL::GetTheInstance(); // Import default parameters from widgets - model.m_DefaultLineWidth = To_User_Unit( units, m_defaultLineWidth.GetValue() ); + model.m_DefaultLineWidth = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_defaultLineWidth.GetValue() ); - model.m_DefaultTextSize.x = To_User_Unit( units, m_defaultTextSizeX.GetValue() ); - model.m_DefaultTextSize.y = To_User_Unit( units, m_defaultTextSizeY.GetValue() ); - model.m_DefaultTextThickness = To_User_Unit( units, m_defaultTextThickness.GetValue() ); + model.m_DefaultTextSize.x = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_defaultTextSizeX.GetValue() ); + model.m_DefaultTextSize.y = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_defaultTextSizeY.GetValue() ); + model.m_DefaultTextThickness = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_defaultTextThickness.GetValue() ); // Get page margins values - model.SetRightMargin( To_User_Unit( units, m_textRightMargin.GetValue() ) ); - model.SetBottomMargin( To_User_Unit( units, m_textBottomMargin.GetValue() ) ); - model.SetLeftMargin( To_User_Unit( units, m_textLeftMargin.GetValue() ) ); - model.SetTopMargin( To_User_Unit( units, m_textTopMargin.GetValue() ) ); + model.SetRightMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_textRightMargin.GetValue() ) ); + model.SetBottomMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_textBottomMargin.GetValue() ) ); + model.SetLeftMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_textLeftMargin.GetValue() ) ); + model.SetTopMargin( EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, + m_textTopMargin.GetValue() ) ); return true; } @@ -207,8 +223,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) } // Position/ start point - m_textPosX.SetDoubleValue( From_User_Unit( units, aItem->m_Pos.m_Pos.x ) ); - m_textPosY.SetDoubleValue( From_User_Unit( units, aItem->m_Pos.m_Pos.y ) ); + m_textPosX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_Pos.m_Pos.x ) ); + m_textPosY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_Pos.m_Pos.y ) ); switch( aItem->m_Pos.m_Anchor ) { @@ -219,8 +235,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) } // End point - m_textEndX.SetDoubleValue( From_User_Unit( units, aItem->m_End.m_Pos.x ) ); - m_textEndY.SetDoubleValue( From_User_Unit( units, aItem->m_End.m_Pos.y ) ); + m_textEndX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_End.m_Pos.x ) ); + m_textEndY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_End.m_Pos.y ) ); switch( aItem->m_End.m_Anchor ) { @@ -230,7 +246,7 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) case LT_CORNER: m_comboBoxCornerEnd->SetSelection( 1 ); break; } - m_lineWidth.SetDoubleValue( From_User_Unit( units, aItem->m_LineWidth ) ); + m_lineWidth.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_LineWidth ) ); // Now, set prms more specific to DS_DATA_ITEM types // For a given type, disable widgets which are not relevant, @@ -252,8 +268,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) m_textCtrlRotation->SetValue( msg ); // Constraints: - m_constraintX.SetDoubleValue( From_User_Unit( units, item->m_BoundingBoxSize.x ) ); - m_constraintY.SetDoubleValue( From_User_Unit( units, item->m_BoundingBoxSize.y ) ); + m_constraintX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, item->m_BoundingBoxSize.x ) ); + m_constraintY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, item->m_BoundingBoxSize.y ) ); // Font Options m_fontCtrl->SetFontSelection( item->m_Font ); @@ -284,8 +300,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) } // Text size - m_textSizeX.SetDoubleValue( From_User_Unit( units, item->m_TextSize.x ) ); - m_textSizeY.SetDoubleValue( From_User_Unit( units, item->m_TextSize.y ) ); + m_textSizeX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, item->m_TextSize.x ) ); + m_textSizeY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, item->m_TextSize.y ) ); } if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON ) @@ -338,8 +354,8 @@ void PROPERTIES_FRAME::CopyPrmsFromItemToPanel( DS_DATA_ITEM* aItem ) msg.Printf( wxT( "%d" ), aItem->m_RepeatCount ); m_textCtrlRepeatCount->SetValue( msg ); - m_textStepX.SetDoubleValue( From_User_Unit( units, aItem->m_IncrementVector.x ) ); - m_textStepY.SetDoubleValue( From_User_Unit( units, aItem->m_IncrementVector.y ) ); + m_textStepX.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_IncrementVector.x ) ); + m_textStepY.SetDoubleValue( EDA_UNIT_UTILS::UI::FromUserUnit( drawSheetIUScale, units, aItem->m_IncrementVector.y ) ); // The number of widgets was modified, so recalculate sizers m_swItemProperties->Layout(); @@ -445,11 +461,14 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) } // Import thickness - aItem->m_LineWidth = To_User_Unit( units, m_lineWidth.GetValue() ); + aItem->m_LineWidth = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_lineWidth.GetValue() ); // Import Start point - aItem->m_Pos.m_Pos.x = To_User_Unit( units, m_textPosX.GetValue() ); - aItem->m_Pos.m_Pos.y = To_User_Unit( units, m_textPosY.GetValue() ); + aItem->m_Pos.m_Pos.x = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosX.GetValue() ); + aItem->m_Pos.m_Pos.y = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textPosY.GetValue() ); switch( m_comboBoxCornerPos->GetSelection() ) { @@ -460,8 +479,10 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) } // Import End point - aItem->m_End.m_Pos.x = To_User_Unit( units, m_textEndX.GetValue() ); - aItem->m_End.m_Pos.y = To_User_Unit( units, m_textEndY.GetValue() ); + aItem->m_End.m_Pos.x = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndX.GetValue() ); + aItem->m_End.m_Pos.y = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textEndY.GetValue() ); switch( m_comboBoxCornerEnd->GetSelection() ) { @@ -477,8 +498,10 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) msg.ToLong( &itmp ); aItem->m_RepeatCount = itmp; - aItem->m_IncrementVector.x = To_User_Unit( units, m_textStepX.GetValue() ); - aItem->m_IncrementVector.y = To_User_Unit( units, m_textStepY.GetValue() ); + aItem->m_IncrementVector.x = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepX.GetValue() ); + aItem->m_IncrementVector.y = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textStepY.GetValue() ); if( aItem->GetType() == DS_DATA_ITEM::DS_TEXT ) { @@ -512,15 +535,19 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) item->m_Font = m_fontCtrl->GetFontSelection( item->m_Bold, item->m_Italic ); msg = m_textCtrlRotation->GetValue(); - item->m_Orient = DoubleValueFromString( EDA_UNITS::UNSCALED, msg ); + item->m_Orient = EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale, EDA_UNITS::UNSCALED, msg ); // Import text size - item->m_TextSize.x = To_User_Unit( units, m_textSizeX.GetValue() ); - item->m_TextSize.y = To_User_Unit( units, m_textSizeY.GetValue() ); + item->m_TextSize.x = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textSizeX.GetValue() ); + item->m_TextSize.y = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_textSizeY.GetValue() ); // Import constraints: - item->m_BoundingBoxSize.x = To_User_Unit( units, m_constraintX.GetValue() ); - item->m_BoundingBoxSize.y = To_User_Unit( units, m_constraintY.GetValue() ); + item->m_BoundingBoxSize.x = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintX.GetValue() ); + item->m_BoundingBoxSize.y = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, units, m_constraintY.GetValue() ); } if( aItem->GetType() == DS_DATA_ITEM::DS_POLYPOLYGON ) @@ -528,7 +555,8 @@ bool PROPERTIES_FRAME::CopyPrmsFromPanelToItem( DS_DATA_ITEM* aItem ) DS_DATA_ITEM_POLYGONS* item = static_cast( aItem ); msg = m_textCtrlRotation->GetValue(); - item->m_Orient = EDA_ANGLE( DoubleValueFromString( EDA_UNITS::UNSCALED, msg ), DEGREES_T ); + item->m_Orient = EDA_ANGLE( + EDA_UNIT_UTILS::UI::DoubleValueFromString( drawSheetIUScale,EDA_UNITS::UNSCALED, msg ), DEGREES_T ); } if( aItem->GetType() == DS_DATA_ITEM::DS_BITMAP ) diff --git a/pagelayout_editor/pl_editor_frame.cpp b/pagelayout_editor/pl_editor_frame.cpp index dec529aeb9..7044316803 100644 --- a/pagelayout_editor/pl_editor_frame.cpp +++ b/pagelayout_editor/pl_editor_frame.cpp @@ -82,7 +82,7 @@ END_EVENT_TABLE() PL_EDITOR_FRAME::PL_EDITOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : EDA_DRAW_FRAME( aKiway, aParent, FRAME_PL_EDITOR, wxT( "PlEditorFrame" ), wxDefaultPosition, wxDefaultSize, - KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME ), + KICAD_DEFAULT_DRAWFRAME_STYLE, PL_EDITOR_FRAME_NAME, drawSheetIUScale ), m_propertiesPagelayout( nullptr ), m_propertiesFrameWidth( 200 ), m_originSelectBox( nullptr ), @@ -672,7 +672,8 @@ void PL_EDITOR_FRAME::DisplayGridMsg() default: gridformatter = "grid %f"; break; } - double grid = To_User_Unit( m_userUnits, GetCanvas()->GetGAL()->GetGridSize().x ); + double grid = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, m_userUnits, + GetCanvas()->GetGAL()->GetGridSize().x ); line.Printf( gridformatter, grid ); SetStatusText( line, 4 ); @@ -718,8 +719,10 @@ void PL_EDITOR_FRAME::UpdateStatusBar() // Display absolute coordinates: VECTOR2D cursorPos = GetCanvas()->GetViewControls()->GetCursorPosition(); VECTOR2D coord = cursorPos - originCoord; - double dXpos = To_User_Unit( GetUserUnits(), coord.x * Xsign ); - double dYpos = To_User_Unit( GetUserUnits(), coord.y * Ysign ); + double dXpos = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), coord.x * Xsign ); + double dYpos = + EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), coord.y * Ysign ); wxString absformatter = wxT( "X %.4g Y %.4g" ); wxString locformatter = wxT( "dx %.4g dy %.4g" ); @@ -744,8 +747,8 @@ void PL_EDITOR_FRAME::UpdateStatusBar() { double dx = cursorPos.x - GetScreen()->m_LocalOrigin.x; double dy = cursorPos.y - GetScreen()->m_LocalOrigin.y; - dXpos = To_User_Unit( GetUserUnits(), dx * Xsign ); - dYpos = To_User_Unit( GetUserUnits(), dy * Ysign ); + dXpos = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), dx * Xsign ); + dYpos = EDA_UNIT_UTILS::UI::ToUserUnit( drawSheetIUScale, GetUserUnits(), dy * Ysign ); line.Printf( locformatter, dXpos, dYpos ); SetStatusText( line, 3 ); } @@ -938,10 +941,11 @@ void PL_EDITOR_FRAME::UpdateMsgPanelInfo() VECTOR2D size = GetPageSettings().GetSizeIU( IU_PER_MILS ); std::vector msgItems; - msgItems.emplace_back( _( "Page Width" ), MessageTextFromValue( GetUserUnits(), size.x ) ); + msgItems.emplace_back( _( "Page Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( + GetIuScale(), GetUserUnits(), size.x ) ); - msgItems.emplace_back( - _( "Page Height" ), MessageTextFromValue( GetUserUnits(), size.y ) ); + msgItems.emplace_back( _( "Page Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( + GetIuScale(), GetUserUnits(), size.y ) ); SetMsgPanel( msgItems ); } diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index a30f976dc6..1b58146da9 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -383,7 +383,6 @@ set( PCBNEW_SRCS # extra sources from common set( PCBNEW_COMMON_SRCS - ${CMAKE_SOURCE_DIR}/common/base_units.cpp ) set( PCBNEW_SCRIPTING_PYTHON_HELPERS diff --git a/pcbnew/board_stackup_manager/board_stackup.cpp b/pcbnew/board_stackup_manager/board_stackup.cpp index 5f1479cd80..be72524bbd 100644 --- a/pcbnew/board_stackup_manager/board_stackup.cpp +++ b/pcbnew/board_stackup_manager/board_stackup.cpp @@ -652,10 +652,10 @@ void BOARD_STACKUP::FormatBoardStackup( OUTPUTFORMATTER* aFormatter, { if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) ) aFormatter->Print( 0, " (thickness %s locked)", - FormatInternalUnits( item->GetThickness( idx ) ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, item->GetThickness( idx ) ).c_str() ); else aFormatter->Print( 0, " (thickness %s)", - FormatInternalUnits( item->GetThickness( idx ) ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, item->GetThickness( idx ) ).c_str() ); } if( item->HasMaterialValue( idx ) ) diff --git a/pcbnew/board_stackup_manager/board_stackup_reporter.cpp b/pcbnew/board_stackup_manager/board_stackup_reporter.cpp index 1489776c97..b0322e0574 100644 --- a/pcbnew/board_stackup_manager/board_stackup_reporter.cpp +++ b/pcbnew/board_stackup_manager/board_stackup_reporter.cpp @@ -91,7 +91,7 @@ wxString BuildStackupReport( BOARD_STACKUP& aStackup, EDA_UNITS aUnits ) if( item->IsThicknessEditable() ) { txt.Printf( wxT( " Thickness %s" ), - StringFromValue( aUnits, item->GetThickness( idx ), true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, item->GetThickness( idx ), true ) ); report << txt; if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && item->IsThicknessLocked( idx ) ) diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index ca93dc1004..b3ad40218e 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -166,7 +166,7 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve wxTextCtrl* textCtrl = static_cast( ui_item.m_ThicknessCtrl ); wxString txt = textCtrl->GetValue(); - int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt ); + int item_thickness = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), txt ); min_thickness += item_thickness; } @@ -180,7 +180,7 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve else { title.Printf( _( "Enter expected board thickness (min value %s):" ), - StringFromValue( m_frame->GetUserUnits(), min_thickness, true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), min_thickness, true ) ); } wxTextEntryDialog dlg( this, title, _( "Adjust Unlocked Dielectric Layers" ) ); @@ -190,12 +190,12 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve wxString result = dlg.GetValue(); - int iu_thickness = ValueFromString( m_frame->GetUserUnits(), result ); + int iu_thickness = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), result ); if( iu_thickness <= min_thickness ) { wxMessageBox( wxString::Format( _("Value too small (min value %s)." ), - StringFromValue( m_frame->GetUserUnits(), min_thickness, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), min_thickness, true ) ) ); return; } @@ -204,7 +204,7 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve if( items_candidate.size() ) { int thickness_layer = ( iu_thickness - min_thickness ) / items_candidate.size(); - wxString txt = StringFromValue( m_frame->GetUserUnits(), thickness_layer, true ); + wxString txt = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), thickness_layer, true ); for( BOARD_STACKUP_ROW_UI_ITEM* ui_item : items_candidate ) { @@ -442,11 +442,11 @@ int PANEL_SETUP_BOARD_STACKUP::computeBoardThickness() wxTextCtrl* textCtrl = static_cast( ui_item.m_ThicknessCtrl ); wxString txt = textCtrl->GetValue(); - int item_thickness = ValueFromString( m_frame->GetUserUnits(), txt ); + int item_thickness = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), txt ); thickness += item_thickness; } - wxString thicknessStr = StringFromValue( m_units, thickness, true ); + wxString thicknessStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_units, thickness, true ); // The text in the event will translate to the value for the text control // and is only updated if it changed @@ -517,7 +517,7 @@ void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync ) wxTextCtrl* textCtrl = dynamic_cast( ui_row_item.m_ThicknessCtrl ); if( textCtrl ) - textCtrl->ChangeValue( StringFromValue( m_units, + textCtrl->ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_units, item->GetThickness( sub_item ), true ) ); if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC ) @@ -763,7 +763,7 @@ BOARD_STACKUP_ROW_UI_ITEM PANEL_SETUP_BOARD_STACKUP::createRowData( int aRow, { wxTextCtrl* textCtrl = new wxTextCtrl( m_scGridWin, ID_ITEM_THICKNESS+row ); textCtrl->SetMinSize( m_numericTextCtrlSize ); - textCtrl->ChangeValue( StringFromValue( m_units, item->GetThickness( aSublayerIdx ), true ) ); + textCtrl->ChangeValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_units, item->GetThickness( aSublayerIdx ), true ) ); m_fgGridSizer->Add( textCtrl, 0, wxLEFT|wxRIGHT|wxALIGN_CENTER_VERTICAL, 2 ); m_controlItemsList.push_back( textCtrl ); textCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, @@ -1088,7 +1088,7 @@ bool PANEL_SETUP_BOARD_STACKUP::transferDataFromUIToStackup() wxTextCtrl* textCtrl = static_cast( ui_item.m_ThicknessCtrl ); txt = textCtrl->GetValue(); - int new_thickness = ValueFromString( m_frame->GetUserUnits(), txt ); + int new_thickness = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), txt ); item->SetThickness( new_thickness, sub_item ); if( new_thickness < 0 ) @@ -1409,7 +1409,7 @@ void PANEL_SETUP_BOARD_STACKUP::onThicknessChange( wxCommandEvent& event ) BOARD_STACKUP_ITEM* item = GetStackupItem( row ); int idx = GetSublayerId( row ); - item->SetThickness( ValueFromString( m_frame->GetUserUnits(), value ), idx ); + item->SetThickness( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), value ), idx ); computeBoardThickness(); } diff --git a/pcbnew/dialogs/dialog_board_reannotate.cpp b/pcbnew/dialogs/dialog_board_reannotate.cpp index 257de63c3f..38cfe2c487 100644 --- a/pcbnew/dialogs/dialog_board_reannotate.cpp +++ b/pcbnew/dialogs/dialog_board_reannotate.cpp @@ -367,8 +367,8 @@ void DIALOG_BOARD_REANNOTATE::MakeSampleText( wxString& aMessage ) "rounded to a %s, %s grid." ), fpLocation ? _( "footprint location" ) : _( "reference designator location" ), - MessageTextFromValue( m_units, m_sortGridx ), - MessageTextFromValue( m_units, m_sortGridy ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, m_sortGridx ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, m_sortGridy ) ); ShowReport( aMessage, RPT_SEVERITY_INFO ); } @@ -397,15 +397,15 @@ void DIALOG_BOARD_REANNOTATE::GetParameters() if( m_gridIndex >= ( int ) m_settings->m_Window.grid.sizes.size() ) { - m_sortGridx = DoubleValueFromString( EDA_UNITS::MILS, - m_settings->m_Window.grid.user_grid_x ); - m_sortGridy = DoubleValueFromString( EDA_UNITS::MILS, - m_settings->m_Window.grid.user_grid_y ); + m_sortGridx = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.user_grid_x ); + m_sortGridy = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.user_grid_y ); } else { - m_sortGridx = DoubleValueFromString( EDA_UNITS::MILS, - m_settings->m_Window.grid.sizes[ m_gridIndex ] ); + m_sortGridx = EDA_UNIT_UTILS::UI::DoubleValueFromString( + pcbIUScale, EDA_UNITS::MILS, m_settings->m_Window.grid.sizes[m_gridIndex] ); m_sortGridy = m_sortGridx; } @@ -482,8 +482,8 @@ static bool ModuleCompare( const RefDesInfo& aA, const RefDesInfo& aB ) wxString DIALOG_BOARD_REANNOTATE::CoordTowxString( int aX, int aY ) { return wxString::Format( wxT( "%s, %s" ), - MessageTextFromValue( m_units, aX ), - MessageTextFromValue( m_units, aY ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, aX ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, aY ) ); } diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp index 0a87ceb50c..9ac92f125d 100644 --- a/pcbnew/dialogs/dialog_board_statistics.cpp +++ b/pcbnew/dialogs/dialog_board_statistics.cpp @@ -436,13 +436,13 @@ void DIALOG_BOARD_STATISTICS::updateWidets() if( m_hasOutline ) { m_gridBoard->SetCellValue( ROW_BOARD_WIDTH, COL_AMOUNT, - MessageTextFromValue( GetUserUnits(), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardWidth ) + wxS( " " ) ); m_gridBoard->SetCellValue( ROW_BOARD_HEIGHT, COL_AMOUNT, - MessageTextFromValue( GetUserUnits(), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardHeight ) + wxS( " " ) ); m_gridBoard->SetCellValue( ROW_BOARD_AREA, COL_AMOUNT, - MessageTextFromValue( GetUserUnits(), m_boardArea, true, + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA ) ); } else @@ -501,9 +501,9 @@ void DIALOG_BOARD_STATISTICS::updateDrillGrid() currentRow, drillType_t::COL_COUNT, wxString::Format( wxT( "%i" ), type.qty ) ); m_gridDrills->SetCellValue( currentRow, drillType_t::COL_SHAPE, shapeStr ); m_gridDrills->SetCellValue( currentRow, drillType_t::COL_X_SIZE, - MessageTextFromValue( GetUserUnits(), type.xSize ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), type.xSize ) ); m_gridDrills->SetCellValue( currentRow, drillType_t::COL_Y_SIZE, - MessageTextFromValue( GetUserUnits(), type.ySize ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), type.ySize ) ); m_gridDrills->SetCellValue( currentRow, drillType_t::COL_PLATED, type.isPlated ? _( "PTH" ) : _( "NPTH" ) ); m_gridDrills->SetCellValue( @@ -693,11 +693,11 @@ void DIALOG_BOARD_STATISTICS::saveReportClicked( wxCommandEvent& aEvent ) if( m_hasOutline ) { msg << wxS( "- " ) << _( "Width" ) << wxS( ": " ) << - MessageTextFromValue( GetUserUnits(), m_boardWidth ) << wxT( "\n" ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardWidth ) << wxT( "\n" ); msg << wxS( "- " ) << _( "Height" ) << wxS( ": " ) << - MessageTextFromValue( GetUserUnits(), m_boardHeight ) << wxT( "\n" ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardHeight ) << wxT( "\n" ); msg << wxS( "- " ) << _( "Area" ) + wxS( ": " ) << - MessageTextFromValue( GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), m_boardArea, true, EDA_DATA_TYPE::AREA ); msg << wxT( "\n" ); } else diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 22fb557aab..666b33bebd 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -503,10 +503,11 @@ void DIALOG_COPPER_ZONE::OnClose( wxCloseEvent& event ) bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) { - if( !m_clearance.Validate( 0, Mils2iu( ZONE_CLEARANCE_MAX_VALUE_MIL ) ) ) + if( !m_clearance.Validate( 0, EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_CLEARANCE_MAX_VALUE_MIL ) ) ) return false; - if( !m_minWidth.Validate( Mils2iu( ZONE_THICKNESS_MIN_VALUE_MIL ), INT_MAX ) ) + if( !m_minWidth.Validate( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THICKNESS_MIN_VALUE_MIL ), + INT_MAX ) ) return false; if( !m_cornerRadius.Validate( 0, INT_MAX ) ) diff --git a/pcbnew/dialogs/dialog_create_array.cpp b/pcbnew/dialogs/dialog_create_array.cpp index 272cb57061..01c88e9c9d 100644 --- a/pcbnew/dialogs/dialog_create_array.cpp +++ b/pcbnew/dialogs/dialog_create_array.cpp @@ -161,7 +161,7 @@ DIALOG_CREATE_ARRAY::DIALOG_CREATE_ARRAY( PCB_BASE_FRAME* aParent, m_vCentre( aParent, m_labelCentreY, m_entryCentreY, m_unitLabelCentreY ), m_circRadius( aParent, m_labelCircRadius, m_valueCircRadius, m_unitLabelCircRadius ), m_circAngle( aParent, m_labelCircAngle, m_entryCircAngle, m_unitLabelCircAngle ), - m_cfg_persister( s_arrayOptions.m_OptionsSet ) + m_cfg_persister( pcbIUScale, s_arrayOptions.m_OptionsSet ) { // Configure display origin transforms m_hSpacing.SetCoordType( ORIGIN_TRANSFORMS::REL_X_COORD ); @@ -391,7 +391,7 @@ bool DIALOG_CREATE_ARRAY::TransferDataFromWindow() { auto newCirc = std::make_unique(); bool ok = true; - double angle = DoubleValueFromString( EDA_UNITS::UNSCALED, m_entryCircAngle->GetValue() ); + double angle = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_entryCircAngle->GetValue() ); newCirc->m_centre.x = m_hCentre.GetValue(); newCirc->m_centre.y = m_vCentre.GetValue(); diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 4e2b417be9..af3cc8b21e 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -1047,7 +1047,7 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName ) if( severity == RPT_SEVERITY_EXCLUSION ) severity = bds.GetSeverity( item->GetErrorCode() ); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, units, severity, itemMap ) ) ); } count = m_ratsnestProvider->GetCount(); @@ -1059,7 +1059,7 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName ) const std::shared_ptr& item = m_ratsnestProvider->GetItem( i ); SEVERITY severity = bds.GetSeverity( item->GetErrorCode() ); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, units, severity, itemMap ) ) ); } count = m_fpWarningsProvider->GetCount(); @@ -1071,7 +1071,7 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName ) const std::shared_ptr& item = m_fpWarningsProvider->GetItem( i ); SEVERITY severity = bds.GetSeverity( item->GetErrorCode() ); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, units, severity, itemMap ) ) ); } diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 54944bd00b..e492b9e64a 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -117,12 +117,12 @@ public: double GetXRef() { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_IDF_Xref->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_IDF_Xref->GetValue() ); } double GetYRef() { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_IDF_Yref->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_IDF_Yref->GetValue() ); } bool GetAutoAdjustOffset() diff --git a/pcbnew/dialogs/dialog_export_step.cpp b/pcbnew/dialogs/dialog_export_step.cpp index b4701e0bf5..861db0b769 100644 --- a/pcbnew/dialogs/dialog_export_step.cpp +++ b/pcbnew/dialogs/dialog_export_step.cpp @@ -79,12 +79,12 @@ protected: double GetXOrg() const { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_STEP_Xorg->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Xorg->GetValue() ); } double GetYOrg() { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_STEP_Yorg->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_STEP_Yorg->GetValue() ); } STEP_ORG_OPT GetOriginOption(); diff --git a/pcbnew/dialogs/dialog_export_vrml.cpp b/pcbnew/dialogs/dialog_export_vrml.cpp index 03a6b041cf..1b73fceb01 100644 --- a/pcbnew/dialogs/dialog_export_vrml.cpp +++ b/pcbnew/dialogs/dialog_export_vrml.cpp @@ -139,12 +139,12 @@ public: double GetXRef() { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_VRML_Xref->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_VRML_Xref->GetValue() ); } double GetYRef() { - return DoubleValueFromString( EDA_UNITS::UNSCALED, m_VRML_Yref->GetValue() ); + return EDA_UNIT_UTILS::UI::DoubleValueFromString( m_VRML_Yref->GetValue() ); } int GetUnits() diff --git a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp index d9041a4393..c9fa26aa68 100644 --- a/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/pcbnew/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -239,7 +239,7 @@ bool DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::TransferDataToWindow() m_LayerCtrl->SetLayerSelection( UNDEFINED_LAYER ); #define SET_INT_VALUE( aRow, aCol, aValue ) \ - m_grid->SetCellValue( aRow, aCol, StringFromValue( GetUserUnits(), aValue, true ) ) + m_grid->SetCellValue( aRow, aCol, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), aValue, true ) ) #define SET_BOOL_VALUE( aRow, aCol, aValue ) \ attr = new wxGridCellAttr; \ diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index db81371d81..f658f0a341 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -236,7 +236,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid() auto setNetclassValue = [this, units]( int aRow, int aCol, int aVal ) { - m_netclassGrid->SetCellValue( aRow, aCol, StringFromValue( units, aVal, true ) ); + m_netclassGrid->SetCellValue( aRow, aCol, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, aVal, true ) ); }; auto buildRow = diff --git a/pcbnew/dialogs/dialog_net_inspector.cpp b/pcbnew/dialogs/dialog_net_inspector.cpp index 7dd25ecf1c..f88852ad85 100644 --- a/pcbnew/dialogs/dialog_net_inspector.cpp +++ b/pcbnew/dialogs/dialog_net_inspector.cpp @@ -1295,7 +1295,7 @@ wxString DIALOG_NET_INSPECTOR::formatCount( unsigned int aValue ) const wxString DIALOG_NET_INSPECTOR::formatLength( int64_t aValue ) const { - return MessageTextFromValue( GetUserUnits(), static_cast( aValue ) ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, GetUserUnits(), static_cast( aValue ) ); } diff --git a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp index 02b7e54f07..f4ec17a421 100644 --- a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp @@ -319,10 +319,10 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow() msg.Printf( _( "Corner %d" ), row+1 ); m_gridCornersList->SetRowLabelValue( row, msg ); - msg = StringFromValue( GetUserUnits(), m_currPoints[row].x, true ); + msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), m_currPoints[row].x, true ); m_gridCornersList->SetCellValue( row, 0, msg ); - msg = StringFromValue( GetUserUnits(), m_currPoints[row].y, true ); + msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), m_currPoints[row].y, true ); m_gridCornersList->SetCellValue( row, 1, msg ); } @@ -563,9 +563,9 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onCellChanging( wxGridEvent& event ) return; if( col == 0 ) // Set the X value - m_currPoints[row].x = ValueFromString( GetUserUnits(), msg ); + m_currPoints[row].x = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, GetUserUnits(), msg ); else // Set the Y value - m_currPoints[row].y = ValueFromString( GetUserUnits(), msg ); + m_currPoints[row].y = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, GetUserUnits(), msg ); Validate(); @@ -602,7 +602,7 @@ void DIALOG_PAD_PRIMITIVES_TRANSFORM::Transform( std::vectorGetValue() ); + double scale = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_scaleCtrl->GetValue() ); // Avoid too small / too large scale, which could create issues: if( scale < 0.01 ) diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index df1ecf1540..6750a4aba1 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -676,8 +676,8 @@ void DIALOG_PAD_PROPERTIES::initValues() static wxString formatCoord( EDA_UNITS aUnits, VECTOR2I aCoord ) { return wxString::Format( wxT( "(X:%s Y:%s)" ), - MessageTextFromValue( aUnits, aCoord.x ), - MessageTextFromValue( aUnits, aCoord.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, aCoord.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, aCoord.y ) ); } void DIALOG_PAD_PROPERTIES::displayPrimitivesList() @@ -699,7 +699,7 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList() for( wxString& s : bs_info ) s.Empty(); - bs_info[4] = _( "width" ) + wxS( " " )+ MessageTextFromValue( m_units, + bs_info[4] = _( "width" ) + wxS( " " )+ EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, primitive->GetWidth() ); switch( primitive->GetShape() ) @@ -730,7 +730,7 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList() bs_info[0] = _( "Circle" ); bs_info[1] = _( "at" ) + wxS( " " ) + formatCoord( m_units, primitive->GetStart() ); - bs_info[2] = _( "radius" ) + wxS( " " ) + MessageTextFromValue( m_units, + bs_info[2] = _( "radius" ) + wxS( " " ) + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_units, primitive->GetRadius() ); break; diff --git a/pcbnew/dialogs/dialog_plot.cpp b/pcbnew/dialogs/dialog_plot.cpp index debe7a908c..7fb4ced0a8 100644 --- a/pcbnew/dialogs/dialog_plot.cpp +++ b/pcbnew/dialogs/dialog_plot.cpp @@ -237,8 +237,8 @@ void DIALOG_PLOT::init_Dialog() m_XScaleAdjust = m_YScaleAdjust = 1.0; } - m_fineAdjustXCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, m_XScaleAdjust ) ); - m_fineAdjustYCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, m_YScaleAdjust ) ); + m_fineAdjustXCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, m_XScaleAdjust ) ); + m_fineAdjustYCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, m_YScaleAdjust ) ); // Test for a reasonable PS width correction value. Set to 0 if problem. if( m_PSWidthAdjust < m_widthAdjustMinValue || m_PSWidthAdjust > m_widthAdjustMaxValue ) @@ -835,8 +835,8 @@ void DIALOG_PLOT::applyPlotSettings() m_trackWidthCorrection.SetValue( m_PSWidthAdjust ); msg.Printf( _( "Width correction constrained. The width correction value must be in the" " range of [%s; %s] for the current design rules." ), - StringFromValue( GetUserUnits(), m_widthAdjustMinValue, true ), - StringFromValue( GetUserUnits(), m_widthAdjustMaxValue, true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), m_widthAdjustMinValue, true ), + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, GetUserUnits(), m_widthAdjustMaxValue, true ) ); reporter.Report( msg, RPT_SEVERITY_WARNING ); } diff --git a/pcbnew/dialogs/dialog_target_properties.cpp b/pcbnew/dialogs/dialog_target_properties.cpp index be8895a2d8..464448ea4d 100644 --- a/pcbnew/dialogs/dialog_target_properties.cpp +++ b/pcbnew/dialogs/dialog_target_properties.cpp @@ -88,7 +88,7 @@ bool DIALOG_TARGET_PROPERTIES::TransferDataToWindow() bool DIALOG_TARGET_PROPERTIES::TransferDataFromWindow() { // Zero-size targets are hard to see/select. - if( !m_Size.Validate( Mils2iu( 1 ), INT_MAX ) ) + if( !m_Size.Validate( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 ), INT_MAX ) ) return false; BOARD_COMMIT commit( m_Parent ); diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 4f6b557837..da150edab7 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -307,9 +307,9 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ ) { VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii]; - wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter ) + wxString msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), viaDimension->m_Diameter ) + wxT( " / " ) - + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill ); + + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), viaDimension->m_Drill ); m_DesignRuleViasCtrl->Append( msg, viaDimension ); if( viaSelection == wxNOT_FOUND @@ -352,7 +352,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ ) { int width = aParent->GetDesignSettings().m_TrackWidthList[ii]; - wxString msg = StringFromValue( m_frame->GetUserUnits(), width ); + wxString msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), width ); m_DesignRuleWidthsCtrl->Append( msg ); if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width ) @@ -407,9 +407,9 @@ void DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged( wxCommandEvent& aEvent ) for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ ) { VIA_DIMENSION* viaDimension = &m_frame->GetDesignSettings().m_ViasDimensionsList[ii]; - wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter ) + wxString msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), viaDimension->m_Diameter ) + wxT( " / " ) - + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill ); + + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), viaDimension->m_Drill ); m_DesignRuleViasCtrl->Append( msg, viaDimension ); } @@ -428,7 +428,7 @@ void DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged( wxCommandEvent& aEvent ) for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ ) { int width = m_frame->GetDesignSettings().m_TrackWidthList[ii]; - wxString msg = StringFromValue( m_frame->GetUserUnits(), width ); + wxString msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), width ); m_DesignRuleWidthsCtrl->Append( msg ); } diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index 02eabf3a4a..328622c7c9 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -34,7 +34,7 @@ PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, EDA_BASE_FRAME* aUnit bool isFootprintEditor ) : PANEL_EDIT_OPTIONS_BASE( aParent ), m_isFootprintEditor( isFootprintEditor ), - m_rotationAngle( aUnitsProvider, m_rotationAngleLabel, m_rotationAngleCtrl, + m_rotationAngle( aUnitsProvider, pcbIUScale, m_rotationAngleLabel, m_rotationAngleCtrl, m_rotationAngleUnits ) { m_magneticPads->Show( m_isFootprintEditor ); diff --git a/pcbnew/dialogs/panel_fp_editor_defaults.cpp b/pcbnew/dialogs/panel_fp_editor_defaults.cpp index 32be198b05..74775efaf0 100644 --- a/pcbnew/dialogs/panel_fp_editor_defaults.cpp +++ b/pcbnew/dialogs/panel_fp_editor_defaults.cpp @@ -220,7 +220,7 @@ void PANEL_FP_EDITOR_DEFAULTS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg ) wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ); #define SET_MILS_CELL( row, col, val ) \ - m_graphicsGrid->SetCellValue( row, col, StringFromValue( m_units, val, true ) ) + m_graphicsGrid->SetCellValue( row, col, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_units, val, true ) ) #define DISABLE_CELL( row, col ) \ m_graphicsGrid->SetReadOnly( row, col ); \ @@ -317,7 +317,7 @@ bool PANEL_FP_EDITOR_DEFAULTS::Show( bool aShow ) int PANEL_FP_EDITOR_DEFAULTS::getGridValue( int aRow, int aCol ) { - return ValueFromString( m_units, m_graphicsGrid->GetCellValue( aRow, aCol ) ); + return EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_units, m_graphicsGrid->GetCellValue( aRow, aCol ) ); } diff --git a/pcbnew/dialogs/panel_setup_constraints.cpp b/pcbnew/dialogs/panel_setup_constraints.cpp index ff94bba790..a93673dbd5 100644 --- a/pcbnew/dialogs/panel_setup_constraints.cpp +++ b/pcbnew/dialogs/panel_setup_constraints.cpp @@ -66,7 +66,7 @@ bool PANEL_SETUP_CONSTRAINTS::TransferDataToWindow() { wxString msg; msg.Printf( m_stCircleToPolyWarning->GetLabel(), - StringFromValue( m_Frame->GetUserUnits(), ARC_HIGH_DEF, true ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), ARC_HIGH_DEF, true ) ); m_stCircleToPolyWarning->SetLabel( msg ); m_useHeightForLengthCalcs->SetValue( m_BrdSettings->m_UseHeightForLengthCalcs ); diff --git a/pcbnew/dialogs/panel_setup_formatting.cpp b/pcbnew/dialogs/panel_setup_formatting.cpp index d1d9971436..2f03e467f2 100644 --- a/pcbnew/dialogs/panel_setup_formatting.cpp +++ b/pcbnew/dialogs/panel_setup_formatting.cpp @@ -41,10 +41,10 @@ bool PANEL_SETUP_FORMATTING::TransferDataToWindow() { const PCB_PLOT_PARAMS& settings = m_frame->GetBoard()->GetPlotOptions(); - m_dashLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, settings.GetDashedLineDashRatio() ) ); - m_gapLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, settings.GetDashedLineGapRatio() ) ); return true; @@ -55,11 +55,9 @@ bool PANEL_SETUP_FORMATTING::TransferDataFromWindow() { PCB_PLOT_PARAMS settings = m_frame->GetBoard()->GetPlotOptions(); - settings.SetDashedLineDashRatio( DoubleValueFromString( EDA_UNITS::UNSCALED, - m_dashLengthCtrl->GetValue() ) ); + settings.SetDashedLineDashRatio( EDA_UNIT_UTILS::UI::DoubleValueFromString( m_dashLengthCtrl->GetValue() ) ); - settings.SetDashedLineGapRatio( DoubleValueFromString( EDA_UNITS::UNSCALED, - m_gapLengthCtrl->GetValue() ) ); + settings.SetDashedLineGapRatio( EDA_UNIT_UTILS::UI::DoubleValueFromString( m_gapLengthCtrl->GetValue() ) ); m_frame->GetBoard()->SetPlotOptions( settings ); @@ -79,9 +77,9 @@ void PANEL_SETUP_FORMATTING::ImportSettingsFrom( BOARD* aBoard ) { const PCB_PLOT_PARAMS& importedSettings = aBoard->GetPlotOptions(); - m_dashLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_dashLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, importedSettings.GetDashedLineDashRatio() ) ); - m_gapLengthCtrl->SetValue( StringFromValue( EDA_UNITS::UNSCALED, + m_gapLengthCtrl->SetValue( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, importedSettings.GetDashedLineGapRatio() ) ); } diff --git a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp index 51b28bc70f..b3ba54ae87 100644 --- a/pcbnew/dialogs/panel_setup_text_and_graphics.cpp +++ b/pcbnew/dialogs/panel_setup_text_and_graphics.cpp @@ -126,7 +126,7 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow() wxColour disabledColour = wxSystemSettings::GetColour( wxSYS_COLOUR_BACKGROUND ); #define SET_MILS_CELL( row, col, val ) \ - m_grid->SetCellValue( row, col, StringFromValue( m_Frame->GetUserUnits(), val, true ) ) + m_grid->SetCellValue( row, col, EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), val, true ) ) #define DISABLE_CELL( row, col ) \ m_grid->SetReadOnly( row, col ); m_grid->SetCellBackgroundColour( row, col, disabledColour ); @@ -198,7 +198,7 @@ bool PANEL_SETUP_TEXT_AND_GRAPHICS::TransferDataToWindow() int PANEL_SETUP_TEXT_AND_GRAPHICS::getGridValue( int aRow, int aCol ) { - return ValueFromString( m_Frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ) ); + return EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), m_grid->GetCellValue( aRow, aCol ) ); } diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index 5a2c46f59f..ebecc8534a 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -141,7 +141,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnSortTrackWidthsClick( wxCommandEvent& aEvent msg = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL ); if( !msg.IsEmpty() ) - trackWidths.push_back( ValueFromString( m_Frame->GetUserUnits(), msg ) ); + trackWidths.push_back( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ) ); } std::sort( trackWidths.begin(), trackWidths.end() ); @@ -166,12 +166,12 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnSortViaSizesClick( wxCommandEvent& aEvent ) if( !msg.IsEmpty() ) { VIA_DIMENSION via_dim; - via_dim.m_Diameter = ValueFromString( m_Frame->GetUserUnits(), msg ); + via_dim.m_Diameter = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL ); if( !msg.IsEmpty() ) - via_dim.m_Drill = ValueFromString( m_Frame->GetUserUnits(), msg ); + via_dim.m_Drill = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); vias.push_back( via_dim ); } @@ -199,15 +199,15 @@ void PANEL_SETUP_TRACKS_AND_VIAS::OnSortDiffPairsClick( wxCommandEvent& aEvent ) if( !msg.IsEmpty() ) { DIFF_PAIR_DIMENSION diffPair_dim; - diffPair_dim.m_Width = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_Width = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_diffPairsGrid->GetCellValue( row, DP_GAP_COL ); - diffPair_dim.m_Gap = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_Gap = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL ); if( !msg.IsEmpty() ) - diffPair_dim.m_ViaGap = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_ViaGap = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); diffPairs.push_back( diffPair_dim ); } @@ -289,7 +289,7 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() msg = m_trackWidthsGrid->GetCellValue( row, TR_WIDTH_COL ); if( !msg.IsEmpty() ) - trackWidths.push_back( ValueFromString( m_Frame->GetUserUnits(), msg ) ); + trackWidths.push_back( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ) ); } for( int row = 0; row < m_viaSizesGrid->GetNumberRows(); ++row ) @@ -299,12 +299,12 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() if( !msg.IsEmpty() ) { VIA_DIMENSION via_dim; - via_dim.m_Diameter = ValueFromString( m_Frame->GetUserUnits(), msg ); + via_dim.m_Diameter = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_viaSizesGrid->GetCellValue( row, VIA_DRILL_COL ); if( !msg.IsEmpty() ) - via_dim.m_Drill = ValueFromString( m_Frame->GetUserUnits(), msg ); + via_dim.m_Drill = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); vias.push_back( via_dim ); } @@ -317,15 +317,15 @@ bool PANEL_SETUP_TRACKS_AND_VIAS::TransferDataFromWindow() if( !msg.IsEmpty() ) { DIFF_PAIR_DIMENSION diffPair_dim; - diffPair_dim.m_Width = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_Width = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_diffPairsGrid->GetCellValue( row, DP_GAP_COL ); - diffPair_dim.m_Gap = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_Gap = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); msg = m_diffPairsGrid->GetCellValue( row, DP_VIA_GAP_COL ); if( !msg.IsEmpty() ) - diffPair_dim.m_ViaGap = ValueFromString( m_Frame->GetUserUnits(), msg ); + diffPair_dim.m_ViaGap = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_Frame->GetUserUnits(), msg ); diffPairs.push_back( diffPair_dim ); } @@ -401,7 +401,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth ) m_trackWidthsGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true ); + wxString val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aWidth, true ); m_trackWidthsGrid->SetCellValue( i, TR_WIDTH_COL, val ); } @@ -412,12 +412,12 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( const int aSize, const int aDri m_viaSizesGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aSize, true ); + wxString val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aSize, true ); m_viaSizesGrid->SetCellValue( i, VIA_SIZE_COL, val ); if( aDrill > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aDrill, true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aDrill, true ); m_viaSizesGrid->SetCellValue( i, VIA_DRILL_COL, val ); } } @@ -430,18 +430,18 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( const int aWidth, const int a m_diffPairsGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true ); + wxString val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aWidth, true ); m_diffPairsGrid->SetCellValue( i, DP_WIDTH_COL, val ); if( aGap > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aGap, true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aGap, true ); m_diffPairsGrid->SetCellValue( i, DP_GAP_COL, val ); } if( aViaGap > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aViaGap, true ); + val = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_Frame->GetUserUnits(), aViaGap, true ); m_diffPairsGrid->SetCellValue( i, DP_VIA_GAP_COL, val ); } } diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index e9e816ef9a..68f571e2b9 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -607,7 +607,7 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT #define REPORT( s ) { if( aReporter ) { aReporter->Report( s ); } } #define UNITS aReporter ? aReporter->GetUnits() : EDA_UNITS::MILLIMETRES -#define REPORT_VALUE( v ) MessageTextFromValue( UNITS, v ) +#define REPORT_VALUE( v ) EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, UNITS, v ) DRC_CONSTRAINT DRC_ENGINE::EvalZoneConnection( const BOARD_ITEM* a, const BOARD_ITEM* b, PCB_LAYER_ID aLayer, REPORTER* aReporter ) @@ -910,7 +910,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO case MIN_RESOLVED_SPOKES_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s min spoke count: %s." ), EscapeHTML( c->constraint.GetName() ), - MessageTextFromValue( EDA_UNITS::UNSCALED, c->constraint.m_Value.Min() ) ) ) + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, EDA_UNITS::UNSCALED, c->constraint.m_Value.Min() ) ) ) break; case ZONE_CONNECTION_CONSTRAINT: @@ -938,8 +938,10 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO if( implicit ) { - min = StringFromValue( UNITS, c->constraint.m_Value.Min(), true ); - opt = StringFromValue( UNITS, c->constraint.m_Value.Opt(), true ); + min = EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, UNITS, c->constraint.m_Value.Min(), true ); + opt = EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, UNITS, c->constraint.m_Value.Opt(), true ); switch( c->constraint.m_Type ) { @@ -1035,13 +1037,16 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO else { if( c->constraint.m_Value.HasMin() ) - min = StringFromValue( UNITS, c->constraint.m_Value.Min(), true ); + min = EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, UNITS, c->constraint.m_Value.Min(), true ); if( c->constraint.m_Value.HasOpt() ) - opt = StringFromValue( UNITS, c->constraint.m_Value.Opt(), true ); + opt = EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, UNITS, c->constraint.m_Value.Opt(), true ); if( c->constraint.m_Value.HasMax() ) - max = StringFromValue( UNITS, c->constraint.m_Value.Max(), true ); + max = EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, UNITS, c->constraint.m_Value.Max(), true ); REPORT( wxString::Format( _( "Checking %s: min %s; opt %s; max %s." ), EscapeHTML( c->constraint.GetName() ), diff --git a/pcbnew/drc/drc_test_provider_annular_width.cpp b/pcbnew/drc/drc_test_provider_annular_width.cpp index 3b7e7e46dc..34cc603afc 100644 --- a/pcbnew/drc/drc_test_provider_annular_width.cpp +++ b/pcbnew/drc/drc_test_provider_annular_width.cpp @@ -247,16 +247,16 @@ bool DRC_TEST_PROVIDER_ANNULAR_WIDTH::Run() { msg.Printf( _( "(%s min annular width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), v_min ), - MessageTextFromValue( userUnits(), annularWidth ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), v_min ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), annularWidth ) ); } if( fail_max ) { msg.Printf( _( "(%s max annular width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), v_max ), - MessageTextFromValue( userUnits(), annularWidth ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), v_max ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), annularWidth ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); diff --git a/pcbnew/drc/drc_test_provider_connection_width.cpp b/pcbnew/drc/drc_test_provider_connection_width.cpp index 4dd47eaa66..d423cc794f 100644 --- a/pcbnew/drc/drc_test_provider_connection_width.cpp +++ b/pcbnew/drc/drc_test_provider_connection_width.cpp @@ -757,8 +757,8 @@ bool DRC_TEST_PROVIDER_CONNECTION_WIDTH::Run() wxString msg; msg.Printf( _( "Minimum connection width %s; actual %s" ), - MessageTextFromValue( userUnits(), aMinWidth ), - MessageTextFromValue( userUnits(), dist ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), aMinWidth ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), dist ) ); drce->SetErrorMessage( msg + wxS( " " ) + layerDesc( aLayer ) ); drce->SetViolatingRule( c.GetParentRule() ); diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index 326956155d..6a240ec23f 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -222,8 +222,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track, msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( track, other ); @@ -266,8 +266,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackAgainstItem( PCB_TRACK* track, msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( track, other ); @@ -350,8 +350,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem, msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, aZone ); @@ -391,8 +391,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZone( BOARD_ITEM* aItem, msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, aZone ); @@ -603,8 +603,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( pad, other ); @@ -636,8 +636,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( pad, other ); @@ -659,8 +659,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( pad, other ); @@ -682,8 +682,8 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadAgainstItem( PAD* pad, SHAPE* pa msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( pad, otherVia ); @@ -935,8 +935,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZonesToZones() msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), zone2zoneClearance ), - MessageTextFromValue( userUnits(), std::max( actual, 0 ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), zone2zoneClearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), std::max( actual, 0 ) ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); } diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp index 811b75fa1e..aeee5fbcbe 100644 --- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp @@ -232,8 +232,8 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() wxString msg; msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetViolatingRule( constraint.GetParentRule() ); @@ -266,8 +266,8 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testCourtyardClearances() wxString msg; msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetViolatingRule( constraint.GetParentRule() ); diff --git a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp index a787eae9d1..e5954f96b9 100644 --- a/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp +++ b/pcbnew/drc/drc_test_provider_diff_pair_coupling.cpp @@ -420,8 +420,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run() int totalLen = std::max( itemSet.totalLengthN, itemSet.totalLengthP ); reportAux( wxString::Format( wxT( " - coupled length: %s, total length: %s" ), - MessageTextFromValue( userUnits(), itemSet.totalCoupled ), - MessageTextFromValue( userUnits(), totalLen ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), itemSet.totalCoupled ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), totalLen ) ) ); int totalUncoupled = totalLen - itemSet.totalCoupled; @@ -438,8 +438,8 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run() msg = wxString::Format( _( "(%s maximum uncoupled length: %s; actual: %s)" ), maxUncoupledConstraint->GetParentRule()->m_Name, - MessageTextFromValue( userUnits(), val.Max() ), - MessageTextFromValue( userUnits(), totalUncoupled ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Max() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), totalUncoupled ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); @@ -490,14 +490,14 @@ bool test::DRC_TEST_PROVIDER_DIFF_PAIR_COUPLING::Run() if( val.HasMin() ) msg += wxString::Format( _( "minimum gap: %s; " ), - MessageTextFromValue( userUnits(), val.Min() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Min() ) ); if( val.HasMax() ) msg += wxString::Format( _( "maximum gap: %s; " ), - MessageTextFromValue( userUnits(), val.Max() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Max() ) ); msg += wxString::Format( _( "actual: %s)" ), - MessageTextFromValue( userUnits(), dp.computedGap ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), dp.computedGap ) ); drcItem->SetErrorMessage( msg ); diff --git a/pcbnew/drc/drc_test_provider_edge_clearance.cpp b/pcbnew/drc/drc_test_provider_edge_clearance.cpp index c75da7359b..4d4d3ad53d 100644 --- a/pcbnew/drc/drc_test_provider_edge_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_edge_clearance.cpp @@ -121,8 +121,8 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::testAgainstEdge( BOARD_ITEM* item, SHAPE* msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), minClearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); } diff --git a/pcbnew/drc/drc_test_provider_hole_size.cpp b/pcbnew/drc/drc_test_provider_hole_size.cpp index 2f59ae34f1..d0549909d4 100644 --- a/pcbnew/drc/drc_test_provider_hole_size.cpp +++ b/pcbnew/drc/drc_test_provider_hole_size.cpp @@ -157,15 +157,15 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkPadHole( PAD* aPad ) { msg.Printf( _( "(%s min width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintValue ), - MessageTextFromValue( userUnits(), holeMinor ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), holeMinor ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintValue ), - MessageTextFromValue( userUnits(), holeMajor ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), holeMajor ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); @@ -226,15 +226,15 @@ void DRC_TEST_PROVIDER_HOLE_SIZE::checkViaHole( PCB_VIA* via, bool aExceedMicro, { msg.Printf( _( "(%s min width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintValue ), - MessageTextFromValue( userUnits(), via->GetDrillValue() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), via->GetDrillValue() ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintValue ), - MessageTextFromValue( userUnits(), via->GetDrillValue() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), via->GetDrillValue() ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); diff --git a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp index cd9a22318c..5922e8e6ef 100644 --- a/pcbnew/drc/drc_test_provider_hole_to_hole.cpp +++ b/pcbnew/drc/drc_test_provider_hole_to_hole.cpp @@ -305,8 +305,8 @@ bool DRC_TEST_PROVIDER_HOLE_TO_HOLE::testHoleAgainstHole( BOARD_ITEM* aItem, SHA msg.Printf( _( "(%s min %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), minClearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, aOther ); diff --git a/pcbnew/drc/drc_test_provider_matched_length.cpp b/pcbnew/drc/drc_test_provider_matched_length.cpp index 0ea2ce14bd..c1970b1dbf 100644 --- a/pcbnew/drc/drc_test_provider_matched_length.cpp +++ b/pcbnew/drc/drc_test_provider_matched_length.cpp @@ -115,15 +115,15 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkLengths( const DRC_CONSTRAINT& aCons { msg.Printf( _( "(%s min length: %s; actual: %s)" ), aConstraint.GetName(), - MessageTextFromValue( userUnits(), minLen ), - MessageTextFromValue( userUnits(), ent.total ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minLen ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ) ); } else if( maxViolation ) { msg.Printf( _( "(%s max length: %s; actual: %s)" ), aConstraint.GetName(), - MessageTextFromValue( userUnits(), maxLen ), - MessageTextFromValue( userUnits(), ent.total ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), maxLen ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); @@ -159,10 +159,10 @@ void DRC_TEST_PROVIDER_MATCHED_LENGTH::checkSkews( const DRC_CONSTRAINT& aConstr msg.Printf( _( "(%s max skew: %s; actual: %s; average net length: %s; actual: %s)" ), aConstraint.GetName(), - MessageTextFromValue( userUnits(), aConstraint.GetValue().Max() ), - MessageTextFromValue( userUnits(), skew ), - MessageTextFromValue( userUnits(), avgLength ), - MessageTextFromValue( userUnits(), ent.total ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), aConstraint.GetValue().Max() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), skew ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), avgLength ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + " " + msg ); @@ -378,10 +378,10 @@ bool DRC_TEST_PROVIDER_MATCHED_LENGTH::runInternal( bool aDelayReportMode ) ent.from, ent.to, (int) ent.items.size(), - MessageTextFromValue( userUnits(), ent.total ), - MessageTextFromValue( userUnits(), ent.totalRoute ), - MessageTextFromValue( userUnits(), ent.totalVia ), - MessageTextFromValue( userUnits(), ent.totalPadToDie ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.totalRoute ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.totalVia ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.totalPadToDie ), ent.viaCount ) ); } diff --git a/pcbnew/drc/drc_test_provider_physical_clearance.cpp b/pcbnew/drc/drc_test_provider_physical_clearance.cpp index 14c6c5341c..7cc5cc0440 100644 --- a/pcbnew/drc/drc_test_provider_physical_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_physical_clearance.cpp @@ -497,8 +497,8 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testShapeLineChain( const SHAPE_LINE_ msg.Printf( _( "Internal clearance violation (%s clearance %s; actual %s)" ), aConstraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), collision.second ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), collision.second ) ); drce->SetErrorMessage( msg ); drce->SetItems( aParentItem ); @@ -548,8 +548,8 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testZoneLayer( ZONE* aZone, PCB_LAYER msg.Printf( _( "(%s clearance %s; actual %s)" ), aConstraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aZone ); @@ -607,8 +607,8 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, other ); @@ -660,8 +660,8 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, other ); @@ -677,8 +677,8 @@ bool DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstItem( BOARD_ITEM* aIte msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, other ); @@ -771,8 +771,8 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, zone ); @@ -812,8 +812,8 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( aItem, zone ); diff --git a/pcbnew/drc/drc_test_provider_silk_clearance.cpp b/pcbnew/drc/drc_test_provider_silk_clearance.cpp index 539ab4e2cd..191ef91d55 100644 --- a/pcbnew/drc/drc_test_provider_silk_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_silk_clearance.cpp @@ -241,8 +241,8 @@ bool DRC_TEST_PROVIDER_SILK_CLEARANCE::Run() msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetParentRule()->m_Name, - MessageTextFromValue( userUnits(), minClearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); } diff --git a/pcbnew/drc/drc_test_provider_solder_mask.cpp b/pcbnew/drc/drc_test_provider_solder_mask.cpp index 40a2c6d435..ec4e38c29d 100644 --- a/pcbnew/drc/drc_test_provider_solder_mask.cpp +++ b/pcbnew/drc/drc_test_provider_solder_mask.cpp @@ -280,8 +280,8 @@ void DRC_TEST_PROVIDER_SOLDER_MASK::testSilkToMaskClearance() msg.Printf( _( "(%s clearance %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), clearance ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg ); drce->SetItems( item ); diff --git a/pcbnew/drc/drc_test_provider_text_dims.cpp b/pcbnew/drc/drc_test_provider_text_dims.cpp index d79be670af..3abbcd97d9 100644 --- a/pcbnew/drc/drc_test_provider_text_dims.cpp +++ b/pcbnew/drc/drc_test_provider_text_dims.cpp @@ -109,8 +109,8 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() msg.Printf( _( "(%s min height %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraint.Value().Min() ), - MessageTextFromValue( userUnits(), actualHeight ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Min() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualHeight ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( item ); @@ -126,8 +126,8 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() msg.Printf( _( "(%s max height %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraint.Value().Max() ), - MessageTextFromValue( userUnits(), actualHeight ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Max() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualHeight ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( item ); @@ -229,8 +229,8 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() msg.Printf( _( "(%s min thickness %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraint.Value().Min() ), - MessageTextFromValue( userUnits(), actualThickness ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Min() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualThickness ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( item ); @@ -246,8 +246,8 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() msg.Printf( _( "(%s max thickness %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraint.Value().Max() ), - MessageTextFromValue( userUnits(), actualThickness ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Max() ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualThickness ) ); drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); drcItem->SetItems( item ); diff --git a/pcbnew/drc/drc_test_provider_track_width.cpp b/pcbnew/drc/drc_test_provider_track_width.cpp index 838079470a..cdd20480b4 100644 --- a/pcbnew/drc/drc_test_provider_track_width.cpp +++ b/pcbnew/drc/drc_test_provider_track_width.cpp @@ -130,15 +130,15 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run() { msg.Printf( _( "(%s min width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintWidth ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintWidth ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintWidth ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintWidth ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); diff --git a/pcbnew/drc/drc_test_provider_via_diameter.cpp b/pcbnew/drc/drc_test_provider_via_diameter.cpp index 59c091f80f..b4347602dd 100644 --- a/pcbnew/drc/drc_test_provider_via_diameter.cpp +++ b/pcbnew/drc/drc_test_provider_via_diameter.cpp @@ -120,15 +120,15 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run() { msg.Printf( _( "(%s min diameter %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintDiameter ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintDiameter ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); } else if( fail_max ) { msg.Printf( _( "(%s max diameter %s; actual %s)" ), constraint.GetName(), - MessageTextFromValue( userUnits(), constraintDiameter ), - MessageTextFromValue( userUnits(), actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintDiameter ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); diff --git a/pcbnew/footprint_editor_settings.cpp b/pcbnew/footprint_editor_settings.cpp index 34aa248633..2341d147fd 100644 --- a/pcbnew/footprint_editor_settings.cpp +++ b/pcbnew/footprint_editor_settings.cpp @@ -406,11 +406,11 @@ bool FOOTPRINT_EDITOR_SETTINGS::MigrateFromLegacy( wxConfigBase* aCfg ) static_cast( EDA_UNITS::INCHES ) ) ); // Convert to internal units - x = From_User_Unit( u, x ); - y = From_User_Unit( u, y ); + x = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, x ); + y = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, y ); - Set( "window.grid.user_grid_x", StringFromValue( u, x ) ); - Set( "window.grid.user_grid_y", StringFromValue( u, y ) ); + Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) ); + Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) ); } return ret; diff --git a/pcbnew/footprint_preview_panel.cpp b/pcbnew/footprint_preview_panel.cpp index 09aa96db2a..90decabc55 100644 --- a/pcbnew/footprint_preview_panel.cpp +++ b/pcbnew/footprint_preview_panel.cpp @@ -194,7 +194,7 @@ FOOTPRINT_PREVIEW_PANEL* FOOTPRINT_PREVIEW_PANEL::New( KIWAY* aKiway, wxWindow* //Bounds checking cannot include number of elements as an index! int gridIdx = std::max( 0, std::min( gridCfg.last_size_idx, (int) gridCfg.sizes.size() - 1 ) ); - int gridSize = (int) ValueFromString( EDA_UNITS::MILS, gridCfg.sizes[ gridIdx ] ); + int gridSize = (int) EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, EDA_UNITS::MILS, gridCfg.sizes[ gridIdx ] ); panel->GetGAL()->SetGridSize( VECTOR2D( gridSize, gridSize ) ); return panel; diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index 3cedc6e8de..dfdb042989 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -40,7 +40,7 @@ FP_TEXT::FP_TEXT( FOOTPRINT* aParentFootprint, TEXT_TYPE text_type ) : BOARD_ITEM( aParentFootprint, PCB_FP_TEXT_T ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( pcbIUScale ) { FOOTPRINT* parentFootprint = static_cast( m_parent ); @@ -295,9 +295,9 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() ); - aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) ); - aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) ); - aList.emplace_back( _( "Height" ), MessageTextFromValue(units, GetTextHeight() ) ); + aList.emplace_back( _( "Thickness" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextThickness() ) ); + aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextWidth() ) ); + aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextHeight() ) ); } diff --git a/pcbnew/fp_text_grid_table.cpp b/pcbnew/fp_text_grid_table.cpp index 4a6689cbac..6b23e4d6dd 100644 --- a/pcbnew/fp_text_grid_table.cpp +++ b/pcbnew/fp_text_grid_table.cpp @@ -203,25 +203,25 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol ) return text.GetText(); case FPT_WIDTH: - return StringFromValue( m_frame->GetUserUnits(), text.GetTextWidth(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), text.GetTextWidth(), true ); case FPT_HEIGHT: - return StringFromValue( m_frame->GetUserUnits(), text.GetTextHeight(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), text.GetTextHeight(), true ); case FPT_THICKNESS: - return StringFromValue( m_frame->GetUserUnits(), text.GetTextThickness(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), text.GetTextThickness(), true ); case FPT_LAYER: return text.GetLayerName(); case FPT_ORIENTATION: - return StringFromValue( EDA_UNITS::DEGREES, text.GetTextAngle().AsDegrees(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::DEGREES, text.GetTextAngle().AsDegrees(), true ); case FPT_XOFFSET: - return StringFromValue( m_frame->GetUserUnits(), text.GetPos0().x, true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), text.GetPos0().x, true ); case FPT_YOFFSET: - return StringFromValue( m_frame->GetUserUnits(), text.GetPos0().y, true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, m_frame->GetUserUnits(), text.GetPos0().y, true ); default: // we can't assert here because wxWidgets sometimes calls this without checking @@ -275,19 +275,18 @@ void FP_TEXT_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue ) break; case FPT_WIDTH: - text.SetTextWidth( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + text.SetTextWidth( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), aValue ) ); break; case FPT_HEIGHT: - text.SetTextHeight( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + text.SetTextHeight( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), aValue ) ); break; - case FPT_THICKNESS:text.SetTextThickness( ValueFromString( m_frame->GetUserUnits(), aValue ) ); + case FPT_THICKNESS:text.SetTextThickness( EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), aValue ) ); break; case FPT_ORIENTATION: - text.SetTextAngle( EDA_ANGLE( DoubleValueFromString( EDA_UNITS::UNSCALED, aValue ), - DEGREES_T ) ); + text.SetTextAngle( EDA_ANGLE( EDA_UNIT_UTILS::UI::DoubleValueFromString( pcbIUScale, EDA_UNITS::UNSCALED, aValue ), DEGREES_T ) ); text.SetDrawCoord(); break; @@ -296,9 +295,9 @@ void FP_TEXT_GRID_TABLE::SetValue( int aRow, int aCol, const wxString &aValue ) pos = text.GetPos0(); if( aCol == FPT_XOFFSET ) - pos.x = ValueFromString( m_frame->GetUserUnits(), aValue ); + pos.x = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), aValue ); else - pos.y = ValueFromString( m_frame->GetUserUnits(), aValue ); + pos.y = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, m_frame->GetUserUnits(), aValue ); text.SetPos0( pos ); text.SetDrawCoord(); diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index b480704eb5..5424af83fa 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -39,7 +39,7 @@ FP_TEXTBOX::FP_TEXTBOX( FOOTPRINT* aParentFootprint ) : FP_SHAPE( aParentFootprint, SHAPE_T::RECT, PCB_FP_TEXTBOX_T ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( pcbIUScale ) { SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); SetVertJustify( GR_TEXT_V_ALIGN_TOP ); @@ -314,17 +314,17 @@ void FP_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() ); - aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) ); - aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, GetTextWidth() ) ); - aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, GetTextHeight() ) ); + aList.emplace_back( _( "Thickness" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextThickness() ) ); + aList.emplace_back( _( "Text Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextWidth() ) ); + aList.emplace_back( _( "Text Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextHeight() ) ); - wxString msg = MessageTextFromValue( units, std::abs( GetEnd().x - GetStart().x ) ); + wxString msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, std::abs( GetEnd().x - GetStart().x ) ); aList.emplace_back( _( "Box Width" ), msg ); - msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, std::abs( GetEnd().y - GetStart().y ) ); aList.emplace_back( _( "Box Height" ), msg ); - m_stroke.GetMsgPanelInfo( units, aList ); + m_stroke.GetMsgPanelInfo( pcbIUScale, units, aList ); } diff --git a/pcbnew/import_gfx/dialog_import_gfx.cpp b/pcbnew/import_gfx/dialog_import_gfx.cpp index d40ff33c89..af7e7d0900 100644 --- a/pcbnew/import_gfx/dialog_import_gfx.cpp +++ b/pcbnew/import_gfx/dialog_import_gfx.cpp @@ -139,7 +139,7 @@ DIALOG_IMPORT_GFX::~DIALOG_IMPORT_GFX() cfg->m_ImportGraphics.origin_y = Iu2Millimeter( m_yOrigin.GetValue() ); cfg->m_ImportGraphics.dxf_units = m_choiceDxfUnits->GetSelection(); - m_importScale = DoubleValueFromString( EDA_UNITS::UNSCALED, m_importScaleCtrl->GetValue() ); + m_importScale = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_importScaleCtrl->GetValue() ); m_textCtrlFileName->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_IMPORT_GFX::onFilename ), @@ -215,7 +215,7 @@ bool DIALOG_IMPORT_GFX::TransferDataFromWindow() } wxString ext = wxFileName( m_textCtrlFileName->GetValue() ).GetExt(); - double scale = DoubleValueFromString( EDA_UNITS::UNSCALED, m_importScaleCtrl->GetValue() ); + double scale = EDA_UNIT_UTILS::UI::DoubleValueFromString( m_importScaleCtrl->GetValue() ); VECTOR2D origin( m_xOrigin.GetValue() / scale, m_yOrigin.GetValue() / scale ); if( std::unique_ptr plugin = m_gfxImportMgr->GetPluginByExt( ext ) ) diff --git a/pcbnew/microwave/microwave_footprint.cpp b/pcbnew/microwave/microwave_footprint.cpp index 5c3c928e5b..aabe3661da 100644 --- a/pcbnew/microwave/microwave_footprint.cpp +++ b/pcbnew/microwave/microwave_footprint.cpp @@ -76,14 +76,14 @@ FOOTPRINT* MICROWAVE_TOOL::createFootprint( MICROWAVE_FOOTPRINT_SHAPE aFootprint break; } - wxString value = StringFromValue( editFrame.GetUserUnits(), gap_size ); + wxString value = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, editFrame.GetUserUnits(), gap_size ); WX_TEXT_ENTRY_DIALOG dlg( &editFrame, msg, _( "Create Microwave Footprint" ), value ); if( dlg.ShowQuasiModal() != wxID_OK ) return nullptr; // cancelled by user value = dlg.GetValue(); - gap_size = ValueFromString( editFrame.GetUserUnits(), value ); + gap_size = EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, editFrame.GetUserUnits(), value ); bool abort = false; diff --git a/pcbnew/microwave/microwave_inductor.cpp b/pcbnew/microwave/microwave_inductor.cpp index 0856633567..47caadc959 100644 --- a/pcbnew/microwave/microwave_inductor.cpp +++ b/pcbnew/microwave/microwave_inductor.cpp @@ -364,14 +364,15 @@ FOOTPRINT* MICROWAVE_TOOL::createMicrowaveInductor( MICROWAVE_INDUCTOR_PATTERN& aInductorPattern.m_Length = min_len; // Enter the desired length. - msg = StringFromValue( editFrame.GetUserUnits(), aInductorPattern.m_Length ); + msg = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, editFrame.GetUserUnits(), aInductorPattern.m_Length ); WX_TEXT_ENTRY_DIALOG dlg( &editFrame, _( "Length of Trace:" ), wxEmptyString, msg ); if( dlg.ShowQuasiModal() != wxID_OK ) return nullptr; // canceled by user msg = dlg.GetValue(); - aInductorPattern.m_Length = ValueFromString( editFrame.GetUserUnits(), msg ); + aInductorPattern.m_Length = + EDA_UNIT_UTILS::UI::ValueFromString( pcbIUScale, editFrame.GetUserUnits(), msg ); // Control values (ii = minimum length) if( aInductorPattern.m_Length < min_len ) diff --git a/pcbnew/netinfo_item.cpp b/pcbnew/netinfo_item.cpp index cfb46a3022..0e0f1afbff 100644 --- a/pcbnew/netinfo_item.cpp +++ b/pcbnew/netinfo_item.cpp @@ -128,15 +128,15 @@ void NETINFO_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetTrackLength( *startTrack ); // Displays the full net length (tracks on pcb + internal ICs connections ): - msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthNet + lengthPadToDie ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), lengthNet + lengthPadToDie ); aList.emplace_back( _( "Net Length" ), msg ); // Displays the net length of tracks only: - msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthNet ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), lengthNet ); aList.emplace_back( _( "On Board" ), msg ); // Displays the net length of internal ICs connections (wires inside ICs): - msg = MessageTextFromValue( aFrame->GetUserUnits(), lengthPadToDie ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), lengthPadToDie ); aList.emplace_back( _( "In Package" ), msg ); } } diff --git a/pcbnew/netlist_reader/board_netlist_updater.cpp b/pcbnew/netlist_reader/board_netlist_updater.cpp index 9bc84df98c..7c6641530e 100644 --- a/pcbnew/netlist_reader/board_netlist_updater.cpp +++ b/pcbnew/netlist_reader/board_netlist_updater.cpp @@ -766,8 +766,8 @@ bool BOARD_NETLIST_UPDATER::updateCopperZoneNets( NETLIST& aNetlist ) msg.Printf( _( "Copper zone on layer %s at (%s, %s) has no pads connected." ), m_board->GetLayerName( layer ), - MessageTextFromValue( m_frame->GetUserUnits(), pos.x ), - MessageTextFromValue( m_frame->GetUserUnits(), pos.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), pos.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), pos.y ) ); } m_reporter->Report( msg, RPT_SEVERITY_WARNING ); diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 223033862d..9253508380 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -60,8 +60,8 @@ using KIGFX::PCB_RENDER_SETTINGS; PAD::PAD( FOOTPRINT* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) { - m_size.x = m_size.y = Mils2iu( 60 ); // Default pad size 60 mils. - m_drill.x = m_drill.y = Mils2iu( 30 ); // Default drill size 30 mils. + m_size.x = m_size.y = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 60 ); // Default pad size 60 mils. + m_drill.x = m_drill.y = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 30 ); // Default drill size 30 mils. m_orient = ANGLE_0; m_lengthPadToDie = 0; @@ -987,12 +987,12 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& if( ( GetShape() == PAD_SHAPE::CIRCLE || GetShape() == PAD_SHAPE::OVAL ) && m_size.x == m_size.y ) { - aList.emplace_back( _( "Diameter" ), MessageTextFromValue( units, m_size.x ) ); + aList.emplace_back( _( "Diameter" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_size.x ) ); } else { - aList.emplace_back( _( "Width" ), MessageTextFromValue( units, m_size.x ) ); - aList.emplace_back( _( "Height" ), MessageTextFromValue( units, m_size.y ) ); + aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_size.x ) ); + aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_size.y ) ); } EDA_ANGLE fp_orient = parentFootprint ? parentFootprint->GetOrientation() : ANGLE_0; @@ -1008,7 +1008,7 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& if( GetPadToDieLength() ) { - msg = MessageTextFromValue(units, GetPadToDieLength() ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetPadToDieLength() ); aList.emplace_back( _( "Length in Package" ), msg ); } @@ -1018,14 +1018,14 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& { aList.emplace_back( _( "Hole" ), wxString::Format( wxT( "%s" ), - MessageTextFromValue( units, m_drill.x ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_drill.x ) ) ); } else { aList.emplace_back( _( "Hole X / Y" ), wxString::Format( wxT( "%s / %s" ), - MessageTextFromValue( units, m_drill.x ), - MessageTextFromValue( units, m_drill.y ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_drill.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_drill.y ) ) ); } } @@ -1035,7 +1035,7 @@ void PAD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& if( !source.IsEmpty() ) { aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ), - MessageTextFromValue( units, clearance ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, clearance ) ), wxString::Format( _( "(from %s)" ), source ) ); } diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 825441d821..ef63f7f74a 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -73,7 +73,7 @@ wxDEFINE_EVENT( BOARD_CHANGED, wxCommandEvent ); PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aFrameName ) : - EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ), + EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, pcbIUScale ), m_pcb( nullptr ), m_originTransforms( *this ), m_spaceMouse( nullptr ) @@ -783,8 +783,10 @@ void PCB_BASE_FRAME::DisplayGridMsg() wxString line; line.Printf( wxT( "grid X %s Y %s" ), - MessageTextFromValue( m_userUnits, gridSize.x, false ), - MessageTextFromValue( m_userUnits, gridSize.y, false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), m_userUnits, gridSize.x, + false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), m_userUnits, gridSize.y, + false ) ); SetStatusText( line, 4 ); } @@ -810,7 +812,8 @@ void PCB_BASE_FRAME::UpdateStatusBar() double ro = hypot( dx, dy ); line.Printf( wxT( "r %s theta %.3f" ), - MessageTextFromValue( GetUserUnits(), ro, false ), theta ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), ro, false ), + theta ); SetStatusText( line, 3 ); } @@ -821,8 +824,10 @@ void PCB_BASE_FRAME::UpdateStatusBar() // Display absolute coordinates: line.Printf( wxT( "X %s Y %s" ), - MessageTextFromValue( GetUserUnits(), userXpos, false ), - MessageTextFromValue( GetUserUnits(), userYpos, false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), userXpos, + false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), userYpos, + false ) ); SetStatusText( line, 2 ); if( !GetShowPolarCoords() ) // display relative cartesian coordinates @@ -836,9 +841,12 @@ void PCB_BASE_FRAME::UpdateStatusBar() userYpos = m_originTransforms.ToDisplayRelY( relYpos ); line.Printf( wxT( "dx %s dy %s dist %s" ), - MessageTextFromValue( GetUserUnits(), userXpos, false ), - MessageTextFromValue( GetUserUnits(), userYpos, false ), - MessageTextFromValue( GetUserUnits(), hypot( userXpos, userYpos ), false ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + userXpos, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + userYpos, false ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), + hypot( userXpos, userYpos ), false ) ); SetStatusText( line, 3 ); } diff --git a/pcbnew/pcb_bitmap.cpp b/pcbnew/pcb_bitmap.cpp index d3ea64fd80..8adb9fe3fd 100644 --- a/pcbnew/pcb_bitmap.cpp +++ b/pcbnew/pcb_bitmap.cpp @@ -209,9 +209,9 @@ void PCB_BITMAP::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), GetSize().x ) ); + aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), GetSize().x ) ); aList.emplace_back( _( "Height" ), - MessageTextFromValue( aFrame->GetUserUnits(), GetSize().y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), GetSize().y ) ); aList.emplace_back( _( "Layer" ), LayerName( m_layer ) ); } diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index d762244aec..2c2cf73f1a 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -124,7 +124,7 @@ wxString PCB_DIMENSION_BASE::GetValueText() const wxString format = wxT( "%." ) + wxString::Format( wxT( "%i" ), precision ) + wxT( "f" ); - text.Printf( format, To_User_Unit( m_units, val ) ); + text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, m_units, val ) ); if( m_suppressZeroes ) { @@ -336,9 +336,9 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, aList.emplace_back( _( "Font" ), m_text.GetDrawFont()->GetName() ); aList.emplace_back( _( "Text Thickness" ), - MessageTextFromValue( units, m_text.GetTextThickness() ) ); - aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, m_text.GetTextWidth() ) ); - aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, m_text.GetTextHeight() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextThickness() ) ); + aList.emplace_back( _( "Text Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextWidth() ) ); + aList.emplace_back( _( "Text Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextHeight() ) ); ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms(); units = aFrame->GetUserUnits(); @@ -347,8 +347,8 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, { VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( wxT( "@(%s, %s)" ), - MessageTextFromValue( units, startCoord.x ), - MessageTextFromValue( units, startCoord.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.y ) ); aList.emplace_back( start, wxEmptyString ); } @@ -356,12 +356,12 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, { VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( wxT( "@(%s, %s)" ), - MessageTextFromValue( units, startCoord.x ), - MessageTextFromValue( units, startCoord.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.y ) ); VECTOR2I endCoord = originTransforms.ToDisplayAbs( GetEnd() ); wxString end = wxString::Format( wxT( "@(%s, %s)" ), - MessageTextFromValue( units, endCoord.x ), - MessageTextFromValue( units, endCoord.y ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, endCoord.x ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, endCoord.y ) ); aList.emplace_back( start, end ); } @@ -738,7 +738,7 @@ void PCB_DIM_ALIGNED::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), m_height ) ); + aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), m_height ) ); } @@ -1091,8 +1091,8 @@ void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() ); - aList.emplace_back( _( "Thickness" ), MessageTextFromValue( units, GetTextThickness() ) ); - aList.emplace_back( _( "Width" ), MessageTextFromValue( units, GetTextWidth() ) ); - aList.emplace_back( _( "Height" ), MessageTextFromValue( units, GetTextHeight() ) ); + aList.emplace_back( _( "Thickness" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextThickness() ) ); + aList.emplace_back( _( "Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextWidth() ) ); + aList.emplace_back( _( "Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextHeight() ) ); } diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index 730d6967e7..922fb1d6ab 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -39,7 +39,7 @@ PCB_TEXTBOX::PCB_TEXTBOX( BOARD_ITEM* parent ) : PCB_SHAPE( parent, PCB_TEXTBOX_T, SHAPE_T::RECT ), - EDA_TEXT( Mils2iu( DEFAULT_SIZE_TEXT ) ) + EDA_TEXT( pcbIUScale ) { SetHorizJustify( GR_TEXT_H_ALIGN_LEFT ); SetVertJustify( GR_TEXT_V_ALIGN_TOP ); @@ -308,17 +308,17 @@ void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetName() ); - aList.emplace_back( _( "Text Thickness" ), MessageTextFromValue( units, GetTextThickness() ) ); - aList.emplace_back( _( "Text Width" ), MessageTextFromValue( units, GetTextWidth() ) ); - aList.emplace_back( _( "Text Height" ), MessageTextFromValue( units, GetTextHeight() ) ); + aList.emplace_back( _( "Text Thickness" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextThickness() ) ); + aList.emplace_back( _( "Text Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextWidth() ) ); + aList.emplace_back( _( "Text Height" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetTextHeight() ) ); - wxString msg = MessageTextFromValue( units, std::abs( GetEnd().x - GetStart().x ) ); + wxString msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, std::abs( GetEnd().x - GetStart().x ) ); aList.emplace_back( _( "Box Width" ), msg ); - msg = MessageTextFromValue( units, std::abs( GetEnd().y - GetStart().y ) ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, std::abs( GetEnd().y - GetStart().y ) ); aList.emplace_back( _( "Box Height" ), msg ); - m_stroke.GetMsgPanelInfo( units, aList ); + m_stroke.GetMsgPanelInfo( pcbIUScale, units, aList ); } diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp index 9f9d340927..2e223a2264 100644 --- a/pcbnew/pcb_track.cpp +++ b/pcbnew/pcb_track.cpp @@ -788,15 +788,15 @@ void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( this )->GetRadius(); - aList.emplace_back( _( "Radius" ), MessageTextFromValue( units, radius ) ); + aList.emplace_back( _( "Radius" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, radius ) ); } - aList.emplace_back( _( "Segment Length" ), MessageTextFromValue( units, GetLength() ) ); + aList.emplace_back( _( "Segment Length" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, GetLength() ) ); // Display full track length (in Pcbnew) if( board && GetNetCode() > 0 ) @@ -807,14 +807,14 @@ void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetTrackLength( *this ); - aList.emplace_back( _( "Routed Length" ), MessageTextFromValue( units, trackLen ) ); + aList.emplace_back( _( "Routed Length" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, trackLen ) ); if( lenPadToDie != 0 ) { - msg = MessageTextFromValue( units, lenPadToDie ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, lenPadToDie ); aList.emplace_back( _( "Pad To Die Length" ), msg ); - msg = MessageTextFromValue( units, trackLen + lenPadToDie ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, trackLen + lenPadToDie ); aList.emplace_back( _( "Full Length" ), msg ); } } @@ -823,7 +823,7 @@ void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector c = GetWidthConstraint( &source ); @@ -831,14 +831,14 @@ void PCB_TRACK::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), m_Width ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), m_Width ); aList.emplace_back( _( "Diameter" ), msg ); - msg = MessageTextFromValue( aFrame->GetUserUnits(), GetDrillValue() ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aFrame->GetUserUnits(), GetDrillValue() ); aList.emplace_back( _( "Hole" ), msg ); @@ -875,13 +875,13 @@ void PCB_VIA::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector( EDA_UNITS::INCHES ) ) ); // Convert to internal units - x = From_User_Unit( u, x ); - y = From_User_Unit( u, y ); + x = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, x ); + y = EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, u, y ); - Set( "window.grid.user_grid_x", StringFromValue( u, x ) ); - Set( "window.grid.user_grid_y", StringFromValue( u, y ) ); + Set( "window.grid.user_grid_x", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, x ) ); + Set( "window.grid.user_grid_y", EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, u, y ) ); } // Footprint editor settings were stored in pcbnew config file. Migrate them here. diff --git a/pcbnew/plugins/eagle/eagle_plugin.cpp b/pcbnew/plugins/eagle/eagle_plugin.cpp index c4eb85a448..a08d7ad2a3 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.cpp +++ b/pcbnew/plugins/eagle/eagle_plugin.cpp @@ -2621,7 +2621,7 @@ void EAGLE_PLUGIN::loadClasses( wxXmlNode* aClasses ) entry.first, eClass.name, m_classMap[ entry.first ]->GetName(), - StringFromValue( EDA_UNITS::MILLIMETRES, entry.second.ToPcbUnits() ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::MILLIMETRES, entry.second.ToPcbUnits() ) ); m_customRules += wxT( "\n" ) + rule; } diff --git a/pcbnew/plugins/eagle/eagle_plugin.h b/pcbnew/plugins/eagle/eagle_plugin.h index e4797f7061..e40280171a 100644 --- a/pcbnew/plugins/eagle/eagle_plugin.h +++ b/pcbnew/plugins/eagle/eagle_plugin.h @@ -25,7 +25,7 @@ #ifndef EAGLE_PLUGIN_H #define EAGLE_PLUGIN_H -#include +#include #include #include #include @@ -55,27 +55,27 @@ struct ERULES mvStopFrame ( 1.0 ), mvCreamFrame ( 0.0 ), - mlMinStopFrame ( Mils2iu( 4.0 ) ), - mlMaxStopFrame ( Mils2iu( 4.0 ) ), - mlMinCreamFrame ( Mils2iu( 0.0 ) ), - mlMaxCreamFrame ( Mils2iu( 0.0 ) ), + mlMinStopFrame ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 4.0 ) ), + mlMaxStopFrame ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 4.0 ) ), + mlMinCreamFrame ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 0.0 ) ), + mlMaxCreamFrame ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 0.0 ) ), psTop ( EPAD::UNDEF ), psBottom ( EPAD::UNDEF ), psFirst ( EPAD::UNDEF ), srRoundness ( 0.0 ), - srMinRoundness ( Mils2iu( 0.0 ) ), - srMaxRoundness ( Mils2iu( 0.0 ) ), + srMinRoundness ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 0.0 ) ), + srMaxRoundness ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 0.0 ) ), rvPadTop ( 0.25 ), // rvPadBottom ( 0.25 ), - rlMinPadTop ( Mils2iu( 10 ) ), - rlMaxPadTop ( Mils2iu( 20 ) ), + rlMinPadTop ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 10 ) ), + rlMaxPadTop ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 20 ) ), rvViaOuter ( 0.25 ), - rlMinViaOuter ( Mils2iu( 10 ) ), - rlMaxViaOuter ( Mils2iu( 20 ) ), + rlMinViaOuter ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 10 ) ), + rlMaxViaOuter ( EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 20 ) ), mdWireWire ( 0 ) {} diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 5c526570f6..73821c2514 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -507,16 +507,16 @@ void PCB_PLUGIN::formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel, if( ind < 0 ) { m_out->Print( nestLevel, "(xy %s)", - FormatInternalUnits( outline.CPoint( ii ) ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, outline.CPoint( ii ) ).c_str() ); needNewline = true; } else { const SHAPE_ARC& arc = outline.Arc( ind ); m_out->Print( nestLevel, "(arc (start %s) (mid %s) (end %s))", - FormatInternalUnits( arc.GetP0() ).c_str(), - FormatInternalUnits( arc.GetArcMid() ).c_str(), - FormatInternalUnits( arc.GetP1() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc.GetP0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc.GetArcMid() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc.GetP1() ).c_str() ); needNewline = true; do @@ -591,18 +591,18 @@ void PCB_PLUGIN::formatSetup( const BOARD* aBoard, int aNestLevel ) const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings(); m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n", - FormatInternalUnits( dsnSettings.m_SolderMaskExpansion ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, dsnSettings.m_SolderMaskExpansion ).c_str() ); if( dsnSettings.m_SolderMaskMinWidth ) { m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n", - FormatInternalUnits( dsnSettings.m_SolderMaskMinWidth ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, dsnSettings.m_SolderMaskMinWidth ).c_str() ); } if( dsnSettings.m_SolderPasteMargin != 0 ) { m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n", - FormatInternalUnits( dsnSettings.m_SolderPasteMargin ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, dsnSettings.m_SolderPasteMargin ).c_str() ); } if( dsnSettings.m_SolderPasteMarginRatio != 0 ) @@ -621,8 +621,8 @@ void PCB_PLUGIN::formatSetup( const BOARD* aBoard, int aNestLevel ) const if( origin != VECTOR2I( 0, 0 ) ) { m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n", - FormatInternalUnits( origin.x ).c_str(), - FormatInternalUnits( origin.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, origin.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, origin.y ).c_str() ); } origin = dsnSettings.GetGridOrigin(); @@ -630,8 +630,8 @@ void PCB_PLUGIN::formatSetup( const BOARD* aBoard, int aNestLevel ) const if( origin != VECTOR2I( 0, 0 ) ) { m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", - FormatInternalUnits( origin.x ).c_str(), - FormatInternalUnits( origin.y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, origin.x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, origin.y ).c_str() ); } aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 ); @@ -647,7 +647,7 @@ void PCB_PLUGIN::formatGeneral( const BOARD* aBoard, int aNestLevel ) const m_out->Print( 0, "\n" ); m_out->Print( aNestLevel, "(general\n" ); m_out->Print( aNestLevel+1, "(thickness %s)\n", - FormatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, dsnSettings.GetBoardThickness() ).c_str() ); m_out->Print( aNestLevel, ")\n\n" ); @@ -855,21 +855,21 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel ) m_out->Print( 0, "\n" ); m_out->Print( aNestLevel+1, "(pts (xy %s %s) (xy %s %s))\n", - FormatInternalUnits( aDimension->GetStart().x ).c_str(), - FormatInternalUnits( aDimension->GetStart().y ).c_str(), - FormatInternalUnits( aDimension->GetEnd().x ).c_str(), - FormatInternalUnits( aDimension->GetEnd().y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetStart().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetStart().y ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetEnd().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetEnd().y ).c_str() ); if( aligned ) { m_out->Print( aNestLevel+1, "(height %s)\n", - FormatInternalUnits( aligned->GetHeight() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aligned->GetHeight() ).c_str() ); } if( radial ) { m_out->Print( aNestLevel+1, "(leader_length %s)\n", - FormatInternalUnits( radial->GetLeaderLength() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, radial->GetLeaderLength() ).c_str() ); } if( ortho ) @@ -905,21 +905,21 @@ void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel ) } m_out->Print( aNestLevel+1, "(style (thickness %s) (arrow_length %s) (text_position_mode %d)", - FormatInternalUnits( aDimension->GetLineThickness() ).c_str(), - FormatInternalUnits( aDimension->GetArrowLength() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetLineThickness() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetArrowLength() ).c_str(), static_cast( aDimension->GetTextPositionMode() ) ); if( aligned ) { m_out->Print( 0, " (extension_height %s)", - FormatInternalUnits( aligned->GetExtensionHeight() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aligned->GetExtensionHeight() ).c_str() ); } if( leader ) m_out->Print( 0, " (text_frame %d)", static_cast( leader->GetTextBorder() ) ); m_out->Print( 0, " (extension_offset %s)", - FormatInternalUnits( aDimension->GetExtensionOffset() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aDimension->GetExtensionOffset() ).c_str() ); if( aDimension->GetKeepTextAligned() ) m_out->Print( 0, " keep_text_aligned" ); @@ -939,30 +939,30 @@ void PCB_PLUGIN::format( const PCB_SHAPE* aShape, int aNestLevel ) const case SHAPE_T::SEGMENT: m_out->Print( aNestLevel, "(gr_line%s (start %s) (end %s)", locked.c_str(), - FormatInternalUnits( aShape->GetStart() ).c_str(), - FormatInternalUnits( aShape->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetEnd() ).c_str() ); break; case SHAPE_T::RECT: m_out->Print( aNestLevel, "(gr_rect%s (start %s) (end %s)", locked.c_str(), - FormatInternalUnits( aShape->GetStart() ).c_str(), - FormatInternalUnits( aShape->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetEnd() ).c_str() ); break; case SHAPE_T::CIRCLE: m_out->Print( aNestLevel, "(gr_circle%s (center %s) (end %s)", locked.c_str(), - FormatInternalUnits( aShape->GetStart() ).c_str(), - FormatInternalUnits( aShape->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetEnd() ).c_str() ); break; case SHAPE_T::ARC: m_out->Print( aNestLevel, "(gr_arc%s (start %s) (mid %s) (end %s)", locked.c_str(), - FormatInternalUnits( aShape->GetStart() ).c_str(), - FormatInternalUnits( aShape->GetArcMid() ).c_str(), - FormatInternalUnits( aShape->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetArcMid() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetEnd() ).c_str() ); break; case SHAPE_T::POLY: @@ -985,10 +985,10 @@ void PCB_PLUGIN::format( const PCB_SHAPE* aShape, int aNestLevel ) const case SHAPE_T::BEZIER: m_out->Print( aNestLevel, "(gr_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))", locked.c_str(), - FormatInternalUnits( aShape->GetStart() ).c_str(), - FormatInternalUnits( aShape->GetBezierC1() ).c_str(), - FormatInternalUnits( aShape->GetBezierC2() ).c_str(), - FormatInternalUnits( aShape->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetBezierC1() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetBezierC2() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aShape->GetEnd() ).c_str() ); break; default: @@ -998,7 +998,7 @@ void PCB_PLUGIN::format( const PCB_SHAPE* aShape, int aNestLevel ) const m_out->Print( 0, "\n" ); - aShape->GetStroke().Format( m_out, aNestLevel + 1 ); + aShape->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 ); // The filled flag represents if a solid fill is present on circles, rectangles and polygons if( ( aShape->GetShape() == SHAPE_T::POLY ) @@ -1028,8 +1028,8 @@ void PCB_PLUGIN::format( const PCB_BITMAP* aBitmap, int aNestLevel ) const wxCHECK_RET( image != nullptr, "wxImage* is NULL" ); m_out->Print( aNestLevel, "(image (at %s %s)", - FormatInternalUnits( aBitmap->GetPosition().x ).c_str(), - FormatInternalUnits( aBitmap->GetPosition().y ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aBitmap->GetPosition().x ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aBitmap->GetPosition().y ).c_str() ); formatLayer( aBitmap->GetLayer() ); @@ -1076,30 +1076,30 @@ void PCB_PLUGIN::format( const FP_SHAPE* aFPShape, int aNestLevel ) const case SHAPE_T::SEGMENT: m_out->Print( aNestLevel, "(fp_line%s (start %s) (end %s)", locked.c_str(), - FormatInternalUnits( aFPShape->GetStart0() ).c_str(), - FormatInternalUnits( aFPShape->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetEnd0() ).c_str() ); break; case SHAPE_T::RECT: m_out->Print( aNestLevel, "(fp_rect%s (start %s) (end %s)", locked.c_str(), - FormatInternalUnits( aFPShape->GetStart0() ).c_str(), - FormatInternalUnits( aFPShape->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetEnd0() ).c_str() ); break; case SHAPE_T::CIRCLE: m_out->Print( aNestLevel, "(fp_circle%s (center %s) (end %s)", locked.c_str(), - FormatInternalUnits( aFPShape->GetStart0() ).c_str(), - FormatInternalUnits( aFPShape->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetEnd0() ).c_str() ); break; case SHAPE_T::ARC: m_out->Print( aNestLevel, "(fp_arc%s (start %s) (mid %s) (end %s)", locked.c_str(), - FormatInternalUnits( aFPShape->GetStart0() ).c_str(), - FormatInternalUnits( aFPShape->GetArcMid0() ).c_str(), - FormatInternalUnits( aFPShape->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetArcMid0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetEnd0() ).c_str() ); break; case SHAPE_T::POLY: @@ -1121,10 +1121,10 @@ void PCB_PLUGIN::format( const FP_SHAPE* aFPShape, int aNestLevel ) const case SHAPE_T::BEZIER: m_out->Print( aNestLevel, "(fp_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))", locked.c_str(), - FormatInternalUnits( aFPShape->GetStart0() ).c_str(), - FormatInternalUnits( aFPShape->GetBezierC1_0() ).c_str(), - FormatInternalUnits( aFPShape->GetBezierC2_0() ).c_str(), - FormatInternalUnits( aFPShape->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetBezierC1_0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetBezierC2_0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFPShape->GetEnd0() ).c_str() ); break; default: @@ -1134,7 +1134,7 @@ void PCB_PLUGIN::format( const FP_SHAPE* aFPShape, int aNestLevel ) const m_out->Print( 0, "\n" ); - aFPShape->GetStroke().Format( m_out, aNestLevel + 1 ); + aFPShape->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 ); // The filled flag represents if a solid fill is present on circles, rectangles and polygons if( ( aFPShape->GetShape() == SHAPE_T::POLY ) @@ -1159,11 +1159,11 @@ void PCB_PLUGIN::format( const PCB_TARGET* aTarget, int aNestLevel ) const { m_out->Print( aNestLevel, "(target %s (at %s) (size %s)", ( aTarget->GetShape() ) ? "x" : "plus", - FormatInternalUnits( aTarget->GetPosition() ).c_str(), - FormatInternalUnits( aTarget->GetSize() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTarget->GetPosition() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTarget->GetSize() ).c_str() ); if( aTarget->GetWidth() != 0 ) - m_out->Print( 0, " (width %s)", FormatInternalUnits( aTarget->GetWidth() ).c_str() ); + m_out->Print( 0, " (width %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTarget->GetWidth() ).c_str() ); formatLayer( aTarget->GetLayer() ); @@ -1218,7 +1218,7 @@ void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const if( !( m_ctl & CTL_OMIT_AT ) ) { m_out->Print( aNestLevel+1, "(at %s", - FormatInternalUnits( aFootprint->GetPosition() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFootprint->GetPosition() ).c_str() ); if( !aFootprint->GetOrientation().IsZero() ) m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aFootprint->GetOrientation() ).c_str() ); @@ -1256,13 +1256,13 @@ void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const if( aFootprint->GetLocalSolderMaskMargin() != 0 ) { m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n", - FormatInternalUnits( aFootprint->GetLocalSolderMaskMargin() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFootprint->GetLocalSolderMaskMargin() ).c_str() ); } if( aFootprint->GetLocalSolderPasteMargin() != 0 ) { m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n", - FormatInternalUnits( aFootprint->GetLocalSolderPasteMargin() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFootprint->GetLocalSolderPasteMargin() ).c_str() ); } if( aFootprint->GetLocalSolderPasteMarginRatio() != 0 ) @@ -1274,7 +1274,7 @@ void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const if( aFootprint->GetLocalClearance() != 0 ) { m_out->Print( aNestLevel+1, "(clearance %s)\n", - FormatInternalUnits( aFootprint->GetLocalClearance() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aFootprint->GetLocalClearance() ).c_str() ); } if( aFootprint->GetZoneConnection() != ZONE_CONNECTION::INHERITED ) @@ -1551,17 +1551,17 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const if( aPad->IsLocked() ) m_out->Print( 0, " locked" ); - m_out->Print( 0, " (at %s", FormatInternalUnits( aPad->GetPos0() ).c_str() ); + m_out->Print( 0, " (at %s", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetPos0() ).c_str() ); if( !aPad->GetOrientation().IsZero() ) m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aPad->GetOrientation() ).c_str() ); m_out->Print( 0, ")" ); - m_out->Print( 0, " (size %s)", FormatInternalUnits( aPad->GetSize() ).c_str() ); + m_out->Print( 0, " (size %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetSize() ).c_str() ); if( (aPad->GetDelta().x) != 0 || (aPad->GetDelta().y != 0 ) ) - m_out->Print( 0, " (rect_delta %s)", FormatInternalUnits( aPad->GetDelta() ).c_str() ); + m_out->Print( 0, " (rect_delta %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetDelta() ).c_str() ); VECTOR2I sz = aPad->GetDrillSize(); VECTOR2I shapeoffset = aPad->GetOffset(); @@ -1575,13 +1575,13 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const m_out->Print( 0, " oval" ); if( sz.x > 0 ) - m_out->Print( 0, " %s", FormatInternalUnits( sz.x ).c_str() ); + m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, sz.x ).c_str() ); if( sz.y > 0 && sz.x != sz.y ) - m_out->Print( 0, " %s", FormatInternalUnits( sz.y ).c_str() ); + m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, sz.y ).c_str() ); if( (shapeoffset.x != 0) || (shapeoffset.y != 0) ) - m_out->Print( 0, " (offset %s)", FormatInternalUnits( aPad->GetOffset() ).c_str() ); + m_out->Print( 0, " (offset %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetOffset() ).c_str() ); m_out->Print( 0, ")" ); } @@ -1664,19 +1664,19 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const if( aPad->GetPadToDieLength() != 0 ) { StrPrintf( &output, " (die_length %s)", - FormatInternalUnits( aPad->GetPadToDieLength() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetPadToDieLength() ).c_str() ); } if( aPad->GetLocalSolderMaskMargin() != 0 ) { StrPrintf( &output, " (solder_mask_margin %s)", - FormatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetLocalSolderMaskMargin() ).c_str() ); } if( aPad->GetLocalSolderPasteMargin() != 0 ) { StrPrintf( &output, " (solder_paste_margin %s)", - FormatInternalUnits( aPad->GetLocalSolderPasteMargin() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetLocalSolderPasteMargin() ).c_str() ); } if( aPad->GetLocalSolderPasteMarginRatio() != 0 ) @@ -1688,7 +1688,7 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const if( aPad->GetLocalClearance() != 0 ) { StrPrintf( &output, " (clearance %s)", - FormatInternalUnits( aPad->GetLocalClearance() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetLocalClearance() ).c_str() ); } if( aPad->GetZoneConnection() != ZONE_CONNECTION::INHERITED ) @@ -1700,7 +1700,7 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const if( aPad->GetThermalSpokeWidth() != 0 ) { StrPrintf( &output, " (thermal_bridge_width %s)", - FormatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetThermalSpokeWidth() ).c_str() ); } if( ( aPad->GetShape() == PAD_SHAPE::CIRCLE && aPad->GetThermalSpokeAngle() != ANGLE_45 ) @@ -1713,7 +1713,7 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const if( aPad->GetThermalGap() != 0 ) { StrPrintf( &output, " (thermal_gap %s)", - FormatInternalUnits( aPad->GetThermalGap() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetThermalGap() ).c_str() ); } if( output.size() ) @@ -1759,44 +1759,44 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const { case SHAPE_T::SEGMENT: m_out->Print( nested_level, "(gr_line (start %s) (end %s)", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); break; case SHAPE_T::RECT: if( primitive->IsAnnotationProxy() ) { m_out->Print( nested_level, "(gr_bbox (start %s) (end %s)", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); } else { m_out->Print( nested_level, "(gr_rect (start %s) (end %s)", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); } break; case SHAPE_T::ARC: m_out->Print( nested_level, "(gr_arc (start %s) (mid %s) (end %s)", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetArcMid() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetArcMid() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); break; case SHAPE_T::CIRCLE: m_out->Print( nested_level, "(gr_circle (center %s) (end %s)", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); break; case SHAPE_T::BEZIER: m_out->Print( nested_level, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))", - FormatInternalUnits( primitive->GetStart() ).c_str(), - FormatInternalUnits( primitive->GetBezierC1() ).c_str(), - FormatInternalUnits( primitive->GetBezierC2() ).c_str(), - FormatInternalUnits( primitive->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetBezierC1() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetBezierC2() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetEnd() ).c_str() ); break; case SHAPE_T::POLY: @@ -1816,7 +1816,7 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const } m_out->Print( 0, " (width %s)", - FormatInternalUnits( primitive->GetWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, primitive->GetWidth() ).c_str() ); // The filled flag represents if a solid fill is present on circles, // rectangles and polygons @@ -1852,7 +1852,7 @@ void PCB_PLUGIN::format( const PCB_TEXT* aText, int aNestLevel ) const m_out->Print( 0, " %s (at %s", m_out->Quotew( aText->GetText() ).c_str(), - FormatInternalUnits( aText->GetTextPos() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aText->GetTextPos() ).c_str() ); if( !aText->GetTextAngle().IsZero() ) @@ -1887,8 +1887,8 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const if( aTextBox->GetShape() == SHAPE_T::RECT ) { m_out->Print( aNestLevel + 1, "(start %s) (end %s)", - FormatInternalUnits( aTextBox->GetStart() ).c_str(), - FormatInternalUnits( aTextBox->GetEnd() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTextBox->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTextBox->GetEnd() ).c_str() ); } else if( aTextBox->GetShape() == SHAPE_T::POLY ) { @@ -1915,7 +1915,7 @@ void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const aTextBox->EDA_TEXT::Format( m_out, aNestLevel + 1, m_ctl | CTL_OMIT_HIDE ); if( aTextBox->GetStroke().GetWidth() > 0 ) - aTextBox->GetStroke().Format( m_out, aNestLevel + 1 ); + aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 ); if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() ) formatRenderCache( aTextBox, aNestLevel + 1 ); @@ -1969,7 +1969,7 @@ void PCB_PLUGIN::format( const FP_TEXT* aText, int aNestLevel ) const type.c_str(), locked.c_str(), m_out->Quotew( aText->GetText() ).c_str(), - FormatInternalUnits( aText->GetPos0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aText->GetPos0() ).c_str() ); // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle, // but internally the angle is held relative to its parent footprint. parent @@ -2031,8 +2031,8 @@ void PCB_PLUGIN::format( const FP_TEXTBOX* aTextBox, int aNestLevel ) const if( aTextBox->GetShape() == SHAPE_T::RECT ) { m_out->Print( aNestLevel, "(start %s) (end %s)", - FormatInternalUnits( aTextBox->GetStart0() ).c_str(), - FormatInternalUnits( aTextBox->GetEnd0() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTextBox->GetStart0() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTextBox->GetEnd0() ).c_str() ); } else if( aTextBox->GetShape() == SHAPE_T::POLY ) { @@ -2059,7 +2059,7 @@ void PCB_PLUGIN::format( const FP_TEXTBOX* aTextBox, int aNestLevel ) const aTextBox->EDA_TEXT::Format( m_out, aNestLevel + 1, m_ctl | CTL_OMIT_HIDE ); if( aTextBox->GetStroke().GetWidth() > 0 ) - aTextBox->GetStroke().Format( m_out, aNestLevel + 1 ); + aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 ); if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() ) formatRenderCache( aTextBox, aNestLevel + 1 ); @@ -2105,8 +2105,8 @@ void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const m_out->Print( 0, " locked" ); m_out->Print( 0, " (at %s) (size %s)", - FormatInternalUnits( aTrack->GetStart() ).c_str(), - FormatInternalUnits( aTrack->GetWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTrack->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTrack->GetWidth() ).c_str() ); // Old boards were using UNDEFINED_DRILL_DIAMETER value in file for via drill when // via drill was the netclass value. @@ -2114,9 +2114,9 @@ void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const // always store the drill value, because netclass value is not stored in the board file. // Otherwise the drill value of some (old) vias can be unknown if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER ) - m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrill() ).c_str() ); + m_out->Print( 0, " (drill %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, via->GetDrill() ).c_str() ); else // Probably old board! - m_out->Print( 0, " (drill %s)", FormatInternalUnits( via->GetDrillValue() ).c_str() ); + m_out->Print( 0, " (drill %s)", EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, via->GetDrillValue() ).c_str() ); m_out->Print( 0, " (layers %s %s)", m_out->Quotew( LSET::Name( layer1 ) ).c_str(), @@ -2140,10 +2140,10 @@ void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const m_out->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s) (width %s)", locked.c_str(), - FormatInternalUnits( arc->GetStart() ).c_str(), - FormatInternalUnits( arc->GetMid() ).c_str(), - FormatInternalUnits( arc->GetEnd() ).c_str(), - FormatInternalUnits( arc->GetWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc->GetMid() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc->GetEnd() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, arc->GetWidth() ).c_str() ); m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( arc->GetLayer() ) ).c_str() ); } @@ -2153,9 +2153,9 @@ void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const m_out->Print( aNestLevel, "(segment%s (start %s) (end %s) (width %s)", locked.c_str(), - FormatInternalUnits( aTrack->GetStart() ).c_str(), - FormatInternalUnits( aTrack->GetEnd() ).c_str(), - FormatInternalUnits( aTrack->GetWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTrack->GetStart() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTrack->GetEnd() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aTrack->GetWidth() ).c_str() ); m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( aTrack->GetLayer() ) ).c_str() ); } @@ -2210,7 +2210,7 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const } m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(), - FormatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetBorderHatchPitch() ).c_str() ); if( aZone->GetAssignedPriority() > 0 ) m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetAssignedPriority() ); @@ -2257,10 +2257,10 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const } m_out->Print( 0, " (clearance %s))\n", - FormatInternalUnits( aZone->GetLocalClearance() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetLocalClearance() ).c_str() ); m_out->Print( aNestLevel+1, "(min_thickness %s)", - FormatInternalUnits( aZone->GetMinThickness() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetMinThickness() ).c_str() ); // We continue to write this for 3rd-party parsers, but we no longer read it (as of V7). m_out->Print( 0, " (filled_areas_thickness no)" ); @@ -2290,8 +2290,8 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const m_out->Print( 0, " (mode hatch)" ); m_out->Print( 0, " (thermal_gap %s) (thermal_bridge_width %s)", - FormatInternalUnits( aZone->GetThermalReliefGap() ).c_str(), - FormatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetThermalReliefGap() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetThermalReliefSpokeWidth() ).c_str() ); if( aZone->GetCornerSmoothingType() != ZONE_SETTINGS::SMOOTHING_NONE ) { @@ -2315,22 +2315,22 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const if( aZone->GetCornerRadius() != 0 ) m_out->Print( 0, " (radius %s)", - FormatInternalUnits( aZone->GetCornerRadius() ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetCornerRadius() ).c_str() ); } if( aZone->GetIslandRemovalMode() != ISLAND_REMOVAL_MODE::ALWAYS ) { m_out->Print( 0, " (island_removal_mode %d) (island_area_min %s)", static_cast( aZone->GetIslandRemovalMode() ), - FormatInternalUnits( aZone->GetMinIslandArea() / IU_PER_MM ).c_str() ); + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetMinIslandArea() / IU_PER_MM ).c_str() ); } if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN ) { m_out->Print( 0, "\n" ); m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)", - FormatInternalUnits( aZone->GetHatchThickness() ).c_str(), - FormatInternalUnits( aZone->GetHatchGap() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetHatchThickness() ).c_str(), + EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aZone->GetHatchGap() ).c_str(), Double2Str( aZone->GetHatchOrientation().AsDegrees() ).c_str() ); if( aZone->GetHatchSmoothingLevel() > 0 ) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 1f69dfc8c5..f937093c6f 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -533,7 +533,7 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, for( const std::shared_ptr& item : violations ) { SEVERITY severity = item->GetParent()->GetSeverity(); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, aUnits, severity, itemMap ) ) ); } fprintf( fp, "\n** Found %d unconnected pads **\n", static_cast( unconnected.size() ) ); @@ -541,7 +541,7 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, for( const std::shared_ptr& item : unconnected ) { SEVERITY severity = bds.GetSeverity( item->GetErrorCode() ); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, aUnits, severity, itemMap ) ) ); } fprintf( fp, "\n** Found %d Footprint errors **\n", static_cast( footprints.size() ) ); @@ -549,7 +549,7 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, for( const std::shared_ptr& item : footprints ) { SEVERITY severity = bds.GetSeverity( item->GetErrorCode() ); - fprintf( fp, "%s", TO_UTF8( item->ShowReport( aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( pcbIUScale, aUnits, severity, itemMap ) ) ); } fprintf( fp, "\n** End of Report **\n" ); diff --git a/pcbnew/router/pns_dp_meander_placer.cpp b/pcbnew/router/pns_dp_meander_placer.cpp index ab2ab7c929..7b5bc3331b 100644 --- a/pcbnew/router/pns_dp_meander_placer.cpp +++ b/pcbnew/router/pns_dp_meander_placer.cpp @@ -444,11 +444,11 @@ const wxString DP_MEANDER_PLACER::TuningInfo( EDA_UNITS aUnits ) const return _( "?" ); } - status += ::MessageTextFromValue( aUnits, m_lastLength ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_lastLength ); status += wxT( "/" ); - status += ::MessageTextFromValue( aUnits, m_settings.m_targetLength ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_settings.m_targetLength ); status += wxT( " (gap: " ); - status += ::MessageTextFromValue( aUnits, m_originPair.Gap() ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_originPair.Gap() ); status += wxT( ")" ); return status; diff --git a/pcbnew/router/pns_meander_placer.cpp b/pcbnew/router/pns_meander_placer.cpp index 3c3533f01c..2d2079aaaa 100644 --- a/pcbnew/router/pns_meander_placer.cpp +++ b/pcbnew/router/pns_meander_placer.cpp @@ -283,9 +283,9 @@ const wxString MEANDER_PLACER::TuningInfo( EDA_UNITS aUnits ) const return _( "?" ); } - status += ::MessageTextFromValue( aUnits, m_lastLength ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_lastLength ); status += wxT( "/" ); - status += ::MessageTextFromValue( aUnits, m_settings.m_targetLength ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_settings.m_targetLength ); return status; } diff --git a/pcbnew/router/pns_meander_skew_placer.cpp b/pcbnew/router/pns_meander_skew_placer.cpp index 00b6dad908..003e401baa 100644 --- a/pcbnew/router/pns_meander_skew_placer.cpp +++ b/pcbnew/router/pns_meander_skew_placer.cpp @@ -175,9 +175,9 @@ const wxString MEANDER_SKEW_PLACER::TuningInfo( EDA_UNITS aUnits ) const return _( "?" ); } - status += ::MessageTextFromValue( aUnits, m_lastLength - m_coupledLength ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_lastLength - m_coupledLength ); status += wxT( "/" ); - status += ::MessageTextFromValue( aUnits, m_settings.m_targetSkew ); + status += EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, m_settings.m_targetSkew ); return status; } diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 1768bb8f0e..7c3fc99ea7 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -231,7 +231,7 @@ protected: if( i == 0 ) msg = _( "Track netclass width" ); else - msg.Printf( _( "Track %s" ), MessageTextFromValue( units, width ) ); + msg.Printf( _( "Track %s" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, width ) ); int menuIdx = ID_POPUP_PCB_SELECT_WIDTH1 + i; Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK ); @@ -250,10 +250,10 @@ protected: { if( via.m_Drill > 0 ) msg.Printf( _("Via %s, hole %s" ), - MessageTextFromValue( units, via.m_Diameter ), - MessageTextFromValue( units, via.m_Drill ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Diameter ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Drill ) ); else - msg.Printf( _( "Via %s" ), MessageTextFromValue( units, via.m_Diameter ) ); + msg.Printf( _( "Via %s" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Diameter ) ); } int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i; @@ -357,13 +357,13 @@ protected: if( diffPair.m_ViaGap <= 0 ) { msg.Printf( _( "Width %s" ), - MessageTextFromValue( units, diffPair.m_Width ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Width ) ); } else { msg.Printf( _( "Width %s, via gap %s" ), - MessageTextFromValue( units, diffPair.m_Width ), - MessageTextFromValue( units, diffPair.m_ViaGap ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Width ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_ViaGap ) ); } } else @@ -371,15 +371,15 @@ protected: if( diffPair.m_ViaGap <= 0 ) { msg.Printf( _( "Width %s, gap %s" ), - MessageTextFromValue( units, diffPair.m_Width ), - MessageTextFromValue( units, diffPair.m_Gap ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Width ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Gap ) ); } else { msg.Printf( _( "Width %s, gap %s, via gap %s" ), - MessageTextFromValue( units, diffPair.m_Width ), - MessageTextFromValue( units, diffPair.m_Gap ), - MessageTextFromValue( units, diffPair.m_ViaGap ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Width ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_Gap ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, diffPair.m_ViaGap ) ); } } @@ -2414,7 +2414,7 @@ void ROUTER_TOOL::UpdateMessagePanel() int width = isDiffPair ? sizes.DiffPairWidth() : sizes.TrackWidth(); items.emplace_back( wxString::Format( _( "Track Width: %s" ), - MessageTextFromValue( units, width ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, width ) ), wxString::Format( _( "(from %s)" ), sizes.GetWidthSource() ) ); if( m_startItem ) @@ -2428,7 +2428,7 @@ void ROUTER_TOOL::UpdateMessagePanel() m_router->GetCurrentLayer(), &constraint ) ) { items.emplace_back( wxString::Format( _( "Min Clearance: %s" ), - MessageTextFromValue( units, constraint.m_Value.Min() ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, constraint.m_Value.Min() ) ), wxString::Format( _( "(from %s)" ), constraint.m_RuleName ) ); } } @@ -2436,7 +2436,7 @@ void ROUTER_TOOL::UpdateMessagePanel() if( isDiffPair ) { items.emplace_back( _( "Diff Pair Gap" ), - MessageTextFromValue( units, sizes.DiffPairGap() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, sizes.DiffPairGap() ) ); } frame()->SetMsgPanel( items ); diff --git a/pcbnew/toolbars_pcb_editor.cpp b/pcbnew/toolbars_pcb_editor.cpp index b461509df9..8fb82987df 100644 --- a/pcbnew/toolbars_pcb_editor.cpp +++ b/pcbnew/toolbars_pcb_editor.cpp @@ -632,7 +632,7 @@ static wxString ComboBoxUnits( EDA_UNITS aUnits, double aValue, bool aIncludeLab case EDA_UNITS::INCHES: format = wxT( "%.5f" ); break; } - text.Printf( format, To_User_Unit( aUnits, aValue ) ); + text.Printf( format, EDA_UNIT_UTILS::UI::ToUserUnit( pcbIUScale, aUnits, aValue ) ); if( aIncludeLabel ) text += EDA_UNIT_UTILS::GetAbbreviatedUnitsLabel( aUnits, EDA_DATA_TYPE::DISTANCE ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 90e3947999..3e8b75f681 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -207,7 +207,7 @@ void BOARD_INSPECTION_TOOL::reportHeader( const wxString& aTitle, BOARD_ITEM* a, wxString reportMin( EDA_UNITS aUnits, DRC_CONSTRAINT& aConstraint ) { if( aConstraint.m_Value.HasMin() ) - return StringFromValue( aUnits, aConstraint.m_Value.Min(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, aConstraint.m_Value.Min(), true ); else return wxT( "" ) + _( "undefined" ) + wxT( "" ); } @@ -216,7 +216,7 @@ wxString reportMin( EDA_UNITS aUnits, DRC_CONSTRAINT& aConstraint ) wxString reportOpt( EDA_UNITS aUnits, DRC_CONSTRAINT& aConstraint ) { if( aConstraint.m_Value.HasOpt() ) - return StringFromValue( aUnits, aConstraint.m_Value.Opt(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, aConstraint.m_Value.Opt(), true ); else return wxT( "" ) + _( "undefined" ) + wxT( "" ); } @@ -225,7 +225,7 @@ wxString reportOpt( EDA_UNITS aUnits, DRC_CONSTRAINT& aConstraint ) wxString reportMax( EDA_UNITS aUnits, DRC_CONSTRAINT& aConstraint ) { if( aConstraint.m_Value.HasMax() ) - return StringFromValue( aUnits, aConstraint.m_Value.Max(), true ); + return EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, aUnits, aConstraint.m_Value.Max(), true ); else return wxT( "" ) + _( "undefined" ) + wxT( "" ); } @@ -403,7 +403,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR { constraint = drcEngine.EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) ); @@ -416,7 +416,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR constraint = drcEngine.EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, a, b, layer, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); if( !drcEngine.HasRulesForConstraintType( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT ) ) { @@ -440,7 +440,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR constraint = drcEngine.EvalRules( HOLE_TO_HOLE_CONSTRAINT, a, b, UNDEFINED_LAYER, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) ); @@ -455,7 +455,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR constraint = drcEngine.EvalRules( EDGE_CLEARANCE_CONSTRAINT, a, b, layer, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) ); @@ -504,7 +504,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR { constraint = drcEngine.EvalRules( CLEARANCE_CONSTRAINT, a, a, layer, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), clearanceStr ) ); @@ -517,7 +517,7 @@ void BOARD_INSPECTION_TOOL::InspectDRCError( const std::shared_ptr& aDR constraint = drcEngine.EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, a, b, layer, r ); clearance = constraint.m_Value.Min(); - clearanceStr = StringFromValue( r->GetUnits(), clearance, true ); + clearanceStr = EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, r->GetUnits(), clearance, true ); if( !drcEngine.HasRulesForConstraintType( PHYSICAL_CLEARANCE_CONSTRAINT ) ) { @@ -651,7 +651,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved thermal relief gap: %s." ), - StringFromValue( units, gap, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, gap, true ) ) ); r->Report( "" ); r->Report( "" ); @@ -665,7 +665,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved thermal relief spoke width: %s." ), - StringFromValue( units, width, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, width, true ) ) ); r->Report( "" ); r->Report( "" ); @@ -692,7 +692,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) clearance = zone->GetLocalClearance(); r->Report( "" ); r->Report( wxString::Format( _( "Zone clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); constraint = drcEngine.EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, pad, zone, layer, r ); @@ -704,7 +704,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( wxString::Format( _( "Overridden by larger physical clearance from %s;" "clearance: %s." ), EscapeHTML( constraint.GetName() ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } if( !pad->FlashLayer( layer ) ) @@ -720,7 +720,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( wxString::Format( _( "Overridden by larger physical hole clearance from %s;" "clearance: %s." ), EscapeHTML( constraint.GetName() ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } } @@ -729,7 +729,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } else { @@ -743,7 +743,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) // Report a 0 clearance for solid connections r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, 0, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, 0, true ) ) ); } r->Flush(); @@ -774,7 +774,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } r->Flush(); @@ -871,7 +871,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( warning ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); r->Flush(); } @@ -895,7 +895,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); r->Flush(); } @@ -939,7 +939,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); r->Flush(); } @@ -968,7 +968,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); r->Flush(); } @@ -1007,7 +1007,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); r->Flush(); } @@ -1036,7 +1036,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) { r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } r->Report( "" ); @@ -1102,7 +1102,7 @@ int BOARD_INSPECTION_TOOL::InspectClearance( const TOOL_EVENT& aEvent ) { r->Report( "" ); r->Report( wxString::Format( _( "Resolved clearance: %s." ), - StringFromValue( units, clearance, true ) ) ); + EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, units, clearance, true ) ) ); } } diff --git a/pcbnew/tools/drawing_stackup_table_tool.cpp b/pcbnew/tools/drawing_stackup_table_tool.cpp index 905f68c917..47e7a29605 100644 --- a/pcbnew/tools/drawing_stackup_table_tool.cpp +++ b/pcbnew/tools/drawing_stackup_table_tool.cpp @@ -317,8 +317,8 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const VECTOR2I& colMaterial.push_back( t ); t = static_cast( dataStyle->Duplicate() ); - t->SetText( StringFromValue( m_frame->GetUserUnits(), stackup_item->GetThickness( j ), - true ) ); + t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, m_frame->GetUserUnits(), stackup_item->GetThickness( j ), true ) ); colThickness.push_back( t ); t = static_cast( dataStyle->Duplicate() ); @@ -326,12 +326,12 @@ std::vector DRAWING_TOOL::DrawSpecificationStackup( const VECTOR2I& colColor.push_back( t ); t = static_cast( dataStyle->Duplicate() ); - t->SetText( StringFromValue( EDA_UNITS::UNSCALED, stackup_item->GetEpsilonR( j ), - false ) ); + t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( + pcbIUScale, EDA_UNITS::UNSCALED, stackup_item->GetEpsilonR( j ), false ) ); colEpsilon.push_back( t ); t = static_cast( dataStyle->Duplicate() ); - t->SetText( StringFromValue( EDA_UNITS::UNSCALED, stackup_item->GetLossTangent( j ), + t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, stackup_item->GetLossTangent( j ), false ) ); colTanD.push_back( t ); } @@ -400,7 +400,7 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& objects.push_back( t ); cursorPos.y = cursorPos.y + t->GetBoundingBox().GetHeight() - + From_User_Unit( EDA_UNITS::MILLIMETRES, 1.0 ); + + EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, EDA_UNITS::MILLIMETRES, 1.0 ); std::vector> texts; std::vector colLabel1; @@ -415,7 +415,7 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& colLabel1.push_back( t ); t = static_cast( dataStyle->Duplicate() ); - t->SetText( StringFromValue( EDA_UNITS::UNSCALED, settings.GetCopperLayerCount(), false ) ); + t->SetText( EDA_UNIT_UTILS::UI::StringFromValue( pcbIUScale, EDA_UNITS::UNSCALED, settings.GetCopperLayerCount(), false ) ); colData1.push_back( t ); SHAPE_POLY_SET outline; @@ -427,8 +427,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& t = static_cast( dataStyle->Duplicate() ); t->SetText( wxString::Format( wxT( "%s x %s" ), - MessageTextFromValue( m_frame->GetUserUnits(), size.GetWidth(), true ), - MessageTextFromValue( m_frame->GetUserUnits(), size.GetHeight(), true ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), size.GetWidth(), true ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), size.GetHeight(), true ) ) ); colData1.push_back( t ); t = static_cast( dataStyle->Duplicate() ); @@ -437,8 +437,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& t = static_cast( dataStyle->Duplicate() ); t->SetText( wxString::Format( wxT( "%s / %s" ), - MessageTextFromValue( m_frame->GetUserUnits(), settings.m_TrackMinWidth, true ), - MessageTextFromValue( m_frame->GetUserUnits(), settings.m_MinClearance, true ) ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), settings.m_TrackMinWidth, true ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), settings.m_MinClearance, true ) ) ); colData1.push_back( t ); t = static_cast( dataStyle->Duplicate() ); @@ -462,7 +462,7 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& colLabel2.push_back( t ); t = static_cast( dataStyle->Duplicate() ); - text = MessageTextFromValue( m_frame->GetUserUnits(), settings.GetBoardThickness(), true ); + text = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), settings.GetBoardThickness(), true ); t->SetText( text ); colData2.push_back( t ); @@ -479,7 +479,7 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& t = static_cast( dataStyle->Duplicate() ); double holeSize = std::min( settings.m_MinThroughDrill, settings.m_ViasMinSize ); - text = MessageTextFromValue( m_frame->GetUserUnits(), holeSize, true ); + text = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), holeSize, true ); t->SetText( text ); colData2.push_back( t ); @@ -534,7 +534,8 @@ std::vector DRAWING_TOOL::DrawBoardCharacteristics( const VECTOR2I& } tableSize->x = tableSize2.x; - tableSize->y = cursorPos.y + tableSize2.y + From_User_Unit( EDA_UNITS::MILLIMETRES, 2.0 ); + tableSize->y = cursorPos.y + tableSize2.y + + EDA_UNIT_UTILS::UI::FromUserUnit( pcbIUScale, EDA_UNITS::MILLIMETRES, 2.0 ); return objects; } diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 28583c8495..bef595f331 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -118,12 +118,12 @@ protected: if( via.m_Drill > 0 ) { msg.Printf( _("Via %s, hole %s" ), - MessageTextFromValue( units, via.m_Diameter ), - MessageTextFromValue( units, via.m_Drill ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Diameter ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Drill ) ); } else { - msg.Printf( _( "Via %s" ), MessageTextFromValue( units, via.m_Diameter ) ); + msg.Printf( _( "Via %s" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, via.m_Diameter ) ); } int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i; @@ -1795,7 +1795,7 @@ bool DRAWING_TOOL::drawShape( const std::string& aTool, PCB_SHAPE** aGraphic, // drawing assistant overlay // TODO: workaround because EDA_SHAPE_TYPE_T is not visible from commons. KIGFX::PREVIEW::GEOM_SHAPE geomShape( static_cast( shape ) ); - KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointManager, userUnits, geomShape ); + KIGFX::PREVIEW::TWO_POINT_ASSISTANT twoPointAsst( twoPointManager, pcbIUScale, userUnits, geomShape ); // Add a VIEW_GROUP that serves as a preview for the new item PCB_SELECTION preview; @@ -2169,7 +2169,7 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, PCB_SHAPE** aGraphic, KIGFX::PREVIEW::ARC_GEOM_MANAGER arcManager; // Arc drawing assistant overlay - KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() ); + KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, pcbIUScale, m_frame->GetUserUnits() ); // Add a VIEW_GROUP that serves as a preview for the new item PCB_SELECTION preview; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index e144e11c39..0b3431a4ee 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -398,7 +398,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) if( theArc->GetAngle() + maxTangentDeviation >= ANGLE_180 ) { wxString msg = wxString::Format( _( "Unable to resize arc tracks of %s or greater." ), - MessageTextFromValue( ANGLE_180 - maxTangentDeviation ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( ANGLE_180 - maxTangentDeviation ) ); frame()->ShowInfoBarError( msg ); return 0; // don't bother with > 180 degree arcs diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index 5e191bd476..d29eb48eae 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -1371,12 +1371,12 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) int actual_clearance = a_shape->GetClearance( b_shape.get() ); msgItems.emplace_back( _( "Resolved clearance" ), - MessageTextFromValue( units, constraint.m_Value.Min() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, constraint.m_Value.Min() ) ); if( actual_clearance > -1 && actual_clearance < std::numeric_limits::max() ) { msgItems.emplace_back( _( "Actual clearance" ), - MessageTextFromValue( units, actual_clearance ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, actual_clearance ) ); } } } @@ -1417,12 +1417,12 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) constraint = drcEngine->EvalRules( HOLE_CLEARANCE_CONSTRAINT, a, b, layer ); msgItems.emplace_back( _( "Resolved hole clearance" ), - MessageTextFromValue( units, constraint.m_Value.Min() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, constraint.m_Value.Min() ) ); if( actual > -1 && actual < std::numeric_limits::max() ) { msgItems.emplace_back( _( "Actual hole clearance" ), - MessageTextFromValue( units, actual ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, actual ) ); } } } @@ -1454,12 +1454,12 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) if( edgeLayer == Edge_Cuts ) { msgItems.emplace_back( _( "Resolved edge clearance" ), - MessageTextFromValue( units, constraint.m_Value.Min() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, constraint.m_Value.Min() ) ); } else { msgItems.emplace_back( _( "Resolved margin clearance" ), - MessageTextFromValue( units, constraint.m_Value.Min() ) ); + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, constraint.m_Value.Min() ) ); } } } diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index f4cd51c7d7..0fabe38e52 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -841,8 +841,8 @@ void PCB_POINT_EDITOR::pinEditedCorner( VECTOR2I& aTopLeft, VECTOR2I& aTopRight, VECTOR2I& aBotLeft, VECTOR2I& aBotRight, const VECTOR2I& aHole, const VECTOR2I& aHoleSize ) const { - int minWidth = Mils2iu( 1 ); - int minHeight = Mils2iu( 1 ); + int minWidth = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 ); + int minHeight = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 1 ); if( isModified( m_editPoints->Point( RECT_TOP_LEFT ) ) ) { @@ -1105,11 +1105,12 @@ void PCB_POINT_EDITOR::updateItem() const pinEditedCorner( topLeft, topRight, botLeft, botRight ); double oldWidth = bitmap->GetSize().x; - double newWidth = std::max( topRight.x - topLeft.x, Mils2iu( 50 ) ); + double newWidth = std::max( topRight.x - topLeft.x, EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 50 ) ); double widthRatio = newWidth / oldWidth; double oldHeight = bitmap->GetSize().y; - double newHeight = std::max( botLeft.y - topLeft.y, Mils2iu( 50 ) ); + double newHeight = + std::max( botLeft.y - topLeft.y, EDA_UNIT_UTILS::Mils2IU( pcbIUScale, 50 ) ); double heightRatio = newHeight / oldHeight; bitmap->SetImageScale( bitmap->GetImageScale() * std::min( widthRatio, heightRatio ) ); diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index 0d56f8f947..ebf839e495 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -204,7 +204,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() ); bool originSet = false; EDA_UNITS units = frame()->GetUserUnits(); - KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, units, + KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, pcbIUScale, units, displayOptions().m_DisplayInvertXAxis, displayOptions().m_DisplayInvertYAxis ); diff --git a/pcbnew/widgets/search_handlers.cpp b/pcbnew/widgets/search_handlers.cpp index c60292514b..c09e758129 100644 --- a/pcbnew/widgets/search_handlers.cpp +++ b/pcbnew/widgets/search_handlers.cpp @@ -71,9 +71,9 @@ wxString FOOTPRINT_SEARCH_HANDLER::GetResultCell( int row, int col ) else if( col == 2 ) return fp->GetLayerName(); else if( col == 3 ) - return MessageTextFromValue( m_frame->GetUserUnits(), fp->GetX() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), fp->GetX() ); else if( col == 4 ) - return MessageTextFromValue( m_frame->GetUserUnits(), fp->GetY() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), fp->GetY() ); return wxEmptyString; } @@ -130,9 +130,9 @@ wxString ZONE_SEARCH_HANDLER::GetResultCell( int row, int col ) else if( col == 1 ) return zone->GetLayerName(); else if( col == 2 ) - return MessageTextFromValue( m_frame->GetUserUnits(), zone->GetX() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), zone->GetX() ); else if( col == 3 ) - return MessageTextFromValue( m_frame->GetUserUnits(), zone->GetY() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), zone->GetY() ); return wxEmptyString; } @@ -189,9 +189,9 @@ wxString TEXT_SEARCH_HANDLER::GetResultCell( int row, int col ) if( col == 1 ) return text->GetLayerName(); else if( col == 2 ) - return MessageTextFromValue( m_frame->GetUserUnits(), text->GetX() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), text->GetX() ); else if( col == 3 ) - return MessageTextFromValue( m_frame->GetUserUnits(), text->GetY() ); + return EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, m_frame->GetUserUnits(), text->GetY() ); return wxEmptyString; } diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index bee80a35a7..d3f57c596b 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -60,9 +60,9 @@ ZONE::ZONE( BOARD_ITEM_CONTAINER* aParent, bool aInFP ) : aParent->GetZoneSettings().ExportSetting( *this ); - m_ZoneMinThickness = Mils2iu( ZONE_THICKNESS_MIL ); - m_thermalReliefSpokeWidth = Mils2iu( ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL ); - m_thermalReliefGap = Mils2iu( ZONE_THERMAL_RELIEF_GAP_MIL ); + m_ZoneMinThickness = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THICKNESS_MIL ); + m_thermalReliefSpokeWidth = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL ); + m_thermalReliefGap = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THERMAL_RELIEF_GAP_MIL ); m_needRefill = false; // True only after edits. } @@ -577,7 +577,7 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList.emplace_back( _( "Fill Mode" ), msg ); - msg = MessageTextFromValue( units, m_area, true, EDA_DATA_TYPE::AREA ); + msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_area, true, EDA_DATA_TYPE::AREA ); aList.emplace_back( _( "Filled Area" ), msg ); wxString source; @@ -586,7 +586,7 @@ void ZONE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& if( !source.IsEmpty() ) { aList.emplace_back( wxString::Format( _( "Min Clearance: %s" ), - MessageTextFromValue( units, clearance ) ), + EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, clearance ) ), wxString::Format( _( "(from %s)" ), source ) ); } @@ -937,7 +937,7 @@ void ZONE::HatchBorder() int ZONE::GetDefaultHatchPitch() { - return Mils2iu( ZONE_BORDER_HATCH_DIST_MIL ); + return EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_BORDER_HATCH_DIST_MIL ); } @@ -1258,7 +1258,7 @@ void ZONE::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, aCornerBuffer.Append( *m_FilledPolysList.at( aLayer ) ); return; } - + SHAPE_POLY_SET temp_buf = m_FilledPolysList.at( aLayer )->CloneDropTriangulation(); // Rebuild filled areas only if clearance is not 0 diff --git a/pcbnew/zone_settings.cpp b/pcbnew/zone_settings.cpp index 4e02066bfc..bc19a06953 100644 --- a/pcbnew/zone_settings.cpp +++ b/pcbnew/zone_settings.cpp @@ -41,9 +41,9 @@ ZONE_SETTINGS::ZONE_SETTINGS() m_ZonePriority = 0; m_FillMode = ZONE_FILL_MODE::POLYGONS; // Mode for filling zone // Zone clearance value - m_ZoneClearance = Mils2iu( ZONE_CLEARANCE_MIL ); + m_ZoneClearance = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_CLEARANCE_MIL ); // Min thickness value in filled areas (this is the minimum width of copper to fill solid areas) : - m_ZoneMinThickness = Mils2iu( ZONE_THICKNESS_MIL ); + m_ZoneMinThickness = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THICKNESS_MIL ); m_HatchThickness = 0; // good value of grid line thickness for ZFM_GRID_PATTERN m_HatchGap = 0; // good value of grid line gap for ZFM_GRID_PATTERN m_HatchOrientation = ANGLE_0; // Grid style: orientation of grid lines @@ -55,15 +55,15 @@ ZONE_SETTINGS::ZONE_SETTINGS() m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; // Option to show the zone // outlines only, short // hatches or full hatches - m_BorderHatchPitch = Mils2iu( ZONE_BORDER_HATCH_DIST_MIL ); + m_BorderHatchPitch = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_BORDER_HATCH_DIST_MIL ); m_Layers.reset().set( F_Cu ); m_Name = wxEmptyString; // thickness of the gap in thermal reliefs: - m_ThermalReliefGap = Mils2iu( ZONE_THERMAL_RELIEF_GAP_MIL ); + m_ThermalReliefGap = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THERMAL_RELIEF_GAP_MIL ); // thickness of the copper bridge in thermal reliefs: - m_ThermalReliefSpokeWidth = Mils2iu( ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL ); + m_ThermalReliefSpokeWidth = EDA_UNIT_UTILS::Mils2IU( pcbIUScale, ZONE_THERMAL_RELIEF_COPPER_WIDTH_MIL ); m_padConnection = ZONE_CONNECTION::THERMAL; // How pads are covered by copper in zone diff --git a/qa/tools/pns/CMakeLists.txt b/qa/tools/pns/CMakeLists.txt index f786f53ac7..04699c7d6b 100644 --- a/qa/tools/pns/CMakeLists.txt +++ b/qa/tools/pns/CMakeLists.txt @@ -61,7 +61,7 @@ add_executable( test_pns ../../qa_utils/test_app_main.cpp ../../qa_utils/utility_program.cpp ../../qa_utils/mocks.cpp - ../../../common/base_units.cpp + playground.cpp main.cpp ) diff --git a/qa/unittests/common/test_format_units.cpp b/qa/unittests/common/test_format_units.cpp index 95cfd0ef68..a14f757ce3 100644 --- a/qa/unittests/common/test_format_units.cpp +++ b/qa/unittests/common/test_format_units.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -45,14 +46,21 @@ BOOST_FIXTURE_TEST_SUITE( UnitConversion, UnitFixture ) */ BOOST_AUTO_TEST_CASE( wxPointUnitFormat ) { - LOCALE_IO toggle; - std::string str = FormatInternalUnits( wxPoint( 123456, 52525252 ) ); - std::string strZero = FormatInternalUnits( wxPoint( 0, 0 ) ); - std::string strNeg = FormatInternalUnits( wxPoint( -123456, -52525252 ) ); - std::string strOddNeg = FormatInternalUnits( wxPoint( -350000, -0 ) ); + LOCALE_IO toggle; - std::string strMax = FormatInternalUnits( wxPoint( std::numeric_limits::min(), - std::numeric_limits::max() ) ); +#ifdef EESCHEMA + const EDA_IU_SCALE& iuScale = schIUScale; +#elif GERBVIEW + const EDA_IU_SCALE& iuScale = gerbIUScale; +#elif PCBNEW + const EDA_IU_SCALE& iuScale = pcbIUScale; +#endif + + std::string str = EDA_UNIT_UTILS::FormatInternalUnits( iuScale, wxPoint( 123456, 52525252 ) ); + std::string strZero = EDA_UNIT_UTILS::FormatInternalUnits( iuScale, wxPoint( 0, 0 ) ); + std::string strNeg = EDA_UNIT_UTILS::FormatInternalUnits( iuScale, wxPoint( -123456, -52525252 ) ); + std::string strOddNeg = EDA_UNIT_UTILS::FormatInternalUnits( iuScale, wxPoint( -350000, -0 ) ); + std::string strMax = EDA_UNIT_UTILS::FormatInternalUnits( iuScale, wxPoint( std::numeric_limits::min(), std::numeric_limits::max() ) ); BOOST_CHECK_EQUAL( strZero, "0 0" ); diff --git a/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp b/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp index 6d6eec0d1b..ca7c9213fc 100644 --- a/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp +++ b/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp @@ -87,7 +87,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCustomRuleSeverityTest, DRC_REGRESSION_TEST_FIXTURE m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); + BOOST_TEST_MESSAGE( + item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); BOOST_ERROR( "Custom rule severity test failed" ); } diff --git a/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp b/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp index d5b2074d67..88f46815c3 100644 --- a/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp +++ b/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp @@ -98,7 +98,8 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperConn, DRC_REGRESSION_TEST_FIXTURE ) for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); } diff --git a/qa/unittests/pcbnew/drc/test_drc_regressions.cpp b/qa/unittests/pcbnew/drc/test_drc_regressions.cpp index 30c3484101..0ef6c122da 100644 --- a/qa/unittests/pcbnew/drc/test_drc_regressions.cpp +++ b/qa/unittests/pcbnew/drc/test_drc_regressions.cpp @@ -101,7 +101,8 @@ BOOST_FIXTURE_TEST_CASE( DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTUR for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); } @@ -171,7 +172,8 @@ BOOST_FIXTURE_TEST_CASE( DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTUR for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); } diff --git a/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp b/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp index d52b7d03c5..b0259672e7 100644 --- a/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp +++ b/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp @@ -82,7 +82,7 @@ BOOST_FIXTURE_TEST_CASE( DRCSolderMaskBridgingTest, DRC_REGRESSION_TEST_FIXTURE m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); BOOST_ERROR( wxString::Format( "DRC solder mask bridge test failed board <%s>", brd_name ) ); } diff --git a/qa/unittests/pcbnew/test_tracks_cleaner.cpp b/qa/unittests/pcbnew/test_tracks_cleaner.cpp index de9c66e439..01e4f3a91d 100644 --- a/qa/unittests/pcbnew/test_tracks_cleaner.cpp +++ b/qa/unittests/pcbnew/test_tracks_cleaner.cpp @@ -117,7 +117,8 @@ BOOST_FIXTURE_TEST_CASE( FailedToCleanRegressionTests, TRACK_CLEANER_TEST_FIXTUR for( const std::shared_ptr& item : realRunItems ) { - BOOST_TEST_MESSAGE( item->ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item->ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); } @@ -199,7 +200,8 @@ BOOST_FIXTURE_TEST_CASE( TrackCleanerRegressionTests, TRACK_CLEANER_TEST_FIXTURE for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); } diff --git a/qa/unittests/pcbnew/test_zone_filler.cpp b/qa/unittests/pcbnew/test_zone_filler.cpp index 2a1819197f..2d13d2a21f 100644 --- a/qa/unittests/pcbnew/test_zone_filler.cpp +++ b/qa/unittests/pcbnew/test_zone_filler.cpp @@ -222,7 +222,8 @@ BOOST_FIXTURE_TEST_CASE( RegressionZoneFillTests, ZONE_FILL_TEST_FIXTURE ) for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, + RPT_SEVERITY_ERROR, itemMap ) ); }