Hot-update units in track editing dialogs.

Fixes https://gitlab.com/kicad/code/kicad/issues/10099

(cherry picked from commit 4e8a7fc911)
This commit is contained in:
Jeff Young 2021-12-23 13:11:26 +00:00
parent 1b033d56a7
commit 93c48b9d46
3 changed files with 88 additions and 7 deletions

View File

@ -86,6 +86,8 @@ protected:
m_layerFilterOpt->SetValue( true ); m_layerFilterOpt->SetValue( true );
} }
void onUnitsChanged( wxCommandEvent& aEvent );
private: private:
void visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem ); void visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem );
void processItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem ); void processItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem );
@ -139,6 +141,8 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
nullptr, this ); nullptr, this );
m_parent->Bind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this );
finishDialogSettings(); finishDialogSettings();
} }
@ -159,10 +163,32 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ),
nullptr, this ); nullptr, this );
m_parent->Unbind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this );
delete[] m_originalColWidths; delete[] m_originalColWidths;
} }
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged( wxCommandEvent& aEvent )
{
int trackSel = m_trackWidthSelectBox->GetSelection();
int viaSel = m_viaSizesSelectBox->GetSelection();
m_parent->UpdateTrackWidthSelectBox( m_trackWidthSelectBox, false );
m_trackWidthSelectBox->Append( INDETERMINATE_ACTION );
m_parent->UpdateViaSizeSelectBox( m_viaSizesSelectBox, false );
m_viaSizesSelectBox->Append( INDETERMINATE_ACTION );
m_trackWidthSelectBox->SetSelection( trackSel );
m_viaSizesSelectBox->SetSelection( viaSel );
m_netclassGrid->ClearGrid();
buildNetclassesGrid();
aEvent.Skip();
}
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists() void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
{ {
// Populate the net filter list with net names // Populate the net filter list with net names
@ -196,7 +222,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid() void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildNetclassesGrid()
{ {
#define SET_NETCLASS_VALUE( row, col, val ) \ #define SET_NETCLASS_VALUE( row, col, val ) \
m_netclassGrid->SetCellValue( row, col, StringFromValue( GetUserUnits(), val, true ) ) m_netclassGrid->SetCellValue( row, col, StringFromValue( m_parent->GetUserUnits(), val, true ) )
m_netclassGrid->SetCellValue( 0, GRID_TRACKSIZE, _( "Track Width" ) ); m_netclassGrid->SetCellValue( 0, GRID_TRACKSIZE, _( "Track Width" ) );
m_netclassGrid->SetCellValue( 0, GRID_VIASIZE, _( "Via Size" ) ); m_netclassGrid->SetCellValue( 0, GRID_VIASIZE, _( "Via Size" ) );

View File

@ -298,7 +298,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
m_netSelector->Disable(); m_netSelector->Disable();
} }
m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
int viaSelection = wxNOT_FOUND; int viaSelection = wxNOT_FOUND;
@ -306,8 +306,8 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ ) for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
{ {
VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii]; VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii];
wxString msg = StringFromValue( m_units, viaDimension->m_Diameter, false ) wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter )
+ " / " + StringFromValue( m_units, viaDimension->m_Drill, false ); + " / " + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill );
m_DesignRuleViasCtrl->Append( msg, viaDimension ); m_DesignRuleViasCtrl->Append( msg, viaDimension );
if( viaSelection == wxNOT_FOUND if( viaSelection == wxNOT_FOUND
@ -341,7 +341,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
if( m_tracks ) if( m_tracks )
{ {
m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
int widthSelection = wxNOT_FOUND; int widthSelection = wxNOT_FOUND;
@ -349,7 +349,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ ) for( unsigned ii = 1; ii < aParent->GetDesignSettings().m_TrackWidthList.size(); ii++ )
{ {
int width = aParent->GetDesignSettings().m_TrackWidthList[ii]; int width = aParent->GetDesignSettings().m_TrackWidthList[ii];
wxString msg = StringFromValue( m_units, width, false ); wxString msg = StringFromValue( m_frame->GetUserUnits(), width );
m_DesignRuleWidthsCtrl->Append( msg ); m_DesignRuleWidthsCtrl->Append( msg );
if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width ) if( widthSelection == wxNOT_FOUND && m_trackWidth.GetValue() == width )
@ -379,11 +379,62 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen
m_StdButtonsOK->SetDefault(); m_StdButtonsOK->SetDefault();
m_frame->Bind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
// Now all widgets have the size fixed, call FinishDialogSettings // Now all widgets have the size fixed, call FinishDialogSettings
finishDialogSettings(); finishDialogSettings();
} }
DIALOG_TRACK_VIA_PROPERTIES::~DIALOG_TRACK_VIA_PROPERTIES()
{
m_frame->Unbind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this );
}
void DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged( wxCommandEvent& aEvent )
{
if( m_vias )
{
int viaSel = m_DesignRuleViasCtrl->GetSelection();
m_DesignRuleViasCtrl->Clear();
// 0 is the netclass place-holder
for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_ViasDimensionsList.size(); ii++ )
{
VIA_DIMENSION* viaDimension = &m_frame->GetDesignSettings().m_ViasDimensionsList[ii];
wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter )
+ " / " + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill );
m_DesignRuleViasCtrl->Append( msg, viaDimension );
}
m_DesignRuleViasCtrl->SetSelection( viaSel );
m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
}
if( m_tracks )
{
int trackSel = m_DesignRuleWidthsCtrl->GetSelection();
m_DesignRuleWidthsCtrl->Clear();
// 0 is the netclass place-holder
for( unsigned ii = 1; ii < m_frame->GetDesignSettings().m_TrackWidthList.size(); ii++ )
{
int width = m_frame->GetDesignSettings().m_TrackWidthList[ii];
wxString msg = StringFromValue( m_frame->GetUserUnits(), width );
m_DesignRuleWidthsCtrl->Append( msg );
}
m_DesignRuleWidthsCtrl->SetSelection( trackSel );
m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) );
}
aEvent.Skip();
}
bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads ) bool DIALOG_TRACK_VIA_PROPERTIES::confirmPadChange( const std::vector<PAD*>& changingPads )
{ {
wxString msg; wxString msg;

View File

@ -38,6 +38,8 @@ public:
DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const PCB_SELECTION& aItems, DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const PCB_SELECTION& aItems,
COMMIT& aCommit ); COMMIT& aCommit );
~DIALOG_TRACK_VIA_PROPERTIES();
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
private: private:
@ -49,6 +51,8 @@ private:
void onViaSelect( wxCommandEvent& aEvent ) override; void onViaSelect( wxCommandEvent& aEvent ) override;
void onViaEdit( wxCommandEvent& aEvent ) override; void onViaEdit( wxCommandEvent& aEvent ) override;
void onUnitsChanged( wxCommandEvent& aEvent );
bool confirmPadChange( const std::vector<PAD*>& connectedPads ); bool confirmPadChange( const std::vector<PAD*>& connectedPads );
PCB_BASE_FRAME* m_frame; PCB_BASE_FRAME* m_frame;