Update board markers from DRC changes before dialog is closed.

Fixes https://gitlab.com/kicad/code/kicad/issues/5110
This commit is contained in:
Jeff Young 2020-08-08 18:06:00 +01:00
parent 484643c5ed
commit ae404e6339
1 changed files with 27 additions and 5 deletions

View File

@ -36,7 +36,7 @@
#include <tool/tool_manager.h> #include <tool/tool_manager.h>
#include <tools/pcb_actions.h> #include <tools/pcb_actions.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <rc_item.h> #include <class_marker_pcb.h>
#include <wx/wupdlock.h> #include <wx/wupdlock.h>
#include <widgets/ui_common.h> #include <widgets/ui_common.h>
#include <pcb_layer_widget.h> #include <pcb_layer_widget.h>
@ -332,15 +332,24 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
switch( GetPopupMenuSelectionFromUser( menu ) ) switch( GetPopupMenuSelectionFromUser( menu ) )
{ {
case 1: case 1:
node->m_RcItem->GetParent()->SetExcluded( false ); {
MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
marker->SetExcluded( false );
m_brdEditor->GetCanvas()->GetView()->Update( marker );
// Update view // Update view
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
modified = true; modified = true;
}
break; break;
case 2: case 2:
node->m_RcItem->GetParent()->SetExcluded( true ); {
MARKER_PCB* marker = dynamic_cast<MARKER_PCB*>( node->m_RcItem->GetParent() );
marker->SetExcluded( true );
m_brdEditor->GetCanvas()->GetView()->Update( marker );
// Update view // Update view
if( m_severities & RPT_SEVERITY_EXCLUSION ) if( m_severities & RPT_SEVERITY_EXCLUSION )
@ -349,11 +358,18 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->DeleteCurrentItem( false );
modified = true; modified = true;
}
break; break;
case 3: case 3:
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR; bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_ERROR;
for( MARKER_PCB* marker : m_brdEditor->GetBoard()->Markers() )
{
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
m_brdEditor->GetCanvas()->GetView()->Update( marker );
}
// Rebuild model and view // Rebuild model and view
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
modified = true; modified = true;
@ -362,6 +378,12 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
case 4: case 4:
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_WARNING; bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_WARNING;
for( MARKER_PCB* marker : m_brdEditor->GetBoard()->Markers() )
{
if( marker->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
m_brdEditor->GetCanvas()->GetView()->Update( marker );
}
// Rebuild model and view // Rebuild model and view
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider ); static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->SetProvider( m_markersProvider );
modified = true; modified = true;
@ -372,13 +394,12 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_IGNORE; bds().m_DRCSeverities[ rcItem->GetErrorCode() ] = RPT_SEVERITY_IGNORE;
std::vector<MARKER_PCB*>& markers = m_brdEditor->GetBoard()->Markers(); std::vector<MARKER_PCB*>& markers = m_brdEditor->GetBoard()->Markers();
KIGFX::VIEW* view = m_parentFrame->GetToolManager()->GetView();
for( unsigned i = 0; i < markers.size(); ) for( unsigned i = 0; i < markers.size(); )
{ {
if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() ) if( markers[i]->GetRCItem()->GetErrorCode() == rcItem->GetErrorCode() )
{ {
view->Remove( markers.at( i ) ); m_brdEditor->GetCanvas()->GetView()->Remove( markers.at( i ) );
markers.erase( markers.begin() + i ); markers.erase( markers.begin() + i );
} }
else else
@ -399,6 +420,7 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
if( modified ) if( modified )
{ {
updateDisplayedCounts(); updateDisplayedCounts();
refreshBoardEditor();
m_brdEditor->OnModify(); m_brdEditor->OnModify();
m_brdEditor->SyncToolbars(); m_brdEditor->SyncToolbars();
} }