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.
This commit is contained in:
parent
2e6969fe96
commit
cf86e18f5c
|
@ -1,3 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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
|
* @file displlst.cpp
|
||||||
*/
|
*/
|
||||||
|
@ -25,22 +49,21 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
|
||||||
column.SetId( i );
|
column.SetId( i );
|
||||||
column.SetText( aItemHeaders.Item( i ) );
|
column.SetText( aItemHeaders.Item( i ) );
|
||||||
column.SetWidth( 300 / aItemHeaders.Count() );
|
column.SetWidth( 300 / aItemHeaders.Count() );
|
||||||
EDA_LIST_DIALOG_BASE::m_listBox->InsertColumn( i, column );
|
m_listBox->InsertColumn( i, column );
|
||||||
}
|
}
|
||||||
|
|
||||||
InsertItems( aItemList, 0 );
|
InsertItems( aItemList, 0 );
|
||||||
|
|
||||||
if( m_sortList )
|
|
||||||
sortList();
|
|
||||||
|
|
||||||
if( !aRefText.IsEmpty() ) // try to select the item matching aRefText
|
if( !aRefText.IsEmpty() ) // try to select the item matching aRefText
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
||||||
|
{
|
||||||
if( aItemList[ii][0] == aRefText )
|
if( aItemList[ii][0] == aRefText )
|
||||||
{
|
{
|
||||||
m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
m_listBox->SetItemState( ii, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_callBackFct == NULL )
|
if( m_callBackFct == NULL )
|
||||||
|
@ -85,12 +108,25 @@ void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
|
||||||
sortList();
|
sortList();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString EDA_LIST_DIALOG::GetTextSelection()
|
|
||||||
|
wxString EDA_LIST_DIALOG::GetTextSelection( int aColumn )
|
||||||
{
|
{
|
||||||
long item = -1;
|
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 );
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,7 +135,7 @@ void EDA_LIST_DIALOG::Append( const wxArrayString& itemList )
|
||||||
long itemIndex = m_listBox->InsertItem( m_listBox->GetItemCount(), itemList[0] );
|
long itemIndex = m_listBox->InsertItem( m_listBox->GetItemCount(), itemList[0] );
|
||||||
|
|
||||||
m_listBox->SetItemData( itemIndex, (long) &(itemList[0]) );
|
m_listBox->SetItemData( itemIndex, (long) &(itemList[0]) );
|
||||||
|
|
||||||
// Adding the next columns content
|
// Adding the next columns content
|
||||||
for( unsigned i = 1; i < itemList.size(); i++ )
|
for( unsigned i = 1; i < itemList.size(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -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 ) );
|
wxASSERT( (int) itemList[row].GetCount() == m_listBox->GetColumnCount() );
|
||||||
m_listBox->SetItemData( itemIndex, (long) &( itemList[i].Item( 0 ) ) );
|
|
||||||
|
for( unsigned col = 0; col < itemList[row].GetCount(); col++ )
|
||||||
// Adding the next columns content
|
|
||||||
for( unsigned j = 1; j < itemList[i].GetCount(); j++ )
|
|
||||||
{
|
{
|
||||||
m_listBox->SetItem( itemIndex, j, itemList[i].Item( j ) );
|
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, col, itemList[row].Item( col ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +179,7 @@ void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event )
|
||||||
|
|
||||||
void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event )
|
void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( m_callBackFct )
|
if( m_callBackFct )
|
||||||
{
|
{
|
||||||
m_messages->Clear();
|
m_messages->Clear();
|
||||||
|
@ -167,13 +211,14 @@ void EDA_LIST_DIALOG::onClose( wxCloseEvent& event )
|
||||||
/* Sort alphabetically, case insensitive.
|
/* Sort alphabetically, case insensitive.
|
||||||
*/
|
*/
|
||||||
static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortData )
|
static int wxCALLBACK MyCompareFunction( long aItem1, long aItem2, long aSortData )
|
||||||
{
|
{
|
||||||
wxString* component1Name = (wxString*) aItem1;
|
wxString* component1Name = (wxString*) aItem1;
|
||||||
wxString* component2Name = (wxString*) aItem2;
|
wxString* component2Name = (wxString*) aItem2;
|
||||||
|
|
||||||
return StrNumCmp( *component1Name, *component2Name, INT_MAX, true );
|
return StrNumCmp( *component1Name, *component2Name, INT_MAX, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EDA_LIST_DIALOG::sortList()
|
void EDA_LIST_DIALOG::sortList()
|
||||||
{
|
{
|
||||||
m_listBox->SortItems( MyCompareFunction, 0 );
|
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 );
|
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;
|
m_KicadEnv += UNIX_STRING_DIR_SEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,20 +48,6 @@
|
||||||
#include <wildcards_and_files_ext.h>
|
#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 )
|
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
|
||||||
{
|
{
|
||||||
// Clear data before reading files
|
// Clear data before reading files
|
||||||
|
@ -76,12 +62,17 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
|
||||||
// Parse Libraries Listed
|
// Parse Libraries Listed
|
||||||
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
wxFileName filename( wxEmptyString, aFootprintsLibNames[ii],
|
// File names can be fully qualified or file name only.
|
||||||
LegacyFootprintLibPathExtension );
|
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" );
|
m_filesNotFound << filename.GetFullName() << wxT( "\n" );
|
||||||
continue;
|
continue;
|
||||||
|
@ -89,19 +80,21 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
wxArrayString fpnames = pi->FootprintEnumerate( libPath );
|
wxArrayString fpnames = pi->FootprintEnumerate( filename.GetFullPath() );
|
||||||
|
|
||||||
for( unsigned i=0; i<fpnames.GetCount(); ++i )
|
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.
|
// we're loading what we enumerated, all must be there.
|
||||||
wxASSERT( m.get() );
|
wxASSERT( m.get() );
|
||||||
|
|
||||||
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
|
FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO();
|
||||||
|
|
||||||
|
fpinfo->SetLibraryName( filename.GetName() );
|
||||||
|
fpinfo->SetLibraryPath( filename.GetFullPath() );
|
||||||
fpinfo->m_Module = fpnames[i];
|
fpinfo->m_Module = fpnames[i];
|
||||||
fpinfo->m_LibName = libPath;
|
|
||||||
fpinfo->m_padCount = m->GetPadCount();
|
fpinfo->m_padCount = m->GetPadCount();
|
||||||
fpinfo->m_KeyWord = m->GetKeywords();
|
fpinfo->m_KeyWord = m->GetKeywords();
|
||||||
fpinfo->m_Doc = m->GetDescription();
|
fpinfo->m_Doc = m->GetDescription();
|
||||||
|
@ -111,7 +104,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
|
||||||
}
|
}
|
||||||
catch( IO_ERROR ioe )
|
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;
|
const wxChar *libname;
|
||||||
if( module_info )
|
if( module_info )
|
||||||
libname = GetChars( module_info->m_LibName );
|
libname = GetChars( module_info->GetLibraryPath() );
|
||||||
else
|
else
|
||||||
libname = GetChars( wxT( "???" ) );
|
libname = GetChars( wxT( "???" ) );
|
||||||
|
|
||||||
msg.Printf( _( "Lib: %s" ), libname );
|
msg.Printf( _( "Lib: %s" ), libname );
|
||||||
|
|
||||||
SetStatusText( msg, 0 );
|
SetStatusText( msg, 0 );
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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
|
* @file database.cpp
|
||||||
*/
|
*/
|
||||||
|
@ -16,6 +40,7 @@
|
||||||
|
|
||||||
extern void DisplayCmpDocAndKeywords( wxString& Name );
|
extern void DisplayCmpDocAndKeywords( wxString& Name );
|
||||||
|
|
||||||
|
|
||||||
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
|
// Used in DataBaseGetName: this is a callback function for EDA_LIST_DIALOG
|
||||||
// to display keywords and description of a component
|
// to display keywords and description of a component
|
||||||
void DisplayCmpDocAndKeywords( wxString& Name )
|
void DisplayCmpDocAndKeywords( wxString& Name )
|
||||||
|
@ -31,6 +56,7 @@ void DisplayCmpDocAndKeywords( wxString& Name )
|
||||||
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
|
Name += wxT( "\nKey Words: " ) + CmpEntry->GetKeyWords();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Displays a list of filtered components found in libraries for selection,
|
* 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
|
* Keys is a list of keywords to filter components which do not match these keywords
|
||||||
|
@ -56,9 +82,9 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
|
||||||
|
|
||||||
if( nameList.empty() )
|
if( nameList.empty() )
|
||||||
{
|
{
|
||||||
if( !BufName.IsEmpty() )
|
if( !BufName.IsEmpty() )
|
||||||
{
|
{
|
||||||
if( !Keys.IsEmpty() )
|
if( !Keys.IsEmpty() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "No components found matching name search criteria '%s' and key search criteria '%s'" ),
|
msg.Printf( _( "No components found matching name search criteria '%s' and key search criteria '%s'" ),
|
||||||
GetChars( BufName ), GetChars( Keys ) );
|
GetChars( BufName ), GetChars( Keys ) );
|
||||||
|
@ -71,7 +97,7 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !Keys.IsEmpty() )
|
if( !Keys.IsEmpty() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "No components found matching key search criteria '%s'" ),
|
msg.Printf( _( "No components found matching key search criteria '%s'" ),
|
||||||
GetChars( Keys ) );
|
GetChars( Keys ) );
|
||||||
|
@ -88,9 +114,9 @@ wxString DataBaseGetName( EDA_DRAW_FRAME* frame, wxString& Keys, wxString& BufNa
|
||||||
}
|
}
|
||||||
|
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
headers.Add( wxT("Component") );
|
headers.Add( _( "Component" ) );
|
||||||
headers.Add( wxT("Library") );
|
headers.Add( _( "Library" ) );
|
||||||
|
|
||||||
// Show candidate list:
|
// Show candidate list:
|
||||||
wxString cmpname;
|
wxString cmpname;
|
||||||
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname,
|
EDA_LIST_DIALOG dlg( frame, _( "Select Component" ), headers, nameList, cmpname,
|
||||||
|
|
|
@ -28,10 +28,10 @@ CMP_LIBRARY* SelectLibraryFromList( EDA_DRAW_FRAME* frame )
|
||||||
|
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
headers.Add( wxT("Library") );
|
headers.Add( wxT("Library") );
|
||||||
|
|
||||||
libNamesList = CMP_LIBRARY::GetLibraryNames();
|
libNamesList = CMP_LIBRARY::GetLibraryNames();
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
std::vector<wxArrayString> itemsToDisplay;
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
// Conversion from wxArrayString to vector of ArrayString
|
||||||
for( unsigned i = 0; i < libNamesList.GetCount(); i++ )
|
for( unsigned i = 0; i < libNamesList.GetCount(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ int DisplayComponentsNamesInLib( EDA_DRAW_FRAME* frame,
|
||||||
headers.Add( wxT("Component") );
|
headers.Add( wxT("Component") );
|
||||||
headers.Add( wxT("Library") );
|
headers.Add( wxT("Library") );
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
std::vector<wxArrayString> itemsToDisplay;
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
// Conversion from wxArrayString to vector of ArrayString
|
||||||
for( unsigned i = 0; i < nameList.GetCount(); i++ )
|
for( unsigned i = 0; i < nameList.GetCount(); i++ )
|
||||||
{
|
{
|
||||||
|
|
|
@ -78,7 +78,15 @@ public:
|
||||||
|
|
||||||
void Append( const wxArrayString& aItemStr );
|
void Append( const wxArrayString& aItemStr );
|
||||||
void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
|
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:
|
private:
|
||||||
void onClose( wxCloseEvent& event );
|
void onClose( wxCloseEvent& event );
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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
|
* @file footprint_info.h
|
||||||
*/
|
*/
|
||||||
|
@ -12,14 +36,16 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class FOOTPRINT_INFO
|
* Class FOOTPRINT_INFO
|
||||||
* is a helper class to handle the list of footprints
|
* is a helper class to handle the list of footprints available in libraries. It stores
|
||||||
* available in libraries. It stores footprint names, doc and keywords
|
* footprint names, doc and keywords
|
||||||
*/
|
*/
|
||||||
class FOOTPRINT_INFO
|
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:
|
public:
|
||||||
wxString m_Module; ///< Module name.
|
wxString m_Module; ///< Module name.
|
||||||
wxString m_LibName; ///< Name of the library containing this module.
|
|
||||||
int m_Num; ///< Order number in the display list.
|
int m_Num; ///< Order number in the display list.
|
||||||
wxString m_Doc; ///< Footprint description.
|
wxString m_Doc; ///< Footprint description.
|
||||||
wxString m_KeyWord; ///< Footprint key words.
|
wxString m_KeyWord; ///< Footprint key words.
|
||||||
|
@ -30,6 +56,14 @@ public:
|
||||||
m_Num = 0;
|
m_Num = 0;
|
||||||
m_padCount = 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
|
* 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 ).
|
* modules in libs ).
|
||||||
* for each module, are stored
|
* for each module, are stored
|
||||||
* the module name
|
* the module name
|
||||||
|
|
|
@ -365,6 +365,12 @@ public:
|
||||||
*/
|
*/
|
||||||
static const wxString ExpandSubtitutions( const wxString aString );
|
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:
|
protected:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -133,6 +133,25 @@ public:
|
||||||
const std::string& aRevision )
|
const std::string& aRevision )
|
||||||
throw( PARSE_ERROR );
|
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
|
* Function clear
|
||||||
* clears the contents of the library nickname, footprint name, and revision strings.
|
* clears the contents of the library nickname, footprint name, and revision strings.
|
||||||
|
|
|
@ -432,7 +432,7 @@ public:
|
||||||
bool aDisplayError );
|
bool aDisplayError );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Select_1_Module_From_List
|
* Function SelectFootprint
|
||||||
* Display a list of modules found in active libraries or a given library
|
* Display a list of modules found in active libraries or a given library
|
||||||
* @param aWindow = the current window ( parent window )
|
* @param aWindow = the current window ( parent window )
|
||||||
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename
|
* @param aLibraryFullFilename = library to list (if aLibraryFullFilename
|
||||||
|
@ -445,10 +445,10 @@ public:
|
||||||
*
|
*
|
||||||
* @return wxEmptyString if abort or fails, or the selected module name if Ok
|
* @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& aLibraryFullFilename,
|
||||||
const wxString& aMask,
|
const wxString& aMask,
|
||||||
const wxString& aKeyWord );
|
const wxString& aKeyWord );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function Load_Module_From_Library
|
* Function Load_Module_From_Library
|
||||||
|
|
|
@ -464,8 +464,8 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
|
||||||
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||||
{
|
{
|
||||||
wxString libPath = getLibPath();
|
wxString libPath = getLibPath();
|
||||||
wxString footprintName = Select_1_Module_From_List( this, libPath,
|
wxString footprintName = PCB_BASE_FRAME::SelectFootprint( this, libPath,
|
||||||
wxEmptyString, wxEmptyString );
|
wxEmptyString, wxEmptyString );
|
||||||
|
|
||||||
if( !footprintName )
|
if( !footprintName )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
|
||||||
if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules )
|
if( ! parent->GetBoard() || ! parent->GetBoard()->m_Modules )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
aModule = Select_1_Module_From_BOARD( parent->GetBoard() );
|
aModule = SelectFootprint( parent->GetBoard() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( aModule == NULL )
|
if( aModule == NULL )
|
||||||
|
@ -114,6 +114,7 @@ bool FOOTPRINT_EDIT_FRAME::Load_Module_From_BOARD( MODULE* aModule )
|
||||||
*/
|
*/
|
||||||
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
||||||
{
|
{
|
||||||
|
wxString fpname;
|
||||||
wxSemaphore semaphore( 0, 1 );
|
wxSemaphore semaphore( 0, 1 );
|
||||||
|
|
||||||
// Close the current Lib browser, if opened, and open a new one, in "modal" mode:
|
// Close the current Lib browser, if opened, and open a new one, in "modal" mode:
|
||||||
|
@ -132,11 +133,13 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
||||||
wxMilliSleep( 50 );
|
wxMilliSleep( 50 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
// Returns the full fp name, i.e. the lib name and th fp name,
|
// Returns the full fp name, i.e. the lib name and th fp name,
|
||||||
// separated by a '/'
|
// separated by a '/' (/ is now an illegal char in fp names)
|
||||||
// (/ is now an illegal char in fp names)
|
fpname = viewer->GetSelectedLibraryFullName() + wxT( "/" ) + viewer->GetSelectedFootprint();
|
||||||
wxString fpname = viewer->GetSelectedLibraryFullName();
|
#else
|
||||||
fpname << wxT("/") << viewer->GetSelectedFootprint();
|
fpname = viewer->GetSelectedLibrary() + wxT( ":" ) + viewer->GetSelectedFootprint();
|
||||||
|
#endif
|
||||||
|
|
||||||
viewer->Destroy();
|
viewer->Destroy();
|
||||||
|
|
||||||
|
@ -145,8 +148,8 @@ wxString PCB_BASE_FRAME::SelectFootprintFromLibBrowser( void )
|
||||||
|
|
||||||
|
|
||||||
MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
bool aUseFootprintViewer,
|
bool aUseFootprintViewer,
|
||||||
wxDC* aDC )
|
wxDC* aDC )
|
||||||
{
|
{
|
||||||
MODULE* module;
|
MODULE* module;
|
||||||
wxPoint curspos = GetScreen()->GetCrossHairPosition();
|
wxPoint curspos = GetScreen()->GetCrossHairPosition();
|
||||||
|
@ -158,8 +161,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
static wxString lastComponentName;
|
static wxString lastComponentName;
|
||||||
|
|
||||||
// Ask for a component name or key words
|
// Ask for a component name or key words
|
||||||
DIALOG_GET_COMPONENT dlg( this, HistoryList,
|
DIALOG_GET_COMPONENT dlg( this, HistoryList, _( "Load Module" ), aUseFootprintViewer );
|
||||||
_( "Load Module" ), aUseFootprintViewer );
|
|
||||||
|
|
||||||
dlg.SetComponentName( lastComponentName );
|
dlg.SetComponentName( lastComponentName );
|
||||||
|
|
||||||
|
@ -168,12 +170,15 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
|
|
||||||
if( dlg.m_GetExtraFunction )
|
if( dlg.m_GetExtraFunction )
|
||||||
{
|
{
|
||||||
// SelectFootprintFromLibBrowser() returns the
|
// SelectFootprintFromLibBrowser() returns the "full" footprint name, i.e.
|
||||||
// "full" footprint name, i.e.
|
// <lib_name>/<footprint name> or FPID format "lib_name:fp_name:rev#"
|
||||||
// <lib_name>/<footprint name>
|
#if !defined( USE_FP_LIB_TABLE )
|
||||||
wxString full_fpname = SelectFootprintFromLibBrowser();
|
wxString full_fpname = SelectFootprintFromLibBrowser();
|
||||||
moduleName = full_fpname.AfterLast( '/' );
|
moduleName = full_fpname.AfterLast( '/' );
|
||||||
libName = full_fpname.BeforeLast( '/' );
|
libName = full_fpname.BeforeLast( '/' );
|
||||||
|
#else
|
||||||
|
libName = SelectFootprintFromLibBrowser();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -186,41 +191,41 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( dlg.IsKeyword() ) // Selection by keywords
|
if( dlg.IsKeyword() ) // Selection by keywords
|
||||||
{
|
{
|
||||||
allowWildSeach = false;
|
allowWildSeach = false;
|
||||||
keys = moduleName;
|
keys = moduleName;
|
||||||
moduleName = Select_1_Module_From_List( this, libName, wxEmptyString, keys );
|
moduleName = SelectFootprint( this, libName, wxEmptyString, keys );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() ) // Cancel command
|
if( moduleName.IsEmpty() ) // Cancel command
|
||||||
{
|
{
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( ( moduleName.Contains( wxT( "?" ) ) )
|
else if( moduleName.Contains( wxT( "?" ) )
|
||||||
|| ( moduleName.Contains( wxT( "*" ) ) ) ) // Selection wild card
|
|| moduleName.Contains( wxT( "*" ) ) ) // Selection wild card
|
||||||
{
|
{
|
||||||
allowWildSeach = false;
|
allowWildSeach = false;
|
||||||
moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() )
|
if( moduleName.IsEmpty() )
|
||||||
{
|
{
|
||||||
m_canvas->MoveCursorToCrossHair();
|
m_canvas->MoveCursorToCrossHair();
|
||||||
return NULL; // Cancel command.
|
return NULL; // Cancel command.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module = GetModuleLibrary( libName, moduleName, false );
|
module = GetModuleLibrary( libName, moduleName, false );
|
||||||
|
|
||||||
if( !module && allowWildSeach ) // Search with wild card
|
if( !module && allowWildSeach ) // Search with wild card
|
||||||
{
|
{
|
||||||
allowWildSeach = false;
|
allowWildSeach = false;
|
||||||
|
|
||||||
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
|
wxString wildname = wxChar( '*' ) + moduleName + wxChar( '*' );
|
||||||
moduleName = wildname;
|
moduleName = wildname;
|
||||||
|
|
||||||
moduleName = Select_1_Module_From_List( this, libName, moduleName, wxEmptyString );
|
moduleName = SelectFootprint( this, libName, moduleName, wxEmptyString );
|
||||||
|
|
||||||
if( moduleName.IsEmpty() )
|
if( moduleName.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
@ -243,11 +248,10 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
|
|
||||||
module->SetFlags( IS_NEW );
|
module->SetFlags( IS_NEW );
|
||||||
module->SetLink( 0 );
|
module->SetLink( 0 );
|
||||||
|
module->SetPosition( curspos );
|
||||||
module->SetTimeStamp( GetNewTimeStamp() );
|
module->SetTimeStamp( GetNewTimeStamp() );
|
||||||
GetBoard()->m_Status_Pcb = 0;
|
GetBoard()->m_Status_Pcb = 0;
|
||||||
|
|
||||||
module->SetPosition( curspos );
|
|
||||||
|
|
||||||
// Put it on FRONT layer,
|
// Put it on FRONT layer,
|
||||||
// (Can be stored flipped if the lib is an archive built from a board)
|
// (Can be stored flipped if the lib is an archive built from a board)
|
||||||
|
@ -271,7 +275,7 @@ MODULE* PCB_BASE_FRAME::Load_Module_From_Library( const wxString& aLibrary,
|
||||||
|
|
||||||
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath,
|
MODULE* PCB_BASE_FRAME::GetModuleLibrary( const wxString& aLibraryPath,
|
||||||
const wxString& aFootprintName,
|
const wxString& aFootprintName,
|
||||||
bool aDisplayError )
|
bool aDisplayError )
|
||||||
{
|
{
|
||||||
if( aLibraryPath.IsEmpty() )
|
if( aLibraryPath.IsEmpty() )
|
||||||
return loadFootprintFromLibraries( aFootprintName, aDisplayError );
|
return loadFootprintFromLibraries( aFootprintName, aDisplayError );
|
||||||
|
@ -298,7 +302,7 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibrary( const wxString& aLibraryPath,
|
||||||
if( aDisplayError )
|
if( aDisplayError )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Footprint %s not found in library <%s>" ),
|
_( "Footprint %s not found in library <%s>." ),
|
||||||
aFootprintName.GetData(),
|
aFootprintName.GetData(),
|
||||||
libPath.GetData() );
|
libPath.GetData() );
|
||||||
|
|
||||||
|
@ -334,7 +338,8 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii], LegacyFootprintLibPathExtension );
|
wxFileName fn = wxFileName( wxEmptyString, g_LibraryNames[ii],
|
||||||
|
LegacyFootprintLibPathExtension );
|
||||||
|
|
||||||
wxString libPath = wxGetApp().FindLibraryPath( fn );
|
wxString libPath = wxGetApp().FindLibraryPath( fn );
|
||||||
|
|
||||||
|
@ -367,7 +372,7 @@ MODULE* PCB_BASE_FRAME::loadFootprintFromLibraries(
|
||||||
if( aDisplayError )
|
if( aDisplayError )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Footprint %s not found in any library" ),
|
_( "Footprint %s not found in any library." ),
|
||||||
aFootprintName.GetData() );
|
aFootprintName.GetData() );
|
||||||
|
|
||||||
DisplayError( NULL, msg );
|
DisplayError( NULL, msg );
|
||||||
|
@ -413,71 +418,105 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const wxString& aFootprintName )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
|
wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow,
|
||||||
const wxString& aLibraryFullFilename,
|
const wxString& aLibraryFullFilename,
|
||||||
const wxString& aMask,
|
const wxString& aMask,
|
||||||
const wxString& aKeyWord )
|
const wxString& aKeyWord )
|
||||||
{
|
{
|
||||||
static wxString OldName; // Save the name of the last module loaded.
|
static wxString OldName; // Save the name of the last module loaded.
|
||||||
wxString CmpName;
|
wxString CmpName;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxArrayString libnames_list;
|
wxArrayString libraries;
|
||||||
|
std::vector< wxArrayString > rows;
|
||||||
|
|
||||||
|
|
||||||
if( aLibraryFullFilename.IsEmpty() )
|
if( aLibraryFullFilename.IsEmpty() )
|
||||||
libnames_list = g_LibraryNames;
|
libraries = g_LibraryNames;
|
||||||
else
|
else
|
||||||
libnames_list.Add( aLibraryFullFilename );
|
libraries.Add( aLibraryFullFilename );
|
||||||
|
|
||||||
|
if( libraries.IsEmpty() )
|
||||||
|
{
|
||||||
|
DisplayError( aWindow, _( "No footprint libraries were specified." ) );
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
// Find modules in libraries.
|
// Find modules in libraries.
|
||||||
MList.ReadFootprintFiles( libnames_list );
|
MList.ReadFootprintFiles( libraries );
|
||||||
|
|
||||||
wxArrayString footprint_names_list;
|
if( MList.GetCount() == 0 )
|
||||||
|
{
|
||||||
|
wxString tmp;
|
||||||
|
|
||||||
if( !aKeyWord.IsEmpty() ) // Create a list of modules found by keyword.
|
for( unsigned i = 0; i < libraries.GetCount(); i++ )
|
||||||
|
{
|
||||||
|
tmp += libraries[i] + wxT( "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
msg.Printf( _( "No footprints could be read from library file(s):\n\n%s\nin any of "
|
||||||
|
"the library search paths. Verify your system is configured properly "
|
||||||
|
"so the footprint libraries can be found." ), GetChars( tmp ) );
|
||||||
|
DisplayError( aWindow, msg );
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !aKeyWord.IsEmpty() ) // Create a list of modules found by keyword.
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
if( KeyWordOk( aKeyWord, MList.GetItem(ii).m_KeyWord ) )
|
if( KeyWordOk( aKeyWord, MList.GetItem( ii ).m_KeyWord ) )
|
||||||
footprint_names_list.Add( MList.GetItem(ii).m_Module );
|
{
|
||||||
|
wxArrayString cols;
|
||||||
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
||||||
|
cols.Add( MList.GetItem( ii ).GetLibraryName() );
|
||||||
|
rows.push_back( cols );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( !aMask.IsEmpty() ) // Create a list of modules found by pattern
|
else if( !aMask.IsEmpty() ) // Create a list of modules found by pattern
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
||||||
{
|
{
|
||||||
wxString& candidate = MList.GetItem(ii).m_Module;
|
wxString& candidate = MList.GetItem( ii ).m_Module;
|
||||||
|
|
||||||
if( WildCompareString( aMask, candidate, false ) )
|
if( WildCompareString( aMask, candidate, false ) )
|
||||||
footprint_names_list.Add( candidate );
|
{
|
||||||
|
wxArrayString cols;
|
||||||
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
||||||
|
cols.Add( MList.GetItem( ii ).GetLibraryName() );
|
||||||
|
rows.push_back( cols );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // Create the full list of modules
|
else // Create the full list of modules
|
||||||
{
|
{
|
||||||
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
for( unsigned ii = 0; ii < MList.GetCount(); ii++ )
|
||||||
footprint_names_list.Add( MList.GetItem(ii).m_Module );
|
{
|
||||||
|
wxArrayString cols;
|
||||||
|
cols.Add( MList.GetItem( ii ).GetFootprintName() );
|
||||||
|
cols.Add( MList.GetItem( ii ).GetLibraryName() );
|
||||||
|
rows.push_back( cols );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( footprint_names_list.GetCount() )
|
if( !rows.empty() )
|
||||||
{
|
{
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
headers.Add( wxT("Module") );
|
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
headers.Add( _( "Module" ) );
|
||||||
for( unsigned i = 0; i < footprint_names_list.GetCount(); i++ )
|
headers.Add( _( "Library" ) );
|
||||||
{
|
|
||||||
wxArrayString item;
|
|
||||||
item.Add( footprint_names_list[i] );
|
|
||||||
itemsToDisplay.push_back( item );
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.Printf( _( "Modules [%d items]" ), (int) footprint_names_list.GetCount() );
|
msg.Printf( _( "Modules [%d items]" ), (int) rows.size() );
|
||||||
EDA_LIST_DIALOG dlg( aWindow, msg, headers, itemsToDisplay, OldName,
|
EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, OldName, DisplayCmpDoc );
|
||||||
DisplayCmpDoc );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
CmpName = dlg.GetTextSelection();
|
CmpName = dlg.GetTextSelection();
|
||||||
|
|
||||||
|
#if defined( USE_FP_LIB_TABLE )
|
||||||
|
CmpName += wxT( ":" ) + dlg.GetTextSelection( 1 );
|
||||||
|
#endif
|
||||||
|
|
||||||
SkipNextLeftButtonReleaseEvent();
|
SkipNextLeftButtonReleaseEvent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -485,13 +524,15 @@ wxString PCB_BASE_FRAME::Select_1_Module_From_List( EDA_DRAW_FRAME* aWindow,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayError( aWindow, _( "No footprint found" ) );
|
DisplayError( aWindow, _( "No footprint found." ) );
|
||||||
CmpName.Empty();
|
CmpName.Empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
if( CmpName != wxEmptyString )
|
if( CmpName != wxEmptyString )
|
||||||
OldName = CmpName;
|
OldName = CmpName;
|
||||||
|
|
||||||
|
wxLogDebug( wxT( "Footprint <%s> was selected." ), GetChars( CmpName ) );
|
||||||
|
|
||||||
return CmpName;
|
return CmpName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,13 +547,12 @@ static void DisplayCmpDoc( wxString& Name )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Name = module_info->m_Doc.IsEmpty() ? wxT( "No Doc" ) : module_info->m_Doc;
|
Name = _( "Description: " ) + module_info->m_Doc;
|
||||||
Name += wxT( "\nKeyW: " );
|
Name += _( "\nKey words: " ) + module_info->m_KeyWord;
|
||||||
Name += module_info->m_KeyWord.IsEmpty() ? wxT( "No Keyword" ) : module_info->m_KeyWord;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
|
MODULE* FOOTPRINT_EDIT_FRAME::SelectFootprint( BOARD* aPcb )
|
||||||
{
|
{
|
||||||
MODULE* module;
|
MODULE* module;
|
||||||
static wxString OldName; // Save name of last module selected.
|
static wxString OldName; // Save name of last module selected.
|
||||||
|
@ -528,7 +568,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
|
||||||
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
|
msg.Printf( _( "Modules [%d items]" ), listnames.GetCount() );
|
||||||
|
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
headers.Add( wxT("Module") );
|
headers.Add( _( "Module" ) );
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
std::vector<wxArrayString> itemsToDisplay;
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
// Conversion from wxArrayString to vector of ArrayString
|
||||||
|
@ -538,6 +578,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Select_1_Module_From_BOARD( BOARD* aPcb )
|
||||||
item.Add( listnames[i] );
|
item.Add( listnames[i] );
|
||||||
itemsToDisplay.push_back( item );
|
itemsToDisplay.push_back( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
EDA_LIST_DIALOG dlg( this, msg, headers, itemsToDisplay, wxEmptyString, NULL, SORT_LIST );
|
EDA_LIST_DIALOG dlg( this, msg, headers, itemsToDisplay, wxEmptyString, NULL, SORT_LIST );
|
||||||
|
|
||||||
if( dlg.ShowModal() == wxID_OK )
|
if( dlg.ShowModal() == wxID_OK )
|
||||||
|
@ -592,7 +633,7 @@ void FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "Footprint library <%s> saved as <%s>" ),
|
_( "Footprint library <%s> saved as <%s>." ),
|
||||||
GetChars( curLibPath ), GetChars( dstLibPath ) );
|
GetChars( curLibPath ), GetChars( dstLibPath ) );
|
||||||
|
|
||||||
DisplayInfoMessage( this, msg );
|
DisplayInfoMessage( this, msg );
|
||||||
|
|
|
@ -285,12 +285,12 @@ public:
|
||||||
bool Load_Module_From_BOARD( MODULE* Module );
|
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
|
* Display the list of modules currently existing on the BOARD
|
||||||
* @return a pointer to a module if this module is selected or NULL otherwise
|
* @return a pointer to a module if this module is selected or NULL otherwise
|
||||||
* @param aPcb = the board from modules can be loaded
|
* @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
|
// functions to edit footprint edges
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,29 @@
|
||||||
|
/*
|
||||||
|
* 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>
|
#include <fctsys.h>
|
||||||
|
@ -85,7 +109,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxArrayString headers;
|
wxArrayString headers;
|
||||||
headers.Add( wxT("Library") );
|
headers.Add( wxT( "Library" ) );
|
||||||
std::vector<wxArrayString> itemsToDisplay;
|
std::vector<wxArrayString> itemsToDisplay;
|
||||||
|
|
||||||
// Conversion from wxArrayString to vector of ArrayString
|
// Conversion from wxArrayString to vector of ArrayString
|
||||||
|
@ -95,6 +119,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
|
||||||
item.Add( g_LibraryNames[i] );
|
item.Add( g_LibraryNames[i] );
|
||||||
itemsToDisplay.push_back( item );
|
itemsToDisplay.push_back( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
EDA_LIST_DIALOG dlg( this, _( "Select Current Library:" ),
|
EDA_LIST_DIALOG dlg( this, _( "Select Current Library:" ),
|
||||||
headers, itemsToDisplay, m_libraryName );
|
headers, itemsToDisplay, m_libraryName );
|
||||||
|
|
||||||
|
@ -110,35 +135,35 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentLibrary( wxCommandEvent& event )
|
||||||
ReCreateFootprintList();
|
ReCreateFootprintList();
|
||||||
|
|
||||||
int id = m_LibList->FindString( m_libraryName );
|
int id = m_LibList->FindString( m_libraryName );
|
||||||
|
|
||||||
if( id >= 0 )
|
if( id >= 0 )
|
||||||
m_LibList->SetSelection( id );
|
m_LibList->SetSelection( id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SelectCurrentFootprint
|
|
||||||
* Selects the current footprint name and display it
|
|
||||||
*/
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
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* oldmodule = GetBoard()->m_Modules;
|
||||||
MODULE * module = Load_Module_From_Library( libname, false );
|
MODULE * module = Load_Module_From_Library( libname, false );
|
||||||
|
|
||||||
if( module )
|
if( module )
|
||||||
{
|
{
|
||||||
module->SetPosition( wxPoint( 0, 0 ) );
|
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 )
|
if( oldmodule )
|
||||||
{
|
{
|
||||||
GetBoard()->Remove( oldmodule );
|
GetBoard()->Remove( oldmodule );
|
||||||
delete oldmodule;
|
delete oldmodule;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_footprintName = module->GetLibRef();
|
m_footprintName = module->GetLibRef();
|
||||||
module->ClearFlags();
|
module->ClearFlags();
|
||||||
SetCurItem( NULL );
|
SetCurItem( NULL );
|
||||||
|
|
||||||
Zoom_Automatique( false );
|
Zoom_Automatique( false );
|
||||||
m_canvas->Refresh( );
|
m_canvas->Refresh();
|
||||||
Update3D_Frame();
|
Update3D_Frame();
|
||||||
m_FootprintList->SetStringSelection( m_footprintName );
|
m_FootprintList->SetStringSelection( m_footprintName );
|
||||||
}
|
}
|
||||||
|
@ -147,7 +172,7 @@ void FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint( wxCommandEvent& event )
|
||||||
|
|
||||||
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
|
const wxString FOOTPRINT_VIEWER_FRAME::GetSelectedLibraryFullName( void )
|
||||||
{
|
{
|
||||||
wxString fullname = m_libraryName + wxT(".") + LegacyFootprintLibPathExtension;
|
wxString fullname = m_libraryName + wxT( "." ) + LegacyFootprintLibPathExtension;
|
||||||
return fullname;
|
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 )
|
void FOOTPRINT_VIEWER_FRAME::RedrawActiveWindow( wxDC* DC, bool EraseBg )
|
||||||
{
|
{
|
||||||
if( !GetBoard() )
|
if( !GetBoard() )
|
||||||
|
|
|
@ -45,23 +45,23 @@ class FOOTPRINT_VIEWER_FRAME : public PCB_BASE_FRAME
|
||||||
private:
|
private:
|
||||||
// List of libraries (for selection )
|
// List of libraries (for selection )
|
||||||
wxSashLayoutWindow* m_LibListWindow;
|
wxSashLayoutWindow* m_LibListWindow;
|
||||||
wxListBox* m_LibList; // The list of libs names
|
wxListBox* m_LibList; // The list of libs names
|
||||||
wxSize m_LibListSize; // size of the window
|
wxSize m_LibListSize; // size of the window
|
||||||
|
|
||||||
// List of components in the selected library
|
// List of components in the selected library
|
||||||
wxSashLayoutWindow* m_FootprintListWindow;
|
wxSashLayoutWindow* m_FootprintListWindow;
|
||||||
wxListBox* m_FootprintList; // The list of footprint names
|
wxListBox* m_FootprintList; // The list of footprint names
|
||||||
wxSize m_FootprintListSize; // size of the window
|
wxSize m_FootprintListSize; // size of the window
|
||||||
|
|
||||||
// Flags
|
// Flags
|
||||||
wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
|
wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
|
||||||
wxString m_configPath; // subpath for configuration
|
wxString m_configPath; // subpath for configuration
|
||||||
|
|
||||||
protected:
|
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_footprintName; // Current selected footprint
|
||||||
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
|
static wxString m_selectedFootprintName; // When the viewer is used to select a footprint
|
||||||
// the selected footprint is here
|
// the selected footprint is here
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL,
|
FOOTPRINT_VIEWER_FRAME( PCB_BASE_FRAME* parent, wxSemaphore* semaphore = NULL,
|
||||||
|
@ -86,7 +86,14 @@ public:
|
||||||
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
|
wxString& GetSelectedFootprint( void ) const { return m_selectedFootprintName; }
|
||||||
const wxString GetSelectedLibraryFullName( void );
|
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;
|
virtual EDA_COLOR_T GetGridColor( void ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void OnSize( wxSizeEvent& event );
|
void OnSize( wxSizeEvent& event );
|
||||||
|
@ -109,7 +116,14 @@ private:
|
||||||
void ReCreateFootprintList();
|
void ReCreateFootprintList();
|
||||||
void Process_Special_Functions( wxCommandEvent& event );
|
void Process_Special_Functions( wxCommandEvent& event );
|
||||||
void DisplayLibInfos();
|
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 RedrawActiveWindow( wxDC* DC, bool EraseBg );
|
||||||
|
|
||||||
void OnCloseWindow( wxCloseEvent& Event );
|
void OnCloseWindow( wxCloseEvent& Event );
|
||||||
void ReCreateHToolbar();
|
void ReCreateHToolbar();
|
||||||
void ReCreateVToolbar();
|
void ReCreateVToolbar();
|
||||||
|
@ -150,6 +164,10 @@ private:
|
||||||
|
|
||||||
void SelectCurrentLibrary( wxCommandEvent& event );
|
void SelectCurrentLibrary( wxCommandEvent& event );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function SelectCurrentFootprint
|
||||||
|
* Selects the current footprint name and display it
|
||||||
|
*/
|
||||||
void SelectCurrentFootprint( wxCommandEvent& event );
|
void SelectCurrentFootprint( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -161,7 +179,8 @@ private:
|
||||||
/**
|
/**
|
||||||
* Function SelectAndViewFootprint
|
* Function SelectAndViewFootprint
|
||||||
* Select and load the next or the previous footprint
|
* 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
|
* @param aMode = NEXT_PART or PREVIOUS_PART
|
||||||
*/
|
*/
|
||||||
void SelectAndViewFootprint( int aMode );
|
void SelectAndViewFootprint( int aMode );
|
||||||
|
@ -179,7 +198,7 @@ private:
|
||||||
* must be called after a footprint selection
|
* must be called after a footprint selection
|
||||||
* Updates the 3D view and 3D frame title.
|
* Updates the 3D view and 3D frame title.
|
||||||
* @param aForceReloadFootprint = true to reload data (default)
|
* @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 );
|
void Update3D_Frame( bool aForceReloadFootprint = true );
|
||||||
|
|
||||||
|
|
|
@ -612,40 +612,40 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_comment:
|
case T_comment:
|
||||||
|
{
|
||||||
|
int commentNumber = parseInt( "comment" );
|
||||||
|
|
||||||
|
switch( commentNumber )
|
||||||
{
|
{
|
||||||
int commentNumber = parseInt( "comment" );
|
case 1:
|
||||||
|
NextTok();
|
||||||
switch( commentNumber )
|
titleBlock.SetComment1( FromUTF8() );
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
NextTok();
|
|
||||||
titleBlock.SetComment1( FromUTF8() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 2:
|
|
||||||
NextTok();
|
|
||||||
titleBlock.SetComment2( FromUTF8() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 3:
|
|
||||||
NextTok();
|
|
||||||
titleBlock.SetComment3( FromUTF8() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 4:
|
|
||||||
NextTok();
|
|
||||||
titleBlock.SetComment4( FromUTF8() );
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
wxString err;
|
|
||||||
err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber );
|
|
||||||
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
NextTok();
|
||||||
|
titleBlock.SetComment2( FromUTF8() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
NextTok();
|
||||||
|
titleBlock.SetComment3( FromUTF8() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
NextTok();
|
||||||
|
titleBlock.SetComment4( FromUTF8() );
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxString err;
|
||||||
|
err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber );
|
||||||
|
THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Expecting( "title, date, rev, company, or comment" );
|
Expecting( "title, date, rev, company, or comment" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool g_Show_Module_Ratsnest;
|
||||||
bool g_Raccord_45_Auto = true;
|
bool g_Raccord_45_Auto = true;
|
||||||
bool g_Alternate_Track_Posture = false;
|
bool g_Alternate_Track_Posture = false;
|
||||||
bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks
|
bool g_Track_45_Only_Allowed = true; // True to allow horiz, vert. and 45deg only tracks
|
||||||
bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments
|
bool g_Segments_45_Only; // True to allow horiz, vert. and 45deg only graphic segments
|
||||||
bool g_TwoSegmentTrackBuild = true;
|
bool g_TwoSegmentTrackBuild = true;
|
||||||
|
|
||||||
LAYER_NUM g_Route_Layer_TOP;
|
LAYER_NUM g_Route_Layer_TOP;
|
||||||
|
@ -78,7 +78,7 @@ wxPoint g_Offset_Module; /* Distance to offset module trace when movi
|
||||||
* this is of the responsibility to users to create this file
|
* this is of the responsibility to users to create this file
|
||||||
* if they want to have a list of footprints
|
* if they want to have a list of footprints
|
||||||
*/
|
*/
|
||||||
wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" );
|
wxString g_DocModulesFileName = wxT( "footprints_doc/footprints.pdf" );
|
||||||
|
|
||||||
wxArrayString g_LibraryNames;
|
wxArrayString g_LibraryNames;
|
||||||
|
|
||||||
|
@ -101,11 +101,12 @@ void EDA_APP::MacOpenFile( const wxString& fileName )
|
||||||
frame->LoadOnePcbFile( fileName, false );
|
frame->LoadOnePcbFile( fileName, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool EDA_APP::OnInit()
|
bool EDA_APP::OnInit()
|
||||||
{
|
{
|
||||||
wxFileName fn;
|
wxFileName fn;
|
||||||
PCB_EDIT_FRAME* frame = NULL;
|
PCB_EDIT_FRAME* frame = NULL;
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
#ifdef KICAD_SCRIPTING
|
#ifdef KICAD_SCRIPTING
|
||||||
if ( !pcbnewInitPythonScripting() )
|
if ( !pcbnewInitPythonScripting() )
|
||||||
|
@ -130,9 +131,10 @@ bool EDA_APP::OnInit()
|
||||||
|
|
||||||
if( fn.GetExt() != PcbFileExtension && fn.GetExt() != LegacyPcbFileExtension )
|
if( fn.GetExt() != PcbFileExtension && fn.GetExt() != LegacyPcbFileExtension )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n\
|
msg.Printf( _( "Pcbnew file <%s> has a wrong extension.\n"
|
||||||
Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
|
"Changing extension to .%s." ),
|
||||||
GetChars( PcbFileExtension ) );
|
GetChars( fn.GetFullPath() ),
|
||||||
|
GetChars( PcbFileExtension ) );
|
||||||
fn.SetExt( PcbFileExtension );
|
fn.SetExt( PcbFileExtension );
|
||||||
wxMessageBox( msg );
|
wxMessageBox( msg );
|
||||||
}
|
}
|
||||||
|
@ -185,6 +187,11 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
|
||||||
// Some will be overwritten after loading the board file
|
// Some will be overwritten after loading the board file
|
||||||
frame->LoadProjectSettings( fn.GetFullPath() );
|
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. */
|
/* Load file specified in the command line. */
|
||||||
if( fn.IsOk() )
|
if( fn.IsOk() )
|
||||||
{
|
{
|
||||||
|
@ -210,13 +217,16 @@ Changing extension to .%s." ), GetChars( fn.GetFullPath() ),
|
||||||
// Try to find a legacy file with the same name:
|
// Try to find a legacy file with the same name:
|
||||||
wxFileName fn_legacy = fn;
|
wxFileName fn_legacy = fn;
|
||||||
fn_legacy.SetExt( LegacyPcbFileExtension );
|
fn_legacy.SetExt( LegacyPcbFileExtension );
|
||||||
|
|
||||||
if( fn_legacy.FileExists() )
|
if( fn_legacy.FileExists() )
|
||||||
{
|
{
|
||||||
msg.Printf( _( "File <%s> does not exist.\n\
|
msg.Printf( _( "File <%s> does not exist.\n"
|
||||||
However a legacy file <%s> exists.\nDo you want to load it?\n\
|
"However a legacy file <%s> exists.\n"
|
||||||
It will be saved under the new file format" ),
|
"Do you want to load it?\n"
|
||||||
|
"It will be saved under the new file format." ),
|
||||||
GetChars( fn.GetFullPath() ),
|
GetChars( fn.GetFullPath() ),
|
||||||
GetChars( fn_legacy.GetFullPath() ) );
|
GetChars( fn_legacy.GetFullPath() ) );
|
||||||
|
|
||||||
if( IsOK( frame, msg ) )
|
if( IsOK( frame, msg ) )
|
||||||
{
|
{
|
||||||
file_exists = true;
|
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 );
|
filename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
|
||||||
frame->GetBoard()->SetFileName( filename );
|
frame->GetBoard()->SetFileName( filename );
|
||||||
frame->UpdateTitle();
|
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
|
{ // File does not exists: prepare an empty board
|
||||||
if( ! fn.GetPath().IsEmpty() )
|
if( ! fn.GetPath().IsEmpty() )
|
||||||
wxSetWorkingDirectory( fn.GetPath() );
|
wxSetWorkingDirectory( fn.GetPath() );
|
||||||
|
|
||||||
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
frame->GetBoard()->SetFileName( fn.GetFullPath( wxPATH_UNIX ) );
|
||||||
frame->UpdateTitle();
|
frame->UpdateTitle();
|
||||||
frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
|
frame->UpdateFileHistory( frame->GetBoard()->GetFileName() );
|
||||||
|
@ -267,12 +278,14 @@ It will be saved under the new file format" ),
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// for some reason KiCad classes do not implement OnExit
|
// for some reason KiCad classes do not implement OnExit
|
||||||
// if I add it in the declaration, I need to fix it in every application
|
// if I add it in the declaration, I need to fix it in every application
|
||||||
// so for now make a note TODO TODO
|
// so for now make a note TODO TODO
|
||||||
// we need to clean up python when the application exits
|
// 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.
|
// 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
|
// 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
|
// in OnExit instead of ~MyApp because OnExit is only called if OnInit is
|
||||||
|
@ -284,5 +297,3 @@ int EDA_APP::OnExit() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -589,10 +589,8 @@ void DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxString newname;
|
wxString newname;
|
||||||
|
|
||||||
newname = m_Parent->Select_1_Module_From_List( m_Parent,
|
newname = m_Parent->SelectFootprint( m_Parent, wxEmptyString, wxEmptyString, wxEmptyString );
|
||||||
wxEmptyString,
|
|
||||||
wxEmptyString,
|
|
||||||
wxEmptyString );
|
|
||||||
if( newname != wxEmptyString )
|
if( newname != wxEmptyString )
|
||||||
m_NewModule->SetValue( newname );
|
m_NewModule->SetValue( newname );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue