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 <drc/drc_rule.h>
25#include <drc/drc_engine.h>
26#include <pcb_edit_frame.h>
27#include <rc_item.h>
28#include <tools/pcb_actions.h>
29#include <tools/pcb_tool_base.h>
30
33
34
38class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
39{
40public:
42
44 bool Init() override;
45
47 void Reset( RESET_REASON aReason ) override;
48
52 int ShowBoardStatistics( const TOOL_EVENT& aEvent );
53
55 int HighlightNet( const TOOL_EVENT& aEvent );
56 int HighlightNetChain( const TOOL_EVENT& aEvent );
57 int ReplaceTerminalPad( const TOOL_EVENT& aEvent );
58
60 int ClearHighlight( const TOOL_EVENT& aEvent );
61
63 int HighlightItem( const TOOL_EVENT& aEvent );
64
66 int UpdateLocalRatsnest( const TOOL_EVENT& aEvent );
67
69 int HideLocalRatsnest( const TOOL_EVENT& aEvent );
70
72 int LocalRatsnestTool( const TOOL_EVENT& aEvent );
73
75 int HideNetInRatsnest( const TOOL_EVENT& aEvent );
76
78 int ShowNetInRatsnest( const TOOL_EVENT& aEvent );
79
80 wxString InspectDRCErrorMenuText( const std::shared_ptr<RC_ITEM>& aDRCItem );
81 void InspectDRCError( const std::shared_ptr<RC_ITEM>& aDRCItem );
82
84 int InspectClearance( const TOOL_EVENT& aEvent );
85
86 int InspectConstraints( const TOOL_EVENT& aEvent );
87
88 int ShowFootprintLinks( const TOOL_EVENT& aEvent );
89
90 int DiffFootprint( const TOOL_EVENT& aEvent );
91 void DiffFootprint( FOOTPRINT* aFootprint, wxTopLevelWindow* aReparentTo = nullptr );
92
94 int CompareBoardWithFile( const TOOL_EVENT& aEvent );
95
97 int CompareBoardWithHistory( const TOOL_EVENT& aEvent );
98
102 bool IsNetHighlightSet() const
103 {
104 return !m_currentlyHighlighted.empty();
105 }
106
108
109private:
111 int showBoardComparison( const wxString& aOtherPath, const wxString& aProjectPath,
112 const wxString& aComparisonLabel );
113
115 void calculateSelectionRatsnest( const VECTOR2I& aDelta );
116
124 bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
125
126 void doHideRatsnestNet( int aNetCode, bool aHide );
127
129 void setTransitions() override;
130
131 std::unique_ptr<DRC_ENGINE> makeDRCEngine( bool* aCompileError, bool* aCourtyardError );
132
133 wxString getItemDescription( BOARD_ITEM* aItem );
134
135 void reportCompileError( REPORTER* r );
136 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, REPORTER* r );
137 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, REPORTER* r );
138 void reportHeader( const wxString& aTitle, BOARD_ITEM* a, BOARD_ITEM* b, PCB_LAYER_ID aLayer,
139 REPORTER* r );
140
141 FOOTPRINT_DIFF_WIDGET* constructDiffPanel( wxPanel* aParentPanel );
142
143 void reportClearance( BOARD_ITEM* aItemA, BOARD_ITEM* aItemB );
144
145 void filterCollectorForInspection( GENERAL_COLLECTOR& aCollector, const VECTOR2I& aPos );
146
147 BOARD_ITEM* pickItemForInspection( const TOOL_EVENT& aEvent, const wxString& aPrompt,
148 const std::vector<KICAD_T>& aTypes,
149 BOARD_ITEM* aLockedHighlight );
150
151private:
152 PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
153
154 std::set<int> m_currentlyHighlighted; // Active net being highlighted, or -1 when off
155 std::set<int> m_lastHighlighted; // For toggling between last two highlighted nets
156
157 CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
158};
159
160#endif //BOARD_INSPECTION_TOOL_H
void InspectDRCError(const std::shared_ptr< RC_ITEM > &aDRCItem)
Show the clearance resolution for two selected items.
int HighlightNet(const TOOL_EVENT &aEvent)
void calculateSelectionRatsnest(const VECTOR2I &aDelta)
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 HighlightNetChain(const TOOL_EVENT &aEvent)
int DiffFootprint(const TOOL_EVENT &aEvent)
void reportClearance(BOARD_ITEM *aItemA, BOARD_ITEM *aItemB)
int LocalRatsnestTool(const TOOL_EVENT &aEvent)
Hide the ratsnest for a given net.
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.
BOARD_ITEM * pickItemForInspection(const TOOL_EVENT &aEvent, const wxString &aPrompt, const std::vector< KICAD_T > &aTypes, BOARD_ITEM *aLockedHighlight)
wxString getItemDescription(BOARD_ITEM *aItem)
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)
Clear all board highlights.
int ShowFootprintLinks(const TOOL_EVENT &aEvent)
void reportHeader(const wxString &aTitle, BOARD_ITEM *a, REPORTER *r)
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)
std::set< int > m_currentlyHighlighted
int UpdateLocalRatsnest(const TOOL_EVENT &aEvent)
Hide ratsnest for selected items. Called when there are no items selected.
int CompareBoardWithHistory(const TOOL_EVENT &aEvent)
Diff the current board against the most recent local-history commit.
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:81
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:71
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:683
VECTOR2< double > VECTOR2D
Definition vector2d.h:682