Eagle Schematic Import: Fix netlist mapping for zones and vias.
This commit is contained in:
parent
3d9c25494c
commit
9016344bb3
|
@ -403,6 +403,12 @@ public:
|
|||
*/
|
||||
void TestforSimilarLabels();
|
||||
|
||||
/**
|
||||
* Function ListNets
|
||||
* return a the list of net names.
|
||||
*/
|
||||
wxArrayString ListNets();
|
||||
|
||||
|
||||
#if defined(DEBUG)
|
||||
void DumpNetTable()
|
||||
|
|
|
@ -866,3 +866,29 @@ void NETLIST_OBJECT_LIST::setUnconnectedFlag()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxArrayString NETLIST_OBJECT_LIST::ListNets()
|
||||
{
|
||||
wxArrayString netNames;
|
||||
wxString netName;
|
||||
wxString ref;
|
||||
|
||||
int netCode;
|
||||
int lastNetCode = -1;
|
||||
int sameNetcodeCount = 0;
|
||||
|
||||
for( unsigned ii = 0; ii < size(); ii++ )
|
||||
{
|
||||
NETLIST_OBJECT* nitem = GetItem( ii );
|
||||
|
||||
// New net found, write net id;
|
||||
if( ( netCode = nitem->GetNet() ) != lastNetCode )
|
||||
{
|
||||
netName = nitem->GetNetName();
|
||||
netNames.Add( netName );
|
||||
lastNetCode = netCode;
|
||||
}
|
||||
}
|
||||
|
||||
return netNames;
|
||||
}
|
||||
|
|
|
@ -1520,3 +1520,12 @@ void SCH_EDIT_FRAME::SetIconScale( int aScale )
|
|||
Layout();
|
||||
SendSizeEvent();
|
||||
}
|
||||
|
||||
wxArrayString SCH_EDIT_FRAME::ListNets()
|
||||
{
|
||||
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
|
||||
|
||||
wxArrayString netnames = net_atoms->ListNets();
|
||||
|
||||
return netnames;
|
||||
}
|
||||
|
|
|
@ -577,6 +577,11 @@ public:
|
|||
unsigned aNetlistOptions,
|
||||
REPORTER* aReporter = NULL );
|
||||
|
||||
/**
|
||||
* Create a list of net names currently in the schematic.
|
||||
*/
|
||||
wxArrayString ListNets() override;
|
||||
|
||||
/**
|
||||
* Clear the current component annotation.
|
||||
*
|
||||
|
|
|
@ -192,6 +192,25 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rematch ophaned zones and vias to schematic nets.
|
||||
*/
|
||||
VTBL_ENTRY bool FixEagleNets()
|
||||
{
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a list of net names currently in use by the player .
|
||||
*/
|
||||
VTBL_ENTRY wxArrayString ListNets()
|
||||
{
|
||||
wxArrayString a;
|
||||
return a;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Function ShowModal
|
||||
* puts up this wxFrame as if it were a modal dialog, with all other instantiated
|
||||
|
|
|
@ -116,10 +116,8 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
wxFileName pcb( sch );
|
||||
wxFileName netlist( pro );
|
||||
pro.SetExt( ProjectFileExtension ); // enforce extension
|
||||
pcb.SetExt( LegacyPcbFileExtension ); // enforce extension
|
||||
netlist.SetExt( NetlistFileExtension );
|
||||
|
||||
if( !pro.IsAbsolute() )
|
||||
pro.MakeAbsolute();
|
||||
|
@ -199,6 +197,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
|
|||
// - second, perform schematic annotation and update footprint references
|
||||
pcbframe->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_PCB_UPDATE_REQUEST, "no-annotate;by-reference", this );
|
||||
pcbframe->Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_PCB_UPDATE_REQUEST, "quiet-annotate;by-timestamp", this );
|
||||
pcbframe->FixEagleNets();
|
||||
}
|
||||
|
||||
ReCreateTreePrj();
|
||||
|
|
|
@ -882,7 +882,7 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
|
|||
|
||||
if( !GetBoard()->GetFileName().IsEmpty() )
|
||||
{
|
||||
wxString tblName = Prj().FootprintLibTblName();
|
||||
wxString tblName = Prj().FootprintLibTblName();
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -891,15 +891,14 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
|
|||
catch( const IO_ERROR& ioe )
|
||||
{
|
||||
wxString msg = wxString::Format( _(
|
||||
"Error occurred saving project specific footprint library "
|
||||
"table:\n\n%s" ),
|
||||
GetChars( ioe.What() )
|
||||
);
|
||||
"Error occurred saving project specific footprint library "
|
||||
"table:\n\n%s" ),
|
||||
GetChars( ioe.What() )
|
||||
);
|
||||
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -911,3 +910,58 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::FixEagleNets()
|
||||
{
|
||||
KIWAY_PLAYER* schematicFrame = Kiway().Player( FRAME_SCH, false );
|
||||
|
||||
// if the schematic file was also loaded. Fix any instances of ophaned zones and vias.
|
||||
if( schematicFrame )
|
||||
{
|
||||
// Get list of nets from schematic.
|
||||
wxArrayString nets = schematicFrame->ListNets();
|
||||
|
||||
// perform netlist matching to prevent ophaned zones.
|
||||
for( auto zone : GetBoard()->Zones() )
|
||||
{
|
||||
wxString zoneNet = zone->GetNet()->GetNetname();
|
||||
wxString localNet = "/" + zoneNet;
|
||||
|
||||
for( int i = 0; i < nets.GetCount(); i++ )
|
||||
{
|
||||
if( nets[i].EndsWith( localNet ) )
|
||||
{
|
||||
NETINFO_ITEM* net = GetBoard()->FindNet( nets[i] );
|
||||
|
||||
if( net )
|
||||
{
|
||||
zone->SetNetCode( net->GetNet() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// perform netlist matching to prevent ophaned tracks/vias.
|
||||
for( auto track : GetBoard()->Tracks() )
|
||||
{
|
||||
wxString trackNet = track->GetNet()->GetNetname();
|
||||
wxString localNet = "/" + trackNet;
|
||||
|
||||
for( int i = 0; i < nets.GetCount(); i++ )
|
||||
{
|
||||
if( nets[i].EndsWith( localNet ) )
|
||||
{
|
||||
NETINFO_ITEM* net = GetBoard()->FindNet( nets[i] );
|
||||
|
||||
if( net )
|
||||
{
|
||||
track->SetNetCode( net->GetNet() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -877,6 +877,11 @@ public:
|
|||
*/
|
||||
bool ImportFile( const wxString& aFileName, int aFileType ) override;
|
||||
|
||||
/**
|
||||
* Rematch ophaned zones and vias to schematic nets.
|
||||
*/
|
||||
bool FixEagleNets() override;
|
||||
|
||||
/**
|
||||
* Function SavePcbFile
|
||||
* writes the board data structures to \a a aFileName
|
||||
|
|
Loading…
Reference in New Issue