common/single_top: allow to launch footprint editor from the command line (--frame switch)
This commit is contained in:
parent
dc7b743782
commit
bcde2a77e2
|
@ -239,19 +239,60 @@ bool PGM_SINGLE_TOP::OnPgmInit()
|
||||||
Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface );
|
Kiway.set_kiface( KIWAY::KifaceType( TOP_FRAME ), kiface );
|
||||||
#endif
|
#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.
|
// 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,
|
// "TOP_FRAME" is a macro that is passed on compiler command line from CMake,
|
||||||
// and is one of the types in FRAME_T.
|
// 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 );
|
Kiway.SetTop( frame );
|
||||||
|
|
||||||
App().SetTopWindow( frame ); // wxApp gets a face.
|
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
|
gerbview handles multiple project data files, i.e. gerber files on
|
||||||
|
@ -264,7 +305,7 @@ bool PGM_SINGLE_TOP::OnPgmInit()
|
||||||
|
|
||||||
std::vector<wxString> argSet;
|
std::vector<wxString> argSet;
|
||||||
|
|
||||||
for( int i=1; i<argc; ++i )
|
for( int i = args_offset; i < argc; ++i )
|
||||||
{
|
{
|
||||||
argSet.push_back( App().argv[i] );
|
argSet.push_back( App().argv[i] );
|
||||||
}
|
}
|
||||||
|
@ -272,7 +313,7 @@ bool PGM_SINGLE_TOP::OnPgmInit()
|
||||||
// special attention to the first argument: argv[1] (==argSet[0])
|
// special attention to the first argument: argv[1] (==argSet[0])
|
||||||
wxFileName argv1( argSet[0] );
|
wxFileName argv1( argSet[0] );
|
||||||
|
|
||||||
if( argc == 2 )
|
if( argc - args_offset > 1 )
|
||||||
{
|
{
|
||||||
#if defined(PGM_DATA_FILE_EXT)
|
#if defined(PGM_DATA_FILE_EXT)
|
||||||
// PGM_DATA_FILE_EXT, if present, may be different for each compile,
|
// PGM_DATA_FILE_EXT, if present, may be different for each compile,
|
||||||
|
|
|
@ -1008,3 +1008,21 @@ void FOOTPRINT_EDIT_FRAME::SetActiveLayer( PCB_LAYER_ID aLayer )
|
||||||
GetGalCanvas()->Refresh();
|
GetGalCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FOOTPRINT_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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;
|
||||||
|
}
|
||||||
|
|
|
@ -315,7 +315,8 @@ public:
|
||||||
* The import function can also read gpcb footprint file, in Newlib format
|
* The import function can also read gpcb footprint file, in Newlib format
|
||||||
* (One footprint per file, Newlib files have no special ext.)
|
* (One footprint per file, Newlib files have no special ext.)
|
||||||
*/
|
*/
|
||||||
MODULE* Import_Module();
|
MODULE* Import_Module( const wxString& aName = wxT("") );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SaveCurrentModule
|
* Function SaveCurrentModule
|
||||||
|
@ -467,6 +468,23 @@ public:
|
||||||
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
|
///> @copydoc EDA_DRAW_FRAME::UseGalCanvas()
|
||||||
virtual void UseGalCanvas( bool aEnable ) override;
|
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<wxString>& aFileSet, int aCtl = 0 ) override;
|
||||||
|
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
Loading…
Reference in New Issue