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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef BOARD_INSPECTION_TOOL_H
21#define BOARD_INSPECTION_TOOL_H
22
24#include <pcb_edit_frame.h>
25#include <rc_item.h>
26#include <tools/pcb_actions.h>
27#include <tools/pcb_tool_base.h>
28
30class DRC_ENGINE;
32
33
37class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
38{
39public:
41
43 bool Init() override;
44
46 void Reset( RESET_REASON aReason ) override;
47
51 int ShowBoardStatistics( const TOOL_EVENT& aEvent );
52
54 int HighlightNet( const TOOL_EVENT& aEvent );
55 int HighlightNetChain( const TOOL_EVENT& aEvent );
56 int ReplaceTerminalPad( const TOOL_EVENT& aEvent );
57
59 int ClearHighlight( const TOOL_EVENT& aEvent );
60
62 int HighlightItem( const TOOL_EVENT& aEvent );
63
65 int UpdateLocalRatsnest( const TOOL_EVENT& aEvent );
66
68 int HideLocalRatsnest( const TOOL_EVENT& aEvent );
69
71 int LocalRatsnestTool( const TOOL_EVENT& aEvent );
72
74 int HideNetInRatsnest( const TOOL_EVENT& aEvent );
75
77 int ShowNetInRatsnest( const TOOL_EVENT& aEvent );
78
79 wxString InspectDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem );
80 void InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
81
83 int InspectClearance( const TOOL_EVENT& aEvent );
84
85 int InspectConstraints( const TOOL_EVENT& aEvent );
86
87 int ShowFootprintLinks( const TOOL_EVENT& aEvent );
88
89 int DiffFootprint( const TOOL_EVENT& aEvent );
90 void DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo = nullptr );
91
93 int CompareBoardWithFile( const TOOL_EVENT& aEvent );
94
96 int CompareBoardWithHistory( const TOOL_EVENT& aEvent );
97
101 bool IsNetHighlightSet() const
102 {
103 return !m_currentlyHighlighted.empty();
104 }
105
106private:
108 int showBoardComparison( const wxString& aOtherPath, const wxString& aProjectPath,
109 const wxString& aComparisonLabel );
110
112 void calculateSelectionRatsnest( const VECTOR2I& aDelta );
113
121 bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
122
123 void doHideRatsnestNet( int aNetCode, bool aHide );
124
126 void setTransitions() override;
127
128 std::unique_ptr<DRC_ENGINE> makeDRCEngine( bool* aCompileError, bool* aCourtyardError );
129
130 wxString getItemDescription( const BOARD_ITEM* aItem );
131
132 void reportCompileError( REPORTER* r );
133 void reportHeader( const wxString& aTitle, const BOARD_ITEM* a, REPORTER* r );
134 void reportHeader( const wxString& aTitle, const BOARD_ITEM* a, const BOARD_ITEM* b, REPORTER* r );
135 void reportHeader( const wxString& aTitle, const BOARD_ITEM* a, const BOARD_ITEM* b, PCB_LAYER_ID aLayer,
136 REPORTER* r );
137
138 FOOTPRINT_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel );
139
140 void reportClearance( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB );
141
142 void filterCollectorForInspection( GENERAL_COLLECTOR& aCollector, const VECTOR2I& aPos );
143
144 BOARD_ITEM* pickItemForInspection( const TOOL_EVENT& aEvent, const wxString& aPrompt,
145 const std::vector<KICAD_T>& aTypes, BOARD_ITEM* aLockedHighlight );
146
147public:
149
150private:
151 PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
152
153 std::set<int> m_currentlyHighlighted; // Active net being highlighted, or -1 when off
154 std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
155
156 CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
157};
158
159#endif //BOARD_INSPECTION_TOOL_H
void InspectDRCError(const std::shared_ptr< RC_ITEM > &aDRCItem)
int HighlightNet(const TOOL_EVENT &aEvent)
Highlight net belonging to the item under the cursor.
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
Recalculate dynamic ratsnest for the current selection.
void setTransitions() override
Bind handlers to corresponding TOOL_ACTIONs.
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 HighlightNetChain(const TOOL_EVENT &aEvent)
int DiffFootprint(const TOOL_EVENT &aEvent)
wxString getItemDescription(const BOARD_ITEM *aItem)
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Show local ratsnest of a component.
bool Init() override
Init() is called once upon a registration of the tool.
int ShowNetInRatsnest(const TOOL_EVENT &aEvent)
Show the ratsnest for a given net.
void reportCompileError(REPORTER *r)
int ClearHighlight(const TOOL_EVENT &aEvent)
Clear all board highlights.
void reportClearance(const BOARD_ITEM *aItemA, const BOARD_ITEM *aItemB)
std::unique_ptr< DRC_ENGINE > makeDRCEngine(bool *aCompileError, bool *aCourtyardError)
int HideNetInRatsnest(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
int InspectConstraints(const TOOL_EVENT &aEvent)
void doHideRatsnestNet(int aNetCode, bool aHide)
BOARD_ITEM * pickItemForInspection(const TOOL_EVENT &aEvent, const wxString &aPrompt, const std::vector< KICAD_T > &aTypes, BOARD_ITEM *aLockedHighlight)
CONNECTIVITY_DATA * m_dynamicData
int showBoardComparison(const wxString &aOtherPath, const wxString &aProjectPath, const wxString &aComparisonLabel)
Diff the board at aOtherPath against the live one and show the dialog.
int ReplaceTerminalPad(const TOOL_EVENT &aEvent)
int ShowFootprintLinks(const TOOL_EVENT &aEvent)
void filterCollectorForInspection(GENERAL_COLLECTOR &aCollector, const VECTOR2I &aPos)
int CompareBoardWithFile(const TOOL_EVENT &aEvent)
Diff the current board against a user-selected .kicad_pcb file.
FOOTPRINT_DIFF_WIDGET * constructDiffPanel(wxPanel *aParentPanel)
int InspectClearance(const TOOL_EVENT &aEvent)
Show the clearance resolution for two selected items.
std::set< int > m_currentlyHighlighted
int UpdateLocalRatsnest(const TOOL_EVENT &aEvent)
Update ratsnest for selected items.
void reportHeader(const wxString &aTitle, const BOARD_ITEM *a, REPORTER *r)
int CompareBoardWithHistory(const TOOL_EVENT &aEvent)
Diff the current board against the most recent local-history commit.
int HideLocalRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
int HighlightItem(const TOOL_EVENT &aEvent)
Perform the appropriate action in response to an Eeschema cross-probe.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:85
Design Rule Checker object that performs all the DRC tests.
Definition drc_engine.h:129
Used when the right click button is pressed, or when the select tool is in effect.
Definition collectors.h:203
The main frame for Pcbnew.
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
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:56
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707