2019-07-16 19:34:07 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-01-27 22:15:38 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-07-16 19:34:07 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
#ifndef BOARD_INSPECTION_TOOL_H
|
|
|
|
#define BOARD_INSPECTION_TOOL_H
|
2019-07-16 19:34:07 +00:00
|
|
|
|
|
|
|
#include <dialogs/dialog_board_statistics.h>
|
2020-11-11 12:59:59 +00:00
|
|
|
#include <dialogs/dialog_net_inspector.h>
|
2020-09-10 19:58:05 +00:00
|
|
|
#include <dialogs/dialog_HTML_reporter_base.h>
|
2020-09-22 23:16:02 +00:00
|
|
|
#include <dialogs/dialog_constraints_reporter.h>
|
2019-07-16 19:34:07 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
|
|
|
#include <tools/pcb_tool_base.h>
|
|
|
|
|
2020-08-15 00:33:27 +00:00
|
|
|
class CONNECTIVITY_DATA;
|
|
|
|
|
2020-10-16 23:15:44 +00:00
|
|
|
|
|
|
|
class DIALOG_INSPECTION_REPORTER : public DIALOG_HTML_REPORTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_INSPECTION_REPORTER( PCB_EDIT_FRAME* aFrame ) :
|
|
|
|
DIALOG_HTML_REPORTER( aFrame ),
|
|
|
|
m_frame( aFrame )
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
PCB_EDIT_FRAME* m_frame;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-07-16 19:34:07 +00:00
|
|
|
/**
|
|
|
|
* Tool for pcb inspection.
|
|
|
|
*/
|
2020-12-16 13:31:32 +00:00
|
|
|
class BOARD_INSPECTION_TOOL : public wxEvtHandler, public PCB_TOOL_BASE
|
2019-07-16 19:34:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-12-16 13:31:32 +00:00
|
|
|
BOARD_INSPECTION_TOOL();
|
2019-07-16 19:34:07 +00:00
|
|
|
|
2019-08-12 14:41:45 +00:00
|
|
|
/// @copydoc TOOL_INTERACTIVE::Init()
|
|
|
|
bool Init() override;
|
|
|
|
|
|
|
|
/// @copydoc TOOL_INTERACTIVE::Reset()
|
|
|
|
void Reset( RESET_REASON aReason ) override;
|
|
|
|
|
2019-07-16 19:34:07 +00:00
|
|
|
/**
|
2021-01-27 22:15:38 +00:00
|
|
|
* Show dialog with board statistics.
|
2019-07-16 19:34:07 +00:00
|
|
|
*/
|
|
|
|
int ShowStatisticsDialog( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Notify Eeschema about the selected item.
|
2019-08-12 14:41:45 +00:00
|
|
|
int CrossProbePcbToSch( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Highlight net belonging to the item under the cursor.
|
2019-08-12 14:41:45 +00:00
|
|
|
int HighlightNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Clear all board highlights
|
2019-08-12 14:41:45 +00:00
|
|
|
int ClearHighlight( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Launch a tool to pick the item whose net is going to be highlighted.
|
2019-08-12 14:41:45 +00:00
|
|
|
int HighlightNetTool( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Perform the appropriate action in response to an Eeschema cross-probe.
|
2019-08-12 14:41:45 +00:00
|
|
|
int HighlightItem( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Update ratsnest for selected items.
|
2019-08-12 14:41:45 +00:00
|
|
|
int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Hide ratsnest for selected items. Called when there are no items selected.
|
2019-08-12 14:41:45 +00:00
|
|
|
int HideDynamicRatsnest( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Show local ratsnest of a component.
|
2019-08-12 14:41:45 +00:00
|
|
|
int LocalRatsnestTool( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int FlipPcbView( const TOOL_EVENT& aEvent );
|
|
|
|
|
|
|
|
int ListNets( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Hide the ratsnest for a given net.
|
2020-07-11 01:06:17 +00:00
|
|
|
int HideNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Show the ratsnest for a given net.
|
2020-07-11 01:06:17 +00:00
|
|
|
int ShowNet( const TOOL_EVENT& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Show the clearance resolution for two selected items.
|
2020-09-10 19:58:05 +00:00
|
|
|
int InspectClearance( const TOOL_EVENT& aEvent );
|
|
|
|
|
2020-09-22 23:16:02 +00:00
|
|
|
int InspectConstraints( const TOOL_EVENT& aEvent );
|
|
|
|
|
2019-08-12 14:41:45 +00:00
|
|
|
private:
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Event handler to recalculate dynamic ratsnest.
|
2019-08-12 14:41:45 +00:00
|
|
|
void ratsnestTimer( wxTimerEvent& aEvent );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Recalculate dynamic ratsnest for the current selection.
|
2020-08-15 00:33:27 +00:00
|
|
|
void calculateSelectionRatsnest( const VECTOR2I& aDelta );
|
2019-08-12 14:41:45 +00:00
|
|
|
|
2021-03-02 13:10:37 +00:00
|
|
|
/**
|
|
|
|
* Look for a #BOARD_CONNECTED_ITEM in a given spot and if one is found - it enables
|
|
|
|
* highlight for its net.
|
|
|
|
*
|
|
|
|
* @param aPosition is the point where an item is expected (world coordinates).
|
|
|
|
* @param aUseSelection is true if we should use the current selection to pick the netcode
|
|
|
|
*/
|
2019-08-12 14:41:45 +00:00
|
|
|
bool highlightNet( const VECTOR2D& aPosition, bool aUseSelection );
|
|
|
|
|
2020-07-11 01:06:17 +00:00
|
|
|
void doHideNet( int aNetCode, bool aHide );
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
///< Bind handlers to corresponding TOOL_ACTIONs.
|
2019-07-16 19:34:07 +00:00
|
|
|
void setTransitions() override;
|
2019-08-12 14:41:45 +00:00
|
|
|
|
2020-09-10 19:58:05 +00:00
|
|
|
void onListNetsDialogClosed( wxCommandEvent& aEvent );
|
|
|
|
void onInspectClearanceDialogClosed( wxCommandEvent& aEvent );
|
2020-09-22 23:16:02 +00:00
|
|
|
void onInspectConstraintsDialogClosed( wxCommandEvent& aEvent );
|
2020-04-13 11:54:35 +00:00
|
|
|
|
2020-11-12 22:30:02 +00:00
|
|
|
void reportZoneConnection( ZONE* aZone, PAD* aPad, REPORTER* r );
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2021-01-01 22:29:15 +00:00
|
|
|
void reportClearance( DRC_CONSTRAINT_T aClearanceType, PCB_LAYER_ID aLayer, BOARD_ITEM* aA,
|
|
|
|
BOARD_ITEM* aB, REPORTER* r );
|
2020-09-11 23:25:10 +00:00
|
|
|
|
2020-12-03 23:02:41 +00:00
|
|
|
wxString getItemDescription( BOARD_ITEM* aItem );
|
|
|
|
|
2019-08-12 14:41:45 +00:00
|
|
|
private:
|
|
|
|
PCB_EDIT_FRAME* m_frame; // Pointer to the currently used edit frame.
|
|
|
|
|
2021-01-27 22:15:38 +00:00
|
|
|
bool m_probingSchToPcb; // Recursion guard when cross-probing to Eeschema
|
2019-08-12 14:41:45 +00:00
|
|
|
int m_lastNetcode; // Used for toggling between last two highlighted nets
|
|
|
|
|
2020-08-15 00:33:27 +00:00
|
|
|
CONNECTIVITY_DATA* m_dynamicData; // Cached connectivity data from the selection
|
2020-04-13 11:37:42 +00:00
|
|
|
|
2020-11-11 12:59:59 +00:00
|
|
|
std::unique_ptr<DIALOG_NET_INSPECTOR> m_listNetsDialog;
|
|
|
|
DIALOG_NET_INSPECTOR::SETTINGS m_listNetsDialogSettings;
|
2020-08-15 00:33:27 +00:00
|
|
|
|
2020-10-16 23:15:44 +00:00
|
|
|
std::unique_ptr<DIALOG_INSPECTION_REPORTER> m_inspectClearanceDialog;
|
2020-09-22 23:16:02 +00:00
|
|
|
std::unique_ptr<DIALOG_CONSTRAINTS_REPORTER> m_inspectConstraintsDialog;
|
2019-07-16 19:34:07 +00:00
|
|
|
};
|
|
|
|
|
2020-12-16 13:31:32 +00:00
|
|
|
#endif //BOARD_INSPECTION_TOOL_H
|