From e3aec20f820708275bea89422516bc2b640a0c26 Mon Sep 17 00:00:00 2001 From: Oleg Endo Date: Mon, 13 Apr 2020 04:20:30 +0900 Subject: [PATCH] move PCB_INSPECTION_TOOL::ListNets into pcb_inspection_tool.cpp, split out dialog_select_net_from_list.h --- .../dialogs/dialog_select_net_from_list.cpp | 58 +-------------- pcbnew/dialogs/dialog_select_net_from_list.h | 71 +++++++++++++++++++ pcbnew/tools/pcb_inspection_tool.cpp | 13 ++++ 3 files changed, 86 insertions(+), 56 deletions(-) create mode 100644 pcbnew/dialogs/dialog_select_net_from_list.h diff --git a/pcbnew/dialogs/dialog_select_net_from_list.cpp b/pcbnew/dialogs/dialog_select_net_from_list.cpp index a922117108..1064ef2c58 100644 --- a/pcbnew/dialogs/dialog_select_net_from_list.cpp +++ b/pcbnew/dialogs/dialog_select_net_from_list.cpp @@ -28,68 +28,14 @@ #include #include #include -#include +#include #include #include #include #include #include #include - -class DIALOG_SELECT_NET_FROM_LIST: public DIALOG_SELECT_NET_FROM_LIST_BASE -{ -private: -public: - DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent ); - ~DIALOG_SELECT_NET_FROM_LIST(); - - // returns true if a net was selected, and its name in aName - bool GetNetName( wxString& aName ); - - /** - * Visually highlights a net. - * @param aNetName is the name of net to be highlighted. An empty string will unhighlight - * any currently highlighted net. - */ - void HighlightNet( const wxString& aNetName ); - -private: - void onSelChanged( wxDataViewEvent& event ) override; - void onFilterChange( wxCommandEvent& event ) override; - void onListSize( wxSizeEvent& event ) override; - void onReport( wxCommandEvent& event ) override; - - void buildNetsList(); - wxString getListColumnHeaderNet() { return _( "Net" ); }; - wxString getListColumnHeaderName() { return _( "Name" ); }; - wxString getListColumnHeaderCount() { return _( "Pad Count" ); }; - wxString getListColumnHeaderVias() { return _( "Via Count" ); }; - wxString getListColumnHeaderBoard() { return _( "Board Length" ); }; - wxString getListColumnHeaderDie() { return _( "Die Length" ); }; - wxString getListColumnHeaderLength() { return _( "Length" ); }; - void adjustListColumns(); - - wxArrayString m_netsInitialNames; // The list of escaped netnames (original names) - wxString m_selection; - bool m_wasSelected; - BOARD* m_brd; - PCB_EDIT_FRAME* m_frame; -}; - - -int PCB_INSPECTION_TOOL::ListNets( const TOOL_EVENT& aEvent ) -{ - DIALOG_SELECT_NET_FROM_LIST dlg( m_frame ); - wxString netname; - - if( dlg.ShowModal() == wxID_CANCEL ) - { - // Clear highlight - dlg.HighlightNet( "" ); - } - - return 0; -} +#include DIALOG_SELECT_NET_FROM_LIST::DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent ) diff --git a/pcbnew/dialogs/dialog_select_net_from_list.h b/pcbnew/dialogs/dialog_select_net_from_list.h new file mode 100644 index 0000000000..e2e1955f5a --- /dev/null +++ b/pcbnew/dialogs/dialog_select_net_from_list.h @@ -0,0 +1,71 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr + * 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 + */ + +#pragma once + +#include + +class PCB_EDIT_FRAME; +class NETINFO_ITEM; +class BOARD; + +class DIALOG_SELECT_NET_FROM_LIST : public DIALOG_SELECT_NET_FROM_LIST_BASE +{ +private: +public: + DIALOG_SELECT_NET_FROM_LIST( PCB_EDIT_FRAME* aParent ); + ~DIALOG_SELECT_NET_FROM_LIST(); + + // returns true if a net was selected, and its name in aName + bool GetNetName( wxString& aName ); + + /** + * Visually highlights a net. + * @param aNetName is the name of net to be highlighted. An empty string will unhighlight + * any currently highlighted net. + */ + void HighlightNet( const wxString& aNetName ); + +private: + void onSelChanged( wxDataViewEvent& event ) override; + void onFilterChange( wxCommandEvent& event ) override; + void onListSize( wxSizeEvent& event ) override; + void onReport( wxCommandEvent& event ) override; + + void buildNetsList(); + wxString getListColumnHeaderNet() { return _( "Net" ); }; + wxString getListColumnHeaderName() { return _( "Name" ); }; + wxString getListColumnHeaderCount() { return _( "Pad Count" ); }; + wxString getListColumnHeaderVias() { return _( "Via Count" ); }; + wxString getListColumnHeaderBoard() { return _( "Board Length" ); }; + wxString getListColumnHeaderDie() { return _( "Die Length" ); }; + wxString getListColumnHeaderLength() { return _( "Length" ); }; + void adjustListColumns(); + + wxArrayString m_netsInitialNames; // The list of escaped netnames (original names) + wxString m_selection; + bool m_wasSelected; + BOARD* m_brd; + PCB_EDIT_FRAME* m_frame; +}; diff --git a/pcbnew/tools/pcb_inspection_tool.cpp b/pcbnew/tools/pcb_inspection_tool.cpp index 2ee7a60008..118ad82261 100644 --- a/pcbnew/tools/pcb_inspection_tool.cpp +++ b/pcbnew/tools/pcb_inspection_tool.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "pcb_inspection_tool.h" @@ -443,6 +444,18 @@ void PCB_INSPECTION_TOOL::calculateSelectionRatsnest() connectivity->ComputeDynamicRatsnest( items ); } +int PCB_INSPECTION_TOOL::ListNets( const TOOL_EVENT& aEvent ) +{ + DIALOG_SELECT_NET_FROM_LIST dlg( m_frame ); + + if( dlg.ShowModal() == wxID_CANCEL ) + { + // Clear highlight + dlg.HighlightNet( "" ); + } + + return 0; +} void PCB_INSPECTION_TOOL::setTransitions() {