From 689072c0e1adb31399fdb2aeb92319e557d6ec82 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Fri, 29 Jan 2016 11:36:51 +0100 Subject: [PATCH] PCB updater: open PCBnew automagically, minor fixes to the dialog --- eeschema/menubar.cpp | 2 +- eeschema/schframe.cpp | 30 ++++++++++++++++++++++++++++ pcbnew/dialogs/dialog_update_pcb.cpp | 3 +++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/eeschema/menubar.cpp b/eeschema/menubar.cpp index 308f7c0bd8..88c865d349 100644 --- a/eeschema/menubar.cpp +++ b/eeschema/menubar.cpp @@ -431,7 +431,7 @@ void SCH_EDIT_FRAME::ReCreateMenuBar() wxMenuItem* updItem = AddMenuItem( toolsMenu, ID_UPDATE_PCB_FROM_SCH, - text, _( "Updates the PCB design with the current schematic." ), + text, _( "Updates the PCB design with the current schematic (forward annotation)." ), KiBitmap( libedit_xpm ) ); KIWAY_PLAYER* pcbFrame = Kiway().Player( FRAME_PCB, false ); // test open already. diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 81cf99ea80..535435f222 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -823,6 +823,36 @@ void SCH_EDIT_FRAME::OnErc( wxCommandEvent& event ) void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event ) { + wxFileName fn = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); + + fn.SetExt( PcbFileExtension ); + + if( Kiface().IsSingle() ) + { + DisplayError( this, _( "Cannot update the PCB, because the Schematic Editor is" + " opened in stand-alone mode. In order to create/update" + " PCBs from schematics, you need to launch Kicad shell" + " and create a PCB project." ) ); + return; + } else { + KIWAY_PLAYER* frame = Kiway().Player( FRAME_PCB, true ); + + // a pcb frame can be already existing, but not yet used. + // this is the case when running the footprint editor, or the footprint viewer first + // if the frame is not visible, the board is not yet loaded + if( !frame->IsVisible() ) + { + frame->OpenProjectFiles( std::vector( 1, fn.GetFullPath() ) ); + frame->Show( true ); + } + + // On Windows, Raise() does not bring the window on screen, when iconized + if( frame->IsIconized() ) + frame->Iconize( false ); + + frame->Raise(); + } + NETLIST_OBJECT_LIST* net_atoms = BuildNetListBase(); NETLIST_EXPORTER_KICAD exporter( net_atoms, Prj().SchLibs() ); STRING_FORMATTER formatter; diff --git a/pcbnew/dialogs/dialog_update_pcb.cpp b/pcbnew/dialogs/dialog_update_pcb.cpp index 2c17b51896..660e7101ed 100644 --- a/pcbnew/dialogs/dialog_update_pcb.cpp +++ b/pcbnew/dialogs/dialog_update_pcb.cpp @@ -104,6 +104,9 @@ void DIALOG_UPDATE_PCB::PerformUpdate( bool aDryRun ) m_frame->SetMsgPanel( board ); + m_btnPerformUpdate->Enable( false ); + m_btnPerformUpdate->SetLabel( _( "Update complete" ) ); + m_btnCancel->SetFocus(); } void DIALOG_UPDATE_PCB::OnMatchChange( wxCommandEvent& event )