Merge branch 'edit_tracks_add_selection' into 'master'

Draft: Pcbnew: Add "Add to selection" feature for Edit Tracks and Vias dialog

See merge request kicad/code/kicad!1868
This commit is contained in:
RigoLigoRLC 2024-07-01 09:06:38 +00:00
commit c448f65dbf
4 changed files with 1835 additions and 1738 deletions

View File

@ -37,33 +37,35 @@
// Columns of netclasses grid // Columns of netclasses grid
enum { enum
{
GRID_NAME = 0, GRID_NAME = 0,
GRID_TRACKSIZE, GRID_TRACKSIZE,
GRID_VIASIZE, GRID_VIASIZE,
GRID_VIADRILL, GRID_VIADRILL,
GRID_uVIASIZE, GRID_uVIASIZE,
GRID_uVIADRILL, GRID_uVIADRILL,
GRID_DIFF_PAIR_WIDTH, // not currently included in grid GRID_DIFF_PAIR_WIDTH, // not currently included in grid
GRID_DIFF_PAIR_GAP, // not currently included in grid GRID_DIFF_PAIR_GAP, // not currently included in grid
GRID_DIFF_PAIR_VIA_GAP // not currently included in grid GRID_DIFF_PAIR_VIA_GAP // not currently included in grid
}; };
// Globals to remember control settings during a session // Globals to remember control settings during a session
static bool g_modifyTracks = true; static bool g_modifyTracks = true;
static bool g_modifyVias = true; static bool g_modifyVias = true;
static bool g_filterByNetclass; static bool g_filterByNetclass;
static wxString g_netclassFilter; static wxString g_netclassFilter;
static bool g_filterByNet; static bool g_filterByNet;
static wxString g_netFilter; static wxString g_netFilter;
static bool g_filterByLayer; static bool g_filterByLayer;
static int g_layerFilter; static int g_layerFilter;
static bool g_filterByTrackWidth = false; static bool g_filterByTrackWidth = false;
static int g_trackWidthFilter = 0; static int g_trackWidthFilter = 0;
static bool g_filterByViaSize = false; static bool g_filterByViaSize = false;
static int g_viaSizeFilter = 0; static int g_viaSizeFilter = 0;
static bool g_filterSelected = false; static bool g_filterSelected = false;
static bool g_selectMatchedItems = false;
class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS : public DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS : public DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE
@ -87,10 +89,7 @@ protected:
{ {
m_filterByTrackWidth->SetValue( true ); m_filterByTrackWidth->SetValue( true );
} }
void OnViaSizeText( wxCommandEvent& aEvent ) override void OnViaSizeText( wxCommandEvent& aEvent ) override { m_filterByViaSize->SetValue( true ); }
{
m_filterByViaSize->SetValue( true );
}
void onUnitsChanged( wxCommandEvent& aEvent ); void onUnitsChanged( wxCommandEvent& aEvent );
@ -101,10 +100,7 @@ private:
bool TransferDataToWindow() override; bool TransferDataToWindow() override;
bool TransferDataFromWindow() override; bool TransferDataFromWindow() override;
void OnNetFilterSelect( wxCommandEvent& event ) void OnNetFilterSelect( wxCommandEvent& event ) { m_netFilterOpt->SetValue( true ); }
{
m_netFilterOpt->SetValue( true );
}
void buildFilterLists(); void buildFilterLists();
@ -113,10 +109,10 @@ private:
BOARD* m_brd; BOARD* m_brd;
PCB_SELECTION m_selection; PCB_SELECTION m_selection;
UNIT_BINDER m_trackWidthFilter; UNIT_BINDER m_trackWidthFilter;
UNIT_BINDER m_viaSizeFilter; UNIT_BINDER m_viaSizeFilter;
std::vector<BOARD_ITEM*> m_items_changed; // a list of modified items std::vector<BOARD_ITEM*> m_items_changed; // a list of modified items
}; };
@ -143,9 +139,10 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS( PCB_EDIT
SetupStandardButtons(); SetupStandardButtons();
m_netFilter->Connect( NET_SELECTED, m_netFilter->Connect(
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NET_SELECTED,
nullptr, this ); wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), nullptr,
this );
m_parent->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, m_parent->Bind( EDA_EVT_UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged,
this ); this );
@ -169,13 +166,15 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::~DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS()
g_filterByViaSize = m_filterByViaSize->GetValue(); g_filterByViaSize = m_filterByViaSize->GetValue();
g_viaSizeFilter = m_viaSizeFilter.GetIntValue(); g_viaSizeFilter = m_viaSizeFilter.GetIntValue();
g_filterSelected = m_selectedItemsFilter->GetValue(); g_filterSelected = m_selectedItemsFilter->GetValue();
g_selectMatchedItems = m_addToSelection->GetValue();
m_netFilter->Disconnect( NET_SELECTED, m_netFilter->Disconnect(
wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), NET_SELECTED,
nullptr, this ); wxCommandEventHandler( DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::OnNetFilterSelect ), nullptr,
this );
m_parent->Unbind( EDA_EVT_UNITS_CHANGED, m_parent->Unbind( EDA_EVT_UNITS_CHANGED, &DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged,
&DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onUnitsChanged, this ); this );
} }
@ -211,7 +210,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
netclassNames.push_back( settings->m_DefaultNetClass->GetName() ); netclassNames.push_back( settings->m_DefaultNetClass->GetName() );
for( const auto& [ name, netclass ] : settings->m_NetClasses ) for( const auto& [name, netclass] : settings->m_NetClasses )
netclassNames.push_back( name ); netclassNames.push_back( name );
m_netclassFilter->Set( netclassNames ); m_netclassFilter->Set( netclassNames );
@ -229,8 +228,8 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::buildFilterLists()
bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow() bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
{ {
PCB_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PCB_SELECTION_TOOL>(); PCB_SELECTION_TOOL* selTool = m_parent->GetToolManager()->GetTool<PCB_SELECTION_TOOL>();
m_selection = selTool->GetSelection(); m_selection = selTool->GetSelection();
BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_selection.Front() ); BOARD_CONNECTED_ITEM* item = dynamic_cast<BOARD_CONNECTED_ITEM*>( m_selection.Front() );
m_tracks->SetValue( g_modifyTracks ); m_tracks->SetValue( g_modifyTracks );
m_vias->SetValue( g_modifyVias ); m_vias->SetValue( g_modifyVias );
@ -257,7 +256,7 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
else if( item ) else if( item )
{ {
if( item->Type() == PCB_ZONE_T ) // a zone can be on more than one layer if( item->Type() == PCB_ZONE_T ) // a zone can be on more than one layer
m_layerFilter->SetLayerSelection( static_cast<ZONE*>(item)->GetFirstLayer() ); m_layerFilter->SetLayerSelection( static_cast<ZONE*>( item )->GetFirstLayer() );
else else
m_layerFilter->SetLayerSelection( item->GetLayer() ); m_layerFilter->SetLayerSelection( item->GetLayer() );
} }
@ -279,6 +278,7 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataToWindow()
m_layerCtrl->SetStringSelection( INDETERMINATE_ACTION ); m_layerCtrl->SetStringSelection( INDETERMINATE_ACTION );
m_selectedItemsFilter->SetValue( g_filterSelected ); m_selectedItemsFilter->SetValue( g_filterSelected );
m_addToSelection->SetValue( g_selectMatchedItems );
wxCommandEvent dummy; wxCommandEvent dummy;
onActionButtonChange( dummy ); onActionButtonChange( dummy );
@ -302,7 +302,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::onActionButtonChange( wxCommandEvent& e
void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoList, void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoList,
PCB_TRACK* aItem ) PCB_TRACK* aItem )
{ {
BOARD_DESIGN_SETTINGS& brdSettings = m_brd->GetDesignSettings(); BOARD_DESIGN_SETTINGS& brdSettings = m_brd->GetDesignSettings();
bool isTrack = aItem->Type() == PCB_TRACE_T; bool isTrack = aItem->Type() == PCB_TRACE_T;
@ -314,7 +314,7 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
if( ( isArc || isTrack ) && m_trackWidthCtrl->GetStringSelection() != INDETERMINATE_ACTION ) if( ( isArc || isTrack ) && m_trackWidthCtrl->GetStringSelection() != INDETERMINATE_ACTION )
{ {
unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex(); unsigned int prevTrackWidthIndex = brdSettings.GetTrackWidthIndex();
int trackWidthIndex = m_trackWidthCtrl->GetSelection(); int trackWidthIndex = m_trackWidthCtrl->GetSelection();
if( trackWidthIndex >= 0 ) if( trackWidthIndex >= 0 )
brdSettings.SetTrackWidthIndex( static_cast<unsigned>( trackWidthIndex + 1 ) ); brdSettings.SetTrackWidthIndex( static_cast<unsigned>( trackWidthIndex + 1 ) );
@ -354,6 +354,11 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::processItem( PICKED_ITEMS_LIST* aUndoLi
m_parent->SetTrackSegmentWidth( aItem, aUndoList, true ); m_parent->SetTrackSegmentWidth( aItem, aUndoList, true );
} }
if( m_addToSelection->GetValue() )
{
m_parent->GetToolManager()->GetTool<PCB_SELECTION_TOOL>()->select( aItem );
}
m_items_changed.push_back( aItem ); m_items_changed.push_back( aItem );
} }
@ -417,9 +422,9 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow()
{ {
if( m_tracks->GetValue() && track->Type() == PCB_TRACE_T ) if( m_tracks->GetValue() && track->Type() == PCB_TRACE_T )
visitItem( &itemsListPicker, track ); visitItem( &itemsListPicker, track );
else if ( m_tracks->GetValue() && track->Type() == PCB_ARC_T ) else if( m_tracks->GetValue() && track->Type() == PCB_ARC_T )
visitItem( &itemsListPicker, track ); visitItem( &itemsListPicker, track );
else if ( m_vias->GetValue() && track->Type() == PCB_VIA_T ) else if( m_vias->GetValue() && track->Type() == PCB_VIA_T )
visitItem( &itemsListPicker, track ); visitItem( &itemsListPicker, track );
} }
@ -445,10 +450,9 @@ bool DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::TransferDataFromWindow()
int GLOBAL_EDIT_TOOL::EditTracksAndVias( const TOOL_EVENT& aEvent ) int GLOBAL_EDIT_TOOL::EditTracksAndVias( const TOOL_EVENT& aEvent )
{ {
PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>(); PCB_EDIT_FRAME* editFrame = getEditFrame<PCB_EDIT_FRAME>();
DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( editFrame ); DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS dlg( editFrame );
dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -175,6 +175,9 @@ DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE::DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE
m_setToDesignRuleValues = new wxRadioButton( sbAction->GetStaticBox(), ID_SPECIFIED_NET_TO_NETCLASS_VALUES, _("Set to net class / custom rule values"), wxDefaultPosition, wxDefaultSize, 0 ); m_setToDesignRuleValues = new wxRadioButton( sbAction->GetStaticBox(), ID_SPECIFIED_NET_TO_NETCLASS_VALUES, _("Set to net class / custom rule values"), wxDefaultPosition, wxDefaultSize, 0 );
sbAction->Add( m_setToDesignRuleValues, 0, wxBOTTOM, 5 ); sbAction->Add( m_setToDesignRuleValues, 0, wxBOTTOM, 5 );
m_addToSelection = new wxCheckBox( sbAction->GetStaticBox(), wxID_ANY, _("Add to selection"), wxDefaultPosition, wxDefaultSize, 0 );
sbAction->Add( m_addToSelection, 0, wxBOTTOM, 5 );
bMainSizer->Add( sbAction, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); bMainSizer->Add( sbAction, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 );

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b) // C++ code generated with wxFormBuilder (version 4.1.0-0-g733bf3d)
// http://www.wxformbuilder.org/ // http://www.wxformbuilder.org/
// //
// PLEASE DO *NOT* EDIT THIS FILE! // PLEASE DO *NOT* EDIT THIS FILE!
@ -66,6 +66,7 @@ class DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS_BASE : public DIALOG_SHIM
wxChoice* m_viaSizesCtrl; wxChoice* m_viaSizesCtrl;
PCB_LAYER_BOX_SELECTOR* m_layerCtrl; PCB_LAYER_BOX_SELECTOR* m_layerCtrl;
wxRadioButton* m_setToDesignRuleValues; wxRadioButton* m_setToDesignRuleValues;
wxCheckBox* m_addToSelection;
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel; wxButton* m_sdbSizerCancel;