Commit 6beacd6e authored by Dick Hollenbeck's avatar Dick Hollenbeck

Rework FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer(), fix up comments and warnings.

parent ede0464c
...@@ -164,7 +164,7 @@ static const wxString dso_full_path( const wxString& aAbsoluteArgv0 ) ...@@ -164,7 +164,7 @@ static const wxString dso_full_path( const wxString& aAbsoluteArgv0 )
// in them. They are basically spin-offs from what was once a top process module. // in them. They are basically spin-offs from what was once a top process module.
// That may not make linux package maintainers happy, but that is not my job. // That may not make linux package maintainers happy, but that is not my job.
// Get over it. KiCad is not a trivial suite, and multiple platforms come // Get over it. KiCad is not a trivial suite, and multiple platforms come
// into play, not merely linux. For starters they will use extension ".kicad", // into play, not merely linux. For starters they will use extension ".kiface",
// but later in time morph to ".so". They are not purely libraries, else they // but later in time morph to ".so". They are not purely libraries, else they
// would begin with "lib" in basename. Like I said, get over it, we're serving // would begin with "lib" in basename. Like I said, get over it, we're serving
// too many masters here: python, windows, linux, OSX, multiple versions of wx... // too many masters here: python, windows, linux, OSX, multiple versions of wx...
...@@ -338,7 +338,8 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -338,7 +338,8 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
// KIFACE::CreateWindow() is a virtual so we don't need to link to it. // KIFACE::CreateWindow() is a virtual so we don't need to link to it.
// Remember its in the *.kiface DSO. // Remember its in the *.kiface DSO.
#if 0 #if 0
// this pulls in EDA_DRAW_FRAME type info, which we don't want in single_top // this pulls in EDA_DRAW_FRAME type info, which we don't want in
// the single_top link image.
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( kiface->CreateWindow( KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( kiface->CreateWindow(
NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ) ); NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ) );
#else #else
...@@ -375,9 +376,9 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -375,9 +376,9 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
if( argc == 2 ) if( argc == 2 )
{ {
#if defined(PGM_DATA_FILE_EXT) #if defined(PGM_DATA_FILE_EXT)
// PGM_DATA_FILE_EXT is different for each compile, it may come // PGM_DATA_FILE_EXT, if present, may be different for each compile,
// from CMake on the compiler command line, often does not. // it may come from CMake on the compiler command line, but often does not.
// This facillity is mostly useful only for those program modules // This facillity is mostly useful for those program modules
// supporting a single argv[1]. // supporting a single argv[1].
if( !argv1.GetExt() ) if( !argv1.GetExt() )
argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) ); argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
...@@ -413,11 +414,13 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp ) ...@@ -413,11 +414,13 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
} }
else else
{ {
/* The lean single_top program launcher has no access program settings, /*
else it would not be lean. That kind of functionality is in the
KIFACE now, but it cannot assume that it is the only KIFACE in memory. The lean single_top program launcher has no access to program
So this looks like a dead concept here, or an expensive one in terms settings, for if it did, it would not be lean. That kind of
of code size. functionality is in the KIFACE now, but it cannot assume that it is
the only KIFACE in memory. So this looks like a dead concept here,
or an expensive one in terms of code size.
wxString dir; wxString dir;
...@@ -455,8 +458,8 @@ void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName ) ...@@ -455,8 +458,8 @@ void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName )
if( filename.FileExists() ) if( filename.FileExists() )
{ {
#if 0 #if 0
// this pulls in EDA_DRAW_FRAME type info, which we don't want in single_top // this pulls in EDA_DRAW_FRAME type info, which we don't want in
// link image. // the single_top link image.
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() ); KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
#else #else
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow(); KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
......
...@@ -248,7 +248,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in ...@@ -248,7 +248,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SCH_SCREEN* screen; SCH_SCREEN* screen;
wxString fullFileName( aFileSet[0] ); wxString fullFileName( aFileSet[0] );
wxString msg; wxString msg;
bool libCacheExist = false;
SCH_SCREENS screenList; SCH_SCREENS screenList;
for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() ) for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
...@@ -384,9 +383,12 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in ...@@ -384,9 +383,12 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
} }
// load the project. // load the project.
libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() ); bool libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
g_RootSheet->SetScreen( NULL ); g_RootSheet->SetScreen( NULL );
bool diag = g_RootSheet->Load( this ); bool diag = g_RootSheet->Load( this );
SetScreen( m_CurrentSheet->LastScreen() ); SetScreen( m_CurrentSheet->LastScreen() );
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() ); UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
...@@ -397,6 +399,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in ...@@ -397,6 +399,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetSheetNumberAndCount(); SetSheetNumberAndCount();
m_canvas->Refresh( true ); m_canvas->Refresh( true );
(void) libCacheExist;
(void) diag;
// return diag; // return diag;
return true; // do not close Eeschema if the file if not found: return true; // do not close Eeschema if the file if not found:
// we may have to create a new schematic file. // we may have to create a new schematic file.
......
...@@ -271,10 +271,31 @@ const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName() ...@@ -271,10 +271,31 @@ const wxChar* FOOTPRINT_VIEWER_FRAME::GetFootprintViewerFrameName()
} }
FOOTPRINT_VIEWER_FRAME* FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer( const wxWindow* aParent ) FOOTPRINT_VIEWER_FRAME* FOOTPRINT_VIEWER_FRAME::GetActiveFootprintViewer( const KIWAY_PLAYER* aParent )
{ {
// top_of_project! wxASSERT( aParent );
wxASSERT( dynamic_cast<const PCB_EDIT_FRAME*>( aParent ) );
// We search only within the current project, and do so by limiting
// the search scope to a wxWindow hierarchy subset. Find the top most
// KIWAY_PLAYER which is part of this PROJECT by matching its KIWAY* to the
// most immediate parent's.
// NOTE: an open FOOTPRINT_VIEWER_FRAME may have either the PCB_EDIT_FRAME
// or the FOOTPRINT_EDIT_FRAME.
KIWAY* kiway = &aParent->Kiway();
wxWindow* frame;
while( (frame = aParent->GetParent()) != NULL )
{
// will go NULL when we reach a non-KIWAY_PLAYER
KIWAY_PLAYER* kwp = dynamic_cast<KIWAY_PLAYER*>( frame );
if( kwp && &kwp->Kiway() == kiway )
aParent = kwp;
else
break;
}
return (FOOTPRINT_VIEWER_FRAME*) wxWindow::FindWindowByName( return (FOOTPRINT_VIEWER_FRAME*) wxWindow::FindWindowByName(
GetFootprintViewerFrameName(), aParent ); GetFootprintViewerFrameName(), aParent );
...@@ -424,7 +445,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event ) ...@@ -424,7 +445,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
{ {
GetBoard()->Add( loadFootprint( id ) ); GetBoard()->Add( loadFootprint( id ) );
} }
catch( IO_ERROR ioe ) catch( const IO_ERROR& ioe )
{ {
wxString msg; wxString msg;
msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n" msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n"
......
...@@ -74,10 +74,14 @@ public: ...@@ -74,10 +74,14 @@ public:
/** /**
* Function GetActiveFootprintViewer (static) * Function GetActiveFootprintViewer (static)
* @return a reference to the current opened Footprint viewer *
* or NULL if no Footprint viewer currently opened * @param aParent the KIWAY_PLAYER which is the parent of the calling wxWindow.
* This is used to traverse the window hierarchy upwards to the topmost
* KIWAY_PLAYER which is still part of the same project.
*
* @return Any currently opened Footprint viewer or NULL if none.
*/ */
static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer( const wxWindow* aParent ); static FOOTPRINT_VIEWER_FRAME* GetActiveFootprintViewer( const KIWAY_PLAYER* aParent );
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; } wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
const wxString GetSelectedLibraryFullName(); const wxString GetSelectedLibraryFullName();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment