Fix some initialisation issues in the Python framework.

Fixes https://gitlab.com/kicad/code/kicad/issues/5824
This commit is contained in:
Jeff Young 2020-09-29 12:33:44 +01:00
parent 7dc1966a0d
commit d70f812255
5 changed files with 53 additions and 25 deletions

View File

@ -183,6 +183,38 @@ void BOARD::ClearProject()
}
std::vector<MARKER_PCB*> BOARD::ResolveDRCExclusions()
{
for( MARKER_PCB* marker : GetBoard()->Markers() )
{
auto i = m_designSettings->m_DrcExclusions.find( marker->Serialize() );
if( i != m_designSettings->m_DrcExclusions.end() )
{
marker->SetExcluded( true );
m_designSettings->m_DrcExclusions.erase( i );
}
}
std::vector<MARKER_PCB*> markers;
for( const wxString& exclusionData : m_designSettings->m_DrcExclusions )
{
MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
if( marker )
{
marker->SetExcluded( true );
markers.push_back( marker );
}
}
m_designSettings->m_DrcExclusions.clear();
return markers;
}
bool BOARD::ResolveTextVar( wxString* token, int aDepth ) const
{
if( m_properties.count( *token ) )

View File

@ -367,6 +367,11 @@ public:
void ClearProject();
/**
* Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
*/
std::vector<MARKER_PCB*> ResolveDRCExclusions();
/**
* Reset all high light data to the init state
*/

View File

@ -778,33 +778,10 @@ void PCB_EDIT_FRAME::RecordDRCExclusions()
void PCB_EDIT_FRAME::ResolveDRCExclusions()
{
BOARD_DESIGN_SETTINGS& bds = GetBoard()->GetDesignSettings();
for( MARKER_PCB* marker : GetBoard()->Markers() )
{
auto i = bds.m_DrcExclusions.find( marker->Serialize() );
if( i != bds.m_DrcExclusions.end() )
{
marker->SetExcluded( true );
bds.m_DrcExclusions.erase( i );
}
}
BOARD_COMMIT commit( this );
for( const wxString& exclusionData : bds.m_DrcExclusions )
{
MARKER_PCB* marker = MARKER_PCB::Deserialize( exclusionData );
if( marker )
{
marker->SetExcluded( true );
for( MARKER_PCB* marker : GetBoard()->ResolveDRCExclusions() )
commit.Add( marker );
}
}
bds.m_DrcExclusions.clear();
commit.Push( wxEmptyString, false, false );
}

View File

@ -139,6 +139,20 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
if( brd )
{
brd->SetProject( project );
// Move legacy view settings to local project settings
if( !brd->m_LegacyVisibleLayers.test( Rescue ) )
project->GetLocalSettings().m_VisibleLayers = loadedBoard->m_LegacyVisibleLayers;
if( !brd->m_LegacyVisibleItems.test( GAL_LAYER_INDEX( GAL_LAYER_ID_BITMASK_END ) ) )
project->GetLocalSettings().m_VisibleItems = loadedBoard->m_LegacyVisibleItems;
BOARD_DESIGN_SETTINGS& bds = brd->GetDesignSettings();
bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
for( MARKER_PCB* marker : brd->ResolveDRCExclusions() )
brd->Add( marker );
brd->BuildConnectivity();
brd->BuildListOfNets();
brd->SynchronizeNetsAndNetClasses();

View File

@ -58,7 +58,7 @@ ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) :
m_progressReporter( nullptr ),
m_maxError( ARC_HIGH_DEF )
{
// To enable add "DebugZoneFiller=true" to kicad_advanced settings file.
// To enable add "DebugZoneFiller=1" to kicad_advanced settings file.
m_debugZoneFiller = ADVANCED_CFG::GetCfg().m_DebugZoneFiller;
}