diff --git a/common/single_top.cpp b/common/single_top.cpp index c9bd80625b..4370829f0e 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -239,19 +239,60 @@ bool PGM_SINGLE_TOP::OnPgmInit() Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface ); #endif + // Open project or file specified on the command line: + int argc = App().argc; + + int args_offset = 1; + + FRAME_T appType = TOP_FRAME; + + const struct + { + wxString name; + FRAME_T type; + } frameTypes[] = { + { wxT( "pcb" ), FRAME_PCB }, + { wxT( "fpedit" ), FRAME_PCB_MODULE_EDITOR }, + { wxT( "" ), FRAME_T_COUNT } + }; + + if( argc > 2 ) + { + if( App().argv[1] == "--frame" ) + { + wxString appName = App().argv[2]; + appType = FRAME_T_COUNT; + + for( int i = 0; frameTypes[i].type != FRAME_T_COUNT; i++ ) + { + const auto& frame = frameTypes[i]; + if(frame.name == appName) + { + appType = frame.type; + } + } + args_offset += 2; + + if( appType == FRAME_T_COUNT ) + { + wxLogError( wxT( "Unknown frame: %s" ), appName ); + return false; + } + } + } + + // Use KIWAY to create a top window, which registers its existence also. // "TOP_FRAME" is a macro that is passed on compiler command line from CMake, // and is one of the types in FRAME_T. - KIWAY_PLAYER* frame = Kiway.Player( TOP_FRAME, true ); + KIWAY_PLAYER* frame = Kiway.Player( appType, true ); Kiway.SetTop( frame ); App().SetTopWindow( frame ); // wxApp gets a face. - // Open project or file specified on the command line: - int argc = App().argc; - if( argc > 1 ) + if( argc > args_offset ) { /* gerbview handles multiple project data files, i.e. gerber files on @@ -264,7 +305,7 @@ bool PGM_SINGLE_TOP::OnPgmInit() std::vector argSet; - for( int i=1; i 1 ) { #if defined(PGM_DATA_FILE_EXT) // PGM_DATA_FILE_EXT, if present, may be different for each compile, diff --git a/pcbnew/modedit.cpp b/pcbnew/modedit.cpp index 207d30309c..f637862ebf 100644 --- a/pcbnew/modedit.cpp +++ b/pcbnew/modedit.cpp @@ -1008,3 +1008,21 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer ) GetGalCanvas()->Refresh(); } } + +bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, int aCtl ) +{ + if( ! Clear_Pcb( true ) ) + return false; // //this command is aborted + + SetCrossHairPosition( wxPoint( 0, 0 ) ); + Import_Module( aFileSet[0] ); + + if( GetBoard()->m_Modules ) + GetBoard()->m_Modules->ClearFlags(); + + GetScreen()->ClrModify(); + Zoom_Automatique( false ); + m_canvas->Refresh(); + + return true; +} diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 1b4d49061a..741a1465dd 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -315,7 +315,8 @@ public: * The import function can also read gpcb footprint file, in Newlib format * (One footprint per file, Newlib files have no special ext.) */ - MODULE* Import_Module(); + MODULE* Import_Module( const wxString& aName = wxT("") ); + /** * Function SaveCurrentModule @@ -467,6 +468,23 @@ public: ///> @copydoc EDA_DRAW_FRAME::UseGalCanvas() virtual void UseGalCanvas( bool aEnable ) override; + /** + * Function OpenProjectFiles (was LoadOnePcbFile) + * loads a KiCad board (.kicad_pcb) from \a aFileName. + * + * @param aFileSet - hold the BOARD file to load, a vector of one element. + * + * @param aCtl - KICTL_ bits, one to indicate that an append of the board file + * aFileName to the currently loaded file is desired. + * @see #KIWAY_PLAYER for bit defines. + * + * @return bool - false if file load fails, otherwise true. + bool LoadOnePcbFile( const wxString& aFileName, bool aAppend = false, + bool aForceFileDialog = false ); + */ + bool OpenProjectFiles( const std::vector& aFileSet, int aCtl = 0 ) override; + + DECLARE_EVENT_TABLE() protected: