Update DRC exclusions model to match terminology.

DRC exclusions were originally written following the C++
pragma model (ie: allow this violation here).  However, the
"exclusion" terminology we used in the GUI suggests a model
model where the exclusions go away when the violation no
longer exists.

Fixes https://gitlab.com/kicad/code/kicad/issues/14351
This commit is contained in:
Jeff Young 2023-04-15 10:54:53 +01:00
parent 27ebba6b33
commit 521aa5b5ae
7 changed files with 34 additions and 26 deletions

View File

@ -306,7 +306,7 @@ void BOARD::UpdateRatsnestExclusions()
}
std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions()
std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions( bool aCreateMarkers )
{
for( PCB_MARKER* marker : GetBoard()->Markers() )
{
@ -321,28 +321,31 @@ std::vector<PCB_MARKER*> BOARD::ResolveDRCExclusions()
std::vector<PCB_MARKER*> newMarkers;
for( const wxString& exclusionData : m_designSettings->m_DrcExclusions )
if( aCreateMarkers )
{
PCB_MARKER* marker = PCB_MARKER::Deserialize( exclusionData );
if( !marker )
continue;
// Check to see if items still exist
for( const KIID& guid : marker->GetRCItem()->GetIDs() )
for( const wxString& exclusionData : m_designSettings->m_DrcExclusions )
{
if( GetItem( guid ) == DELETED_BOARD_ITEM::GetInstance() )
PCB_MARKER* marker = PCB_MARKER::Deserialize( exclusionData );
if( !marker )
continue;
// Check to see if items still exist
for( const KIID& guid : marker->GetRCItem()->GetIDs() )
{
delete marker;
marker = nullptr;
break;
if( GetItem( guid ) == DELETED_BOARD_ITEM::GetInstance() )
{
delete marker;
marker = nullptr;
break;
}
}
}
if( marker )
{
marker->SetExcluded( true );
newMarkers.push_back( marker );
if( marker )
{
marker->SetExcluded( true );
newMarkers.push_back( marker );
}
}
}

View File

@ -460,8 +460,12 @@ public:
/**
* Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
*
* @param aCreateMarkers if true, create markers from serialized data; if false only
* use serialized data to set existing markers to excluded.
* The former is used on board load; the later after a DRC.
*/
std::vector<PCB_MARKER*> ResolveDRCExclusions();
std::vector<PCB_MARKER*> ResolveDRCExclusions( bool aCreateMarkers );
/**
* Update the visibility flags on the current unconnected ratsnest lines.

View File

@ -826,7 +826,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
// we should not ask PLUGINs to do these items:
loadedBoard->BuildListOfNets();
ResolveDRCExclusions();
ResolveDRCExclusions( true );
m_toolManager->RunAction( PCB_ACTIONS::repairBoard, true, true);
if( loadedBoard->IsModified() )

View File

@ -984,11 +984,11 @@ void PCB_EDIT_FRAME::RecordDRCExclusions()
}
void PCB_EDIT_FRAME::ResolveDRCExclusions()
void PCB_EDIT_FRAME::ResolveDRCExclusions( bool aCreateMarkers )
{
BOARD_COMMIT commit( this );
for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions() )
for( PCB_MARKER* marker : GetBoard()->ResolveDRCExclusions( aCreateMarkers ) )
{
if( marker->GetMarkerType() == MARKER_BASE::MARKER_DRAWING_SHEET )
marker->GetRCItem()->SetItems( GetCanvas()->GetDrawingSheet() );

View File

@ -238,9 +238,10 @@ public:
void RecordDRCExclusions();
/**
* Update markers to match recorded exclusions.
* If aCreateMarkers then create DRC exclusion markers from the serialized data. If false,
* then use the serialized data to set exclusion flags on existing markers.
*/
void ResolveDRCExclusions();
void ResolveDRCExclusions( bool aCreateMarkers );
void Process_Special_Functions( wxCommandEvent& event );
void Tracks_and_Vias_Size_Event( wxCommandEvent& event );

View File

@ -183,7 +183,7 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
// Best efforts...
}
for( PCB_MARKER* marker : brd->ResolveDRCExclusions() )
for( PCB_MARKER* marker : brd->ResolveDRCExclusions( true ) )
brd->Add( marker );
brd->BuildConnectivity();

View File

@ -206,7 +206,7 @@ void DRC_TOOL::updatePointers()
// update my pointers, m_editFrame is the only unchangeable one
m_pcb = m_editFrame->GetBoard();
m_editFrame->ResolveDRCExclusions();
m_editFrame->ResolveDRCExclusions( false );
if( m_drcDialog )
m_drcDialog->UpdateData();