diff --git a/common/dialogs/eda_view_switcher.cpp b/common/dialogs/eda_view_switcher.cpp new file mode 100644 index 0000000000..50c3eaa54a --- /dev/null +++ b/common/dialogs/eda_view_switcher.cpp @@ -0,0 +1,217 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2007 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include +#include +#include + + +// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or +// not, in repeatedly creating/destroying a wxDC to do the measurement in). +// Use default column widths instead. +static int DEFAULT_COL_WIDTHS[] = { 200, 600 }; + + + +EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, + const wxArrayString& aItemHeaders, + const std::vector& aItemList, + const wxString& aSelection ) : + EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle ) +{ + m_itemsList = &aItemList; + + m_filterBox->SetHint( _( "Filter" ) ); + + initDialog( aItemHeaders, aSelection ); + + // DIALOG_SHIM needs a unique hash_key because classname is not sufficient + // because so many dialogs share this same class, with different numbers of + // columns, different column names, and column widths. + m_hash_key = TO_UTF8( aTitle ); + + m_sdbSizerOK->SetDefault(); + + // this line fixes an issue on Linux Ubuntu using Unity (dialog not shown), + // and works fine on all systems + GetSizer()->Fit( this ); + + Centre(); +} + + +void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection ) +{ + for( unsigned i = 0; i < aItemHeaders.Count(); i++ ) + { + m_listBox->InsertColumn( i, aItemHeaders.Item( i ), + wxLIST_FORMAT_LEFT, DEFAULT_COL_WIDTHS[ i ] ); + } + + InsertItems( *m_itemsList, 0 ); + + if( !aSelection.IsEmpty() ) + { + long sel = m_listBox->FindItem( -1, aSelection ); + + if( sel != wxNOT_FOUND ) + { + m_listBox->SetItemState( sel, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); + + // Set to a small size so EnsureVisible() won't be foiled by later additions. + // ListBox will expand to fit later. + m_listBox->SetSize( m_listBox->GetSize().GetX(), 100 ); + m_listBox->EnsureVisible( sel ); + } + } +} + + +void EDA_LIST_DIALOG::SetListLabel( const wxString& aLabel ) +{ + m_listLabel->SetLabel( aLabel ); + m_listBox->SetSingleStyle( wxLC_NO_HEADER, true ); +} + + +void EDA_LIST_DIALOG::SetOKLabel( const wxString& aLabel ) +{ + m_sdbSizerOK->SetLabel( aLabel ); +} + + +void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event ) +{ + wxString filter; + wxString itemName; + + filter = wxT( "*" ) + m_filterBox->GetLineText( 0 ).MakeLower() + wxT( "*" ); + + m_listBox->DeleteAllItems(); + + for( const wxArrayString& row : *m_itemsList ) + { + itemName = row.Item( 0 ); + + if( itemName.MakeLower().Matches( filter ) ) + Append( row ); + } + + sortList(); +} + + +wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn ) +{ + wxCHECK_MSG( unsigned( aColumn ) < unsigned( m_listBox->GetColumnCount() ), wxEmptyString, + wxT( "Invalid list control column." ) ); + + long item = m_listBox->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED ); + + if( item >= 0 ) // if something is selected. + { + wxListItem info; + + info.m_mask = wxLIST_MASK_TEXT; + info.m_itemId = item; + info.m_col = aColumn; + + if( m_listBox->GetItem( info ) ) + return info.m_text; + } + + return wxEmptyString; +} + + +void EDA_LIST_DIALOG::Append( const wxArrayString& itemList ) +{ + long itemIndex = m_listBox->InsertItem( m_listBox->GetItemCount(), itemList[0] ); + + m_listBox->SetItemPtrData( itemIndex, wxUIntPtr( &itemList[0] ) ); + + // Adding the next columns content + for( unsigned i = 1; i < itemList.size(); i++ ) + m_listBox->SetItem( itemIndex, i, itemList[i] ); +} + + +void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList, int position ) +{ + for( unsigned row = 0; row < itemList.size(); row++ ) + { + wxASSERT( (int) itemList[row].GetCount() == m_listBox->GetColumnCount() ); + + for( unsigned col = 0; col < itemList[row].GetCount(); col++ ) + { + wxListItem info; + info.m_itemId = row + position; + info.m_col = col; + info.m_text = itemList[row].Item( col ); + info.m_width = DEFAULT_COL_WIDTHS[ col ]; + info.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_WIDTH; + + if( col == 0 ) + { + info.m_data = wxUIntPtr( &itemList[row].Item( col ) ); + info.m_mask |= wxLIST_MASK_DATA; + + m_listBox->InsertItem( info ); + } + else + { + m_listBox->SetItem( info ); + } + } + } + + sortList(); +} + + +void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event ) +{ + EndModal( wxID_OK ); +} + + +/* Sort alphabetically, case insensitive. + */ +static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2, + wxIntPtr WXUNUSED( aSortData ) ) +{ + wxString* component1Name = (wxString*) aItem1; + wxString* component2Name = (wxString*) aItem2; + + return StrNumCmp( *component1Name, *component2Name, true ); +} + + +void EDA_LIST_DIALOG::sortList() +{ + m_listBox->SortItems( myCompareFunction, 0 ); +} diff --git a/common/dialogs/eda_view_switcher.h b/common/dialogs/eda_view_switcher.h new file mode 100644 index 0000000000..c19ef4281b --- /dev/null +++ b/common/dialogs/eda_view_switcher.h @@ -0,0 +1,130 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, you may find one here: + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html + * or you may search the http://www.gnu.org website for the version 2 license, + * or you may write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#ifndef EDA_VIEW_SWITCHER_H +#define EDA_VIEW_SWITCHER_H + + +#include + +class EDA_DRAW_FRAME; + +/** + * EDA_LIST_DIALOG + * + * A dialog which shows: + * a list of elements for selection, + * a text control to display help or info about the selected item. + * 2 buttons (OK and Cancel) + * + */ +class EDA_VIEW_SWITCHER : public EDA_VIEW_SWITCHER_BASE +{ +public: + + /** + * Constructor: + * @param aParent Pointer to the parent window. + * @param aTitle = The title shown on top. + * @param aItemHeaders an optional array containing the column header names for the dialog. + * @param aItemList = A wxArrayString of the list of elements. + * @param aRefText = An item name if an item must be preselected. + */ + EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle, + const wxArrayString& aItemHeaders, + const std::vector& aItemList, + const wxString& aRefText ); + + // ~EDA_LIST_DIALOG() {} + + void SetListLabel( const wxString& aLabel ); + void SetOKLabel( const wxString& aLabel ); + + void Append( const wxArrayString& aItemStr ); + void InsertItems( const std::vector& aItemList, int aPosition = 0 ); + + /** + * Function GetTextSelection + * return the selected text from \a aColumn in the wxListCtrl in the dialog. + * + * @param aColumn is the column to return the text from. + * @return a wxString object containing the selected text from \a aColumn. + */ + wxString GetTextSelection( int aColumn = 0 ); + +private: + void onListItemActivated( wxListEvent& event ) override; + void textChangeInFilterBox(wxCommandEvent& event) override; + + void initDialog( const wxArrayString& aItemHeaders, const wxString& aSelection); + void sortList(); + +private: + const std::vector* m_itemsList; +}; + + +/**************************************************************************/ +/* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */ +/* dialog boxes, */ +/**************************************************************************/ +class EDA_POSITION_CTRL +{ +public: + EDA_UNITS m_UserUnit; + + wxTextCtrl* m_FramePosX; + wxTextCtrl* m_FramePosY; + +private: + wxStaticText* m_TextX, * m_TextY; + +public: + EDA_POSITION_CTRL( wxWindow* parent, const wxString& title, const wxPoint& pos_to_edit, + EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); + + ~EDA_POSITION_CTRL(); + + void Enable( bool x_win_on, bool y_win_on ); + void SetValue( int x_value, int y_value ); + wxPoint GetValue(); +}; + + +/************************************************************* + * Class to edit/enter a size (pair of values for X and Y size) + * ( INCHES or MM ) in dialog boxes + ***************************************************************/ +class EDA_SIZE_CTRL : public EDA_POSITION_CTRL +{ +public: + EDA_SIZE_CTRL( wxWindow* parent, const wxString& title, const wxSize& size_to_edit, + EDA_UNITS user_unit, wxBoxSizer* BoxSizer ); + + ~EDA_SIZE_CTRL() { } + wxSize GetValue(); +}; + + + +#endif // EDA_VIEW_SWITCHER_H diff --git a/common/dialogs/eda_view_switcher_base.cpp b/common/dialogs/eda_view_switcher_base.cpp new file mode 100644 index 0000000000..dec2313c41 --- /dev/null +++ b/common/dialogs/eda_view_switcher_base.cpp @@ -0,0 +1,36 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "eda_view_switcher_base.h" + +/////////////////////////////////////////////////////////////////////////// + +EDA_VIEW_SWITCHER_BASE::EDA_VIEW_SWITCHER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizerMain; + bSizerMain = new wxBoxSizer( wxVERTICAL ); + + m_staticText2 = new wxStaticText( this, wxID_ANY, _("View Preset Switcher"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText2->Wrap( -1 ); + bSizerMain->Add( m_staticText2, 0, wxALL, 5 ); + + m_listBox = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 ); + bSizerMain->Add( m_listBox, 1, wxEXPAND, 5 ); + + + this->SetSizer( bSizerMain ); + this->Layout(); + bSizerMain->Fit( this ); + + this->Centre( wxBOTH ); +} + +EDA_VIEW_SWITCHER_BASE::~EDA_VIEW_SWITCHER_BASE() +{ +} diff --git a/common/dialogs/eda_view_switcher_base.fbp b/common/dialogs/eda_view_switcher_base.fbp new file mode 100644 index 0000000000..58a6f2037f --- /dev/null +++ b/common/dialogs/eda_view_switcher_base.fbp @@ -0,0 +1,282 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + eda_list_dialog_base + 1000 + none + + 1 + eda_list_dialog_base + + . + + 1 + 1 + 1 + 1 + UI + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + decl_pure_virtual + + + + 0 + wxID_ANY + + + EDA_LIST_DIALOG_BASE + + + wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + + + + + + + + bSizerMain + wxVERTICAL + none + + 5 + wxEXPAND|wxTOP|wxRIGHT|wxLEFT + 1 + + + bMargins + wxVERTICAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Items: + 0 + + 0 + + + 0 + + 1 + m_listLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND + 3 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,200 + 1 + m_listBox + 1 + + + protected + 1 + + Resizable + 1 + + wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + wxALWAYS_SHOW_SB|wxBORDER_SIMPLE|wxVSCROLL + onListItemActivated + + + + 5 + wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + + 0 + + 1 + m_filterBox + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + textChangeInFilterBox + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer + protected + + + + + + diff --git a/common/dialogs/eda_view_switcher_base.h b/common/dialogs/eda_view_switcher_base.h new file mode 100644 index 0000000000..9bfb748d9b --- /dev/null +++ b/common/dialogs/eda_view_switcher_base.h @@ -0,0 +1,44 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Oct 26 2018) +// http://www.wxformbuilder.org/ +// +// PLEASE DO *NOT* EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class EDA_VIEW_SWITCHER_BASE +/////////////////////////////////////////////////////////////////////////////// +class EDA_VIEW_SWITCHER_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxStaticText* m_staticText2; + wxListBox* m_listBox; + + public: + + EDA_VIEW_SWITCHER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("View Preset Switcher"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSTAY_ON_TOP ); + ~EDA_VIEW_SWITCHER_BASE(); + +}; + diff --git a/pcbnew/cleanup_item.cpp b/pcbnew/cleanup_item.cpp index d70e89d339..3d718e5f2e 100644 --- a/pcbnew/cleanup_item.cpp +++ b/pcbnew/cleanup_item.cpp @@ -44,12 +44,13 @@ wxString CLEANUP_ITEM::GetErrorText( int aCode, bool aTranslate ) const switch( aCode ) { // For cleanup tracks and vias: - case CLEANUP_SHORT: msg = _HKI( "Remove track shorting two nets" ); break; + case CLEANUP_SHORTING_TRACK: msg = _HKI( "Remove track shorting two nets" ); break; + case CLEANUP_SHORTING_VIA: msg = _HKI( "Remove via shorting two nets" ); break; case CLEANUP_REDUNDANT_VIA: msg = _HKI( "Remove redundant via" ); break; case CLEANUP_DUPLICATE_TRACK: msg = _HKI( "Remove duplicate track" ); break; case CLEANUP_MERGE_TRACKS: msg = _HKI( "Merge co-linear tracks" ); break; - case CLEANUP_DANGLING_TRACK: msg = _HKI( "Remove dangling track" ); break; - case CLEANUP_DANGLING_VIA: msg = _HKI( "Remove dangling via" ); break; + case CLEANUP_DANGLING_TRACK: msg = _HKI( "Remove track not connected at both ends" ); break; + case CLEANUP_DANGLING_VIA: msg = _HKI( "Remove via connected on fewer than two layers" ); break; case CLEANUP_ZERO_LENGTH_TRACK: msg = _HKI( "Remove zero-length track" ); break; case CLEANUP_TRACK_IN_PAD: msg = _HKI( "Remove track inside pad" ); break; diff --git a/pcbnew/cleanup_item.h b/pcbnew/cleanup_item.h index b9f691471c..6df60e66ff 100644 --- a/pcbnew/cleanup_item.h +++ b/pcbnew/cleanup_item.h @@ -32,7 +32,8 @@ class PCB_BASE_FRAME; enum CLEANUP_RC_CODE { CLEANUP_FIRST = DRCE_LAST + 1, - CLEANUP_SHORT = CLEANUP_FIRST, + CLEANUP_SHORTING_TRACK = CLEANUP_FIRST, + CLEANUP_SHORTING_VIA, CLEANUP_REDUNDANT_VIA, CLEANUP_DUPLICATE_TRACK, CLEANUP_MERGE_TRACKS, diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.cpp b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.cpp index 66a3dff9d2..779eef992b 100644 --- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.cpp +++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Jul 27 2020) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -27,15 +27,15 @@ DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE::DIALOG_CLEANUP_TRACKS_AND_VIAS_BASE( wxWind m_cleanViasOpt = new wxCheckBox( this, wxID_ANY, _("&Delete redundant vias"), wxDefaultPosition, wxDefaultSize, 0 ); m_cleanViasOpt->SetToolTip( _("remove vias on through hole pads and superimposed vias") ); - bSizerUpper->Add( m_cleanViasOpt, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + bSizerUpper->Add( m_cleanViasOpt, 0, wxALL, 5 ); - m_deleteDanglingViasOpt = new wxCheckBox( this, wxID_ANY, _("Delete vias connected only on one layer"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerUpper->Add( m_deleteDanglingViasOpt, 0, wxALL, 5 ); + m_deleteDanglingViasOpt = new wxCheckBox( this, wxID_ANY, _("Delete vias connected on only one layer"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizerUpper->Add( m_deleteDanglingViasOpt, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); m_mergeSegmOpt = new wxCheckBox( this, wxID_ANY, _("&Merge co-linear tracks"), wxDefaultPosition, wxDefaultSize, 0 ); m_mergeSegmOpt->SetToolTip( _("merge aligned track segments, and remove null segments") ); - bSizerUpper->Add( m_mergeSegmOpt, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + bSizerUpper->Add( m_mergeSegmOpt, 0, wxALL, 5 ); m_deleteUnconnectedOpt = new wxCheckBox( this, wxID_ANY, _("Delete tracks unconnected at one end"), wxDefaultPosition, wxDefaultSize, 0 ); m_deleteUnconnectedOpt->SetToolTip( _("delete tracks having at least one dangling end") ); diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.fbp b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.fbp index 9b102c0011..87395aedff 100644 --- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.fbp +++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.fbp @@ -134,7 +134,7 @@ 5 - wxBOTTOM|wxLEFT|wxRIGHT + wxALL 0 1 @@ -199,7 +199,7 @@ 5 - wxALL + wxBOTTOM|wxRIGHT|wxLEFT 0 1 @@ -230,7 +230,7 @@ 0 0 wxID_ANY - Delete vias connected only on one layer + Delete vias connected on only one layer 0 @@ -264,7 +264,7 @@ 5 - wxBOTTOM|wxLEFT|wxRIGHT + wxALL 0 1 diff --git a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.h b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.h index b6466a4fa2..1752be29e3 100644 --- a/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.h +++ b/pcbnew/dialogs/dialog_cleanup_tracks_and_vias_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version 3.9.0 Jul 27 2020) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! diff --git a/pcbnew/tracks_cleaner.cpp b/pcbnew/tracks_cleaner.cpp index 33a93ee74a..6276500bda 100644 --- a/pcbnew/tracks_cleaner.cpp +++ b/pcbnew/tracks_cleaner.cpp @@ -75,7 +75,7 @@ void TRACKS_CLEANER::CleanupBoard( bool aDryRun, std::vectorTracks() ); if( aRemoveMisConnected ) - removeBadTrackSegments(); + removeShortingTrackSegments(); if( aDeleteTracksinPad ) deleteTracksInPads(); @@ -97,7 +97,7 @@ void TRACKS_CLEANER::CleanupBoard( bool aDryRun, std::vector connectivity = m_brd->GetConnectivity(); @@ -109,7 +109,13 @@ void TRACKS_CLEANER::removeBadTrackSegments() { if( segment->GetNetCode() != testedPad->GetNetCode() ) { - std::shared_ptr item( new CLEANUP_ITEM( CLEANUP_SHORT ) ); + std::shared_ptr item; + + if( segment->Type() == PCB_VIA_T ) + item = std::make_shared( CLEANUP_SHORTING_VIA ); + else + item = std::make_shared( CLEANUP_SHORTING_TRACK ); + item->SetItems( segment ); m_itemsList->push_back( item ); @@ -121,7 +127,13 @@ void TRACKS_CLEANER::removeBadTrackSegments() { if( segment->GetNetCode() != testedTrack->GetNetCode() ) { - std::shared_ptr item( new CLEANUP_ITEM( CLEANUP_SHORT ) ); + std::shared_ptr item; + + if( segment->Type() == PCB_VIA_T ) + item = std::make_shared( CLEANUP_SHORTING_VIA ); + else + item = std::make_shared( CLEANUP_SHORTING_TRACK ); + item->SetItems( segment ); m_itemsList->push_back( item ); @@ -142,8 +154,8 @@ void TRACKS_CLEANER::cleanupVias() for( TRACK* track : m_brd->Tracks() ) { - if( auto via = dyn_cast( track ) ) - vias.push_back( via ); + if( track->Type() == PCB_VIA_T ) + vias.push_back( static_cast( track ) ); } for( auto via1_it = vias.begin(); via1_it != vias.end(); via1_it++ ) diff --git a/pcbnew/tracks_cleaner.h b/pcbnew/tracks_cleaner.h index dd022f3994..0bb1299318 100644 --- a/pcbnew/tracks_cleaner.h +++ b/pcbnew/tracks_cleaner.h @@ -55,7 +55,7 @@ private: /* * Removes track segments which are connected to more than one net (short circuits). */ - void removeBadTrackSegments(); + void removeShortingTrackSegments(); /** * Removes redundant vias like vias at same location or on pad through.