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
29#include <drc/drc_rule.h>
30#include <drc/drc_engine.h>
31#include <pcb_edit_frame.h>
32#include <rc_item.h>
33#include <tools/pcb_actions.h>
34#include <tools/pcb_tool_base.h>
35
37
38
42class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
43{
44public:
46
48 bool Init() override;
49
51 void Reset( RESET_REASON aReason ) override;
52
56 int ShowBoardStatistics( const TOOL_EVENT& aEvent );
57
59 int HighlightNet( const TOOL_EVENT& aEvent );
60
62 int ClearHighlight( const TOOL_EVENT& aEvent );
63
65 int HighlightItem( const TOOL_EVENT& aEvent );
66
68 int UpdateLocalRatsnest( const TOOL_EVENT& aEvent );
69
71 int HideLocalRatsnest( const TOOL_EVENT& aEvent );
72
74 int LocalRatsnestTool( const TOOL_EVENT& aEvent );
75
76 int ListNets( const TOOL_EVENT& aEvent );
77
79 int HideNetInRatsnest( const TOOL_EVENT& aEvent );
80
82 int ShowNetInRatsnest( const TOOL_EVENT& aEvent );
83
84 void InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
85
87 int InspectClearance( const TOOL_EVENT& aEvent );
88
89 int InspectConstraints( const TOOL_EVENT& aEvent );
90
94 bool IsNetHighlightSet() const
95 {
96 return !m_currentlyHighlighted.empty();
97 }
98
99private:
101 void calculateSelectionRatsnest( const VECTOR2I& aDelta );
102
110 bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
111
112 void doHideRatsnestNet( int aNetCode, bool aHide );
113
115 void setTransitions() override;
116
117 void onListNetsDialogClosed( wxCommandEvent& aEvent );
118 void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
119 void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent );
120
121 DRC_ENGINE makeDRCEngine( bool* aCompileError, bool* aCourtyardError = nullptr );
122
123 wxString getItemDescription( BOARD_ITEM* aItem );
124
125 void reportCompileError( REPORTER* r );
126 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, REPORTER* r );
127 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, REPORTER* r );
128 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, PCB_LAYER_ID aLayer,
129 REPORTER* r );
130
131private:
132 PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
133
134 std::set<int> m_currentlyHighlighted; // Active net being highlighted, or -1 when off
135 std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
136
137 CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
138
139 std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
141
142 std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectClearanceDialog;
143 std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
144};
145
146#endif //BOARD_INSPECTION_TOOL_H
Tool for pcb inspection.
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.
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 ShowBoardStatistics(const TOOL_EVENT &aEvent)
Show dialog with board statistics.
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 LocalRatsnestTool(const TOOL_EVENT &aEvent)
std::set< int > m_lastHighlighted
bool Init() override
Init() is called once upon a registration of the tool.
int ShowNetInRatsnest(const TOOL_EVENT &aEvent)
void reportCompileError(REPORTER *r)
int ClearHighlight(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
int HideNetInRatsnest(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
void onListNetsDialogClosed(wxCommandEvent &aEvent)
int InspectConstraints(const TOOL_EVENT &aEvent)
void doHideRatsnestNet(int aNetCode, bool aHide)
Bind handlers to corresponding TOOL_ACTIONs.
wxString getItemDescription(BOARD_ITEM *aItem)
void onInspectConstraintsDialogClosed(wxCommandEvent &aEvent)
CONNECTIVITY_DATA * m_dynamicData
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.
std::unique_ptr< DIALOG_CONSTRAINTS_REPORTER > m_inspectClearanceDialog
std::set< int > m_currentlyHighlighted
int UpdateLocalRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
int HideLocalRatsnest(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
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:70
Design Rule Checker object that performs all the DRC tests.
Definition: drc_engine.h:83
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:156
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59