KiCad PCB EDA Suite
pcb_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-2020 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_STATISTICS_TOOL_H
25 #define __BOARD_STATISTICS_TOOL_H
26 
30 #include <pcb_edit_frame.h>
31 #include <tools/pcb_actions.h>
32 #include <tools/pcb_tool_base.h>
33 
34 class CONNECTIVITY_DATA;
35 
41 class PCB_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
42 {
43 public:
45 
47  bool Init() override;
48 
50  void Reset( RESET_REASON aReason ) override;
51 
57  int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
58 
60  int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
61 
63  int HighlightNet( const TOOL_EVENT& aEvent );
64 
66  int ClearHighlight( const TOOL_EVENT& aEvent );
67 
69  int HighlightNetTool( const TOOL_EVENT& aEvent );
70 
72  int HighlightItem( const TOOL_EVENT& aEvent );
73 
75  int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
76 
78  int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
79 
81  int LocalRatsnestTool( const TOOL_EVENT& aEvent );
82 
83  int FlipPcbView( const TOOL_EVENT& aEvent );
84 
85  int ListNets( const TOOL_EVENT& aEvent );
86 
88  int HideNet( const TOOL_EVENT& aEvent );
89 
91  int ShowNet( const TOOL_EVENT& aEvent );
92 
94  int InspectClearance( const TOOL_EVENT& aEvent );
95 
96 private:
98  void ratsnestTimer( wxTimerEvent& aEvent );
99 
101  void calculateSelectionRatsnest( const VECTOR2I& aDelta );
102 
103  bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
104 
105  void doHideNet( int aNetCode, bool aHide );
106 
108  void setTransitions() override;
109 
110  void onListNetsDialogClosed( wxCommandEvent& aEvent );
111  void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
112 
113  void reportZoneConnection( ZONE_CONTAINER* aZone, D_PAD* aPad, REPORTER* r );
114 
116  REPORTER* r );
117 
118 private:
119  PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
120 
121  bool m_probingSchToPcb; // Recursion guard when cross-probing to EESchema
122  int m_lastNetcode; // Used for toggling between last two highlighted nets
123 
124  CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
125 
126  std::unique_ptr<DIALOG_SELECT_NET_FROM_LIST> m_listNetsDialog;
128 
129  std::unique_ptr<DIALOG_HTML_REPORTER> m_inspectClearanceDialog;
130 };
131 
132 #endif //__BOARD_STATISTICS_TOOL_H
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
DIALOG_SELECT_NET_FROM_LIST::SETTINGS m_listNetsDialogSettings
int InspectClearance(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items
int HighlightNetTool(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
void reportCopperClearance(PCB_LAYER_ID aLayer, BOARD_CONNECTED_ITEM *aA, BOARD_ITEM *aB, REPORTER *r)
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Notifies eeschema about the selected item.
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...
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
void reportZoneConnection(ZONE_CONTAINER *aZone, D_PAD *aPad, REPORTER *r)
std::unique_ptr< DIALOG_SELECT_NET_FROM_LIST > m_listNetsDialog
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected and have...
int HideNet(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net
void onListNetsDialogClosed(wxCommandEvent &aEvent)
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Function ShowStatisticDialog()
void doHideNet(int aNetCode, bool aHide)
PCB_EDIT_FRAME * m_frame
PCB_LAYER_ID
A quick note on layer IDs:
int HighlightItem(const TOOL_EVENT &aEvent)
Performs the appropriate action in response to an eeschema cross-probe.
TOOL_EVENT.
Definition: tool_event.h:171
PCB_INSPECTION_TOOL.
CONNECTIVITY_DATA * m_dynamicData
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
Recalculates dynamic ratsnest for the current selection
int HideDynamicRatsnest(const TOOL_EVENT &aEvent)
Hides ratsnest for selected items. Called when there are no items selected.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
std::unique_ptr< DIALOG_HTML_REPORTER > m_inspectClearanceDialog
int FlipPcbView(const TOOL_EVENT &aEvent)
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Shows local ratsnest of a component
PCB_EDIT_FRAME is the main frame for Pcbnew.
RESET_REASON
Determines the reason of reset for a tool
Definition: tool_base.h:79
int ListNets(const TOOL_EVENT &aEvent)
void onInspectClearanceDialogClosed(wxCommandEvent &aEvent)
int ClearHighlight(const TOOL_EVENT &aEvent)
Clears all board highlights
int ShowNet(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest