From eacaa39aa21c2f347e05bf52c61e2c7d5053ef4c Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 10 Apr 2018 11:52:12 +0100 Subject: [PATCH] Remove global units usage from GetSelectionText... ... and GetMsgPanelInfo. Step 4 in the g_UserUnit eradication effort. Also removes a couple of conversion routines that were close enough to extinction. (cherry picked from commit c75da51) --- common/base_struct.cpp | 2 +- common/base_units.cpp | 26 ----- common/draw_frame.cpp | 2 +- cvpcb/display_footprints_frame.cpp | 2 +- eeschema/controle.cpp | 6 +- eeschema/drc_erc_item.cpp | 62 ++++++------ eeschema/edit_component_in_schematic.cpp | 2 +- eeschema/find.cpp | 14 ++- eeschema/getpart.cpp | 2 +- eeschema/lib_arc.cpp | 14 +-- eeschema/lib_arc.h | 4 +- eeschema/lib_bezier.cpp | 6 +- eeschema/lib_bezier.h | 2 +- eeschema/lib_circle.cpp | 16 +-- eeschema/lib_circle.h | 4 +- eeschema/lib_draw_item.cpp | 2 +- eeschema/lib_draw_item.h | 3 +- eeschema/lib_edit_frame.cpp | 4 +- eeschema/lib_field.cpp | 17 ++-- eeschema/lib_field.h | 4 +- eeschema/lib_pin.cpp | 45 ++++----- eeschema/lib_pin.h | 9 +- eeschema/lib_polyline.cpp | 12 +-- eeschema/lib_polyline.h | 4 +- eeschema/lib_rectangle.cpp | 16 +-- eeschema/lib_rectangle.h | 4 +- eeschema/lib_text.cpp | 12 +-- eeschema/lib_text.h | 4 +- eeschema/libedit_onleftclick.cpp | 2 +- eeschema/libedit_onrightclick.cpp | 2 +- eeschema/pinedit.cpp | 6 +- eeschema/sch_bitmap.h | 5 +- eeschema/sch_bus_entry.cpp | 4 +- eeschema/sch_bus_entry.h | 4 +- eeschema/sch_collectors.cpp | 32 +++--- eeschema/sch_collectors.h | 2 +- eeschema/sch_component.cpp | 14 ++- eeschema/sch_component.h | 4 +- eeschema/sch_field.cpp | 9 +- eeschema/sch_field.h | 2 +- eeschema/sch_junction.h | 5 +- eeschema/sch_line.cpp | 31 +++--- eeschema/sch_line.h | 2 +- eeschema/sch_marker.cpp | 4 +- eeschema/sch_marker.h | 7 +- eeschema/sch_no_connect.h | 5 +- eeschema/sch_sheet.cpp | 10 +- eeschema/sch_sheet.h | 6 +- eeschema/sch_sheet_pin.cpp | 8 +- eeschema/sch_text.cpp | 30 ++---- eeschema/sch_text.h | 10 +- eeschema/symbdraw.cpp | 2 +- gerbview/gerber_draw_item.cpp | 18 ++-- gerbview/gerber_draw_item.h | 4 +- gerbview/gerbview_draw_panel_gal.cpp | 3 +- gerbview/gerbview_draw_panel_gal.h | 2 +- gerbview/gerbview_frame.cpp | 2 +- gerbview/locate.cpp | 2 +- gerbview/tools/selection_tool.cpp | 2 +- include/base_struct.h | 19 +--- include/base_units.h | 38 ------- include/class_draw_panel_gal.h | 3 +- include/common.h | 15 ++- include/drc_item.h | 14 ++- include/widgets/unit_binder.h | 1 + pcbnew/attribut.cpp | 2 +- pcbnew/class_board.cpp | 13 ++- pcbnew/class_board.h | 2 +- pcbnew/class_dimension.cpp | 17 +--- pcbnew/class_dimension.h | 4 +- pcbnew/class_drawsegment.cpp | 36 ++++--- pcbnew/class_drawsegment.h | 8 +- pcbnew/class_edge_mod.cpp | 20 ++-- pcbnew/class_edge_mod.h | 4 +- pcbnew/class_marker_pcb.cpp | 23 +++-- pcbnew/class_marker_pcb.h | 4 +- pcbnew/class_module.cpp | 12 +-- pcbnew/class_module.h | 4 +- pcbnew/class_pad.cpp | 69 ++++++------- pcbnew/class_pad.h | 4 +- pcbnew/class_pcb_target.cpp | 11 +- pcbnew/class_pcb_target.h | 2 +- pcbnew/class_pcb_text.cpp | 18 ++-- pcbnew/class_pcb_text.h | 4 +- pcbnew/class_text_mod.cpp | 35 +++---- pcbnew/class_text_mod.h | 4 +- pcbnew/class_track.cpp | 122 ++++++++++------------- pcbnew/class_track.h | 22 ++-- pcbnew/class_zone.cpp | 11 +- pcbnew/class_zone.h | 4 +- pcbnew/controle.cpp | 2 +- pcbnew/dialogs/dialog_netlist.cpp | 8 +- pcbnew/dialogs/dialog_pad_properties.cpp | 20 ++-- pcbnew/drc_item.cpp | 66 ++++++------ pcbnew/footprint_edit_frame.cpp | 2 +- pcbnew/footprint_editor_utils.cpp | 2 +- pcbnew/footprint_viewer_frame.cpp | 2 +- pcbnew/kicad_plugin.cpp | 2 +- pcbnew/netinfo.h | 2 +- pcbnew/netinfo_item.cpp | 8 +- pcbnew/onleftclick.cpp | 2 +- pcbnew/onrightclick.cpp | 8 +- pcbnew/pcb_base_frame.cpp | 6 +- pcbnew/pcb_draw_panel_gal.cpp | 2 +- pcbnew/pcb_draw_panel_gal.h | 3 +- pcbnew/router/pns_kicad_iface.cpp | 3 +- pcbnew/tools/pcb_editor_control.cpp | 2 +- pcbnew/tools/selection_tool.cpp | 2 +- 108 files changed, 539 insertions(+), 687 deletions(-) diff --git a/common/base_struct.cpp b/common/base_struct.cpp index ca8876a96e..ffa0e44a24 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -171,7 +171,7 @@ SEARCH_RESULT EDA_ITEM::Visit( INSPECTOR inspector, void* testData, const KICAD_ } -wxString EDA_ITEM::GetSelectMenuText() const +wxString EDA_ITEM::GetSelectMenuText( EDA_UNITS_T aUnits ) const { wxFAIL_MSG( wxT( "GetSelectMenuText() was not overridden for schematic item type " ) + GetClass() ); diff --git a/common/base_units.cpp b/common/base_units.cpp index aab16fff1a..78a3f274e3 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -121,12 +121,6 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue, bool aUseMils ) * could truncate the actual value */ -// JEY TODO: retire this in favour of MessageTextFromValue().... -wxString CoordinateToString( int aValue, bool aUseMils ) -{ - return MessageTextFromValue( g_UserUnit, aValue, aUseMils ); -} - // A lower-precision (for readability) version of StringFromValue() wxString MessageTextFromValue( EDA_UNITS_T aUnits, int aValue, bool aUseMils ) @@ -390,16 +384,6 @@ int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMi } -// JEY TODO: remove -int ValueFromString( const wxString& aTextValue ) -{ - int value; - - value = ValueFromString( g_UserUnit, aTextValue); - - return value; -} - // JEY TODO: remove; use a UNIT_BINDER instead int ValueFromTextCtrl( const wxTextCtrl& aTextCtr ) { @@ -415,16 +399,6 @@ int ValueFromTextCtrl( const wxTextCtrl& aTextCtr ) return value; } - -wxString& operator <<( wxString& aString, const wxPoint& aPos ) -{ - aString << wxT( "@ (" ) << CoordinateToString( aPos.x ); - aString << wxT( "," ) << CoordinateToString( aPos.y ); - aString << wxT( ")" ); - - return aString; -} - /** * Function AngleToStringDegrees * is a helper to convert the \a double \a aAngle (in internal unit) diff --git a/common/draw_frame.cpp b/common/draw_frame.cpp index d401803cd2..29d308348d 100644 --- a/common/draw_frame.cpp +++ b/common/draw_frame.cpp @@ -862,7 +862,7 @@ void EDA_DRAW_FRAME::SetMsgPanel( EDA_ITEM* aItem ) wxCHECK_RET( aItem != NULL, wxT( "Invalid EDA_ITEM pointer. Bad programmer." ) ); MSG_PANEL_ITEMS items; - aItem->GetMsgPanelInfo( items ); + aItem->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/cvpcb/display_footprints_frame.cpp b/cvpcb/display_footprints_frame.cpp index e81ef62faf..beea4f36e4 100644 --- a/cvpcb/display_footprints_frame.cpp +++ b/cvpcb/display_footprints_frame.cpp @@ -537,7 +537,7 @@ void DISPLAY_FOOTPRINTS_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg ) if ( Module ) { MSG_PANEL_ITEMS items; - Module->GetMsgPanelInfo( items ); + Module->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/eeschema/controle.cpp b/eeschema/controle.cpp index 95bd3fa712..e62cd8daa3 100644 --- a/eeschema/controle.cpp +++ b/eeschema/controle.cpp @@ -118,7 +118,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC // Force display pin information (the previous display could be a component info) MSG_PANEL_ITEMS items; - Pin->GetMsgPanelInfo( items, component ); + Pin->GetMsgPanelInfo( m_UserUnits, items, component ); SetMsgPanel( items ); @@ -188,7 +188,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ ) { - wxString text = m_collectedItems[i]->GetSelectMenuText(); + wxString text = m_collectedItems[i]->GetSelectMenuText( m_UserUnits ); BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage(); AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) ); } @@ -214,7 +214,7 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateItem( const wxPoint& aPosition, const KICAD_T aF ( (SCH_COMPONENT*) item )->SetCurrentSheetPath( &GetCurrentSheet() ); MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } else diff --git a/eeschema/drc_erc_item.cpp b/eeschema/drc_erc_item.cpp index a97fa8a830..282ebfe417 100644 --- a/eeschema/drc_erc_item.cpp +++ b/eeschema/drc_erc_item.cpp @@ -69,17 +69,16 @@ wxString DRC_ITEM::GetErrorText() const } } -wxString DRC_ITEM::ShowCoord( const wxPoint& aPos ) +wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos ) { return wxString::Format( _( "@(%s, %s)" ), - GetChars( CoordinateToString( aPos.x ) ), - GetChars( CoordinateToString( aPos.y ) ) ); + MessageTextFromValue( aUnits, aPos.x ), + MessageTextFromValue( aUnits, aPos.y ) ); } wxString DRC_ITEM::ShowHtml() const { - wxString ret; wxString mainText = m_MainText; // a wxHtmlWindows does not like < and > in the text to display // because these chars have a special meaning in html @@ -95,9 +94,7 @@ wxString DRC_ITEM::ShowHtml() const if( m_noCoordinate ) { // omit the coordinate, a NETCLASS has no location - ret.Printf( _( "

%s
   %s" ), - GetChars( errText ), - GetChars( mainText ) ); + return wxString::Format( _( "

%s
   %s" ), errText, mainText ); } else if( m_hasSecondItem ) { @@ -107,48 +104,45 @@ wxString DRC_ITEM::ShowHtml() const // an html fragment for the entire message in the listbox. feel free // to add color if you want: - ret.Printf( _( "

%s
   %s: %s
   %s: %s" ), - GetChars( errText ), - hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), - GetChars( ShowCoord( m_MainPosition )), - GetChars( mainText ), - GetChars( ShowCoord( m_AuxiliaryPosition )), - GetChars( auxText ) ); + return wxString::Format( _( "

%s
   %s: %s
   %s: %s" ), + errText, + hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), + ShowCoord( g_UserUnit, m_MainPosition ), + mainText, + ShowCoord( g_UserUnit, m_AuxiliaryPosition ), + auxText ); } else { - ret.Printf( _( "

%s
   %s: %s" ), - GetChars( errText ), - hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), - GetChars( ShowCoord( m_MainPosition ) ), - GetChars( mainText ) ); + return wxString::Format( _( "

%s
   %s: %s" ), + errText, + hrefColour.GetAsString( wxC2S_HTML_SYNTAX ), + ShowCoord( g_UserUnit, m_MainPosition ), + mainText ); } - - return ret; } wxString DRC_ITEM::ShowReport() const { - wxString ret; - if( m_hasSecondItem ) { - ret.Printf( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), - m_ErrorCode, - GetChars( GetErrorText() ), - GetChars( ShowCoord( m_MainPosition ) ), GetChars( m_MainText ), - GetChars( ShowCoord( m_AuxiliaryPosition ) ), GetChars( m_AuxiliaryText ) ); + return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), + m_ErrorCode, + GetErrorText(), + ShowCoord( g_UserUnit, m_MainPosition ), + m_MainText, + ShowCoord( g_UserUnit, m_AuxiliaryPosition ), + m_AuxiliaryText ); } else { - ret.Printf( wxT( "ErrType(%d): %s\n %s: %s\n" ), - m_ErrorCode, - GetChars( GetErrorText() ), - GetChars( ShowCoord( m_MainPosition ) ), GetChars( m_MainText ) ); + return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ), + m_ErrorCode, + GetErrorText(), + ShowCoord( g_UserUnit, m_MainPosition ), + m_MainText ); } - - return ret; } diff --git a/eeschema/edit_component_in_schematic.cpp b/eeschema/edit_component_in_schematic.cpp index 0ea4585fad..385afe745c 100644 --- a/eeschema/edit_component_in_schematic.cpp +++ b/eeschema/edit_component_in_schematic.cpp @@ -87,7 +87,7 @@ void SCH_EDIT_FRAME::EditComponentFieldText( SCH_FIELD* aField ) MSG_PANEL_ITEMS items; component->SetCurrentSheetPath( &GetCurrentSheet() ); - component->GetMsgPanelInfo( items ); + component->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/eeschema/find.cpp b/eeschema/find.cpp index 3c97b31b19..65569b2c20 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -92,12 +92,10 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) RedrawScreen( lastMarker->GetPosition(), warpCursor ); - wxString path = sheetFoundIn->Path(); - wxString units = GetAbbreviatedUnitsLabel(); - double x = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().x ); - double y = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().y ); - msg.Printf( _( "Design rule check marker found in sheet %s at %0.3f%s, %0.3f%s" ), - GetChars( path ), x, GetChars( units ), y, GetChars( units) ); + msg.Printf( _( "Design rule check marker found in sheet %s at %s, %s" ), + sheetFoundIn->Path(), + MessageTextFromValue( m_UserUnits, lastMarker->GetPosition().x ), + MessageTextFromValue( m_UserUnits, lastMarker->GetPosition().y ) ); SetStatusText( msg ); } else @@ -449,7 +447,7 @@ void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent ) if( m_foundItems.GetItem( data ) != NULL ) { - wxLogTrace( traceFindReplace, wxT( "Found " ) + m_foundItems.GetText() ); + wxLogTrace( traceFindReplace, wxT( "Found " ) + m_foundItems.GetText( MILLIMETRES ) ); SCH_SHEET_PATH* sheet = schematic.GetSheetByPath( data.GetSheetPath() ); @@ -483,7 +481,7 @@ void SCH_EDIT_FRAME::updateFindReplaceView( wxFindDialogEvent& aEvent ) RedrawScreen( data.GetPosition(), warpCursor ); - msg = m_foundItems.GetText(); + msg = m_foundItems.GetText( m_UserUnits ); if( aEvent.GetFlags() & FR_SEARCH_REPLACE ) aEvent.SetFlags( aEvent.GetFlags() | FR_REPLACE_ITEM_FOUND ); diff --git a/eeschema/getpart.cpp b/eeschema/getpart.cpp index 49e803dd8a..9f539be385 100644 --- a/eeschema/getpart.cpp +++ b/eeschema/getpart.cpp @@ -283,7 +283,7 @@ SCH_COMPONENT* SCH_EDIT_FRAME::Load_Component( wxDC* aD MSG_PANEL_ITEMS items; component->SetCurrentSheetPath( &GetCurrentSheet() ); - component->GetMsgPanelInfo( items ); + component->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); component->Draw( m_canvas, aDC, wxPoint( 0, 0 ), g_XorMode ); diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index c55b7cc6f2..a63c0bf658 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -478,14 +478,14 @@ start(%d, %d), end(%d, %d), radius %d" ), } -void LIB_ARC::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void LIB_ARC::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; EDA_RECT bBox = GetBoundingBox(); - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, m_Width, true ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); @@ -496,12 +496,12 @@ void LIB_ARC::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) } -wxString LIB_ARC::GetSelectMenuText() const +wxString LIB_ARC::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString::Format( _( "Arc center (%s, %s), radius %s" ), - GetChars( CoordinateToString( m_Pos.x ) ), - GetChars( CoordinateToString( m_Pos.y ) ), - GetChars( CoordinateToString( m_Radius ) ) ); + MessageTextFromValue( aUnits, m_Pos.x ), + MessageTextFromValue( aUnits, m_Pos.y ), + MessageTextFromValue( aUnits, m_Radius ) ); } diff --git a/eeschema/lib_arc.h b/eeschema/lib_arc.h index 886d464d15..dce73b89cc 100644 --- a/eeschema/lib_arc.h +++ b/eeschema/lib_arc.h @@ -102,7 +102,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; int GetPenSize() const override; @@ -159,7 +159,7 @@ public: void CalcRadiusAngles(); - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index c727e2f45a..cd948186cc 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -319,14 +319,14 @@ const EDA_RECT LIB_BEZIER::GetBoundingBox() const } -void LIB_BEZIER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void LIB_BEZIER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; EDA_RECT bBox = GetBoundingBox(); - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, m_Width, true ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); diff --git a/eeschema/lib_bezier.h b/eeschema/lib_bezier.h index 919a7f37f1..a1d5122224 100644 --- a/eeschema/lib_bezier.h +++ b/eeschema/lib_bezier.h @@ -104,7 +104,7 @@ public: int GetPenSize( ) const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; EDA_ITEM* Clone() const override; diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index d513360364..85ecb0cce2 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -229,18 +229,18 @@ const EDA_RECT LIB_CIRCLE::GetBoundingBox() const } -void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_CIRCLE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; EDA_RECT bBox = GetBoundingBox(); - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, m_Width, true ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); - msg = StringFromValue( g_UserUnit, m_Radius, true ); + msg = MessageTextFromValue( aUnits, m_Radius, true ); aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, @@ -250,12 +250,12 @@ void LIB_CIRCLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) } -wxString LIB_CIRCLE::GetSelectMenuText() const +wxString LIB_CIRCLE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString::Format( _( "Circle center (%s, %s), radius %s" ), - GetChars( CoordinateToString( m_Pos.x ) ), - GetChars( CoordinateToString( m_Pos.y ) ), - GetChars( CoordinateToString( m_Radius ) ) ); + MessageTextFromValue( aUnits, m_Pos.x ), + MessageTextFromValue( aUnits, m_Pos.y ), + MessageTextFromValue( aUnits, m_Radius ) ); } diff --git a/eeschema/lib_circle.h b/eeschema/lib_circle.h index 1a2740285d..08c8cec5e8 100644 --- a/eeschema/lib_circle.h +++ b/eeschema/lib_circle.h @@ -69,7 +69,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override; @@ -102,7 +102,7 @@ public: int GetRadius() const { return m_Radius; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/lib_draw_item.cpp b/eeschema/lib_draw_item.cpp index 7acacd235a..74defe902f 100644 --- a/eeschema/lib_draw_item.cpp +++ b/eeschema/lib_draw_item.cpp @@ -56,7 +56,7 @@ LIB_ITEM::LIB_ITEM( KICAD_T aType, } -void LIB_ITEM::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; diff --git a/eeschema/lib_draw_item.h b/eeschema/lib_draw_item.h index af0d333088..8f83d1f422 100644 --- a/eeschema/lib_draw_item.h +++ b/eeschema/lib_draw_item.h @@ -248,7 +248,8 @@ public: *

* @param aList is the list to populate. */ - virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits, + std::vector< MSG_PANEL_ITEM >& aList ) override; /** * Test LIB_ITEM objects for equivalence. diff --git a/eeschema/lib_edit_frame.cpp b/eeschema/lib_edit_frame.cpp index dee0134669..41c9af3b8a 100644 --- a/eeschema/lib_edit_frame.cpp +++ b/eeschema/lib_edit_frame.cpp @@ -1401,7 +1401,7 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF for( int i = 0; i < m_collectedItems.GetCount() && i < MAX_SELECT_ITEM_IDS; i++ ) { - wxString text = m_collectedItems[i]->GetSelectMenuText(); + wxString text = m_collectedItems[i]->GetSelectMenuText( m_UserUnits ); BITMAP_DEF xpm = m_collectedItems[i]->GetMenuImage(); AddMenuItem( &selectMenu, ID_SELECT_ITEM_START + i, text, KiBitmap( xpm ) ); @@ -1419,7 +1419,7 @@ LIB_ITEM* LIB_EDIT_FRAME::locateItem( const wxPoint& aPosition, const KICAD_T aF if( item ) { MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } else diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 974411eb7e..5b1f62a0b1 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -532,11 +532,9 @@ void LIB_FIELD::SetText( const wxString& aText ) } -wxString LIB_FIELD::GetSelectMenuText() const +wxString LIB_FIELD::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - return wxString::Format( _( "Field %s \"%s\"" ), - GetChars( GetName() ), - GetChars( ShortenedShownText() ) ); + return wxString::Format( _( "Field %s \"%s\"" ), GetName(), ShortenedShownText() ); } @@ -606,25 +604,24 @@ void LIB_FIELD::calcEdit( const wxPoint& aPosition ) } -void LIB_FIELD::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_FIELD::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); // Display style: msg = GetTextStyleName(); aList.push_back( MSG_PANEL_ITEM( _( "Style" ), msg, MAGENTA ) ); - msg = StringFromValue( g_UserUnit, GetTextWidth(), true ); + msg = MessageTextFromValue( aUnits, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, BLUE ) ); - msg = StringFromValue( g_UserUnit, GetTextHeight(), true ); + msg = MessageTextFromValue( aUnits, GetTextHeight(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, BLUE ) ); // Display field name (ref, value ...) - msg = GetName(); - aList.push_back( MSG_PANEL_ITEM( _( "Field" ), msg, BROWN ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Field" ), GetName(), BROWN ) ); // Display field text: aList.push_back( MSG_PANEL_ITEM( _( "Value" ), GetShownText(), BROWN ) ); diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index f622729ed1..c00cd95073 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -165,7 +165,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; bool HitTest( const wxPoint& aPosition ) const override; @@ -231,7 +231,7 @@ public: void SetWidth( int aWidth ) override { SetThickness( aWidth ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index c530c98174..9a38e51514 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1698,19 +1698,17 @@ void LIB_PIN::SetWidth( int aWidth ) } -void LIB_PIN::getMsgPanelInfoBase( MSG_PANEL_ITEMS& aList ) +void LIB_PIN::getMsgPanelInfoBase( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString text = m_number.IsEmpty() ? wxT( "?" ) : m_number; - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); aList.push_back( MSG_PANEL_ITEM( _( "Name" ), m_name, DARKCYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Number" ), text, DARKCYAN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Type" ), - GetText( m_type ), - RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Type" ), GetText( m_type ), RED ) ); text = GetText( m_shape ); @@ -1724,33 +1722,33 @@ void LIB_PIN::getMsgPanelInfoBase( MSG_PANEL_ITEMS& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Visible" ), text, DARKGREEN ) ); // Display pin length - text = StringFromValue( g_UserUnit, m_length, true ); + text = StringFromValue( aUnits, m_length, true ); aList.push_back( MSG_PANEL_ITEM( _( "Length" ), text, MAGENTA ) ); text = getPinOrientationName( (unsigned) GetOrientationIndex( m_orientation ) ); aList.push_back( MSG_PANEL_ITEM( _( "Orientation" ), text, DARKMAGENTA ) ); } -void LIB_PIN::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { - getMsgPanelInfoBase( aList ); + getMsgPanelInfoBase( aUnits, aList ); wxString text; wxPoint pinpos = GetPosition(); pinpos.y = -pinpos.y; // Display coord are top to bottom // lib items coord are bottom to top - text = StringFromValue( g_UserUnit, pinpos.x, true ); + text = MessageTextFromValue( aUnits, pinpos.x, true ); aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) ); - text = StringFromValue( g_UserUnit, pinpos.y, true ); + text = MessageTextFromValue( aUnits, pinpos.y, true ); aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) ); } -void LIB_PIN::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList, +void LIB_PIN::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList, SCH_COMPONENT* aComponent ) { - getMsgPanelInfoBase( aList ); + getMsgPanelInfoBase( aUnits, aList ); if( !aComponent ) return; @@ -1759,10 +1757,10 @@ void LIB_PIN::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList, wxPoint pinpos = aComponent->GetTransform().TransformCoordinate( GetPosition() ) + aComponent->GetPosition(); - text = StringFromValue( g_UserUnit, pinpos.x, true ); + text = MessageTextFromValue( aUnits, pinpos.x, true ); aList.push_back( MSG_PANEL_ITEM( _( "Pos X" ), text, DARKMAGENTA ) ); - text = StringFromValue( g_UserUnit, pinpos.y, true ); + text = MessageTextFromValue( aUnits, pinpos.y, true ); aList.push_back( MSG_PANEL_ITEM( _( "Pos Y" ), text, DARKMAGENTA ) ); aList.push_back( MSG_PANEL_ITEM( aComponent->GetField( REFERENCE )->GetShownText(), @@ -1957,23 +1955,18 @@ BITMAP_DEF LIB_PIN::GetMenuImage() const } -wxString LIB_PIN::GetSelectMenuText() const +wxString LIB_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString tmp; - wxString style; - - style = GetText( m_shape ); - - tmp.Printf( _( "Pin %s, %s, %s" ), - GetChars( m_number ), GetChars( GetElectricalTypeName() ), GetChars( style )); - - return tmp; + return wxString::Format( _( "Pin %s, %s, %s" ), + m_number, + GetElectricalTypeName(), + GetText( m_shape )); } bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) ); // Note: this will have to be modified if we add find and replace capability to the // compoment library editor. Otherwise, you wont be able to replace pin text. @@ -1981,7 +1974,7 @@ bool LIB_PIN::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* || ( aSearchData.GetFlags() & FR_SEARCH_REPLACE ) ) return false; - wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText( MILLIMETRES ) ); if( EDA_ITEM::Matches( GetName(), aSearchData ) || EDA_ITEM::Matches( m_number, aSearchData ) ) { diff --git a/eeschema/lib_pin.h b/eeschema/lib_pin.h index 870e2fa0f2..6fe9f79a20 100644 --- a/eeschema/lib_pin.h +++ b/eeschema/lib_pin.h @@ -128,7 +128,7 @@ public: bool HitTest( const wxPoint &aPosRef, int aThreshold, const TRANSFORM& aTransform ) const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** * Display pin info (given by GetMsgPanelInfo) and add some info related to aComponent @@ -136,7 +136,8 @@ public: * @param aList is the message list to fill * @param aComponent is the component which "owns" the pin */ - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList, SCH_COMPONENT* aComponent ); + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList, + SCH_COMPONENT* aComponent ); bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; @@ -484,7 +485,7 @@ public: BITMAP_DEF GetMenuImage() const override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; EDA_ITEM* Clone() const override; @@ -494,7 +495,7 @@ private: * they are pin info without the actual pin position, which * is not known in schematic without knowing the parent component */ - void getMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ); + void getMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ); /** diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 9113d1f928..3e31b2014c 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -312,14 +312,14 @@ void LIB_POLYLINE::DeleteSegment( const wxPoint aPosition ) } -void LIB_POLYLINE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_POLYLINE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; EDA_RECT bBox = GetBoundingBox(); - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, m_Width, true ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); @@ -330,11 +330,11 @@ void LIB_POLYLINE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) } -wxString LIB_POLYLINE::GetSelectMenuText() const +wxString LIB_POLYLINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString::Format( _( "Polyline at (%s, %s) with %d points" ), - GetChars( CoordinateToString( m_PolyPoints[0].x ) ), - GetChars( CoordinateToString( m_PolyPoints[0].y ) ), + MessageTextFromValue( aUnits, m_PolyPoints[0].x ), + MessageTextFromValue( aUnits, m_PolyPoints[0].y ), int( m_PolyPoints.size() ) ); } diff --git a/eeschema/lib_polyline.h b/eeschema/lib_polyline.h index 2a6bba10be..6426ae81a9 100644 --- a/eeschema/lib_polyline.h +++ b/eeschema/lib_polyline.h @@ -84,7 +84,7 @@ public: int GetPenSize( ) const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override; @@ -113,7 +113,7 @@ public: void SetWidth( int aWidth ) override { m_Width = aWidth; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index 187c2d5e6e..83d53be62f 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -209,13 +209,13 @@ void LIB_RECTANGLE::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, } -void LIB_RECTANGLE::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_RECTANGLE::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, m_Width, true ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } @@ -291,13 +291,13 @@ bool LIB_RECTANGLE::HitTest( const wxPoint &aPosition, int aThreshold, const TRA } -wxString LIB_RECTANGLE::GetSelectMenuText() const +wxString LIB_RECTANGLE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString::Format( _( "Rectangle from (%s, %s) to (%s, %s)" ), - GetChars( CoordinateToString( m_Pos.x ) ), - GetChars( CoordinateToString( m_Pos.y ) ), - GetChars( CoordinateToString( m_End.x ) ), - GetChars( CoordinateToString( m_End.y ) ) ); + MessageTextFromValue( aUnits, m_Pos.x ), + MessageTextFromValue( aUnits, m_Pos.y ), + MessageTextFromValue( aUnits, m_End.x ), + MessageTextFromValue( aUnits, m_End.y ) ); } diff --git a/eeschema/lib_rectangle.h b/eeschema/lib_rectangle.h index 5c85b7931b..e4d29d757b 100644 --- a/eeschema/lib_rectangle.h +++ b/eeschema/lib_rectangle.h @@ -74,7 +74,7 @@ public: const EDA_RECT GetBoundingBox() const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; void BeginEdit( STATUS_FLAGS aEditMode, const wxPoint aStartPoint = wxPoint( 0, 0 ) ) override; @@ -107,7 +107,7 @@ public: wxPoint GetEnd() const { return m_End; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 9440a93eed..00e1f72b35 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -290,13 +290,13 @@ void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aO } -void LIB_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void LIB_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; - LIB_ITEM::GetMsgPanelInfo( aList ); + LIB_ITEM::GetMsgPanelInfo( aUnits, aList ); - msg = StringFromValue( g_UserUnit, GetThickness(), true ); + msg = MessageTextFromValue( aUnits, GetThickness(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Line Width" ), msg, BLUE ) ); } @@ -357,11 +357,9 @@ void LIB_TEXT::SetText( const wxString& aText ) } -wxString LIB_TEXT::GetSelectMenuText() const +wxString LIB_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString msg; - msg.Printf( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) ); - return msg; + return wxString::Format( _( "Graphic Text \"%s\"" ), ShortenedShownText() ); } diff --git a/eeschema/lib_text.h b/eeschema/lib_text.h index bad432168d..98e19abe25 100644 --- a/eeschema/lib_text.h +++ b/eeschema/lib_text.h @@ -94,7 +94,7 @@ public: int GetPenSize( ) const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; const EDA_RECT GetBoundingBox() const override; @@ -127,7 +127,7 @@ public: void SetWidth( int aWidth ) override { SetThickness( aWidth ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/libedit_onleftclick.cpp b/eeschema/libedit_onleftclick.cpp index 14520f620a..6e153c2e48 100644 --- a/eeschema/libedit_onleftclick.cpp +++ b/eeschema/libedit_onleftclick.cpp @@ -56,7 +56,7 @@ void LIB_EDIT_FRAME::OnLeftClick( wxDC* DC, const wxPoint& aPosition ) if( item ) { MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/eeschema/libedit_onrightclick.cpp b/eeschema/libedit_onrightclick.cpp index fd94f07aa3..9056b4d43d 100644 --- a/eeschema/libedit_onrightclick.cpp +++ b/eeschema/libedit_onrightclick.cpp @@ -95,7 +95,7 @@ bool LIB_EDIT_FRAME::OnRightClick( const wxPoint& aPosition, wxMenu* PopMenu ) if( item ) { MSG_PANEL_ITEMS items; - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } else diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 2be5c2bea1..c79eeeeda3 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -193,7 +193,7 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) OnModify( ); MSG_PANEL_ITEMS items; - pin->GetMsgPanelInfo( items ); + pin->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); m_canvas->Refresh(); } @@ -365,7 +365,7 @@ void LIB_EDIT_FRAME::StartMovePin( LIB_ITEM* aItem ) MSG_PANEL_ITEMS items; - cur_pin->GetMsgPanelInfo( items ); + cur_pin->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); m_canvas->SetMouseCapture( DrawMovePin, AbortPinMove ); @@ -654,7 +654,7 @@ void LIB_EDIT_FRAME::RepeatPinItem( wxDC* DC, LIB_PIN* SourcePin ) m_canvas->CrossHairOn( DC ); MSG_PANEL_ITEMS items; - pin->GetMsgPanelInfo( items ); + pin->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); OnModify( ); } diff --git a/eeschema/sch_bitmap.h b/eeschema/sch_bitmap.h index ed0bfb503c..b318b8be45 100644 --- a/eeschema/sch_bitmap.h +++ b/eeschema/sch_bitmap.h @@ -126,7 +126,10 @@ public: bool IsSelectStateChanged( const wxRect& aRect ) override; - wxString GetSelectMenuText() const override { return wxString( _( "Image" ) ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return wxString( _( "Image" ) ); + } BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 68a64792e4..fa6a362fc6 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -332,13 +332,13 @@ void SCH_BUS_ENTRY_BASE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) } -wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText() const +wxString SCH_BUS_WIRE_ENTRY::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString( _( "Bus to Wire Entry" ) ); } -wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText() const +wxString SCH_BUS_BUS_ENTRY::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString( _( "Bus to Bus Entry" ) ); } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 8c958828cd..69ed4711a0 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -148,7 +148,7 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; EDA_ITEM* Clone() const override; @@ -181,7 +181,7 @@ public: return aItem->Type() == SCH_LINE_T && aItem->GetLayer() == LAYER_BUS; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; EDA_ITEM* Clone() const override; diff --git a/eeschema/sch_collectors.cpp b/eeschema/sch_collectors.cpp index a1db6b8f0a..b6dfc2cdc1 100644 --- a/eeschema/sch_collectors.cpp +++ b/eeschema/sch_collectors.cpp @@ -345,8 +345,14 @@ public: SCH_ITEM( nullptr, NOT_USED ) {} - wxString GetSelectMenuText() const override { return _( "(Deleted Item)" ); } - wxString GetClass() const override { return wxT( "DELETED_SCH_ITEM" ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return _( "(Deleted Item)" ); + } + wxString GetClass() const override + { + return wxT( "DELETED_SCH_ITEM" ); + } // define pure virtuals: wxPoint GetPosition() const override { return wxPoint(); } @@ -444,7 +450,7 @@ void SCH_FIND_COLLECTOR::dump() GetChars( m_findReplaceData.GetReplaceString() ) ); for( m_foundIndex = 0; m_foundIndex < GetCount(); m_foundIndex++ ) - wxLogTrace( traceFindReplace, wxT( " " ) + GetText() ); + wxLogTrace( traceFindReplace, wxT( " " ) + GetText( MILLIMETRES ) ); m_foundIndex = tmp; } @@ -482,7 +488,7 @@ SCH_FIND_COLLECTOR_DATA SCH_FIND_COLLECTOR::GetFindData( int aIndex ) } -wxString SCH_FIND_COLLECTOR::GetText() +wxString SCH_FIND_COLLECTOR::GetText( EDA_UNITS_T aUnits ) { wxCHECK_MSG( (GetCount() != 0) && IsValidIndex( m_foundIndex ), wxEmptyString, wxT( "Cannot get found item at invalid index." ) ); @@ -490,23 +496,19 @@ wxString SCH_FIND_COLLECTOR::GetText() SCH_FIND_COLLECTOR_DATA data = m_data[ m_foundIndex ]; EDA_ITEM* foundItem = GetItem( m_foundIndex ); - wxString msg; - if( data.GetParent() ) { - msg.Printf( _( "Child item %s of parent item %s found in sheet %s" ), - GetChars( foundItem->GetSelectMenuText() ), - GetChars( data.GetParent()->GetSelectMenuText() ), - GetChars( data.GetSheetPath() ) ); + return wxString::Format( _( "Child item %s of parent item %s found in sheet %s" ), + foundItem->GetSelectMenuText( aUnits ), + data.GetParent()->GetSelectMenuText( aUnits ), + data.GetSheetPath() ); } else { - msg.Printf( _( "Item %s found in sheet %s" ), - GetChars( foundItem->GetSelectMenuText() ), - GetChars( data.GetSheetPath() ) ); + return wxString::Format( _( "Item %s found in sheet %s" ), + foundItem->GetSelectMenuText( aUnits ), + data.GetSheetPath() ); } - - return msg; } diff --git a/eeschema/sch_collectors.h b/eeschema/sch_collectors.h index 48bca22ec6..df4accddb0 100644 --- a/eeschema/sch_collectors.h +++ b/eeschema/sch_collectors.h @@ -344,7 +344,7 @@ public: * current index or a wxEmptyString if the list is empty or the index is * invalid. */ - wxString GetText(); + wxString GetText( EDA_UNITS_T aUnits ); /** * Function GetItem diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 018d34545e..e326faa7ee 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1373,7 +1373,7 @@ const EDA_RECT SCH_COMPONENT::GetBoundingBox() const } -void SCH_COMPONENT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void SCH_COMPONENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; @@ -1520,7 +1520,7 @@ void SCH_COMPONENT::Rotate( wxPoint aPosition ) bool SCH_COMPONENT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) ); // Components are searchable via the child field and pin item text. return false; @@ -1682,13 +1682,11 @@ LIB_ITEM* SCH_COMPONENT::GetDrawItem( const wxPoint& aPosition, KICAD_T aType ) } -wxString SCH_COMPONENT::GetSelectMenuText() const +wxString SCH_COMPONENT::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString tmp; - tmp.Printf( _( "Symbol %s, %s" ), - GetChars( GetLibId().GetLibItemName() ), - GetChars( GetField( REFERENCE )->GetShownText() ) ); - return tmp; + return wxString::Format( _( "Symbol %s, %s" ), + GetLibId().GetLibItemName().wx_str(), + GetField( REFERENCE )->GetShownText() ); } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index cafba15e1c..bd72868e89 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -285,7 +285,7 @@ public: */ wxPoint GetScreenCoord( const wxPoint& aPoint ); - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** * Clear exiting component annotation. @@ -594,7 +594,7 @@ public: */ LIB_ITEM* GetDrawItem( const wxPoint& aPosition, KICAD_T aType = TYPE_NOT_INIT ); - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 4db543e60a..c63810632c 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -338,7 +338,7 @@ bool SCH_FIELD::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint || ((m_id == REFERENCE) && !(aSearchData.GetFlags() & FR_REPLACE_REFERENCES)) ) return false; - wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText( MILLIMETRES ) ); // Take sheet path into account which effects the reference field and the unit for // components with multiple parts. @@ -426,12 +426,9 @@ void SCH_FIELD::Rotate( wxPoint aPosition ) } -wxString SCH_FIELD::GetSelectMenuText() const +wxString SCH_FIELD::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString tmp; - tmp.Printf( _( "Field %s" ), GetChars( GetName() ) ); - - return tmp; + return wxString::Format( _( "Field %s" ), GetName() ); } diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index 9d8285bb27..dcccc910e6 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -178,7 +178,7 @@ public: bool Replace( wxFindReplaceData& aSearchData, void* aAuxData = NULL ) override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 72b67c47d0..4fcc9ffd58 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -85,7 +85,10 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText() const override { return wxString( _( "Junction" ) ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return wxString( _( "Junction" ) ); + } BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 05fb9df3a5..8469c28494 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -607,40 +607,39 @@ void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const } -wxString SCH_LINE::GetSelectMenuText() const +wxString SCH_LINE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString menuText, txtfmt, orient; + wxString txtfmt, orient; if( m_start.x == m_end.x ) - orient = _( "Vert." ); + orient = _( "Vertical " ); else if( m_start.y == m_end.y ) - orient = _( "Horiz." ); + orient = _( "Horizontal " ); switch( m_Layer ) { case LAYER_NOTES: - txtfmt = _( "%s Graphic Line from (%s, %s) to (%s, %s)" ); + txtfmt = _( "%sGraphic Line from (%s, %s) to (%s, %s)" ); break; case LAYER_WIRE: - txtfmt = _( "%s Wire from (%s, %s) to (%s, %s)" ); + txtfmt = _( "%sWire from (%s, %s) to (%s, %s)" ); break; case LAYER_BUS: - txtfmt = _( "%s Bus from (%s, %s) to (%s, %s)" ); + txtfmt = _( "%sBus from (%s, %s) to (%s, %s)" ); break; default: - txtfmt += _( "%s Line on Unknown Layer from (%s, %s) to (%s, %s)" ); + txtfmt = _( "%sLine on Unknown Layer from (%s, %s) to (%s, %s)" ); } - menuText.Printf( txtfmt, GetChars( orient ), - GetChars( CoordinateToString( m_start.x ) ), - GetChars( CoordinateToString( m_start.y ) ), - GetChars( CoordinateToString( m_end.x ) ), - GetChars( CoordinateToString( m_end.y ) ) ); - - return menuText; + return wxString::Format( txtfmt, + orient, + MessageTextFromValue( aUnits, m_start.x ), + MessageTextFromValue( aUnits, m_start.y ), + MessageTextFromValue( aUnits, m_end.x ), + MessageTextFromValue( aUnits, m_end.y ) ); } @@ -811,7 +810,7 @@ int SCH_EDIT_FRAME::EditLine( SCH_LINE* aLine, bool aRedraw ) if( dlg.ShowModal() == wxID_CANCEL ) return wxID_CANCEL; - int new_width = std::max( 1, ValueFromString( dlg.GetWidth() ) ); + int new_width = std::max( 1, ValueFromString( m_UserUnits, dlg.GetWidth() ) ); int new_style = dlg.GetStyle(); COLOR4D new_color = dlg.GetColor(); diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index bae4549ead..d129c4b985 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -168,7 +168,7 @@ public: bool CanConnect( const SCH_ITEM* aItem ) const override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_marker.cpp b/eeschema/sch_marker.cpp index 3b04455b0d..48ff000131 100644 --- a/eeschema/sch_marker.cpp +++ b/eeschema/sch_marker.cpp @@ -112,10 +112,8 @@ const EDA_RECT SCH_MARKER::GetBoundingBox() const } -void SCH_MARKER::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void SCH_MARKER::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { - wxString msg; - aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ), GetReporter().GetErrorText(), DARKRED ) ); } diff --git a/eeschema/sch_marker.h b/eeschema/sch_marker.h index 3f3cf61a11..c364f28448 100644 --- a/eeschema/sch_marker.h +++ b/eeschema/sch_marker.h @@ -90,11 +90,14 @@ public: */ bool Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; bool IsSelectStateChanged( const wxRect& aRect ) override; - wxString GetSelectMenuText() const override { return wxString( _( "ERC Marker" ) ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return wxString( _( "ERC Marker" ) ); + } BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index ae72209557..9ee4c68d4d 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -87,7 +87,10 @@ public: void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; - wxString GetSelectMenuText() const override { return wxString( _( "No Connect" ) ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return wxString( _( "No Connect" ) ); + } BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 74b9f76d37..ac12e92f34 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -649,7 +649,7 @@ wxString SCH_SHEET::GetFileName( void ) const } -void SCH_SHEET::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void SCH_SHEET::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { aList.push_back( MSG_PANEL_ITEM( _( "Sheet Name" ), m_name, CYAN ) ); aList.push_back( MSG_PANEL_ITEM( _( "File Name" ), m_fileName, BROWN ) ); @@ -735,7 +735,7 @@ void SCH_SHEET::Resize( const wxSize& aSize ) bool SCH_SHEET::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint* aFindLocation ) { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) ); // Ignore the sheet file name if searching to replace. if( !(aSearchData.GetFlags() & FR_SEARCH_REPLACE) @@ -866,11 +866,9 @@ SEARCH_RESULT SCH_SHEET::Visit( INSPECTOR aInspector, void* testData, const KICA } -wxString SCH_SHEET::GetSelectMenuText() const +wxString SCH_SHEET::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString tmp; - tmp.Printf( _( "Hierarchical Sheet %s" ), GetChars( m_name ) ); - return tmp; + return wxString::Format( _( "Hierarchical Sheet %s" ), m_name ); } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 2ed299dfb9..0db142b65c 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -188,7 +188,7 @@ public: bool IsConnectable() const override { return true; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; @@ -313,7 +313,7 @@ public: */ int GetScreenCount() const; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /* there is no member for orientation in sch_sheet, to preserve file * format, we detect orientation based on pin edges @@ -535,7 +535,7 @@ public: SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 2fa1787540..8c73b21040 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -218,7 +218,7 @@ bool SCH_SHEET_PIN::Matches( wxFindReplaceData& aSearchData, wxCHECK_MSG( GetParent() != NULL, false, wxT( "Sheet pin " ) + m_Text + wxT( " does not have a parent sheet!" ) ); - wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " child item " ) + GetSelectMenuText( MILLIMETRES ) ); if( SCH_ITEM::Matches( m_Text, aSearchData ) ) { @@ -341,11 +341,9 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) } -wxString SCH_SHEET_PIN::GetSelectMenuText() const +wxString SCH_SHEET_PIN::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString tmp; - tmp.Printf( _( "Hierarchical Sheet Pin %s" ), GetChars( ShortenedShownText() ) ); - return tmp; + return wxString::Format( _( "Hierarchical Sheet Pin %s" ), ShortenedShownText() ); } BITMAP_DEF SCH_SHEET_PIN::GetMenuImage() const diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index df3c23968c..4eb5b50d11 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -176,7 +176,7 @@ wxPoint SCH_TEXT::GetSchematicTextOffset() const bool SCH_TEXT::Matches( wxFindReplaceData& aSearchData, void* aAuxData, wxPoint * aFindLocation ) { - wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText() ); + wxLogTrace( traceFindItem, wxT( " item " ) + GetSelectMenuText( MILLIMETRES ) ); if( SCH_ITEM::Matches( m_Text, aSearchData ) ) { @@ -494,11 +494,9 @@ const EDA_RECT SCH_TEXT::GetBoundingBox() const } -wxString SCH_TEXT::GetSelectMenuText() const +wxString SCH_TEXT::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString msg; - msg.Printf( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) ); - return msg; + return wxString::Format( _( "Graphic Text \"%s\"" ), GetChars( ShortenedShownText() ) ); } @@ -604,7 +602,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter ) /* * Display the type, shape, size and some other props to the Message panel */ -void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) +void SCH_TEXT::GetMsgPanelInfo( EDA_UNITS_T aUnits, MSG_PANEL_ITEMS& aList ) { wxString msg; @@ -692,7 +690,7 @@ void SCH_TEXT::GetMsgPanelInfo( MSG_PANEL_ITEMS& aList ) } // Display text size (X or Y value, with are the same value in Eeschema) - msg = StringFromValue( g_UserUnit, GetTextWidth(), true ); + msg = MessageTextFromValue( aUnits, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Size" ), msg, RED ) ); } @@ -807,11 +805,9 @@ const EDA_RECT SCH_LABEL::GetBoundingBox() const } -wxString SCH_LABEL::GetSelectMenuText() const +wxString SCH_LABEL::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString msg; - msg.Printf( _( "Label %s" ), GetChars( ShortenedShownText() ) ); - return msg; + return wxString::Format( _( "Label %s" ), ShortenedShownText() ); } @@ -1176,11 +1172,9 @@ const EDA_RECT SCH_GLOBALLABEL::GetBoundingBox() const } -wxString SCH_GLOBALLABEL::GetSelectMenuText() const +wxString SCH_GLOBALLABEL::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString msg; - msg.Printf( _( "Global Label %s" ), GetChars( ShortenedShownText() ) ); - return msg; + return wxString::Format( _( "Global Label %s" ), GetChars( ShortenedShownText() ) ); } @@ -1439,11 +1433,9 @@ void SCH_HIERLABEL::Rotate( wxPoint aPosition ) } -wxString SCH_HIERLABEL::GetSelectMenuText() const +wxString SCH_HIERLABEL::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString msg; - msg.Printf( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) ); - return msg; + return wxString::Format( _( "Hierarchical Label %s" ), GetChars( ShortenedShownText() ) ); } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index d11d1c4120..19c649f7c0 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -182,7 +182,7 @@ public: virtual bool CanIncrementLabel() const override { return true; } - virtual wxString GetSelectMenuText() const override; + virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; virtual BITMAP_DEF GetMenuImage() const override; @@ -202,7 +202,7 @@ public: virtual EDA_ITEM* Clone() const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const override; @@ -245,7 +245,7 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; @@ -297,7 +297,7 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; @@ -349,7 +349,7 @@ public: ( aItem->GetLayer() == LAYER_WIRE || aItem->GetLayer() == LAYER_BUS ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index b30a856182..1e86ba3de4 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -121,7 +121,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) OnModify( ); MSG_PANEL_ITEMS items; - DrawItem->GetMsgPanelInfo( items ); + DrawItem->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); m_canvas->Refresh(); } diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index 27c324127e..b110b0943f 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -683,7 +683,7 @@ void GERBER_DRAW_ITEM::DrawGbrPoly( EDA_RECT* aClipBox, } -void GERBER_DRAW_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void GERBER_DRAW_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; wxString text; @@ -982,17 +982,15 @@ SEARCH_RESULT GERBER_DRAW_ITEM::Visit( INSPECTOR inspector, void* testData, cons } -wxString GERBER_DRAW_ITEM::GetSelectMenuText() const +wxString GERBER_DRAW_ITEM::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text, layerName; + wxString layerName; layerName = GERBER_FILE_IMAGE_LIST::GetImagesList().GetDisplayName( GetLayer(), true ); - text.Printf( _( "%s (D%d) on layer %d: %s" ), - ShowGBRShape(), - m_DCode, - GetLayer() + 1, - layerName ); - - return text; + return wxString::Format( _( "%s (D%d) on layer %d: %s" ), + ShowGBRShape(), + m_DCode, + GetLayer() + 1, + layerName ); } diff --git a/gerbview/gerber_draw_item.h b/gerbview/gerber_draw_item.h index 9c35315643..77e26fe6e7 100644 --- a/gerbview/gerber_draw_item.h +++ b/gerbview/gerber_draw_item.h @@ -253,7 +253,7 @@ public: /* divers */ int Shape() const { return m_Shape; } - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; wxString ShowGBRShape() const; @@ -323,7 +323,7 @@ public: SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; ///> @copydoc EDA_ITEM::GetSelectMenuText() - virtual wxString GetSelectMenuText() const override; + virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; ///> @copydoc EDA_ITEM::GetMenuImage() BITMAP_DEF GetMenuImage() const override; diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp index 19e83a935e..b7399fedea 100644 --- a/gerbview/gerbview_draw_panel_gal.cpp +++ b/gerbview/gerbview_draw_panel_gal.cpp @@ -89,7 +89,8 @@ void GERBVIEW_DRAW_PANEL_GAL::SetHighContrastLayer( int aLayer ) } -void GERBVIEW_DRAW_PANEL_GAL::GetMsgPanelInfo( std::vector& aList ) +void GERBVIEW_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_UNITS_T aUnits, + std::vector& aList ) { } diff --git a/gerbview/gerbview_draw_panel_gal.h b/gerbview/gerbview_draw_panel_gal.h index 5b05a65afb..26d1b9ba0e 100644 --- a/gerbview/gerbview_draw_panel_gal.h +++ b/gerbview/gerbview_draw_panel_gal.h @@ -51,7 +51,7 @@ public: virtual void SetHighContrastLayer( int aLayer ) override; ///> @copydoc EDA_DRAW_PANEL_GAL::GetMsgPanelInfo() - void GetMsgPanelInfo( std::vector& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) override; ///> @copydoc EDA_DRAW_PANEL_GAL::OnShow() void OnShow() override; diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index b698430d55..ccd60dd26b 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -1062,7 +1062,7 @@ void GERBVIEW_FRAME::SetCurItem( GERBER_DRAW_ITEM* aItem, bool aDisplayInfo ) if( aDisplayInfo ) { MSG_PANEL_ITEMS items; - aItem->GetMsgPanelInfo( items ); + aItem->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } } diff --git a/gerbview/locate.cpp b/gerbview/locate.cpp index 99fe3e3f57..b2186ab756 100644 --- a/gerbview/locate.cpp +++ b/gerbview/locate.cpp @@ -99,7 +99,7 @@ GERBER_DRAW_ITEM* GERBVIEW_FRAME::Locate( const wxPoint& aPosition, int aTypeloc if( gerb_item ) { MSG_PANEL_ITEMS items; - gerb_item->GetMsgPanelInfo( items ); + gerb_item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/gerbview/tools/selection_tool.cpp b/gerbview/tools/selection_tool.cpp index 294f87d032..f49f8062f8 100644 --- a/gerbview/tools/selection_tool.cpp +++ b/gerbview/tools/selection_tool.cpp @@ -632,7 +632,7 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec { wxString text; EDA_ITEM* item = ( *aCollector )[i]; - text = item->GetSelectMenuText(); + text = item->GetSelectMenuText( m_frame->GetUserUnits() ); menu.Add( text, i + 1, item->GetMenuImage() ); } diff --git a/include/base_struct.h b/include/base_struct.h index 0de994f2c0..1176b2e639 100644 --- a/include/base_struct.h +++ b/include/base_struct.h @@ -33,12 +33,14 @@ #define BASE_STRUCT_H_ #include +#include "common.h" #include #include #if defined(DEBUG) #include // needed for Show() + extern std::ostream& operator <<( std::ostream& out, const wxSize& size ); extern std::ostream& operator <<( std::ostream& out, const wxPoint& pt ); @@ -141,19 +143,6 @@ typedef const INSPECTOR_FUNC& INSPECTOR; /// std::function passed to nested u typedef unsigned STATUS_FLAGS; -/** - * timestamp_t is our type to represent unique IDs for all kinds of elements; - * historically simply the timestamp when they were created. - * - * Long term, this type might be renamed to something like unique_id_t - * (and then rename all the methods from {Get,Set}TimeStamp() - * to {Get,Set}Id()) ? - * - * The type should be at least 32 bit and simple to map via swig; swig does - * have issues with types such as 'int32_t', so we choose 'long'. - */ -typedef long timestamp_t; - /** * Class EDA_ITEM * is a base class for most all the KiCad significant classes, used in @@ -285,7 +274,7 @@ public: * * @param aList is the list to populate. */ - virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) + virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { } @@ -382,7 +371,7 @@ public: * * @return The menu text string. */ - virtual wxString GetSelectMenuText() const; + virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const; /** * Function GetMenuImage diff --git a/include/base_units.h b/include/base_units.h index 894a8c694c..6bd913c707 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -81,22 +81,6 @@ void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed = */ double To_User_Unit( EDA_UNITS_T aUnit, double aValue, bool aUseMils = false ); -/** - * Function CoordinateToString - * is a helper to convert the \a integer coordinate \a aValue to a string in inches, - * millimeters, or unscaled units according to the current user units setting. - * - * Should be used only to display a coordinate in status, but not in dialogs, - * because the mantissa of the number displayed has 4 digits max for readability. - * (i.e. the value shows the decimils or the microns ) - * However the actual internal value could need up to 8 digits to be printed - * - * @param aValue The integer coordinate to convert. - * @param aUseMils Convert inch values to mils if true. - * @return The converted string for display in user interface elements. - */ -wxString CoordinateToString( int aValue, bool aUseMils = false ); - /** * Function AngleToStringDegrees * is a helper to convert the \a double \a aAngle (in internal unit) @@ -149,16 +133,6 @@ wxString MessageTextFromValue( EDA_UNITS_T aUnits, int aValue, bool aUseMils = f wxString StringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false, bool aUseMils = false ); -/** - * Operator << overload - * outputs a point to the argument string in a format resembling - * "@ (x,y) - * @param aString Where to put the text describing the point value - * @param aPoint The point to output. - * @return wxString& - the input string - */ -wxString& operator <<( wxString& aString, const wxPoint& aPoint ); - /** * Function PutValueInLocalUnits * converts \a aValue from internal units to user units and append the units notation @@ -197,18 +171,6 @@ double DoubleValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, */ int ValueFromString( EDA_UNITS_T aUnits, const wxString& aTextValue, bool aUseMils = false ); -/** - * Function ValueFromString - - * converts \a aTextValue in \a aUnits to internal units used by the application, - * unit type will be obtained from g_UserUnit. - * - * @param aTextValue A reference to a wxString object containing the string to convert. - * @return The string from Value, according to units (inch, mm ...) for display, - */ - -int ValueFromString( const wxString& aTextValue ); - /** * Convert the number Value in a string according to the internal units * and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl diff --git a/include/class_draw_panel_gal.h b/include/class_draw_panel_gal.h index 4ef3a4ad06..e50d41816d 100644 --- a/include/class_draw_panel_gal.h +++ b/include/class_draw_panel_gal.h @@ -37,6 +37,7 @@ #include #include #include +#include class BOARD; class EDA_DRAW_FRAME; @@ -159,7 +160,7 @@ public: */ virtual void SetTopLayer( int aLayer ); - virtual void GetMsgPanelInfo( std::vector& aList ) + virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) { assert( false ); } diff --git a/include/common.h b/include/common.h index b06d54415d..ce2ccea0a1 100644 --- a/include/common.h +++ b/include/common.h @@ -38,7 +38,6 @@ #include #include -#include // For timestamp_t definition #include #include @@ -52,6 +51,20 @@ class SEARCH_STACK; class REPORTER; +/** + * timestamp_t is our type to represent unique IDs for all kinds of elements; + * historically simply the timestamp when they were created. + * + * Long term, this type might be renamed to something like unique_id_t + * (and then rename all the methods from {Get,Set}TimeStamp() + * to {Get,Set}Id()) ? + * + * The type should be at least 32 bit and simple to map via swig; swig does + * have issues with types such as 'int32_t', so we choose 'long'. + */ +typedef long timestamp_t; + + // Flag for special keys // This type could be extended to 64 bits to add room for more flags. // For compatibility with old code, keep flag bits out of the least diff --git a/include/drc_item.h b/include/drc_item.h index 29bebc3c5b..3a5d147c1d 100644 --- a/include/drc_item.h +++ b/include/drc_item.h @@ -26,6 +26,7 @@ #define DRC_ITEM_H #include +#include class MARKER_BASE; class BOARD; @@ -91,14 +92,17 @@ public: EDA_ITEM* bAuxiliaryItem = nullptr, const wxPoint& bAuxiliaryPos = wxPoint() ) { m_ErrorCode = aErrorCode; - m_MainText = aMainItem->GetSelectMenuText(); - m_AuxiliaryText = bAuxiliaryItem ? bAuxiliaryItem->GetSelectMenuText() : wxString( wxEmptyString ); + m_MainText = aMainItem->GetSelectMenuText( g_UserUnit ); + m_AuxiliaryText = wxEmptyString; m_MainPosition = aMainPos; m_AuxiliaryPosition = bAuxiliaryPos; m_hasSecondItem = bAuxiliaryItem != nullptr; m_noCoordinate = false; m_parent = nullptr; + if( m_hasSecondItem ) + m_AuxiliaryText = bAuxiliaryItem->GetSelectMenuText( g_UserUnit ); + // Weak references (void*). One must search the BOARD_ITEMS or SCH_ITEMS for a match. m_mainItemWeakRef = aMainItem; m_auxItemWeakRef = bAuxiliaryItem; @@ -125,8 +129,8 @@ public: m_noCoordinate = false; m_parent = nullptr; - m_mainItemWeakRef = nullptr; - m_auxItemWeakRef = nullptr; + m_mainItemWeakRef = nullptr; + m_auxItemWeakRef = nullptr; } /** @@ -225,7 +229,7 @@ public: * @param aPos The position to format * @return wxString - The formated string */ - static wxString ShowCoord( const wxPoint& aPos ); + static wxString ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos ); }; diff --git a/include/widgets/unit_binder.h b/include/widgets/unit_binder.h index bfe1dcf55d..9421f8e452 100644 --- a/include/widgets/unit_binder.h +++ b/include/widgets/unit_binder.h @@ -27,6 +27,7 @@ #include #include +#include #include diff --git a/pcbnew/attribut.cpp b/pcbnew/attribut.cpp index f65fe8b2d8..5c6cfff5ca 100644 --- a/pcbnew/attribut.cpp +++ b/pcbnew/attribut.cpp @@ -59,7 +59,7 @@ void PCB_EDIT_FRAME::Attribut_Segment( TRACK* track, wxDC* DC, bool Flag_On ) m_canvas->CrossHairOn( DC ); // Display cursor shape MSG_PANEL_ITEMS items; - track->GetMsgPanelInfo( items ); + track->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 2beb6dc298..89858f64c2 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -72,8 +72,15 @@ public: BOARD_ITEM( nullptr, NOT_USED ) {} - wxString GetSelectMenuText() const override { return _( "(Deleted Item)" ); } - wxString GetClass() const override { return wxT( "DELETED_BOARD_ITEM" ); } + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override + { + return _( "(Deleted Item)" ); + } + + wxString GetClass() const override + { + return wxT( "DELETED_BOARD_ITEM" ); + } // pure virtuals: const wxPoint GetPosition() const override { return wxPoint(); } @@ -1181,7 +1188,7 @@ EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const } -void BOARD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void BOARD::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString txt; int viasCount = 0; diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index d78ce55077..1b066565aa 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -805,7 +805,7 @@ public: return ComputeBoundingBox( true ); } - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** * Function Draw. diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 9696414e87..a7b1eb9c42 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -215,7 +215,6 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) int arrow_dw_X = 0, arrow_dw_Y = 0; // coordinates of arrow line '\' int hx, hy; // dimension line interval double angle, angle_f; - wxString msg; // Init layer : m_Text.SetLayer( GetLayer() ); @@ -317,8 +316,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) if( !aDoNotChangeText ) { m_Value = measure; - msg = ::CoordinateToString( m_Value ); - SetText( msg ); + SetText( MessageTextFromValue( g_UserUnit, m_Value ) ); } } @@ -379,10 +377,10 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color, // see class_cotation.h -void DIMENSION::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void DIMENSION::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { // for now, display only the text within the DIMENSION using class TEXTE_PCB. - m_Text.GetMsgPanelInfo( aList ); + m_Text.GetMsgPanelInfo( aUnits, aList ); } @@ -485,14 +483,9 @@ const EDA_RECT DIMENSION::GetBoundingBox() const } -wxString DIMENSION::GetSelectMenuText() const +wxString DIMENSION::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - text.Printf( _( "Dimension \"%s\" on %s" ), - GetChars( GetText() ), - GetChars( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Dimension \"%s\" on %s" ), GetText(), GetLayerName() ); } diff --git a/pcbnew/class_dimension.h b/pcbnew/class_dimension.h index 103d59af30..877633555c 100644 --- a/pcbnew/class_dimension.h +++ b/pcbnew/class_dimension.h @@ -205,7 +205,7 @@ public: */ void Mirror( const wxPoint& axis_pos ); - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; bool HitTest( const wxPoint& aPosition ) const override; @@ -219,7 +219,7 @@ public: // Virtual function const EDA_RECT GetBoundingBox() const override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index c62cc2d8dd..3a2989dc49 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -396,7 +396,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, } } -void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void DRAWSEGMENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; @@ -411,7 +411,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) case S_CIRCLE: aList.push_back( MSG_PANEL_ITEM( shape, _( "Circle" ), RED ) ); - msg = ::CoordinateToString( GetLineLength( m_Start, m_End ) ); + msg = MessageTextFromValue( aUnits, GetLineLength( m_Start, m_End ) ); aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) ); break; @@ -420,7 +420,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg.Printf( wxT( "%.1f" ), m_Angle / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, RED ) ); - msg = ::CoordinateToString( GetLineLength( m_Start, m_End ) ); + msg = MessageTextFromValue( aUnits, GetLineLength( m_Start, m_End ) ); aList.push_back( MSG_PANEL_ITEM( _( "Radius" ), msg, RED ) ); break; @@ -432,7 +432,7 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) ); - msg = ::CoordinateToString( GetLineLength( m_Start, m_End ) ); + msg = MessageTextFromValue( aUnits, GetLineLength( m_Start, m_End ) ); aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKGREEN ) ); // angle counter-clockwise from 3'o-clock @@ -443,15 +443,17 @@ void DRAWSEGMENT::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) } } - wxString start; - start << GetStart(); - - wxString end; - end << GetEnd(); + wxString start = wxString::Format( _( "@(%s, %s)" ), + MessageTextFromValue( aUnits, GetStart().x ), + MessageTextFromValue( aUnits, GetStart().y ) ); + wxString end = wxString::Format( _( "@(%s, %s)" ), + MessageTextFromValue( aUnits, GetEnd().x ), + MessageTextFromValue( aUnits, GetEnd().y ) ); aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) ); - msg = ::CoordinateToString( m_Width ); + + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) ); } @@ -721,16 +723,12 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy } -wxString DRAWSEGMENT::GetSelectMenuText() const +wxString DRAWSEGMENT::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - - text.Printf( _( "Pcb Graphic %s, length %s on %s" ), - GetChars( ShowShape( m_Shape ) ), - GetChars( ::MessageTextFromValue( g_UserUnit, GetLength() ) ), - GetChars( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Pcb Graphic %s, length %s on %s" ), + ShowShape( m_Shape ), + MessageTextFromValue( aUnits, GetLength() ), + GetLayerName() ); } diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 50adf49593..0b6dff4fbc 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -199,13 +199,15 @@ public: void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; - virtual void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + virtual void GetMsgPanelInfo( EDA_UNITS_T aUnits, + std::vector< MSG_PANEL_ITEM >& aList ) override; virtual const EDA_RECT GetBoundingBox() const override; virtual bool HitTest( const wxPoint& aPosition ) const override; - bool HitTest( const EDA_RECT& aRect, bool aContained = true, int aAccuracy = 0 ) const override; + bool HitTest( const EDA_RECT& aRect, bool aContained = true, + int aAccuracy = 0 ) const override; wxString GetClass() const override { @@ -245,7 +247,7 @@ public: int aCircleToSegmentsCount, double aCorrectionFactor ) const override; - virtual wxString GetSelectMenuText() const override; + virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; virtual BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index cddd2ee632..feef53a7b3 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -232,7 +232,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode, // see class_edge_mod.h -void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void EDGE_MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; @@ -250,24 +250,20 @@ void EDGE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Value" ), module->GetValue(), BLUE ) ); msg.Printf( wxT( "%8.8lX" ), module->GetTimeStamp() ); aList.push_back( MSG_PANEL_ITEM( _( "TimeStamp" ), msg, BROWN ) ); - aList.push_back( MSG_PANEL_ITEM( _( "Footprint Layer" ), - module->GetLayerName(), RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Footprint Layer" ), module->GetLayerName(), RED ) ); // append the features shared with the base class - DRAWSEGMENT::GetMsgPanelInfo( aList ); + DRAWSEGMENT::GetMsgPanelInfo( aUnits, aList ); } -wxString EDGE_MODULE::GetSelectMenuText() const +wxString EDGE_MODULE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - text.Printf( _( "Graphic %s of %s on %s" ), - GetChars( ShowShape( m_Shape ) ), - GetChars( ((MODULE*) GetParent())->GetReference() ), - GetChars( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Graphic %s of %s on %s" ), + ShowShape( m_Shape ), + ((MODULE*) GetParent())->GetReference(), + GetLayerName() ); } diff --git a/pcbnew/class_edge_mod.h b/pcbnew/class_edge_mod.h index 38dcac19e3..07b766543f 100644 --- a/pcbnew/class_edge_mod.h +++ b/pcbnew/class_edge_mod.h @@ -115,14 +115,14 @@ public: void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; wxString GetClass() const override { return wxT( "MGRAPHIC" ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp index 9e42f19f80..198199ef14 100644 --- a/pcbnew/class_marker_pcb.cpp +++ b/pcbnew/class_marker_pcb.cpp @@ -93,7 +93,7 @@ bool MARKER_PCB::IsOnLayer( PCB_LAYER_ID aLayer ) const return IsCopperLayer( aLayer ); } -void MARKER_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void MARKER_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { const DRC_ITEM& rpt = m_drc; @@ -107,13 +107,16 @@ void MARKER_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) ); - wxString txtA; - txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT( ": " ) << rpt.GetTextA(); - + wxString txtA = wxString::Format( wxT( "%s: %s" ), + DRC_ITEM::ShowCoord( aUnits, rpt.GetPointA() ), + rpt.GetTextA() ); wxString txtB; - - if ( rpt.HasSecondItem() ) - txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT( ": " ) << rpt.GetTextB(); + if( rpt.HasSecondItem() ) + { + txtB = wxString::Format( wxT( "%s: %s" ), + DRC_ITEM::ShowCoord( aUnits, rpt.GetPointB() ), + rpt.GetTextB() ); + } aList.push_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) ); } @@ -131,11 +134,11 @@ void MARKER_PCB::Flip(const wxPoint& aCentre ) } -wxString MARKER_PCB::GetSelectMenuText() const +wxString MARKER_PCB::GetSelectMenuText( EDA_UNITS_T aUnits ) const { return wxString::Format( _( "Marker @(%s, %s)" ), - GetChars( CoordinateToString( m_Pos.x ) ), - GetChars( CoordinateToString( m_Pos.y ) ) ); + MessageTextFromValue( aUnits, m_Pos.x ), + MessageTextFromValue( aUnits, m_Pos.y ) ); } diff --git a/pcbnew/class_marker_pcb.h b/pcbnew/class_marker_pcb.h index 712852b8d8..ecbb0654e1 100644 --- a/pcbnew/class_marker_pcb.h +++ b/pcbnew/class_marker_pcb.h @@ -98,9 +98,9 @@ public: bool IsOnLayer( PCB_LAYER_ID aLayer ) const override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 02d844d747..1e6cc2cb32 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -546,7 +546,7 @@ SHAPE_POLY_SET MODULE::GetBoundingPoly() const } -void MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { int nbpad; wxString msg; @@ -867,20 +867,14 @@ SEARCH_RESULT MODULE::Visit( INSPECTOR inspector, void* testData, const KICAD_T } -wxString MODULE::GetSelectMenuText() const +wxString MODULE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { wxString reference = GetReference(); if( reference.IsEmpty() ) reference = _( "" ); - wxString text; - - text.Printf( _( "Footprint %s on %s" ), - GetChars ( reference ), - GetChars ( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Footprint %s on %s" ), reference, GetLayerName() ); } diff --git a/pcbnew/class_module.h b/pcbnew/class_module.h index 54c0254f74..0f78732053 100644 --- a/pcbnew/class_module.h +++ b/pcbnew/class_module.h @@ -436,7 +436,7 @@ public: const wxPoint& offset, int dim_ancre, GR_DRAWMODE draw_mode ); ///> @copydoc EDA_ITEM::GetMsgPanelInfo - void GetMsgPanelInfo( std::vector& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) override; bool HitTest( const wxPoint& aPosition ) const override; @@ -598,7 +598,7 @@ public: return wxT( "MODULE" ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index ddf1bc8783..e97f057358 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -700,10 +700,10 @@ int D_PAD::GetThermalGap() const } -void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) +void D_PAD::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM>& aList ) { MODULE* module; - wxString Line; + wxString msg; BOARD* board; module = (MODULE*) m_Parent; @@ -723,45 +723,46 @@ void D_PAD::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM>& aList ) aList.push_back( MSG_PANEL_ITEM( ShowPadShape(), ShowPadAttr(), DARKGREEN ) ); - Line = ::CoordinateToString( m_Size.x ); - aList.push_back( MSG_PANEL_ITEM( _( "Width" ), Line, RED ) ); + msg = MessageTextFromValue( aUnits, m_Size.x, true ); + aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); - Line = ::CoordinateToString( m_Size.y ); - aList.push_back( MSG_PANEL_ITEM( _( "Height" ), Line, RED ) ); + msg = MessageTextFromValue( aUnits, m_Size.y, true ); + aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); - Line = ::CoordinateToString( (unsigned) m_Drill.x ); + msg = MessageTextFromValue( aUnits, m_Drill.x, true ); if( GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE ) { - aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), Line, RED ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Drill" ), msg, RED ) ); } else { - Line = ::CoordinateToString( (unsigned) m_Drill.x ); - wxString msg; - msg = ::CoordinateToString( (unsigned) m_Drill.y ); - Line += wxT( "/" ) + msg; - aList.push_back( MSG_PANEL_ITEM( _( "Drill X / Y" ), Line, RED ) ); + msg = MessageTextFromValue( aUnits, m_Drill.x, true ) + + wxT( "/" ) + + MessageTextFromValue( aUnits, m_Drill.y, true ); + aList.push_back( MSG_PANEL_ITEM( _( "Drill X / Y" ), msg, RED ) ); } double module_orient_degrees = module ? module->GetOrientationDegrees() : 0; if( module_orient_degrees != 0.0 ) - Line.Printf( wxT( "%3.1f(+%3.1f)" ), - GetOrientationDegrees() - module_orient_degrees, - module_orient_degrees ); + msg.Printf( wxT( "%3.1f(+%3.1f)" ), + GetOrientationDegrees() - module_orient_degrees, + module_orient_degrees ); else - Line.Printf( wxT( "%3.1f" ), GetOrientationDegrees() ); + msg.Printf( wxT( "%3.1f" ), GetOrientationDegrees() ); - aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), Line, LIGHTBLUE ) ); + aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, LIGHTBLUE ) ); - Line = ::CoordinateToString( m_Pos.x ) + wxT( ", " ) + ::CoordinateToString( m_Pos.y ); - aList.push_back( MSG_PANEL_ITEM( _( "Position" ), Line, LIGHTBLUE ) ); + msg = MessageTextFromValue( aUnits, m_Pos.x ) + + wxT( ", " ) + + MessageTextFromValue( aUnits, m_Pos.y ); + aList.push_back( MSG_PANEL_ITEM( _( "Position" ), msg, LIGHTBLUE ) ); if( GetPadToDieLength() ) { - Line = ::CoordinateToString( GetPadToDieLength() ); - aList.push_back( MSG_PANEL_ITEM( _( "Length in package" ), Line, CYAN ) ); + msg = MessageTextFromValue( aUnits, GetPadToDieLength(), true ); + aList.push_back( MSG_PANEL_ITEM( _( "Length in package" ), msg, CYAN ) ); } } @@ -1199,27 +1200,21 @@ wxString D_PAD::ShowPadAttr() const } -wxString D_PAD::GetSelectMenuText() const +wxString D_PAD::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - wxString padlayers( LayerMaskDescribe( GetBoard(), m_layerMask ) ); - wxString padname( GetName() ); - - if( padname.IsEmpty() ) + if( GetName().IsEmpty() ) { - text.Printf( _( "Pad of %s on %s" ), - GetChars( GetParent()->GetReference() ), - GetChars( padlayers ) ); + return wxString::Format( _( "Pad of %s on %s" ), + GetParent()->GetReference(), + LayerMaskDescribe( GetBoard(), m_layerMask ) ); } else { - text.Printf( _( "Pad %s of %s on %s" ), - GetChars( GetName() ), - GetChars( GetParent()->GetReference() ), - GetChars( padlayers ) ); + return wxString::Format( _( "Pad %s of %s on %s" ), + GetName(), + GetParent()->GetReference(), + LayerMaskDescribe( GetBoard(), m_layerMask ) ); } - - return text; } diff --git a/pcbnew/class_pad.h b/pcbnew/class_pad.h index e251304e79..c93b949a28 100644 --- a/pcbnew/class_pad.h +++ b/pcbnew/class_pad.h @@ -645,7 +645,7 @@ public: int GetSubRatsnest() const { return m_SubRatsnest; } void SetSubRatsnest( int aSubRatsnest ) { m_SubRatsnest = aSubRatsnest; } - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; bool IsOnLayer( PCB_LAYER_ID aLayer ) const override { @@ -685,7 +685,7 @@ public: void Rotate( const wxPoint& aRotCentre, double aAngle ) override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_pcb_target.cpp b/pcbnew/class_pcb_target.cpp index 69f973a794..5c6eda61be 100644 --- a/pcbnew/class_pcb_target.cpp +++ b/pcbnew/class_pcb_target.cpp @@ -183,17 +183,10 @@ const EDA_RECT PCB_TARGET::GetBoundingBox() const } -wxString PCB_TARGET::GetSelectMenuText() const +wxString PCB_TARGET::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - wxString msg; - - msg = ::CoordinateToString( m_Size ); - // Targets are on *every* layer by definition - text.Printf( _( "Target size %s" ), GetChars( msg ) ); - - return text; + return wxString::Format( _( "Target size %s" ), MessageTextFromValue( aUnits, m_Size ) ); } diff --git a/pcbnew/class_pcb_target.h b/pcbnew/class_pcb_target.h index 95bcb29645..2c152bb964 100644 --- a/pcbnew/class_pcb_target.h +++ b/pcbnew/class_pcb_target.h @@ -97,7 +97,7 @@ public: // Virtual function const EDA_RECT GetBoundingBox() const override; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_pcb_text.cpp b/pcbnew/class_pcb_text.cpp index 216474da69..e0bf3e125b 100644 --- a/pcbnew/class_pcb_text.cpp +++ b/pcbnew/class_pcb_text.cpp @@ -114,7 +114,7 @@ void TEXTE_PCB::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, } -void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void TEXTE_PCB::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; @@ -135,13 +135,13 @@ void TEXTE_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg.Printf( wxT( "%.1f" ), GetTextAngle() / 10.0 ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( GetThickness() ); + msg = MessageTextFromValue( aUnits, GetThickness() ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, MAGENTA ) ); - msg = ::CoordinateToString( GetTextWidth() ); + msg = MessageTextFromValue( aUnits, GetTextWidth() ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); - msg = ::CoordinateToString( GetTextHeight() ); + msg = MessageTextFromValue( aUnits, GetTextHeight() ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } @@ -178,15 +178,9 @@ void TEXTE_PCB::Flip( const wxPoint& aCentre ) } -wxString TEXTE_PCB::GetSelectMenuText() const +wxString TEXTE_PCB::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - - text.Printf( _( "Pcb Text \"%s\" on %s"), - GetChars ( ShortenedShownText() ), - GetChars( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Pcb Text \"%s\" on %s"), ShortenedShownText(), GetLayerName() ); } diff --git a/pcbnew/class_pcb_text.h b/pcbnew/class_pcb_text.h index 9d272d25b2..705d7d15a6 100644 --- a/pcbnew/class_pcb_text.h +++ b/pcbnew/class_pcb_text.h @@ -91,7 +91,7 @@ public: void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& offset = ZeroOffset ) override; - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; virtual bool HitTest( const wxPoint& aPosition ) const override { @@ -143,7 +143,7 @@ public: int aCircleToSegmentsCount, double aCorrectionFactor ) const; - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_text_mod.cpp b/pcbnew/class_text_mod.cpp index 01d89cb4e5..b8b5702560 100644 --- a/pcbnew/class_text_mod.cpp +++ b/pcbnew/class_text_mod.cpp @@ -360,7 +360,7 @@ double TEXTE_MODULE::GetDrawRotation() const // see class_text_mod.h -void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void TEXTE_MODULE::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { MODULE* module = (MODULE*) m_Parent; @@ -403,43 +403,36 @@ void TEXTE_MODULE::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) msg.Printf( wxT( "%.1f" ), GetTextAngleDegrees() ); aList.push_back( MSG_PANEL_ITEM( _( "Angle" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( GetThickness() ); + msg = MessageTextFromValue( aUnits, GetThickness(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Thickness" ), msg, DARKGREEN ) ); - msg = ::CoordinateToString( GetTextWidth() ); + msg = MessageTextFromValue( aUnits, GetTextWidth(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, RED ) ); - msg = ::CoordinateToString( GetTextHeight() ); + msg = MessageTextFromValue( aUnits, GetTextHeight(), true ); aList.push_back( MSG_PANEL_ITEM( _( "Height" ), msg, RED ) ); } -wxString TEXTE_MODULE::GetSelectMenuText() const +wxString TEXTE_MODULE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - const wxChar *reference = GetChars( static_cast( GetParent() )->GetReference() ); - switch( m_Type ) { case TEXT_is_REFERENCE: - text.Printf( _( "Reference %s" ), reference ); - break; + return wxString::Format( _( "Reference %s" ), + static_cast( GetParent() )->GetReference() ); case TEXT_is_VALUE: - text.Printf( _( "Value %s of %s" ), - GetChars( GetShownText() ), - reference ); - break; + return wxString::Format( _( "Value %s of %s" ), + GetShownText(), + static_cast( GetParent() )->GetReference() ); default: // wrap this one in quotes: - text.Printf( _( "Text \"%s\" of %s on %s" ), - GetChars( ShortenedShownText() ), - reference, - GetChars( GetLayerName() ) ); - break; + return wxString::Format( _( "Text \"%s\" of %s on %s" ), + ShortenedShownText(), + static_cast( GetParent() )->GetReference(), + GetLayerName() ); } - - return text; } diff --git a/pcbnew/class_text_mod.h b/pcbnew/class_text_mod.h index 11a42e8c12..001784cb0b 100644 --- a/pcbnew/class_text_mod.h +++ b/pcbnew/class_text_mod.h @@ -194,7 +194,7 @@ public: GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ); - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; virtual bool TextHitTest( const wxPoint& aPoint, int aAccuracy = 0 ) const override; @@ -215,7 +215,7 @@ public: return wxT( "MTEXT" ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 80e4865366..d510edcb7c 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -108,13 +108,6 @@ EDA_ITEM* TRACK::Clone() const } -wxString TRACK::ShowWidth() const -{ - wxString msg = ::CoordinateToString( m_Width ); - return msg; -} - - SEGZONE::SEGZONE( BOARD_ITEM* aParent ) : TRACK( aParent, PCB_ZONE_T ) { @@ -127,15 +120,9 @@ EDA_ITEM* SEGZONE::Clone() const } -wxString SEGZONE::GetSelectMenuText() const +wxString SEGZONE::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - - text.Printf( _( "Zone [%s] on %s" ), - GetChars( GetNetnameMsg() ), - GetChars( GetLayerName() ) ); - - return text; + return wxString::Format( _( "Zone [%s] on %s" ), GetNetnameMsg(), GetLayerName() ); } @@ -160,9 +147,8 @@ EDA_ITEM* VIA::Clone() const } -wxString VIA::GetSelectMenuText() const +wxString VIA::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; wxString format; BOARD* board = GetBoard(); @@ -186,23 +172,21 @@ wxString VIA::GetSelectMenuText() const PCB_LAYER_ID topLayer; PCB_LAYER_ID botLayer; LayerPair( &topLayer, &botLayer ); - text.Printf( format.GetData(), - GetChars( ShowWidth() ), - GetChars( GetNetnameMsg() ), - GetChars( board->GetLayerName( topLayer ) ), - GetChars( board->GetLayerName( botLayer ) ) ); + return wxString::Format( format.GetData(), + MessageTextFromValue( aUnits, m_Width ), + GetNetnameMsg(), + board->GetLayerName( topLayer ), + board->GetLayerName( botLayer ) ); } else { - text.Printf( format.GetData(), - GetChars( ShowWidth() ), - GetChars( GetNetnameMsg() ), - wxT( "??" ), - wxT( "??" ) ); + return wxString::Format( format.GetData(), + MessageTextFromValue( aUnits, m_Width ), + GetNetnameMsg(), + wxT( "??" ), + wxT( "??" ) ); } - - return text; } @@ -1058,13 +1042,13 @@ unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const // see class_track.h -void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void TRACK::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; BOARD* board = GetBoard(); // Display basic infos - GetMsgPanelInfoBase( aList ); + GetMsgPanelInfoBase( aUnits, aList ); // Display full track length (in Pcbnew) if( board ) @@ -1080,15 +1064,15 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) track_buffer_start = track_buffer_start->Back(); board->MarkTrace( track_buffer_start, this, NULL, &trackLen, &lenPadToDie, false ); - msg = ::MessageTextFromValue( g_UserUnit, trackLen ); + msg = MessageTextFromValue( aUnits, trackLen ); aList.push_back( MSG_PANEL_ITEM( _( "Length" ), msg, DARKCYAN ) ); if( lenPadToDie != 0 ) { - msg = ::MessageTextFromValue( g_UserUnit, trackLen + lenPadToDie ); + msg = MessageTextFromValue( aUnits, trackLen + lenPadToDie ); aList.push_back( MSG_PANEL_ITEM( _( "Full Length" ), msg, DARKCYAN ) ); - msg = ::MessageTextFromValue( g_UserUnit, lenPadToDie ); + msg = MessageTextFromValue( aUnits, lenPadToDie, true ); aList.push_back( MSG_PANEL_ITEM( _( "Pad To Die Length" ), msg, DARKCYAN ) ); } } @@ -1098,22 +1082,22 @@ void TRACK::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) if( netclass ) { aList.push_back( MSG_PANEL_ITEM( _( "NC Name" ), netclass->GetName(), DARKMAGENTA ) ); - aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ), - ::CoordinateToString( netclass->GetClearance(), true ), - DARKMAGENTA ) ); - aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ), - ::CoordinateToString( netclass->GetTrackWidth(), true ), - DARKMAGENTA ) ); - aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ), - ::CoordinateToString( netclass->GetViaDiameter(), true ), - DARKMAGENTA ) ); - aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"), - ::CoordinateToString( netclass->GetViaDrill(), true ), - DARKMAGENTA ) ); + + msg = MessageTextFromValue( aUnits, netclass->GetClearance(), true ); + aList.push_back( MSG_PANEL_ITEM( _( "NC Clearance" ), msg, DARKMAGENTA ) ); + + msg = MessageTextFromValue( aUnits, netclass->GetTrackWidth(), true ); + aList.push_back( MSG_PANEL_ITEM( _( "NC Width" ), msg, DARKMAGENTA ) ); + + msg = MessageTextFromValue( aUnits, netclass->GetViaDiameter(), true ); + aList.push_back( MSG_PANEL_ITEM( _( "NC Via Size" ), msg, DARKMAGENTA ) ); + + msg = MessageTextFromValue( aUnits, netclass->GetViaDrill(), true ); + aList.push_back( MSG_PANEL_ITEM( _( "NC Via Drill"), msg, DARKMAGENTA ) ); } } -void TRACK::GetMsgPanelInfoBase_Common( std::vector< MSG_PANEL_ITEM >& aList ) +void TRACK::GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; @@ -1173,14 +1157,14 @@ void TRACK::GetMsgPanelInfoBase_Common( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Status" ), msg, MAGENTA ) ); } -void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) +void TRACK::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; BOARD* board = GetBoard(); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Track" ), DARKCYAN ) ); - GetMsgPanelInfoBase_Common( aList ); + GetMsgPanelInfoBase_Common( aUnits, aList ); // Display layer if( board ) @@ -1191,23 +1175,23 @@ void TRACK::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) ); // Display width - msg = ::CoordinateToString( (unsigned) m_Width ); + msg = MessageTextFromValue( aUnits, m_Width, true ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) ); // Display segment length - msg = ::MessageTextFromValue( g_UserUnit, GetLength() ); + msg = ::MessageTextFromValue( aUnits, GetLength() ); aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) ); } -void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) +void SEGZONE::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; BOARD* board = GetBoard(); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Zone " ), DARKCYAN ) ); - GetMsgPanelInfoBase_Common( aList ); + GetMsgPanelInfoBase_Common( aUnits, aList ); // Display layer if( board ) @@ -1218,16 +1202,16 @@ void SEGZONE::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), msg, BROWN ) ); // Display width - msg = ::CoordinateToString( (unsigned) m_Width ); + msg = MessageTextFromValue( aUnits, m_Width ); aList.push_back( MSG_PANEL_ITEM( _( "Width" ), msg, DARKCYAN ) ); // Display segment length - msg = ::MessageTextFromValue( g_UserUnit, GetLength() ); + msg = MessageTextFromValue( aUnits, GetLength() ); aList.push_back( MSG_PANEL_ITEM( _( "Segment Length" ), msg, DARKCYAN ) ); } -void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) +void VIA::GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; BOARD* board = GetBoard(); @@ -1256,7 +1240,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); - GetMsgPanelInfoBase_Common( aList ); + GetMsgPanelInfoBase_Common( aUnits, aList ); // Display layer pair @@ -1273,15 +1257,13 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Layers" ), msg, BROWN ) ); // Display width - msg = ::CoordinateToString( (unsigned) m_Width ); + msg = MessageTextFromValue( aUnits, m_Width, true ); // Display diameter value: aList.push_back( MSG_PANEL_ITEM( _( "Diameter" ), msg, DARKCYAN ) ); // Display drill value - int drill_value = GetDrillValue(); - - msg = ::CoordinateToString( drill_value ); + msg = MessageTextFromValue( aUnits, GetDrillValue() ); wxString title = _( "Drill" ); title += wxT( " " ); @@ -1301,7 +1283,7 @@ void VIA::GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) drill_class_value = net->GetViaDrillSize(); } - drl_specific = drill_value != drill_class_value; + drl_specific = GetDrillValue() != drill_class_value; } @@ -1605,17 +1587,13 @@ int TRACK::GetEndSegments( int aCount, TRACK** aStartTrace, TRACK** aEndTrace ) } -wxString TRACK::GetSelectMenuText() const +wxString TRACK::GetSelectMenuText( EDA_UNITS_T aUnits ) const { - wxString text; - - text.Printf( _("Track %s %s on %s, length: %s" ), - GetChars( ShowWidth() ), - GetChars( GetNetnameMsg() ), - GetChars( GetLayerName() ), - GetChars( ::MessageTextFromValue( g_UserUnit, GetLength() ) ) ); - - return text; + return wxString::Format( _("Track %s %s on %s, length: %s" ), + MessageTextFromValue( aUnits, m_Width ), + GetNetnameMsg(), + GetLayerName(), + MessageTextFromValue( aUnits, GetLength() ) ); } diff --git a/pcbnew/class_track.h b/pcbnew/class_track.h index bf0751e161..75df81ed62 100644 --- a/pcbnew/class_track.h +++ b/pcbnew/class_track.h @@ -212,13 +212,7 @@ public: */ bool IsNull(); - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; - - /** - * Function ShowWidth - * returns the width of the track in displayable user units. - */ - wxString ShowWidth() const; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; @@ -294,7 +288,7 @@ public: */ virtual int GetClearance( BOARD_CONNECTED_ITEM* aItem = NULL ) const override; - virtual wxString GetSelectMenuText() const override; + virtual wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; @@ -326,12 +320,12 @@ protected: * Display info about the track segment only, and does not calculate the full track length * @param aList A list of #MSG_PANEL_ITEM objects to add status information. */ - virtual void GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ); + virtual void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ); /** * Helper function for the common panel info */ - void GetMsgPanelInfoBase_Common( std::vector< MSG_PANEL_ITEM >& aList ); + void GetMsgPanelInfoBase_Common( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ); /** * Helper for drawing the short netname in tracks */ @@ -365,7 +359,7 @@ public: SEGZONE* Next() const { return static_cast( Pnext ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; void Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE aDrawMode, const wxPoint& aOffset = ZeroOffset ) override; @@ -375,7 +369,7 @@ public: EDA_ITEM* Clone() const override; protected: - virtual void GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; }; @@ -441,7 +435,7 @@ public: return wxT( "VIA" ); } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; @@ -497,7 +491,7 @@ public: virtual void SwapData( BOARD_ITEM* aImage ) override; protected: - virtual void GetMsgPanelInfoBase( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfoBase( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; private: /// The bottom layer of the via (the top layer is in m_Layer) diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index ca2ae6c8c4..f6a7a4d2b4 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -810,7 +810,7 @@ bool ZONE_CONTAINER::HitTestFilledArea( const wxPoint& aRefPos ) const } -void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void ZONE_CONTAINER::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; @@ -1044,7 +1044,7 @@ bool ZONE_CONTAINER::AppendCorner( wxPoint aPosition, int aHoleIdx, bool aAllowD } -wxString ZONE_CONTAINER::GetSelectMenuText() const +wxString ZONE_CONTAINER::GetSelectMenuText( EDA_UNITS_T aUnits ) const { wxString text; @@ -1057,12 +1057,7 @@ wxString ZONE_CONTAINER::GetSelectMenuText() const else text << GetNetnameMsg(); - wxString msg; - msg.Printf( _( "Zone Outline %s on %s" ), - GetChars( text ), - GetChars( GetLayerName() ) ); - - return msg; + return wxString::Format( _( "Zone Outline %s on %s" ), text, GetLayerName() ); } diff --git a/pcbnew/class_zone.h b/pcbnew/class_zone.h index b6b9018c2a..af72b94a42 100644 --- a/pcbnew/class_zone.h +++ b/pcbnew/class_zone.h @@ -100,7 +100,7 @@ public: */ unsigned GetPriority() const { return m_priority; } - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; void SetLayerSet( LSET aLayerSet ); @@ -590,7 +590,7 @@ public: return m_RawPolysList; } - wxString GetSelectMenuText() const override; + wxString GetSelectMenuText( EDA_UNITS_T aUnits ) const override; BITMAP_DEF GetMenuImage() const override; diff --git a/pcbnew/controle.cpp b/pcbnew/controle.cpp index daafd02b77..49b905290b 100644 --- a/pcbnew/controle.cpp +++ b/pcbnew/controle.cpp @@ -236,7 +236,7 @@ BOARD_ITEM* PCB_BASE_FRAME::PcbGeneralLocateAndDisplay( int aHotKeyCode ) wxString text; item = (*m_Collector)[i]; - text = item->GetSelectMenuText(); + text = item->GetSelectMenuText( m_UserUnits ); BITMAP_DEF xpm = item->GetMenuImage(); diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index c2ba624746..51235c0cd6 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -215,8 +215,8 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event ) list << wxT(" (") << module->GetValue() << wxT(")"); list << wxT(" @ "); - list << CoordinateToString( module->GetPosition().x ), - list << wxT(", ") << CoordinateToString( module->GetPosition().y ), + list << MessageTextFromValue( m_units, module->GetPosition().x ), + list << wxT(", ") << MessageTextFromValue( m_units, module->GetPosition().y ), err_cnt++; if( ERR_CNT_MAX < err_cnt ) @@ -261,8 +261,8 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event ) list << wxT( " (" ) << module->GetValue() << wxT( ")" ); list << wxT( " @ " ); - list << CoordinateToString( module->GetPosition().x ), - list << wxT( ", " ) << CoordinateToString( module->GetPosition().y ), + list << MessageTextFromValue( m_units, module->GetPosition().x ), + list << wxT( ", " ) << MessageTextFromValue( m_units, module->GetPosition().y ), err_cnt++; if( ERR_CNT_MAX < err_cnt ) diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index f8e86a0df0..3bff6c1d21 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -716,11 +716,11 @@ void DIALOG_PAD_PROPERTIES::initValues() } // A small helper function, to display coordinates: -static wxString formatCoord( wxPoint aCoord ) +static wxString formatCoord( EDA_UNITS_T aUnits, wxPoint aCoord ) { return wxString::Format( "(X:%s Y:%s)", - CoordinateToString( aCoord.x, true ), - CoordinateToString( aCoord.y, true ) ); + MessageTextFromValue( aUnits, aCoord.x, true ), + MessageTextFromValue( aUnits, aCoord.y, true ) ); } void DIALOG_PAD_PROPERTIES::displayPrimitivesList() @@ -743,20 +743,20 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList() bs_info[jj].Empty(); bs_info[4] = wxString::Format( _( "width %s" ), - CoordinateToString( primitive.m_Thickness, true ) ); + MessageTextFromValue( m_units, primitive.m_Thickness, true ) ); switch( primitive.m_Shape ) { case S_SEGMENT: // usual segment : line with rounded ends bs_info[0] = _( "Segment" ); - bs_info[1] = _( "from " ) + formatCoord( primitive.m_Start ); - bs_info[2] = _( "to " ) + formatCoord( primitive.m_End ); + bs_info[1] = _( "from " ) + formatCoord( m_units, primitive.m_Start ); + bs_info[2] = _( "to " ) + formatCoord( m_units, primitive.m_End ); break; case S_ARC: // Arc with rounded ends bs_info[0] = _( "Arc" ); - bs_info[1] = _( "center " ) + formatCoord( primitive.m_Start ); // Center - bs_info[2] = _( "start " ) + formatCoord( primitive.m_End ); // Start point + bs_info[1] = _( "center " ) + formatCoord( m_units, primitive.m_Start );// Center + bs_info[2] = _( "start " ) + formatCoord( m_units, primitive.m_End ); // Start point bs_info[3] = wxString::Format( _( "angle %s" ), FMT_ANGLE( primitive.m_ArcAngle ) ); break; @@ -766,9 +766,9 @@ void DIALOG_PAD_PROPERTIES::displayPrimitivesList() else bs_info[0] = _( "circle" ); - bs_info[1] = formatCoord( primitive.m_Start ); + bs_info[1] = formatCoord( m_units, primitive.m_Start ); bs_info[2] = wxString::Format( _( "radius %s" ), - CoordinateToString( primitive.m_Radius, true ) ); + MessageTextFromValue( m_units, primitive.m_Radius, true ) ); break; case S_POLYGON: // polygon diff --git a/pcbnew/drc_item.cpp b/pcbnew/drc_item.cpp index 3514c4260e..5e13422999 100644 --- a/pcbnew/drc_item.cpp +++ b/pcbnew/drc_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2007 Dick Hollenbeck, dick@softplc.com - * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2015-2018 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 @@ -23,9 +23,6 @@ */ -/*************************************************/ -/* class_drc_item.cpp - DRC_ITEM class functions */ -/*************************************************/ #include #include @@ -143,22 +140,21 @@ wxString DRC_ITEM::GetErrorText() const return wxString( _( "Footprint has incorrect courtyard (not a closed shape)" ) ); default: - return wxString::Format( wxT( "Unknown DRC error code %d" ), m_ErrorCode ); + return wxString::Format( _( "Unknown DRC error code %d" ), m_ErrorCode ); } } -wxString DRC_ITEM::ShowCoord( const wxPoint& aPos ) +wxString DRC_ITEM::ShowCoord( EDA_UNITS_T aUnits, const wxPoint& aPos ) { - return wxString::Format( _( "@(%s, %s)" ), - GetChars( CoordinateToString( aPos.x ) ), - GetChars( CoordinateToString( aPos.y ) ) ); + return wxString::Format( wxT( "@(%s, %s)" ), + MessageTextFromValue( aUnits, aPos.x ), + MessageTextFromValue( aUnits, aPos.y ) ); } wxString DRC_ITEM::ShowHtml() const { - wxString ret; wxString mainText = m_MainText; // a wxHtmlWindows does not like < and > in the text to display // because these chars have a special meaning in html @@ -173,9 +169,9 @@ wxString DRC_ITEM::ShowHtml() const if( m_noCoordinate ) { // omit the coordinate, a NETCLASS has no location - ret.Printf( _( "%s
   %s" ), - GetChars( errText ), - GetChars( mainText ) ); + return wxString::Format( wxT( "%s
   %s" ), + errText, + mainText ); } else if( m_hasSecondItem ) { @@ -185,43 +181,43 @@ wxString DRC_ITEM::ShowHtml() const // an html fragment for the entire message in the listbox. feel free // to add color if you want: - ret.Printf( _( "%s
   %s: %s
   %s: %s" ), - GetChars( errText ), - GetChars( ShowCoord( m_MainPosition )), GetChars( mainText ), - GetChars( ShowCoord( m_AuxiliaryPosition )), GetChars( auxText ) ); + return wxString::Format( wxT( "%s
   %s: %s
   %s: %s" ), + errText, + ShowCoord( g_UserUnit, m_MainPosition ), + mainText, + ShowCoord( g_UserUnit, m_AuxiliaryPosition ), + auxText ); } else { - ret.Printf( _( "%s
   %s: %s" ), - GetChars( errText ), - GetChars( ShowCoord( m_MainPosition ) ), GetChars( mainText ) ); + return wxString::Format( wxT( "%s
   %s: %s" ), + errText, + ShowCoord( g_UserUnit, m_MainPosition ), + mainText ); } - - return ret; } wxString DRC_ITEM::ShowReport() const { - wxString ret; - if( m_hasSecondItem ) { - ret.Printf( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), - m_ErrorCode, - GetChars( GetErrorText() ), - GetChars( ShowCoord( m_MainPosition ) ), GetChars( m_MainText ), - GetChars( ShowCoord( m_AuxiliaryPosition ) ), GetChars( m_AuxiliaryText ) ); + return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n %s: %s\n" ), + m_ErrorCode, + GetErrorText(), + ShowCoord( g_UserUnit, m_MainPosition ), + m_MainText, + ShowCoord( g_UserUnit, m_AuxiliaryPosition ), + m_AuxiliaryText ); } else { - ret.Printf( wxT( "ErrType(%d): %s\n %s: %s\n" ), - m_ErrorCode, - GetChars( GetErrorText() ), - GetChars( ShowCoord( m_MainPosition ) ), GetChars( m_MainText ) ); + return wxString::Format( wxT( "ErrType(%d): %s\n %s: %s\n" ), + m_ErrorCode, + GetErrorText(), + ShowCoord( g_UserUnit, m_MainPosition ), + m_MainText ); } - - return ret; } diff --git a/pcbnew/footprint_edit_frame.cpp b/pcbnew/footprint_edit_frame.cpp index 2763619ebe..270980d2b7 100644 --- a/pcbnew/footprint_edit_frame.cpp +++ b/pcbnew/footprint_edit_frame.cpp @@ -983,7 +983,7 @@ void FOOTPRINT_EDIT_FRAME::UpdateMsgPanel() if( item ) { - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } else diff --git a/pcbnew/footprint_editor_utils.cpp b/pcbnew/footprint_editor_utils.cpp index 7f56617894..abd4a83bdd 100644 --- a/pcbnew/footprint_editor_utils.cpp +++ b/pcbnew/footprint_editor_utils.cpp @@ -139,7 +139,7 @@ BOARD_ITEM* FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay( int aHotKeyCode ) { item = (*m_Collector)[ii]; - wxString text = item->GetSelectMenuText(); + wxString text = item->GetSelectMenuText( g_UserUnit ); BITMAP_DEF xpm = item->GetMenuImage(); AddMenuItem( &itemMenu, diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 24727485b4..3b66e4e793 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -899,7 +899,7 @@ void FOOTPRINT_VIEWER_FRAME::UpdateMsgPanel() { MSG_PANEL_ITEMS items; - footprint->GetMsgPanelInfo( items ); + footprint->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } else diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 7ed587aa2d..afeba3d91f 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -1591,7 +1591,7 @@ void PCB_IO::format( TRACK* aTrack, int aNestLevel ) const const VIA* via = static_cast( aTrack ); BOARD* board = (BOARD*) via->GetParent(); - wxCHECK_RET( board != 0, wxT( "Via " ) + via->GetSelectMenuText() + + wxCHECK_RET( board != 0, wxT( "Via " ) + via->GetSelectMenuText( MILLIMETRES ) + wxT( " has no parent." ) ); m_out->Print( aNestLevel, "(via" ); diff --git a/pcbnew/netinfo.h b/pcbnew/netinfo.h index e3c7de7d76..5ba9a18807 100644 --- a/pcbnew/netinfo.h +++ b/pcbnew/netinfo.h @@ -247,7 +247,7 @@ public: * * @param aList is the list in which to place the status information. */ - void GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) override; /** * Function Clear diff --git a/pcbnew/netinfo_item.cpp b/pcbnew/netinfo_item.cpp index 98eb8368d4..8cedf499ec 100644 --- a/pcbnew/netinfo_item.cpp +++ b/pcbnew/netinfo_item.cpp @@ -85,7 +85,7 @@ void NETINFO_ITEM::SetClass( const NETCLASSPTR& aNetClass ) } -void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) +void NETINFO_ITEM::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_ITEM >& aList ) { wxString txt; double lengthnet = 0.0; // This is the length of tracks on pcb @@ -140,14 +140,14 @@ void NETINFO_ITEM::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) aList.push_back( MSG_PANEL_ITEM( _( "Vias" ), txt, BLUE ) ); // Displays the full net length (tracks on pcb + internal ICs connections ): - txt = ::MessageTextFromValue( g_UserUnit, lengthnet + lengthPadToDie ); + txt = MessageTextFromValue( aUnits, lengthnet + lengthPadToDie ); aList.push_back( MSG_PANEL_ITEM( _( "Net Length" ), txt, RED ) ); // Displays the net length of tracks only: - txt = ::MessageTextFromValue( g_UserUnit, lengthnet ); + txt = MessageTextFromValue( aUnits, lengthnet ); aList.push_back( MSG_PANEL_ITEM( _( "On Board" ), txt, RED ) ); // Displays the net length of internal ICs connections (wires inside ICs): - txt = ::MessageTextFromValue( g_UserUnit, lengthPadToDie ); + txt = MessageTextFromValue( aUnits, lengthPadToDie, true ); aList.push_back( MSG_PANEL_ITEM( _( "In Package" ), txt, RED ) ); } diff --git a/pcbnew/onleftclick.cpp b/pcbnew/onleftclick.cpp index 252c573678..8dd2b0507e 100644 --- a/pcbnew/onleftclick.cpp +++ b/pcbnew/onleftclick.cpp @@ -212,7 +212,7 @@ void PCB_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition ) if( net ) { MSG_PANEL_ITEMS items; - net->GetMsgPanelInfo( items ); + net->GetMsgPanelInfo( m_UserUnits, items ); SetMsgPanel( items ); } } diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index 4cca8684f5..6466b87430 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -737,7 +737,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFootprints( MODULE* aModule, wxMenu* menu sub_menu_footprint = new wxMenu; - msg = aModule->GetSelectMenuText(); + msg = aModule->GetSelectMenuText( m_UserUnits ); AddMenuItem( menu, sub_menu_footprint, -1, msg, KiBitmap( module_xpm ) ); if( !flags ) @@ -830,7 +830,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpTexts( TEXTE_MODULE* FpText, wxMenu* me wxMenu* sub_menu_Fp_text; int flags = FpText->GetFlags(); - wxString msg = FpText->GetSelectMenuText(); + wxString msg = FpText->GetSelectMenuText( m_UserUnits ); sub_menu_Fp_text = new wxMenu; @@ -894,7 +894,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForFpPads( D_PAD* Pad, wxMenu* menu ) SetCurrentNetClass( Pad->GetNetClassName() ); - wxString msg = Pad->GetSelectMenuText(); + wxString msg = Pad->GetSelectMenuText( m_UserUnits ); sub_menu_Pad = new wxMenu; AddMenuItem( menu, sub_menu_Pad, -1, msg, KiBitmap( pad_xpm ) ); @@ -940,7 +940,7 @@ void PCB_EDIT_FRAME::createPopUpMenuForTexts( TEXTE_PCB* Text, wxMenu* menu ) wxMenu* sub_menu_Text; int flags = Text->GetFlags(); - wxString msg = Text->GetSelectMenuText(); + wxString msg = Text->GetSelectMenuText( m_UserUnits ); sub_menu_Text = new wxMenu; diff --git a/pcbnew/pcb_base_frame.cpp b/pcbnew/pcb_base_frame.cpp index 676f255ed6..4eb3a60535 100644 --- a/pcbnew/pcb_base_frame.cpp +++ b/pcbnew/pcb_base_frame.cpp @@ -756,14 +756,14 @@ void PCB_BASE_FRAME::UpdateMsgPanel() if( item ) { - item->GetMsgPanelInfo( items ); + item->GetMsgPanelInfo( m_UserUnits, items ); } else // show general information about the board { if( IsGalCanvasActive() ) - GetGalCanvas()->GetMsgPanelInfo( items ); + GetGalCanvas()->GetMsgPanelInfo( m_UserUnits, items ); else - m_Pcb->GetMsgPanelInfo( items ); + m_Pcb->GetMsgPanelInfo( m_UserUnits, items ); } SetMsgPanel( items ); diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 03f5432b66..69aa4aa342 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -315,7 +315,7 @@ void PCB_DRAW_PANEL_GAL::SyncLayersVisibility( const BOARD* aBoard ) } -void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( std::vector& aList ) +void PCB_DRAW_PANEL_GAL::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) { BOARD* board = static_cast( m_parent )->GetBoard(); wxString txt; diff --git a/pcbnew/pcb_draw_panel_gal.h b/pcbnew/pcb_draw_panel_gal.h index 0d02580d62..c580e6b58d 100644 --- a/pcbnew/pcb_draw_panel_gal.h +++ b/pcbnew/pcb_draw_panel_gal.h @@ -27,6 +27,7 @@ #include #include +#include namespace KIGFX { @@ -93,7 +94,7 @@ public: void SyncLayersVisibility( const BOARD* aBoard ); ///> @copydoc EDA_DRAW_PANEL_GAL::GetMsgPanelInfo() - void GetMsgPanelInfo( std::vector& aList ) override; + void GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector& aList ) override; ///> @copydoc EDA_DRAW_PANEL_GAL::OnShow() void OnShow() override; diff --git a/pcbnew/router/pns_kicad_iface.cpp b/pcbnew/router/pns_kicad_iface.cpp index 4e7a5d1188..38117a4191 100644 --- a/pcbnew/router/pns_kicad_iface.cpp +++ b/pcbnew/router/pns_kicad_iface.cpp @@ -798,7 +798,8 @@ bool PNS_KICAD_IFACE::syncZone( PNS::NODE* aWorld, ZONE_CONTAINER* aZone ) aZone->GetPosition().x, aZone->GetPosition().y ), KIDIALOG::KD_WARNING ); dlg.ShowDetailedText( wxString::Format( _( "%s\nThis zone cannot be handled by the track layout tool.\n" - "Please verify it is not a self-intersecting polygon." ), aZone->GetSelectMenuText() ) ); + "Please verify it is not a self-intersecting polygon." ), + aZone->GetSelectMenuText( g_UserUnit ) ) ); dlg.DoNotShowCheckbox(); dlg.ShowModal(); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index a3e7df3cf9..9395dae90a 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -988,7 +988,7 @@ static bool highlightNet( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition, if( netinfo ) { MSG_PANEL_ITEMS items; - netinfo->GetMsgPanelInfo( items ); + netinfo->GetMsgPanelInfo( frame->GetUserUnits(), items ); frame->SetMsgPanel( items ); frame->SendCrossProbeNetName( netinfo->GetNetname() ); } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 43b8400907..9703a0ae05 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -1417,7 +1417,7 @@ BOARD_ITEM* SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, { wxString text; BOARD_ITEM* item = ( *aCollector )[i]; - text = item->GetSelectMenuText(); + text = item->GetSelectMenuText( m_frame->GetUserUnits() ); wxString menuText = wxString::Format("&%d. %s", i + 1, text ); menu.Add( menuText, i + 1, item->GetMenuImage() );