Commit cf86e18f authored by Wayne Stambaugh's avatar Wayne Stambaugh

Footprint library table work, minor fixes, and code cleaning.

* Fix a bug when full file name and path are passed to FOOTPRINT_INFO::
  ReadFootprintFiles() which I created in bug fix lp:593989.
* Fix a wxString debug assertion in EDA_APP::InitEDA_Appl() when the KICAD
  environment variable is defined as an empty string.
* Add error dialog when libraries cannot be found in system search path
  when loading footprint using the select footprint dialog.
* Add footprint library name column to the EDA_LIST_DIALOG when selecting
  footprints from the list.
* Allow reading all columns from the selected row in EDA_LIST_DIALOG.
* Remove redundant sort from EDA_LIST_DIALOG constructor
* Add library name member variable and accessors to FOOTPRINT_INFO.
* Make headers translatable for Eeschema select component from list dialog.
* Add some helper methods to FPID for identifying the FPID type and validity.
* Remove a bunch of trailing whitespace and add missing license comments.
parent 2e6969fe
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file displlst.cpp
*/
......@@ -25,23 +49,22 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
column.SetId( i );
column.SetText( aItemHeaders.Item( i ) );
column.SetWidth( 300 / aItemHeaders.Count() );
EDA_LIST_DIALOG_BASE::m_listBox->InsertColumn( i, column );
m_listBox->InsertColumn( i, column );
}
InsertItems( aItemList, 0 );
if( m_sortList )
sortList();
if( !aRefText.IsEmpty() ) // try to select the item matching aRefText
{
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
{
if( aItemList[ii][0] == aRefText )
{
m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
break;
}
}
}
if( m_callBackFct == NULL )
{
......@@ -85,12 +108,25 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
sortList();
}
wxString EDA_LIST_DIALOG::GetTextSelection()
wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
{
wxCHECK_MSG( aColumn < m_listBox->GetColumnCount(), wxEmptyString,
wxT( "Invalid list control column." ) );
wxListItem info;
wxString text;
long item = -1;
item = m_listBox->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
wxString text = m_listBox->GetItemText( item );
return text;
info.m_mask = wxLIST_MASK_TEXT;
info.m_itemId = item;
info.m_col = aColumn;
if( !m_listBox->GetItem( info ) )
return wxEmptyString;
return info.m_text;
}
......@@ -107,18 +143,26 @@ void EDA_LIST_DIALOG::Append( const wxArrayString& itemList )
}
}
void EDA_LIST_DIALOG::InsertItems( const std::vector<wxArrayString>& itemList,
int position )
void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList, int position )
{
for( unsigned i = 0; i < itemList.size(); i++ )
for( unsigned row = 0; row < itemList.size(); row++ )
{
long itemIndex = m_listBox->InsertItem( position+i, itemList[i].Item( 0 ) );
m_listBox->SetItemData( itemIndex, (long) &( itemList[i].Item( 0 ) ) );
wxASSERT( (int) itemList[row].GetCount() == m_listBox->GetColumnCount() );
// Adding the next columns content
for( unsigned j = 1; j < itemList[i].GetCount(); j++ )
for( unsigned col = 0; col < itemList[row].GetCount(); col++ )
{
long itemIndex;
if( col == 0 )
{
itemIndex = m_listBox->InsertItem( row+position, itemList[row].Item( col ) );
m_listBox->SetItemData( itemIndex, (long) &itemList[row].Item( col ) );
}
else
{
m_listBox->SetItem( itemIndex, j, itemList[i].Item( j ) );
m_listBox->SetItem( itemIndex, col, itemList[row].Item( col ) );
}
}
}
......@@ -174,6 +218,7 @@ static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortDat
return StrNumCmp( *component1Name, *component2Name, INT_MAX, true );
}
void EDA_LIST_DIALOG::sortList()
{
m_listBox->SortItems( MyCompareFunction, 0 );
......
......@@ -326,7 +326,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
{
m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( m_KicadEnv.Last() != '/' )
if( !m_KicadEnv.IsEmpty() && m_KicadEnv.Last() != '/' )
m_KicadEnv += UNIX_STRING_DIR_SEP;
}
......
......@@ -48,20 +48,6 @@
#include <wildcards_and_files_ext.h>
/* Read the list of libraries (*.mod files)
* for each module are stored
* the module name
* documentation string
* associated keywords
* lib name
* Module description format:
* $MODULE c64acmd First line of module description
* Li c64acmd DIN connector Library reference
* Cd Europe 96 AC male vertical documentation string
* Kw PAD_CONN DIN associated keywords
* ...... other data (pads, outlines ..)
* $Endmodule
*/
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
{
// Clear data before reading files
......@@ -76,12 +62,17 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
// Parse Libraries Listed
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
{
wxFileName filename( wxEmptyString, aFootprintsLibNames[ii],
LegacyFootprintLibPathExtension );
// File names can be fully qualified or file name only.
wxFileName filename = aFootprintsLibNames[ii];
wxString libPath = wxGetApp().FindLibraryPath( filename );
if( !filename.IsAbsolute() )
{
filename = wxFileName( wxEmptyString, aFootprintsLibNames[ii],
LegacyFootprintLibPathExtension );
filename = wxGetApp().FindLibraryPath( filename );
}
if( !libPath )
if( !filename.FileExists() )
{
m_filesNotFound << filename.GetFullName() << wxT( "\n" );
continue;
......@@ -89,19 +80,21 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
try
{
wxArrayString fpnames = pi->FootprintEnumerate( libPath );
wxArrayString fpnames = pi->FootprintEnumerate( filename.GetFullPath() );
for( unsigned i=0; i<fpnames.GetCount(); ++i )
{
std::auto_ptr<MODULE> m( pi->FootprintLoad( libPath, fpnames[i] ) );
std::auto_ptr<MODULE> m( pi->FootprintLoad( filename.GetFullPath(),
fpnames[i] ) );
// we're loading what we enumerated, all must be there.
wxASSERT( m.get() );
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
fpinfo->SetLibraryName( filename.GetName() );
fpinfo->SetLibraryPath( filename.GetFullPath() );
fpinfo->m_Module = fpnames[i];
fpinfo->m_LibName = libPath;
fpinfo->m_padCount = m->GetPadCount();
fpinfo->m_KeyWord = m->GetKeywords();
fpinfo->m_Doc = m->GetDescription();
......@@ -111,7 +104,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
}
catch( IO_ERROR ioe )
{
m_filesInvalid << ioe.errorText << wxT("\n");
m_filesInvalid << ioe.errorText << wxT( "\n" );
}
}
}
......
......@@ -533,9 +533,10 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
const wxChar *libname;
if( module_info )
libname = GetChars( module_info->m_LibName );
libname = GetChars( module_info->GetLibraryPath() );
else
libname = GetChars( wxT( "???" ) );
msg.Printf( _( "Lib: %s" ), libname );
SetStatusText( msg, 0 );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file database.cpp
*/
......@@ -16,6 +40,7 @@
extern void DisplayCmpDocAndKeywords( wxString& Name );
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
// to display keywords and description of a component
void DisplayCmpDocAndKeywords( wxString& Name )
......@@ -31,6 +56,7 @@ void DisplayCmpDocAndKeywords( wxString& Name )
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
}
/*
* Displays a list of filtered components found in libraries for selection,
* Keys is a list of keywords to filter components which do not match these keywords
......@@ -88,8 +114,8 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
}
wxArrayString headers;
headers.Add( wxT("Component") );
headers.Add( wxT("Library") );
headers.Add( _( "Component" ) );
headers.Add( _( "Library" ) );
// Show candidate list:
wxString cmpname;
......
......@@ -78,7 +78,15 @@ public:
void Append( const wxArrayString& aItemStr );
void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
wxString GetTextSelection();
/**
* Function GetTextSelection
* return the selected text from \a aColumn in the wxListCtrl in the dialog.
*
* @param aColumn is the column to return the text from.
* @return a wxString object containing the selected text from \a aColumn.
*/
wxString GetTextSelection( int aColumn = 0 );
private:
void onClose( wxCloseEvent& event );
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2011 Jean-Pierre Charras, <jp.charras@wanadoo.fr>
* Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* @file footprint_info.h
*/
......@@ -12,14 +36,16 @@
/*
* Class FOOTPRINT_INFO
* is a helper class to handle the list of footprints
* available in libraries. It stores footprint names, doc and keywords
* is a helper class to handle the list of footprints available in libraries. It stores
* footprint names, doc and keywords
*/
class FOOTPRINT_INFO
{
wxString m_libName; ///< Name of the library containing this module excluding path and ext.
wxString m_libPath; ///< The full library name and path associated the footprint.
public:
wxString m_Module; ///< Module name.
wxString m_LibName; ///< Name of the library containing this module.
int m_Num; ///< Order number in the display list.
wxString m_Doc; ///< Footprint description.
wxString m_KeyWord; ///< Footprint key words.
......@@ -30,6 +56,14 @@ public:
m_Num = 0;
m_padCount = 0;
}
const wxString& GetFootprintName() const { return m_Module; }
void SetLibraryName( const wxString& aLibName ) { m_libName = aLibName; }
const wxString& GetLibraryName() const { return m_libName; }
void SetLibraryPath( const wxString& aLibPath ) { m_libPath = aLibPath; }
const wxString& GetLibraryPath() const { return m_libPath; }
};
......@@ -85,7 +119,7 @@ public:
/**
* Function ReadFootprintFiles
* Read the list of libraries (*.mod files) and populates m_List ( list of availaible
* Read the list of libraries (*.mod files) and populates m_List ( list of available
* modules in libs ).
* for each module, are stored
* the module name
......
......@@ -365,6 +365,12 @@ public:
*/
static const wxString ExpandSubtitutions( const wxString aString );
/**
* Function IsEmpty
* @return true if the footprint library table is empty.
*/
bool IsEmpty() const { return rows.empty(); }
protected:
/**
......
......@@ -133,6 +133,25 @@ public:
const std::string& aRevision )
throw( PARSE_ERROR );
/**
* Function IsValid
* @return true is the #FPID is valid.
*
* A valid #FPID must have both the footprint library nickname and the footprint name
* defined. The revision field is optional.
*
* @note A return value of true does not indicated that the #FPID is a valid #FP_LIB_TABLE
* entry.
*/
bool IsValid() const { return !nickname.empty() && !footprint.empty(); }
/**
* Function IsLegacy
* @return true if the #FPID only has the #footprint name defined.
*/
bool IsLegacy() const { return nickname.empty() && !footprint.empty() && revision.empty(); }
/**
* Function clear
* clears the contents of the library nickname, footprint name, and revision strings.
......
......@@ -432,7 +432,7 @@ public:
bool aDisplayError );
/**
* Function Select_1_Module_From_List
* Function SelectFootprint
* Display a list of modules found in active libraries or a given library
* @param aWindow = the current window ( parent window )
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename
......@@ -445,7 +445,7 @@ public:
*
* @return wxEmptyString if abort or fails, or the selected module name if Ok
*/
wxString Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
wxString SelectFootprint( EDA_DRAW_FRAME* aWindow,
const wxString& aLibraryFullFilename,
const wxString& aMask,
const wxString& aKeyWord );
......
......@@ -464,7 +464,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
{
wxString libPath = getLibPath();
wxString footprintName = Select_1_Module_From_List( this, libPath,
wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath,
wxEmptyString, wxEmptyString );
if( !footprintName )
......
This diff is collapsed.
......@@ -285,12 +285,12 @@ public:
bool Load_Module_From_BOARD( MODULE* Module );
/**
* Function Select_1_Module_From_BOARD
* Function SelectFootprint
* Display the list of modules currently existing on the BOARD
* @return a pointer to a module if this module is selected or NULL otherwise
* @param aPcb = the board from modules can be loaded
*/
MODULE* Select_1_Module_From_BOARD( BOARD* aPcb );
MODULE* SelectFootprint( BOARD* aPcb );
// functions to edit footprint edges
......
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2012 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file viewlibs.cpp
* @file modview.cpp
*/
#include <fctsys.h>
......@@ -85,7 +109,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
return;
wxArrayString headers;
headers.Add( wxT("Library") );
headers.Add( wxT( "Library" ) );
std::vector<wxArrayString> itemsToDisplay;
// Conversion from wxArrayString to vector of ArrayString
......@@ -95,6 +119,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
item.Add( g_LibraryNames[i] );
itemsToDisplay.push_back( item );
}
EDA_LIST_DIALOG dlg( this, _( "Select Current Library:" ),
headers, itemsToDisplay, m_libraryName );
......@@ -110,35 +135,35 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
ReCreateFootprintList();
int id = m_LibList->FindString( m_libraryName );
if( id >= 0 )
m_LibList->SetSelection( id );
}
/**
* Function SelectCurrentFootprint
* Selects the current footprint name and display it
*/
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
{
wxString libname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
wxString libname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
MODULE* oldmodule = GetBoard()->m_Modules;
MODULE * module = Load_Module_From_Library( libname, false );
if( module )
{
module->SetPosition( wxPoint( 0, 0 ) );
// Only one fotprint allowed: remove the previous footprint (if exists)
// Only one footprint allowed: remove the previous footprint (if exists)
if( oldmodule )
{
GetBoard()->Remove( oldmodule );
delete oldmodule;
}
m_footprintName = module->GetLibRef();
module->ClearFlags();
SetCurItem( NULL );
Zoom_Automatique( false );
m_canvas->Refresh( );
m_canvas->Refresh();
Update3D_Frame();
m_FootprintList->SetStringSelection( m_footprintName );
}
......@@ -147,7 +172,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
{
wxString fullname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
wxString fullname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
return fullname;
}
......@@ -188,11 +213,6 @@ void FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint( int aMode )
}
/**
* Function RedrawActiveWindow
* Display the current selected component.
* If the component is an alias, the ROOT component is displayed
*/
void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
{
if( !GetBoard() )
......
......@@ -58,7 +58,7 @@ private:
wxString m_configPath; // subpath for configuration
protected:
static wxString m_libraryName; // Current selected libary
static wxString m_libraryName; // Current selected library
static wxString m_footprintName; // Current selected footprint
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
// the selected footprint is here
......@@ -86,7 +86,14 @@ public:
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
const wxString GetSelectedLibraryFullName( void );
/**
* Function GetSelectedLibrary
* @return the selected library name from the #FP_LIB_TABLE.
*/
const wxString& GetSelectedLibrary() { return m_libraryName; }
virtual EDA_COLOR_T GetGridColor( void ) const;
private:
void OnSize( wxSizeEvent& event );
......@@ -109,7 +116,14 @@ private:
void ReCreateFootprintList();
void Process_Special_Functions( wxCommandEvent& event );
void DisplayLibInfos();
/**
* Function RedrawActiveWindow
* Display the current selected component.
* If the component is an alias, the ROOT component is displayed
*/
void RedrawActiveWindow( wxDC* DC, bool EraseBg );
void OnCloseWindow( wxCloseEvent& Event );
void ReCreateHToolbar();
void ReCreateVToolbar();
......@@ -150,6 +164,10 @@ private:
void SelectCurrentLibrary( wxCommandEvent& event );
/**
* Function SelectCurrentFootprint
* Selects the current footprint name and display it
*/
void SelectCurrentFootprint( wxCommandEvent& event );
/**
......@@ -161,7 +179,8 @@ private:
/**
* Function SelectAndViewFootprint
* Select and load the next or the previous footprint
* if no current footprint, Rebuild the list of footprints availlable in a given footprint library
* if no current footprint, Rebuild the list of footprints available in a given footprint
* library
* @param aMode = NEXT_PART or PREVIOUS_PART
*/
void SelectAndViewFootprint( int aMode );
......@@ -179,7 +198,7 @@ private:
* must be called after a footprint selection
* Updates the 3D view and 3D frame title.
* @param aForceReloadFootprint = true to reload data (default)
* = false to update title only -(aftre creating the 3D viewer)
* = false to update title only -(after creating the 3D viewer)
*/
void Update3D_Frame( bool aForceReloadFootprint = true );
......
......@@ -101,6 +101,7 @@ void EDA_APP::MacOpenFile( const wxString& fileName )
frame->LoadOnePcbFile( fileName, false );
}
bool EDA_APP::OnInit()
{
wxFileName fn;
......@@ -130,8 +131,9 @@ bool EDA_APP::OnInit()
if( fn.GetExt() != PcbFileExtension && fn.GetExt() != LegacyPcbFileExtension )
{
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n\
Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n"
"Changing extension to .%s." ),
GetChars( fn.GetFullPath() ),
GetChars( PcbFileExtension ) );
fn.SetExt( PcbFileExtension );
wxMessageBox( msg );
......@@ -185,6 +187,11 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
// Some will be overwritten after loading the board file
frame->LoadProjectSettings( fn.GetFullPath() );
// Set the KISYSMOD environment variable for the current process if it is not already
// defined. This is required to expand the global footprint library table paths.
if( !wxGetEnv( wxT( "KISYSMOD" ), &msg ) && !GetLibraryPathList().IsEmpty() )
wxSetEnv( wxT( "KISYSMOD" ), GetLibraryPathList()[0] );
/* Load file specified in the command line. */
if( fn.IsOk() )
{
......@@ -210,13 +217,16 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
// Try to find a legacy file with the same name:
wxFileName fn_legacy = fn;
fn_legacy.SetExt( LegacyPcbFileExtension );
if( fn_legacy.FileExists() )
{
msg.Printf( _( "File <%s> does not exist.\n\
However a legacy file <%s> exists.\nDo you want to load it?\n\
It will be saved under the new file format" ),
msg.Printf( _( "File <%s> does not exist.\n"
"However a legacy file <%s> exists.\n"
"Do you want to load it?\n"
"It will be saved under the new file format." ),
GetChars( fn.GetFullPath() ),
GetChars( fn_legacy.GetFullPath() ) );
if( IsOK( frame, msg ) )
{
file_exists = true;
......@@ -225,7 +235,7 @@ It will be saved under the new file format" ),
filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
frame->GetBoard()->SetFileName( filename );
frame->UpdateTitle();
frame->OnModify(); // Ready to save theboard inder the new fmt
frame->OnModify(); // Ready to save the board under the new format
}
}
}
......@@ -234,6 +244,7 @@ It will be saved under the new file format" ),
{ // File does not exists: prepare an empty board
if( ! fn.GetPath().IsEmpty() )
wxSetWorkingDirectory( fn.GetPath() );
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
frame->UpdateTitle();
frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
......@@ -267,12 +278,14 @@ It will be saved under the new file format" ),
return true;
}
#if 0
// for some reason KiCad classes do not implement OnExit
// if I add it in the declaration, I need to fix it in every application
// so for now make a note TODO TODO
// we need to clean up python when the application exits
int EDA_APP::OnExit() {
int EDA_APP::OnExit()
{
// Restore the thread state and tell Python to cleanup after itself.
// wxPython will do its own cleanup as part of that process. This is done
// in OnExit instead of ~MyApp because OnExit is only called if OnInit is
......@@ -284,5 +297,3 @@ int EDA_APP::OnExit() {
}
#endif
......@@ -589,10 +589,8 @@ void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
{
wxString newname;
newname = m_Parent->Select_1_Module_From_List( m_Parent,
wxEmptyString,
wxEmptyString,
wxEmptyString );
newname = m_Parent->SelectFootprint( m_Parent, wxEmptyString, wxEmptyString, wxEmptyString );
if( newname != wxEmptyString )
m_NewModule->SetValue( newname );
}
......
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