KiCad PCB EDA Suite
board_inspection_tool.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) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef BOARD_INSPECTION_TOOL_H
25 #define BOARD_INSPECTION_TOOL_H
26 
31 #include <pcb_edit_frame.h>
32 #include <tools/pcb_actions.h>
33 #include <tools/pcb_tool_base.h>
34 
35 class CONNECTIVITY_DATA;
36 
37 
39 {
40 public:
42  DIALOG_HTML_REPORTER( aFrame ),
43  m_frame( aFrame )
44  {
45  m_sdbSizerOK->SetDefault();
47  }
48 
49  void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override;
50 
51  void OnOK( wxCommandEvent& event ) override
52  {
53  Close();
54  }
55 
56 protected:
58 };
59 
60 
64 class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
65 {
66 public:
68 
70  bool Init() override;
71 
73  void Reset( RESET_REASON aReason ) override;
74 
78  int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
79 
81  int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
82 
84  int HighlightNet( const TOOL_EVENT& aEvent );
85 
87  int ClearHighlight( const TOOL_EVENT& aEvent );
88 
90  int HighlightNetTool( const TOOL_EVENT& aEvent );
91 
93  int HighlightItem( const TOOL_EVENT& aEvent );
94 
96  int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
97 
99  int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
100 
102  int LocalRatsnestTool( const TOOL_EVENT& aEvent );
103 
104  int FlipPcbView( const TOOL_EVENT& aEvent );
105 
106  int ListNets( const TOOL_EVENT& aEvent );
107 
109  int HideNet( const TOOL_EVENT& aEvent );
110 
112  int ShowNet( const TOOL_EVENT& aEvent );
113 
115  int InspectClearance( const TOOL_EVENT& aEvent );
116 
117  int InspectConstraints( const TOOL_EVENT& aEvent );
118 
119 private:
121  void ratsnestTimer( wxTimerEvent& aEvent );
122 
124  void calculateSelectionRatsnest( const VECTOR2I& aDelta );
125 
133  bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
134 
135  void doHideNet( int aNetCode, bool aHide );
136 
138  void setTransitions() override;
139 
140  void onListNetsDialogClosed( wxCommandEvent& aEvent );
141  void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
142  void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent );
143 
144  void reportZoneConnection( ZONE* aZone, PAD* aPad, REPORTER* r );
145 
146  void reportClearance( DRC_CONSTRAINT_T aClearanceType, PCB_LAYER_ID aLayer, BOARD_ITEM* aA,
147  BOARD_ITEM* aB, REPORTER* r );
148 
149  wxString getItemDescription( BOARD_ITEM* aItem );
150 
151 private:
152  PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
153 
154  bool m_probingSchToPcb; // Recursion guard when cross-probing to Eeschema
155  int m_lastNetcode; // Used for toggling between last two highlighted nets
156 
157  CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
158 
159  std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
161 
162  std::unique_ptr<DIALOG_INSPECTION_REPORTER> m_inspectClearanceDialog;
163  std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
164 };
165 
166 #endif //BOARD_INSPECTION_TOOL_H
void reportClearance(DRC_CONSTRAINT_T aClearanceType, PCB_LAYER_ID aLayer, BOARD_ITEM *aA, BOARD_ITEM *aB, REPORTER *r)
int HideDynamicRatsnest(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
wxString getItemDescription(BOARD_ITEM *aItem)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:82
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
int InspectClearance(const TOOL_EVENT &aEvent)
int ClearHighlight(const TOOL_EVENT &aEvent)
Launch a tool to pick the item whose net is going to be highlighted.
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Highlight net belonging to the item under the cursor.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:98
DRC_CONSTRAINT_T
Definition: drc_rule.h:41
int InspectConstraints(const TOOL_EVENT &aEvent)
PCB_LAYER_ID
A quick note on layer IDs:
int HighlightNet(const TOOL_EVENT &aEvent)
Clear all board highlights.
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectConstraintsDialog
void onInspectClearanceDialogClosed(wxCommandEvent &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
Generic, UI-independent tool event.
Definition: tool_event.h:173
Class DIALOG_HTML_REPORTER.
int HighlightItem(const TOOL_EVENT &aEvent)
Update ratsnest for selected items.
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
int ShowNet(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items.
void ratsnestTimer(wxTimerEvent &aEvent)
< Event handler to recalculate dynamic ratsnest.
bool highlightNet(const VECTOR2D &aPosition, bool aUseSelection)
Look for a BOARD_CONNECTED_ITEM in a given spot and if one is found - it enables highlight for its ne...
std::unique_ptr< DIALOG_NET_INSPECTOR > m_listNetsDialog
void reportZoneConnection(ZONE *aZone, PAD *aPad, REPORTER *r)
int ListNets(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
int HighlightNetTool(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings
bool Init() override
Init() is called once upon a registration of the tool.
void onListNetsDialogClosed(wxCommandEvent &aEvent)
void doHideNet(int aNetCode, bool aHide)
Bind handlers to corresponding TOOL_ACTIONs.
The main frame for Pcbnew.
DIALOG_INSPECTION_REPORTER(PCB_EDIT_FRAME *aFrame)
int FlipPcbView(const TOOL_EVENT &aEvent)
CONNECTIVITY_DATA * m_dynamicData
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
int HideNet(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
void OnOK(wxCommandEvent &event) override
Definition: pad.h:60
std::unique_ptr< DIALOG_INSPECTION_REPORTER > m_inspectClearanceDialog
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
void onInspectConstraintsDialogClosed(wxCommandEvent &aEvent)
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Show dialog with board statistics.
void OnErrorLinkClicked(wxHtmlLinkEvent &event) override
Tool for pcb inspection.