mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-21 19:43:44 +00:00
ADDED: filters for Cleanup Tracks and Vias.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/9052
This commit is contained in:
parent
bcdd4ffea4
commit
a8a4de029e
@ -30,13 +30,19 @@
|
||||
#include <drc/drc_item.h>
|
||||
#include <tools/zone_filler_tool.h>
|
||||
#include <reporter.h>
|
||||
#include <pcb_layer_box_selector.h>
|
||||
#include <board_design_settings.h>
|
||||
#include <board_connected_item.h>
|
||||
#include <pcb_group.h>
|
||||
#include <project/net_settings.h>
|
||||
|
||||
DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME* aParentFrame ) :
|
||||
DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( aParentFrame ),
|
||||
m_parentFrame( aParentFrame ),
|
||||
m_brd( aParentFrame->GetBoard() ),
|
||||
m_firstRun( true )
|
||||
{
|
||||
auto cfg = m_parentFrame->GetPcbNewSettings();
|
||||
PCBNEW_SETTINGS* cfg = m_parentFrame->GetPcbNewSettings();
|
||||
m_reporter = new WX_TEXT_CTRL_REPORTER( m_tcReport );
|
||||
|
||||
m_cbRefillZones->SetValue( cfg->m_Cleanup.cleanup_refill_zones );
|
||||
@ -47,11 +53,17 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::DIALOG_CLEANUP_TRACKS_AND_VIAS( PCB_EDIT_FRAME*
|
||||
m_deleteTracksInPadsOpt->SetValue( cfg->m_Cleanup.cleanup_tracks_in_pad );
|
||||
m_deleteDanglingViasOpt->SetValue( cfg->m_Cleanup.delete_dangling_vias );
|
||||
|
||||
buildFilterLists();
|
||||
|
||||
m_changesTreeModel = new RC_TREE_MODEL( m_parentFrame, m_changesDataView );
|
||||
m_changesDataView->AssociateModel( m_changesTreeModel );
|
||||
|
||||
setupOKButtonLabel();
|
||||
|
||||
m_netFilter->Connect( NET_SELECTED,
|
||||
wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS::OnNetFilterSelect ),
|
||||
nullptr, this );
|
||||
|
||||
m_sdbSizer->SetSizeHints( this );
|
||||
|
||||
finishDialogSettings();
|
||||
@ -86,6 +98,36 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS::~DIALOG_CLEANUP_TRACKS_AND_VIAS()
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::buildFilterLists()
|
||||
{
|
||||
// Populate the net filter list with net names
|
||||
m_netFilter->SetBoard( m_brd );
|
||||
m_netFilter->SetNetInfo( &m_brd->GetNetInfo() );
|
||||
|
||||
if( !m_brd->GetHighLightNetCodes().empty() )
|
||||
m_netFilter->SetSelectedNetcode( *m_brd->GetHighLightNetCodes().begin() );
|
||||
|
||||
// Populate the netclass filter list with netclass names
|
||||
wxArrayString netclassNames;
|
||||
std::shared_ptr<NET_SETTINGS>& settings = m_brd->GetDesignSettings().m_NetSettings;
|
||||
|
||||
netclassNames.push_back( settings->GetDefaultNetclass()->GetName() );
|
||||
|
||||
for( const auto& [name, netclass] : settings->GetNetclasses() )
|
||||
netclassNames.push_back( name );
|
||||
|
||||
m_netclassFilter->Set( netclassNames );
|
||||
m_netclassFilter->SetStringSelection( m_brd->GetDesignSettings().GetCurrentNetClassName() );
|
||||
|
||||
// Populate the layer filter list
|
||||
m_layerFilter->SetBoardFrame( m_parentFrame );
|
||||
m_layerFilter->SetLayersHotkeys( false );
|
||||
m_layerFilter->SetNotAllowedLayerSet( LSET::AllNonCuMask() );
|
||||
m_layerFilter->Resync();
|
||||
m_layerFilter->SetLayerSelection( m_parentFrame->GetActiveLayer() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::setupOKButtonLabel()
|
||||
{
|
||||
if( m_firstRun )
|
||||
@ -97,9 +139,27 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::setupOKButtonLabel()
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnCheckBox( wxCommandEvent& anEvent )
|
||||
{
|
||||
m_changesTreeModel->Update( nullptr, RPT_SEVERITY_ACTION );
|
||||
m_firstRun = true;
|
||||
setupOKButtonLabel();
|
||||
m_tcReport->Clear();
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnNetFilterSelect( wxCommandEvent& aEvent )
|
||||
{
|
||||
OnCheckBox( aEvent );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnNetclassFilterSelect( wxCommandEvent& aEvent )
|
||||
{
|
||||
OnCheckBox( aEvent );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnLayerFilterSelect( wxCommandEvent& aEvent )
|
||||
{
|
||||
OnCheckBox( aEvent );
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +186,52 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
|
||||
|
||||
wxBusyCursor busy;
|
||||
BOARD_COMMIT commit( m_parentFrame );
|
||||
TRACKS_CLEANER cleaner( m_parentFrame->GetBoard(), commit );
|
||||
TRACKS_CLEANER cleaner( m_brd, commit );
|
||||
|
||||
cleaner.SetFilter(
|
||||
[&]( BOARD_CONNECTED_ITEM* aItem ) -> bool
|
||||
{
|
||||
if( m_selectedItemsFilter->GetValue() )
|
||||
{
|
||||
if( !aItem->IsSelected() )
|
||||
{
|
||||
PCB_GROUP* group = aItem->GetParentGroup();
|
||||
|
||||
while( group && !group->IsSelected() )
|
||||
group = group->GetParentGroup();
|
||||
|
||||
if( !group )
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( m_netFilterOpt->GetValue() && m_netFilter->GetSelectedNetcode() >= 0 )
|
||||
{
|
||||
if( aItem->GetNetCode() != m_netFilter->GetSelectedNetcode() )
|
||||
return true;
|
||||
}
|
||||
|
||||
if( m_netclassFilterOpt->GetValue()
|
||||
&& !m_netclassFilter->GetStringSelection().IsEmpty() )
|
||||
{
|
||||
wxString filterNetclass = m_netclassFilter->GetStringSelection();
|
||||
NETCLASS* netclass = aItem->GetEffectiveNetClass();
|
||||
|
||||
if( !netclass->ContainsNetclassWithName( filterNetclass ) )
|
||||
return true;
|
||||
}
|
||||
|
||||
if( m_layerFilterOpt->GetValue()
|
||||
&& m_layerFilter->GetLayerSelection() != UNDEFINED_LAYER )
|
||||
{
|
||||
if( aItem->GetLayer() != m_layerFilter->GetLayerSelection() )
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
m_outputBook->SetSelection( 1 );
|
||||
|
||||
if( !aDryRun )
|
||||
{
|
||||
@ -177,7 +282,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
|
||||
m_parentFrame->GetCanvas()->Refresh( true );
|
||||
}
|
||||
|
||||
m_reporter->Report( _( "Done." ) );
|
||||
m_outputBook->SetSelection( 0 );
|
||||
setupOKButtonLabel();
|
||||
}
|
||||
|
||||
@ -185,7 +290,7 @@ void DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup( bool aDryRun )
|
||||
void DIALOG_CLEANUP_TRACKS_AND_VIAS::OnSelectItem( wxDataViewEvent& aEvent )
|
||||
{
|
||||
const KIID& itemID = RC_TREE_MODEL::ToUUID( aEvent.GetItem() );
|
||||
BOARD_ITEM* item = m_parentFrame->GetBoard()->GetItem( itemID );
|
||||
BOARD_ITEM* item = m_brd->GetItem( itemID );
|
||||
WINDOW_THAWER thawer( m_parentFrame );
|
||||
|
||||
m_parentFrame->FocusOnItem( item );
|
||||
|
@ -41,9 +41,13 @@ public:
|
||||
|
||||
private:
|
||||
void doCleanup( bool aDryRun );
|
||||
void buildFilterLists();
|
||||
void setupOKButtonLabel();
|
||||
|
||||
void OnCheckBox( wxCommandEvent& anEvent ) override;
|
||||
void OnCheckBox( wxCommandEvent& aEvent ) override;
|
||||
void OnNetFilterSelect( wxCommandEvent& aEvent );
|
||||
void OnNetclassFilterSelect( wxCommandEvent& aEvent ) override;
|
||||
void OnLayerFilterSelect( wxCommandEvent& aEvent ) override;
|
||||
void OnSelectItem( wxDataViewEvent& event ) override;
|
||||
void OnLeftDClickItem( wxMouseEvent& event ) override;
|
||||
|
||||
@ -51,6 +55,7 @@ private:
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
PCB_EDIT_FRAME* m_parentFrame;
|
||||
BOARD* m_brd;
|
||||
RC_TREE_MODEL* m_changesTreeModel;
|
||||
bool m_firstRun;
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "pcb_layer_box_selector.h"
|
||||
|
||||
#include "dialog_cleanup_tracks_and_vias_base.h"
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
@ -19,68 +21,159 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWind
|
||||
wxBoxSizer* bSizerTop;
|
||||
bSizerTop = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
wxBoxSizer* bSizerLeft;
|
||||
bSizerLeft = new wxBoxSizer( wxVERTICAL );
|
||||
wxStaticBoxSizer* sbSizer3;
|
||||
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Actions") ), wxVERTICAL );
|
||||
|
||||
m_cbRefillZones = new wxCheckBox( this, wxID_ANY, _("Refill zones before run cleanup"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerLeft->Add( m_cbRefillZones, 0, wxALL, 5 );
|
||||
m_cbRefillZones = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Refill zones before running cleanup"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer3->Add( m_cbRefillZones, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_cleanShortCircuitOpt = new wxCheckBox( this, wxID_ANY, _("Delete &tracks connecting different nets"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sbSizer3->Add( 0, 12, 1, wxEXPAND, 5 );
|
||||
|
||||
m_cleanShortCircuitOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Delete &tracks connecting different nets"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_cleanShortCircuitOpt->SetToolTip( _("remove track segments connecting nodes belonging to different nets (short circuit)") );
|
||||
|
||||
bSizerLeft->Add( m_cleanShortCircuitOpt, 0, wxALL, 5 );
|
||||
sbSizer3->Add( m_cleanShortCircuitOpt, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_cleanViasOpt = new wxCheckBox( this, wxID_ANY, _("&Delete redundant vias"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sbSizer3->Add( 0, 10, 1, wxEXPAND, 5 );
|
||||
|
||||
m_cleanViasOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("&Delete redundant vias"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_cleanViasOpt->SetToolTip( _("remove vias on through hole pads and superimposed vias") );
|
||||
|
||||
bSizerLeft->Add( m_cleanViasOpt, 0, wxALL, 5 );
|
||||
sbSizer3->Add( m_cleanViasOpt, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_deleteDanglingViasOpt = new wxCheckBox( this, wxID_ANY, _("Delete vias connected on only one layer"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
bSizerLeft->Add( m_deleteDanglingViasOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
||||
m_deleteDanglingViasOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Delete vias connected on only one layer"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbSizer3->Add( m_deleteDanglingViasOpt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_mergeSegmOpt = new wxCheckBox( this, wxID_ANY, _("&Merge co-linear tracks"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
||||
sbSizer3->Add( 0, 10, 1, wxEXPAND, 5 );
|
||||
|
||||
m_mergeSegmOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("&Merge co-linear tracks"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_mergeSegmOpt->SetToolTip( _("merge aligned track segments, and remove null segments") );
|
||||
|
||||
bSizerLeft->Add( m_mergeSegmOpt, 0, wxALL, 5 );
|
||||
sbSizer3->Add( m_mergeSegmOpt, 0, wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_deleteUnconnectedOpt = new wxCheckBox( this, wxID_ANY, _("Delete tracks unconnected at one end"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_deleteUnconnectedOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Delete tracks unconnected at one end"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_deleteUnconnectedOpt->SetToolTip( _("delete tracks having at least one dangling end") );
|
||||
|
||||
bSizerLeft->Add( m_deleteUnconnectedOpt, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
||||
sbSizer3->Add( m_deleteUnconnectedOpt, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_deleteTracksInPadsOpt = new wxCheckBox( this, wxID_ANY, _("Delete tracks fully inside pads"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_deleteTracksInPadsOpt = new wxCheckBox( sbSizer3->GetStaticBox(), wxID_ANY, _("Delete tracks fully inside pads"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_deleteTracksInPadsOpt->SetToolTip( _("Delete tracks that have both start and end positions inside of a pad") );
|
||||
|
||||
bSizerLeft->Add( m_deleteTracksInPadsOpt, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
||||
sbSizer3->Add( m_deleteTracksInPadsOpt, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizerTop->Add( bSizerLeft, 0, wxEXPAND|wxALL, 5 );
|
||||
bSizerTop->Add( sbSizer3, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxBoxSizer* bSizerRight;
|
||||
bSizerRight = new wxBoxSizer( wxVERTICAL );
|
||||
wxStaticBoxSizer* sbFilters;
|
||||
sbFilters = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Filter Items") ), wxVERTICAL );
|
||||
|
||||
m_tcReport = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
|
||||
bSizerRight->Add( m_tcReport, 1, wxALL|wxEXPAND, 5 );
|
||||
wxFlexGridSizer* fgSizer3;
|
||||
fgSizer3 = new wxFlexGridSizer( 0, 2, 3, 0 );
|
||||
fgSizer3->AddGrowableCol( 1 );
|
||||
fgSizer3->AddGrowableRow( 0 );
|
||||
fgSizer3->AddGrowableRow( 1 );
|
||||
fgSizer3->AddGrowableRow( 2 );
|
||||
fgSizer3->AddGrowableRow( 3 );
|
||||
fgSizer3->SetFlexibleDirection( wxBOTH );
|
||||
fgSizer3->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
||||
|
||||
m_netFilterOpt = new wxCheckBox( sbFilters->GetStaticBox(), wxID_ANY, _("Filter items by net:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_netFilterOpt, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_netFilter = new NET_SELECTOR( sbFilters->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_netFilter, 1, wxEXPAND|wxRIGHT, 5 );
|
||||
|
||||
m_netclassFilterOpt = new wxCheckBox( sbFilters->GetStaticBox(), wxID_ANY, _("Filter items by net class:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_netclassFilterOpt, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
wxArrayString m_netclassFilterChoices;
|
||||
m_netclassFilter = new wxChoice( sbFilters->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_netclassFilterChoices, 0 );
|
||||
m_netclassFilter->SetSelection( 0 );
|
||||
m_netclassFilter->SetMinSize( wxSize( 140,-1 ) );
|
||||
|
||||
fgSizer3->Add( m_netclassFilter, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT, 5 );
|
||||
|
||||
|
||||
bSizerTop->Add( bSizerRight, 1, wxEXPAND, 5 );
|
||||
fgSizer3->Add( 0, 7, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerTop, 0, wxEXPAND, 5 );
|
||||
fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
m_layerFilterOpt = new wxCheckBox( sbFilters->GetStaticBox(), wxID_ANY, _("Filter items by layer:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
fgSizer3->Add( m_layerFilterOpt, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_layerFilter = new PCB_LAYER_BOX_SELECTOR( sbFilters->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
|
||||
fgSizer3->Add( m_layerFilter, 0, wxEXPAND|wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
|
||||
|
||||
|
||||
fgSizer3->Add( 0, 7, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
fgSizer3->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
sbFilters->Add( fgSizer3, 0, wxEXPAND|wxBOTTOM, 5 );
|
||||
|
||||
|
||||
sbFilters->Add( 0, 5, 0, 0, 5 );
|
||||
|
||||
m_selectedItemsFilter = new wxCheckBox( sbFilters->GetStaticBox(), wxID_ANY, _("Selected items only"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
sbFilters->Add( m_selectedItemsFilter, 0, wxALL, 5 );
|
||||
|
||||
|
||||
sbFilters->Add( 0, 0, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerTop->Add( sbFilters, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bSizerTop, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bLowerSizer;
|
||||
bLowerSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
bLowerSizer->SetMinSize( wxSize( 660,250 ) );
|
||||
staticChangesLabel = new wxStaticText( this, wxID_ANY, _("Changes to be applied:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_outputBook = new wxSimplebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_changesPanel = new wxPanel( m_outputBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* changesSizer;
|
||||
changesSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
staticChangesLabel = new wxStaticText( m_changesPanel, wxID_ANY, _("Changes to be applied:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
staticChangesLabel->Wrap( -1 );
|
||||
bLowerSizer->Add( staticChangesLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
changesSizer->Add( staticChangesLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_changesDataView = new wxDataViewCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER );
|
||||
bLowerSizer->Add( m_changesDataView, 1, wxALL|wxEXPAND, 5 );
|
||||
m_changesDataView = new wxDataViewCtrl( m_changesPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_NO_HEADER );
|
||||
changesSizer->Add( m_changesDataView, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bLowerSizer, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 );
|
||||
m_changesPanel->SetSizer( changesSizer );
|
||||
m_changesPanel->Layout();
|
||||
changesSizer->Fit( m_changesPanel );
|
||||
m_outputBook->AddPage( m_changesPanel, _("a page"), false );
|
||||
m_runningPanel = new wxPanel( m_outputBook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* progressSizer;
|
||||
progressSizer = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
staticProgressLabel = new wxStaticText( m_runningPanel, wxID_ANY, _("Progress:"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
staticProgressLabel->Wrap( -1 );
|
||||
progressSizer->Add( staticProgressLabel, 0, wxALL, 5 );
|
||||
|
||||
m_tcReport = new wxTextCtrl( m_runningPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
|
||||
progressSizer->Add( m_tcReport, 1, wxEXPAND|wxRIGHT|wxLEFT, 3 );
|
||||
|
||||
|
||||
m_runningPanel->SetSizer( progressSizer );
|
||||
m_runningPanel->Layout();
|
||||
progressSizer->Fit( m_runningPanel );
|
||||
m_outputBook->AddPage( m_runningPanel, _("a page"), false );
|
||||
|
||||
bLowerSizer->Add( m_outputBook, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
bSizerMain->Add( bLowerSizer, 1, wxEXPAND|wxALL, 5 );
|
||||
|
||||
m_sdbSizer = new wxStdDialogButtonSizer();
|
||||
m_sdbSizerOK = new wxButton( this, wxID_OK );
|
||||
@ -106,6 +199,12 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWind
|
||||
m_mergeSegmOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_deleteUnconnectedOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_deleteTracksInPadsOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netFilterOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netclassFilterOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netclassFilter->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnNetclassFilterSelect ), NULL, this );
|
||||
m_layerFilterOpt->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_layerFilter->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLayerFilterSelect ), NULL, this );
|
||||
m_selectedItemsFilter->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_changesDataView->Connect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this );
|
||||
m_changesDataView->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this );
|
||||
}
|
||||
@ -120,6 +219,12 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::~DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE()
|
||||
m_mergeSegmOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_deleteUnconnectedOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_deleteTracksInPadsOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netFilterOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netclassFilterOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_netclassFilter->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnNetclassFilterSelect ), NULL, this );
|
||||
m_layerFilterOpt->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_layerFilter->Disconnect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLayerFilterSelect ), NULL, this );
|
||||
m_selectedItemsFilter->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnCheckBox ), NULL, this );
|
||||
m_changesDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_SELECTION_CHANGED, wxDataViewEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnSelectItem ), NULL, this );
|
||||
m_changesDataView->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::OnLeftDClickItem ), NULL, this );
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version 4.2.1-0-g80c4cb6)
|
||||
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO *NOT* EDIT THIS FILE!
|
||||
@ -10,6 +10,8 @@
|
||||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
class PCB_LAYER_BOX_SELECTOR;
|
||||
|
||||
#include "dialog_shim.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/checkbox.h>
|
||||
@ -18,14 +20,21 @@
|
||||
#include <wx/colour.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/statbox.h>
|
||||
#include <widgets/net_selector.h>
|
||||
#include <wx/choice.h>
|
||||
#include <wx/bmpcbox.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/dataview.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/simplebook.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/dialog.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
/// Class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -41,9 +50,20 @@ class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE : public DIALOG_SHIM
|
||||
wxCheckBox* m_mergeSegmOpt;
|
||||
wxCheckBox* m_deleteUnconnectedOpt;
|
||||
wxCheckBox* m_deleteTracksInPadsOpt;
|
||||
wxTextCtrl* m_tcReport;
|
||||
wxCheckBox* m_netFilterOpt;
|
||||
NET_SELECTOR* m_netFilter;
|
||||
wxCheckBox* m_netclassFilterOpt;
|
||||
wxChoice* m_netclassFilter;
|
||||
wxCheckBox* m_layerFilterOpt;
|
||||
PCB_LAYER_BOX_SELECTOR* m_layerFilter;
|
||||
wxCheckBox* m_selectedItemsFilter;
|
||||
wxSimplebook* m_outputBook;
|
||||
wxPanel* m_changesPanel;
|
||||
wxStaticText* staticChangesLabel;
|
||||
wxDataViewCtrl* m_changesDataView;
|
||||
wxPanel* m_runningPanel;
|
||||
wxStaticText* staticProgressLabel;
|
||||
wxTextCtrl* m_tcReport;
|
||||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
@ -51,6 +71,8 @@ class DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE : public DIALOG_SHIM
|
||||
// Virtual event handlers, override them in your derived class
|
||||
virtual void onInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
|
||||
virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnNetclassFilterSelect( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnLayerFilterSelect( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void OnSelectItem( wxDataViewEvent& event ) { event.Skip(); }
|
||||
virtual void OnLeftDClickItem( wxMouseEvent& event ) { event.Skip(); }
|
||||
|
||||
|
@ -40,7 +40,8 @@ TRACKS_CLEANER::TRACKS_CLEANER( BOARD* aPcb, BOARD_COMMIT& aCommit ) :
|
||||
m_commit( aCommit ),
|
||||
m_dryRun( true ),
|
||||
m_itemsList( nullptr ),
|
||||
m_reporter( nullptr )
|
||||
m_reporter( nullptr ),
|
||||
m_filter( nullptr )
|
||||
{
|
||||
}
|
||||
|
||||
@ -160,6 +161,15 @@ void TRACKS_CLEANER::CleanupBoard( bool aDryRun,
|
||||
}
|
||||
|
||||
|
||||
bool TRACKS_CLEANER::filterItem( BOARD_CONNECTED_ITEM* aItem )
|
||||
{
|
||||
if( !m_filter )
|
||||
return false;
|
||||
|
||||
return (m_filter)( aItem );
|
||||
}
|
||||
|
||||
|
||||
void TRACKS_CLEANER::removeShortingTrackSegments()
|
||||
{
|
||||
std::shared_ptr<CONNECTIVITY_DATA> connectivity = m_brd->GetConnectivity();
|
||||
@ -168,8 +178,7 @@ void TRACKS_CLEANER::removeShortingTrackSegments()
|
||||
|
||||
for( PCB_TRACK* segment : m_brd->Tracks() )
|
||||
{
|
||||
// Assume that the user knows what they are doing
|
||||
if( segment->IsLocked() )
|
||||
if( segment->IsLocked() || filterItem( segment ) )
|
||||
continue;
|
||||
|
||||
for( PAD* testedPad : connectivity->GetConnectedPads( segment ) )
|
||||
@ -266,7 +275,7 @@ bool TRACKS_CLEANER::deleteDanglingTracks( bool aTrack, bool aVia )
|
||||
|
||||
for( PCB_TRACK* track : temp_tracks )
|
||||
{
|
||||
if( track->IsLocked() || ( track->GetFlags() & IS_DELETED ) > 0 )
|
||||
if( track->HasFlag( IS_DELETED ) || track->IsLocked() || filterItem( track ) )
|
||||
continue;
|
||||
|
||||
if( !aVia && track->Type() == PCB_VIA_T )
|
||||
@ -316,7 +325,7 @@ void TRACKS_CLEANER::deleteTracksInPads()
|
||||
|
||||
for( PCB_TRACK* track : m_brd->Tracks() )
|
||||
{
|
||||
if( track->IsLocked() )
|
||||
if( track->IsLocked() || filterItem( track ) )
|
||||
continue;
|
||||
|
||||
if( track->Type() == PCB_VIA_T )
|
||||
@ -370,7 +379,7 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
|
||||
|
||||
for( PCB_TRACK* track : m_brd->Tracks() )
|
||||
{
|
||||
if( track->HasFlag( IS_DELETED ) || track->IsLocked() )
|
||||
if( track->HasFlag( IS_DELETED ) || track->IsLocked() || filterItem( track ) )
|
||||
continue;
|
||||
|
||||
if( aDeleteDuplicateVias && track->Type() == PCB_VIA_T )
|
||||
@ -484,7 +493,6 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
|
||||
auto mergeSegments =
|
||||
[&]( std::shared_ptr<CN_CONNECTIVITY_ALGO> connectivity ) -> bool
|
||||
{
|
||||
|
||||
for( PCB_TRACK* segment : m_brd->Tracks() )
|
||||
{
|
||||
// one can merge only collinear segments, not vias or arcs.
|
||||
@ -494,6 +502,9 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
|
||||
if( segment->HasFlag( IS_DELETED ) ) // already taken into account
|
||||
continue;
|
||||
|
||||
if( filterItem( segment ) )
|
||||
continue;
|
||||
|
||||
// for each end of the segment:
|
||||
for( CN_ITEM* citem : connectivity->ItemEntry( segment ).GetItems() )
|
||||
{
|
||||
@ -510,7 +521,8 @@ void TRACKS_CLEANER::cleanup( bool aDeleteDuplicateVias, bool aDeleteNullSegment
|
||||
BOARD_CONNECTED_ITEM* candidate = connected->Parent();
|
||||
|
||||
if( candidate->Type() == PCB_TRACE_T
|
||||
&& !candidate->HasFlag( IS_DELETED ) )
|
||||
&& !candidate->HasFlag( IS_DELETED )
|
||||
&& !filterItem( candidate ) )
|
||||
{
|
||||
PCB_TRACK* candidateSegment = static_cast<PCB_TRACK*>( candidate );
|
||||
|
||||
|
@ -56,7 +56,14 @@ public:
|
||||
bool aDeleteUnconnected, bool aDeleteTracksinPad, bool aDeleteDanglingVias,
|
||||
REPORTER* aReporter = nullptr );
|
||||
|
||||
void SetFilter( const std::function<bool( BOARD_CONNECTED_ITEM* aItem )>& aFilter )
|
||||
{
|
||||
m_filter = aFilter;
|
||||
}
|
||||
|
||||
private:
|
||||
bool filterItem( BOARD_CONNECTED_ITEM* aItem );
|
||||
|
||||
/*
|
||||
* Removes track segments which are connected to more than one net (short circuits).
|
||||
*/
|
||||
@ -109,6 +116,8 @@ private:
|
||||
|
||||
// Cache connections. O(n^2) is awful, but it beats O(2n^3).
|
||||
std::map<PCB_TRACK*, std::vector<BOARD_CONNECTED_ITEM*>> m_connectedItemsCache;
|
||||
|
||||
std::function<bool( BOARD_CONNECTED_ITEM* aItem )> m_filter;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user