KiCad PCB EDA Suite
dialog_net_inspector.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 Oleg Endo <olegendo@gcc.gnu.org>
5  * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
6  * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #pragma once
27 
28 #include <core/optional.h>
30 
31 class PCB_EDIT_FRAME;
32 class NETINFO_ITEM;
33 class BOARD;
34 class CN_ITEM;
35 class EDA_PATTERN_MATCH;
36 
38 {
39 public:
40  struct SETTINGS
41  {
42  wxString filter_string;
43  bool show_zero_pad_nets = true;
44  bool group_by = false;
45  int group_by_kind = 0;
46  wxString group_by_text;
47  int sorting_column = -1;
48  bool sort_order_asc = true;
49 
50  std::vector<int> column_order;
51  };
52 
53  DIALOG_NET_INSPECTOR( PCB_EDIT_FRAME* aParent, const SETTINGS& aSettings );
55 
56  SETTINGS Settings() const;
57 
58  virtual void OnBoardItemAdded( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
59  virtual void OnBoardItemsAdded( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) override;
60  virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
61  virtual void OnBoardItemsRemoved( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) override;
62  virtual void OnBoardNetSettingsChanged( BOARD& aBoard ) override;
63  virtual void OnBoardItemChanged( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override;
64  virtual void OnBoardItemsChanged( BOARD& aBoard, std::vector<BOARD_ITEM*>& aBoardItems ) override;
65  virtual void OnBoardHighlightNetChanged( BOARD& aBoard ) override;
66 
67 private:
68  struct COLUMN_DESC;
69  class LIST_ITEM;
71 
72  using LIST_ITEM_ITER = std::vector<std::unique_ptr<LIST_ITEM>>::iterator;
73  using LIST_ITEM_CONST_ITER = std::vector<std::unique_ptr<LIST_ITEM>>::const_iterator;
74 
75  static const COLUMN_DESC COLUMN_NET;
76  static const COLUMN_DESC COLUMN_NAME;
83 
84  wxString formatNetCode( const NETINFO_ITEM* aNet ) const;
85  wxString formatNetName( const NETINFO_ITEM* aNet ) const;
86  wxString formatCount( unsigned int aValue ) const;
87  wxString formatLength( int64_t aValue ) const;
88 
89  std::vector<CN_ITEM*> relevantConnectivityItems() const;
90  bool netFilterMatches( NETINFO_ITEM* aNet ) const;
91  void updateNet( NETINFO_ITEM* aNet );
92  unsigned int calculateViaLength( const PCB_TRACK* ) const;
93 
94  void onSelChanged( wxDataViewEvent& event ) override;
95  void onSelChanged();
96  void onSortingChanged( wxDataViewEvent& event ) override;
97  void onFilterChange( wxCommandEvent& event ) override;
98  void onListSize( wxSizeEvent& event ) override;
99  void onAddNet( wxCommandEvent& event ) override;
100  void onRenameNet( wxCommandEvent& event ) override;
101  void onDeleteNet( wxCommandEvent& event ) override;
102  void onReport( wxCommandEvent& event ) override;
103 
104  std::unique_ptr<LIST_ITEM> buildNewItem( NETINFO_ITEM* aNet, unsigned int aPadCount,
105  const std::vector<CN_ITEM*>& aCNItems );
106 
107  void buildNetsList();
108  void adjustListColumns();
109 
110  void onParentWindowClosed( wxCommandEvent& event );
111  void onUnitsChanged( wxCommandEvent& event );
112  void onBoardChanged( wxCommandEvent& event );
113 
114  void updateDisplayedRowValues( const OPT<LIST_ITEM_ITER>& aRow );
115 
116  // special zero-netcode item. unconnected pads etc might use different
117  // (dummy) NETINFO_ITEM. redirect all of them to this item, which we get
118  // from the board object in buildNetsList.
120 
121  std::vector<std::unique_ptr<EDA_PATTERN_MATCH>> m_netFilter;
122  std::vector<std::unique_ptr<EDA_PATTERN_MATCH>> m_groupFilter;
123 
126  bool m_in_build_nets_list = false;
128 
129  class DATA_MODEL;
130  wxObjectDataPtr<DATA_MODEL> m_data_model;
131 };
static const COLUMN_DESC COLUMN_CHIP_LENGTH
std::vector< CN_ITEM * > relevantConnectivityItems() const
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void onRenameNet(wxCommandEvent &event) override
virtual void OnBoardNetSettingsChanged(BOARD &aBoard) override
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
virtual void OnBoardHighlightNetChanged(BOARD &aBoard) override
void onBoardChanged(wxCommandEvent &event)
static const COLUMN_DESC COLUMN_NET
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_netFilter
wxString formatCount(unsigned int aValue) const
static const COLUMN_DESC COLUMN_TOTAL_LENGTH
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
void onDeleteNet(wxCommandEvent &event) override
static const COLUMN_DESC COLUMN_PAD_COUNT
void onParentWindowClosed(wxCommandEvent &event)
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void onSortingChanged(wxDataViewEvent &event) override
void onReport(wxCommandEvent &event) override
std::vector< std::unique_ptr< LIST_ITEM > >::iterator LIST_ITEM_ITER
std::vector< std::unique_ptr< LIST_ITEM > >::const_iterator LIST_ITEM_CONST_ITER
bool netFilterMatches(NETINFO_ITEM *aNet) const
void updateNet(NETINFO_ITEM *aNet)
void updateDisplayedRowValues(const OPT< LIST_ITEM_ITER > &aRow)
static const COLUMN_DESC COLUMN_NAME
static const COLUMN_DESC COLUMN_BOARD_LENGTH
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
wxString formatLength(int64_t aValue) const
void onUnitsChanged(wxCommandEvent &event)
unsigned int calculateViaLength(const PCB_TRACK *) const
void onListSize(wxSizeEvent &event) override
std::vector< std::unique_ptr< EDA_PATTERN_MATCH > > m_groupFilter
Handle the data for a net.
Definition: netinfo.h:66
std::unique_ptr< LIST_ITEM > buildNewItem(NETINFO_ITEM *aNet, unsigned int aPadCount, const std::vector< CN_ITEM * > &aCNItems)
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:190
DIALOG_NET_INSPECTOR(PCB_EDIT_FRAME *aParent, const SETTINGS &aSettings)
The main frame for Pcbnew.
boost::optional< T > OPT
Definition: optional.h:7
void onAddNet(wxCommandEvent &event) override
static const COLUMN_DESC COLUMN_VIA_LENGTH
Class DIALOG_NET_INSPECTOR_BASE.
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItems) override
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem) override
void onFilterChange(wxCommandEvent &event) override
static const COLUMN_DESC COLUMN_VIA_COUNT
wxString formatNetName(const NETINFO_ITEM *aNet) const
wxString formatNetCode(const NETINFO_ITEM *aNet) const
wxObjectDataPtr< DATA_MODEL > m_data_model