KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2023 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
28#include <drc/drc_rule.h>
29#include <drc/drc_engine.h>
30#include <pcb_edit_frame.h>
31#include <rc_item.h>
32#include <tools/pcb_actions.h>
33#include <tools/pcb_tool_base.h>
34
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
77 int HideNetInRatsnest( const TOOL_EVENT& aEvent );
78
80 int ShowNetInRatsnest( const TOOL_EVENT& aEvent );
81
82 wxString InspectDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem );
83 void InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
84
86 int InspectClearance( const TOOL_EVENT& aEvent );
87
88 int InspectConstraints( const TOOL_EVENT& aEvent );
89
90 int ShowFootprintLinks( const TOOL_EVENT& aEvent );
91
92 int DiffFootprint( const TOOL_EVENT& aEvent );
93 void DiffFootprint( FOOTPRINT* aFootprint );
94
98 bool IsNetHighlightSet() const
99 {
100 return !m_currentlyHighlighted.empty();
101 }
102
103private:
105 void calculateSelectionRatsnest( const VECTOR2I& aDelta );
106
114 bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
115
116 void doHideRatsnestNet( int aNetCode, bool aHide );
117
119 void setTransitions() override;
120
121 std::unique_ptr<DRC_ENGINE> makeDRCEngine( bool* aCompileError, bool* aCourtyardError );
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
131 FOOTPRINT_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel );
132
133private:
134 PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
135
136 std::set<int> m_currentlyHighlighted; // Active net being highlighted, or -1 when off
137 std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
138
139 CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
140};
141
142#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.
wxString InspectDRCErrorMenuText(const std::shared_ptr< RC_ITEM > &aDRCItem)
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 DiffFootprint(const TOOL_EVENT &aEvent)
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
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.
std::unique_ptr< DRC_ENGINE > makeDRCEngine(bool *aCompileError, bool *aCourtyardError)
int HideNetInRatsnest(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
int InspectConstraints(const TOOL_EVENT &aEvent)
void doHideRatsnestNet(int aNetCode, bool aHide)
Bind handlers to corresponding TOOL_ACTIONs.
wxString getItemDescription(BOARD_ITEM *aItem)
CONNECTIVITY_DATA * m_dynamicData
int ShowFootprintLinks(const TOOL_EVENT &aEvent)
void reportHeader(const wxString &aTitle, BOARD_ITEM *a, REPORTER *r)
FOOTPRINT_DIFF_WIDGET * constructDiffPanel(wxPanel *aParentPanel)
int InspectClearance(const TOOL_EVENT &aEvent)
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:79
The main frame for Pcbnew.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
RESET_REASON
Determine the reason of reset for a tool.
Definition: tool_base.h:78
Generic, UI-independent tool event.
Definition: tool_event.h:167
void Reset() override
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60