diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index a56e28e73b..62f59648e6 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -86,6 +86,8 @@ protected: m_layerFilterOpt->SetValue( true ); } + void onUnitsChanged( wxCommandEvent& aEvent ); + private: void visitItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem ); void processItem( PICKED_ITEMS_LIST* aUndoList, PCB_TRACK* aItem ); @@ -108,7 +110,7 @@ private: DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParent ) : DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE( aParent ) { - m_parent = aParent; + m_parent = aParent; m_brd = m_parent->GetBoard(); m_originalColWidths = new int[ m_netclassGrid->GetNumberCols() ]; @@ -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 ), nullptr, this ); + m_parent->Bind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this ); + 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 ), nullptr, this ); + m_parent->Unbind( UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this ); + 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() { // 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() { #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_VIASIZE, _( "Via Size" ) ); diff --git a/pcbnew/dialogs/dialog_track_via_properties.cpp b/pcbnew/dialogs/dialog_track_via_properties.cpp index 165f6af4b8..70f13987cc 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.cpp +++ b/pcbnew/dialogs/dialog_track_via_properties.cpp @@ -298,7 +298,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen m_netSelector->Disable(); } - m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); + m_DesignRuleViasUnit->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) ); 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++ ) { VIA_DIMENSION* viaDimension = &aParent->GetDesignSettings().m_ViasDimensionsList[ii]; - wxString msg = StringFromValue( m_units, viaDimension->m_Diameter, false ) - + " / " + StringFromValue( m_units, viaDimension->m_Drill, false ); + wxString msg = StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Diameter ) + + " / " + StringFromValue( m_frame->GetUserUnits(), viaDimension->m_Drill ); m_DesignRuleViasCtrl->Append( msg, viaDimension ); if( viaSelection == wxNOT_FOUND @@ -341,7 +341,7 @@ DIALOG_TRACK_VIA_PROPERTIES::DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParen if( m_tracks ) { - m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_units ) ); + m_DesignRuleWidthsUnits->SetLabel( GetAbbreviatedUnitsLabel( m_frame->GetUserUnits() ) ); 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++ ) { 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 ); 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_frame->Bind( UNITS_CHANGED, &DIALOG_TRACK_VIA_PROPERTIES::onUnitsChanged, this ); + // Now all widgets have the size fixed, call 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& changingPads ) { wxString msg; diff --git a/pcbnew/dialogs/dialog_track_via_properties.h b/pcbnew/dialogs/dialog_track_via_properties.h index d878996ab0..04b063cf4c 100644 --- a/pcbnew/dialogs/dialog_track_via_properties.h +++ b/pcbnew/dialogs/dialog_track_via_properties.h @@ -38,6 +38,8 @@ public: DIALOG_TRACK_VIA_PROPERTIES( PCB_BASE_FRAME* aParent, const PCB_SELECTION& aItems, COMMIT& aCommit ); + ~DIALOG_TRACK_VIA_PROPERTIES(); + bool TransferDataFromWindow() override; private: @@ -49,6 +51,8 @@ private: void onViaSelect( wxCommandEvent& aEvent ) override; void onViaEdit( wxCommandEvent& aEvent ) override; + void onUnitsChanged( wxCommandEvent& aEvent ); + bool confirmPadChange( const std::vector& connectedPads ); PCB_BASE_FRAME* m_frame;