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 <drc/drc_rule.h>
32#include <drc/drc_engine.h>
33#include <pcb_edit_frame.h>
34#include <rc_item.h>
35#include <tools/pcb_actions.h>
36#include <tools/pcb_tool_base.h>
37
39
40
44class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
45{
46public:
48
50 bool Init() override;
51
53 void Reset( RESET_REASON aReason ) override;
54
58 int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
59
61 int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
62
64 int HighlightNet( const TOOL_EVENT& aEvent );
65
67 int ClearHighlight( const TOOL_EVENT& aEvent );
68
70 int HighlightNetTool( const TOOL_EVENT& aEvent );
71
73 int HighlightItem( const TOOL_EVENT& aEvent );
74
76 int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
77
79 int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
80
82 int LocalRatsnestTool( const TOOL_EVENT& aEvent );
83
84 int FlipPcbView( const TOOL_EVENT& aEvent );
85
86 int ListNets( const TOOL_EVENT& aEvent );
87
89 int HideNet( const TOOL_EVENT& aEvent );
90
92 int ShowNet( const TOOL_EVENT& aEvent );
93
94 void InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
95
97 int InspectClearance( const TOOL_EVENT& aEvent );
98
99 int InspectConstraints( const TOOL_EVENT& aEvent );
100
104 bool IsNetHighlightSet() const
105 {
106 return !m_currentlyHighlighted.empty();
107 }
108
109 static bool HasHole( BOARD_ITEM* aItem );
110
111private:
113 void calculateSelectionRatsnest( const VECTOR2I& aDelta );
114
122 bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
123
124 void doHideNet( int aNetCode, bool aHide );
125
127 void setTransitions() override;
128
129 void onListNetsDialogClosed( wxCommandEvent& aEvent );
130 void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
131 void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent );
132
133 DRC_ENGINE makeDRCEngine( bool* aCompileError, bool* aCourtyardError = nullptr );
134
135 wxString getItemDescription( BOARD_ITEM* aItem );
136
138 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, REPORTER* r );
139 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, REPORTER* r );
140 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, PCB_LAYER_ID aLayer,
141 REPORTER* r );
142
143private:
144 PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
145
146 bool m_probingSchToPcb; // Recursion guard when cross-probing to Eeschema
147 std::set<int> m_currentlyHighlighted; // Active net being highlighted, or -1 when off
148 std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
149
150 CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
151
152 std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
154
155 std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectClearanceDialog;
156 std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
157};
158
159#endif //BOARD_INSPECTION_TOOL_H
Tool for pcb inspection.
int ShowStatisticsDialog(const TOOL_EVENT &aEvent)
Show dialog with board statistics.
static bool HasHole(BOARD_ITEM *aItem)
void InspectDRCError(const std::shared_ptr< RC_ITEM > &aDRCItem)
Show the clearance resolution for two selected items.
int HighlightNet(const TOOL_EVENT &aEvent)
Clear all board highlights.
int HideNet(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
< Recalculate dynamic ratsnest for the current selection.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int HideDynamicRatsnest(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectConstraintsDialog
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...
int ListNets(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
std::unique_ptr< DIALOG_NET_INSPECTOR > m_listNetsDialog
int CrossProbePcbToSch(const TOOL_EVENT &aEvent)
Highlight net belonging to the item under the cursor.
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
std::set< int > m_lastHighlighted
bool Init() override
Init() is called once upon a registration of the tool.
void reportCompileError(REPORTER *r)
int ShowNet(const TOOL_EVENT &aEvent)
int ClearHighlight(const TOOL_EVENT &aEvent)
Launch a tool to pick the item whose net is going to be highlighted.
void onListNetsDialogClosed(wxCommandEvent &aEvent)
int InspectConstraints(const TOOL_EVENT &aEvent)
wxString getItemDescription(BOARD_ITEM *aItem)
void onInspectConstraintsDialogClosed(wxCommandEvent &aEvent)
CONNECTIVITY_DATA * m_dynamicData
int HighlightNetTool(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
int UpdateSelectionRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
void reportHeader(const wxString &aTitle, BOARD_ITEM *a, REPORTER *r)
DRC_ENGINE makeDRCEngine(bool *aCompileError, bool *aCourtyardError=nullptr)
void onInspectClearanceDialogClosed(wxCommandEvent &aEvent)
int InspectClearance(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int FlipPcbView(const TOOL_EVENT &aEvent)
void doHideNet(int aNetCode, bool aHide)
Bind handlers to corresponding TOOL_ACTIONs.
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectClearanceDialog
std::set< int > m_currentlyHighlighted
int HighlightItem(const TOOL_EVENT &aEvent)
Update ratsnest for selected items.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:53
Design Rule Checker object that performs all the DRC tests.
Definition: drc_engine.h:82
The main frame for Pcbnew.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:71
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:155
E_SERIE r
Definition: eserie.cpp:41
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59