Eeschema/Pcbnew: Update PCB From Schematics tool: ensure the netlist is reliable: warn user if a component is not annotated before exporting the netlist to Pcbnew (like in netlist creation dialog).

This commit is contained in:
jean-pierre charras 2016-10-22 20:02:15 +02:00
parent 3bf1717002
commit 1840c3c4c7
3 changed files with 16 additions and 9 deletions

View File

@ -852,7 +852,9 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
" PCBs from schematics, you need to launch Kicad shell" " PCBs from schematics, you need to launch Kicad shell"
" and create a PCB project." ) ); " and create a PCB project." ) );
return; return;
} else { }
else
{
KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true ); KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true );
// a pcb frame can be already existing, but not yet used. // a pcb frame can be already existing, but not yet used.
@ -871,17 +873,22 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
frame->Raise(); frame->Raise();
} }
// Ensure the schematic is OK for a netlist creation
// (especially all components are annotated):
bool success = prepareForNetlist();
if( !success )
return;
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase(); NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchLibs() ); NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchLibs() );
STRING_FORMATTER formatter; STRING_FORMATTER formatter;
exporter.Format( &formatter, GNL_ALL ); exporter.Format( &formatter, GNL_ALL );
Kiway().ExpressMail( FRAME_PCB, // Now, send the "kicad" (s-expr) netlist to Pcbnew
MAIL_SCH_PCB_UPDATE, Kiway().ExpressMail( FRAME_PCB, MAIL_SCH_PCB_UPDATE,
formatter.GetString(), // an abbreviated "kicad" (s-expr) netlist formatter.GetString(), this );
this
);
} }
void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnCreateNetlist( wxCommandEvent& event )

View File

@ -614,7 +614,6 @@ bool BOARD_NETLIST_UPDATER::testConnectivity( NETLIST& aNetlist )
bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist ) bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
{ {
wxString msg; wxString msg;
m_errorCount = 0; m_errorCount = 0;
m_warningCount = 0; m_warningCount = 0;

View File

@ -1114,7 +1114,9 @@ void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
" PCBs from schematics, you need to launch Kicad shell" " PCBs from schematics, you need to launch Kicad shell"
" and create a PCB project." ) ); " and create a PCB project." ) );
return; return;
} else { }
else
{
KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true ); KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
wxFileName schfn = Prj().AbsolutePath( Prj().GetProjectName() ); wxFileName schfn = Prj().AbsolutePath( Prj().GetProjectName() );
@ -1127,6 +1129,5 @@ void PCB_EDIT_FRAME::OnUpdatePCBFromSch( wxCommandEvent& event )
} }
Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_PCB_UPDATE_REQUEST, "", this ); Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_PCB_UPDATE_REQUEST, "", this );
} }
} }