2020-11-21 20:42:27 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-03-14 22:13:19 +00:00
|
|
|
* Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-11-21 20:42:27 +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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <dialog_footprint_checker.h>
|
2021-04-08 17:13:48 +00:00
|
|
|
#include <widgets/appearance_controls.h>
|
2020-11-21 20:42:27 +00:00
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tools/pcb_actions.h>
|
2021-06-03 18:05:43 +00:00
|
|
|
#include <footprint.h>
|
2022-03-18 19:35:40 +00:00
|
|
|
#include <pad.h>
|
2020-11-21 20:42:27 +00:00
|
|
|
#include <pcb_marker.h>
|
2021-12-01 14:42:44 +00:00
|
|
|
#include <drc/drc_item.h>
|
2020-11-21 20:42:27 +00:00
|
|
|
#include <footprint_edit_frame.h>
|
2021-07-14 20:03:32 +00:00
|
|
|
#include <convert_shape_list_to_polygon.h>
|
2020-12-25 16:26:32 +00:00
|
|
|
#include <tools/footprint_editor_control.h>
|
2020-11-21 20:42:27 +00:00
|
|
|
|
|
|
|
|
2022-08-20 10:44:40 +00:00
|
|
|
static FOOTPRINT* g_lastFootprint = nullptr;
|
|
|
|
static bool g_lastChecksRun = false;
|
|
|
|
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
DIALOG_FOOTPRINT_CHECKER::DIALOG_FOOTPRINT_CHECKER( FOOTPRINT_EDIT_FRAME* aParent ) :
|
|
|
|
DIALOG_FOOTPRINT_CHECKER_BASE( aParent ),
|
2021-04-08 17:13:48 +00:00
|
|
|
m_frame( aParent ),
|
|
|
|
m_checksRun( false ),
|
2022-08-30 11:03:40 +00:00
|
|
|
m_severities( RPT_SEVERITY_ERROR | RPT_SEVERITY_WARNING ),
|
|
|
|
m_centerMarkerOnIdle( nullptr )
|
2020-11-21 20:42:27 +00:00
|
|
|
{
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>( m_frame->GetBoard(),
|
|
|
|
MARKER_BASE::MARKER_DRC );
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
m_markersTreeModel = new RC_TREE_MODEL( m_frame, m_markersDataView );
|
|
|
|
m_markersDataView->AssociateModel( m_markersTreeModel );
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersTreeModel->Update( m_markersProvider, m_severities );
|
2022-08-20 10:44:40 +00:00
|
|
|
|
|
|
|
if( m_frame->GetBoard()->GetFirstFootprint() == g_lastFootprint )
|
|
|
|
{
|
|
|
|
m_checksRun = g_lastChecksRun;
|
|
|
|
updateDisplayedCounts();
|
|
|
|
}
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons( { { wxID_OK, _( "Run Checks" ) },
|
|
|
|
{ wxID_CANCEL, _( "Close" ) } } );
|
2021-04-08 17:13:48 +00:00
|
|
|
|
|
|
|
syncCheckboxes();
|
|
|
|
|
|
|
|
finishDialogSettings();
|
2020-11-21 20:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_FOOTPRINT_CHECKER::~DIALOG_FOOTPRINT_CHECKER()
|
|
|
|
{
|
2022-08-20 10:44:40 +00:00
|
|
|
m_frame->FocusOnItem( nullptr );
|
|
|
|
|
|
|
|
g_lastFootprint = m_frame->GetBoard()->GetFirstFootprint();
|
|
|
|
g_lastChecksRun = m_checksRun;
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
m_markersTreeModel->DecRef();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_FOOTPRINT_CHECKER::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool DIALOG_FOOTPRINT_CHECKER::TransferDataFromWindow()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
// Don't globally define this; different facilities use different definitions of "ALL"
|
|
|
|
static int RPT_SEVERITY_ALL = RPT_SEVERITY_WARNING | RPT_SEVERITY_ERROR | RPT_SEVERITY_EXCLUSION;
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::syncCheckboxes()
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::runChecks()
|
|
|
|
{
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
FOOTPRINT* footprint = board->GetFirstFootprint();
|
|
|
|
wxString msg;
|
|
|
|
|
|
|
|
deleteAllMarkers();
|
|
|
|
|
|
|
|
if( !footprint )
|
|
|
|
{
|
|
|
|
msg = _( "No footprint loaded." );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
auto errorHandler =
|
2022-08-19 17:34:53 +00:00
|
|
|
[&]( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB, const BOARD_ITEM* aItemC,
|
|
|
|
int aErrorCode, const wxString& aMsg, const VECTOR2I& aPt )
|
2020-11-21 20:42:27 +00:00
|
|
|
{
|
2022-03-18 19:35:40 +00:00
|
|
|
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( aErrorCode );
|
|
|
|
|
|
|
|
if( !aMsg.IsEmpty() )
|
|
|
|
drcItem->SetErrorMessage( drcItem->GetErrorText() + wxS( " " ) + aMsg );
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
drcItem->SetItems( aItemA, aItemB, aItemC );
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2020-11-25 00:08:09 +00:00
|
|
|
PCB_MARKER* marker = new PCB_MARKER( drcItem, aPt );
|
2020-11-21 20:42:27 +00:00
|
|
|
board->Add( marker );
|
|
|
|
m_frame->GetCanvas()->GetView()->Add( marker );
|
|
|
|
};
|
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
OUTLINE_ERROR_HANDLER outlineErrorHandler =
|
|
|
|
[&]( const wxString& aMsg, BOARD_ITEM* aItemA, BOARD_ITEM* aItemB, const VECTOR2I& aPt )
|
2021-09-25 15:55:33 +00:00
|
|
|
{
|
2023-08-18 09:30:03 +00:00
|
|
|
if( !aItemA ) // If we only have a single item, make sure it's A
|
|
|
|
std::swap( aItemA, aItemB );
|
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
errorHandler( aItemA, aItemB, nullptr, DRCE_MALFORMED_COURTYARD, aMsg, aPt );
|
2021-09-25 15:55:33 +00:00
|
|
|
};
|
|
|
|
|
2022-07-31 21:14:24 +00:00
|
|
|
footprint->BuildCourtyardCaches( &outlineErrorHandler );
|
2022-03-18 19:35:40 +00:00
|
|
|
|
|
|
|
footprint->CheckFootprintAttributes(
|
2022-03-26 15:10:41 +00:00
|
|
|
[&]( const wxString& aMsg )
|
2021-10-19 11:24:30 +00:00
|
|
|
{
|
2022-08-19 17:34:53 +00:00
|
|
|
errorHandler( footprint, nullptr, nullptr, DRCE_FOOTPRINT_TYPE_MISMATCH, aMsg,
|
|
|
|
{ 0, 0 } );
|
2022-03-18 19:35:40 +00:00
|
|
|
} );
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-03-18 19:35:40 +00:00
|
|
|
footprint->CheckPads(
|
|
|
|
[&]( const PAD* aPad, int aErrorCode, const wxString& aMsg )
|
|
|
|
{
|
2022-08-19 17:34:53 +00:00
|
|
|
errorHandler( aPad, nullptr, nullptr, aErrorCode, aMsg, aPad->GetPosition() );
|
2022-03-18 19:35:40 +00:00
|
|
|
} );
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-09-25 16:23:14 +00:00
|
|
|
footprint->CheckShortingPads(
|
2022-03-18 19:35:40 +00:00
|
|
|
[&]( const PAD* aPadA, const PAD* aPadB, const VECTOR2I& aPosition )
|
|
|
|
{
|
2022-09-25 16:23:14 +00:00
|
|
|
errorHandler( aPadA, aPadB, nullptr, DRCE_SHORTING_ITEMS, wxEmptyString,
|
2022-08-19 17:34:53 +00:00
|
|
|
aPosition );
|
2022-03-18 19:35:40 +00:00
|
|
|
} );
|
2021-10-19 11:24:30 +00:00
|
|
|
|
2022-08-19 17:34:53 +00:00
|
|
|
if( footprint->IsNetTie() )
|
|
|
|
{
|
|
|
|
footprint->CheckNetTiePadGroups(
|
|
|
|
[&]( const wxString& aMsg )
|
|
|
|
{
|
|
|
|
errorHandler( footprint, nullptr, nullptr, DRCE_FOOTPRINT, aMsg, { 0, 0 } );
|
|
|
|
} );
|
|
|
|
|
|
|
|
footprint->CheckNetTies(
|
|
|
|
[&]( const BOARD_ITEM* aItemA, const BOARD_ITEM* aItemB, const BOARD_ITEM* aItemC,
|
|
|
|
const VECTOR2I& aPosition )
|
|
|
|
{
|
|
|
|
errorHandler( aItemA, aItemB, aItemC, DRCE_SHORTING_ITEMS, wxEmptyString,
|
|
|
|
aPosition );
|
|
|
|
} );
|
|
|
|
}
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_checksRun = true;
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersTreeModel->Update( m_markersProvider, m_severities );
|
|
|
|
updateDisplayedCounts();
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
refreshEditor();
|
2020-11-21 20:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-20 10:01:43 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::SelectMarker( const PCB_MARKER* aMarker )
|
|
|
|
{
|
|
|
|
m_markersTreeModel->SelectMarker( aMarker );
|
|
|
|
|
|
|
|
// wxWidgets on some platforms fails to correctly ensure that a selected item is
|
|
|
|
// visible, so we have to do it in a separate idle event.
|
|
|
|
m_centerMarkerOnIdle = aMarker;
|
|
|
|
Bind( wxEVT_IDLE, &DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler( wxIdleEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_markersTreeModel->CenterMarker( m_centerMarkerOnIdle );
|
|
|
|
m_centerMarkerOnIdle = nullptr;
|
|
|
|
Unbind( wxEVT_IDLE, &DIALOG_FOOTPRINT_CHECKER::centerMarkerIdleHandler, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnRunChecksClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
2021-04-08 17:13:48 +00:00
|
|
|
m_checksRun = false;
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
runChecks();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnSelectItem( wxDataViewEvent& aEvent )
|
|
|
|
{
|
|
|
|
BOARD* board = m_frame->GetBoard();
|
|
|
|
RC_TREE_NODE* node = RC_TREE_MODEL::ToNode( aEvent.GetItem() );
|
|
|
|
const KIID& itemID = node ? RC_TREE_MODEL::ToUUID( aEvent.GetItem() ) : niluuid;
|
|
|
|
BOARD_ITEM* item = board->GetItem( itemID );
|
|
|
|
|
2022-08-20 10:01:43 +00:00
|
|
|
if( m_centerMarkerOnIdle )
|
|
|
|
{
|
|
|
|
// we already came from a cross-probe of the marker in the document; don't go
|
|
|
|
// around in circles
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
if( node && item )
|
|
|
|
{
|
2022-03-21 18:18:39 +00:00
|
|
|
PCB_LAYER_ID principalLayer = UNDEFINED_LAYER;
|
2021-04-08 17:13:48 +00:00
|
|
|
LSET violationLayers;
|
|
|
|
std::shared_ptr<RC_ITEM> rc_item = node->m_RcItem;
|
|
|
|
|
2022-03-21 18:18:39 +00:00
|
|
|
if( item->GetLayerSet().count() > 0 )
|
|
|
|
principalLayer = item->GetLayerSet().Seq().front();
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
if( rc_item->GetErrorCode() == DRCE_MALFORMED_COURTYARD )
|
|
|
|
{
|
|
|
|
BOARD_ITEM* a = board->GetItem( rc_item->GetMainItemID() );
|
|
|
|
|
|
|
|
if( a && ( a->GetFlags() & MALFORMED_B_COURTYARD ) > 0
|
|
|
|
&& ( a->GetFlags() & MALFORMED_F_COURTYARD ) == 0 )
|
|
|
|
{
|
|
|
|
principalLayer = B_CrtYd;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
principalLayer = F_CrtYd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (rc_item->GetErrorCode() == DRCE_INVALID_OUTLINE )
|
|
|
|
{
|
|
|
|
principalLayer = Edge_Cuts;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
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( a || b || c || d )
|
|
|
|
violationLayers = LSET::AllLayersMask();
|
|
|
|
|
|
|
|
if( a )
|
|
|
|
violationLayers &= a->GetLayerSet();
|
|
|
|
|
|
|
|
if( b )
|
|
|
|
violationLayers &= b->GetLayerSet();
|
|
|
|
|
|
|
|
if( c )
|
|
|
|
violationLayers &= c->GetLayerSet();
|
|
|
|
|
|
|
|
if( d )
|
|
|
|
violationLayers &= d->GetLayerSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( violationLayers.count() )
|
|
|
|
principalLayer = violationLayers.Seq().front();
|
|
|
|
else
|
|
|
|
violationLayers.set( principalLayer );
|
|
|
|
|
|
|
|
WINDOW_THAWER thawer( m_frame );
|
|
|
|
|
|
|
|
m_frame->FocusOnItem( item );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
|
|
|
|
if( ( violationLayers & board->GetVisibleLayers() ) == 0 )
|
|
|
|
{
|
|
|
|
m_frame->GetAppearancePanel()->SetLayerVisible( principalLayer, true );
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( board->GetVisibleLayers().test( principalLayer ) )
|
|
|
|
m_frame->SetActiveLayer( principalLayer );
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnLeftDClickItem( wxMouseEvent& event )
|
|
|
|
{
|
|
|
|
if( m_markersDataView->GetCurrentItem().IsOk() )
|
|
|
|
{
|
|
|
|
// turn control over to m_frame, hide this DIALOG_FOOTPRINT_CHECKER window,
|
|
|
|
// no destruction so we can preserve listbox cursor
|
|
|
|
if( !IsModal() )
|
|
|
|
Show( false );
|
|
|
|
}
|
|
|
|
|
2021-06-09 19:32:58 +00:00
|
|
|
// Do not skip aVent here: this is not useful, and Pcbnew crashes
|
2021-04-08 17:13:48 +00:00
|
|
|
// if skipped (at least on Windows)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnSeverity( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
int flag = 0;
|
|
|
|
|
|
|
|
if( aEvent.GetEventObject() == m_showAll )
|
|
|
|
flag = RPT_SEVERITY_ALL;
|
|
|
|
else if( aEvent.GetEventObject() == m_showErrors )
|
|
|
|
flag = RPT_SEVERITY_ERROR;
|
|
|
|
else if( aEvent.GetEventObject() == m_showWarnings )
|
|
|
|
flag = RPT_SEVERITY_WARNING;
|
|
|
|
else if( aEvent.GetEventObject() == m_showExclusions )
|
|
|
|
flag = RPT_SEVERITY_EXCLUSION;
|
|
|
|
|
|
|
|
if( aEvent.IsChecked() )
|
|
|
|
m_severities |= flag;
|
|
|
|
else if( aEvent.GetEventObject() == m_showAll )
|
|
|
|
m_severities = RPT_SEVERITY_ERROR;
|
|
|
|
else
|
|
|
|
m_severities &= ~flag;
|
|
|
|
|
|
|
|
syncCheckboxes();
|
|
|
|
|
2022-08-30 11:03:40 +00:00
|
|
|
m_markersTreeModel->Update( m_markersProvider, m_severities );
|
2021-04-08 17:13:48 +00:00
|
|
|
updateDisplayedCounts();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-21 20:42:27 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnCancelClick( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_frame->FocusOnItem( nullptr );
|
|
|
|
|
|
|
|
SetReturnCode( wxID_CANCEL );
|
|
|
|
|
|
|
|
// Leave the tool to destroy (or not) the dialog
|
2020-12-25 16:26:32 +00:00
|
|
|
FOOTPRINT_EDITOR_CONTROL* tool = m_frame->GetToolManager()->GetTool<FOOTPRINT_EDITOR_CONTROL>();
|
2020-11-21 20:42:27 +00:00
|
|
|
tool->DestroyCheckerDialog();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnClose( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
wxCommandEvent dummy;
|
|
|
|
OnCancelClick( dummy );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::refreshEditor()
|
2020-11-21 20:42:27 +00:00
|
|
|
{
|
|
|
|
WINDOW_THAWER thawer( m_frame );
|
|
|
|
|
|
|
|
m_frame->GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnDeleteOneClick( wxCommandEvent& aEvent )
|
2020-11-21 20:42:27 +00:00
|
|
|
{
|
2021-04-08 17:13:48 +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 );
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_markersTreeModel->DeleteCurrentItem( true );
|
|
|
|
|
|
|
|
// redraw the pcb
|
|
|
|
refreshEditor();
|
|
|
|
|
|
|
|
updateDisplayedCounts();
|
2020-11-21 20:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::OnDeleteAllClick( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
deleteAllMarkers();
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
m_checksRun = false;
|
|
|
|
refreshEditor();
|
|
|
|
updateDisplayedCounts();
|
2020-11-21 20:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_FOOTPRINT_CHECKER::deleteAllMarkers()
|
|
|
|
{
|
|
|
|
// 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 );
|
2020-11-21 20:42:27 +00:00
|
|
|
|
2022-08-08 21:00:37 +00:00
|
|
|
m_markersTreeModel->DeleteItems( false, true, false );
|
|
|
|
m_frame->GetBoard()->DeleteMARKERs( true, true );
|
2020-11-21 20:42:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-08 17:13:48 +00:00
|
|
|
void DIALOG_FOOTPRINT_CHECKER::updateDisplayedCounts()
|
|
|
|
{
|
|
|
|
// Collect counts:
|
|
|
|
|
|
|
|
int numErrors = 0;
|
|
|
|
int numWarnings = 0;
|
|
|
|
int numExcluded = 0;
|
|
|
|
|
|
|
|
if( m_markersProvider )
|
|
|
|
{
|
|
|
|
numErrors += m_markersProvider->GetCount( RPT_SEVERITY_ERROR );
|
|
|
|
numWarnings += m_markersProvider->GetCount( RPT_SEVERITY_WARNING );
|
|
|
|
numExcluded += m_markersProvider->GetCount( RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update badges:
|
|
|
|
|
|
|
|
if( !m_checksRun && numErrors == 0 )
|
|
|
|
numErrors = -1;
|
|
|
|
|
|
|
|
if( !m_checksRun && numWarnings == 0 )
|
|
|
|
numWarnings = -1;
|
|
|
|
|
|
|
|
m_errorsBadge->SetMaximumNumber( numErrors );
|
|
|
|
m_errorsBadge->UpdateNumber( numErrors, RPT_SEVERITY_ERROR );
|
|
|
|
|
|
|
|
m_warningsBadge->SetMaximumNumber( numWarnings );
|
|
|
|
m_warningsBadge->UpdateNumber( numWarnings, RPT_SEVERITY_WARNING );
|
|
|
|
|
|
|
|
m_exclusionsBadge->SetMaximumNumber( numExcluded );
|
|
|
|
m_exclusionsBadge->UpdateNumber( numExcluded, RPT_SEVERITY_EXCLUSION );
|
|
|
|
}
|
|
|
|
|