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 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 
27 
29 #include <pcb_edit_frame.h>
30 #include <tools/pcb_actions.h>
31 #include <tools/pcb_tool_base.h>
32 
33 
39 class PCB_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
40 {
41 public:
43 
45  bool Init() override;
46 
48  void Reset( RESET_REASON aReason ) override;
49 
55  int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
56 
58  int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
59 
61  int HighlightNet( const TOOL_EVENT& aEvent );
62 
64  int ClearHighlight( const TOOL_EVENT& aEvent );
65 
67  int HighlightNetTool( const TOOL_EVENT& aEvent );
68 
70  int HighlightItem( const TOOL_EVENT& aEvent );
71 
73  int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
74 
76  int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
77 
79  int LocalRatsnestTool( const TOOL_EVENT& aEvent );
80 
81  int FlipPcbView( const TOOL_EVENT& aEvent );
82 
83  int ListNets( const TOOL_EVENT& aEvent );
84 
85 private:
87  void ratsnestTimer( wxTimerEvent& aEvent );
88 
91 
92  bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
93 
95  void setTransitions() override;
96 
97 private:
98  PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
99 
100  bool m_probingSchToPcb; // Recursion guard when cross-probing to EESchema
101  int m_lastNetcode; // Used for toggling between last two highlighted nets
102 
103  bool m_slowRatsnest; // Indicates current selection ratsnest will be slow to calculate
104  wxTimer m_ratsnestTimer; // Timer to initiate lazy ratsnest calculation (ie: when slow)
105 };
106 
107 #endif //__BOARD_STATISTICS_TOOL_H
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Updates ratsnest for selected items.
int HighlightNet(const TOOL_EVENT &aEvent)
Highlights net belonging to the item under the cursor.
int HighlightNetTool(const TOOL_EVENT &aEvent)
Launches a tool to pick the item whose net is going to be highlighted.
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...
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Function ShowStatisticDialog()
PCB_EDIT_FRAME * m_frame
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.
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.
int FlipPcbView(const TOOL_EVENT &aEvent)
void calculateSelectionRatsnest()
Recalculates dynamic ratsnest for the current selection
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)
int ClearHighlight(const TOOL_EVENT &aEvent)
Clears all board highlights
void ratsnestTimer(wxTimerEvent &aEvent)
Event handler to recalculate dynamic ratsnest