diff --git a/CMakeLists.txt b/CMakeLists.txt index 6195bbd65a..d34e3d2a45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,16 +49,10 @@ option( KICAD_SCRIPTING_WXPYTHON option( USE_FP_LIB_TABLE "Use the new footprint library table implementation. ( default OFF)" ) -# BUILD_GITHUB_PLUGIN for MINGW is pretty demanding due to download_openssl.cmake and openssl's -# use of perl to drive its configure step. You might find it works in a cross builder say on linux. -# Dick is not personally supporting Windows any more with this exotic stuff. Some other windows -# developer will have to smooth out the build issues. So enable this for MINGW without my help but -# with my best wishes. option( BUILD_GITHUB_PLUGIN "Build the GITHUB_PLUGIN for pcbnew." OFF ) -#Set version option (stable or testing) - +# Set version option (stable or testing) if( KICAD_STABLE_VERSION) add_definitions( -DKICAD_STABLE_VERSION ) message( STATUS "Building stable version of KiCad" ) diff --git a/CMakeModules/download_avhttp.cmake b/CMakeModules/download_avhttp.cmake index 35c6195c65..6fa9f423b4 100644 --- a/CMakeModules/download_avhttp.cmake +++ b/CMakeModules/download_avhttp.cmake @@ -56,4 +56,4 @@ ExternalProject_Add( avhttp set( AVHTTP_INCLUDE_DIR "${PREFIX}/include" CACHE FILEPATH "AVHTTP include directory" ) - +mark_as_advanced( AVHTTP_INCLUDE_DIR ) diff --git a/CMakeModules/download_boost.cmake b/CMakeModules/download_boost.cmake index d16fed7bc7..6df019a3f2 100644 --- a/CMakeModules/download_boost.cmake +++ b/CMakeModules/download_boost.cmake @@ -42,6 +42,8 @@ if( BUILD_GITHUB_PLUGIN ) # Chosen libraries are based on AVHTTP requirements, and possibly # unit_test_framework for its own worth. set( BOOST_LIBS_BUILT + context + #coroutine date_time #exception filesystem @@ -172,14 +174,17 @@ if( BUILD_GITHUB_PLUGIN ) set( boost_libs "" ) set_boost_lib_names( "${BOOST_LIBS_BUILT}" boost_libs ) - #message( STATUS "BOOST_ROOT:${BOOST_ROOT} boost_libs:${boost_libs}" ) + set( Boost_LIBRARIES ${boost_libs} CACHE FILEPATH "Boost libraries directory" ) set( Boost_INCLUDE_DIR "${BOOST_INCLUDE}" CACHE FILEPATH "Boost include directory" ) + + mark_as_advanced( Boost_LIBRARIES Boost_INCLUDE_DIR ) + + #message( STATUS "BOOST_ROOT:${BOOST_ROOT} BOOST_LIBRARIES:${BOOST_LIBRARIES}" ) #message( STATUS "Boost_INCLUDE_DIR: ${Boost_INCLUDE_DIR}" ) else( BUILD_GITHUB_PLUGIN ) - ExternalProject_Add( boost PREFIX "${PREFIX}" DOWNLOAD_DIR "${DOWNLOAD_DIR}" diff --git a/TODO.txt b/TODO.txt index 621a2e828c..5fbb609bd0 100644 --- a/TODO.txt +++ b/TODO.txt @@ -151,11 +151,5 @@ Dick's Final TODO List: *) Get licensing cleaned up. *) Re-arrange the repo architecture. *) Merge KiCad GAL/TOM/ORSON if nobody else does. -*) lib_convert.py (i.e. convert) all footprint libraries to pretty format and move copy them to - github if nobody else does. -*) DLL-ization of pcbnew eeschema -*) Pass options, i.e. PROPERTIES to all PLUGIN::Footprint*() calls. Current code needs - to be based on NickNames, not Libpaths, so we have access to the FP_LIB_TABLE::ROWs. - User should not be prompted for a libpath for reading from it, he/she must pick from the - known list of nicknames. Possibly duplicate some of the PLUGIN:::Footprint*() api in ROW or - FP_LIB_TABLE. Again, limited to PLUGIN::Footprint*() calls, not Load() and Save(). +*) DLL-ization of pcbnew & eeschema + http://www.eevblog.com/forum/open-source-kicad-geda/seriously-irritated-with-the-library-editor!/ diff --git a/common/footprint_info.cpp b/common/footprint_info.cpp index 516b484d6d..c2b45d6496 100644 --- a/common/footprint_info.cpp +++ b/common/footprint_info.cpp @@ -43,8 +43,9 @@ #include +#if !defined( USE_FP_LIB_TABLE ) -bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) +bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintLibNames ) { bool retv = true; @@ -58,10 +59,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) ); // Parse Libraries Listed - for( unsigned ii = 0; ii < aFootprintsLibNames.GetCount(); ii++ ) + for( unsigned ii = 0; ii < aFootprintLibNames.GetCount(); ii++ ) { // Footprint library file names can be fully qualified or file name only. - wxFileName filename = aFootprintsLibNames[ii]; + wxFileName filename = aFootprintLibNames[ii]; if( !filename.FileExists() ) { @@ -69,19 +70,19 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) if( !filename.FileExists() ) { - filename = wxFileName( wxEmptyString, aFootprintsLibNames[ii], + filename = wxFileName( wxEmptyString, aFootprintLibNames[ii], LegacyFootprintLibPathExtension ); filename = wxGetApp().FindLibraryPath( filename.GetFullName() ); } } - wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ), + wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintLibNames[ii] ), GetChars( filename.GetFullPath() ) ); if( !filename.IsOk() || !filename.FileExists() ) { - m_filesNotFound << aFootprintsLibNames[ii] << wxT( "\n" ); + m_filesNotFound << aFootprintLibNames[ii] << wxT( "\n" ); retv = false; continue; } @@ -131,8 +132,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) return retv; } +#else -bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) +bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname ) { bool retv = true; @@ -141,44 +143,35 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) m_filesInvalid.Empty(); m_List.clear(); - std::vector< wxString > libNickNames = aTable.GetLogicalLibs(); + std::vector< wxString > nicknames; - // Parse Libraries Listed - for( unsigned ii = 0; ii < libNickNames.size(); ii++ ) + if( !aNickname ) + // do all of them + nicknames = aTable->GetLogicalLibs(); + else + nicknames.push_back( *aNickname ); + + for( unsigned ii = 0; ii < nicknames.size(); ii++ ) { - const FP_LIB_TABLE::ROW* row = aTable.FindRow( libNickNames[ii] ); + const wxString& nickname = nicknames[ii]; - wxCHECK2_MSG( row != NULL, retv = false; continue, - wxString::Format( wxT( "No library name <%s> found in footprint library " - "table." ), GetChars( libNickNames[ii] ) ) ); try { - PLUGIN* plugin = IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ); - - if( plugin == NULL ) - { - m_filesNotFound << wxString::Format( _( "Cannot find plugin type '%s'." ), - GetChars( row->GetType() ) ); - retv = false; - continue; - } - - PLUGIN::RELEASER pi( plugin ); - - wxString path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() ); - wxArrayString fpnames = pi->FootprintEnumerate( path ); + wxArrayString fpnames = aTable->FootprintEnumerate( nickname ); for( unsigned i=0; i m( pi->FootprintLoad( path, fpnames[i] ) ); + std::auto_ptr m( aTable->FootprintLoad( nickname, fpnames[i] ) ); // we're loading what we enumerated, all must be there. wxASSERT( m.get() ); FOOTPRINT_INFO* fpinfo = new FOOTPRINT_INFO(); - fpinfo->SetLibraryName( libNickNames[ii] ); - fpinfo->SetLibraryPath( path ); + fpinfo->SetLibraryName( nickname ); + + //fpinfo->SetLibraryPath( path ); + fpinfo->m_Module = fpnames[i]; fpinfo->m_padCount = m->GetPadCount( MODULE::DO_NOT_INCLUDE_NPTH ); fpinfo->m_KeyWord = m->GetKeywords(); @@ -199,8 +192,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) return retv; } +#endif // USE_FP_LIB_TABLE -FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString & aFootprintName ) +FOOTPRINT_INFO* FOOTPRINT_LIST::GetModuleInfo( const wxString& aFootprintName ) { BOOST_FOREACH( FOOTPRINT_INFO& footprint, m_List ) { diff --git a/common/fp_lib_table.cpp b/common/fp_lib_table.cpp index 186505514b..ace123d410 100644 --- a/common/fp_lib_table.cpp +++ b/common/fp_lib_table.cpp @@ -38,6 +38,7 @@ #include #include #include +#include using namespace FP_LIB_TABLE_T; @@ -97,7 +98,23 @@ MODULE* FP_LIB_TABLE::FootprintLoad( const wxString& aNickname, const wxString& { const ROW* row = FindRow( aNickname ); wxASSERT( (PLUGIN*) row->plugin ); - return row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName, row->GetProperties() ); + + MODULE* ret = row->plugin->FootprintLoad( row->GetFullURI( true ), aFootprintName, row->GetProperties() ); + + // The library cannot know its own name, because it might have been renamed or moved. + // Therefore footprints cannot know their own library nickname when residing in + // a footprint library. + // Only at this API layer can we tell the footprint about its actual library nickname. + if( ret ) + { + // remove "const"-ness, I really do want to set nickname without + // having to copy the FPID and its two strings, twice each. + FPID& fpid = (FPID&) ret->GetFPID(); + + fpid.SetLibNickname( row->GetNickName() ); + } + + return ret; } @@ -296,58 +313,60 @@ void FP_LIB_TABLE::Save( const wxFileName& aPath ) const throw( IO_ERROR ) PROPERTIES* FP_LIB_TABLE::ParseOptions( const std::string& aOptionsList ) { - const char* cp = &aOptionsList[0]; - const char* end = cp + aOptionsList.size(); - - PROPERTIES props; - std::string pair; - - // Parse all name=value pairs - while( cp < end ) + if( aOptionsList.size() ) { - pair.clear(); + const char* cp = &aOptionsList[0]; + const char* end = cp + aOptionsList.size(); - // Skip leading white space. - while( cp < end && isspace( *cp ) ) - ++cp; + PROPERTIES props; + std::string pair; - // Find the end of pair/field + // Parse all name=value pairs while( cp < end ) { - if( *cp=='\\' && cp+1plugin ) row->setPlugin( IO_MGR::PluginFind( row->type ) ); -#endif return row; } diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index f3f0bf7822..768a7b8c38 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -25,6 +25,8 @@ set( CVPCB_DIALOGS dialogs/dialog_display_options_base.cpp ../pcbnew/dialogs/dialog_fp_lib_table.cpp ../pcbnew/dialogs/dialog_fp_lib_table_base.cpp + ../pcbnew/dialogs/dialog_fp_plugin_options.cpp + ../pcbnew/dialogs/dialog_fp_plugin_options_base.cpp ) set( CVPCB_SRCS diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 4d4a1e6f74..5a077766a7 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -490,42 +490,13 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName ) return NULL; } - wxString libName = FROM_UTF8( fpid.GetLibNickname().c_str() ); + std::string nickname = fpid.GetLibNickname(); + std::string fpname = fpid.GetFootprintName(); wxLogDebug( wxT( "Load footprint <%s> from library <%s>." ), - fpid.GetFootprintName().c_str(), fpid.GetLibNickname().c_str() ); + fpname.c_str(), nickname.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 ); + footprint = m_footprintLibTable->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) ); #else CVPCB_MAINFRAME* parent = ( CVPCB_MAINFRAME* ) GetParent(); diff --git a/cvpcb/cvframe.cpp b/cvpcb/cvframe.cpp index 08e669e7d8..2c3ac40d53 100644 --- a/cvpcb/cvframe.cpp +++ b/cvpcb/cvframe.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -57,16 +58,6 @@ static const wxString KeepCvpcbOpenEntry( wxT( "KeepCvpcbOpen" ) ); static const wxString FootprintDocFileEntry( wxT( "footprints_doc_file" ) ); -/** - * Function InvokePcbLibTableEditor - * shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables. - * - * @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal - * and/or the @a aProject table, respectively. If set, table was modified. - */ -int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ); - - BEGIN_EVENT_TABLE( CVPCB_MAINFRAME, EDA_BASE_FRAME ) EVT_MENU_RANGE( wxID_FILE1, wxID_FILE9, CVPCB_MAINFRAME::LoadNetList ) @@ -750,7 +741,7 @@ bool CVPCB_MAINFRAME::LoadFootprintFiles() m_footprints.ReadFootprintFiles( m_ModuleLibNames ); #else if( m_footprintLibTable != NULL ) - m_footprints.ReadFootprintFiles( *m_footprintLibTable ); + m_footprints.ReadFootprintFiles( m_footprintLibTable ); #endif // Display error messages, if any. diff --git a/include/footprint_info.h b/include/footprint_info.h index 0035938cfa..4feb367836 100644 --- a/include/footprint_info.h +++ b/include/footprint_info.h @@ -126,28 +126,22 @@ public: /** * Function ReadFootprintFiles - * Read the list of libraries (*.mod files) and populates m_List ( list of available - * modules in libs ). - * for each module, are stored - * the module name - * documentation string - * associated keywords - * library 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 * * @param aFootprintsLibNames = an array string giving the list of libraries to load */ bool ReadFootprintFiles( wxArrayString& aFootprintsLibNames ); - bool ReadFootprintFiles( FP_LIB_TABLE& aTable ); + /** + * Function ReadFootprintFiles + * reads all the footprints provided by the combination of aTable and aNickname. + * @param aTable defines all the libraries. + * @param aNickname is the library to read from, or if NULL means read all + * footprints from all known libraries. + */ + bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL ); }; + /// FOOTPRINT object list sort function. inline bool operator<( const FOOTPRINT_INFO& item1, const FOOTPRINT_INFO& item2 ) { diff --git a/include/fp_lib_table.h b/include/fp_lib_table.h index 3e7c54a290..81cfccd687 100644 --- a/include/fp_lib_table.h +++ b/include/fp_lib_table.h @@ -149,7 +149,7 @@ public: properties = r.properties ? new PROPERTIES( *r.properties ) : NULL; // do not copy the PLUGIN, it is lazily created. - // setPlugin( NULL ); + setPlugin( NULL ); return *this; } diff --git a/include/hashtables.h b/include/hashtables.h index d117a59abc..04c842808a 100644 --- a/include/hashtables.h +++ b/include/hashtables.h @@ -32,12 +32,16 @@ // So boost seems best for all platforms. -#if 0 // C++ +#if 0 // C++ std::unordered_map, maybe in the future #include /// Map a C string to a wxString, used in PLUGINs. -typedef std::unordered_map< std::string, std::string > PROPERTIES; +/// was typedef std::unordered_map< std::string, std::string > PROPERTIES; +class PROPERTIES : public std::unordered_map< std::string, std::string > +{ +}; + /// Map a C string to an integer. Used in DSNLEXER. typedef std::unordered_map< std::string, int > KEYWORD_MAP; @@ -57,7 +61,10 @@ typedef std::unordered_map< std::string, EDA_RECT > RECT_MAP; // see http://www.boost.org/doc/libs/1_49_0/doc/html/boost/unordered_map.html /// Map a std::string to a wxString, used in PLUGINs. -typedef boost::unordered_map< std::string, std::string > PROPERTIES; +/// was typedef boost::unordered_map< std::string, std::string > PROPERTIES; +class PROPERTIES : public boost::unordered_map< std::string, std::string > +{ +}; /// Equality test for "const char*" type used in very specialized KEYWORD_MAP below diff --git a/include/wxBasePcbFrame.h b/include/wxBasePcbFrame.h index abe921852e..f8e31fdf17 100644 --- a/include/wxBasePcbFrame.h +++ b/include/wxBasePcbFrame.h @@ -453,21 +453,25 @@ public: /** * Function SelectFootprint - * Display a list of modules found in active libraries or a given library + * displays a list of modules found in all libraries or a given library + * * @param aWindow = the current window ( parent window ) - * @param aLibraryFullFilename = library to list (if aLibraryFullFilename - * == void, list all modules) - * @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not - * used ) + * + * @param aLibraryName = library to list (if aLibraryFullFilename is empty, then list all modules). + * This is a nickname for the FP_LIB_TABLE build. + * + * @param aMask = Display filter (wildcart)( Mask = wxEmptyString if not used ) + * * @param aKeyWord = keyword list, to display a filtered list of module * having one (or more) of these keywords in their * keyword list ( aKeyWord = wxEmptyString if not used ) + * * @param aTable is the #FP_LIB_TABLE to search. * * @return wxEmptyString if abort or fails, or the selected module name if Ok */ wxString SelectFootprint( EDA_DRAW_FRAME* aWindow, - const wxString& aLibraryFullFilename, + const wxString& aLibraryName, const wxString& aMask, const wxString& aKeyWord, FP_LIB_TABLE* aTable ); diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index 43971a89de..8c24056a1d 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -1685,14 +1685,4 @@ public: }; -/** - * Function InvokePcbLibTableEditor - * shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables. - * - * @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal - * and/or the @a aProject table, respectively. If set, table was modified. - */ -int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ); - - #endif // WXPCB_STRUCT_H_ diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 414b8541d4..118751b5a9 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -58,6 +58,8 @@ set( PCBNEW_DIALOGS dialogs/dialog_find.cpp dialogs/dialog_fp_lib_table_base.cpp dialogs/dialog_fp_lib_table.cpp + dialogs/dialog_fp_plugin_options_base.cpp + dialogs/dialog_fp_plugin_options.cpp dialogs/dialog_freeroute_exchange.cpp dialogs/dialog_freeroute_exchange_base.cpp dialogs/dialog_gendrill.cpp diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 402540eb25..bf7b9d3ac1 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -2,7 +2,6 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2012 Wayne Stambaugh * Copyright (C) 2012 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or @@ -27,16 +26,11 @@ /* TODO: *) Grab text from any pending ChoiceEditor when OK button pressed. - -*) Test wxRE_ADVANCED on Windows. +*) After any change to uri, reparse the environment variables. */ -#include -#include -#include -#include #include #include #include @@ -44,6 +38,12 @@ #include #include +#include +#include +#include +#include +#include + /// grid column order is established by this sequence enum COL_ORDER @@ -411,6 +411,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE } // go to the problematic row + m_cur_grid->SetGridCursor( r, 0 ); m_cur_grid->SelectBlock( r, 0, r, 0 ); m_cur_grid->MakeCellVisible( r, 0 ); @@ -455,6 +456,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE } // go to the lower of the two rows, it is technically the duplicate: + m_cur_grid->SetGridCursor( r2, 0 ); m_cur_grid->SelectBlock( r2, 0, r2, 0 ); m_cur_grid->MakeCellVisible( r2, 0 ); @@ -508,15 +510,20 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE { int last_row = m_cur_grid->GetNumberRows() - 1; - m_cur_grid->SelectBlock( last_row, 0, last_row, 0 ); m_cur_grid->MakeCellVisible( last_row, 0 ); + m_cur_grid->SetGridCursor( last_row, 0 ); } } void deleteRowHandler( wxMouseEvent& event ) { - int curRow = getCursorRow(); + int rowCount = m_cur_grid->GetNumberRows(); + int curRow = getCursorRow(); + m_cur_grid->DeleteRows( curRow ); + + if( curRow && curRow == rowCount - 1 ) + m_cur_grid->SetGridCursor( curRow-1, getCursorCol() ); } void moveUpHandler( wxMouseEvent& event ) @@ -582,8 +589,18 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE void optionsEditor( wxMouseEvent& event ) { - // @todo: write the options editor, and pass the options to the Footprint*() calls. - //D(printf("%s:%d\n", __func__, (int) m_cur_grid->GetNumberRows() );) + FP_TBL_MODEL* tbl = (FP_TBL_MODEL*) m_cur_grid->GetTable(); + + int curRow = getCursorRow(); + ROW& row = tbl->rows[curRow]; + + wxString result; + const wxString& options = row.GetOptions(); + + InvokePluginOptionsEditor( this, row.GetNickName(), options, &result ); + + if( options != result ) + row.SetOptions( result ); } void onCancelButtonClick( wxCommandEvent& event ) @@ -591,6 +608,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE EndModal( 0 ); } + void onCancelButtonClick( wxCloseEvent& event ) + { + EndModal( 0 ); + } + void onOKButtonClick( wxCommandEvent& event ) { int dialogRet = 0; @@ -617,6 +639,11 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE } } + void onGridCmdSelectCell( wxGridEvent& event ) + { + event.Skip(); + } + void onGridCellLeftClick( wxGridEvent& event ) { event.Skip(); @@ -710,7 +737,7 @@ class DIALOG_FP_LIB_TABLE : public DIALOG_FP_LIB_TABLE_BASE wxGrid* m_cur_grid; ///< changed based on tab choice public: - DIALOG_FP_LIB_TABLE( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : + DIALOG_FP_LIB_TABLE( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) : DIALOG_FP_LIB_TABLE_BASE( aParent ), m_global( aGlobal ), m_project( aProject ), @@ -900,7 +927,7 @@ void DIALOG_FP_LIB_TABLE::paste() } -int InvokePcbLibTableEditor( wxFrame* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) +int InvokePcbLibTableEditor( wxTopLevelWindow* aParent, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ) { DIALOG_FP_LIB_TABLE dlg( aParent, aGlobal, aProject ); diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp index 66f3f222e4..9a6308bb41 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.cpp @@ -190,6 +190,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID this->Centre( wxBOTH ); // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ) ); this->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); m_auinotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); m_global_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this ); @@ -214,6 +215,7 @@ DIALOG_FP_LIB_TABLE_BASE::DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID DIALOG_FP_LIB_TABLE_BASE::~DIALOG_FP_LIB_TABLE_BASE() { // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_LIB_TABLE_BASE::onCancelButtonClick ) ); this->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( DIALOG_FP_LIB_TABLE_BASE::onKeyDown ) ); m_auinotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( DIALOG_FP_LIB_TABLE_BASE::pageChangedHandler ), NULL, this ); m_global_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FP_LIB_TABLE_BASE::onGridCellLeftClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp index 3f9726188c..254f407946 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.fbp +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.fbp @@ -32,7 +32,7 @@ 1 1 - impl_virtual + decl_pure_virtual @@ -43,7 +43,7 @@ DIALOG_FP_LIB_TABLE_BASE 900,600 - wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU + wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER DIALOG_SHIM; dialog_shim.h PCB Library Tables @@ -59,7 +59,7 @@ - + onCancelButtonClick @@ -1105,11 +1105,11 @@ - + 5 wxALL|wxEXPAND 0 - + wxID_ANY Path Substitutions @@ -1262,11 +1262,11 @@ - + 5 wxEXPAND 0 - + m_bottom_sizer wxVERTICAL diff --git a/pcbnew/dialogs/dialog_fp_lib_table_base.h b/pcbnew/dialogs/dialog_fp_lib_table_base.h index c3569e5f80..feb8d932f3 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table_base.h +++ b/pcbnew/dialogs/dialog_fp_lib_table_base.h @@ -57,24 +57,25 @@ class DIALOG_FP_LIB_TABLE_BASE : public DIALOG_SHIM wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class - virtual void onKeyDown( wxKeyEvent& event ) { event.Skip(); } - virtual void pageChangedHandler( wxAuiNotebookEvent& event ) { event.Skip(); } - virtual void onGridCellLeftClick( wxGridEvent& event ) { event.Skip(); } - virtual void onGridCellLeftDClick( wxGridEvent& event ) { event.Skip(); } - virtual void onGridCellRightClick( wxGridEvent& event ) { event.Skip(); } - virtual void onGridCmdSelectCell( wxGridEvent& event ) { event.Skip(); } - virtual void appendRowHandler( wxMouseEvent& event ) { event.Skip(); } - virtual void deleteRowHandler( wxMouseEvent& event ) { event.Skip(); } - virtual void moveUpHandler( wxMouseEvent& event ) { event.Skip(); } - virtual void moveDownHandler( wxMouseEvent& event ) { event.Skip(); } - virtual void optionsEditor( wxMouseEvent& event ) { event.Skip(); } - virtual void onCancelButtonClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onOKButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onCancelButtonClick( wxCloseEvent& event ) = 0; + virtual void onKeyDown( wxKeyEvent& event ) = 0; + virtual void pageChangedHandler( wxAuiNotebookEvent& event ) = 0; + virtual void onGridCellLeftClick( wxGridEvent& event ) = 0; + virtual void onGridCellLeftDClick( wxGridEvent& event ) = 0; + virtual void onGridCellRightClick( wxGridEvent& event ) = 0; + virtual void onGridCmdSelectCell( wxGridEvent& event ) = 0; + virtual void appendRowHandler( wxMouseEvent& event ) = 0; + virtual void deleteRowHandler( wxMouseEvent& event ) = 0; + virtual void moveUpHandler( wxMouseEvent& event ) = 0; + virtual void moveDownHandler( wxMouseEvent& event ) = 0; + virtual void optionsEditor( wxMouseEvent& event ) = 0; + virtual void onCancelButtonClick( wxCommandEvent& event ) = 0; + virtual void onOKButtonClick( wxCommandEvent& event ) = 0; public: - DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 900,600 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + DIALOG_FP_LIB_TABLE_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("PCB Library Tables"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 900,600 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); ~DIALOG_FP_LIB_TABLE_BASE(); }; diff --git a/pcbnew/dialogs/dialog_fp_plugin_options.cpp b/pcbnew/dialogs/dialog_fp_plugin_options.cpp new file mode 100644 index 0000000000..5040a10a45 --- /dev/null +++ b/pcbnew/dialogs/dialog_fp_plugin_options.cpp @@ -0,0 +1,101 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck + * Copyright (C) 2013 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 + */ + + +#include +#include +#include + + +class DIALOG_FP_PLUGIN_OPTIONS : public DIALOG_FP_PLUGIN_OPTIONS_BASE +{ + +public: + DIALOG_FP_PLUGIN_OPTIONS( wxTopLevelWindow* aParent, + const wxString& aNickname, const wxString& aOptions, wxString* aResult ) : + DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ), + m_callers_options( aOptions ), + m_options( aOptions ), + m_result( aResult ) + { + wxString title = wxString::Format( + _( "Options for Library '%s'" ), GetChars( aNickname ) ); + + SetTitle( title ); + } + + +private: + const wxString& m_callers_options; + wxString m_options; + wxString* m_result; + + //----------------------------------------------------------- + void onAddRow( wxCommandEvent& event ) + { + } + + void onDeleteRow( wxCommandEvent& event ) + { + } + + void onMoveUp( wxCommandEvent& event ) + { + } + + void onMoveDown( wxCommandEvent& event ) + { + } + + void onCancelButtonClick( wxCommandEvent& event ) + { + *m_result = m_callers_options; // no change + EndModal( 0 ); + } + + void onCancelButtonClick( wxCloseEvent& event ) + { + *m_result = m_callers_options; // no change + EndModal( 0 ); + } + + void onOKButtonClick( wxCommandEvent& event ) + { + *m_result = m_options; // change from edits + + EndModal( 1 ); + } + + //---------------------------------------------------------- + +}; + + +void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, + const wxString& aNickname, const wxString& aOptions, wxString* aResult ) +{ + DIALOG_FP_PLUGIN_OPTIONS dlg( aCaller, aNickname, aOptions, aResult ); + + dlg.ShowModal(); +} diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp new file mode 100644 index 0000000000..d4a943ba64 --- /dev/null +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp @@ -0,0 +1,132 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 30 2013) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_fp_plugin_options_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* m_horizontal_sizer; + m_horizontal_sizer = new wxBoxSizer( wxHORIZONTAL ); + + wxStaticBoxSizer* sbSizer1; + sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options:") ), wxVERTICAL ); + + m_grid1 = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); + + // Grid + m_grid1->CreateGrid( 5, 2 ); + m_grid1->EnableEditing( true ); + m_grid1->EnableGridLines( true ); + m_grid1->EnableDragGridSize( false ); + m_grid1->SetMargins( 0, 0 ); + + // Columns + m_grid1->EnableDragColMove( false ); + m_grid1->EnableDragColSize( true ); + m_grid1->SetColLabelSize( 30 ); + m_grid1->SetColLabelValue( 0, _("Option") ); + m_grid1->SetColLabelValue( 1, _("Value") ); + m_grid1->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Rows + m_grid1->EnableDragRowSize( false ); + m_grid1->SetRowLabelSize( 80 ); + m_grid1->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); + + // Label Appearance + + // Cell Defaults + m_grid1->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); + sbSizer1->Add( m_grid1, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer6; + bSizer6 = new wxBoxSizer( wxHORIZONTAL ); + + m_add_row = new wxButton( this, wxID_ANY, _("Add Row"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( m_add_row, 0, wxALL, 5 ); + + m_delete_row = new wxButton( this, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( m_delete_row, 0, wxALL, 5 ); + + m_move_up = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( m_move_up, 0, wxALL, 5 ); + + m_move_down = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer6->Add( m_move_down, 0, wxALL, 5 ); + + + sbSizer1->Add( bSizer6, 0, wxALIGN_CENTER, 5 ); + + + m_horizontal_sizer->Add( sbSizer1, 1, wxEXPAND, 5 ); + + wxBoxSizer* bSizer3; + bSizer3 = new wxBoxSizer( wxHORIZONTAL ); + + m_button1 = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer3->Add( m_button1, 0, wxALIGN_CENTER|wxALL, 5 ); + + + m_horizontal_sizer->Add( bSizer3, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 ); + + wxStaticBoxSizer* sbSizer3; + sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxHORIZONTAL ); + + m_listCtrl1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL ); + sbSizer3->Add( m_listCtrl1, 1, wxEXPAND, 5 ); + + + m_horizontal_sizer->Add( sbSizer3, 1, wxEXPAND, 5 ); + + + bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + + bSizer4->Add( m_sdbSizer1, 0, wxALL|wxEXPAND, 5 ); + + + this->SetSizer( bSizer4 ); + this->Layout(); + bSizer4->Fit( this ); + + this->Centre( wxBOTH ); + + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) ); + m_add_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this ); + m_delete_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this ); + m_move_up->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this ); + m_move_down->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this ); + m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this ); + m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this ); +} + +DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE() +{ + // Disconnect Events + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) ); + m_add_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this ); + m_delete_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this ); + m_move_up->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this ); + m_move_down->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this ); + m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this ); + m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp new file mode 100644 index 0000000000..3e4ba3aef1 --- /dev/null +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp @@ -0,0 +1,872 @@ + + + + + + C++ + 1 + source_name + 0 + 0 + res + UTF-8 + connect + dialog_fp_plugin_options_base + 1000 + none + 1 + dialog_fp_plugin_options + + . + + 1 + 1 + 1 + 0 + 0 + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + decl_pure_virtual + + + + 0 + wxID_ANY + + + DIALOG_FP_PLUGIN_OPTIONS_BASE + + -1,-1 + wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER + DIALOG_SHIM; dialog_shim.h + + + + + + + + + + + + + + + onCancelButtonClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer4 + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 1 + + + m_horizontal_sizer + wxHORIZONTAL + none + + 5 + wxEXPAND + 1 + + wxID_ANY + Plugin Options: + + sbSizer1 + wxVERTICAL + none + + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + 0 + 0 + + + + 1 + + + wxALIGN_LEFT + + wxALIGN_TOP + 0 + 1 + wxALIGN_CENTRE + 30 + "Option" "Value" + wxALIGN_CENTRE + 2 + + + 1 + 0 + Dock + 0 + Left + 0 + 1 + 0 + 0 + 1 + 1 + + 1 + + + 1 + 0 + 0 + wxID_ANY + + + + 0 + 0 + + 0 + + + 0 + + 1 + m_grid1 + 1 + + + protected + 1 + + Resizable + wxALIGN_CENTRE + 80 + + wxALIGN_CENTRE + + 5 + 1 + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER + 0 + + + bSizer6 + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Add Row + + 0 + + + 0 + + 1 + m_add_row + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onAddRow + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Delete Row + + 0 + + + 0 + + 1 + m_delete_row + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onDeleteRow + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Up + + 0 + + + 0 + + 1 + m_move_up + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onMoveUp + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Move Down + + 0 + + + 0 + + 1 + m_move_down + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + onMoveDown + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND + 0 + + + bSizer3 + wxHORIZONTAL + none + + 5 + wxALIGN_CENTER|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + << + + 0 + + + 0 + + 1 + m_button1 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxEXPAND + 1 + + wxID_ANY + Option Choices: + + sbSizer3 + wxHORIZONTAL + none + + + 5 + wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_listCtrl1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLC_REPORT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizer1 + protected + + onCancelButtonClick + + + + onOKButtonClick + + + + + + + + diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.h b/pcbnew/dialogs/dialog_fp_plugin_options_base.h new file mode 100644 index 0000000000..e83b94baee --- /dev/null +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.h @@ -0,0 +1,68 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Apr 30 2013) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __DIALOG_FP_PLUGIN_OPTIONS_BASE_H__ +#define __DIALOG_FP_PLUGIN_OPTIONS_BASE_H__ + +#include +#include +#include +class DIALOG_SHIM; + +#include "dialog_shim.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_FP_PLUGIN_OPTIONS_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM +{ + private: + + protected: + wxGrid* m_grid1; + wxButton* m_add_row; + wxButton* m_delete_row; + wxButton* m_move_up; + wxButton* m_move_down; + wxButton* m_button1; + wxListCtrl* m_listCtrl1; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Cancel; + + // Virtual event handlers, overide them in your derived class + virtual void onCancelButtonClick( wxCloseEvent& event ) = 0; + virtual void onAddRow( wxCommandEvent& event ) = 0; + virtual void onDeleteRow( wxCommandEvent& event ) = 0; + virtual void onMoveUp( wxCommandEvent& event ) = 0; + virtual void onMoveDown( wxCommandEvent& event ) = 0; + virtual void onCancelButtonClick( wxCommandEvent& event ) = 0; + virtual void onOKButtonClick( wxCommandEvent& event ) = 0; + + + public: + + DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER ); + ~DIALOG_FP_PLUGIN_OPTIONS_BASE(); + +}; + +#endif //__DIALOG_FP_PLUGIN_OPTIONS_BASE_H__ diff --git a/pcbnew/github/CMakeLists.txt b/pcbnew/github/CMakeLists.txt index a2ba58bab3..963990f13a 100644 --- a/pcbnew/github/CMakeLists.txt +++ b/pcbnew/github/CMakeLists.txt @@ -73,7 +73,3 @@ endif() add_dependencies( github_plugin boost ) add_dependencies( github_plugin avhttp ) - - -#target_link_libraries( github_plugin ${wxWidgets_LIBRARIES} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES}) - diff --git a/pcbnew/invoke_pcb_dialog.h b/pcbnew/invoke_pcb_dialog.h index 273fd5417b..de0bcb532e 100644 --- a/pcbnew/invoke_pcb_dialog.h +++ b/pcbnew/invoke_pcb_dialog.h @@ -41,31 +41,39 @@ #define INVOKE_A_DIALOG_H_ -class wxFrame; -class wxDialog; +class wxTopLevelWindow; class wxPoint; class wxSize; -class wxRealPoint; +//class wxRealPoint; +class wxString; // Often this is not used in the prototypes, since wxFrame is good enough and would // represent maximum information hiding. class PCB_EDIT_FRAME; +class FP_LIB_TABLE; -/* template: junk it after some are added: +/** + * Function InvokePcbLibTableEditor + * shows the modal DIALOG_FP_LIB_TABLE for purposes of editing two lib tables. + * + * @return int - bits 0 and 1 tell whether a change was made to the @a aGlobal + * and/or the @a aProject table, respectively. If set, table was modified. + */ +int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, FP_LIB_TABLE* aProject ); -/// Create and show DIALOG_ANNOTATE and return whatever -/// DIALOG_ANNOTATE::ShowModal() returns. -int InvokeDialogAnnotate( SCH_EDIT_FRAME* aCaller ); +/** + * Function InvokePluginOptionsEditor + * calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set can be edited. + * + * @param aCaller is the wxTopLevelWindow which is invoking the dialog. + * @param aNickname is the footprint library whose options are being edited. + * @param aOptionsIn is the options string on calling into this function. + * @param aResult is where to put the result of the editing. + */ +void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, + const wxString& aNickname, const wxString& aOptions, wxString* aResult ); -/// Create the modeless DIALOG_ERC and show it, return something to -/// destroy or close it. The dialog will have ID_DIALOG_ERC from id.h -wxDialog* InvokeDialogERC( SCH_EDIT_FRAME* aCaller ); - -/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever -/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns. -int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); -*/ #endif // INVOKE_A_DIALOG_H_ diff --git a/pcbnew/librairi.cpp b/pcbnew/librairi.cpp index 3054b367fd..d2187d7ab7 100644 --- a/pcbnew/librairi.cpp +++ b/pcbnew/librairi.cpp @@ -655,7 +655,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibPath, if( aDisplayDialog ) { wxString msg = wxString::Format( FMT_MOD_EXISTS, - footprintName.GetData(), aLibPath.GetData() ); + footprintName.GetData(), aLibPath.GetData() ); SetStatusText( msg ); } @@ -821,14 +821,12 @@ void FOOTPRINT_EDIT_FRAME::Select_Active_Library() if( dlg.ShowModal() != wxID_OK ) return; - setLibNickName( dlg.GetTextSelection() ); - wxString uri = m_footprintLibTable->FindRow( dlg.GetTextSelection() )->GetFullURI(); - wxString fileName = FP_LIB_TABLE::ExpandSubstitutions( uri ); + wxString nickname = dlg.GetTextSelection(); - wxLogDebug( wxT( "Loading footprint library <%s> with uri <%s> from <%s>." ), - GetChars( dlg.GetTextSelection() ), GetChars( uri ), GetChars( fileName ) ); + setLibNickName( nickname ); + + wxLogDebug( wxT( "Chose footprint library <%s>." ), GetChars( nickname ) ); - setLibPath( fileName ); updateTitle(); } diff --git a/pcbnew/loadcmp.cpp b/pcbnew/loadcmp.cpp index 6d7d3db020..5b84ed2596 100644 --- a/pcbnew/loadcmp.cpp +++ b/pcbnew/loadcmp.cpp @@ -432,31 +432,15 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId ) wxCHECK_MSG( m_footprintLibTable != NULL, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) ); - wxString libName = FROM_UTF8( aFootprintId.GetLibNickname().c_str() ); + wxString nickname = FROM_UTF8( aFootprintId.GetLibNickname().c_str() ); + wxString fpname = FROM_UTF8( aFootprintId.GetFootprintName().c_str() ); - const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( libName ); - - if( row == NULL ) - { - wxString msg; - msg.Printf( _( "No library named <%s> was found in the footprint library table." ), - aFootprintId.GetLibNickname().c_str() ); - THROW_IO_ERROR( msg ); - } - - wxString footprintName = FROM_UTF8( aFootprintId.GetFootprintName().c_str() ); - wxString libPath = row->GetFullURI(); - - libPath = FP_LIB_TABLE::ExpandSubstitutions( libPath ); - - PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::EnumFromStr( row->GetType() ) ) ); - - return pi->FootprintLoad( libPath, footprintName, row->GetProperties() ); + return m_footprintLibTable->FootprintLoad( nickname, fpname ); } wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, - const wxString& aLibraryFullFilename, + const wxString& aLibraryName, const wxString& aMask, const wxString& aKeyWord, FP_LIB_TABLE* aTable ) @@ -468,15 +452,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, FP_LIB_TABLE libTable; std::vector< wxArrayString > rows; - #if !defined( USE_FP_LIB_TABLE ) - if( aLibraryFullFilename.IsEmpty() ) + + if( aLibraryName.IsEmpty() ) { libraries = g_LibraryNames; } else { - libraries.Add( aLibraryFullFilename ); + libraries.Add( aLibraryName ); } if( libraries.IsEmpty() ) @@ -486,35 +470,15 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, } MList.ReadFootprintFiles( libraries ); + #else + wxASSERT( aTable != NULL ); - if( aLibraryFullFilename.IsEmpty() ) - { - std::vector< wxString > libNames = aTable->GetLogicalLibs(); - - for( unsigned i = 0; i < libNames.size(); i++ ) - { - FP_LIB_TABLE::ROW row = *aTable->FindRow( libNames[i] ); - libTable.InsertRow( row ); - } - } - else - { - FP_LIB_TABLE::ROW row = *aTable->FindRow( aLibraryFullFilename ); - libTable.InsertRow( row ); - } - - if( libTable.IsEmpty() ) - { - DisplayError( aWindow, _( "No footprint libraries were specified." ) ); - return wxEmptyString; - } - - if( !MList.ReadFootprintFiles( libTable ) ) + if( !MList.ReadFootprintFiles( aTable, !aLibraryName ? NULL : &aLibraryName ) ) { msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n" ), - GetChars( aLibraryFullFilename ) ); + GetChars( aLibraryName ) ); if( !MList.m_filesNotFound.IsEmpty() ) msg += _( "Files not found:\n\n" ) + MList.m_filesNotFound; @@ -591,6 +555,7 @@ wxString PCB_BASE_FRAME::SelectFootprint( EDA_DRAW_FRAME* aWindow, headers.Add( _( "Library" ) ); msg.Printf( _( "Modules [%d items]" ), (int) rows.size() ); + EDA_LIST_DIALOG dlg( aWindow, msg, headers, rows, OldName, DisplayCmpDoc ); if( dlg.ShowModal() == wxID_OK ) diff --git a/pcbnew/module_editor_frame.h b/pcbnew/module_editor_frame.h index 442da70151..378dd2fe5a 100644 --- a/pcbnew/module_editor_frame.h +++ b/pcbnew/module_editor_frame.h @@ -434,7 +434,6 @@ protected: // @todo these will eventually have to be made instance variables. static wxString m_lib_nick_name; - static wxString m_lib_path; /// The library nickName is a short string, for now the same as the library path /// but without path and without extension. After library table support it becomes @@ -442,9 +441,18 @@ protected: wxString getLibNickName() const { return m_lib_nick_name; } void setLibNickName( const wxString& aLibNickName ) { m_lib_nick_name = aLibNickName; } + static wxString m_lib_path; + +#if !defined(USE_FP_LIB_TABLE) + void setLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; } + /// The libPath is the full string used in the PLUGIN::Footprint*() calls. wxString getLibPath() const { return m_lib_path; } - void setLibPath( const wxString& aLibPath ) { m_lib_path = aLibPath; } + +#else + /// The libPath is not publicly visible, grab it from the FP_LIB_TABLE if we must. + wxString getLibPath(); +#endif }; #endif // MODULE_EDITOR_FRAME_H_ diff --git a/pcbnew/moduleframe.cpp b/pcbnew/moduleframe.cpp index d98c93a821..41db7b5fa2 100644 --- a/pcbnew/moduleframe.cpp +++ b/pcbnew/moduleframe.cpp @@ -256,6 +256,20 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME() m_Pcb = 0; } +#if defined(USE_FP_LIB_TABLE) +wxString FOOTPRINT_EDIT_FRAME::getLibPath() +{ + try + { + const FP_LIB_TABLE::ROW* row = GetFootprintLibraryTable()->FindRow( m_lib_nick_name ); + return row->GetFullURI( true ); + } + catch( IO_ERROR ioe ) + { + return wxEmptyString; + } +} +#endif const wxChar* FOOTPRINT_EDIT_FRAME::GetFootprintEditorFrameName() { diff --git a/pcbnew/modview_frame.cpp b/pcbnew/modview_frame.cpp index 5a5ab9cee2..9976912a69 100644 --- a/pcbnew/modview_frame.cpp +++ b/pcbnew/modview_frame.cpp @@ -393,23 +393,14 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() wxArrayString libsList; #if !defined( USE_FP_LIB_TABLE ) + libsList.Add( m_libraryName ); libLoaded = fp_info_list.ReadFootprintFiles( libsList ); + #else - const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( m_libraryName ); - if( row == NULL ) - { - wxString msg; - msg.Format( _( "Footprint library table entry <%s> not found." ), - GetChars( m_libraryName ) ); - DisplayError( this, msg ); - return; - } + libLoaded = fp_info_list.ReadFootprintFiles( m_footprintLibTable, &m_libraryName ); - FP_LIB_TABLE tmp; - tmp.InsertRow( *row ); - libLoaded = fp_info_list.ReadFootprintFiles( tmp ); #endif if( !libLoaded ) diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 4602111ee7..76455bc614 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -184,6 +184,11 @@ bool EDA_APP::OnInit() * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT( "PcbFrame" ), g_Board_Editor_Hokeys_Descr ); +#if defined( USE_FP_LIB_TABLE ) + // Set any environment variables before loading FP_LIB_TABLE + SetFootprintLibTablePath(); +#endif + frame = new PCB_EDIT_FRAME( NULL, wxT( "Pcbnew" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); #ifdef KICAD_SCRIPTING @@ -206,10 +211,6 @@ bool EDA_APP::OnInit() // Some will be overwritten after loading the board file frame->LoadProjectSettings( fn.GetFullPath() ); -#if defined( USE_FP_LIB_TABLE ) - SetFootprintLibTablePath(); -#endif - /* Load file specified in the command line. */ if( fn.IsOk() ) { diff --git a/pcbnew/pcbnew_config.cpp b/pcbnew/pcbnew_config.cpp index 9585b67cdc..8beacacd1e 100644 --- a/pcbnew/pcbnew_config.cpp +++ b/pcbnew/pcbnew_config.cpp @@ -54,6 +54,7 @@ #include #include +#include #include #include #include