2011-10-31 20:29:46 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-17 14:36:04 +00:00
|
|
|
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2016-09-08 18:17:37 +00:00
|
|
|
* Copyright (C) 2009-2016 Dick Hollenbeck, dick@softplc.com
|
2023-03-09 11:25:32 +00:00
|
|
|
* Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2011-10-31 20:29:46 +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
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-01-15 15:26:13 +00:00
|
|
|
#include <confirm.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_drc.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <board_design_settings.h>
|
2021-09-14 22:45:14 +00:00
|
|
|
#include <kiface_base.h>
|
2021-03-20 15:35:37 +00:00
|
|
|
#include <macros.h>
|
2021-06-06 19:03:10 +00:00
|
|
|
#include <pad.h>
|
2021-12-01 14:42:44 +00:00
|
|
|
#include <drc/drc_item.h>
|
2023-08-13 18:44:31 +00:00
|
|
|
#include <drc/drc_report.h>
|
2021-12-01 14:42:44 +00:00
|
|
|
#include <connectivity/connectivity_data.h>
|
2022-01-22 23:22:15 +00:00
|
|
|
#include <connectivity/connectivity_algo.h>
|
2022-08-15 16:59:34 +00:00
|
|
|
#include <drawing_sheet/ds_proxy_view_item.h>
|
2018-01-29 20:58:58 +00:00
|
|
|
#include <pcb_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2018-01-28 09:35:33 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2020-01-15 15:26:13 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-11-14 18:11:28 +00:00
|
|
|
#include <pcb_marker.h>
|
2024-03-01 23:19:13 +00:00
|
|
|
#include <pgm_base.h>
|
2021-06-07 21:56:43 +00:00
|
|
|
#include <wx/filedlg.h>
|
2020-02-24 23:17:30 +00:00
|
|
|
#include <wx/wupdlock.h>
|
2020-07-11 17:42:00 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2020-02-28 00:05:40 +00:00
|
|
|
#include <widgets/ui_common.h>
|
2021-08-14 20:05:21 +00:00
|
|
|
#include <widgets/progress_reporter_base.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <widgets/wx_html_report_box.h>
|
2020-09-24 14:17:18 +00:00
|
|
|
#include <dialogs/panel_setup_rules_base.h>
|
2020-09-14 17:54:14 +00:00
|
|
|
#include <tools/drc_tool.h>
|
2021-06-16 15:11:17 +00:00
|
|
|
#include <tools/zone_filler_tool.h>
|
2021-05-20 22:59:23 +00:00
|
|
|
#include <tools/board_inspection_tool.h>
|
2020-09-18 19:57:54 +00:00
|
|
|
#include <kiplatform/ui.h>
|
2020-02-27 22:00:14 +00:00
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
|
|
|
|
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
|
|
|
|
// Use default column widths instead.
|
|
|
|
static int DEFAULT_SINGLE_COL_WIDTH = 660;
|
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
static BOARD* g_lastDRCBoard = nullptr;
|
2022-06-20 16:25:24 +00:00
|
|
|
static bool g_lastDRCRun = false;
|
|
|
|
static bool g_lastFootprintTestsRun = false;
|
2022-06-19 19:51:19 +00:00
|
|
|
static std::vector<wxString> g_lastIgnored;
|
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) :
|
2020-03-16 11:05:01 +00:00
|
|
|
DIALOG_DRC_BASE( aParent ),
|
2021-08-14 20:05:21 +00:00
|
|
|
PROGRESS_REPORTER_BASE( 1 ),
|
2020-09-18 19:57:54 +00:00
|
|
|
m_running( false ),
|
2020-09-14 17:54:14 +00:00
|
|
|
m_drcRun( false ),
|
|
|
|
m_footprintTestsRun( false ),
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel( nullptr ),
|
2020-02-28 00:05:40 +00:00
|
|
|
m_unconnectedTreeModel( nullptr ),
|
2022-08-30 11:03:40 +00:00
|
|
|
m_fpWarningsTreeModel( nullptr ),
|
2024-03-30 03:31:51 +00:00
|
|
|
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ),
|
|
|
|
m_lastUpdateUi( std::chrono::steady_clock::now() )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2020-01-15 15:26:13 +00:00
|
|
|
SetName( DIALOG_DRC_WINDOW_NAME ); // Set a window name to be able to find it
|
2019-09-19 07:11:45 +00:00
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
m_frame = aEditorFrame;
|
2021-04-08 17:13:48 +00:00
|
|
|
m_currentBoard = m_frame->GetBoard();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->SetImmediateMode();
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = m_frame->GetPcbNewSettings();
|
|
|
|
m_severities = cfg->m_DrcDialog.severities;
|
|
|
|
|
|
|
|
m_markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_currentBoard,
|
|
|
|
MARKER_BASE::MARKER_DRC,
|
|
|
|
MARKER_BASE::MARKER_DRAWING_SHEET );
|
|
|
|
|
|
|
|
m_ratsnestProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_currentBoard,
|
|
|
|
MARKER_BASE::MARKER_RATSNEST );
|
|
|
|
|
|
|
|
m_fpWarningsProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_currentBoard,
|
|
|
|
MARKER_BASE::MARKER_PARITY );
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel = new RC_TREE_MODEL( m_frame, m_markerDataView );
|
|
|
|
m_markerDataView->AssociateModel( m_markersTreeModel );
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersTreeModel->Update( m_markersProvider, m_severities );
|
2020-02-24 23:17:30 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_unconnectedTreeModel = new RC_TREE_MODEL( m_frame, m_unconnectedDataView );
|
2020-02-24 23:17:30 +00:00
|
|
|
m_unconnectedDataView->AssociateModel( m_unconnectedTreeModel );
|
2022-08-30 11:03:40 +00:00
|
|
|
m_unconnectedTreeModel->Update( m_ratsnestProvider, m_severities );
|
2020-02-24 23:17:30 +00:00
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
m_fpWarningsTreeModel = new RC_TREE_MODEL( m_frame, m_footprintsDataView );
|
|
|
|
m_footprintsDataView->AssociateModel( m_fpWarningsTreeModel );
|
|
|
|
m_fpWarningsTreeModel->Update( m_fpWarningsProvider, m_severities );
|
2020-02-24 23:17:30 +00:00
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
m_ignoredList->InsertColumn( 0, wxEmptyString, wxLIST_FORMAT_LEFT, DEFAULT_SINGLE_COL_WIDTH );
|
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
if( m_currentBoard == g_lastDRCBoard )
|
|
|
|
{
|
2022-06-20 16:25:24 +00:00
|
|
|
m_drcRun = g_lastDRCRun;
|
|
|
|
m_footprintTestsRun = g_lastFootprintTestsRun;
|
2022-06-19 19:51:19 +00:00
|
|
|
|
|
|
|
for( const wxString& str : g_lastIgnored )
|
|
|
|
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(), str );
|
|
|
|
}
|
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
m_Notebook->SetSelection( 0 );
|
|
|
|
|
2020-09-15 20:13:48 +00:00
|
|
|
if( Kiface().IsSingle() )
|
|
|
|
m_cbTestFootprints->Hide();
|
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Run DRC" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2018-01-30 14:13:34 +00:00
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
m_markersTitleTemplate = m_Notebook->GetPageText( 0 );
|
|
|
|
m_unconnectedTitleTemplate = m_Notebook->GetPageText( 1 );
|
|
|
|
m_footprintsTitleTemplate = m_Notebook->GetPageText( 2 );
|
|
|
|
m_ignoredTitleTemplate = m_Notebook->GetPageText( 3 );
|
|
|
|
|
|
|
|
m_cbRefillZones->SetValue( cfg->m_DrcDialog.refill_zones );
|
|
|
|
m_cbReportAllTrackErrors->SetValue( cfg->m_DrcDialog.test_all_track_errors );
|
|
|
|
|
|
|
|
if( !Kiface().IsSingle() )
|
|
|
|
m_cbTestFootprints->SetValue( cfg->m_DrcDialog.test_footprints );
|
|
|
|
|
|
|
|
Layout(); // adding the units above expanded Clearance text, now resize.
|
|
|
|
|
|
|
|
SetFocus();
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
syncCheckboxes();
|
2016-06-15 17:00:30 +00:00
|
|
|
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2009-11-05 22:02:24 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 14:13:34 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
DIALOG_DRC::~DIALOG_DRC()
|
2017-03-16 17:09:33 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->FocusOnItem( nullptr );
|
2020-01-13 01:44:19 +00:00
|
|
|
|
2022-06-20 16:25:24 +00:00
|
|
|
g_lastDRCBoard = m_currentBoard;
|
|
|
|
g_lastDRCRun = m_drcRun;
|
|
|
|
g_lastFootprintTestsRun = m_footprintTestsRun;
|
2022-06-19 19:51:19 +00:00
|
|
|
|
2022-06-20 16:25:24 +00:00
|
|
|
g_lastIgnored.clear();
|
2022-06-19 19:51:19 +00:00
|
|
|
|
2022-06-20 16:25:24 +00:00
|
|
|
for( int ii = 0; ii < m_ignoredList->GetItemCount(); ++ii )
|
|
|
|
g_lastIgnored.push_back( m_ignoredList->GetItemText( ii ) );
|
2022-06-19 19:51:19 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = nullptr;
|
2020-09-15 20:13:48 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
cfg = m_frame->GetPcbNewSettings();
|
|
|
|
}
|
|
|
|
catch( const std::runtime_error& e )
|
|
|
|
{
|
|
|
|
wxFAIL_MSG( e.what() );
|
|
|
|
}
|
2020-09-15 20:13:48 +00:00
|
|
|
|
2023-10-16 21:04:01 +00:00
|
|
|
if( cfg )
|
|
|
|
{
|
|
|
|
cfg->m_DrcDialog.refill_zones = m_cbRefillZones->GetValue();
|
|
|
|
cfg->m_DrcDialog.test_all_track_errors = m_cbReportAllTrackErrors->GetValue();
|
|
|
|
|
|
|
|
if( !Kiface().IsSingle() )
|
|
|
|
cfg->m_DrcDialog.test_footprints = m_cbTestFootprints->GetValue();
|
|
|
|
|
|
|
|
cfg->m_DrcDialog.severities = m_severities;
|
|
|
|
}
|
2020-02-24 23:17:30 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel->DecRef();
|
2022-08-30 11:03:40 +00:00
|
|
|
m_unconnectedTreeModel->DecRef();
|
|
|
|
m_fpWarningsTreeModel->DecRef();
|
2017-03-16 17:09:33 +00:00
|
|
|
}
|
2009-11-05 22:02:24 +00:00
|
|
|
|
2018-01-30 14:13:34 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnActivateDlg( wxActivateEvent& aEvent )
|
2016-04-15 18:15:22 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
if( m_currentBoard != m_frame->GetBoard() )
|
2016-04-15 18:15:22 +00:00
|
|
|
{
|
2020-09-14 17:54:14 +00:00
|
|
|
// If m_currentBoard is not the current board, (for instance because a new board
|
|
|
|
// was loaded), close the dialog, because many pointers are now invalid in lists
|
2016-04-15 18:15:22 +00:00
|
|
|
SetReturnCode( wxID_CANCEL );
|
|
|
|
Close();
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
DRC_TOOL* drcTool = m_frame->GetToolManager()->GetTool<DRC_TOOL>();
|
2020-09-16 20:38:23 +00:00
|
|
|
drcTool->DestroyDRCDialog();
|
2016-04-15 18:15:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-22 21:34:01 +00:00
|
|
|
// PROGRESS_REPORTER calls
|
2019-05-14 22:07:34 +00:00
|
|
|
|
2020-09-16 15:03:55 +00:00
|
|
|
bool DIALOG_DRC::updateUI()
|
|
|
|
{
|
2023-06-03 15:59:00 +00:00
|
|
|
double cur = alg::clamp( 0.0, (double) m_progress.load() / m_maxProgress, 1.0 );
|
2020-09-16 15:03:55 +00:00
|
|
|
|
2024-03-30 03:31:51 +00:00
|
|
|
int newValue = KiROUND( cur * 1000.0 );
|
|
|
|
m_gauge->SetValue( newValue );
|
|
|
|
|
|
|
|
// There is significant overhead on at least Windows when updateUi is called constantly thousands of times
|
|
|
|
// in the drc process and safeyieldfor is called each time.
|
|
|
|
// Gate the yield to a limited rate which still allows the UI to function without slowing down the main thread
|
|
|
|
// which is also running DRC
|
|
|
|
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
|
|
|
if( std::chrono::duration_cast<std::chrono::milliseconds>( now - m_lastUpdateUi ).count()
|
|
|
|
> 100 )
|
|
|
|
{
|
|
|
|
Pgm().App().SafeYieldFor( this, wxEVT_CATEGORY_NATIVE_EVENTS );
|
|
|
|
m_lastUpdateUi = now;
|
|
|
|
}
|
2020-09-16 15:03:55 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
return !m_cancelled;
|
2020-09-16 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DRC::AdvancePhase( const wxString& aMessage )
|
|
|
|
{
|
2021-08-14 20:05:21 +00:00
|
|
|
PROGRESS_REPORTER_BASE::AdvancePhase( aMessage );
|
2020-09-23 10:46:41 +00:00
|
|
|
SetCurrentProgress( 0.0 );
|
2020-09-16 15:03:55 +00:00
|
|
|
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Report( aMessage );
|
2020-09-16 15:03:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
// Don't globally define this; different facilities use different definitions of "ALL"
|
2020-03-04 09:48:18 +00:00
|
|
|
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_EXCLUSION;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::syncCheckboxes()
|
2016-06-15 17:00:30 +00:00
|
|
|
{
|
2020-03-04 09:48:18 +00:00
|
|
|
m_showAll->SetValue( m_severities == RPT_SEVERITY_ALL );
|
|
|
|
m_showErrors->SetValue( m_severities & RPT_SEVERITY_ERROR );
|
|
|
|
m_showWarnings->SetValue( m_severities & RPT_SEVERITY_WARNING );
|
|
|
|
m_showExclusions->SetValue( m_severities & RPT_SEVERITY_EXCLUSION );
|
2016-06-15 17:00:30 +00:00
|
|
|
}
|
|
|
|
|
2018-02-10 20:17:11 +00:00
|
|
|
|
2020-10-17 19:15:26 +00:00
|
|
|
void DIALOG_DRC::OnErrorLinkClicked( wxHtmlLinkEvent& event )
|
|
|
|
{
|
2021-08-16 15:06:21 +00:00
|
|
|
m_frame->ShowBoardSetupDialog( _( "Custom Rules" ) );
|
2020-10-17 19:15:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2021-06-16 15:11:17 +00:00
|
|
|
TOOL_MANAGER* toolMgr = m_frame->GetToolManager();
|
|
|
|
DRC_TOOL* drcTool = toolMgr->GetTool<DRC_TOOL>();
|
|
|
|
ZONE_FILLER_TOOL* zoneFillerTool = toolMgr->GetTool<ZONE_FILLER_TOOL>();
|
|
|
|
bool refillZones = m_cbRefillZones->GetValue();
|
|
|
|
bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
|
|
|
|
bool testFootprints = m_cbTestFootprints->GetValue();
|
|
|
|
|
|
|
|
if( zoneFillerTool->IsBusy() )
|
|
|
|
{
|
|
|
|
wxBell();
|
|
|
|
return;
|
|
|
|
}
|
2020-09-24 14:17:18 +00:00
|
|
|
|
|
|
|
// This is not the time to have stale or buggy rules. Ensure they're up-to-date
|
|
|
|
// and that they at least parse.
|
|
|
|
try
|
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
drcTool->GetDRCEngine()->InitEngine( m_frame->GetDesignRulesPath() );
|
2020-09-24 14:17:18 +00:00
|
|
|
}
|
2021-02-20 16:58:12 +00:00
|
|
|
catch( PARSE_ERROR& )
|
2020-09-24 14:17:18 +00:00
|
|
|
{
|
2020-10-17 19:15:26 +00:00
|
|
|
m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
|
|
|
m_DeleteCurrentMarkerButton->Enable( false );
|
|
|
|
m_DeleteAllMarkersButton->Enable( false );
|
|
|
|
m_saveReport->Enable( false );
|
|
|
|
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Clear();
|
2023-03-09 11:25:32 +00:00
|
|
|
m_messages->Report( _( "DRC incomplete: could not compile custom design rules." )
|
|
|
|
+ wxS( " " )
|
|
|
|
+ wxS( "<a href='$CUSTOM_RULES'>" ) + _( "Show design rules." ) + wxT( "</a>" ) );
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Flush();
|
2020-10-17 19:15:26 +00:00
|
|
|
|
|
|
|
Raise();
|
2020-09-24 14:17:18 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-09-14 17:54:14 +00:00
|
|
|
|
|
|
|
m_footprintTestsRun = false;
|
2020-09-18 19:57:54 +00:00
|
|
|
m_cancelled = false;
|
2009-06-27 06:26:41 +00:00
|
|
|
|
2024-01-11 00:55:18 +00:00
|
|
|
m_frame->GetBoard()->RecordDRCExclusions();
|
2020-08-02 21:45:06 +00:00
|
|
|
deleteAllMarkers( true );
|
2007-12-03 05:14:51 +00:00
|
|
|
|
2021-07-11 21:47:19 +00:00
|
|
|
std::vector<std::reference_wrapper<RC_ITEM>> violations = DRC_ITEM::GetItemsWithSeverities();
|
|
|
|
m_ignoredList->DeleteAllItems();
|
|
|
|
|
|
|
|
for( std::reference_wrapper<RC_ITEM>& item : violations )
|
|
|
|
{
|
|
|
|
if( bds().GetSeverity( item.get().GetErrorCode() ) == RPT_SEVERITY_IGNORE )
|
|
|
|
{
|
|
|
|
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(),
|
|
|
|
wxT( " • " ) + item.get().GetErrorText() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-19 22:53:25 +00:00
|
|
|
m_ignoredList->SetColumnWidth( 0, m_ignoredList->GetParent()->GetClientSize().x - 20 );
|
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
Raise();
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2020-09-17 13:36:34 +00:00
|
|
|
m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Clear();
|
2020-09-18 19:57:54 +00:00
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
|
|
|
|
|
|
|
m_running = true;
|
2020-09-23 10:36:27 +00:00
|
|
|
m_sdbSizerCancel->SetLabel( _( "Cancel" ) );
|
|
|
|
m_sdbSizerOK->Enable( false );
|
|
|
|
m_DeleteCurrentMarkerButton->Enable( false );
|
|
|
|
m_DeleteAllMarkersButton->Enable( false );
|
2020-09-20 11:21:03 +00:00
|
|
|
m_saveReport->Enable( false );
|
2020-09-14 17:54:14 +00:00
|
|
|
|
2022-02-07 18:51:49 +00:00
|
|
|
{
|
|
|
|
wxBusyCursor dummy;
|
2023-05-11 13:53:28 +00:00
|
|
|
drcTool->RunTests( this, refillZones, reportAllTrackErrors, testFootprints );
|
2022-02-07 18:51:49 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
if( m_cancelled )
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Report( _( "-------- DRC cancelled by user.<br><br>" ) );
|
2020-09-18 19:57:54 +00:00
|
|
|
else
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Report( _( "Done.<br><br>" ) );
|
2020-04-07 00:31:39 +00:00
|
|
|
|
|
|
|
Raise();
|
2020-09-18 19:57:54 +00:00
|
|
|
wxYield(); // Allow time slice to refresh Messages
|
2020-09-16 15:03:55 +00:00
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
m_running = false;
|
2020-09-23 10:36:27 +00:00
|
|
|
m_sdbSizerCancel->SetLabel( _( "Close" ) );
|
|
|
|
m_sdbSizerOK->Enable( true );
|
|
|
|
m_DeleteCurrentMarkerButton->Enable( true );
|
|
|
|
m_DeleteAllMarkersButton->Enable( true );
|
2020-09-20 11:21:03 +00:00
|
|
|
m_saveReport->Enable( true );
|
2020-09-18 19:57:54 +00:00
|
|
|
|
|
|
|
if( !m_cancelled )
|
|
|
|
{
|
2024-01-10 17:23:29 +00:00
|
|
|
m_sdbSizerCancel->SetDefault();
|
|
|
|
// wxWidgets has a tendency to keep both buttons highlighted without the following:
|
|
|
|
m_sdbSizerOK->Enable( false );
|
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
wxMilliSleep( 500 );
|
|
|
|
m_runningResultsBook->ChangeSelection( 1 );
|
2023-08-08 13:02:54 +00:00
|
|
|
KIPLATFORM::UI::ForceFocus( m_Notebook );
|
2024-01-12 14:38:25 +00:00
|
|
|
|
|
|
|
// now re-enable m_sdbSizerOK button
|
|
|
|
m_sdbSizerOK->Enable( true );
|
2020-09-18 19:57:54 +00:00
|
|
|
}
|
2020-09-16 15:03:55 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-03 21:28:56 +00:00
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
void DIALOG_DRC::UpdateData()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersTreeModel->Update( m_markersProvider, m_severities );
|
|
|
|
m_unconnectedTreeModel->Update( m_ratsnestProvider, m_severities );
|
|
|
|
m_fpWarningsTreeModel->Update( m_fpWarningsProvider, m_severities );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
updateDisplayedCounts();
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
2007-10-03 15:21:13 +00:00
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnDRCItemSelected( wxDataViewEvent& aEvent )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
BOARD* board = m_frame->GetBoard();
|
2020-08-11 16:46:35 +00:00
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2020-12-11 17:04:14 +00:00
|
|
|
auto getActiveLayers =
|
|
|
|
[]( BOARD_ITEM* aItem ) -> LSET
|
|
|
|
{
|
|
|
|
if( aItem->Type() == PCB_PAD_T )
|
|
|
|
{
|
|
|
|
PAD* pad = static_cast<PAD*>( aItem );
|
|
|
|
LSET layers;
|
|
|
|
|
|
|
|
for( int layer : aItem->GetLayerSet().Seq() )
|
|
|
|
{
|
|
|
|
if( pad->FlashLayer( layer ) )
|
|
|
|
layers.set( layer );
|
|
|
|
}
|
|
|
|
|
|
|
|
return layers;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return aItem->GetLayerSet();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( !node )
|
|
|
|
{
|
|
|
|
// list is being freed; don't do anything with null ptrs
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
|
|
|
|
|
|
|
|
if( rc_item->GetErrorCode() == DRCE_UNRESOLVED_VARIABLE
|
|
|
|
&& rc_item->GetParent()->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
|
2020-04-07 00:31:39 +00:00
|
|
|
{
|
2022-08-15 16:59:34 +00:00
|
|
|
m_frame->FocusOnLocation( node->m_RcItem->GetParent()->GetPos() );
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const KIID& itemID = RC_TREE_MODEL::ToUUID( aEvent.GetItem() );
|
|
|
|
BOARD_ITEM* item = board->GetItem( itemID );
|
|
|
|
|
|
|
|
if( !item || item == DELETED_BOARD_ITEM::GetInstance() )
|
|
|
|
{
|
|
|
|
// nothing to highlight / focus on
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
PCB_LAYER_ID principalLayer;
|
|
|
|
LSET violationLayers;
|
|
|
|
BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() );
|
|
|
|
BOARD_ITEM* b = board->GetItem( rc_item->GetAuxItemID() );
|
|
|
|
BOARD_ITEM* c = board->GetItem( rc_item->GetAuxItem2ID() );
|
|
|
|
BOARD_ITEM* d = board->GetItem( rc_item->GetAuxItem3ID() );
|
|
|
|
|
|
|
|
if( rc_item->GetErrorCode() == DRCE_MALFORMED_COURTYARD )
|
|
|
|
{
|
|
|
|
if( a && ( a->GetFlags() & MALFORMED_B_COURTYARD ) > 0
|
|
|
|
&& ( a->GetFlags() & MALFORMED_F_COURTYARD ) == 0 )
|
2020-11-20 13:55:10 +00:00
|
|
|
{
|
2022-08-15 16:59:34 +00:00
|
|
|
principalLayer = B_CrtYd;
|
2020-11-20 13:55:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-08-15 16:59:34 +00:00
|
|
|
principalLayer = F_CrtYd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rc_item->GetErrorCode() == DRCE_INVALID_OUTLINE )
|
|
|
|
{
|
|
|
|
principalLayer = Edge_Cuts;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
principalLayer = UNDEFINED_LAYER;
|
2022-03-01 11:55:59 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( a || b || c || d )
|
|
|
|
violationLayers = LSET::AllLayersMask();
|
2020-12-23 15:14:41 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
// Try to initialize principalLayer to a valid layer. Note that some markers have
|
|
|
|
// a layer set to UNDEFINED_LAYER, so we may need to keep looking.
|
2022-03-01 11:55:59 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
for( BOARD_ITEM* it: { a, b, c, d } )
|
|
|
|
{
|
|
|
|
if( !it )
|
|
|
|
continue;
|
2022-01-07 11:53:10 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
LSET layersList = getActiveLayers( it );
|
|
|
|
violationLayers &= layersList;
|
2022-03-01 11:55:59 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( principalLayer <= UNDEFINED_LAYER && layersList.count() )
|
|
|
|
principalLayer = layersList.Seq().front();
|
2020-11-20 13:55:10 +00:00
|
|
|
}
|
2022-08-15 16:59:34 +00:00
|
|
|
}
|
2020-08-11 16:46:35 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( violationLayers.count() )
|
|
|
|
principalLayer = violationLayers.Seq().front();
|
|
|
|
else if( !(principalLayer <= UNDEFINED_LAYER ) )
|
|
|
|
violationLayers.set( principalLayer );
|
2020-08-11 16:46:35 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
WINDOW_THAWER thawer( m_frame );
|
2020-08-11 16:46:35 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( principalLayer > UNDEFINED_LAYER && ( violationLayers & board->GetVisibleLayers() ) == 0 )
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( principalLayer, true );
|
2020-04-07 00:31:39 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( principalLayer > UNDEFINED_LAYER && board->GetVisibleLayers().test( principalLayer ) )
|
|
|
|
m_frame->SetActiveLayer( principalLayer );
|
2021-09-25 14:31:19 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( rc_item->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
|
|
|
{
|
|
|
|
if( !m_frame->GetPcbNewSettings()->m_Display.m_ShowGlobalRatsnest )
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::showRatsnest );
|
2022-01-22 23:22:15 +00:00
|
|
|
|
2022-09-14 22:32:41 +00:00
|
|
|
if( item->Type() == PCB_ZONE_T )
|
2022-08-15 16:59:34 +00:00
|
|
|
{
|
2024-03-08 18:23:12 +00:00
|
|
|
m_frame->FocusOnItem( item, principalLayer );
|
|
|
|
|
2022-09-29 16:07:42 +00:00
|
|
|
m_frame->GetBoard()->GetConnectivity()->RunOnUnconnectedEdges(
|
|
|
|
[&]( CN_EDGE& edge )
|
|
|
|
{
|
2023-11-01 17:08:51 +00:00
|
|
|
// Connectivity was valid when DRC was run, but this is a modeless dialog
|
|
|
|
// so it might not be now.
|
|
|
|
if( !edge.GetSourceNode() || edge.GetSourceNode()->Dirty() )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if( !edge.GetTargetNode() || edge.GetTargetNode()->Dirty() )
|
|
|
|
return true;
|
|
|
|
|
2022-09-29 16:07:42 +00:00
|
|
|
if( edge.GetSourceNode()->Parent() == a
|
2024-03-08 18:23:12 +00:00
|
|
|
&& edge.GetTargetNode()->Parent() == b )
|
2022-09-29 16:07:42 +00:00
|
|
|
{
|
2024-03-08 18:23:12 +00:00
|
|
|
VECTOR2I focusPos;
|
|
|
|
|
|
|
|
if( item == a && item == b )
|
|
|
|
{
|
|
|
|
focusPos = ( node->m_Type == RC_TREE_NODE::MAIN_ITEM )
|
|
|
|
? edge.GetSourcePos()
|
|
|
|
: edge.GetTargetPos();
|
|
|
|
}
|
2022-09-29 16:07:42 +00:00
|
|
|
else
|
2024-03-08 18:23:12 +00:00
|
|
|
{
|
|
|
|
focusPos = ( item == edge.GetSourceNode()->Parent() )
|
|
|
|
? edge.GetSourcePos()
|
|
|
|
: edge.GetTargetPos();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_frame->FocusOnLocation( focusPos );
|
|
|
|
m_frame->RefreshCanvas();
|
2022-09-29 16:07:42 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
} );
|
2022-01-22 23:22:15 +00:00
|
|
|
}
|
2022-09-14 22:32:41 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->FocusOnItem( item, principalLayer );
|
|
|
|
}
|
2022-08-15 16:59:34 +00:00
|
|
|
}
|
|
|
|
else if( rc_item->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG )
|
|
|
|
{
|
|
|
|
BOARD_CONNECTED_ITEM* track = dynamic_cast<PCB_TRACK*>( item );
|
|
|
|
std::vector<BOARD_ITEM*> items;
|
2022-04-15 12:56:58 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( track )
|
|
|
|
{
|
|
|
|
int net = track->GetNetCode();
|
2022-04-15 12:56:58 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
wxASSERT( net > 0 ); // Without a net how can it be a diff-pair?
|
2022-04-08 10:37:27 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
for( const KIID& id : rc_item->GetIDs() )
|
2022-04-15 12:56:58 +00:00
|
|
|
{
|
2022-08-15 16:59:34 +00:00
|
|
|
auto* candidate = dynamic_cast<BOARD_CONNECTED_ITEM*>( board->GetItem( id ) );
|
2022-04-08 10:37:27 +00:00
|
|
|
|
2022-08-15 16:59:34 +00:00
|
|
|
if( candidate && candidate->GetNetCode() == net )
|
|
|
|
items.push_back( candidate );
|
|
|
|
}
|
2022-04-08 10:37:27 +00:00
|
|
|
}
|
2021-10-05 22:33:30 +00:00
|
|
|
else
|
|
|
|
{
|
2022-08-15 16:59:34 +00:00
|
|
|
items.push_back( item );
|
2021-10-05 22:33:30 +00:00
|
|
|
}
|
2022-08-15 16:59:34 +00:00
|
|
|
|
|
|
|
m_frame->FocusOnItems( items, principalLayer );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_frame->FocusOnItem( item, principalLayer );
|
2020-08-11 16:46:35 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
aEvent.Skip();
|
2007-10-03 15:21:13 +00:00
|
|
|
}
|
|
|
|
|
2007-11-13 09:35:39 +00:00
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnDRCItemDClick( wxDataViewEvent& aEvent )
|
2007-11-13 09:35:39 +00:00
|
|
|
{
|
2020-02-28 00:05:40 +00:00
|
|
|
if( aEvent.GetItem().IsOk() )
|
2007-11-27 01:34:35 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
// turn control over to m_frame, hide this DIALOG_DRC window,
|
2020-02-24 23:17:30 +00:00
|
|
|
// no destruction so we can preserve listbox cursor
|
|
|
|
if( !IsModal() )
|
|
|
|
Show( false );
|
2007-11-27 01:34:35 +00:00
|
|
|
}
|
|
|
|
|
2021-09-06 18:58:46 +00:00
|
|
|
// Do not skip aEvent here: this is not useful, and Pcbnew crashes
|
2020-09-28 19:07:51 +00:00
|
|
|
// if skipped (at least on Windows)
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-03-16 11:05:01 +00:00
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
if( !node )
|
|
|
|
return;
|
|
|
|
|
2021-12-01 14:42:44 +00:00
|
|
|
std::shared_ptr<RC_ITEM> rcItem = node->m_RcItem;
|
|
|
|
DRC_ITEM* drcItem = static_cast<DRC_ITEM*>( rcItem.get() );
|
|
|
|
std::shared_ptr<CONNECTIVITY_DATA> conn = m_currentBoard->GetConnectivity();
|
|
|
|
wxString listName;
|
|
|
|
wxMenu menu;
|
|
|
|
wxString msg;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
switch( bds().m_DRCSeverities[ rcItem->GetErrorCode() ] )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-03-04 09:48:18 +00:00
|
|
|
case RPT_SEVERITY_ERROR: listName = _( "errors" ); break;
|
|
|
|
case RPT_SEVERITY_WARNING: listName = _( "warnings" ); break;
|
2020-03-16 11:05:01 +00:00
|
|
|
default: listName = _( "appropriate" ); break;
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
if( rcItem->GetParent()->IsExcluded() )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
|
|
|
menu.Append( 1, _( "Remove exclusion for this violation" ),
|
|
|
|
wxString::Format( _( "It will be placed back in the %s list" ), listName ) );
|
2021-09-06 18:58:46 +00:00
|
|
|
|
|
|
|
if( drcItem->GetViolatingRule() && !drcItem->GetViolatingRule()->m_Implicit )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Remove all exclusions for violations of rule '%s'" ),
|
|
|
|
drcItem->GetViolatingRule()->m_Name );
|
|
|
|
menu.Append( 11, msg );
|
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu.Append( 2, _( "Exclude this violation" ),
|
|
|
|
wxString::Format( _( "It will be excluded from the %s list" ), listName ) );
|
2021-09-06 18:58:46 +00:00
|
|
|
|
|
|
|
if( drcItem->GetViolatingRule() && !drcItem->GetViolatingRule()->m_Implicit )
|
|
|
|
{
|
|
|
|
msg.Printf( _( "Exclude all violations of rule '%s'" ),
|
|
|
|
drcItem->GetViolatingRule()->m_Name );
|
|
|
|
menu.Append( 21, msg );
|
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
|
2021-05-20 22:59:23 +00:00
|
|
|
if( rcItem->GetErrorCode() == DRCE_CLEARANCE
|
2022-04-15 21:09:35 +00:00
|
|
|
|| rcItem->GetErrorCode() == DRCE_EDGE_CLEARANCE
|
2022-08-29 15:30:06 +00:00
|
|
|
|| rcItem->GetErrorCode() == DRCE_HOLE_CLEARANCE
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_DRILLED_HOLES_TOO_CLOSE )
|
2021-05-20 22:59:23 +00:00
|
|
|
{
|
2023-03-13 23:35:07 +00:00
|
|
|
menu.Append( 3, _( "Run Inspect > Clearance Resolution" ) );
|
2021-05-20 22:59:23 +00:00
|
|
|
}
|
2022-04-15 21:09:35 +00:00
|
|
|
else if( rcItem->GetErrorCode() == DRCE_TEXT_HEIGHT
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_TEXT_THICKNESS
|
2022-04-15 23:57:08 +00:00
|
|
|
|| rcItem->GetErrorCode() == DRCE_DIFF_PAIR_UNCOUPLED_LENGTH_TOO_LONG
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_TRACK_WIDTH
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_VIA_DIAMETER
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_ANNULAR_WIDTH
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_DRILL_OUT_OF_RANGE
|
2022-07-31 15:02:04 +00:00
|
|
|
|| rcItem->GetErrorCode() == DRCE_MICROVIA_DRILL_OUT_OF_RANGE
|
2023-04-12 12:53:43 +00:00
|
|
|
|| rcItem->GetErrorCode() == DRCE_CONNECTION_WIDTH
|
|
|
|
|| rcItem->GetErrorCode() == DRCE_ASSERTION_FAILURE )
|
2022-04-15 21:09:35 +00:00
|
|
|
{
|
2023-03-13 23:35:07 +00:00
|
|
|
menu.Append( 3, _( "Run Inspect > Constraints Resolution" ) );
|
|
|
|
}
|
|
|
|
else if( rcItem->GetErrorCode() == DRCE_LIB_FOOTPRINT_MISMATCH )
|
|
|
|
{
|
2023-12-13 16:07:09 +00:00
|
|
|
menu.Append( 3, _( "Run Inspect > Compare Footprint with Library" ) );
|
2022-04-15 21:09:35 +00:00
|
|
|
}
|
2021-05-20 22:59:23 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
menu.AppendSeparator();
|
|
|
|
|
2020-05-15 23:25:33 +00:00
|
|
|
if( bds().m_DRCSeverities[ rcItem->GetErrorCode() ] == RPT_SEVERITY_WARNING )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-04-24 18:56:44 +00:00
|
|
|
msg.Printf( _( "Change severity to Error for all '%s' violations" ),
|
2020-06-08 02:19:46 +00:00
|
|
|
rcItem->GetErrorText(),
|
2020-04-24 18:56:44 +00:00
|
|
|
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
2021-05-20 22:59:23 +00:00
|
|
|
menu.Append( 4, msg );
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-04-24 18:56:44 +00:00
|
|
|
msg.Printf( _( "Change severity to Warning for all '%s' violations" ),
|
2020-06-08 02:19:46 +00:00
|
|
|
rcItem->GetErrorText(),
|
2020-04-24 18:56:44 +00:00
|
|
|
_( "Violation severities can also be edited in the Board Setup... dialog" ) );
|
2021-05-20 22:59:23 +00:00
|
|
|
menu.Append( 5, msg );
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
|
2020-04-24 18:56:44 +00:00
|
|
|
msg.Printf( _( "Ignore all '%s' violations" ),
|
2020-06-08 02:19:46 +00:00
|
|
|
rcItem->GetErrorText(),
|
2020-04-24 18:56:44 +00:00
|
|
|
_( "Violations will not be checked or reported" ) );
|
2021-05-20 22:59:23 +00:00
|
|
|
menu.Append( 6, msg );
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-03-04 21:51:39 +00:00
|
|
|
menu.AppendSeparator();
|
|
|
|
|
2021-05-20 22:59:23 +00:00
|
|
|
menu.Append( 7, _( "Edit violation severities..." ), _( "Open the Board Setup... dialog" ) );
|
2020-03-04 21:51:39 +00:00
|
|
|
|
2020-04-24 21:59:57 +00:00
|
|
|
bool modified = false;
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
switch( GetPopupMenuSelectionFromUser( menu ) )
|
|
|
|
{
|
|
|
|
case 1:
|
2020-08-08 17:06:00 +00:00
|
|
|
{
|
2021-12-01 14:42:44 +00:00
|
|
|
PCB_MARKER* marker = dynamic_cast<PCB_MARKER*>( rcItem->GetParent() );
|
2020-08-08 17:06:00 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
if( marker )
|
|
|
|
{
|
|
|
|
marker->SetExcluded( false );
|
2021-12-01 14:42:44 +00:00
|
|
|
|
|
|
|
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
2022-09-29 16:07:42 +00:00
|
|
|
{
|
|
|
|
m_frame->GetBoard()->UpdateRatsnestExclusions();
|
2021-12-01 14:42:44 +00:00
|
|
|
m_frame->GetCanvas()->RedrawRatsnest();
|
2022-09-29 16:07:42 +00:00
|
|
|
}
|
2021-12-01 14:42:44 +00:00
|
|
|
else
|
2022-09-29 16:07:42 +00:00
|
|
|
{
|
2021-12-01 14:42:44 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
2022-09-29 16:07:42 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
// Update view
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
modified = true;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
|
|
|
|
case 2:
|
2020-08-08 17:06:00 +00:00
|
|
|
{
|
2021-12-01 14:42:44 +00:00
|
|
|
PCB_MARKER* marker = dynamic_cast<PCB_MARKER*>( rcItem->GetParent() );
|
2020-08-08 17:06:00 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
if( marker )
|
|
|
|
{
|
|
|
|
marker->SetExcluded( true );
|
2021-12-01 14:42:44 +00:00
|
|
|
|
|
|
|
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
2022-09-29 16:07:42 +00:00
|
|
|
{
|
|
|
|
m_frame->GetBoard()->UpdateRatsnestExclusions();
|
2021-12-01 14:42:44 +00:00
|
|
|
m_frame->GetCanvas()->RedrawRatsnest();
|
2022-09-29 16:07:42 +00:00
|
|
|
}
|
2021-12-01 14:42:44 +00:00
|
|
|
else
|
2022-09-29 16:07:42 +00:00
|
|
|
{
|
2021-12-01 14:42:44 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
2022-09-29 16:07:42 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
// Update view
|
|
|
|
if( m_severities & RPT_SEVERITY_EXCLUSION )
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
|
|
|
else
|
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-09-20 01:20:41 +00:00
|
|
|
modified = true;
|
|
|
|
}
|
2021-07-19 23:56:05 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2021-09-06 18:58:46 +00:00
|
|
|
case 11:
|
|
|
|
{
|
|
|
|
for( PCB_MARKER* marker : m_frame->GetBoard()->Markers() )
|
|
|
|
{
|
|
|
|
DRC_ITEM* candidateDrcItem = static_cast<DRC_ITEM*>( marker->GetRCItem().get() );
|
|
|
|
|
|
|
|
if( candidateDrcItem->GetViolatingRule() == drcItem->GetViolatingRule() )
|
|
|
|
marker->SetExcluded( false );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markersProvider, m_severities );
|
2021-09-06 18:58:46 +00:00
|
|
|
modified = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 21:
|
|
|
|
{
|
|
|
|
for( PCB_MARKER* marker : m_frame->GetBoard()->Markers() )
|
|
|
|
{
|
|
|
|
DRC_ITEM* candidateDrcItem = static_cast<DRC_ITEM*>( marker->GetRCItem().get() );
|
|
|
|
|
|
|
|
if( candidateDrcItem->GetViolatingRule() == drcItem->GetViolatingRule() )
|
|
|
|
marker->SetExcluded( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markersProvider, m_severities );
|
2021-09-06 18:58:46 +00:00
|
|
|
modified = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
case 3:
|
2021-05-20 22:59:23 +00:00
|
|
|
{
|
|
|
|
TOOL_MANAGER* toolMgr = m_frame->GetToolManager();
|
|
|
|
BOARD_INSPECTION_TOOL* inspectionTool = toolMgr->GetTool<BOARD_INSPECTION_TOOL>();
|
|
|
|
|
|
|
|
inspectionTool->InspectDRCError( node->m_RcItem );
|
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2021-05-20 22:59:23 +00:00
|
|
|
|
|
|
|
case 4:
|
2020-05-15 23:25:33 +00:00
|
|
|
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
for( PCB_MARKER* marker : m_frame->GetBoard()->Markers() )
|
2020-08-08 17:06:00 +00:00
|
|
|
{
|
|
|
|
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
2020-08-08 17:06:00 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markersProvider, m_severities );
|
2020-04-24 21:59:57 +00:00
|
|
|
modified = true;
|
2020-02-28 00:05:40 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-20 22:59:23 +00:00
|
|
|
case 5:
|
2020-05-15 23:25:33 +00:00
|
|
|
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_WARNING;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
for( PCB_MARKER* marker : m_frame->GetBoard()->Markers() )
|
2020-08-08 17:06:00 +00:00
|
|
|
{
|
|
|
|
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
2020-08-08 17:06:00 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markersProvider, m_severities );
|
2020-04-24 21:59:57 +00:00
|
|
|
modified = true;
|
2020-02-28 00:05:40 +00:00
|
|
|
break;
|
|
|
|
|
2021-05-20 22:59:23 +00:00
|
|
|
case 6:
|
2020-05-04 21:05:30 +00:00
|
|
|
{
|
2020-05-15 23:25:33 +00:00
|
|
|
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_IGNORE;
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2022-01-10 21:05:14 +00:00
|
|
|
m_ignoredList->InsertItem( m_ignoredList->GetItemCount(),
|
|
|
|
wxT( " • " ) + rcItem->GetErrorText() );
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
std::vector<PCB_MARKER*>& markers = m_frame->GetBoard()->Markers();
|
2020-05-04 21:05:30 +00:00
|
|
|
|
|
|
|
for( unsigned i = 0; i < markers.size(); )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2020-05-04 21:05:30 +00:00
|
|
|
if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
|
2020-05-26 20:01:04 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Remove( markers.at( i ) );
|
2020-05-04 21:05:30 +00:00
|
|
|
markers.erase( markers.begin() + i );
|
2020-05-26 20:01:04 +00:00
|
|
|
}
|
2020-05-04 21:05:30 +00:00
|
|
|
else
|
2021-12-01 14:42:44 +00:00
|
|
|
{
|
2020-05-04 21:05:30 +00:00
|
|
|
++i;
|
2021-12-01 14:42:44 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 14:42:44 +00:00
|
|
|
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
|
|
|
m_frame->GetCanvas()->RedrawRatsnest();
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
// Rebuild model and view
|
2022-08-30 11:03:40 +00:00
|
|
|
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->Update( m_markersProvider, m_severities );
|
2020-04-24 21:59:57 +00:00
|
|
|
modified = true;
|
2020-02-28 00:05:40 +00:00
|
|
|
break;
|
2021-07-19 23:56:05 +00:00
|
|
|
}
|
2020-03-04 21:51:39 +00:00
|
|
|
|
2021-05-20 22:59:23 +00:00
|
|
|
case 7:
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->ShowBoardSetupDialog( _( "Violation Severity" ) );
|
2020-03-04 21:51:39 +00:00
|
|
|
break;
|
2020-02-28 00:05:40 +00:00
|
|
|
}
|
2020-04-24 21:59:57 +00:00
|
|
|
|
|
|
|
if( modified )
|
|
|
|
{
|
|
|
|
updateDisplayedCounts();
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
|
|
|
m_frame->OnModify();
|
2020-04-24 21:59:57 +00:00
|
|
|
}
|
2018-01-28 09:35:33 +00:00
|
|
|
}
|
2008-02-23 04:53:44 +00:00
|
|
|
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
void DIALOG_DRC::OnEditViolationSeverities( wxHyperlinkEvent& aEvent )
|
2021-07-11 21:47:19 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
m_frame->ShowBoardSetupDialog( _( "Violation Severity" ) );
|
2021-07-11 21:47:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnSeverity( wxCommandEvent& aEvent )
|
2018-01-28 09:35:33 +00:00
|
|
|
{
|
2020-02-27 22:00:14 +00:00
|
|
|
int flag = 0;
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
if( aEvent.GetEventObject() == m_showAll )
|
2020-03-04 09:48:18 +00:00
|
|
|
flag = RPT_SEVERITY_ALL;
|
2020-02-28 00:05:40 +00:00
|
|
|
else if( aEvent.GetEventObject() == m_showErrors )
|
2020-03-04 09:48:18 +00:00
|
|
|
flag = RPT_SEVERITY_ERROR;
|
2020-02-28 00:05:40 +00:00
|
|
|
else if( aEvent.GetEventObject() == m_showWarnings )
|
2020-03-04 09:48:18 +00:00
|
|
|
flag = RPT_SEVERITY_WARNING;
|
2020-02-28 00:05:40 +00:00
|
|
|
else if( aEvent.GetEventObject() == m_showExclusions )
|
2020-03-04 09:48:18 +00:00
|
|
|
flag = RPT_SEVERITY_EXCLUSION;
|
2020-02-27 22:00:14 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
if( aEvent.IsChecked() )
|
2020-02-27 22:00:14 +00:00
|
|
|
m_severities |= flag;
|
2020-02-28 00:05:40 +00:00
|
|
|
else if( aEvent.GetEventObject() == m_showAll )
|
2020-03-04 09:48:18 +00:00
|
|
|
m_severities = RPT_SEVERITY_ERROR;
|
2020-02-27 22:00:14 +00:00
|
|
|
else
|
|
|
|
m_severities &= ~flag;
|
|
|
|
|
|
|
|
syncCheckboxes();
|
2022-08-30 11:03:40 +00:00
|
|
|
UpdateData();
|
2020-02-27 22:00:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent )
|
2020-02-27 22:00:14 +00:00
|
|
|
{
|
2023-12-28 02:10:01 +00:00
|
|
|
wxFileName fn( "DRC." + FILEEXT::ReportFileExtension );
|
2019-03-26 02:38:18 +00:00
|
|
|
|
2023-10-23 17:01:04 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Report File" ), Prj().GetProjectPath(), fn.GetFullName(),
|
2023-12-28 02:10:01 +00:00
|
|
|
FILEEXT::ReportFileWildcard() + wxS( "|" ) + FILEEXT::JsonFileWildcard(),
|
2023-08-13 22:48:29 +00:00
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
2019-03-26 02:38:18 +00:00
|
|
|
|
2020-02-27 22:00:14 +00:00
|
|
|
if( dlg.ShowModal() != wxID_OK )
|
2020-02-24 23:17:30 +00:00
|
|
|
return;
|
2019-03-26 02:38:18 +00:00
|
|
|
|
2020-02-27 22:00:14 +00:00
|
|
|
fn = dlg.GetPath();
|
|
|
|
|
|
|
|
if( fn.GetExt().IsEmpty() )
|
2023-12-28 02:10:01 +00:00
|
|
|
fn.SetExt( FILEEXT::ReportFileExtension );
|
2020-02-27 22:00:14 +00:00
|
|
|
|
|
|
|
if( !fn.IsAbsolute() )
|
|
|
|
{
|
|
|
|
wxString prj_path = Prj().GetProjectPath();
|
|
|
|
fn.MakeAbsolute( prj_path );
|
|
|
|
}
|
|
|
|
|
2023-08-13 18:44:31 +00:00
|
|
|
DRC_REPORT reportWriter( m_frame->GetBoard(), GetUserUnits(), m_markersProvider,
|
|
|
|
m_ratsnestProvider, m_fpWarningsProvider );
|
|
|
|
|
2023-08-13 22:48:29 +00:00
|
|
|
bool success = false;
|
2023-12-28 02:10:01 +00:00
|
|
|
if( fn.GetExt() == FILEEXT::JsonFileExtension )
|
2023-08-13 22:48:29 +00:00
|
|
|
success = reportWriter.WriteJsonReport( fn.GetFullPath() );
|
|
|
|
else
|
|
|
|
success = reportWriter.WriteTextReport( fn.GetFullPath() );
|
|
|
|
|
|
|
|
if( success )
|
2020-02-27 22:00:14 +00:00
|
|
|
{
|
2020-10-18 11:51:36 +00:00
|
|
|
m_messages->Report( wxString::Format( _( "Report file '%s' created<br>" ),
|
2020-10-17 19:15:26 +00:00
|
|
|
fn.GetFullPath() ) );
|
2020-02-27 22:00:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-05 12:40:38 +00:00
|
|
|
DisplayError( this, wxString::Format( _( "Failed to create file '%s'." ),
|
2020-02-27 22:00:14 +00:00
|
|
|
fn.GetFullPath() ) );
|
|
|
|
}
|
2007-11-13 09:35:39 +00:00
|
|
|
}
|
2007-11-27 01:34:35 +00:00
|
|
|
|
|
|
|
|
2020-09-18 19:57:54 +00:00
|
|
|
void DIALOG_DRC::OnClose( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
if( m_running )
|
|
|
|
aEvent.Veto();
|
|
|
|
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
|
|
|
|
OnCancelClick( dummy );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnCancelClick( wxCommandEvent& aEvent )
|
2019-03-28 19:30:51 +00:00
|
|
|
{
|
2020-09-18 19:57:54 +00:00
|
|
|
if( m_running )
|
|
|
|
{
|
|
|
|
m_cancelled = true;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->FocusOnItem( nullptr );
|
2020-02-25 12:17:13 +00:00
|
|
|
|
2020-02-24 23:17:30 +00:00
|
|
|
SetReturnCode( wxID_CANCEL );
|
2019-03-28 19:30:51 +00:00
|
|
|
|
2020-02-24 23:17:30 +00:00
|
|
|
// The dialog can be modal or not modal.
|
|
|
|
// Leave the DRC caller destroy (or not) the dialog
|
2021-04-08 17:13:48 +00:00
|
|
|
DRC_TOOL* drcTool = m_frame->GetToolManager()->GetTool<DRC_TOOL>();
|
2020-09-16 20:38:23 +00:00
|
|
|
drcTool->DestroyDRCDialog();
|
2019-03-28 19:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnChangingNotebookPage( wxNotebookEvent& aEvent )
|
2012-12-10 19:08:09 +00:00
|
|
|
{
|
2020-02-24 23:17:30 +00:00
|
|
|
m_markerDataView->UnselectAll();
|
|
|
|
m_unconnectedDataView->UnselectAll();
|
|
|
|
m_footprintsDataView->UnselectAll();
|
2024-01-21 11:18:59 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
2019-03-28 19:30:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
void DIALOG_DRC::refreshEditor()
|
2007-12-03 21:28:56 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
WINDOW_THAWER thawer( m_frame );
|
2018-01-17 09:34:38 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->GetCanvas()->Refresh();
|
2007-12-03 21:28:56 +00:00
|
|
|
}
|
2007-12-03 05:14:51 +00:00
|
|
|
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
void DIALOG_DRC::PrevMarker()
|
|
|
|
{
|
|
|
|
if( m_Notebook->IsShown() )
|
|
|
|
{
|
|
|
|
switch( m_Notebook->GetSelection() )
|
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
case 0: m_markersTreeModel->PrevMarker(); break;
|
2020-12-01 22:35:11 +00:00
|
|
|
case 1: m_unconnectedTreeModel->PrevMarker(); break;
|
2022-08-30 11:03:40 +00:00
|
|
|
case 2: m_fpWarningsTreeModel->PrevMarker(); break;
|
2021-07-11 21:47:19 +00:00
|
|
|
case 3: break;
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_DRC::NextMarker()
|
|
|
|
{
|
|
|
|
if( m_Notebook->IsShown() )
|
|
|
|
{
|
|
|
|
switch( m_Notebook->GetSelection() )
|
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
case 0: m_markersTreeModel->NextMarker(); break;
|
2020-12-01 22:35:11 +00:00
|
|
|
case 1: m_unconnectedTreeModel->NextMarker(); break;
|
2022-08-30 11:03:40 +00:00
|
|
|
case 2: m_fpWarningsTreeModel->NextMarker(); break;
|
2021-07-11 21:47:19 +00:00
|
|
|
case 3: break;
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-10-05 22:33:30 +00:00
|
|
|
void DIALOG_DRC::SelectMarker( const PCB_MARKER* aMarker )
|
2021-07-11 17:04:57 +00:00
|
|
|
{
|
|
|
|
if( m_Notebook->IsShown() )
|
|
|
|
{
|
|
|
|
m_Notebook->SetSelection( 0 );
|
|
|
|
m_markersTreeModel->SelectMarker( aMarker );
|
2021-10-05 22:33:30 +00:00
|
|
|
|
2024-02-04 17:37:48 +00:00
|
|
|
CallAfter(
|
|
|
|
[=]
|
|
|
|
{
|
|
|
|
m_markersTreeModel->CenterMarker( aMarker );
|
|
|
|
} );
|
2021-07-11 17:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-01 22:35:11 +00:00
|
|
|
void DIALOG_DRC::ExcludeMarker()
|
|
|
|
{
|
|
|
|
if( !m_Notebook->IsShown() || m_Notebook->GetSelection() != 0 )
|
|
|
|
return;
|
|
|
|
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( m_markerDataView->GetCurrentItem() );
|
|
|
|
PCB_MARKER* marker = dynamic_cast<PCB_MARKER*>( node->m_RcItem->GetParent() );
|
|
|
|
|
2021-09-06 18:58:46 +00:00
|
|
|
if( marker && marker->GetSeverity() != RPT_SEVERITY_EXCLUSION )
|
2020-12-01 22:35:11 +00:00
|
|
|
{
|
|
|
|
marker->SetExcluded( true );
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame->GetCanvas()->GetView()->Update( marker );
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
// Update view
|
|
|
|
if( m_severities & RPT_SEVERITY_EXCLUSION )
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel->ValueChanged( node );
|
2020-12-01 22:35:11 +00:00
|
|
|
else
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel->DeleteCurrentItem( false );
|
2020-12-01 22:35:11 +00:00
|
|
|
|
|
|
|
updateDisplayedCounts();
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
|
|
|
m_frame->OnModify();
|
2020-12-01 22:35:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-08-02 21:45:06 +00:00
|
|
|
void DIALOG_DRC::deleteAllMarkers( bool aIncludeExclusions )
|
2007-12-03 05:14:51 +00:00
|
|
|
{
|
2018-05-31 07:31:03 +00:00
|
|
|
// Clear current selection list to avoid selection of deleted items
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2018-05-31 07:31:03 +00:00
|
|
|
|
2022-08-08 21:00:37 +00:00
|
|
|
m_markersTreeModel->DeleteItems( false, aIncludeExclusions, false );
|
|
|
|
m_unconnectedTreeModel->DeleteItems( false, aIncludeExclusions, false );
|
2022-08-30 11:03:40 +00:00
|
|
|
m_fpWarningsTreeModel->DeleteItems( false, aIncludeExclusions, false );
|
2022-08-08 21:00:37 +00:00
|
|
|
|
|
|
|
m_frame->GetBoard()->DeleteMARKERs( true, aIncludeExclusions );
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnDeleteOneClick( wxCommandEvent& aEvent )
|
2007-12-01 03:42:52 +00:00
|
|
|
{
|
2020-09-17 13:36:34 +00:00
|
|
|
if( m_Notebook->GetSelection() == 0 )
|
2007-12-03 05:14:51 +00:00
|
|
|
{
|
2020-02-24 23:17:30 +00:00
|
|
|
// Clear the selection. It may be the selected DRC marker.
|
2023-06-26 22:16:51 +00:00
|
|
|
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::selectionClear );
|
2011-12-22 13:28:11 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel->DeleteCurrentItem( true );
|
2019-05-14 22:07:34 +00:00
|
|
|
|
2020-02-24 23:17:30 +00:00
|
|
|
// redraw the pcb
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2020-09-17 13:36:34 +00:00
|
|
|
else if( m_Notebook->GetSelection() == 1 )
|
2007-12-03 05:14:51 +00:00
|
|
|
{
|
2020-02-28 00:05:40 +00:00
|
|
|
m_unconnectedTreeModel->DeleteCurrentItem( true );
|
|
|
|
}
|
2020-09-17 13:36:34 +00:00
|
|
|
else if( m_Notebook->GetSelection() == 2 )
|
2020-02-28 00:05:40 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
m_fpWarningsTreeModel->DeleteCurrentItem( true );
|
2007-12-03 05:14:51 +00:00
|
|
|
}
|
2016-09-08 18:17:37 +00:00
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
updateDisplayedCounts();
|
2016-09-08 18:17:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::OnDeleteAllClick( wxCommandEvent& aEvent )
|
2020-02-25 12:17:13 +00:00
|
|
|
{
|
2020-08-04 12:25:44 +00:00
|
|
|
static bool s_includeExclusions = false;
|
|
|
|
|
2020-08-02 21:45:06 +00:00
|
|
|
int numExcluded = 0;
|
|
|
|
|
|
|
|
if( m_markersProvider )
|
|
|
|
numExcluded += m_markersProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
if( m_ratsnestProvider )
|
|
|
|
numExcluded += m_ratsnestProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
2020-08-02 21:45:06 +00:00
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
if( m_fpWarningsProvider )
|
|
|
|
numExcluded += m_fpWarningsProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
2020-08-02 21:45:06 +00:00
|
|
|
|
|
|
|
if( numExcluded > 0 )
|
|
|
|
{
|
2024-02-09 11:20:08 +00:00
|
|
|
wxMessageDialog dlg( this, _( "Delete exclusions too?" ), _( "Delete All Markers" ),
|
|
|
|
wxYES_NO | wxCANCEL | wxCENTER | wxICON_QUESTION );
|
|
|
|
dlg.SetYesNoLabels( _( "Errors and Warnings Only" ),
|
|
|
|
_( "Errors, Warnings and Exclusions" ) );
|
2020-08-02 21:45:06 +00:00
|
|
|
|
|
|
|
int ret = dlg.ShowModal();
|
|
|
|
|
|
|
|
if( ret == wxID_CANCEL )
|
|
|
|
return;
|
2024-02-09 11:20:08 +00:00
|
|
|
else if( ret == wxID_NO )
|
|
|
|
s_includeExclusions = true;
|
2020-08-02 21:45:06 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 12:25:44 +00:00
|
|
|
deleteAllMarkers( s_includeExclusions );
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
2020-02-28 00:05:40 +00:00
|
|
|
updateDisplayedCounts();
|
2020-02-25 12:17:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-03-16 11:05:01 +00:00
|
|
|
void DIALOG_DRC::updateDisplayedCounts()
|
2016-09-08 18:17:37 +00:00
|
|
|
{
|
2022-02-09 15:34:22 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = m_frame->GetDesignSettings();
|
|
|
|
DRC_TOOL* drcTool = m_frame->GetToolManager()->GetTool<DRC_TOOL>();
|
|
|
|
DRC_ENGINE* drcEngine = drcTool->GetDRCEngine().get();
|
|
|
|
|
2020-10-28 17:28:30 +00:00
|
|
|
// Collect counts:
|
|
|
|
|
|
|
|
int numMarkers = 0;
|
|
|
|
int numUnconnected = 0;
|
|
|
|
int numFootprints = 0;
|
|
|
|
|
|
|
|
int numErrors = 0;
|
|
|
|
int numWarnings = 0;
|
|
|
|
int numExcluded = 0;
|
|
|
|
|
|
|
|
if( m_markersProvider )
|
|
|
|
{
|
|
|
|
numMarkers += m_markersProvider->GetCount();
|
|
|
|
numErrors += m_markersProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_markersProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_markersProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
if( m_ratsnestProvider )
|
2020-10-28 17:28:30 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
numUnconnected += m_ratsnestProvider->GetCount();
|
|
|
|
numErrors += m_ratsnestProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_ratsnestProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_ratsnestProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
2020-10-28 17:28:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
if( m_footprintTestsRun && m_fpWarningsProvider )
|
2020-10-28 17:28:30 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
numFootprints += m_fpWarningsProvider->GetCount();
|
|
|
|
numErrors += m_fpWarningsProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_fpWarningsProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_fpWarningsProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
2020-10-28 17:28:30 +00:00
|
|
|
}
|
|
|
|
|
2022-09-11 16:27:47 +00:00
|
|
|
bool showErrors = m_showErrors->GetValue();
|
|
|
|
bool showWarnings = m_showWarnings->GetValue();
|
2022-02-09 15:34:22 +00:00
|
|
|
bool errorsOverflowed = false;
|
|
|
|
bool warningsOverflowed = false;
|
|
|
|
bool markersOverflowed = false;
|
|
|
|
bool unconnectedOverflowed = false;
|
|
|
|
bool footprintsOverflowed = false;
|
|
|
|
|
|
|
|
for( int ii = DRCE_FIRST; ii < DRCE_LAST; ++ii )
|
|
|
|
{
|
2022-09-11 16:27:47 +00:00
|
|
|
if( drcEngine->IsErrorLimitExceeded( ii ) )
|
2022-02-09 15:34:22 +00:00
|
|
|
{
|
|
|
|
if( bds.GetSeverity( ii ) == RPT_SEVERITY_ERROR )
|
|
|
|
errorsOverflowed = true;
|
|
|
|
else if( bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING )
|
|
|
|
warningsOverflowed = true;
|
|
|
|
|
|
|
|
if( ii == DRCE_UNCONNECTED_ITEMS )
|
|
|
|
{
|
2022-09-11 16:27:47 +00:00
|
|
|
if( showWarnings && bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING )
|
|
|
|
unconnectedOverflowed = true;
|
|
|
|
else if( showErrors && bds.GetSeverity( ii ) == RPT_SEVERITY_ERROR )
|
|
|
|
unconnectedOverflowed = true;
|
2022-02-09 15:34:22 +00:00
|
|
|
}
|
|
|
|
else if( ii == DRCE_MISSING_FOOTPRINT
|
|
|
|
|| ii == DRCE_DUPLICATE_FOOTPRINT
|
|
|
|
|| ii == DRCE_EXTRA_FOOTPRINT
|
2024-01-20 18:41:11 +00:00
|
|
|
|| ii == DRCE_NET_CONFLICT
|
|
|
|
|| ii == DRCE_SCHEMATIC_PARITY_ISSUES )
|
2022-02-09 15:34:22 +00:00
|
|
|
{
|
2022-09-11 16:27:47 +00:00
|
|
|
if( showWarnings && bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING )
|
|
|
|
footprintsOverflowed = true;
|
|
|
|
else if( showErrors && bds.GetSeverity( ii ) == RPT_SEVERITY_ERROR )
|
|
|
|
footprintsOverflowed = true;
|
2022-02-09 15:34:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-11 16:27:47 +00:00
|
|
|
if( showWarnings && bds.GetSeverity( ii ) == RPT_SEVERITY_WARNING )
|
|
|
|
markersOverflowed = true;
|
|
|
|
else if( showErrors && bds.GetSeverity( ii ) == RPT_SEVERITY_ERROR )
|
|
|
|
markersOverflowed = true;
|
2022-02-09 15:34:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-28 19:30:51 +00:00
|
|
|
wxString msg;
|
2022-02-09 15:34:22 +00:00
|
|
|
wxString num;
|
2019-03-28 19:30:51 +00:00
|
|
|
|
2020-10-28 17:28:30 +00:00
|
|
|
// Update tab headers:
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-09-14 17:54:14 +00:00
|
|
|
if( m_drcRun )
|
2019-03-28 19:30:51 +00:00
|
|
|
{
|
2022-02-09 15:34:22 +00:00
|
|
|
num.Printf( markersOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numMarkers );
|
|
|
|
msg.Printf( m_markersTitleTemplate, num );
|
2019-03-28 19:30:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg = m_markersTitleTemplate;
|
2022-02-09 15:34:22 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
2022-06-19 19:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Notebook->SetPageText( 0, msg );
|
2019-03-28 19:30:51 +00:00
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
if( m_drcRun )
|
|
|
|
{
|
|
|
|
num.Printf( unconnectedOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numUnconnected );
|
|
|
|
msg.sprintf( m_unconnectedTitleTemplate, num );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-28 19:30:51 +00:00
|
|
|
msg = m_unconnectedTitleTemplate;
|
2022-02-09 15:34:22 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
2022-06-19 19:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_Notebook->SetPageText( 1, msg );
|
2018-01-30 14:13:34 +00:00
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
if( m_footprintTestsRun )
|
|
|
|
{
|
|
|
|
num.Printf( footprintsOverflowed ? wxT( "%d+" ) : wxT( "%d" ), numFootprints );
|
|
|
|
msg.sprintf( m_footprintsTitleTemplate, num );
|
|
|
|
}
|
|
|
|
else if( m_drcRun )
|
|
|
|
{
|
|
|
|
msg = m_footprintsTitleTemplate;
|
|
|
|
msg.Replace( wxT( "%s" ), _( "not run" ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-03-28 19:30:51 +00:00
|
|
|
msg = m_footprintsTitleTemplate;
|
2022-02-09 15:34:22 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
2022-06-19 19:51:19 +00:00
|
|
|
}
|
2021-07-11 21:47:19 +00:00
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
m_Notebook->SetPageText( 2, msg );
|
|
|
|
|
|
|
|
if( m_drcRun )
|
|
|
|
{
|
|
|
|
num.Printf( wxT( "%d" ), m_ignoredList->GetItemCount() );
|
|
|
|
msg.sprintf( m_ignoredTitleTemplate, num );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-11 21:47:19 +00:00
|
|
|
msg = m_ignoredTitleTemplate;
|
2022-02-09 15:34:22 +00:00
|
|
|
msg.Replace( wxT( "(%s)" ), wxEmptyString );
|
2019-03-28 19:30:51 +00:00
|
|
|
}
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2022-06-19 19:51:19 +00:00
|
|
|
m_Notebook->SetPageText( 3, msg );
|
|
|
|
|
2020-10-28 17:28:30 +00:00
|
|
|
// Update badges:
|
2020-02-28 00:05:40 +00:00
|
|
|
|
2020-10-20 15:57:09 +00:00
|
|
|
if( !m_drcRun && numErrors == 0 )
|
2020-09-21 10:37:20 +00:00
|
|
|
numErrors = -1;
|
2020-10-20 15:57:09 +00:00
|
|
|
|
|
|
|
if( !m_drcRun && numWarnings == 0 )
|
2020-09-21 10:37:20 +00:00
|
|
|
numWarnings = -1;
|
|
|
|
|
2020-10-20 15:49:52 +00:00
|
|
|
m_errorsBadge->SetMaximumNumber( numErrors );
|
2022-02-09 15:34:22 +00:00
|
|
|
m_errorsBadge->UpdateNumber( errorsOverflowed ? numErrors + 1 : numErrors,
|
|
|
|
RPT_SEVERITY_ERROR );
|
2020-10-20 15:49:52 +00:00
|
|
|
|
|
|
|
m_warningsBadge->SetMaximumNumber( numWarnings );
|
2022-02-09 15:34:22 +00:00
|
|
|
m_warningsBadge->UpdateNumber( warningsOverflowed ? numWarnings + 1 : numWarnings,
|
|
|
|
RPT_SEVERITY_WARNING );
|
2020-10-20 15:49:52 +00:00
|
|
|
|
|
|
|
m_exclusionsBadge->SetMaximumNumber( numExcluded );
|
2020-10-20 01:32:49 +00:00
|
|
|
m_exclusionsBadge->UpdateNumber( numExcluded, RPT_SEVERITY_EXCLUSION );
|
2007-12-01 03:42:52 +00:00
|
|
|
}
|