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

This commit is contained in:
Dick Hollenbeck 2014-04-04 09:57:26 -05:00
parent ede0464cbd
commit 6beacd6e95
4 changed files with 54 additions and 21 deletions

View File

@ -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.
// 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
// 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
// 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...
@ -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.
// Remember its in the *.kiface DSO.
#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(
NULL, TOP_FRAME, &kiway, KFCTL_STANDALONE ) );
#else
@ -375,9 +376,9 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
if( argc == 2 )
{
#if defined(PGM_DATA_FILE_EXT)
// PGM_DATA_FILE_EXT is different for each compile, it may come
// from CMake on the compiler command line, often does not.
// This facillity is mostly useful only for those program modules
// PGM_DATA_FILE_EXT, if present, may be different for each compile,
// it may come from CMake on the compiler command line, but often does not.
// This facillity is mostly useful for those program modules
// supporting a single argv[1].
if( !argv1.GetExt() )
argv1.SetExt( wxT( PGM_DATA_FILE_EXT ) );
@ -413,11 +414,13 @@ bool PGM_SINGLE_TOP::OnPgmInit( wxApp* aWxApp )
}
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.
So this looks like a dead concept here, or an expensive one in terms
of code size.
/*
The lean single_top program launcher has no access to program
settings, for if it did, 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. So this looks like a dead concept here,
or an expensive one in terms of code size.
wxString dir;
@ -455,8 +458,8 @@ void PGM_SINGLE_TOP::MacOpenFile( const wxString& aFileName )
if( filename.FileExists() )
{
#if 0
// this pulls in EDA_DRAW_FRAME type info, which we don't want in single_top
// link image.
// 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*>( App().GetTopWindow() );
#else
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();

View File

@ -248,7 +248,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SCH_SCREEN* screen;
wxString fullFileName( aFileSet[0] );
wxString msg;
bool libCacheExist = false;
SCH_SCREENS screenList;
for( screen = screenList.GetFirst(); screen != NULL; screen = screenList.GetNext() )
@ -384,9 +383,12 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
}
// load the project.
libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
bool libCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() );
g_RootSheet->SetScreen( NULL );
bool diag = g_RootSheet->Load( this );
SetScreen( m_CurrentSheet->LastScreen() );
UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() );
@ -397,6 +399,9 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetSheetNumberAndCount();
m_canvas->Refresh( true );
(void) libCacheExist;
(void) diag;
// return diag;
return true; // do not close Eeschema if the file if not found:
// we may have to create a new schematic file.

View File

@ -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( dynamic_cast<const PCB_EDIT_FRAME*>( aParent ) );
wxASSERT( 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(
GetFootprintViewerFrameName(), aParent );
@ -424,7 +445,7 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& event )
{
GetBoard()->Add( loadFootprint( id ) );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxString msg;
msg.Printf( _( "Could not load footprint \"%s\" from library \"%s\".\n\n"

View File

@ -74,10 +74,14 @@ public:
/**
* 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; }
const wxString GetSelectedLibraryFullName();