Options for board update KiWay request (MAIL_SCH_UPDATE[_REQUEST])

Board update KiWay request may now contain options in the message
payload:
- "no-annotate": do not enforce annotation
- "quiet-annotate": annotate without displaying a dialog
- "by-reference": update netlist by reference, no dialog displayed
- "by-timestamp": update netlist by timestamp, no dialog displayed
This commit is contained in:
Maciej Suminski 2018-02-16 19:26:11 +01:00
parent b356275e76
commit 43523a6179
4 changed files with 64 additions and 13 deletions

View File

@ -234,9 +234,7 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
case MAIL_SCH_PCB_UPDATE_REQUEST:
{
wxCommandEvent dummy;
OnUpdatePCB( dummy );
doUpdatePcb( payload );
break;
}

View File

@ -846,6 +846,12 @@ void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event )
void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
{
doUpdatePcb( "" );
}
void SCH_EDIT_FRAME::doUpdatePcb( const wxString& aUpdateOptions )
{
wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() );
@ -879,12 +885,22 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
frame->Raise();
}
if( aUpdateOptions.Contains( "quiet-annotate" ) )
{
SCH_SCREENS schematic;
schematic.UpdateSymbolLinks();
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols();
AnnotateComponents( true, UNSORTED, INCREMENTAL_BY_REF, false, false, true );
}
if( !aUpdateOptions.Contains( "no-annotate" ) )
{
// Ensure the schematic is OK for a netlist creation
// (especially all components are annotated):
bool success = prepareForNetlist();
if( !success )
if( !prepareForNetlist() )
return;
}
NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase();
NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchSymbolLibTable() );
@ -894,7 +910,7 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
// Now, send the "kicad" (s-expr) netlist to Pcbnew
Kiway().ExpressMail( FRAME_PCB, MAIL_SCH_PCB_UPDATE,
formatter.GetString(), this );
wxString::Format("%s\n%s", aUpdateOptions, formatter.GetString() ).ToStdString(), this );
}

View File

@ -1483,6 +1483,16 @@ public:
wxString GetNetListerCommand() const { return m_netListerCommand; }
/**
* Updates netlist and sends it to pcbnew.
* @param aUpdateOptions is a string defining update options:
* - "no-annotate" does not perform schematic annotation
* - "quiet-annotate" performs schematic annotation without showing annotation dialog
* aUpdateOptions may also contain other options accepted for netlist reader.
* @see PCB_EDIT_FRAME::KiwayMailIn()
*/
void doUpdatePcb( const wxString& aUpdateOptions = "" );
int GetIconScale() override;
void SetIconScale( int aScale ) override;

View File

@ -26,6 +26,7 @@
#include <collectors.h>
#include <pcbnew.h>
#include <board_netlist_updater.h>
#include <netlist_reader.h>
#include <pcb_netlist.h>
#include <dialogs/dialog_update_pcb.h>
@ -364,10 +365,21 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
case MAIL_SCH_PCB_UPDATE:
{
NETLIST netlist;
size_t split = payload.find( '\n' );
wxCHECK( split != std::string::npos, /*void*/ );
// Extract options and netlist
std::string options = payload.substr( 0, split );
std::string netlistData = payload.substr( split + 1 );
// Quiet update options
bool by_reference = options.find( "by-reference" ) != std::string::npos;
bool by_timestamp = options.find( "by-timestamp" ) != std::string::npos;
wxASSERT( !( by_reference && by_timestamp ) ); // only one at a time please
try
{
STRING_LINE_READER* lineReader = new STRING_LINE_READER( payload, _( "EEschema netlist" ) );
STRING_LINE_READER* lineReader = new STRING_LINE_READER( netlistData, _( "EEschema netlist" ) );
KICAD_NETLIST_READER netlistReader( lineReader, &netlist );
netlistReader.LoadNetlist();
}
@ -376,10 +388,25 @@ void PCB_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
assert( false ); // should never happen
}
DIALOG_UPDATE_PCB updateDialog( this, &netlist );
if( by_reference || by_timestamp )
{
netlist.SetDeleteExtraFootprints( false );
netlist.SetFindByTimeStamp( by_timestamp );
netlist.SetReplaceFootprints( true );
BOARD_NETLIST_UPDATER updater( this, GetBoard() );
updater.SetLookupByTimestamp( by_timestamp );
updater.SetDeleteUnusedComponents( false );
updater.SetReplaceFootprints( true );
updater.SetDeleteSinglePadNets( false );
updater.UpdateNetlist( netlist );
}
else
{
DIALOG_UPDATE_PCB updateDialog( this, &netlist );
updateDialog.PerformUpdate( true );
updateDialog.ShowModal();
}
break;
}