From 64a6fc0fd43d4a7dc23d5c72fa7cb7597aea8d70 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 19 Sep 2022 17:09:59 +0100 Subject: [PATCH] Push UNITS_PROVIDER down into a low-level mixin. This allows us to also construct cheap UNIT_PROVIDERs for specific tasks when necessary. --- 3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp | 2 +- common/drawing_sheet/ds_draw_item.cpp | 20 ++-- common/eda_base_frame.cpp | 20 +--- common/eda_draw_frame.cpp | 3 +- common/eda_item.cpp | 2 +- common/eda_shape.cpp | 2 +- common/kiway_player.cpp | 31 ++--- common/rc_item.cpp | 28 ++--- common/stroke_params.cpp | 6 +- common/tool/selection_tool.cpp | 16 +-- cvpcb/cvpcb_mainframe.cpp | 3 +- eeschema/connection_graph.cpp | 14 ++- eeschema/dialogs/dialog_erc.cpp | 2 +- eeschema/lib_field.cpp | 2 +- eeschema/lib_field.h | 2 +- eeschema/lib_pin.cpp | 2 +- eeschema/lib_pin.h | 2 +- eeschema/lib_shape.cpp | 10 +- eeschema/lib_shape.h | 2 +- eeschema/lib_text.cpp | 2 +- eeschema/lib_text.h | 2 +- eeschema/lib_textbox.cpp | 12 +- eeschema/lib_textbox.h | 2 +- eeschema/sch_bitmap.h | 2 +- eeschema/sch_bus_entry.cpp | 4 +- eeschema/sch_bus_entry.h | 4 +- eeschema/sch_connection.cpp | 4 +- eeschema/sch_field.cpp | 5 +- eeschema/sch_field.h | 2 +- eeschema/sch_junction.h | 2 +- eeschema/sch_label.cpp | 8 +- eeschema/sch_label.h | 8 +- eeschema/sch_line.cpp | 6 +- eeschema/sch_line.h | 2 +- eeschema/sch_marker.h | 2 +- eeschema/sch_no_connect.h | 2 +- eeschema/sch_pin.cpp | 7 +- eeschema/sch_pin.h | 2 +- eeschema/sch_shape.cpp | 10 +- eeschema/sch_shape.h | 2 +- eeschema/sch_sheet.cpp | 4 +- eeschema/sch_sheet.h | 2 +- eeschema/sch_sheet_path.cpp | 2 +- eeschema/sch_sheet_pin.cpp | 2 +- eeschema/sch_sheet_pin.h | 2 +- eeschema/sch_symbol.cpp | 4 +- eeschema/sch_symbol.h | 2 +- eeschema/sch_text.cpp | 2 +- eeschema/sch_text.h | 2 +- eeschema/sch_textbox.cpp | 16 ++- eeschema/sch_textbox.h | 2 +- gerbview/gerber_draw_item.cpp | 2 +- gerbview/gerber_draw_item.h | 2 +- include/board_item.h | 2 +- include/drawing_sheet/ds_draw_item.h | 12 +- include/eda_base_frame.h | 22 +--- include/eda_draw_frame.h | 62 ---------- include/eda_item.h | 4 +- include/kiway_player.h | 2 +- include/pcb_group.h | 2 +- include/rc_item.h | 9 +- include/stroke_params.h | 4 +- include/units_provider.h | 108 ++++++++++++++++++ kicad/kicad_manager_frame.cpp | 6 +- pcbnew/board.cpp | 2 +- pcbnew/board.h | 2 +- pcbnew/dialogs/dialog_drc.cpp | 8 +- pcbnew/dialogs/dialog_group_properties.cpp | 4 +- pcbnew/dialogs/dialog_position_relative.cpp | 7 +- pcbnew/drc/drc_engine.cpp | 87 +++++++------- pcbnew/drc/drc_engine.h | 6 +- pcbnew/drc/drc_test_provider.cpp | 9 +- pcbnew/drc/drc_test_provider.h | 10 +- .../drc/drc_test_provider_annular_width.cpp | 8 +- .../drc_test_provider_connection_width.cpp | 4 +- .../drc_test_provider_copper_clearance.cpp | 36 +++--- .../drc_test_provider_courtyard_clearance.cpp | 8 +- .../drc_test_provider_diff_pair_coupling.cpp | 14 +-- .../drc/drc_test_provider_edge_clearance.cpp | 4 +- pcbnew/drc/drc_test_provider_hole_size.cpp | 16 +-- pcbnew/drc/drc_test_provider_hole_to_hole.cpp | 4 +- .../drc/drc_test_provider_matched_length.cpp | 24 ++-- .../drc_test_provider_physical_clearance.cpp | 28 ++--- .../drc/drc_test_provider_silk_clearance.cpp | 4 +- pcbnew/drc/drc_test_provider_solder_mask.cpp | 4 +- pcbnew/drc/drc_test_provider_text_dims.cpp | 16 +-- pcbnew/drc/drc_test_provider_track_width.cpp | 8 +- pcbnew/drc/drc_test_provider_via_diameter.cpp | 8 +- pcbnew/footprint.cpp | 2 +- pcbnew/footprint.h | 2 +- pcbnew/fp_shape.cpp | 2 +- pcbnew/fp_shape.h | 2 +- pcbnew/fp_text.cpp | 2 +- pcbnew/fp_text.h | 2 +- pcbnew/fp_textbox.cpp | 4 +- pcbnew/fp_textbox.h | 2 +- pcbnew/pad.cpp | 2 +- pcbnew/pad.h | 2 +- pcbnew/pcb_bitmap.h | 2 +- pcbnew/pcb_dimension.cpp | 43 +++---- pcbnew/pcb_dimension.h | 4 +- pcbnew/pcb_group.cpp | 2 +- pcbnew/pcb_marker.cpp | 6 +- pcbnew/pcb_marker.h | 2 +- pcbnew/pcb_shape.cpp | 2 +- pcbnew/pcb_shape.h | 2 +- pcbnew/pcb_target.cpp | 2 +- pcbnew/pcb_target.h | 2 +- pcbnew/pcb_text.cpp | 2 +- pcbnew/pcb_text.h | 2 +- pcbnew/pcb_textbox.cpp | 4 +- pcbnew/pcb_textbox.h | 2 +- pcbnew/pcb_track.cpp | 6 +- pcbnew/pcb_track.h | 4 +- pcbnew/plugins/kicad/pcb_plugin.cpp | 3 +- .../scripting/pcbnew_scripting_helpers.cpp | 9 +- pcbnew/router/pns_kicad_iface.cpp | 7 +- pcbnew/tools/board_inspection_tool.cpp | 8 +- pcbnew/tools/pcb_control.cpp | 4 +- pcbnew/zone.cpp | 2 +- pcbnew/zone.h | 2 +- .../drc/test_custom_rule_severities.cpp | 5 +- .../pcbnew/drc/test_drc_copper_conn.cpp | 5 +- .../pcbnew/drc/test_drc_regressions.cpp | 10 +- .../pcbnew/drc/test_solder_mask_bridging.cpp | 4 +- qa/unittests/pcbnew/test_tracks_cleaner.cpp | 10 +- qa/unittests/pcbnew/test_zone_filler.cpp | 5 +- scripting/kipython_frame.cpp | 3 +- 128 files changed, 533 insertions(+), 510 deletions(-) create mode 100644 include/units_provider.h diff --git a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp index 8ace0a42ab..001abad759 100644 --- a/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp +++ b/3d-viewer/3d_viewer/eda_3d_viewer_frame.cpp @@ -89,7 +89,7 @@ END_EVENT_TABLE() EDA_3D_VIEWER_FRAME::EDA_3D_VIEWER_FRAME( KIWAY* aKiway, PCB_BASE_FRAME* aParent, const wxString& aTitle, long style ) : KIWAY_PLAYER( aKiway, aParent, FRAME_PCB_DISPLAY3D, aTitle, wxDefaultPosition, - wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ) ), + wxDefaultSize, style, QUALIFIED_VIEWER3D_FRAMENAME( aParent ), unityScale ), m_mainToolBar( nullptr ), m_canvas( nullptr ), m_currentCamera( m_trackBallCamera ), m_viewportsLabel( nullptr ), m_cbViewports( nullptr ), diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index f4db0bed03..a068268da9 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -188,7 +188,7 @@ bool DS_DRAW_ITEM_TEXT::HitTest( const BOX2I& aRect, bool aContains, int aAccura } -wxString DS_DRAW_ITEM_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_TEXT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Text '%s'" ), GetShownText() ); } @@ -283,7 +283,7 @@ bool DS_DRAW_ITEM_POLYPOLYGONS::HitTest( const BOX2I& aRect, bool aContained, in } -wxString DS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_POLYPOLYGONS::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return _( "Imported Shape" ); } @@ -379,13 +379,11 @@ bool DS_DRAW_ITEM_RECT::HitTest( const BOX2I& aRect, bool aContained, int aAccur } -wxString DS_DRAW_ITEM_RECT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_RECT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Rectangle, width %s height %s" ), - 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 ) ) ); + aUnitsProvider->MessageTextFromValue( std::abs( GetStart().x - GetEnd().x ) ), + aUnitsProvider->MessageTextFromValue( std::abs( GetStart().y - GetEnd().y ) ) ); } @@ -414,10 +412,10 @@ bool DS_DRAW_ITEM_LINE::HitTest( const VECTOR2I& aPosition, int aAccuracy ) cons } -wxString DS_DRAW_ITEM_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_LINE::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Line, length %s" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( drawSheetIUScale, aUnits, EuclideanNorm( GetStart() - GetEnd() ) ) ); + aUnitsProvider->MessageTextFromValue( EuclideanNorm( GetStart() - GetEnd() ) ) ); } @@ -462,13 +460,13 @@ bool DS_DRAW_ITEM_BITMAP::HitTest( const BOX2I& aRect, bool aContains, int aAccu } -wxString DS_DRAW_ITEM_BITMAP::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_BITMAP::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return _( "Image" ); } -wxString DS_DRAW_ITEM_PAGE::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString DS_DRAW_ITEM_PAGE::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return _( "Page Limits" ); } diff --git a/common/eda_base_frame.cpp b/common/eda_base_frame.cpp index 70a6b305e8..4c5ec1cada 100644 --- a/common/eda_base_frame.cpp +++ b/common/eda_base_frame.cpp @@ -124,7 +124,6 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType ) m_supportsAutoSave = false; m_autoSaveState = false; m_undoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS; - m_userUnits = EDA_UNITS::MILLIMETRES; m_isClosing = false; m_isNonUserClose = false; m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER ); @@ -153,21 +152,14 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType ) } -EDA_BASE_FRAME::EDA_BASE_FRAME( FRAME_T aFrameType, KIWAY* aKiway ) : - wxFrame(), - TOOLS_HOLDER(), - KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ) -{ - commonInit( aFrameType ); -} - - -EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, - const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aFrameName, KIWAY* aKiway ) : +EDA_BASE_FRAME::EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, + const wxPoint& aPos, const wxSize& aSize, long aStyle, + const wxString& aFrameName, KIWAY* aKiway, + const EDA_IU_SCALE& aIuScale ) : wxFrame( aParent, wxID_ANY, aTitle, aPos, aSize, aStyle, aFrameName ), TOOLS_HOLDER(), - KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ) + KIWAY_HOLDER( aKiway, KIWAY_HOLDER::FRAME ), + UNITS_PROVIDER( aIuScale, EDA_UNITS::MILLIMETRES ) { commonInit( aFrameType ); } diff --git a/common/eda_draw_frame.cpp b/common/eda_draw_frame.cpp index b53af5f44e..db3426bfa9 100644 --- a/common/eda_draw_frame.cpp +++ b/common/eda_draw_frame.cpp @@ -82,8 +82,7 @@ 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, const EDA_IU_SCALE& aIuScale ) : - KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName ), - m_iuScale( aIuScale ) + KIWAY_PLAYER( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aIuScale ) { m_socketServer = nullptr; m_mainToolBar = nullptr; diff --git a/common/eda_item.cpp b/common/eda_item.cpp index 7d1a96b130..9ef37b9806 100644 --- a/common/eda_item.cpp +++ b/common/eda_item.cpp @@ -105,7 +105,7 @@ INSPECT_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, } -wxString EDA_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString EDA_ITEM::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) + GetClass() ); diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 2e6ed115e8..7f29e9d60b 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -628,7 +628,7 @@ void EDA_SHAPE::ShapeGetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetIuScale(), aFrame->GetUserUnits(), aList ); + m_stroke.GetMsgPanelInfo( aFrame, aList ); } diff --git a/common/kiway_player.cpp b/common/kiway_player.cpp index e7bccfad83..8a86151075 100644 --- a/common/kiway_player.cpp +++ b/common/kiway_player.cpp @@ -40,14 +40,16 @@ END_EVENT_TABLE() KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, - const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aWdoName ) : - EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aWdoName, aKiway ), - m_modal( false ), - m_modal_loop( nullptr ), - m_modal_resultant_parent( nullptr ), - m_modal_ret_val( false ), - m_socketServer( nullptr ) + const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, + long aStyle, const wxString& aFrameName, + const EDA_IU_SCALE& aIuScale ) : + EDA_BASE_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName, aKiway, + aIuScale ), + m_modal( false ), + m_modal_loop( nullptr ), + m_modal_resultant_parent( nullptr ), + m_modal_ret_val( false ), + m_socketServer( nullptr ) { } @@ -55,12 +57,13 @@ KIWAY_PLAYER::KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType KIWAY_PLAYER::KIWAY_PLAYER( wxWindow* aParent, wxWindowID aId, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, const wxString& aWdoName ) : - EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName, nullptr ), - m_modal( false ), - m_modal_loop( nullptr ), - m_modal_resultant_parent( nullptr ), - m_modal_ret_val( false ), - m_socketServer( nullptr ) + EDA_BASE_FRAME( aParent, (FRAME_T) aId, aTitle, aPos, aSize, aStyle, aWdoName, nullptr, + unityScale ), + m_modal( false ), + m_modal_loop( nullptr ), + m_modal_resultant_parent( nullptr ), + m_modal_ret_val( false ), + m_socketServer( nullptr ) { } diff --git a/common/rc_item.cpp b/common/rc_item.cpp index 972243917c..cd4b11fe98 100644 --- a/common/rc_item.cpp +++ b/common/rc_item.cpp @@ -44,11 +44,11 @@ wxString RC_ITEM::GetErrorMessage() const } -wxString RC_ITEM::ShowCoord( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, const VECTOR2I& aPos ) +static wxString showCoord( UNITS_PROVIDER* aUnitsProvider, const VECTOR2I& aPos ) { return wxString::Format( wxT( "@(%s, %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( aIuScale, aUnits, aPos.x ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( aIuScale, aUnits, aPos.y ) ); + aUnitsProvider->MessageTextFromValue( aPos.x ), + aUnitsProvider->MessageTextFromValue( aPos.y ) ); } @@ -76,7 +76,7 @@ void RC_ITEM::SetItems( const EDA_ITEM* aItem, const EDA_ITEM* bItem, } -wxString RC_ITEM::ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SEVERITY aSeverity, +wxString RC_ITEM::ShowReport( UNITS_PROVIDER* aUnitsProvider, SEVERITY aSeverity, const std::map& aItemMap ) const { wxString severity; @@ -120,10 +120,10 @@ wxString RC_ITEM::ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SE GetErrorMessage(), GetViolatingRuleDesc(), severity, - ShowCoord( aIuScale, aUnits, mainItem->GetPosition() ), - mainItem->GetSelectMenuText( aUnits ), - ShowCoord( aIuScale, aUnits, auxItem->GetPosition() ), - auxItem->GetSelectMenuText( aUnits ) ); + showCoord( aUnitsProvider, mainItem->GetPosition()), + mainItem->GetSelectMenuText( aUnitsProvider ), + showCoord( aUnitsProvider, auxItem->GetPosition()), + auxItem->GetSelectMenuText( aUnitsProvider ) ); } else if( mainItem ) { @@ -132,8 +132,8 @@ wxString RC_ITEM::ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SE GetErrorMessage(), GetViolatingRuleDesc(), severity, - ShowCoord( aIuScale, aUnits, mainItem->GetPosition() ), - mainItem->GetSelectMenuText( aUnits ) ); + showCoord( aUnitsProvider, mainItem->GetPosition()), + mainItem->GetSelectMenuText( aUnitsProvider ) ); } else { @@ -374,7 +374,7 @@ void RC_TREE_MODEL::GetValue( wxVariant& aVariant, else { EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetMainItemID() ); - aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() ); + aVariant = item->GetSelectMenuText( m_editFrame ); } break; @@ -382,21 +382,21 @@ void RC_TREE_MODEL::GetValue( wxVariant& aVariant, case RC_TREE_NODE::AUX_ITEM: { EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItemID() ); - aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() ); + aVariant = item->GetSelectMenuText( m_editFrame ); } break; case RC_TREE_NODE::AUX_ITEM2: { EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem2ID() ); - aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() ); + aVariant = item->GetSelectMenuText( m_editFrame ); } break; case RC_TREE_NODE::AUX_ITEM3: { EDA_ITEM* item = m_editFrame->GetItem( rcItem->GetAuxItem3ID() ); - aVariant = item->GetSelectMenuText( m_editFrame->GetUserUnits() ); + aVariant = item->GetSelectMenuText( m_editFrame ); } break; } diff --git a/common/stroke_params.cpp b/common/stroke_params.cpp index b94921a4c7..6549189f78 100644 --- a/common/stroke_params.cpp +++ b/common/stroke_params.cpp @@ -190,7 +190,7 @@ wxString STROKE_PARAMS::GetLineStyleToken( PLOT_DASH_TYPE aStyle ) } -void STROKE_PARAMS::GetMsgPanelInfo( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, +void STROKE_PARAMS::GetMsgPanelInfo( UNITS_PROVIDER* aUnitsProvider, std::vector& aList, bool aIncludeStyle, bool aIncludeWidth ) { @@ -211,9 +211,7 @@ void STROKE_PARAMS::GetMsgPanelInfo( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUn } if( aIncludeWidth ) - { - aList.emplace_back( _( "Line Width" ), EDA_UNIT_UTILS::UI::MessageTextFromValue( aIuScale, aUnits, GetWidth() ) ); - } + aList.emplace_back( _( "Line Width" ), aUnitsProvider->MessageTextFromValue( GetWidth() ) ); } diff --git a/common/tool/selection_tool.cpp b/common/tool/selection_tool.cpp index 87a7687a69..ed1178d4d9 100644 --- a/common/tool/selection_tool.cpp +++ b/common/tool/selection_tool.cpp @@ -234,11 +234,11 @@ int SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent ) bool SELECTION_TOOL::doSelectionMenu( COLLECTOR* aCollector ) { - EDA_UNITS userUnits = getEditFrame()->GetUserUnits(); - EDA_ITEM* current = nullptr; - SELECTION highlightGroup; - bool selectAll = false; - bool expandSelection = false; + UNITS_PROVIDER* unitsProvider = getEditFrame(); + EDA_ITEM* current = nullptr; + SELECTION highlightGroup; + bool selectAll = false; + bool expandSelection = false; highlightGroup.SetLayer( LAYER_SELECT_OVERLAY ); getView()->Add( &highlightGroup ); @@ -263,18 +263,18 @@ bool SELECTION_TOOL::doSelectionMenu( COLLECTOR* aCollector ) { #ifdef __WXMAC__ menuText = wxString::Format( "%s\t%d", - item->GetSelectMenuText( userUnits ), + item->GetSelectMenuText( unitsProvider ), i + 1 ); #else menuText = wxString::Format( "&%d %s\t%d", i + 1, - item->GetSelectMenuText( userUnits ), + item->GetSelectMenuText( unitsProvider ), i + 1 ); #endif } else { - menuText = item->GetSelectMenuText( userUnits ); + menuText = item->GetSelectMenuText( unitsProvider ); } menu.Add( menuText, i + 1, item->GetMenuImage() ); diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index bf0667c661..0e5868fc46 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -65,7 +65,8 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition, - wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME ), + wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, CVPCB_MAINFRAME_NAME, + unityScale ), m_footprintListPendingUpdate( false ), m_viewerPendingUpdate( false ) { diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 82c8b40ed0..bdb336ab7c 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -984,10 +984,14 @@ void CONNECTION_GRAPH::collectAllDriverValues() break; } default: + { + UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILLIMETRES ); + wxLogTrace( ConnTrace, "Unexpected strong driver %s", - driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ); + driver->GetSelectMenuText( &unitsProvider ) ); break; } + } } } } @@ -1174,10 +1178,12 @@ void CONNECTION_GRAPH::processSubGraphs() } else { + UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILLIMETRES ); + wxLogTrace( ConnTrace, - "%ld (%s) weakly driven by unique sheet pin %s, promoting", - subgraph->m_code, name, - subgraph->m_driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ); + "%ld (%s) weakly driven by unique sheet pin %s, promoting", + subgraph->m_code, name, + subgraph->m_driver->GetSelectMenuText( &unitsProvider ) ); subgraph->m_strong_driver = true; } diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 907ceb5f71..5e7c71cc76 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( schIUScale, GetUserUnits(), severity, itemMap ); + msg << marker->GetRCItem()->ShowReport( m_parent, severity, itemMap ); } } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 04aa3f896e..414adac9b2 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -497,7 +497,7 @@ void LIB_FIELD::SetName( const wxString& aName ) } -wxString LIB_FIELD::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString LIB_FIELD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( "%s '%s'", GetName(), KIUI::EllipsizeMenuText( GetShownText() ) ); } diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index b54ce37eb3..1899d5d1ef 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -167,7 +167,7 @@ public: void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 2fa14ab437..ec090101ea 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1322,7 +1322,7 @@ BITMAPS LIB_PIN::GetMenuImage() const } -wxString LIB_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString LIB_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { if( !m_name.IsEmpty() ) { diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index df88960ca1..76dabd8ef5 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -235,7 +235,7 @@ public: BITMAPS GetMenuImage() const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/lib_shape.cpp b/eeschema/lib_shape.cpp index 7cac90d792..8a8d17a177 100644 --- a/eeschema/lib_shape.cpp +++ b/eeschema/lib_shape.cpp @@ -447,22 +447,22 @@ void LIB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( GetRadius() ) ); case SHAPE_T::CIRCLE: return wxString::Format( _( "Circle, radius %s" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, GetRadius() ) ); + aUnitsProvider->MessageTextFromValue( GetRadius() ) ); case SHAPE_T::RECT: return wxString::Format( _( "Rectangle, width %s height %s" ), - 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 ) ) ); + aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ), + aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) ); case SHAPE_T::POLY: return wxString::Format( _( "Polyline, %d points" ), diff --git a/eeschema/lib_shape.h b/eeschema/lib_shape.h index c477cd4b84..d03243852c 100644 --- a/eeschema/lib_shape.h +++ b/eeschema/lib_shape.h @@ -107,7 +107,7 @@ public: void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 0cf1ef1543..3c3cb260d6 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -438,7 +438,7 @@ const BOX2I LIB_TEXT::GetBoundingBox() const } -wxString LIB_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString LIB_TEXT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index 35c5e7d806..b092a9a537 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -101,7 +101,7 @@ public: void Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffset, const TRANSFORM& aTransform, bool aDimmed ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 2887ea4f4d..27b1d84713 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -356,7 +356,7 @@ bool LIB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) } -wxString LIB_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString LIB_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Graphic Text Box" ) ); } @@ -458,13 +458,13 @@ void LIB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( GetTextWidth() ) ); - wxString msg = aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ); - aList.emplace_back( _( "Box Width" ), msg ); + aList.emplace_back( _( "Box Width" ), + aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) ); - msg = aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ); - aList.emplace_back( _( "Box Height" ), msg ); + aList.emplace_back( _( "Box Height" ), + aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) ); - m_stroke.GetMsgPanelInfo( schIUScale, aFrame->GetUserUnits(), aList ); + m_stroke.GetMsgPanelInfo( aFrame, aList ); } diff --git a/eeschema/lib_textbox.h b/eeschema/lib_textbox.h index c5a6f2e120..a066920dd7 100644 --- a/eeschema/lib_textbox.h +++ b/eeschema/lib_textbox.h @@ -79,7 +79,7 @@ public: virtual bool IsReplaceable() const override { return true; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index 6f4d02fc61..b11727b8b5 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -124,7 +124,7 @@ public: void MirrorVertically( int aCenter ) override; void Rotate( const VECTOR2I& aCenter ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return wxString( _( "Image" ) ); } diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 9f65b40b2c..35185fa4c1 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -412,13 +412,13 @@ std::vector SCH_BUS_ENTRY_BASE::GetConnectionPoints() const } -wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString( _( "Bus to Wire Entry" ) ); } -wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString( _( "Bus to Bus Entry" ) ); } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 86136776ce..7f7ecf5e2b 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -178,7 +178,7 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; EDA_ITEM* Clone() const override; @@ -225,7 +225,7 @@ public: return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_connection.cpp b/eeschema/sch_connection.cpp index b902ce3eec..50084cea4f 100644 --- a/eeschema/sch_connection.cpp +++ b/eeschema/sch_connection.cpp @@ -439,7 +439,9 @@ void SCH_CONNECTION::AppendInfoToMsgPanel( std::vector& aList ) if( SCH_ITEM* driver = Driver() ) { - msg.Printf( "%s at %p", driver->GetSelectMenuText( EDA_UNITS::MILLIMETRES ), driver ); + UNITS_PROVIDER unitsProvider( schIUScale, EDA_UNITS::MILLIMETRES ); + + msg.Printf( "%s at %p", driver->GetSelectMenuText( &unitsProvider ), driver ); aList.emplace_back( wxT( "Connection Source" ), msg ); } #endif diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index fe8bca3f35..e7eb6e7e8d 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -553,9 +553,6 @@ bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) co wxString text = GetShownText(); - wxLogTrace( traceFindItem, wxT( " child item " ) - + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ); - if( !IsVisible() && !searchHiddenFields ) return false; @@ -704,7 +701,7 @@ void SCH_FIELD::Rotate( const VECTOR2I& aCenter ) } -wxString SCH_FIELD::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_FIELD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( "%s '%s'", GetName(), KIUI::EllipsizeMenuText( GetShownText() ) ); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 7b2bb3c197..34cf7ff288 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -204,7 +204,7 @@ public: bool Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData = nullptr ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 524f7cac3a..d1786e2518 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -92,7 +92,7 @@ public: || aItem->Type() == SCH_SYMBOL_T ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return wxString( _( "Junction" ) ); } diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 152088d7ed..daf21c2176 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -1020,7 +1020,7 @@ const BOX2I SCH_LABEL::GetBodyBoundingBox() const } -wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_LABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); } @@ -1191,7 +1191,7 @@ void SCH_DIRECTIVE_LABEL::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) } -wxString SCH_DIRECTIVE_LABEL::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_DIRECTIVE_LABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { if( m_fields.empty() ) { @@ -1473,7 +1473,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings } -wxString SCH_GLOBALLABEL::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_GLOBALLABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); } @@ -1606,7 +1606,7 @@ VECTOR2I SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings } -wxString SCH_HIERLABEL::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_HIERLABEL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h index 184dc76542..ee90027128 100644 --- a/eeschema/sch_label.h +++ b/eeschema/sch_label.h @@ -229,7 +229,7 @@ public: bool IsConnectable() const override { return true; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; @@ -291,7 +291,7 @@ public: void AutoplaceFields( SCH_SCREEN* aScreen, bool aManual ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; bool IsConnectable() const override { return true; } @@ -347,7 +347,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; @@ -399,7 +399,7 @@ public: bool IsConnectable() const override { return true; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index fc8e53ff98..886fc427ab 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -691,7 +691,7 @@ void SCH_LINE::GetSelectedPoints( std::vector& aPoints ) const } -wxString SCH_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_LINE::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxString txtfmt; @@ -724,7 +724,7 @@ wxString SCH_LINE::GetSelectMenuText( EDA_UNITS aUnits ) const } return wxString::Format( txtfmt, - EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, EuclideanNorm( m_start - m_end ) ) ); + aUnitsProvider->MessageTextFromValue( 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( aFrame, aList, true, false ); SCH_CONNECTION* conn = nullptr; diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 085019c379..55ee42238d 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -245,7 +245,7 @@ public: bool CanConnect( const SCH_ITEM* aItem ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 1367974bca..c20e3d7a05 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -94,7 +94,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return wxString( _( "ERC Marker" ) ); } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 2a0c520625..cbed76ee05 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -92,7 +92,7 @@ public: std::vector GetConnectionPoints() const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return wxString( _( "No Connect" ) ); } diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 1cd34d8156..5ffffc7889 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -191,17 +191,16 @@ SCH_SYMBOL* SCH_PIN::GetParentSymbol() const } -wxString SCH_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( "Symbol %s %s", GetParentSymbol()->GetField( REFERENCE_FIELD )->GetShownText(), - m_libPin->GetSelectMenuText( aUnits ) ); + m_libPin->GetSelectMenuText( aUnitsProvider ) ); } void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - EDA_UNITS units = aFrame->GetUserUnits(); wxString msg; aList.emplace_back( _( "Type" ), _( "Pin" ) ); @@ -222,7 +221,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( GetLength() ), true ); int i = PinOrientationIndex( GetOrientation() ); aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) ); diff --git a/eeschema/sch_pin.h b/eeschema/sch_pin.h index 026dd12b12..41e150e353 100644 --- a/eeschema/sch_pin.h +++ b/eeschema/sch_pin.h @@ -68,7 +68,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; void Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override {} diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index 0623a267dc..f20db1cc42 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -368,22 +368,22 @@ void SCH_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( GetRadius() ) ); case SHAPE_T::CIRCLE: return wxString::Format( _( "Circle, radius %s" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, aUnits, GetRadius() ) ); + aUnitsProvider->MessageTextFromValue( GetRadius() ) ); case SHAPE_T::RECT: return wxString::Format( _( "Rectangle, width %s height %s" ), - 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 ) ) ); + aUnitsProvider->MessageTextFromValue( std::abs( m_start.x - m_end.x ) ), + aUnitsProvider->MessageTextFromValue( std::abs( m_start.y - m_end.y ) ) ); case SHAPE_T::POLY: return wxString::Format( _( "Polyline, %d points" ), diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 70ab078759..abd6382947 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -99,7 +99,7 @@ public: void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 8151b994d4..a343e5a187 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -914,8 +914,6 @@ void SCH_SHEET::Resize( const wxSize& aSize ) bool SCH_SHEET::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ); - // Sheets are searchable via the child field and pin item text. return false; } @@ -1035,7 +1033,7 @@ void SCH_SHEET::RunOnChildren( const std::function& aFunction } -wxString SCH_SHEET::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_SHEET::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Sheet %s" ), m_fields[ SHEETNAME ].GetText() ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 6af6501c78..102f338a7c 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -355,7 +355,7 @@ public: void RunOnChildren( const std::function& aFunction ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index dd92a65487..4e8ff5a2f2 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -57,7 +57,7 @@ public: SCH_ITEM( nullptr, NOT_USED ) {} - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return _( "(Deleted Item)" ); } diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index bf98611a03..70399f2d6b 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -325,7 +325,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector& aItemList ) } -wxString SCH_SHEET_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_SHEET_PIN::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Sheet Pin %s" ), KIUI::EllipsizeMenuText( GetShownText() ) ); diff --git a/eeschema/sch_sheet_pin.h b/eeschema/sch_sheet_pin.h index 637de4391c..fdd0256b2b 100644 --- a/eeschema/sch_sheet_pin.h +++ b/eeschema/sch_sheet_pin.h @@ -182,7 +182,7 @@ public: bool IsConnectable() const override { return true; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 73a0acb91f..32c67070b5 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1662,8 +1662,6 @@ void SCH_SYMBOL::Rotate( const VECTOR2I& aCenter ) bool SCH_SYMBOL::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( EDA_UNITS::MILLIMETRES ) ); - // Symbols are searchable via the child field and pin item text. return false; } @@ -1781,7 +1779,7 @@ LIB_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType ) } -wxString SCH_SYMBOL::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_SYMBOL::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Symbol %s [%s]" ), GetField( REFERENCE_FIELD )->GetShownText(), diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index c288d7b8e2..b563cae154 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -691,7 +691,7 @@ public: */ LIB_ITEM* GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType = TYPE_NOT_INIT ); - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 2bc616b685..5939ea12ea 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -393,7 +393,7 @@ void SCH_TEXT::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const } -wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_TEXT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index 97c0ae54b8..d363cb0440 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -201,7 +201,7 @@ public: void ViewGetLayers( int aLayers[], int& aCount ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 51e745fabe..150d36c8cd 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -363,7 +363,7 @@ void SCH_TEXTBOX::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const } -wxString SCH_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString SCH_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Graphic Text Box" ) ); } @@ -435,8 +435,6 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - EDA_UNITS units = aFrame->GetUserUnits(); - // Don't use GetShownText() here; we want to show the user the variable references aList.emplace_back( _( "Text Box" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); @@ -446,13 +444,13 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( GetTextWidth() ) ); - wxString msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, std::abs( GetEnd().x - GetStart().x ) ); - aList.emplace_back( _( "Box Width" ), msg ); + aList.emplace_back( _( "Box Width" ), + aFrame->MessageTextFromValue( std::abs( GetEnd().x - GetStart().x ) ) ); - msg = EDA_UNIT_UTILS::UI::MessageTextFromValue( schIUScale, units, std::abs( GetEnd().y - GetStart().y ) ); - aList.emplace_back( _( "Box Height" ), msg ); + aList.emplace_back( _( "Box Height" ), + aFrame->MessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ) ); - m_stroke.GetMsgPanelInfo( schIUScale, units, aList ); + m_stroke.GetMsgPanelInfo( aFrame, aList ); } diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index 4df2bb4ab7..32ff3ff257 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -100,7 +100,7 @@ public: virtual bool IsReplaceable() const override { return true; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 6a5814266c..6d720a3cca 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -993,7 +993,7 @@ INSPECT_RESULT GERBER_DRAW_ITEM::Visit( INSPECTOR inspector, void* testData, } -wxString GERBER_DRAW_ITEM::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString GERBER_DRAW_ITEM::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxString layerName = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true ); diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index f74761ccc3..be9c4dc46c 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -222,7 +222,7 @@ public: const std::vector& aScanTypes ) override; ///< @copydoc EDA_ITEM::GetSelectMenuText() - virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + virtual wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; ///< @copydoc EDA_ITEM::GetMenuImage() BITMAPS GetMenuImage() const override; diff --git a/include/board_item.h b/include/board_item.h index b34b410578..d35e199e38 100644 --- a/include/board_item.h +++ b/include/board_item.h @@ -341,7 +341,7 @@ public: BOARD_ITEM( nullptr, NOT_USED ) {} - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return _( "(Deleted Item)" ); } diff --git a/include/drawing_sheet/ds_draw_item.h b/include/drawing_sheet/ds_draw_item.h index d216b07435..e985fe2d37 100644 --- a/include/drawing_sheet/ds_draw_item.h +++ b/include/drawing_sheet/ds_draw_item.h @@ -143,7 +143,7 @@ public: void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -178,7 +178,7 @@ public: void PrintWsItem( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -232,7 +232,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -279,7 +279,7 @@ public: const BOX2I GetBoundingBox() const override; bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override { return false; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -329,7 +329,7 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } @@ -362,7 +362,7 @@ public: bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; const BOX2I GetBoundingBox() const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); } diff --git a/include/eda_base_frame.h b/include/eda_base_frame.h index 1bf3b39dfc..48375f5748 100644 --- a/include/eda_base_frame.h +++ b/include/eda_base_frame.h @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include // Option for main frames @@ -101,7 +101,8 @@ wxDECLARE_EVENT( UNITS_CHANGED, wxCommandEvent ); * calling it from the derived class's SaveSettings(). This class is not a #KIWAY_PLAYER * because #KICAD_MANAGER_FRAME is derived from it and that class is not a player. */ -class EDA_BASE_FRAME : public wxFrame, public TOOLS_HOLDER, public KIWAY_HOLDER +class EDA_BASE_FRAME : public wxFrame, public TOOLS_HOLDER, public KIWAY_HOLDER, + public UNITS_PROVIDER { public: /** @@ -115,25 +116,10 @@ public: EDA_BASE_FRAME( wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, long aStyle, - const wxString& aFrameName, KIWAY* aKiway ); - - EDA_BASE_FRAME( FRAME_T aFrameType, KIWAY* aKiway ); + const wxString& aFrameName, KIWAY* aKiway, const EDA_IU_SCALE& aIuScale ); ~EDA_BASE_FRAME(); - /** - * Return the user units currently in use. - */ - EDA_UNITS GetUserUnits() const - { - return m_userUnits; - } - - void SetUserUnits( EDA_UNITS aUnits ) - { - m_userUnits = aUnits; - } - void ChangeUserUnits( EDA_UNITS aUnits ); virtual void ToggleUserUnits() { } diff --git a/include/eda_draw_frame.h b/include/eda_draw_frame.h index 047b49a665..caab9ff588 100644 --- a/include/eda_draw_frame.h +++ b/include/eda_draw_frame.h @@ -450,67 +450,6 @@ public: */ void ShowChangedLanguage() override; - const EDA_IU_SCALE& GetIuScale() const { return m_iuScale; } - - /** - * Converts \a aValue in internal units into a united string. - * - * For readability, trailing 0s are removed if the mantissa has 3 or more digits. - * 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. - * - * @param aValue = value in internal units - * @param aAddUnitLabel = 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( double aValue, bool aAddUnitLabel = false, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) - { - return EDA_UNIT_UTILS::UI::StringFromValue( GetIuScale(), GetUserUnits(), aValue, - aAddUnitLabel, aType ); - } - - wxString StringFromValue( const EDA_ANGLE& aValue, bool aAddUnitLabel = false ) - { - return EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::DEGREES, - aValue.AsDegrees(), aAddUnitLabel, - EDA_DATA_TYPE::DISTANCE ); - } - - /** - * A lower-precision version of StringFromValue(). - * - * Should ONLY be used for status text and messages. Not suitable for dialogs, files, etc. - * where the loss of precision matters. - */ - wxString MessageTextFromValue( double aValue, bool aAddUnitLabel = true, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) - { - return EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), aValue, - aAddUnitLabel, aType ); - } - - wxString MessageTextFromValue( const EDA_ANGLE& aValue, bool aAddUnitLabel = true ) - { - return EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::DEGREES, - aValue.AsDegrees() ); - } - - /** - * Converts \a aTextValue in \a aUnits to internal units used by the frame. - * @warning This utilizes the current locale and will break if decimal formats differ - * - * @param aTextValue A reference to a wxString object containing the string to convert. - * @return internal units value - */ - long long int ValueFromString( const wxString& aTextValue, - EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) - { - return EDA_UNIT_UTILS::UI::ValueFromString( GetIuScale(), GetUserUnits(), aTextValue, - aType ); - } - DECLARE_EVENT_TABLE() protected: @@ -584,7 +523,6 @@ 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_item.h b/include/eda_item.h index 88ba0c1e65..3dc5109168 100644 --- a/include/eda_item.h +++ b/include/eda_item.h @@ -34,7 +34,7 @@ #include #include #include - +#include enum class BITMAPS : unsigned int; @@ -370,7 +370,7 @@ public: * * @return The menu text string. */ - virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const; + virtual wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const; /** * Return a pointer to an image to be used in menus. diff --git a/include/kiway_player.h b/include/kiway_player.h index ac2c771743..d377d1e1b0 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -67,7 +67,7 @@ class KIWAY_PLAYER : public EDA_BASE_FRAME public: KIWAY_PLAYER( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType, const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize, - long aStyle, const wxString& aWdoName = wxFrameNameStr ); + long aStyle, const wxString& aFrameName, const EDA_IU_SCALE& aIuScale ); /// Don't use this one, only wxformbuilder uses it, and it must be augmented with /// a SetKiway() early in derived constructor. diff --git a/include/pcb_group.h b/include/pcb_group.h index a8b655e894..3af158b9ef 100644 --- a/include/pcb_group.h +++ b/include/pcb_group.h @@ -180,7 +180,7 @@ public: void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; ///< @copydoc EDA_ITEM::GetSelectMenuText - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; ///< @copydoc EDA_ITEM::GetMenuImage BITMAPS GetMenuImage() const override; diff --git a/include/rc_item.h b/include/rc_item.h index d49f094b88..7c85e882e1 100644 --- a/include/rc_item.h +++ b/include/rc_item.h @@ -25,6 +25,7 @@ #define RC_ITEM_H #include +#include #include #include #include @@ -129,7 +130,7 @@ public: * * @return wxString - the simple multi-line report text. */ - virtual wxString ShowReport( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, SEVERITY aSeverity, + virtual wxString ShowReport( UNITS_PROVIDER* aUnitsProvider, SEVERITY aSeverity, const std::map& aItemMap ) const; int GetErrorCode() const { return m_errorCode; } @@ -160,12 +161,6 @@ public: return wxEmptyString; } - /** - * Format a coordinate or position to text. - */ - static wxString ShowCoord( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, - const VECTOR2I& aPos ); - protected: int m_errorCode; ///< The error code's numeric value wxString m_errorMessage; ///< A message describing the details of this specific error diff --git a/include/stroke_params.h b/include/stroke_params.h index 76d9219cf9..f49cb1a7cd 100644 --- a/include/stroke_params.h +++ b/include/stroke_params.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include @@ -113,7 +113,7 @@ public: void Format( OUTPUTFORMATTER* out, const EDA_IU_SCALE& aIuScale, int nestLevel ) const; - void GetMsgPanelInfo( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits, std::vector& aList, + void GetMsgPanelInfo( UNITS_PROVIDER* aUnitsProvider, std::vector& aList, bool aIncludeStyle = true, bool aIncludeWidth = true ); // Helper functions diff --git a/include/units_provider.h b/include/units_provider.h new file mode 100644 index 0000000000..3d0a952d6c --- /dev/null +++ b/include/units_provider.h @@ -0,0 +1,108 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2022 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 + */ + +#ifndef UNITS_PROVIDER_H +#define UNITS_PROVIDER_H + +#include + +class UNITS_PROVIDER +{ +public: + UNITS_PROVIDER( const EDA_IU_SCALE& aIuScale, EDA_UNITS aUnits ) : + m_iuScale( aIuScale ), + m_userUnits( aUnits ) + {} + + EDA_UNITS GetUserUnits() const { return m_userUnits; } + void SetUserUnits( EDA_UNITS aUnits ) { m_userUnits = aUnits; } + + const EDA_IU_SCALE& GetIuScale() const { return m_iuScale; } + // No SetIuScale(); scale is invariant + + /** + * Converts \a aValue in internal units into a united string. + * + * For readability, trailing 0s are removed if the mantissa has 3 or more digits. + * 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. + * + * @param aValue = value in internal units + * @param aAddUnitLabel = 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( double aValue, bool aAddUnitLabel = false, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) + { + return EDA_UNIT_UTILS::UI::StringFromValue( GetIuScale(), GetUserUnits(), aValue, + aAddUnitLabel, aType ); + } + + wxString StringFromValue( const EDA_ANGLE& aValue, bool aAddUnitLabel = false ) + { + return EDA_UNIT_UTILS::UI::StringFromValue( unityScale, EDA_UNITS::DEGREES, + aValue.AsDegrees(), aAddUnitLabel, + EDA_DATA_TYPE::DISTANCE ); + } + + /** + * A lower-precision version of StringFromValue(). + * + * Should ONLY be used for status text and messages. Not suitable for dialogs, files, etc. + * where the loss of precision matters. + */ + wxString MessageTextFromValue( double aValue, bool aAddUnitLabel = true, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) + { + return EDA_UNIT_UTILS::UI::MessageTextFromValue( GetIuScale(), GetUserUnits(), aValue, + aAddUnitLabel, aType ); + } + + wxString MessageTextFromValue( const EDA_ANGLE& aValue, bool aAddUnitLabel = true ) + { + return EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::DEGREES, + aValue.AsDegrees(), aAddUnitLabel, + EDA_DATA_TYPE::DISTANCE ); + } + + /** + * Converts \a aTextValue in \a aUnits to internal units used by the frame. + * @warning This utilizes the current locale and will break if decimal formats differ + * + * @param aTextValue A reference to a wxString object containing the string to convert. + * @return internal units value + */ + long long int ValueFromString( const wxString& aTextValue, + EDA_DATA_TYPE aType = EDA_DATA_TYPE::DISTANCE ) + { + return EDA_UNIT_UTILS::UI::ValueFromString( GetIuScale(), GetUserUnits(), aTextValue, + aType ); + } + +private: + const EDA_IU_SCALE& m_iuScale; + EDA_UNITS m_userUnits; +}; + +#endif // UNITS_PROVIDER_H diff --git a/kicad/kicad_manager_frame.cpp b/kicad/kicad_manager_frame.cpp index 7462af9f90..0902c77b23 100644 --- a/kicad/kicad_manager_frame.cpp +++ b/kicad/kicad_manager_frame.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 CERN (www.cern.ch) - * Copyright (C) 2004-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2004-2022 KiCad Developers, see change_log.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 @@ -111,8 +111,8 @@ END_EVENT_TABLE() KICAD_MANAGER_FRAME::KICAD_MANAGER_FRAME( wxWindow* parent, const wxString& title, const wxPoint& pos, const wxSize& size ) : - EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size, - KICAD_DEFAULT_DRAWFRAME_STYLE, KICAD_MANAGER_FRAME_NAME, &::Kiway ), + EDA_BASE_FRAME( parent, KICAD_MAIN_FRAME_T, title, pos, size, KICAD_DEFAULT_DRAWFRAME_STYLE, + KICAD_MANAGER_FRAME_NAME, &::Kiway, unityScale ), m_leftWin( nullptr ), m_launcher( nullptr ), m_mainToolBar( nullptr ) diff --git a/pcbnew/board.cpp b/pcbnew/board.cpp index 7c6444b33f..17309760f9 100644 --- a/pcbnew/board.cpp +++ b/pcbnew/board.cpp @@ -868,7 +868,7 @@ void BOARD::Remove( BOARD_ITEM* aBoardItem, REMOVE_MODE aRemoveMode ) } -wxString BOARD::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString BOARD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "PCB" ) ); } diff --git a/pcbnew/board.h b/pcbnew/board.h index 77ba082733..11ac32d3c3 100644 --- a/pcbnew/board.h +++ b/pcbnew/board.h @@ -625,7 +625,7 @@ public: const TITLE_BLOCK& GetTitleBlock() const { return m_titles; } void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) { m_titles = aTitleBlock; } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; /** * Extract the board outlines and build a closed polygon from lines, arcs and circle items diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index af3cc8b21e..964dcae771 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -1025,8 +1025,8 @@ bool DIALOG_DRC::writeReport( const wxString& aFullFileName ) std::map itemMap; m_frame->GetBoard()->FillItemMap( itemMap ); - EDA_UNITS units = GetUserUnits(); BOARD_DESIGN_SETTINGS& bds = m_frame->GetBoard()->GetDesignSettings(); + UNITS_PROVIDER unitsProvider( pcbIUScale, GetUserUnits() ); int count; fprintf( fp, "** Drc report for %s **\n", TO_UTF8( m_frame->GetBoard()->GetFileName() ) ); @@ -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( pcbIUScale, units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, 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( pcbIUScale, units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, 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( pcbIUScale, units, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) ); } diff --git a/pcbnew/dialogs/dialog_group_properties.cpp b/pcbnew/dialogs/dialog_group_properties.cpp index 72d5fb1a2b..17211f5bb7 100644 --- a/pcbnew/dialogs/dialog_group_properties.cpp +++ b/pcbnew/dialogs/dialog_group_properties.cpp @@ -48,7 +48,7 @@ DIALOG_GROUP_PROPERTIES::DIALOG_GROUP_PROPERTIES( PCB_BASE_EDIT_FRAME* aParent, m_locked->Show( dynamic_cast( aParent ) != nullptr ); for( BOARD_ITEM* item : m_group->GetItems() ) - m_membersList->Append( item->GetSelectMenuText( m_brdEditor->GetUserUnits() ), item ); + m_membersList->Append( item->GetSelectMenuText( m_brdEditor ), item ); SetupStandardButtons(); @@ -155,7 +155,7 @@ void DIALOG_GROUP_PROPERTIES::DoAddMember( EDA_ITEM* aItem ) if( aItem == m_group ) return; - m_membersList->Append( aItem->GetSelectMenuText( m_brdEditor->GetUserUnits() ), aItem ); + m_membersList->Append( aItem->GetSelectMenuText( m_brdEditor ), aItem ); } diff --git a/pcbnew/dialogs/dialog_position_relative.cpp b/pcbnew/dialogs/dialog_position_relative.cpp index a01b52f687..ed4e3c6c5c 100644 --- a/pcbnew/dialogs/dialog_position_relative.cpp +++ b/pcbnew/dialogs/dialog_position_relative.cpp @@ -243,13 +243,14 @@ void DIALOG_POSITION_RELATIVE::OnUseUserOriginClick( wxCommandEvent& event ) void DIALOG_POSITION_RELATIVE::UpdateAnchor( EDA_ITEM* aItem ) { - wxString reference = _( "" ); - BOARD_ITEM* item = dynamic_cast( aItem ); + UNITS_PROVIDER unitsProvider( pcbIUScale, GetUserUnits() ); + BOARD_ITEM* item = dynamic_cast( aItem ); + wxString reference = _( "" ); if( item ) { m_anchor_position = item->GetPosition(); - reference = item->GetSelectMenuText( GetUserUnits() ); + reference = item->GetSelectMenuText( &unitsProvider ); } m_referenceInfo->SetLabel( wxString::Format( _( "Reference item: %s" ), reference ) ); diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 378cde95e0..2fa35f09b5 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -64,12 +64,12 @@ void drcPrintDebugMessage( int level, const wxString& msg, const char *function, DRC_ENGINE::DRC_ENGINE( BOARD* aBoard, BOARD_DESIGN_SETTINGS *aSettings ) : + UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES ), m_designSettings ( aSettings ), m_board( aBoard ), m_drawingSheet( nullptr ), m_schematicNetlist( nullptr ), m_rulesValid( false ), - m_userUnits( EDA_UNITS::MILLIMETRES ), m_reportAllTrackErrors( false ), m_testFootprints( false ), m_reporter( nullptr ), @@ -564,7 +564,7 @@ void DRC_ENGINE::InitEngine( const wxFileName& aRulePath ) void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aTestFootprints ) { - m_userUnits = aUnits; + SetUserUnits( aUnits ); m_reportAllTrackErrors = aReportAllTrackErrors; m_testFootprints = aTestFootprints; @@ -595,7 +595,7 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT { ReportAux( wxString::Format( wxT( "Run DRC provider: '%s'" ), provider->GetName() ) ); - if( !provider->Run() ) + if( !provider->RunTests( aUnits ) ) break; } @@ -606,10 +606,6 @@ 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 ) EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, UNITS, v ) -#define REPORT_UNSCALED_VALUE( v ) \ - EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED, v ) DRC_CONSTRAINT DRC_ENGINE::EvalZoneConnection( const BOARD_ITEM* a, const BOARD_ITEM* b, PCB_LAYER_ID aLayer, REPORTER* aReporter ) @@ -735,8 +731,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ), - EscapeHTML( a->GetSelectMenuText( UNITS ) ), - REPORT_VALUE( overrideA ) ) ) + EscapeHTML( a->GetSelectMenuText( this ) ), + MessageTextFromValue( overrideA ) ) ) override_val = ac->GetLocalClearanceOverrides( &msg ); } @@ -745,8 +741,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "Local override on %s; clearance: %s." ), - EscapeHTML( b->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( overrideB ) ) ) ) + EscapeHTML( b->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( overrideB ) ) ) ) if( overrideB > override_val ) override_val = bc->GetLocalClearanceOverrides( &msg ); @@ -763,7 +759,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Board minimum clearance: %s." ), - REPORT_VALUE( override_val ) ) ) + MessageTextFromValue( override_val ) ) ) } } else @@ -775,7 +771,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Board minimum hole clearance: %s." ), - REPORT_VALUE( override_val ) ) ) + MessageTextFromValue( override_val ) ) ) } } @@ -794,7 +790,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Local override on %s; zone connection: %s." ), - EscapeHTML( pad->GetSelectMenuText( UNITS ) ), + EscapeHTML( pad->GetSelectMenuText( this ) ), EscapeHTML( PrintZoneConnection( override ) ) ) ) constraint.SetName( msg ); @@ -811,8 +807,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Local override on %s; thermal relief gap: %s." ), - EscapeHTML( pad->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( gap_override ) ) ) ) + EscapeHTML( pad->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( gap_override ) ) ) ) constraint.SetName( msg ); constraint.m_Value.SetMin( gap_override ); @@ -828,8 +824,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Local override on %s; thermal spoke width: %s." ), - EscapeHTML( pad->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( spoke_override ) ) ) ) + EscapeHTML( pad->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( spoke_override ) ) ) ) if( zone && zone->GetMinThickness() > spoke_override ) { @@ -837,8 +833,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "%s min thickness: %s." ), - EscapeHTML( zone->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( spoke_override ) ) ) ) + EscapeHTML( zone->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( spoke_override ) ) ) ) } constraint.SetName( msg ); @@ -882,37 +878,38 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO case PHYSICAL_HOLE_CLEARANCE_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s clearance: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_VALUE( c->constraint.m_Value.Min() ) ) ) + MessageTextFromValue( c->constraint.m_Value.Min() ) ) ) break; case DIFF_PAIR_MAX_UNCOUPLED_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s max uncoupled length: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_VALUE( c->constraint.m_Value.Max() ) ) ) + MessageTextFromValue( c->constraint.m_Value.Max() ) ) ) break; case SKEW_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s max skew: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_VALUE( c->constraint.m_Value.Max() ) ) ) + MessageTextFromValue( c->constraint.m_Value.Max() ) ) ) break; case THERMAL_RELIEF_GAP_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s gap: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_VALUE( c->constraint.m_Value.Min() ) ) ) + MessageTextFromValue( c->constraint.m_Value.Min() ) ) ) break; case THERMAL_SPOKE_WIDTH_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s thermal spoke width: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_VALUE( c->constraint.m_Value.Opt() ) ) ) + MessageTextFromValue( c->constraint.m_Value.Opt() ) ) ) break; case MIN_RESOLVED_SPOKES_CONSTRAINT: REPORT( wxString::Format( _( "Checking %s min spoke count: %s." ), EscapeHTML( c->constraint.GetName() ), - REPORT_UNSCALED_VALUE( c->constraint.m_Value.Min() ) ) ) + EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED, + c->constraint.m_Value.Min() ) ) ) break; case ZONE_CONNECTION_CONSTRAINT: @@ -940,8 +937,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO if( implicit ) { - min = REPORT_VALUE( c->constraint.m_Value.Min() ); - opt = REPORT_VALUE( c->constraint.m_Value.Opt() ); + min = MessageTextFromValue( c->constraint.m_Value.Min() ); + opt = MessageTextFromValue( c->constraint.m_Value.Opt() ); switch( c->constraint.m_Type ) { @@ -1037,13 +1034,13 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO else { if( c->constraint.m_Value.HasMin() ) - min = REPORT_VALUE( c->constraint.m_Value.Min() ); + min = MessageTextFromValue( c->constraint.m_Value.Min() ); if( c->constraint.m_Value.HasOpt() ) - opt = REPORT_VALUE( c->constraint.m_Value.Opt() ); + opt = MessageTextFromValue( c->constraint.m_Value.Opt() ); if( c->constraint.m_Value.HasMax() ) - max = REPORT_VALUE( c->constraint.m_Value.Max() ); + max = MessageTextFromValue( c->constraint.m_Value.Max() ); REPORT( wxString::Format( _( "Checking %s: min %s; opt %s; max %s." ), EscapeHTML( c->constraint.GetName() ), @@ -1181,7 +1178,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO const BOARD_ITEM* x = !hasDrilledHole( a ) ? a : b; REPORT( wxString::Format( _( "%s is not a drilled hole; rule ignored." ), - x->GetSelectMenuText( UNITS ) ) ) + x->GetSelectMenuText( this ) ) ) } return false; @@ -1319,8 +1316,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ), - EscapeHTML( a->GetSelectMenuText( UNITS ) ), - REPORT_VALUE( localA ) ) ) + EscapeHTML( a->GetSelectMenuText( this ) ), + MessageTextFromValue( localA ) ) ) if( localA > clearance ) { @@ -1336,8 +1333,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "Local clearance on %s; clearance: %s." ), - EscapeHTML( b->GetSelectMenuText( UNITS ) ), - REPORT_VALUE( localB ) ) ) + EscapeHTML( b->GetSelectMenuText( this ) ), + MessageTextFromValue( localB ) ) ) if( localB > clearance ) { @@ -1351,7 +1348,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "Board minimum clearance: %s." ), - REPORT_VALUE( m_designSettings->m_MinClearance ) ) ) + MessageTextFromValue( m_designSettings->m_MinClearance ) ) ) if( clearance < m_designSettings->m_MinClearance ) { @@ -1366,7 +1363,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "Board minimum clearance: %s." ), - REPORT_VALUE( m_designSettings->m_MinClearance ) ) ) + MessageTextFromValue( m_designSettings->m_MinClearance ) ) ) if( constraint.m_Value.Min() < m_designSettings->m_MinClearance ) { @@ -1387,7 +1384,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO { REPORT( "" ) REPORT( wxString::Format( _( "%s zone connection: %s." ), - EscapeHTML( parentFootprint->GetSelectMenuText( UNITS ) ), + EscapeHTML( parentFootprint->GetSelectMenuText( this ) ), EscapeHTML( PrintZoneConnection( local ) ) ) ) constraint.SetParentRule( nullptr ); @@ -1403,7 +1400,7 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "%s pad connection: %s." ), - EscapeHTML( zone->GetSelectMenuText( UNITS ) ), + EscapeHTML( zone->GetSelectMenuText( this ) ), EscapeHTML( PrintZoneConnection( local ) ) ) ) constraint.SetParentRule( nullptr ); @@ -1420,8 +1417,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "%s thermal relief gap: %s." ), - EscapeHTML( zone->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( local ) ) ) ) + EscapeHTML( zone->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( local ) ) ) ) constraint.SetParentRule( nullptr ); constraint.SetName( _( "zone" ) ); @@ -1437,8 +1434,8 @@ DRC_CONSTRAINT DRC_ENGINE::EvalRules( DRC_CONSTRAINT_T aConstraintType, const BO REPORT( "" ) REPORT( wxString::Format( _( "%s thermal spoke width: %s." ), - EscapeHTML( zone->GetSelectMenuText( UNITS ) ), - EscapeHTML( REPORT_VALUE( local ) ) ) ) + EscapeHTML( zone->GetSelectMenuText( this ) ), + EscapeHTML( MessageTextFromValue( local ) ) ) ) constraint.SetParentRule( nullptr ); constraint.SetName( _( "zone" ) ); @@ -1530,8 +1527,6 @@ void DRC_ENGINE::ProcessAssertions( const BOARD_ITEM* a, #undef REPORT -#undef UNITS -#undef REPORT_VALUE bool DRC_ENGINE::IsErrorLimitExceeded( int error_code ) diff --git a/pcbnew/drc/drc_engine.h b/pcbnew/drc/drc_engine.h index e595e00ea1..31fca93f29 100644 --- a/pcbnew/drc/drc_engine.h +++ b/pcbnew/drc/drc_engine.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ typedef std::function& aItem, * Note that EvalRules() has yet another optional REPORTER for reporting resolution info to * the user. */ -class DRC_ENGINE +class DRC_ENGINE : public UNITS_PROVIDER { public: DRC_ENGINE( BOARD* aBoard = nullptr, BOARD_DESIGN_SETTINGS* aSettings = nullptr ); @@ -159,7 +159,6 @@ public: bool HasRulesForConstraintType( DRC_CONSTRAINT_T constraintID ); - EDA_UNITS UserUnits() const { return m_userUnits; } bool GetReportAllTrackErrors() const { return m_reportAllTrackErrors; } bool GetTestFootprints() const { return m_testFootprints; } @@ -238,7 +237,6 @@ protected: bool m_rulesValid; std::vector m_testProviders; - EDA_UNITS m_userUnits; std::vector m_errorLimits; bool m_reportAllTrackErrors; bool m_testFootprints; diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 0a4553c66c..a7b7b25bfa 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -44,7 +44,8 @@ DRC_TEST_PROVIDER_REGISTRY::~DRC_TEST_PROVIDER_REGISTRY() DRC_TEST_PROVIDER::DRC_TEST_PROVIDER() : - m_drcEngine( nullptr ) + UNITS_PROVIDER( pcbIUScale, EDA_UNITS::MILLIMETRES ), + m_drcEngine( nullptr ) { } @@ -112,12 +113,6 @@ void DRC_TEST_PROVIDER::reportAux( wxString fmt, ... ) } -EDA_UNITS DRC_TEST_PROVIDER::userUnits() const -{ - return m_drcEngine->UserUnits(); -} - - void DRC_TEST_PROVIDER::accountCheck( const DRC_RULE* ruleToTest ) { auto it = m_stats.find( ruleToTest ); diff --git a/pcbnew/drc/drc_test_provider.h b/pcbnew/drc/drc_test_provider.h index b97807893b..a6a21c985e 100644 --- a/pcbnew/drc/drc_test_provider.h +++ b/pcbnew/drc/drc_test_provider.h @@ -69,10 +69,10 @@ public: * Represent a DRC "provider" which runs some DRC functions over a #BOARD and spits out * #DRC_ITEMs and positions as needed. */ -class DRC_TEST_PROVIDER +class DRC_TEST_PROVIDER : public UNITS_PROVIDER { public: - DRC_TEST_PROVIDER (); + DRC_TEST_PROVIDER(); virtual ~DRC_TEST_PROVIDER() = default; static void Init(); @@ -83,6 +83,12 @@ public: m_stats.clear(); } + bool RunTests( EDA_UNITS aUnits ) + { + SetUserUnits( aUnits ); + return Run(); + } + /** * Run this provider against the given PCB with configured options (if any). */ diff --git a/pcbnew/drc/drc_test_provider_annular_width.cpp b/pcbnew/drc/drc_test_provider_annular_width.cpp index 34cc603afc..1bd8bcc70d 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), v_min ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), annularWidth ) ); + MessageTextFromValue( v_min ), + MessageTextFromValue( annularWidth ) ); } if( fail_max ) { msg.Printf( _( "(%s max annular width %s; actual %s)" ), constraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), v_max ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), annularWidth ) ); + MessageTextFromValue( v_max ), + MessageTextFromValue( 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 d423cc794f..a1db6be2f5 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" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), aMinWidth ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), dist ) ); + MessageTextFromValue( aMinWidth ), + MessageTextFromValue( 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 6a240ec23f..27c9bc7923 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), zone2zoneClearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), std::max( actual, 0 ) ) ); + MessageTextFromValue( zone2zoneClearance ), + MessageTextFromValue( 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 aeee5fbcbe..c944ff5cc5 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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 e5954f96b9..8a30471d43 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" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), itemSet.totalCoupled ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), totalLen ) ) ); + MessageTextFromValue( itemSet.totalCoupled ), + MessageTextFromValue( 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, - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Max() ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), totalUncoupled ) ); + MessageTextFromValue( val.Max() ), + MessageTextFromValue( 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; " ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Min() ) ); + MessageTextFromValue( val.Min() ) ); if( val.HasMax() ) msg += wxString::Format( _( "maximum gap: %s; " ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), val.Max() ) ); + MessageTextFromValue( val.Max() ) ); msg += wxString::Format( _( "actual: %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), dp.computedGap ) ); + MessageTextFromValue( 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 4d4d3ad53d..425dcbe695 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( minClearance ), + MessageTextFromValue( 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 d0549909d4..b29d86b55f 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), holeMinor ) ); + MessageTextFromValue( constraintValue ), + MessageTextFromValue( holeMinor ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), holeMajor ) ); + MessageTextFromValue( constraintValue ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), via->GetDrillValue() ) ); + MessageTextFromValue( constraintValue ), + MessageTextFromValue( via->GetDrillValue() ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintValue ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), via->GetDrillValue() ) ); + MessageTextFromValue( constraintValue ), + MessageTextFromValue( 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 5922e8e6ef..769cdf9907 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( minClearance ), + MessageTextFromValue( 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 c1970b1dbf..d5d3b2afe5 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minLen ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ) ); + MessageTextFromValue( minLen ), + MessageTextFromValue( ent.total ) ); } else if( maxViolation ) { msg.Printf( _( "(%s max length: %s; actual: %s)" ), aConstraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), maxLen ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), ent.total ) ); + MessageTextFromValue( maxLen ), + MessageTextFromValue( 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(), - 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 ) ); + MessageTextFromValue( aConstraint.GetValue().Max() ), + MessageTextFromValue( skew ), + MessageTextFromValue( avgLength ), + MessageTextFromValue( 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(), - 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 ), + MessageTextFromValue( ent.total ), + MessageTextFromValue( ent.totalRoute ), + MessageTextFromValue( ent.totalVia ), + MessageTextFromValue( 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 7cc5cc0440..38defb0f49 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), collision.second ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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 191ef91d55..f42e15e812 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, - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), minClearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( minClearance ), + MessageTextFromValue( 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 ec4e38c29d..65829b23a6 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), clearance ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( clearance ), + MessageTextFromValue( 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 3abbcd97d9..3dd9c39ba6 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Min() ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualHeight ) ); + MessageTextFromValue( constraint.Value().Min() ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Max() ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualHeight ) ); + MessageTextFromValue( constraint.Value().Max() ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Min() ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualThickness ) ); + MessageTextFromValue( constraint.Value().Min() ), + MessageTextFromValue( 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraint.Value().Max() ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actualThickness ) ); + MessageTextFromValue( constraint.Value().Max() ), + MessageTextFromValue( 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 cdd20480b4..ebefb16a35 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintWidth ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( constraintWidth ), + MessageTextFromValue( actual ) ); } else { msg.Printf( _( "(%s max width %s; actual %s)" ), constraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintWidth ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( constraintWidth ), + MessageTextFromValue( 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 b4347602dd..2670342ef5 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(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintDiameter ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( constraintDiameter ), + MessageTextFromValue( actual ) ); } else if( fail_max ) { msg.Printf( _( "(%s max diameter %s; actual %s)" ), constraint.GetName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), constraintDiameter ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, userUnits(), actual ) ); + MessageTextFromValue( constraintDiameter ), + MessageTextFromValue( actual ) ); } drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + msg ); diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 151451a1bd..33a6932afa 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1350,7 +1350,7 @@ INSPECT_RESULT FOOTPRINT::Visit( INSPECTOR inspector, void* testData, } -wxString FOOTPRINT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString FOOTPRINT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxString reference = GetReference(); diff --git a/pcbnew/footprint.h b/pcbnew/footprint.h index 66b0364de9..f7c7b8570c 100644 --- a/pcbnew/footprint.h +++ b/pcbnew/footprint.h @@ -644,7 +644,7 @@ public: return wxT( "FOOTPRINT" ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/fp_shape.cpp b/pcbnew/fp_shape.cpp index 0ce36f8680..6a2f0e86b3 100644 --- a/pcbnew/fp_shape.cpp +++ b/pcbnew/fp_shape.cpp @@ -121,7 +121,7 @@ void FP_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorm_Uuid.AsString(); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index 9c6eeece7e..c50f72f398 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -300,7 +300,7 @@ void FP_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) ); aList.emplace_back( _( "Box Height" ), msg ); - m_stroke.GetMsgPanelInfo( pcbIUScale, aFrame->GetUserUnits(), aList ); + m_stroke.GetMsgPanelInfo( aFrame, aList ); } -wxString FP_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString FP_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Footprint Text Box of %s" ), static_cast( GetParent() )->GetReference() ); diff --git a/pcbnew/fp_textbox.h b/pcbnew/fp_textbox.h index e865901ec1..081150ee1f 100644 --- a/pcbnew/fp_textbox.h +++ b/pcbnew/fp_textbox.h @@ -128,7 +128,7 @@ public: return wxT( "FP_TEXTBOX" ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 63d4be3eaf..733baa5332 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1217,7 +1217,7 @@ wxString PAD::ShowPadAttr() const } -wxString PAD::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PAD::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { if( GetNumber().IsEmpty() ) { diff --git a/pcbnew/pad.h b/pcbnew/pad.h index 55963a3ec3..58f7dfb3f9 100644 --- a/pcbnew/pad.h +++ b/pcbnew/pad.h @@ -663,7 +663,7 @@ public: void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pcb_bitmap.h b/pcbnew/pcb_bitmap.h index 97d06ea5a5..8fdbdd4a9a 100644 --- a/pcbnew/pcb_bitmap.h +++ b/pcbnew/pcb_bitmap.h @@ -107,7 +107,7 @@ public: void Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) override; void Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override { return wxString( _( "Image" ) ); } diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index 5d79e32902..bb339693e4 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -318,28 +318,29 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, aList.emplace_back( _( "Suffix" ), GetSuffix() ); - EDA_UNITS units; + // Use our own UNITS_PROVIDER to report dimension info in dimension's units rather than + // in frame's units. + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::MILLIMETRES ); + unitsProvider.SetUserUnits( GetUnits() ); - GetUnits( units ); - aList.emplace_back( _( "Units" ), EDA_UNIT_UTILS::GetLabel( units ) ); + aList.emplace_back( _( "Units" ), EDA_UNIT_UTILS::GetLabel( GetUnits() ) ); aList.emplace_back( _( "Font" ), m_text.GetDrawFont()->GetName() ); aList.emplace_back( _( "Text Thickness" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextThickness() ) ); + unitsProvider.MessageTextFromValue( m_text.GetTextThickness() ) ); aList.emplace_back( _( "Text Width" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextWidth() ) ); + unitsProvider.MessageTextFromValue( m_text.GetTextWidth() ) ); aList.emplace_back( _( "Text Height" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, m_text.GetTextHeight() ) ); + unitsProvider.MessageTextFromValue( m_text.GetTextHeight() ) ); ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms(); - units = aFrame->GetUserUnits(); if( Type() == PCB_DIM_CENTER_T || Type() == PCB_FP_DIM_CENTER_T ) { VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( wxT( "@(%s, %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.x ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.y ) ); + aFrame->MessageTextFromValue( startCoord.x ), + aFrame->MessageTextFromValue( startCoord.y ) ); aList.emplace_back( start, wxEmptyString ); } @@ -347,12 +348,12 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, { VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( wxT( "@(%s, %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.x ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.y ) ); + aFrame->MessageTextFromValue( startCoord.x ), + aFrame->MessageTextFromValue( startCoord.y ) ); VECTOR2I endCoord = originTransforms.ToDisplayAbs( GetEnd() ); wxString end = wxString::Format( wxT( "@(%s, %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, endCoord.x ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, endCoord.y ) ); + aFrame->MessageTextFromValue( endCoord.x ), + aFrame->MessageTextFromValue( endCoord.y ) ); aList.emplace_back( start, end ); } @@ -446,7 +447,7 @@ const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() const } -wxString PCB_DIMENSION_BASE::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_DIMENSION_BASE::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Dimension '%s' on %s" ), GetText(), GetLayerName() ); } @@ -729,11 +730,12 @@ void PCB_DIM_ALIGNED::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetOriginTransforms(); - EDA_UNITS units = aFrame->GetUserUnits(); VECTOR2I startCoord = originTransforms.ToDisplayAbs( GetStart() ); wxString start = wxString::Format( wxT( "@(%s, %s)" ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.x ), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, units, startCoord.y ) ); + aFrame->MessageTextFromValue( startCoord.x ), + aFrame->MessageTextFromValue( startCoord.y ) ); aList.emplace_back( start, wxEmptyString ); diff --git a/pcbnew/pcb_dimension.h b/pcbnew/pcb_dimension.h index e15b06423f..6c270858a0 100644 --- a/pcbnew/pcb_dimension.h +++ b/pcbnew/pcb_dimension.h @@ -158,7 +158,7 @@ public: wxString GetSuffix() const { return m_suffix; } void SetSuffix( const wxString& aSuffix ); - void GetUnits( EDA_UNITS& aUnits ) const { aUnits = m_units; } + EDA_UNITS GetUnits() const { return m_units; } void SetUnits( EDA_UNITS aUnits ); DIM_UNITS_MODE GetUnitsMode() const; @@ -245,7 +245,7 @@ public: std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash = FLASHING::DEFAULT ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; const BOX2I ViewBBox() const override; diff --git a/pcbnew/pcb_group.cpp b/pcbnew/pcb_group.cpp index 8acb4fd027..4063981438 100644 --- a/pcbnew/pcb_group.cpp +++ b/pcbnew/pcb_group.cpp @@ -310,7 +310,7 @@ void PCB_GROUP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } -wxString PCB_GROUP::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_GROUP::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { if( m_name.empty() ) { diff --git a/pcbnew/pcb_marker.cpp b/pcbnew/pcb_marker.cpp index 7bb349eab4..84483aeeeb 100644 --- a/pcbnew/pcb_marker.cpp +++ b/pcbnew/pcb_marker.cpp @@ -206,10 +206,10 @@ void PCB_MARKER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetItem( m_rcItem->GetAuxItemID() ); if( mainItem ) - mainText = mainItem->GetSelectMenuText( aFrame->GetUserUnits() ); + mainText = mainItem->GetSelectMenuText( aFrame ); if( auxItem ) - auxText = auxItem->GetSelectMenuText( aFrame->GetUserUnits() ); + auxText = auxItem->GetSelectMenuText( aFrame ); aList.emplace_back( mainText, auxText ); } @@ -236,7 +236,7 @@ std::shared_ptr PCB_MARKER::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASH } -wxString PCB_MARKER::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_MARKER::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { // m_rcItem->GetErrorMessage() could be used instead, but is probably too long // for menu duty. diff --git a/pcbnew/pcb_marker.h b/pcbnew/pcb_marker.h index 7fdc12b4d3..91120e1ee5 100644 --- a/pcbnew/pcb_marker.h +++ b/pcbnew/pcb_marker.h @@ -98,7 +98,7 @@ public: return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index 89dd30332a..139e1a63f8 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -259,7 +259,7 @@ void PCB_SHAPE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector PCB_TARGET::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASH } -wxString PCB_TARGET::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_TARGET::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { // Targets are on *every* layer by definition return _( "Target" ); diff --git a/pcbnew/pcb_target.h b/pcbnew/pcb_target.h index 62f8854cf3..8f402e7593 100644 --- a/pcbnew/pcb_target.h +++ b/pcbnew/pcb_target.h @@ -86,7 +86,7 @@ public: std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash = FLASHING::DEFAULT ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index d26b963ac2..ea8d143954 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -229,7 +229,7 @@ void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } -wxString PCB_TEXT::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_TEXT::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "PCB Text '%s' on %s"), KIUI::EllipsizeMenuText( GetShownText() ), diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 2e1a42e2d9..f86965ad8c 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -136,7 +136,7 @@ public: virtual std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, FLASHING aFlash = FLASHING::DEFAULT ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index f5a9fa34e9..6008e605ab 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -316,7 +316,7 @@ void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorMessageTextFromValue( std::abs( GetEnd().y - GetStart().y ) )); - m_stroke.GetMsgPanelInfo( pcbIUScale, aFrame->GetUserUnits(), aList ); + m_stroke.GetMsgPanelInfo( aFrame, aList ); } @@ -398,7 +398,7 @@ bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) } -wxString PCB_TEXTBOX::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_TEXTBOX::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "PCB Text Box on %s"), GetLayerName() ); } diff --git a/pcbnew/pcb_textbox.h b/pcbnew/pcb_textbox.h index ee0a28b331..92382d0d08 100644 --- a/pcbnew/pcb_textbox.h +++ b/pcbnew/pcb_textbox.h @@ -125,7 +125,7 @@ public: virtual std::shared_ptr GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER, FLASHING aFlash = FLASHING::DEFAULT ) const override; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/pcb_track.cpp b/pcbnew/pcb_track.cpp index 4af88c1c38..875e83c3cf 100644 --- a/pcbnew/pcb_track.cpp +++ b/pcbnew/pcb_track.cpp @@ -94,7 +94,7 @@ EDA_ITEM* PCB_VIA::Clone() const } -wxString PCB_VIA::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_VIA::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxString formatStr; @@ -1015,13 +1015,13 @@ bool PCB_VIA::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) cons } -wxString PCB_TRACK::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString PCB_TRACK::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( Type() == PCB_ARC_T ? _("Track (arc) %s on %s, length %s" ) : _("Track %s on %s, length %s" ), GetNetnameMsg(), GetLayerName(), - EDA_UNIT_UTILS::UI::MessageTextFromValue( pcbIUScale, aUnits, GetLength() ) ); + aUnitsProvider->MessageTextFromValue( GetLength() ) ); } diff --git a/pcbnew/pcb_track.h b/pcbnew/pcb_track.h index de7f770fc6..76fd2ab4e4 100644 --- a/pcbnew/pcb_track.h +++ b/pcbnew/pcb_track.h @@ -196,7 +196,7 @@ public: MINOPTMAX GetWidthConstraint( wxString* aSource ) const; - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; @@ -407,7 +407,7 @@ public: return wxT( "PCB_VIA" ); } - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index b8ed8c4479..8cbb9ed257 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -2077,8 +2077,7 @@ void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const const PCB_VIA* via = static_cast( aTrack ); BOARD* board = (BOARD*) via->GetParent(); - wxCHECK_RET( board != nullptr, wxT( "Via " ) + - via->GetSelectMenuText( EDA_UNITS::MILLIMETRES ) + wxT( " has no parent." ) ); + wxCHECK_RET( board != nullptr, wxT( "Via has no parent." ) ); m_out->Print( aNestLevel, "(via" ); diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index f937093c6f..e5e18bae53 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -450,8 +450,9 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits, { wxCHECK( aBoard, false ); - BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings(); + BOARD_DESIGN_SETTINGS& bds = aBoard->GetDesignSettings(); std::shared_ptr engine = bds.m_DRCEngine; + UNITS_PROVIDER unitsProvider( pcbIUScale, aUnits ); if( !engine ) { @@ -533,7 +534,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( pcbIUScale, aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) ); } fprintf( fp, "\n** Found %d unconnected pads **\n", static_cast( unconnected.size() ) ); @@ -541,7 +542,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( pcbIUScale, aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) ); } fprintf( fp, "\n** Found %d Footprint errors **\n", static_cast( footprints.size() ) ); @@ -549,7 +550,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( pcbIUScale, aUnits, severity, itemMap ) ) ); + fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) ); } fprintf( fp, "\n** End of Report **\n" ); diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index c4b75ec0f4..923ff067e9 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -1093,9 +1093,10 @@ bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_ if( !poly->IsTriangulationUpToDate() ) { - KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ), - aZone->GetSelectMenuText( GetUnits() ) ), - KIDIALOG::KD_WARNING ); + UNITS_PROVIDER unitsProvider( pcbIUScale, GetUnits() ); + KIDIALOG dlg( nullptr, wxString::Format( _( "%s is malformed." ), + aZone->GetSelectMenuText( &unitsProvider ) ), + KIDIALOG::KD_WARNING ); dlg.ShowDetailedText( wxString::Format( _( "This zone cannot be handled by the router.\n" "Please verify it is not a self-intersecting " "polygon." ) ) ); diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 7b249d38a7..fd95346545 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -154,17 +154,17 @@ wxString BOARD_INSPECTION_TOOL::getItemDescription( BOARD_ITEM* aItem ) if( !aItem ) return wxString(); - wxString s = aItem->GetSelectMenuText( m_frame->GetUserUnits() ); + wxString msg = aItem->GetSelectMenuText( m_frame ); if( aItem->IsConnected() && !isNPTHPad( aItem ) ) { BOARD_CONNECTED_ITEM* cItem = static_cast( aItem ); - s += wxS( " " ) + wxString::Format( _( "[netclass %s]" ), - cItem->GetEffectiveNetClass()->GetName() ); + msg += wxS( " " ) + wxString::Format( _( "[netclass %msg]" ), + cItem->GetEffectiveNetClass()->GetName() ); } - return s; + return msg; }; diff --git a/pcbnew/tools/pcb_control.cpp b/pcbnew/tools/pcb_control.cpp index ae27f3be40..31cf6afbaa 100644 --- a/pcbnew/tools/pcb_control.cpp +++ b/pcbnew/tools/pcb_control.cpp @@ -1343,8 +1343,8 @@ int PCB_CONTROL::UpdateMessagePanel( const TOOL_EVENT& aEvent ) BOARD_ITEM* a = static_cast( selection[0] ); BOARD_ITEM* b = static_cast( selection[1] ); - msgItems.emplace_back( MSG_PANEL_ITEM( a->GetSelectMenuText( m_frame->GetUserUnits() ), - b->GetSelectMenuText( m_frame->GetUserUnits() ) ) ); + msgItems.emplace_back( MSG_PANEL_ITEM( a->GetSelectMenuText( m_frame ), + b->GetSelectMenuText( m_frame ) ) ); BOARD_CONNECTED_ITEM* a_conn = dyn_cast( a ); BOARD_CONNECTED_ITEM* b_conn = dyn_cast( b ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 38a367b33d..7393ed2080 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -724,7 +724,7 @@ bool ZONE::AppendCorner( VECTOR2I aPosition, int aHoleIdx, bool aAllowDuplicatio } -wxString ZONE::GetSelectMenuText( EDA_UNITS aUnits ) const +wxString ZONE::GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const { wxString layerDesc; int count = 0; diff --git a/pcbnew/zone.h b/pcbnew/zone.h index 4183557bd3..67bbb6b1ac 100644 --- a/pcbnew/zone.h +++ b/pcbnew/zone.h @@ -668,7 +668,7 @@ public: void AddPolygon( const SHAPE_LINE_CHAIN& aPolygon ); - wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; + wxString GetSelectMenuText( UNITS_PROVIDER* aUnitsProvider ) const override; BITMAPS GetMenuImage() const override; diff --git a/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp b/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp index ca7c9213fc..e2f23a35fe 100644 --- a/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp +++ b/qa/unittests/pcbnew/drc/test_custom_rule_severities.cpp @@ -83,12 +83,13 @@ BOOST_FIXTURE_TEST_CASE( DRCCustomRuleSeverityTest, DRC_REGRESSION_TEST_FIXTURE { BOOST_CHECK_EQUAL( violations.size(), 8 ); + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) - BOOST_TEST_MESSAGE( - item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, 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 88f46815c3..542d0b0d2b 100644 --- a/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp +++ b/qa/unittests/pcbnew/drc/test_drc_copper_conn.cpp @@ -93,13 +93,14 @@ BOOST_FIXTURE_TEST_CASE( DRCCopperConn, DRC_REGRESSION_TEST_FIXTURE ) } else { + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, 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 0ef6c122da..279f811001 100644 --- a/qa/unittests/pcbnew/drc/test_drc_regressions.cpp +++ b/qa/unittests/pcbnew/drc/test_drc_regressions.cpp @@ -96,13 +96,14 @@ BOOST_FIXTURE_TEST_CASE( DRCFalsePositiveRegressions, DRC_REGRESSION_TEST_FIXTUR } else { + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, itemMap ) ); } @@ -167,13 +168,14 @@ BOOST_FIXTURE_TEST_CASE( DRCFalseNegativeRegressions, DRC_REGRESSION_TEST_FIXTUR { BOOST_CHECK_EQUAL( violations.size(), entry.second ); + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, 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 b0259672e7..b6e653fb1f 100644 --- a/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp +++ b/qa/unittests/pcbnew/drc/test_solder_mask_bridging.cpp @@ -78,11 +78,13 @@ BOOST_FIXTURE_TEST_CASE( DRCSolderMaskBridgingTest, DRC_REGRESSION_TEST_FIXTURE { BOOST_CHECK_EQUAL( violations.size(), expected_err_cnt ); + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, RPT_SEVERITY_ERROR, itemMap ) ); + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, 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 01e4f3a91d..d656946caf 100644 --- a/qa/unittests/pcbnew/test_tracks_cleaner.cpp +++ b/qa/unittests/pcbnew/test_tracks_cleaner.cpp @@ -112,13 +112,14 @@ BOOST_FIXTURE_TEST_CASE( FailedToCleanRegressionTests, TRACK_CLEANER_TEST_FIXTUR BOOST_CHECK_EQUAL( dryRunItems.size(), entry.m_Expected ); BOOST_CHECK_EQUAL( realRunItems.size(), entry.m_Expected ); + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const std::shared_ptr& item : realRunItems ) { - BOOST_TEST_MESSAGE( item->ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item->ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, itemMap ) ); } @@ -195,13 +196,14 @@ BOOST_FIXTURE_TEST_CASE( TrackCleanerRegressionTests, TRACK_CLEANER_TEST_FIXTURE } else { + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, itemMap ) ); } diff --git a/qa/unittests/pcbnew/test_zone_filler.cpp b/qa/unittests/pcbnew/test_zone_filler.cpp index 067fd2e008..7842481af1 100644 --- a/qa/unittests/pcbnew/test_zone_filler.cpp +++ b/qa/unittests/pcbnew/test_zone_filler.cpp @@ -217,13 +217,14 @@ BOOST_FIXTURE_TEST_CASE( RegressionZoneFillTests, ZONE_FILL_TEST_FIXTURE ) } else { + UNITS_PROVIDER unitsProvider( pcbIUScale, EDA_UNITS::INCHES ); + std::map itemMap; m_board->FillItemMap( itemMap ); for( const DRC_ITEM& item : violations ) { - BOOST_TEST_MESSAGE( item.ShowReport( pcbIUScale, EDA_UNITS::INCHES, - RPT_SEVERITY_ERROR, + BOOST_TEST_MESSAGE( item.ShowReport( &unitsProvider, RPT_SEVERITY_ERROR, itemMap ) ); } diff --git a/scripting/kipython_frame.cpp b/scripting/kipython_frame.cpp index 379c4bfcb2..96c1d3e59b 100644 --- a/scripting/kipython_frame.cpp +++ b/scripting/kipython_frame.cpp @@ -87,7 +87,8 @@ output.SetParent( parent ) KIPYTHON_FRAME::KIPYTHON_FRAME( KIWAY* aKiway, wxWindow* aParent ) : KIWAY_PLAYER( aKiway, aParent, FRAME_PYTHON, wxT( "KiPython" ), wxDefaultPosition, - wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KiPython" ) ) + wxDefaultSize, KICAD_DEFAULT_DRAWFRAME_STYLE, wxT( "KiPython" ), + unityScale ) { CallAfter( [&](){ SetupPythonEditor(); } );