From 8b52e969d63bff4186c43b1a5b78fc70b94b50e0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 21 Dec 2021 19:07:28 +0000 Subject: [PATCH] Restore units to a bunch of wxGrids. Fixes https://gitlab.com/kicad/code/kicad/issues/10063 --- eeschema/dialogs/dialog_lib_edit_pin_table.cpp | 6 +++--- eeschema/fields_grid_table.cpp | 6 +++--- eeschema/lib_pin.cpp | 8 +++++--- eeschema/sch_pin.cpp | 5 +++-- pcbnew/board_stackup_manager/panel_board_stackup.cpp | 8 +++++--- pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp | 4 ++-- pcbnew/dialogs/panel_setup_tracks_and_vias.cpp | 12 ++++++------ pcbnew/fp_text_grid_table.cpp | 10 +++++----- 8 files changed, 32 insertions(+), 27 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp index 3d0b289403..8ec47b9082 100644 --- a/eeschema/dialogs/dialog_lib_edit_pin_table.cpp +++ b/eeschema/dialogs/dialog_lib_edit_pin_table.cpp @@ -109,13 +109,13 @@ public: val = StringFromValue( aUserUnits, pin->GetNameTextSize(), true ); break; case COL_LENGTH: - val = StringFromValue( aUserUnits, pin->GetLength() ); + val = StringFromValue( aUserUnits, pin->GetLength(), true ); break; case COL_POSX: - val = StringFromValue( aUserUnits, pin->GetPosition().x ); + val = StringFromValue( aUserUnits, pin->GetPosition().x, true ); break; case COL_POSY: - val = StringFromValue( aUserUnits, pin->GetPosition().y ); + val = StringFromValue( aUserUnits, pin->GetPosition().y, true ); break; case COL_VISIBLE: val = StringFromBool( pin->IsVisible() ); diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 13cf012ed9..0af658a4d8 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -416,7 +416,7 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) return StringFromBool( field.IsBold() ); case FDC_TEXT_SIZE: - return StringFromValue( m_userUnits, field.GetTextSize().GetHeight() ); + return StringFromValue( m_userUnits, field.GetTextSize().GetHeight(), true ); case FDC_ORIENTATION: switch ( (int) field.GetTextAngle() ) @@ -428,10 +428,10 @@ wxString FIELDS_GRID_TABLE::GetValue( int aRow, int aCol ) break; case FDC_POSX: - return StringFromValue( m_userUnits, field.GetTextPos().x ); + return StringFromValue( m_userUnits, field.GetTextPos().x, true ); case FDC_POSY: - return StringFromValue( m_userUnits, field.GetTextPos().y ); + return StringFromValue( m_userUnits, field.GetTextPos().y, true ); default: // we can't assert here because wxWidgets sometimes calls this without checking diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 50be185118..81a2db2732 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -1036,6 +1036,8 @@ void LIB_PIN::Plot( PLOTTER* aPlotter, const wxPoint& aPffset, bool aFill, void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { + EDA_UNITS units = aFrame->GetUserUnits(); + LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); aList.emplace_back( _( "Name" ), UnescapeString( GetShownName() ) ); @@ -1046,7 +1048,7 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), m_length ) ); + aList.emplace_back( _( "Length" ), MessageTextFromValue( units, m_length, true ) ); int i = PinOrientationIndex( m_orientation ); aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) ); @@ -1054,8 +1056,8 @@ void LIB_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), pinpos.x ) ); - aList.emplace_back( _( "Pos Y" ), MessageTextFromValue( aFrame->GetUserUnits(), pinpos.y ) ); + aList.emplace_back( _( "Pos X" ), MessageTextFromValue( units, pinpos.x, true ) ); + aList.emplace_back( _( "Pos Y" ), MessageTextFromValue( units, pinpos.y, true ) ); } diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 6bc9b482c3..3ea686ee68 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -188,7 +188,8 @@ wxString SCH_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector& aList ) { - wxString msg; + EDA_UNITS units = aFrame->GetUserUnits(); + wxString msg; aList.emplace_back( _( "Type" ), _( "Pin" ) ); @@ -215,7 +216,7 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetUserUnits(), GetLength() ) ); + aList.emplace_back( _( "Length" ), MessageTextFromValue( units, GetLength() ), true ); int i = PinOrientationIndex( GetOrientation() ); aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) ); diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index 89aafaa92a..724f99c86b 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -215,7 +215,7 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve if( items_candidate.size() ) { int thickness_layer = ( iu_thickness - min_thickness ) / items_candidate.size(); - wxString txt = StringFromValue( m_frame->GetUserUnits(), thickness_layer ); + wxString txt = StringFromValue( m_frame->GetUserUnits(), thickness_layer, true ); for( BOARD_STACKUP_ROW_UI_ITEM* ui_item : items_candidate ) { @@ -527,8 +527,10 @@ void PANEL_SETUP_BOARD_STACKUP::synchronizeWithBoard( bool aFullSync ) wxTextCtrl* textCtrl = dynamic_cast( ui_row_item.m_ThicknessCtrl ); if( textCtrl ) - textCtrl->SetValue( StringFromValue( m_units, - item->GetThickness( sub_item ), true ) ); + { + textCtrl->SetValue( StringFromValue( m_units, item->GetThickness( sub_item ), + true ) ); + } if( item->GetType() == BS_ITEM_TYPE_DIELECTRIC ) { diff --git a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp index bb6422d3f6..4c55fa74b0 100644 --- a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp @@ -295,10 +295,10 @@ bool DIALOG_PAD_PRIMITIVE_POLY_PROPS::TransferDataToWindow() msg.Printf( "Corner %d", row+1 ); m_gridCornersList->SetRowLabelValue( row, msg ); - msg = StringFromValue( GetUserUnits(), m_currPoints[row].x ); + msg = StringFromValue( GetUserUnits(), m_currPoints[row].x, true ); m_gridCornersList->SetCellValue( row, 0, msg ); - msg = StringFromValue( GetUserUnits(), m_currPoints[row].y ); + msg = StringFromValue( GetUserUnits(), m_currPoints[row].y, true ); m_gridCornersList->SetCellValue( row, 1, msg ); } diff --git a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp index 2a29f7c42a..1984cc2ae9 100644 --- a/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp +++ b/pcbnew/dialogs/panel_setup_tracks_and_vias.cpp @@ -281,7 +281,7 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendTrackWidth( const int aWidth ) m_trackWidthsGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth ); + wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true ); m_trackWidthsGrid->SetCellValue( i, TR_WIDTH_COL, val ); } @@ -292,12 +292,12 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendViaSize( const int aSize, const int aDri m_viaSizesGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aSize ); + wxString val = StringFromValue( m_Frame->GetUserUnits(), aSize, true ); m_viaSizesGrid->SetCellValue( i, VIA_SIZE_COL, val ); if( aDrill > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aDrill ); + val = StringFromValue( m_Frame->GetUserUnits(), aDrill, true ); m_viaSizesGrid->SetCellValue( i, VIA_DRILL_COL, val ); } } @@ -310,18 +310,18 @@ void PANEL_SETUP_TRACKS_AND_VIAS::AppendDiffPairs( const int aWidth, const int a m_diffPairsGrid->AppendRows( 1 ); - wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth ); + wxString val = StringFromValue( m_Frame->GetUserUnits(), aWidth, true ); m_diffPairsGrid->SetCellValue( i, DP_WIDTH_COL, val ); if( aGap > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aGap ); + val = StringFromValue( m_Frame->GetUserUnits(), aGap, true ); m_diffPairsGrid->SetCellValue( i, DP_GAP_COL, val ); } if( aViaGap > 0 ) { - val = StringFromValue( m_Frame->GetUserUnits(), aViaGap ); + val = StringFromValue( m_Frame->GetUserUnits(), aViaGap, true ); m_diffPairsGrid->SetCellValue( i, DP_VIA_GAP_COL, val ); } } diff --git a/pcbnew/fp_text_grid_table.cpp b/pcbnew/fp_text_grid_table.cpp index 882f8b9b6a..b365638006 100644 --- a/pcbnew/fp_text_grid_table.cpp +++ b/pcbnew/fp_text_grid_table.cpp @@ -190,13 +190,13 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol ) return text.GetText(); case FPT_WIDTH: - return StringFromValue( m_userUnits, text.GetTextWidth() ); + return StringFromValue( m_userUnits, text.GetTextWidth(), true ); case FPT_HEIGHT: - return StringFromValue( m_userUnits, text.GetTextHeight() ); + return StringFromValue( m_userUnits, text.GetTextHeight(), true ); case FPT_THICKNESS: - return StringFromValue( m_userUnits, text.GetTextThickness() ); + return StringFromValue( m_userUnits, text.GetTextThickness(), true ); case FPT_LAYER: return text.GetLayerName(); @@ -206,10 +206,10 @@ wxString FP_TEXT_GRID_TABLE::GetValue( int aRow, int aCol ) true ); case FPT_XOFFSET: - return StringFromValue( m_userUnits, text.GetPos0().x ); + return StringFromValue( m_userUnits, text.GetPos0().x, true ); case FPT_YOFFSET: - return StringFromValue( m_userUnits, text.GetPos0().y ); + return StringFromValue( m_userUnits, text.GetPos0().y, true ); default: // we can't assert here because wxWidgets sometimes calls this without checking