Restore units to a bunch of wxGrids.

Fixes https://gitlab.com/kicad/code/kicad/issues/10063
This commit is contained in:
Jeff Young 2021-12-21 19:07:28 +00:00
parent f696c4ddfc
commit 8b52e969d6
8 changed files with 32 additions and 27 deletions

View File

@ -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() );

View File

@ -416,7 +416,7 @@ wxString FIELDS_GRID_TABLE<T>::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<T>::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

View File

@ -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<MSG_PANEL_ITEM>& 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::vector<MSG_PANEL_ITE
aList.emplace_back( _( "Style" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
// Display pin length
aList.emplace_back( _( "Length" ), StringFromValue( aFrame->GetUserUnits(), 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::vector<MSG_PANEL_ITE
wxPoint pinpos = GetPosition();
pinpos.y = -pinpos.y; // Display coords are top to bottom; lib item coords are bottom to top
aList.emplace_back( _( "Pos X" ), MessageTextFromValue( aFrame->GetUserUnits(), 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 ) );
}

View File

@ -188,6 +188,7 @@ wxString SCH_PIN::GetSelectMenuText( EDA_UNITS aUnits ) const
void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{
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::vector<MSG_PANEL_ITE
aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
aList.emplace_back( _( "Length" ), StringFromValue( aFrame->GetUserUnits(), GetLength() ) );
aList.emplace_back( _( "Length" ), MessageTextFromValue( units, GetLength() ), true );
int i = PinOrientationIndex( GetOrientation() );
aList.emplace_back( _( "Orientation" ), PinOrientationName( (unsigned) i ) );

View File

@ -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<wxTextCtrl*>( 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 )
{

View File

@ -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 );
}

View File

@ -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 );
}
}

View File

@ -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