Keep BOARD_DESIGN_SETTINGS DRC marker exclusions up-to-date.
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17429
This commit is contained in:
parent
797ab998cc
commit
0598ca0f90
|
@ -326,17 +326,45 @@ void BOARD::UpdateRatsnestExclusions()
|
|||
}
|
||||
|
||||
|
||||
void BOARD::RecordDRCExclusions()
|
||||
{
|
||||
m_designSettings->m_DrcExclusions.clear();
|
||||
m_designSettings->m_DrcExclusionComments.clear();
|
||||
|
||||
for( PCB_MARKER* marker : m_markers )
|
||||
{
|
||||
if( marker->IsExcluded() )
|
||||
{
|
||||
wxString serialized = marker->Serialize();
|
||||
m_designSettings->m_DrcExclusions.insert( serialized );
|
||||
m_designSettings->m_DrcExclusionComments[ serialized ] = marker->GetComment();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions( bool aCreateMarkers )
|
||||
{
|
||||
std::set<wxString> exclusions = m_designSettings->m_DrcExclusions;
|
||||
std::map<wxString, wxString> comments = m_designSettings->m_DrcExclusionComments;
|
||||
|
||||
m_designSettings->m_DrcExclusions.clear();
|
||||
m_designSettings->m_DrcExclusionComments.clear();
|
||||
|
||||
for( PCB_MARKER* marker : GetBoard()->Markers() )
|
||||
{
|
||||
wxString serialized = marker->Serialize();
|
||||
std::set<wxString>::iterator it = m_designSettings->m_DrcExclusions.find( serialized );
|
||||
std::set<wxString>::iterator it = exclusions.find( serialized );
|
||||
|
||||
if( it != m_designSettings->m_DrcExclusions.end() )
|
||||
if( it != exclusions.end() )
|
||||
{
|
||||
marker->SetExcluded( true, m_designSettings->m_DrcExclusionComments[serialized] );
|
||||
m_designSettings->m_DrcExclusions.erase( it );
|
||||
marker->SetExcluded( true, comments[ serialized ] );
|
||||
|
||||
// Exclusion still valid; store back to BOARD_DESIGN_SETTINGS
|
||||
m_designSettings->m_DrcExclusions.insert( serialized );
|
||||
m_designSettings->m_DrcExclusionComments[ serialized ] = comments[ serialized ];
|
||||
|
||||
exclusions.erase( it );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +372,7 @@ std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions( bool aCreateMarkers )
|
|||
|
||||
if( aCreateMarkers )
|
||||
{
|
||||
for( const wxString& serialized : m_designSettings->m_DrcExclusions )
|
||||
for( const wxString& serialized : exclusions )
|
||||
{
|
||||
PCB_MARKER* marker = PCB_MARKER::Deserialize( serialized );
|
||||
|
||||
|
@ -364,14 +392,16 @@ std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions( bool aCreateMarkers )
|
|||
|
||||
if( marker )
|
||||
{
|
||||
marker->SetExcluded( true, m_designSettings->m_DrcExclusionComments[serialized] );
|
||||
marker->SetExcluded( true, comments[ serialized ] );
|
||||
newMarkers.push_back( marker );
|
||||
|
||||
// Exclusion still valid; store back to BOARD_DESIGN_SETTINGS
|
||||
m_designSettings->m_DrcExclusions.insert( serialized );
|
||||
m_designSettings->m_DrcExclusionComments[ serialized ] = comments[ serialized ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_designSettings->m_DrcExclusions.clear();
|
||||
|
||||
return newMarkers;
|
||||
}
|
||||
|
||||
|
@ -2750,18 +2780,3 @@ bool BOARD::operator==( const BOARD_ITEM& aItem ) const
|
|||
}
|
||||
|
||||
|
||||
void BOARD::RecordDRCExclusions()
|
||||
{
|
||||
m_designSettings->m_DrcExclusions.clear();
|
||||
m_designSettings->m_DrcExclusionComments.clear();
|
||||
|
||||
for( PCB_MARKER* marker : m_markers )
|
||||
{
|
||||
if( marker->IsExcluded() )
|
||||
{
|
||||
wxString serialized = marker->Serialize();
|
||||
m_designSettings->m_DrcExclusions.insert( serialized );
|
||||
m_designSettings->m_DrcExclusionComments[ serialized ] = marker->GetComment();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -697,6 +697,10 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
|||
|
||||
marker->SetExcluded( true, dlg.GetValue() );
|
||||
|
||||
wxString serialized = marker->Serialize();
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.insert( serialized );
|
||||
m_frame->GetDesignSettings().m_DrcExclusionComments[ serialized ] = dlg.GetValue();
|
||||
|
||||
// Update view
|
||||
static_cast<RC_TREE_MODEL*>( aEvent.GetModel() )->ValueChanged( node );
|
||||
modified = true;
|
||||
|
@ -709,6 +713,10 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
|||
{
|
||||
marker->SetExcluded( false );
|
||||
|
||||
wxString serialized = marker->Serialize();
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.erase( serialized );
|
||||
m_frame->GetDesignSettings().m_DrcExclusionComments.erase( serialized );
|
||||
|
||||
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
||||
{
|
||||
m_frame->GetBoard()->UpdateRatsnestExclusions();
|
||||
|
@ -737,6 +745,10 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
|||
|
||||
marker->SetExcluded( true, dlg.GetValue() );
|
||||
|
||||
wxString serialized = marker->Serialize();
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.insert( serialized );
|
||||
m_frame->GetDesignSettings().m_DrcExclusionComments[ serialized ] = dlg.GetValue();
|
||||
|
||||
if( rcItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
|
||||
{
|
||||
m_frame->GetBoard()->UpdateRatsnestExclusions();
|
||||
|
@ -764,7 +776,13 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
|||
DRC_ITEM* candidateDrcItem = static_cast<DRC_ITEM*>( marker->GetRCItem().get() );
|
||||
|
||||
if( candidateDrcItem->GetViolatingRule() == drcItem->GetViolatingRule() )
|
||||
{
|
||||
marker->SetExcluded( false );
|
||||
|
||||
wxString serialized = marker->Serialize();
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.erase( serialized );
|
||||
m_frame->GetDesignSettings().m_DrcExclusionComments.erase( serialized );
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild model and view
|
||||
|
@ -778,7 +796,12 @@ void DIALOG_DRC::OnDRCItemRClick( wxDataViewEvent& aEvent )
|
|||
DRC_ITEM* candidateDrcItem = static_cast<DRC_ITEM*>( marker->GetRCItem().get() );
|
||||
|
||||
if( candidateDrcItem->GetViolatingRule() == drcItem->GetViolatingRule() )
|
||||
{
|
||||
marker->SetExcluded( true );
|
||||
|
||||
wxString serialized = marker->Serialize();
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.insert( serialized );
|
||||
}
|
||||
}
|
||||
|
||||
// Rebuild model and view
|
||||
|
@ -1043,6 +1066,7 @@ void DIALOG_DRC::ExcludeMarker()
|
|||
if( marker && marker->GetSeverity() != RPT_SEVERITY_EXCLUSION )
|
||||
{
|
||||
marker->SetExcluded( true );
|
||||
m_frame->GetDesignSettings().m_DrcExclusions.insert( marker->Serialize() );
|
||||
m_frame->GetCanvas()->GetView()->Update( marker );
|
||||
|
||||
// Update view
|
||||
|
|
|
@ -1266,10 +1266,8 @@ int PCBNEW_JOBS_HANDLER::JobExportDrc( JOB* aJob )
|
|||
|
||||
commit.Push( _( "DRC" ), SKIP_UNDO | SKIP_SET_DIRTY );
|
||||
|
||||
// now "resolve" the drc exclusions again because its the only way to set exclusion status on
|
||||
// a marker
|
||||
for( PCB_MARKER* marker : brd->ResolveDRCExclusions( false ) )
|
||||
brd->Add( marker );
|
||||
// Update the exclusion status on any excluded markers that still exist.
|
||||
brd->ResolveDRCExclusions( false );
|
||||
|
||||
std::shared_ptr<DRC_ITEMS_PROVIDER> markersProvider = std::make_shared<DRC_ITEMS_PROVIDER>(
|
||||
brd, MARKER_BASE::MARKER_DRC, MARKER_BASE::MARKER_DRAWING_SHEET );
|
||||
|
|
|
@ -605,9 +605,8 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
|
|||
engine->RunTests( aUnits, aReportAllTrackErrors, false );
|
||||
engine->ClearViolationHandler();
|
||||
|
||||
// now "resolve" the drc exclusions again because its the only way to set exclusion status on a marker
|
||||
for( PCB_MARKER* marker : aBoard->ResolveDRCExclusions( false ) )
|
||||
aBoard->Add( marker );
|
||||
// Update the exclusion status on any excluded markers that still exist.
|
||||
aBoard->ResolveDRCExclusions( false );
|
||||
|
||||
// TODO: Unify this with DIALOG_DRC::writeReport
|
||||
|
||||
|
|
Loading…
Reference in New Issue