7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 16:59:18 +00:00

Merged upstream.

This commit is contained in:
Maciej Suminski 2013-09-20 17:54:35 +02:00
commit 8e472c736a
165 changed files with 7763 additions and 2431 deletions
3d-viewer
CMakeLists.txt
CMakeModules
common
cvpcb
eeschema
gerbview
include
pagelayout_editor
pcbnew
CMakeLists.txtbuild_BOM_from_board.cppclass_board.cppclass_board.hclass_board_design_settings.cppclass_drc_item.cppclass_module.cppclass_module.hclass_pcb_layer_box_selector.cppclass_pcb_layer_box_selector.hclass_pcb_layer_widget.cppclean.cpp
dialogs
dimension.cppdrc_clearance_test_functions.cppdrc_stuff.heagle_plugin.cppedgemod.cppedit.cppeditrack.cppexport_d356.cppexport_gencad.cppfiles.cppgen_modules_placefile.cppglobaleditpad.cpphotkeys.cpphotkeys.hhotkeys_board_editor.cpphotkeys_module_editor.cppkicad_netlist_reader.cppkicad_plugin.cpplegacy_netlist_reader.cpplegacy_plugin.cpplibrairi.cpploadcmp.cppmenubar_pcbframe.cppmodedit.cppmodedit_onclick.cppmoduleframe.cppmodview.cppmodview_frame.cppmuonde.cppnetlist.cppnetlist_reader.cppnetlist_reader.honleftclick.cpponrightclick.cpp
pcad2kicadpcb_plugin
pcb_netlist.cpppcb_netlist.hpcb_parser.cpppcbframe.cpppcbnew.cpppcbnew_config.cpppcbnew_id.hplot_board_layers.cpp
scripting/plugins
sel_layer.cppspecctra.hspecctra_export.cppswap_layers.cpptarget_edit.cpptool_pcb.cppxchgmod.cpp
scripts/bom-in-python
template

View File

@ -60,7 +60,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_VERTEX >& aVertices )
aVertices[ii].y *= m_MatScale.y;
aVertices[ii].z *= m_MatScale.z;
// adjust rotation
// adjust rotation
if( m_MatRotation.x )
RotatePoint( &aVertices[ii].y, &aVertices[ii].z, m_MatRotation.x * 10 );
@ -176,64 +176,39 @@ GLuint EDA_3D_CANVAS::DisplayCubeforTest()
return gllist;
}
VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title,
wxBoxSizer* BoxSizer )
VERTEX_VALUE_CTRL::VERTEX_VALUE_CTRL( wxWindow* aParent, wxBoxSizer* aBoxSizer )
{
wxString text;
wxStaticText* msgtitle;
wxString text;
if( title.IsEmpty() )
text = _( "Vertex " );
else
text = title;
wxFlexGridSizer* gridSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
gridSizer->AddGrowableCol( 1 );
gridSizer->SetFlexibleDirection( wxHORIZONTAL );
gridSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
msgtitle = new wxStaticText( parent, -1, text, wxDefaultPosition, wxSize( -1, -1 ), 0 );
aBoxSizer->Add( gridSizer, 0, wxEXPAND, 5 );
BoxSizer->Add( msgtitle, wxGROW | wxLEFT | wxRIGHT | wxTOP | wxBOTTOM );
wxStaticText* msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "X:" ) );
gridSizer->Add( msgtitle, 0, wxALL , 5 );
wxFlexGridSizer* GridSizer = new wxFlexGridSizer( 3, 2, 0, 0 );
m_XValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition,wxDefaultSize, 0 );
gridSizer->Add( m_XValueCtrl, 0, wxALL|wxEXPAND, 5 );
BoxSizer->Add( GridSizer, 0, wxGROW | wxALL, 5 );
msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "Y:" ), wxDefaultPosition,
wxDefaultSize, 0 );
gridSizer->Add( msgtitle, 0, wxALL, 5 );
msgtitle = new wxStaticText( parent, -1, wxT( "X:" ) );
m_YValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0 );
gridSizer->Add( m_YValueCtrl, 0, wxALL|wxEXPAND, 5 );
GridSizer->Add( msgtitle, 0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT , 5 );
m_XValueCtrl = new wxTextCtrl( parent, -1, wxEmptyString,
wxDefaultPosition, wxSize( -1, -1 ), 0 );
msgtitle = new wxStaticText( aParent, wxID_ANY, wxT( "Z:" ), wxDefaultPosition,
wxDefaultSize, 0 );
gridSizer->Add( msgtitle, 0, wxALL, 5 );
GridSizer->Add( m_XValueCtrl,
0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT, 5 );
msgtitle = new wxStaticText( parent, -1, wxT( "Y:" ), wxDefaultPosition,
wxSize( -1, -1 ), 0 );
GridSizer->Add( msgtitle,
0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT, 5 );
m_YValueCtrl = new wxTextCtrl( parent, -1, wxEmptyString,
wxDefaultPosition, wxSize( -1, -1 ), 0 );
GridSizer->Add( m_YValueCtrl, 0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT, 5 );
msgtitle = new wxStaticText( parent, -1, wxT( "Z:" ), wxDefaultPosition,
wxSize( -1, -1 ), 0 );
GridSizer->Add( msgtitle, 0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT, 5 );
m_ZValueCtrl = new wxTextCtrl( parent, -1, wxEmptyString,
wxDefaultPosition, wxSize( -1, -1 ), 0 );
GridSizer->Add( m_ZValueCtrl, 0,
wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL |
wxLEFT | wxRIGHT, 5 );
m_ZValueCtrl = new wxTextCtrl( aParent, wxID_ANY, wxEmptyString,
wxDefaultPosition, wxDefaultSize, 0 );
gridSizer->Add( m_ZValueCtrl, 0, wxALL|wxEXPAND, 5 );
}

View File

@ -155,10 +155,9 @@ class VERTEX_VALUE_CTRL
{
private:
wxTextCtrl* m_XValueCtrl, * m_YValueCtrl, * m_ZValueCtrl;
wxStaticText* m_Text;
public:
VERTEX_VALUE_CTRL( wxWindow* parent, const wxString& title, wxBoxSizer* BoxSizer );
VERTEX_VALUE_CTRL( wxWindow* parent, wxBoxSizer* BoxSizer );
~VERTEX_VALUE_CTRL();

View File

@ -197,10 +197,14 @@ else()
endif()
endif()
#================================================
# Locations for install targets.
set( KICAD_BIN bin
CACHE PATH "Location of KiCad binaries." )
set( KICAD_FP_LIB_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}"
CACHE PATH "Default path where footprint libraries are installed." )
if( UNIX )
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
set( KICAD_PLUGINS lib/kicad/plugins
@ -209,12 +213,10 @@ if( UNIX )
CACHE PATH "Location of KiCad data files." )
set( KICAD_DOCS share/doc/kicad
CACHE PATH "Location of KiCad documentation files." )
set( KICAD_FP_LIB_INSTALL_PATH "${KICAD_FP_LIB_INSTALL_PATH}/share/kicad/modules" )
endif()
if( MINGW )
# Like all variables, CMAKE_INSTALL_PREFIX can be over-ridden on the command line.
set( CMAKE_INSTALL_PREFIX c:/kicad
CACHE PATH "" )
# Everything without leading / is relative to CMAKE_INSTALL_PREFIX.
set( KICAD_PLUGINS ${KICAD_BIN}/plugins
CACHE PATH "Location of KiCad plugins." )
@ -222,6 +224,7 @@ if( MINGW )
CACHE PATH "Location of KiCad data files." )
set( KICAD_DOCS doc
CACHE PATH "Location of KiCad documentation files." )
set( KICAD_FP_LIB_INSTALL_PATH "${KICAD_FP_LIB_INSTALL_PATH}/modules" )
endif()
set( KICAD_DEMOS ${KICAD_DATA}/demos

View File

@ -81,6 +81,12 @@
/// Definition to compile with Pcbnew footprint library table implementation.
#cmakedefine USE_FP_LIB_TABLE
/// The install prefix defined in CMAKE_INSTALL_PREFIX.
#define DEFAULT_INSTALL_PATH "@CMAKE_INSTALL_PREFIX"
/// Default footprint library install path when installed with `make install`.
#define DEFAULT_FP_LIB_PATH "@KICAD_FP_LIB_INSTALL_PATH@"
/// When defined, build the GITHUB_PLUGIN for pcbnew.
#cmakedefine BUILD_GITHUB_PLUGIN

View File

@ -214,6 +214,7 @@ set(PCB_COMMON_SRCS
../pcbnew/legacy_plugin.cpp
../pcbnew/kicad_plugin.cpp
../pcbnew/gpcb_plugin.cpp
../pcbnew/pcb_netlist.cpp
pcb_plot_params_keywords.cpp
pcb_keywords.cpp
../pcbnew/pcb_parser.cpp

View File

@ -7,56 +7,73 @@
#include <wx/wx.h>
#include <wx/ownerdrw.h>
#include <wx/menuitem.h>
#include <wx/aui/aui.h>
#include <class_layer_box_selector.h>
/* class to display a layer list.
*
*/
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY )
LAYER_SELECTOR::LAYER_SELECTOR()
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
if( choices != NULL )
ResyncBitmapOnly();
}
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxAuiToolBar* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY )
{
m_layerorder = true;
m_layerhotkeys = true;
m_hotkeys = NULL;
if( !choices.IsEmpty() )
ResyncBitmapOnly();
}
bool LAYER_BOX_SELECTOR::SetLayersOrdered( bool value )
bool LAYER_SELECTOR::SetLayersOrdered( bool value )
{
m_layerorder = value;
return m_layerorder;
}
bool LAYER_BOX_SELECTOR::SetLayersHotkeys( bool value )
bool LAYER_SELECTOR::SetLayersHotkeys( bool value )
{
m_layerhotkeys = value;
return m_layerhotkeys;
}
void LAYER_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}
/* class to display a layer list in a wxBitmapComboBox.
*/
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[] ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, n, choices, wxCB_READONLY ),
LAYER_SELECTOR()
{
if( choices != NULL )
ResyncBitmapOnly();
}
LAYER_BOX_SELECTOR::LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices ) :
wxBitmapComboBox( parent, id, wxEmptyString, pos, size, choices, wxCB_READONLY ),
LAYER_SELECTOR()
{
if( !choices.IsEmpty() )
ResyncBitmapOnly();
}
// Get Current Item #
int LAYER_BOX_SELECTOR::GetChoice()
{
@ -67,6 +84,9 @@ int LAYER_BOX_SELECTOR::GetChoice()
// Get Current Layer
LAYER_NUM LAYER_BOX_SELECTOR::GetLayerSelection() const
{
if( GetSelection() < 0 )
return UNDEFINED_LAYER;
return (LAYER_NUM)(intptr_t) GetClientData( GetSelection() );
}
@ -104,21 +124,3 @@ void LAYER_BOX_SELECTOR::ResyncBitmapOnly()
SetBitmapLayer( layerbmp, i );
}
}
void LAYER_BOX_SELECTOR::SetBitmapLayer( wxBitmap& aLayerbmp, LAYER_NUM aLayer )
{
wxMemoryDC bmpDC;
wxBrush brush;
// Prepare Bitmap
bmpDC.SelectObject( aLayerbmp );
brush.SetColour( MakeColour( GetLayerColor( aLayer ) ) );
brush.SetStyle( wxSOLID );
bmpDC.SetBrush( brush );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
bmpDC.SetBrush( *wxTRANSPARENT_BRUSH );
bmpDC.SetPen( *wxBLACK_PEN );
bmpDC.DrawRectangle( 0, 0, aLayerbmp.GetWidth(), aLayerbmp.GetHeight() );
}

View File

@ -64,18 +64,16 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" );
* the size of the array. */
#define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / sizeof( struct LANGUAGE_DESCR ) )
// Default font size
#define FONT_DEFAULT_SIZE 10 // Default font size.
// some key strings used to store parameters in config
static wxString backgroundColorKey( wxT( "BackgroundColor" ) );
static wxString showPageLimitsKey( wxT( "ShowPageLimits" ) );
static wxString workingDirKey( wxT( "WorkingDir" ) ) ;
static wxString languageCfgKey( wxT( "LanguageID" ) );
static wxString kicadFpLibPath( wxT( "KicadFootprintLibraryPath" ) );
/**
* The real font size will be computed at run time
* A small class to handle the list on existing translations.
* the locale translation is automatic.
* the selection of languages is mainly for maintainer's convenience
@ -354,7 +352,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId )
wxImage::AddHandler( new wxJPEGHandler );
wxFileSystem::AddHandler( new wxZipFSHandler );
// Analise the command line & init binary path
// Analyze the command line & init binary path
SetBinDir();
SetDefaultSearchPaths();
SetLanguagePath();
@ -496,24 +494,20 @@ void EDA_APP::SetDefaultSearchPaths( void )
* if the user is savvy enough to set an environment variable they know
* what they are doing. */
if( ::wxGetEnv( wxT( "KICAD" ), NULL ) )
m_searchPaths.AddEnvList( wxT( "KICAD" ) );
tmp.AddEnvList( wxT( "KICAD" ) );
// Add the user's home path.
m_searchPaths.Add( GetTraits()->GetStandardPaths().GetUserDataDir() );
tmp.Add( GetTraits()->GetStandardPaths().GetUserDataDir() );
// Standard application data path if it is different from the binary path.
if( fn.GetPath() != GetTraits()->GetStandardPaths().GetDataDir() )
{
m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() );
tmp.Add( GetTraits()->GetStandardPaths().GetDataDir() );
}
// Up one level relative to binary path with "share" appended for Windows.
fn.RemoveLastDir();
m_searchPaths.Add( fn.GetPath() );
fn.AppendDir( wxT( "share" ) );
m_searchPaths.Add( fn.GetPath() );
fn.AppendDir( wxT( "kicad" ) );
m_searchPaths.Add( fn.GetPath() );
tmp.Add( fn.GetPath() );
/* The normal OS program file install paths allow for binary to be
* installed in a different path from the library files. This is
@ -524,13 +518,16 @@ void EDA_APP::SetDefaultSearchPaths( void )
#ifdef __WXMSW__
tmp.AddEnvList( wxT( "PROGRAMFILES" ) );
#elif __WXMAC__
m_searchPaths.Add( wxT( "/Library/Application Support/kicad" ) );
m_searchPaths.Add( wxString( wxGetenv( wxT( "HOME" ) ) ) +
wxT("/Library/Application Support/kicad") );
tmp.Add( wxT( "/Library/Application Support" ) );
tmp.Add( wxString( wxGetenv( wxT( "HOME" ) ) ) + wxT( "/Library/Application Support" ) );
#else
tmp.AddEnvList( wxT( "PATH" ) );
#endif
// This is the equivalent of CMAKE_INSTALL_PREFIX. Useful when installed by `make install`.
tmp.Add( wxT( DEFAULT_INSTALL_PATH ) );
// Add kicad, kicad/share, share, and share/kicad to each possible base path.
for( i = 0; i < tmp.GetCount(); i++ )
{
fn = wxFileName( tmp[i], wxEmptyString );
@ -621,6 +618,13 @@ void EDA_APP::SetDefaultSearchPaths( void )
fn.RemoveLastDir();
}
}
#if 0 && defined( DEBUG )
wxLogDebug( wxT( "Library search paths:" ) );
for( unsigned i = 0; i < m_libSearchPaths.GetCount(); i++ )
wxLogDebug( wxT( " %s" ), GetChars( m_libSearchPaths[i] ) );
#endif
}
@ -662,11 +666,14 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory )
}
// FIXME OSX Mountain Lion (10.8)
// Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce on 10.7
// In general terms i think is better have a failsafe default than an uninit variable
// Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce
// on 10.7
// In general terms I think is better have a failsafe default than an uninit variable
int draw_bg_color = (int)BLACK; // Default for all apps but Eeschema
if( m_Id == APP_EESCHEMA_T )
draw_bg_color = (int)WHITE; // Default for Eeschema
m_settings->Read( backgroundColorKey, &draw_bg_color );
g_DrawBgColor = ColorFromInt( draw_bg_color );
@ -876,7 +883,7 @@ void EDA_APP::AddMenuLanguageList( wxMenu* MasterMenu )
wxString EDA_APP::FindFileInSearchPaths( const wxString& filename,
const wxArrayString* subdirs )
const wxArrayString* subdirs )
{
size_t i, j;
wxFileName fn;
@ -979,21 +986,6 @@ wxString EDA_APP::GetHelpFile( void )
}
wxString EDA_APP::GetLibraryFile( const wxString& filename )
{
wxArrayString subdirs;
subdirs.Add( wxT( "share" ) );
#ifndef __WXMSW__
/* Up on level relative to binary path with "share/kicad" appended for
* all other platforms. */
subdirs.Add( wxT( "kicad" ) );
#endif
return FindFileInSearchPaths( filename, &subdirs );
}
wxString EDA_APP::ReturnLastVisitedLibraryPath( const wxString& aSubPathToSearch )
{
if( !m_LastVisitedLibPath.IsEmpty() )
@ -1164,3 +1156,52 @@ bool EDA_APP::LockFile( const wxString& fileName )
return true;
}
bool EDA_APP::SetFootprintLibTablePath()
{
wxString path;
// Set the KISYSMOD environment variable for the current process if it is not already
// defined in the user's environment. This is required to expand the global footprint
// library table paths.
if( wxGetEnv( wxT( "KISYSMOD" ), &path ) && wxFileName::DirExists( path ) )
return true;
// Set the KISYSMOD environment variable to the path defined in the user's configuration
// if it is defined and the path exists.
if( m_commonSettings->Read( kicadFpLibPath, &path ) && wxFileName::DirExists( path ) )
{
wxSetEnv( wxT( "KISYSMOD" ), path );
return true;
}
// Attempt to determine where the footprint libraries were installed using the legacy
// library search paths.
if( !GetLibraryPathList().IsEmpty() )
{
unsigned modFileCount = 0;
wxString bestPath;
wxArrayString tmp;
for( unsigned i = 0; i < GetLibraryPathList().GetCount(); i++ )
{
unsigned cnt = wxDir::GetAllFiles( GetLibraryPathList()[i], &tmp, wxT( "*.mod" ),
wxDIR_FILES );
if( cnt > modFileCount )
{
modFileCount = cnt;
bestPath = GetLibraryPathList()[i];
}
}
if( modFileCount != 0 )
{
wxSetEnv( wxT( "KISYSMOD" ), bestPath );
return true;
}
}
return false;
}

View File

@ -39,6 +39,7 @@
#include <footprint_info.h>
#include <io_mgr.h>
#include <fp_lib_table.h>
#include <fpid.h>
#include <class_module.h>
@ -182,6 +183,31 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
}
FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString & aFootprintName )
{
BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List )
{
#if defined( USE_FP_LIB_TABLE )
FPID fpid;
wxCHECK_MSG( fpid.Parse( aFootprintName ) < 0, NULL,
wxString::Format( wxT( "<%s> is not a valid FPID." ),
GetChars( aFootprintName ) ) );
wxString libNickname = FROM_UTF8( fpid.GetLibNickname().c_str() );
wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() );
if( libNickname == footprint.m_libName && footprintName == footprint.m_Module )
return &footprint;
#else
if( aFootprintName.CmpNoCase( footprint.m_Module ) == 0 )
return &footprint;
#endif
}
return NULL;
}
bool FOOTPRINT_INFO::InLibrary( const wxString& aLibrary ) const
{
if( aLibrary.IsEmpty() )

View File

@ -30,10 +30,15 @@
#include <set>
#include <appl_wxstruct.h>
#include <pcb_netlist.h>
#include <reporter.h>
#include <footprint_info.h>
#include <wildcards_and_files_ext.h>
#include <fpid.h>
#include <fp_lib_table_lexer.h>
#include <fp_lib_table.h>
using namespace FP_LIB_TABLE_T;
@ -98,7 +103,6 @@ void FP_LIB_TABLE::Parse( FP_LIB_TABLE_LEXER* in ) throw( IO_ERROR, PARSE_ERROR
// After (name), remaining (lib) elements are order independent, and in
// some cases optional.
bool sawType = false;
bool sawOpts = false;
bool sawDesc = false;
@ -250,6 +254,35 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::findRow( const wxString& aNickName )
}
const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRowByURI( const wxString& aURI )
{
FP_LIB_TABLE* cur = this;
do
{
cur->ensureIndex();
for( unsigned i = 0; i < cur->rows.size(); i++ )
{
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() );
if( wxFileName::GetPathSeparator() == wxChar( '\\' ) && uri.Find( wxChar( '/' ) ) >= 0 )
uri.Replace( wxT( "/" ), wxT( "\\" ) );
if( (wxFileName::IsCaseSensitive() && uri == aURI)
|| (!wxFileName::IsCaseSensitive() && uri.Upper() == aURI.Upper() ) )
{
return &cur->rows[i]; // found
}
}
// not found, search fall back table(s), if any
} while( ( cur = cur->fallBack ) != 0 );
return 0; // not found
}
bool FP_LIB_TABLE::InsertRow( const ROW& aRow, bool doReplace )
{
ensureIndex();
@ -280,8 +313,8 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aLibraryNickName
if( !row )
{
wxString msg = wxString::Format( _("lib table contains no logical lib '%s'" ),
GetChars( aLibraryNickName ) );
wxString msg = wxString::Format( _( "lib table contains no logical lib '%s'" ),
GetChars( aLibraryNickName ) );
THROW_IO_ERROR( msg );
}
@ -319,23 +352,205 @@ bool FP_LIB_TABLE::IsEmpty() const
}
void FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
bool FP_LIB_TABLE::MissingLegacyLibs( const wxArrayString& aLibNames, wxString* aErrorMsg )
{
wxFileName fn = GetGlobalTableFileName();
bool retv = false;
wxLogDebug( wxT( "Loading global footprint table file: %s" ), GetChars( fn.GetFullPath() ) );
for( unsigned i = 0; i < aLibNames.GetCount(); i++ )
{
wxFileName fn = wxFileName( wxEmptyString, aLibNames[i], LegacyFootprintLibPathExtension );
wxString legacyLibPath = wxGetApp().FindLibraryPath( fn );
if( legacyLibPath.IsEmpty() )
continue;
if( FindRowByURI( legacyLibPath ) == 0 )
{
retv = true;
if( aErrorMsg )
*aErrorMsg += wxT( "\"" ) + legacyLibPath + wxT( "\"\n" );
}
}
return retv;
}
bool FP_LIB_TABLE::ConvertFromLegacy( NETLIST& aNetList, const wxArrayString& aLibNames,
REPORTER* aReporter ) throw( IO_ERROR )
{
wxString msg;
FPID lastFPID;
COMPONENT* component;
MODULE* module = 0;
bool retv = true;
if( aNetList.IsEmpty() )
return true;
aNetList.SortByFPID();
wxString libPath;
wxFileName fn;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned ii = 0; ii < aNetList.GetCount(); ii++ )
{
component = aNetList.GetComponent( ii );
// The footprint hasn't been assigned yet so ignore it.
if( component->GetFPID().empty() )
continue;
if( component->GetFPID() != lastFPID )
{
module = NULL;
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
{
fn = wxFileName( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
libPath = wxGetApp().FindLibraryPath( fn );
if( !libPath )
{
if( aReporter )
{
msg.Printf( _( "Cannot find footprint library file \"%s\" in any of the "
"KiCad legacy library search paths.\n" ),
GetChars( fn.GetFullPath() ) );
aReporter->Report( msg );
}
retv = false;
continue;
}
module = pi->FootprintLoad( libPath,
FROM_UTF8( component->GetFPID().GetFootprintName().c_str() ) );
if( module )
{
lastFPID = component->GetFPID();
break;
}
}
}
if( module == NULL )
{
if( aReporter )
{
msg.Printf( _( "Component `%s` footprint <%s> was not found in any legacy "
"library.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
aReporter->Report( msg );
}
// Clear the footprint assignment since the old library lookup method is no
// longer valid.
FPID emptyFPID;
component->SetFPID( emptyFPID );
retv = false;
continue;
}
else
{
wxString libNickname;
FP_LIB_TABLE* cur = this;
do
{
cur->ensureIndex();
for( unsigned i = 0; i < cur->rows.size(); i++ )
{
wxString uri = ExpandSubstitutions( cur->rows[i].GetFullURI() );
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 )
uri.Replace( wxT( "/"), wxT( "\\" ) );
if( uri == libPath )
{
libNickname = cur->rows[i].GetNickName();
break;
}
}
} while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() );
if( libNickname.IsEmpty() )
{
if( aReporter )
{
msg.Printf( _( "Component `%s` footprint <%s> legacy library path <%s > "
"was not found in the footprint library table.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
aReporter->Report( msg );
}
retv = false;
}
else
{
FPID newFPID = lastFPID;
newFPID.SetLibNickname( libNickname );
if( !newFPID.IsValid() )
{
msg.Printf( _( "Component `%s` FPID <%s> is not valid.\n" ),
GetChars( component->GetReference() ),
GetChars( FROM_UTF8( newFPID.Format().c_str() ) ) );
aReporter->Report( msg );
retv = false;
}
else
{
// The footprint name should already be set.
component->SetFPID( newFPID );
}
}
}
}
return retv;
}
bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARSE_ERROR )
{
bool tableExists = true;
wxFileName fn = GetGlobalTableFileName();
if( !fn.FileExists() )
{
/// @todo call some script to create initial global footprint table.
}
else
{
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
tableExists = false;
aTable.Parse( &lexer );
// Attempt to copy the default global file table from the KiCad template folder to
// the users home configuration path.
wxString fileName( wxT( "fp_global_table" ) );
fileName = wxGetApp().FindLibraryPath( fileName );
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
emptyTable.Format( &sf, 0 );
}
}
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
aTable.Parse( &lexer );
return tableExists;
}
@ -357,7 +572,26 @@ wxString FP_LIB_TABLE::GetGlobalTableFileName()
wxString FP_LIB_TABLE::GetFileName()
{
return wxString( wxT( ".fp-lib-table" ) );
return wxString( wxT( "fp-lib-table" ) );
}
void FP_LIB_TABLE::Load( const wxFileName& aFileName, FP_LIB_TABLE* aFallBackTable )
throw( IO_ERROR )
{
wxFileName fn = aFileName;
fallBack = aFallBackTable;
fn.SetName( FP_LIB_TABLE::GetFileName() );
fn.SetExt( wxEmptyString );
if( fn.FileExists() )
{
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
Parse( &lexer );
}
}

View File

@ -27,6 +27,7 @@
#include <memory>
#include <wx/wx.h> // _()
#include <macros.h> // TO_UTF8()
#include <fpid.h>
@ -170,6 +171,12 @@ int FPID::Parse( const std::string& aId )
}
int FPID::Parse( const wxString& aId )
{
return Parse( std::string( TO_UTF8( aId ) ) );
}
FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
{
int offset = Parse( aId );
@ -185,6 +192,23 @@ FPID::FPID( const std::string& aId ) throw( PARSE_ERROR )
}
FPID::FPID( const wxString& aId ) throw( PARSE_ERROR )
{
std::string id = TO_UTF8( aId );
int offset = Parse( id );
if( offset != -1 )
{
THROW_PARSE_ERROR( _( "Illegal character found in FPID string" ),
wxString::FromUTF8( id.c_str() ),
id.c_str(),
0,
offset );
}
}
int FPID::SetLibNickname( const std::string& aLogical )
{
int offset = okLogical( aLogical );
@ -198,6 +222,12 @@ int FPID::SetLibNickname( const std::string& aLogical )
}
int FPID::SetLibNickname( const wxString& aLogical )
{
return SetLibNickname( std::string( TO_UTF8( aLogical ) ) );
}
int FPID::SetFootprintName( const std::string& aFootprintName )
{
int separation = int( aFootprintName.find_first_of( "/" ) );
@ -216,6 +246,12 @@ int FPID::SetFootprintName( const std::string& aFootprintName )
}
int FPID::SetFootprintName( const wxString& aFootprintName )
{
return SetFootprintName( std::string( TO_UTF8( aFootprintName ) ) );
}
int FPID::SetRevision( const std::string& aRevision )
{
int offset = okRevision( aRevision );

View File

@ -1,5 +1,5 @@
/**
* @file class_worksheet_layuout.cpp
* @file class_worksheet_layout.cpp
* @brief description of graphic items and texts to build a title block
*/

View File

@ -1,5 +1,5 @@
/**
* @file page_layout_default_description.cpp
* @file common/page_layout/page_layout_default_description.cpp
*/
/*

View File

@ -1,5 +1,5 @@
/**
* @file page_layout_reader.cpp
* @file common/page_layout/page_layout_reader.cpp
* @brief read an S expression of description of graphic items and texts
* to build a title block and page layout
*/

View File

@ -1,5 +1,5 @@
/**
* @file title_block_shape.cpp
* @file title_block_shapes.cpp
* @brief description of graphic items and texts to build a title block
*/

View File

@ -1,5 +1,5 @@
/**
* @file title_block_shape_gost.h
* @file title_block_shapes_gost.cpp
* @brief description of graphic items and texts to build a title block
* using GOST standard
*/

View File

@ -1,5 +1,5 @@
/**
* @file page_layout_default_description.cpp
* @file common/page_layout_default_description.cpp
*/
/*

View File

@ -1,5 +1,5 @@
/**
* @file page_layout_reader.cpp
* @file common/page_layout_reader.cpp
* @brief read an S expression of description of graphic items and texts
* to build a title block and page layout
*/

View File

@ -39,6 +39,7 @@ autoplace_cost90
autoplace_cost180
aux_axis_origin
blind
blind_buried_vias_allowed
bold
bottom
center

View File

@ -1,5 +1,5 @@
/**
* @file reporter.h
* @file reporter.cpp
*/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
@ -43,3 +43,13 @@ REPORTER& WX_TEXT_CTRL_REPORTER::Report( const wxString& aText )
m_textCtrl->AppendText( aText );
return *this;
}
REPORTER& WX_STRING_REPORTER::Report( const wxString& aText )
{
wxCHECK_MSG( m_string != NULL, *this,
wxT( "No wxString object defined in WX_STRING_REPORTER." ) );
*m_string << aText;
return *this;
}

View File

@ -9,6 +9,7 @@ include_directories(
./dialogs
../3d-viewer
../pcbnew
../pcbnew/dialogs
../polygon
../common
${INC_AFTER}
@ -22,6 +23,8 @@ set( CVPCB_DIALOGS
dialogs/dialog_cvpcb_config_fbp.cpp
dialogs/dialog_display_options.cpp
dialogs/dialog_display_options_base.cpp
../pcbnew/dialogs/dialog_fp_lib_table.cpp
../pcbnew/dialogs/dialog_fp_lib_table_base.cpp
)
set( CVPCB_SRCS

View File

@ -165,7 +165,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
bool found = false;
m_ListCmp->SetSelection( ii++, true );
if( !component->GetFootprintName().IsEmpty() )
if( !component->GetFPID().empty() )
continue;
BOOST_FOREACH( FOOTPRINT_ALIAS& alias, aliases )

View File

@ -1,6 +1,30 @@
/*************/
/** cfg.cpp **/
/*************/
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2007 Jean-Pierre Charras, jean-pierre.charras
* 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 cfg.cpp
*/
#include <fctsys.h>
#include <appl_wxstruct.h>
@ -9,6 +33,8 @@
#include <gestfich.h>
#include <param_config.h>
#include <wildcards_and_files_ext.h>
#include <fp_lib_table.h>
#include <confirm.h>
#include <cvpcb.h>
#include <cvpcb_mainframe.h>
@ -59,8 +85,24 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" );
/* User library path takes precedent over default library search paths. */
// User library path takes precedent over default library search paths.
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
#if defined( USE_FP_LIB_TABLE )
delete m_footprintLibTable;
// Attempt to load the project footprint library table if it exists.
m_footprintLibTable = new FP_LIB_TABLE();
try
{
m_footprintLibTable->Load( fn, m_globalFootprintTable );
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
#endif
}

View File

@ -36,6 +36,9 @@
#include <bitmaps.h>
#include <msgpanel.h>
#include <wildcards_and_files_ext.h>
#include <fpid.h>
#include <fp_lib_table.h>
#include <pcbcommon.h>
#include <io_mgr.h>
#include <class_module.h>
@ -473,10 +476,59 @@ EDA_COLOR_T DISPLAY_FOOTPRINTS_FRAME::GetGridColor() const
MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
{
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
MODULE* footprint = NULL;
try
{
#if defined( USE_FP_LIB_TABLE )
FPID fpid;
if( fpid.Parse( aFootprintName ) >= 0 )
{
DisplayInfoMessage( this, wxString::Format( wxT( "Footprint ID <%s> is not valid." ),
GetChars( aFootprintName ) ) );
return NULL;
}
wxString libName = FROM_UTF8( fpid.GetLibNickname().c_str() );
wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ),
fpid.GetFootprintName().c_str(), fpid.GetLibNickname().c_str() );
const FP_LIB_TABLE::ROW* row;
try
{
row = m_footprintLibTable->FindRow( libName );
if( row == NULL )
{
wxString msg;
msg.Printf( _( "No library named <%s> was found in the footprint library table." ),
fpid.GetLibNickname().c_str() );
DisplayInfoMessage( this, msg );
return NULL;
}
}
catch( IO_ERROR ioe )
{
DisplayError( this, ioe.errorText );
}
wxString footprintName = FROM_UTF8( fpid.GetFootprintName().c_str() );
wxString libPath = row->GetFullURI();
libPath = FP_LIB_TABLE::ExpandSubstitutions( libPath );
wxLogDebug( wxT( "Loading footprint <%s> from library <%s>." ),
GetChars( footprintName ), GetChars( libPath ) );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) );
footprint = pi->FootprintLoad( libPath, footprintName );
#else
CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent();
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
for( unsigned i = 0; i < parent->m_ModuleLibNames.GetCount(); ++i )
@ -493,19 +545,16 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
fn.GetFullName().GetData() );
// @todo we should not be using wxMessageBox directly.
wxMessageBox( msg, titleLibLoadError, wxOK | wxICON_ERROR, this );
wxMessageBox( msg, wxEmptyString, wxOK | wxICON_ERROR, this );
continue;
}
MODULE* footprint = pi->FootprintLoad( libPath, aFootprintName );
footprint = pi->FootprintLoad( libPath, aFootprintName );
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
if( footprint != NULL )
break;
}
#endif
}
catch( IO_ERROR ioe )
{
@ -513,6 +562,13 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
return NULL;
}
if( footprint )
{
footprint->SetParent( (EDA_ITEM*) GetBoard() );
footprint->SetPosition( wxPoint( 0, 0 ) );
return footprint;
}
wxString msg = wxString::Format( _( "Footprint '%s' not found" ), aFootprintName.GetData() );
DisplayError( this, msg );
return NULL;
@ -532,6 +588,7 @@ void DISPLAY_FOOTPRINTS_FRAME::InitDisplay()
FOOTPRINT_INFO* module_info = parentframe->m_footprints.GetModuleInfo( footprintName );
const wxChar *libname;
if( module_info )
libname = GetChars( module_info->GetLibraryPath() );
else

View File

@ -22,7 +22,7 @@
*/
/**
* @file class_components_listbox.h
* @file class_components_listbox.cpp
*/
#include <fctsys.h>

View File

@ -135,8 +135,14 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
{
if( aFilterType == UNFILTERED )
{
#if !defined( USE_FP_LIB_TABLE )
msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).m_Module ) );
#else
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetLibraryName() ),
GetChars( aList.GetItem( ii ).m_Module ) );
#endif
newList.Add( msg );
continue;
}
@ -153,8 +159,14 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
&& (aComponent->GetNetCount() != aList.GetItem( ii ).m_padCount) )
continue;
#if !defined( USE_FP_LIB_TABLE )
msg.Printf( wxT( "%3zu %s" ), newList.GetCount() + 1,
aList.GetItem( ii ).m_Module.GetData() );
#else
msg.Printf( wxT( "%3zu %s:%s" ), newList.GetCount() + 1,
GetChars( aList.GetItem( ii ).GetLibraryName() ),
GetChars( aList.GetItem( ii ).m_Module ) );
#endif
newList.Add( msg );
}
@ -169,9 +181,24 @@ void FOOTPRINTS_LISTBOX::SetFootprints( FOOTPRINT_LIST& aList, const wxString& a
selection = 0;
DeleteAllItems();
SetItemCount( m_footprintList.GetCount() );
SetSelection( selection, true );
Refresh();
if( m_footprintList.GetCount() )
{
SetItemCount( m_footprintList.GetCount() );
SetSelection( selection, true );
RefreshItems( 0L, m_footprintList.GetCount()-1 );
#if defined (__WXGTK__ )
// @bug On GTK and wxWidgets 2.8.x, this will assert in debug builds because the
// column parameter is -1. This was the only way to prevent GTK3 from
// ellipsizing long strings down to a few characters. It still doesn't set
// the scroll bars correctly (too short) but it's better than any of the
// other alternatives. If someone knows how to fix this, please do.
SetColumnWidth( -1, wxLIST_AUTOSIZE );
#else
SetColumnWidth( 0, wxLIST_AUTOSIZE );
#endif
}
}

Some files were not shown because too many files have changed in this diff Show More