Remove GITHUB plugins
KiCad github downloads are no longer supported Fixes https://gitlab.com/kicad/code/kicad/issues/6182
This commit is contained in:
parent
1d110d5414
commit
9ed6cdd943
|
@ -93,10 +93,6 @@ option( KICAD_BUILD_QA_TESTS
|
||||||
"Build software Quality assurance unit tests (default ON)"
|
"Build software Quality assurance unit tests (default ON)"
|
||||||
ON )
|
ON )
|
||||||
|
|
||||||
option( BUILD_GITHUB_PLUGIN
|
|
||||||
"Build the GITHUB_PLUGIN for pcbnew."
|
|
||||||
ON )
|
|
||||||
|
|
||||||
option( KICAD_SPICE
|
option( KICAD_SPICE
|
||||||
"Build KiCad with internal Spice simulator."
|
"Build KiCad with internal Spice simulator."
|
||||||
ON )
|
ON )
|
||||||
|
|
|
@ -69,9 +69,6 @@
|
||||||
#define WXPYTHON_VERSION "@WXPYTHON_VERSION@"
|
#define WXPYTHON_VERSION "@WXPYTHON_VERSION@"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// When defined, build the GITHUB_PLUGIN for pcbnew.
|
|
||||||
#cmakedefine BUILD_GITHUB_PLUGIN
|
|
||||||
|
|
||||||
/// A file extension with a leading '.' is a suffix, and this one is used on
|
/// A file extension with a leading '.' is a suffix, and this one is used on
|
||||||
/// top level program modules which implement the KIFACE.
|
/// top level program modules which implement the KIFACE.
|
||||||
#define KIFACE_SUFFIX "@KIFACE_SUFFIX@"
|
#define KIFACE_SUFFIX "@KIFACE_SUFFIX@"
|
||||||
|
|
|
@ -231,13 +231,6 @@ wxString GetVersionInfoData( const wxString& aTitle, bool aHtml, bool aBrief )
|
||||||
aMsg << OFF;
|
aMsg << OFF;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
aMsg << indent4 << "BUILD_GITHUB_PLUGIN=";
|
|
||||||
#ifdef BUILD_GITHUB_PLUGIN
|
|
||||||
aMsg << ON;
|
|
||||||
#else
|
|
||||||
aMsg << OFF;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef KICAD_USE_OCE
|
#ifdef KICAD_USE_OCE
|
||||||
aMsg << indent4 << "KICAD_USE_OCE=" << ON;
|
aMsg << indent4 << "KICAD_USE_OCE=" << ON;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,6 @@ static const ENV_VAR_LIST predefined_env_vars = {
|
||||||
"KICAD_SYMBOL_DIR",
|
"KICAD_SYMBOL_DIR",
|
||||||
"KISYS3DMOD",
|
"KISYS3DMOD",
|
||||||
"KISYSMOD",
|
"KISYSMOD",
|
||||||
"KIGITHUB",
|
|
||||||
"KICAD_TEMPLATE_DIR",
|
"KICAD_TEMPLATE_DIR",
|
||||||
"KICAD_USER_TEMPLATE_DIR",
|
"KICAD_USER_TEMPLATE_DIR",
|
||||||
"KICAD_PTEMPLATES",
|
"KICAD_PTEMPLATES",
|
||||||
|
@ -74,9 +73,6 @@ void initialiseEnvVarHelp( STRING_MAP& aMap )
|
||||||
_( "The base path of system footprint 3D shapes (.3Dshapes folders).");
|
_( "The base path of system footprint 3D shapes (.3Dshapes folders).");
|
||||||
aMap["KICAD_SYMBOL_DIR"] =
|
aMap["KICAD_SYMBOL_DIR"] =
|
||||||
_( "The base path of the locally installed symbol libraries.");
|
_( "The base path of the locally installed symbol libraries.");
|
||||||
aMap["KIGITHUB"] =
|
|
||||||
_( "Used by KiCad to define the URL of the repository "
|
|
||||||
"of the official KiCad footprint libraries.");
|
|
||||||
aMap["KICAD_TEMPLATE_DIR"] =
|
aMap["KICAD_TEMPLATE_DIR"] =
|
||||||
_( "A directory containing project templates installed with KiCad.");
|
_( "A directory containing project templates installed with KiCad.");
|
||||||
aMap["KICAD_USER_TEMPLATE_DIR"] =
|
aMap["KICAD_USER_TEMPLATE_DIR"] =
|
||||||
|
@ -136,4 +132,4 @@ OPT<wxString> GetEnvVar( const wxString& aEnvVarName )
|
||||||
}
|
}
|
||||||
|
|
||||||
return opt_value;
|
return opt_value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1024,7 +1024,6 @@ bool FILENAME_RESOLVER::GetKicadPaths( std::list< wxString >& paths )
|
||||||
{
|
{
|
||||||
// filter out URLs, template directories, and known system paths
|
// filter out URLs, template directories, and known system paths
|
||||||
if( mS->first == wxString( "KICAD_PTEMPLATES" )
|
if( mS->first == wxString( "KICAD_PTEMPLATES" )
|
||||||
|| mS->first == wxString( "KIGITHUB" )
|
|
||||||
|| mS->first == wxString( "KISYSMOD" ) )
|
|| mS->first == wxString( "KISYSMOD" ) )
|
||||||
{
|
{
|
||||||
++mS;
|
++mS;
|
||||||
|
|
|
@ -259,26 +259,6 @@ bool PGM_BASE::InitPgm()
|
||||||
|
|
||||||
SetLanguagePath();
|
SetLanguagePath();
|
||||||
|
|
||||||
wxString envVarName = wxT( "KIGITHUB" );
|
|
||||||
ENV_VAR_ITEM envVarItem;
|
|
||||||
wxString envValue;
|
|
||||||
wxFileName tmpFileName;
|
|
||||||
|
|
||||||
if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
|
|
||||||
{
|
|
||||||
tmpFileName.AssignDir( envValue );
|
|
||||||
envVarItem.SetDefinedExternally( true );
|
|
||||||
wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Found entry %s externally", envVarName );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
envVarItem.SetValue( wxString( wxT( "https://github.com/KiCad" ) ) );
|
|
||||||
envVarItem.SetDefinedExternally( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxLogTrace( traceEnvVars, "PGM_BASE::InitPgm: Setting entry %s = %s", envVarName, envVarItem.GetValue() );
|
|
||||||
m_local_env_vars[ envVarName ] = envVarItem;
|
|
||||||
|
|
||||||
wxFileName baseSharePath;
|
wxFileName baseSharePath;
|
||||||
#if defined( __WXMSW__ )
|
#if defined( __WXMSW__ )
|
||||||
// Make the paths relative to the executable dir as KiCad might be installed anywhere
|
// Make the paths relative to the executable dir as KiCad might be installed anywhere
|
||||||
|
@ -296,7 +276,10 @@ bool PGM_BASE::InitPgm()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// KISYSMOD
|
// KISYSMOD
|
||||||
envVarName = wxT( "KISYSMOD" );
|
wxString envVarName = wxT( "KISYSMOD" );
|
||||||
|
ENV_VAR_ITEM envVarItem;
|
||||||
|
wxString envValue;
|
||||||
|
wxFileName tmpFileName;
|
||||||
|
|
||||||
if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
|
if( wxGetEnv( envVarName, &envValue ) == true && !envValue.IsEmpty() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -76,10 +76,6 @@ target_link_libraries( cvpcb_kiface
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
target_link_libraries( cvpcb_kiface github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Must follow github_plugin
|
# Must follow github_plugin
|
||||||
target_link_libraries( cvpcb_kiface ${Boost_LIBRARIES} )
|
target_link_libraries( cvpcb_kiface ${Boost_LIBRARIES} )
|
||||||
|
|
||||||
|
|
|
@ -380,7 +380,7 @@ protected:
|
||||||
wxString m_editor_name;
|
wxString m_editor_name;
|
||||||
wxSize m_help_size;
|
wxSize m_help_size;
|
||||||
|
|
||||||
/// Local environment variable expansion settings such as KIGITHUB, KISYSMOD, and KISYS3DMOD.
|
/// Local environment variable expansion settings such as KISYSMOD, and KISYS3DMOD.
|
||||||
ENV_VAR_MAP m_local_env_vars;
|
ENV_VAR_MAP m_local_env_vars;
|
||||||
|
|
||||||
/// Flag to indicate if the environment variable overwrite warning dialog should be shown.
|
/// Flag to indicate if the environment variable overwrite warning dialog should be shown.
|
||||||
|
|
|
@ -27,14 +27,6 @@ if( KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES )
|
||||||
#message( STATUS "pcbnew INC_AFTER:${INC_AFTER}" )
|
#message( STATUS "pcbnew INC_AFTER:${INC_AFTER}" )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
set( GITHUB_3DLIBRARIES_WIZARD
|
|
||||||
dialogs/wizard_3DShape_Libs_downloader_base.cpp
|
|
||||||
dialogs/wizard_3DShape_Libs_downloader.cpp
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories( BEFORE ${INC_BEFORE} )
|
include_directories( BEFORE ${INC_BEFORE} )
|
||||||
include_directories(
|
include_directories(
|
||||||
./dialogs
|
./dialogs
|
||||||
|
@ -180,7 +172,6 @@ set( PCBNEW_DIALOGS
|
||||||
footprint_wizard.cpp
|
footprint_wizard.cpp
|
||||||
footprint_wizard_frame.cpp
|
footprint_wizard_frame.cpp
|
||||||
footprint_wizard_frame_functions.cpp
|
footprint_wizard_frame_functions.cpp
|
||||||
${GITHUB_3DLIBRARIES_WIZARD}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if( KICAD_SCRIPTING AND KICAD_SCRIPTING_ACTION_MENU )
|
if( KICAD_SCRIPTING AND KICAD_SCRIPTING_ACTION_MENU )
|
||||||
|
@ -513,11 +504,6 @@ if( KICAD_SCRIPTING ) # Generate pcbnew.py and pcbnew_wrap.cxx using swig
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( UNIX AND NOT APPLE )
|
if( UNIX AND NOT APPLE )
|
||||||
list( APPEND PCBNEW_EXTRA_LIBS rt )
|
list( APPEND PCBNEW_EXTRA_LIBS rt )
|
||||||
endif()
|
endif()
|
||||||
|
@ -623,13 +609,6 @@ add_subdirectory( plugins/cadstar )
|
||||||
|
|
||||||
set( PCBNEW_IO_LIBRARIES pcad2kicadpcb altium2pcbnew cadstar2pcbnew CACHE INTERNAL "")
|
set( PCBNEW_IO_LIBRARIES pcad2kicadpcb altium2pcbnew cadstar2pcbnew CACHE INTERNAL "")
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
add_subdirectory( github )
|
|
||||||
# github_plugin depends on make_lexer outputs in common
|
|
||||||
add_dependencies( github_plugin pcbcommon )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
# a very small program launcher for pcbnew_kiface
|
# a very small program launcher for pcbnew_kiface
|
||||||
add_executable( pcbnew WIN32 MACOSX_BUNDLE
|
add_executable( pcbnew WIN32 MACOSX_BUNDLE
|
||||||
${CMAKE_SOURCE_DIR}/common/single_top.cpp
|
${CMAKE_SOURCE_DIR}/common/single_top.cpp
|
||||||
|
@ -726,10 +705,9 @@ set( PCBNEW_KIFACE_LIBRARIES
|
||||||
markdown_lib
|
markdown_lib
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${Boost_LIBRARIES} # must follow GITHUB
|
${Boost_LIBRARIES}
|
||||||
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -377,9 +377,6 @@ PANEL_FP_LIB_TABLE::PANEL_FP_LIB_TABLE( DIALOG_EDIT_LIBRARY_TABLES* aParent,
|
||||||
wxArrayString choices;
|
wxArrayString choices;
|
||||||
|
|
||||||
choices.Add( IO_MGR::ShowType( IO_MGR::KICAD_SEXP ) );
|
choices.Add( IO_MGR::ShowType( IO_MGR::KICAD_SEXP ) );
|
||||||
#if defined(BUILD_GITHUB_PLUGIN)
|
|
||||||
choices.Add( IO_MGR::ShowType( IO_MGR::GITHUB ) );
|
|
||||||
#endif
|
|
||||||
choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
|
choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
|
||||||
choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
|
choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
|
||||||
choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
|
choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
|
||||||
|
|
|
@ -1,575 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 CERN
|
|
||||||
* Code derived from "wizard_add_fplib.cpp" ( author Maciej Suminski <maciej.suminski@cern.ch> )
|
|
||||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 1992-2015 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Wizard for selecting and dowloading 3D shapes libraries of footprints
|
|
||||||
* consisting of 3 steps:
|
|
||||||
* - select source and destination (Github URL and local folder)
|
|
||||||
* - pick and select libraries
|
|
||||||
* - download files
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <wx/wx.h>
|
|
||||||
#include <wx/uri.h>
|
|
||||||
#include <wx/dir.h>
|
|
||||||
#include <widgets/app_progress_dialog.h>
|
|
||||||
|
|
||||||
#include <pgm_base.h>
|
|
||||||
#include <project.h>
|
|
||||||
#include <wizard_3DShape_Libs_downloader.h>
|
|
||||||
#include <confirm.h>
|
|
||||||
#include <3d_viewer/eda_3d_viewer.h>
|
|
||||||
#include <bitmaps.h>
|
|
||||||
#include <settings/common_settings.h>
|
|
||||||
|
|
||||||
#include <../github/github_getliblist.h>
|
|
||||||
|
|
||||||
// a key to store the default Kicad Github 3D libs URL
|
|
||||||
#define KICAD_3DLIBS_URL_KEY wxT( "kicad_3Dlib_url" )
|
|
||||||
#define KICAD_3DLIBS_LAST_DOWNLOAD_DIR wxT( "kicad_3Dlib_last_download_dir" )
|
|
||||||
|
|
||||||
#define DEFAULT_GITHUB_3DSHAPES_LIBS_URL \
|
|
||||||
"https://github.com/KiCad/kicad-packages3d"
|
|
||||||
// wxT( "https://github.com/KiCad/kicad-library/tree/master/modules/packages3d" )
|
|
||||||
|
|
||||||
void Invoke3DShapeLibsDownloaderWizard( wxWindow* aCaller )
|
|
||||||
{
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER wizard( aCaller );
|
|
||||||
wizard.RunWizard( wizard.GetFirstPage() );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER::WIZARD_3DSHAPE_LIBS_DOWNLOADER( wxWindow* aParent ) :
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE( aParent )
|
|
||||||
{
|
|
||||||
m_welcomeDlg = m_pages[0];
|
|
||||||
m_githubListDlg = m_pages[1];
|
|
||||||
m_reviewDlg = m_pages[2];
|
|
||||||
|
|
||||||
// Initialize default download dir (local target folder of 3D shapes libs)
|
|
||||||
wxString default_path;
|
|
||||||
wxGetEnv( KISYS3DMOD, &default_path );
|
|
||||||
|
|
||||||
auto cfg = Pgm().GetCommonSettings();
|
|
||||||
|
|
||||||
setDownloadDir( cfg->m_3DLibsDownloadPath.empty() ? default_path : cfg->m_3DLibsDownloadPath );
|
|
||||||
|
|
||||||
// Restore the Github 3D shapes libs url
|
|
||||||
wxString githubUrl = cfg->m_3DLibsUrl;
|
|
||||||
|
|
||||||
if( githubUrl.IsEmpty() )
|
|
||||||
githubUrl = DEFAULT_GITHUB_3DSHAPES_LIBS_URL;
|
|
||||||
|
|
||||||
SetGithubURL( githubUrl );
|
|
||||||
|
|
||||||
|
|
||||||
// Give the minimal size to the dialog, which allows displaying any page
|
|
||||||
wxSize minsize;
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < m_pages.size(); ii++ )
|
|
||||||
{
|
|
||||||
wxSize size = m_pages[ii]->GetSizer()->CalcMin();
|
|
||||||
minsize.x = std::max( minsize.x, size.x );
|
|
||||||
minsize.y = std::max( minsize.y, size.y );
|
|
||||||
}
|
|
||||||
|
|
||||||
SetMinSize( minsize );
|
|
||||||
SetPageSize( minsize );
|
|
||||||
GetSizer()->SetSizeHints( this );
|
|
||||||
Center();
|
|
||||||
|
|
||||||
setupDialogOrder();
|
|
||||||
updateGithubControls();
|
|
||||||
|
|
||||||
// When starting m_textCtrlGithubURL has the focus, and the text is selected,
|
|
||||||
// and not fully visible.
|
|
||||||
// Forcing deselection does not work, at least on W7 with wxWidgets 3.0.2
|
|
||||||
// So (and also because m_textCtrlGithubURL and m_downloadDir are rarely modified
|
|
||||||
// the focus is given to another widget.
|
|
||||||
m_hyperlinkGithubKicad->SetFocus();
|
|
||||||
|
|
||||||
Connect( wxEVT_RADIOBUTTON, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnSourceCheck ), NULL, this );
|
|
||||||
Connect( wxEVT_CHECKLISTBOX, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckGithubList ), NULL, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER::~WIZARD_3DSHAPE_LIBS_DOWNLOADER()
|
|
||||||
{
|
|
||||||
auto cfg = Pgm().GetCommonSettings();
|
|
||||||
|
|
||||||
cfg->m_3DLibsUrl = GetGithubURL().ToStdString();
|
|
||||||
cfg->m_3DLibsDownloadPath = getDownloadDir().ToStdString();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnPageChanged( wxWizardEvent& aEvent )
|
|
||||||
{
|
|
||||||
SetBitmap( KiBitmap( wizard_add_fplib_icon_xpm ) );
|
|
||||||
enableNext( true );
|
|
||||||
|
|
||||||
if( GetCurrentPage() == m_githubListDlg )
|
|
||||||
setupGithubList();
|
|
||||||
else if( GetCurrentPage() == m_reviewDlg )
|
|
||||||
setupReview();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckGithubList( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
wxArrayInt dummy;
|
|
||||||
|
|
||||||
enableNext( m_checkList3Dlibnames->GetCheckedItems( dummy ) > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnSourceCheck( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
updateGithubControls();
|
|
||||||
setupDialogOrder();
|
|
||||||
}
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnGridLibReviewSize( wxSizeEvent& event )
|
|
||||||
{
|
|
||||||
// Adjust the width of the column 1 of m_gridLibReview (library names) to the
|
|
||||||
// max available width.
|
|
||||||
int gridwidth = m_gridLibReview->GetClientSize().x;
|
|
||||||
gridwidth -= m_gridLibReview->GetColSize( 0 ) + m_gridLibReview->GetColLabelSize();
|
|
||||||
|
|
||||||
if( gridwidth < 200 )
|
|
||||||
gridwidth = 200;
|
|
||||||
|
|
||||||
m_gridLibReview->SetColSize( 1, gridwidth );
|
|
||||||
|
|
||||||
event.Skip();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::setupReview()
|
|
||||||
{
|
|
||||||
// Prepare the last page of the wizard.
|
|
||||||
|
|
||||||
m_LocalFolderInfo->SetLabel( getDownloadDir() );
|
|
||||||
|
|
||||||
wxArrayInt checkedIndices;
|
|
||||||
m_checkList3Dlibnames->GetCheckedItems( checkedIndices );
|
|
||||||
|
|
||||||
m_libraries.Clear();
|
|
||||||
|
|
||||||
// populate m_libraries with the name of libraries, without the github path:
|
|
||||||
for( unsigned int ii = 0; ii < checkedIndices.GetCount(); ++ii )
|
|
||||||
{
|
|
||||||
m_libraries.Add( m_checkList3Dlibnames->GetString( checkedIndices[ii] ).AfterLast( '/' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adjust number of rows in m_gridLibReview:
|
|
||||||
int delta = m_libraries.GetCount() - m_gridLibReview->GetNumberRows();
|
|
||||||
|
|
||||||
if( delta < 0 )
|
|
||||||
m_gridLibReview->DeleteRows( -delta );
|
|
||||||
else if( delta > 0 )
|
|
||||||
m_gridLibReview->AppendRows( delta );
|
|
||||||
|
|
||||||
// For user info, verify the existence of these libs in local folder
|
|
||||||
wxArrayString liblist;
|
|
||||||
wxFileName fn;
|
|
||||||
fn.AssignDir( getDownloadDir() );
|
|
||||||
|
|
||||||
for( unsigned int ii = 0; ii < m_libraries.GetCount(); ++ii )
|
|
||||||
{
|
|
||||||
fn.SetName( m_libraries[ii] );
|
|
||||||
|
|
||||||
wxDir dirs;
|
|
||||||
bool isNew = ! dirs.Exists( fn.GetFullPath() );
|
|
||||||
wxString info = isNew ? _( "New" ) : _( "Update" );
|
|
||||||
|
|
||||||
liblist.Add( info + wxT(" ") + m_libraries[ii] );
|
|
||||||
|
|
||||||
m_gridLibReview->SetCellValue( ii, 0, info );
|
|
||||||
m_gridLibReview->SetCellValue( ii, 1, m_libraries[ii] );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_gridLibReview->AutoSizeColumn( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnSelectAll3Dlibs( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
for( unsigned int i = 0; i < m_checkList3Dlibnames->GetCount(); ++i )
|
|
||||||
m_checkList3Dlibnames->Check( i, true );
|
|
||||||
|
|
||||||
// The list might be empty, e.g. in case of download error
|
|
||||||
wxArrayInt dummy;
|
|
||||||
enableNext( m_checkList3Dlibnames->GetCheckedItems( dummy ) > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnUnselectAll3Dlibs( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
for( unsigned int i = 0; i < m_checkList3Dlibnames->GetCount(); ++i )
|
|
||||||
m_checkList3Dlibnames->Check( i, false );
|
|
||||||
|
|
||||||
enableNext( false );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnChangeSearch( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
wxString searchPhrase = m_searchCtrl3Dlibs->GetValue().Lower();
|
|
||||||
|
|
||||||
// Store the current selection
|
|
||||||
wxArrayInt checkedIndices;
|
|
||||||
m_checkList3Dlibnames->GetCheckedItems( checkedIndices );
|
|
||||||
wxArrayString checkedStrings;
|
|
||||||
|
|
||||||
for( unsigned int i = 0; i < checkedIndices.GetCount(); ++i )
|
|
||||||
checkedStrings.Add( m_checkList3Dlibnames->GetString( checkedIndices[i] ).AfterLast( '/' ) );
|
|
||||||
|
|
||||||
m_checkList3Dlibnames->Clear();
|
|
||||||
|
|
||||||
// Rebuild the list, putting the matching entries on the top
|
|
||||||
int matching = 0; // number of entries matching the search phrase
|
|
||||||
for( unsigned int i = 0; i < m_githubLibs.GetCount(); ++i )
|
|
||||||
{
|
|
||||||
const wxString& lib = m_githubLibs[i].AfterLast( '/' );
|
|
||||||
bool wasChecked = ( checkedStrings.Index( lib ) != wxNOT_FOUND );
|
|
||||||
int insertedIdx = -1;
|
|
||||||
|
|
||||||
if( !searchPhrase.IsEmpty() && lib.Lower().BeforeLast( '.' ).Contains( searchPhrase ) )
|
|
||||||
{
|
|
||||||
insertedIdx = m_checkList3Dlibnames->Insert( lib, matching++ );
|
|
||||||
m_checkList3Dlibnames->SetSelection( insertedIdx );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
insertedIdx = m_checkList3Dlibnames->Append( lib );
|
|
||||||
|
|
||||||
if( wasChecked )
|
|
||||||
m_checkList3Dlibnames->Check( insertedIdx );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !m_checkList3Dlibnames->IsEmpty() )
|
|
||||||
m_checkList3Dlibnames->EnsureVisible( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnWizardFinished( wxWizardEvent& aEvent )
|
|
||||||
{
|
|
||||||
// we download a localy copy of the libraries
|
|
||||||
wxString error;
|
|
||||||
|
|
||||||
if( !downloadGithubLibsFromList( m_libraries, &error ) )
|
|
||||||
{
|
|
||||||
DisplayError( this, error );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnBrowseButtonClick( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
wxString path = getDownloadDir();
|
|
||||||
|
|
||||||
path = wxDirSelector( _("Choose a folder to save the downloaded libraries" ),
|
|
||||||
path, 0, wxDefaultPosition, this );
|
|
||||||
|
|
||||||
if( !path.IsEmpty() && wxDirExists( path ) )
|
|
||||||
{
|
|
||||||
setDownloadDir( path );
|
|
||||||
updateGithubControls();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnDefault3DPathButtonClick( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
wxString default_path;
|
|
||||||
wxGetEnv( KISYS3DMOD, &default_path );
|
|
||||||
|
|
||||||
if( !default_path.IsEmpty() && wxDirExists( default_path ) )
|
|
||||||
{
|
|
||||||
setDownloadDir( default_path );
|
|
||||||
updateGithubControls();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
wxMessageBox( _( "KISYS3DMOD path not defined , or not existing" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnCheckSaveCopy( wxCommandEvent& aEvent )
|
|
||||||
{
|
|
||||||
updateGithubControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::getLibsListGithub( wxArrayString& aList )
|
|
||||||
{
|
|
||||||
wxBeginBusyCursor();
|
|
||||||
|
|
||||||
// Be sure there is no trailing '/' at the end of the repo name
|
|
||||||
wxString git_url = m_textCtrlGithubURL->GetValue();
|
|
||||||
|
|
||||||
if( git_url.EndsWith( wxT( "/" ) ) )
|
|
||||||
{
|
|
||||||
git_url.RemoveLast();
|
|
||||||
m_textCtrlGithubURL->SetValue( git_url );
|
|
||||||
}
|
|
||||||
|
|
||||||
GITHUB_GETLIBLIST getter( git_url );
|
|
||||||
getter.Get3DshapesLibsList( &aList, filter3dshapeslibraries );
|
|
||||||
|
|
||||||
wxEndBusyCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Download the .3Dshapes libraries folders found in aUrlList and store them on disk
|
|
||||||
// in a master folder
|
|
||||||
bool WIZARD_3DSHAPE_LIBS_DOWNLOADER::downloadGithubLibsFromList( wxArrayString& aUrlList,
|
|
||||||
wxString* aErrorMessage )
|
|
||||||
{
|
|
||||||
// Display a progress bar to show the download state
|
|
||||||
// The title is updated for each downloaded library.
|
|
||||||
// the state will be updated by downloadOneLib() for each file.
|
|
||||||
// for OSX do not enable wPD_APP_MODAL, keep wxPD_AUTO_HIDE
|
|
||||||
APP_PROGRESS_DIALOG pdlg( _( "Downloading 3D libraries" ), wxEmptyString,
|
|
||||||
aUrlList.GetCount(), this, true,
|
|
||||||
#ifndef __WXMAC__
|
|
||||||
wxPD_APP_MODAL |
|
|
||||||
#endif
|
|
||||||
wxPD_CAN_ABORT | wxPD_AUTO_HIDE );
|
|
||||||
|
|
||||||
// Built the full server name string:
|
|
||||||
wxURI repo( GetGithubURL() );
|
|
||||||
wxString server = repo.GetScheme() + "://" + repo.GetServer();
|
|
||||||
|
|
||||||
// Download libs:
|
|
||||||
for( size_t ii = 0; ii < aUrlList.GetCount(); ii++ )
|
|
||||||
{
|
|
||||||
wxString& libsrc_name = aUrlList[ii];
|
|
||||||
|
|
||||||
// Recover the full URL lib from short name:
|
|
||||||
// (note: m_githubLibs stores the URL relative to the server name)
|
|
||||||
wxString url;
|
|
||||||
|
|
||||||
for( unsigned jj = 0; jj < m_githubLibs.GetCount(); jj++ )
|
|
||||||
{
|
|
||||||
if( m_githubLibs[jj].EndsWith( libsrc_name ) )
|
|
||||||
{
|
|
||||||
url = server + m_githubLibs[jj];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wxFileName fn( libsrc_name );
|
|
||||||
// Set our local path
|
|
||||||
fn.SetPath( getDownloadDir() );
|
|
||||||
wxString libdst_name = fn.GetFullPath();
|
|
||||||
|
|
||||||
// Display the name of the library to download in the wxProgressDialog
|
|
||||||
pdlg.SetTitle( wxString::Format( wxT("%s [%lu/%lu]" ),
|
|
||||||
libsrc_name.AfterLast( '/' ).GetData(),
|
|
||||||
ii + 1, aUrlList.GetCount() ) );
|
|
||||||
|
|
||||||
if( !wxDirExists( libdst_name ) )
|
|
||||||
wxMkdir( libdst_name );
|
|
||||||
|
|
||||||
if( !downloadOneLib( url, libdst_name, &pdlg, aErrorMessage ) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool WIZARD_3DSHAPE_LIBS_DOWNLOADER::downloadOneLib( const wxString& aLibURL,
|
|
||||||
const wxString& aLocalLibName, wxProgressDialog* aIndicator,
|
|
||||||
wxString* aErrorMessage )
|
|
||||||
{
|
|
||||||
wxArrayString fileslist;
|
|
||||||
|
|
||||||
bool success;
|
|
||||||
|
|
||||||
// Get the list of candidate files: with ext .wrl .stp .step .STEP .STP or .wings
|
|
||||||
do
|
|
||||||
{
|
|
||||||
GITHUB_GETLIBLIST getter( aLibURL );
|
|
||||||
success = getter.Get3DshapesLibsList( &fileslist, filter3dshapesfiles );
|
|
||||||
} while( 0 );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Load each file in list:
|
|
||||||
wxURI repo( aLibURL );
|
|
||||||
|
|
||||||
wxString server = repo.GetServer();
|
|
||||||
|
|
||||||
// Github gives the current url of files inside .3dshapes folders like:
|
|
||||||
// "https://github.com/KiCad/kicad-library/blob/master/modules/packages3d/Capacitors_SMD.3dshapes/C_0402.wrl"
|
|
||||||
// which displays a html page showing the file in html form.
|
|
||||||
//
|
|
||||||
// the URL of the corresponding raw file is
|
|
||||||
// "https://github.com/KiCad/kicad-library/raw/master/modules/packages3d/Capacitors_SMD.3dshapes/C_0402.wrl"
|
|
||||||
//
|
|
||||||
// However Github redirects this current url to raw.githubusercontent.com/fullfilename
|
|
||||||
// when trying to download raw files.
|
|
||||||
// "https://github.com/KiCad/kicad-library/raw/master/modules/packages3d/Capacitors_SMD.3dshapes/C_0402.wrl"
|
|
||||||
// would be redirected to:
|
|
||||||
// "https://raw.githubusercontent.com/KiCad/kicad-library/master/modules/packages3d/Capacitors_SMD.3dshapes/C_0402.wrl"
|
|
||||||
// So use raw.githubusercontent.com instead of github.com
|
|
||||||
// (and removes the "/raw" in path) speed up the downloads (x2 faster).
|
|
||||||
//
|
|
||||||
// wxURI has no way to change the server name, so we need to use tricks to make the URL.
|
|
||||||
//
|
|
||||||
// Comment this next line to use the github.com URL
|
|
||||||
#define FORCE_GITHUB_RAW_URL
|
|
||||||
|
|
||||||
#ifdef FORCE_GITHUB_RAW_URL
|
|
||||||
if( server.Cmp( wxT( "github.com" ) ) == 0 )
|
|
||||||
server = wxT( "raw.githubusercontent.com" );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
wxString full_url_base = repo.GetScheme() + wxT( "://" ) + server;
|
|
||||||
wxString target_full_url;
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < fileslist.GetCount(); ii++ )
|
|
||||||
{
|
|
||||||
target_full_url = full_url_base + fileslist[ii];
|
|
||||||
|
|
||||||
#ifdef FORCE_GITHUB_RAW_URL
|
|
||||||
// Remove "blob/" in URL string to build the URL on "raw.githubusercontent.com"
|
|
||||||
// server from "github.com" URL string:
|
|
||||||
target_full_url.Replace( wxT( "blob/" ), wxT( "" ) );
|
|
||||||
#else
|
|
||||||
// Replace "blob" by "raw" in URL to access the raw file itself, not the html page
|
|
||||||
// on "github.com" server
|
|
||||||
target_full_url.Replace( wxT( "blob" ), wxT( "raw" ) );
|
|
||||||
#endif
|
|
||||||
aIndicator->SetRange( fileslist.GetCount() );
|
|
||||||
bool abort = !aIndicator->Update( ii, target_full_url.AfterLast( '/' ) );
|
|
||||||
|
|
||||||
if( abort )
|
|
||||||
{
|
|
||||||
if( aErrorMessage )
|
|
||||||
*aErrorMessage << _( "Aborted by user" );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Download the current file.
|
|
||||||
// Get3DshapesLibsList actually downloads and stores the target_full_url content.
|
|
||||||
GITHUB_GETLIBLIST getter( target_full_url );
|
|
||||||
success = getter.Get3DshapesLibsList( NULL, NULL );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
break;
|
|
||||||
|
|
||||||
wxFileName fn;
|
|
||||||
fn.AssignDir( aLocalLibName );
|
|
||||||
fn.SetFullName( fileslist[ii].AfterLast( '/' ) );
|
|
||||||
|
|
||||||
// The entire downloaded file is stored in getter buffer
|
|
||||||
const std::string& buffer = getter.GetBuffer();
|
|
||||||
|
|
||||||
// Write is "as this". It can be a binary file.
|
|
||||||
wxFile file(fn.GetFullPath(), wxFile::write);
|
|
||||||
file.Write( &buffer[0], buffer.size() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::setupGithubList()
|
|
||||||
{
|
|
||||||
// Enable 'Next' only if there is at least one library selected
|
|
||||||
wxArrayInt checkedIndices;
|
|
||||||
m_checkList3Dlibnames->GetCheckedItems( checkedIndices );
|
|
||||||
enableNext( checkedIndices.GetCount() > 0 );
|
|
||||||
|
|
||||||
// Update only if the text has changed or the list is empty
|
|
||||||
if( m_githubLibs.GetCount() == 0 || m_textCtrlGithubURL->IsModified() )
|
|
||||||
{
|
|
||||||
m_githubLibs.Clear();
|
|
||||||
getLibsListGithub( m_githubLibs );
|
|
||||||
|
|
||||||
// Populate the list
|
|
||||||
m_checkList3Dlibnames->Clear();
|
|
||||||
for( unsigned int i = 0; i < m_githubLibs.GetCount(); ++i )
|
|
||||||
{
|
|
||||||
const wxString& lib = m_githubLibs[i].AfterLast( '/' );
|
|
||||||
m_checkList3Dlibnames->Append( lib );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_textCtrlGithubURL->SetModified( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !m_checkList3Dlibnames->IsEmpty() )
|
|
||||||
m_checkList3Dlibnames->EnsureVisible( 0 );
|
|
||||||
|
|
||||||
// Clear the search box
|
|
||||||
m_searchCtrl3Dlibs->Clear();
|
|
||||||
|
|
||||||
// Clear the review list so it will be reloaded
|
|
||||||
m_libraries.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::updateGithubControls()
|
|
||||||
{
|
|
||||||
bool valid = wxFileName::IsDirWritable( getDownloadDir() );
|
|
||||||
|
|
||||||
// Shows or not the warning text if the target 3d folder does not exist, or is not
|
|
||||||
// writable.
|
|
||||||
m_invalidDirWarningText->Show( !valid );
|
|
||||||
m_bitmapDirWarn->Show( !valid );
|
|
||||||
|
|
||||||
// If the dialog starts with m_invalidDirWarningText and m_bitmapDirWarn not shown
|
|
||||||
// the size and position of the sizer containing these widgets can be incorrect,
|
|
||||||
// until a wxSizeEvent is fired, and the widgets are not shown, or truncated,
|
|
||||||
// at least on Windows. So fire a dummy wxSizeEvent if the size looks bad
|
|
||||||
if( m_invalidDirWarningText->IsShown() && m_invalidDirWarningText->GetSize().x < 2 )
|
|
||||||
{
|
|
||||||
wxSizeEvent event( GetSize() );
|
|
||||||
wxPostEvent( this, event );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allow to go further only if there is a valid target directory selected
|
|
||||||
enableNext( valid );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called when the local folder name is edited.
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::OnLocalFolderChange( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
updateGithubControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void WIZARD_3DSHAPE_LIBS_DOWNLOADER::setupDialogOrder()
|
|
||||||
{
|
|
||||||
m_welcomeDlg->SetNext( m_githubListDlg );
|
|
||||||
m_githubListDlg->SetPrev( m_welcomeDlg );
|
|
||||||
m_githubListDlg->SetNext( m_reviewDlg );
|
|
||||||
m_reviewDlg->SetPrev( m_githubListDlg );
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,154 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 CERN
|
|
||||||
* Code derived from "wizard_add_fplib.h" (from Maciej Suminski <maciej.suminski@cern.ch>)
|
|
||||||
* Copyright (C) 2014-2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 1992-2015 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <wizard_3DShape_Libs_downloader_base.h>
|
|
||||||
|
|
||||||
class KIWAY_PLAYER;
|
|
||||||
|
|
||||||
class WIZARD_3DSHAPE_LIBS_DOWNLOADER : public WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER( wxWindow* aParent );
|
|
||||||
~WIZARD_3DSHAPE_LIBS_DOWNLOADER();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetFirstPage
|
|
||||||
* Returns the welcoming page for the wizard.
|
|
||||||
*/
|
|
||||||
inline wxWizardPage* GetFirstPage() const
|
|
||||||
{
|
|
||||||
return m_welcomeDlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function GetGithubURL
|
|
||||||
* Returns the current Github repository URL set in the wizard.
|
|
||||||
*/
|
|
||||||
inline wxString GetGithubURL() const
|
|
||||||
{
|
|
||||||
return m_textCtrlGithubURL->GetValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function SetGithubURL
|
|
||||||
* Sets the current Github repository URL used by the wizard.
|
|
||||||
* @param aUrl is the new URL to be applied.
|
|
||||||
*/
|
|
||||||
inline void SetGithubURL( const wxString& aUrl )
|
|
||||||
{
|
|
||||||
m_textCtrlGithubURL->SetValue( aUrl );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wizard event handlers
|
|
||||||
void OnSourceCheck( wxCommandEvent& aEvent );
|
|
||||||
void OnCheckGithubList( wxCommandEvent& aEvent );
|
|
||||||
void OnPageChanged( wxWizardEvent& aEvent ) override;
|
|
||||||
void OnSelectAll3Dlibs( wxCommandEvent& aEvent ) override;
|
|
||||||
void OnUnselectAll3Dlibs( wxCommandEvent& aEvent ) override;
|
|
||||||
|
|
||||||
/** Called when the content of m_searchCtrl3Dlibs has changed.
|
|
||||||
* Rebuild the list of libraries, lib cacdidate first
|
|
||||||
*/
|
|
||||||
void OnChangeSearch( wxCommandEvent& aEvent ) override;
|
|
||||||
|
|
||||||
void OnWizardFinished( wxWizardEvent& aEvent ) override;
|
|
||||||
void OnBrowseButtonClick( wxCommandEvent& aEvent ) override;
|
|
||||||
void OnCheckSaveCopy( wxCommandEvent& aEvent );
|
|
||||||
void OnDefault3DPathButtonClick( wxCommandEvent& event ) override;
|
|
||||||
void OnGridLibReviewSize( wxSizeEvent& event ) override;
|
|
||||||
void OnLocalFolderChange( wxCommandEvent& event ) override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Initialization of wizard pages
|
|
||||||
void setupDialogOrder();
|
|
||||||
void setupGithubList(); // Prepare the second page
|
|
||||||
// (list of available .3dshapes libraries on github)
|
|
||||||
void setupReview(); // Prepare the last page
|
|
||||||
|
|
||||||
///> Sets the target directory for libraries downloaded from Github
|
|
||||||
void setDownloadDir( const wxString& aDir )
|
|
||||||
{
|
|
||||||
m_downloadDir->SetValue( aDir );
|
|
||||||
}
|
|
||||||
|
|
||||||
///> Gets the current target for downloaded libraries
|
|
||||||
inline wxString getDownloadDir() const
|
|
||||||
{
|
|
||||||
return m_downloadDir->GetValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
///> Downloads the list of Github libraries
|
|
||||||
void getLibsListGithub( wxArrayString& aList );
|
|
||||||
|
|
||||||
///> Saves a list of Github libraries locally.
|
|
||||||
bool downloadGithubLibsFromList( wxArrayString& aUrlList, wxString* aErrorMessage );
|
|
||||||
|
|
||||||
///> Saves a Github library aLibURL locally in aLocalLibName.
|
|
||||||
bool downloadOneLib( const wxString& aLibURL,
|
|
||||||
const wxString& aLocalLibName,
|
|
||||||
wxProgressDialog * aIndicator,
|
|
||||||
wxString* aErrorMessage );
|
|
||||||
|
|
||||||
///> Enables Github widgets depending on the selected options.
|
|
||||||
void updateGithubControls();
|
|
||||||
|
|
||||||
///> Enables/disable 'Next' button
|
|
||||||
inline void enableNext( bool aEnable )
|
|
||||||
{
|
|
||||||
wxWindow* nextBtn = FindWindowById( wxID_FORWARD );
|
|
||||||
|
|
||||||
if( nextBtn )
|
|
||||||
nextBtn->Enable( aEnable );
|
|
||||||
}
|
|
||||||
|
|
||||||
// A callback function to filter 3D filenames
|
|
||||||
static bool filter3dshapesfiles( const wxString& aData )
|
|
||||||
{
|
|
||||||
return aData.Contains( wxT( ".wrl" ) ) ||
|
|
||||||
aData.Contains( wxT( ".wings" ) ) ||
|
|
||||||
aData.Contains( wxT( ".stp" ) ) ||
|
|
||||||
aData.Contains( wxT( ".step" ) ) ||
|
|
||||||
aData.Contains( wxT( ".STP" ) ) ||
|
|
||||||
aData.Contains( wxT( ".STEP" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// A callback function to filter 3D folders names
|
|
||||||
static bool filter3dshapeslibraries( const wxString& aData )
|
|
||||||
{
|
|
||||||
return aData.Contains( wxT( ".3dshapes" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
///> Cache for the downloaded Github library list
|
|
||||||
wxArrayString m_githubLibs;
|
|
||||||
|
|
||||||
///> Libraries names selected in the wizard
|
|
||||||
wxArrayString m_libraries;
|
|
||||||
|
|
||||||
// Aliases for wizard pages to make code more readable
|
|
||||||
wxWizardPageSimple* m_welcomeDlg;
|
|
||||||
wxWizardPageSimple* m_githubListDlg;
|
|
||||||
wxWizardPageSimple* m_reviewDlg;
|
|
||||||
};
|
|
|
@ -1,251 +0,0 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
|
||||||
// http://www.wxformbuilder.org/
|
|
||||||
//
|
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "wizard_3DShape_Libs_downloader_base.h"
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxBitmap& bitmap, const wxPoint& pos, long style )
|
|
||||||
{
|
|
||||||
this->Create( parent, id, title, bitmap, pos, style );
|
|
||||||
this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize );
|
|
||||||
|
|
||||||
wxWizardPageSimple* m_wizPage1 = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
|
||||||
m_pages.Add( m_wizPage1 );
|
|
||||||
|
|
||||||
m_wizPage1->SetMinSize( wxSize( 720,480 ) );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizer1;
|
|
||||||
bSizer1 = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_staticTextWelcome = new wxStaticText( m_wizPage1, wxID_ANY, _("Welcome to the 3D shape Libraries downloader Wizard!"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticTextWelcome->Wrap( -1 );
|
|
||||||
bSizer1->Add( m_staticTextWelcome, 0, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer1->Add( 0, 20, 0, 0, 5 );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizer19;
|
|
||||||
bSizer19 = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_staticText8 = new wxStaticText( m_wizPage1, wxID_ANY, _("Please select the URL for the 3D libraries to download"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticText8->Wrap( -1 );
|
|
||||||
bSizer19->Add( m_staticText8, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
m_textCtrlGithubURL = new wxTextCtrl( m_wizPage1, wxID_ANY, _("https://github.com/KiCad/packages3d"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_textCtrlGithubURL->SetMinSize( wxSize( 300,-1 ) );
|
|
||||||
|
|
||||||
bSizer19->Add( m_textCtrlGithubURL, 0, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer19->Add( 0, 10, 0, 0, 5 );
|
|
||||||
|
|
||||||
wxFlexGridSizer* fgSizerLocalFolder;
|
|
||||||
fgSizerLocalFolder = new wxFlexGridSizer( 0, 2, 0, 0 );
|
|
||||||
fgSizerLocalFolder->AddGrowableCol( 0 );
|
|
||||||
fgSizerLocalFolder->SetFlexibleDirection( wxBOTH );
|
|
||||||
fgSizerLocalFolder->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizerDinname;
|
|
||||||
bSizerDinname = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_staticText9 = new wxStaticText( m_wizPage1, wxID_ANY, _("3D shape local folder:"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticText9->Wrap( -1 );
|
|
||||||
bSizerDinname->Add( m_staticText9, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
m_downloadDir = new wxTextCtrl( m_wizPage1, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizerDinname->Add( m_downloadDir, 0, wxRIGHT|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
fgSizerLocalFolder->Add( bSizerDinname, 1, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizerButts;
|
|
||||||
bSizerButts = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_btnBrowse = new wxButton( m_wizPage1, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizerButts->Add( m_btnBrowse, 0, wxEXPAND|wxALL, 5 );
|
|
||||||
|
|
||||||
m_buttonDefault3DPath = new wxButton( m_wizPage1, wxID_ANY, _("Default 3D Path"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizerButts->Add( m_buttonDefault3DPath, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
fgSizerLocalFolder->Add( bSizerButts, 0, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizerWarnMsg;
|
|
||||||
bSizerWarnMsg = new wxBoxSizer( wxHORIZONTAL );
|
|
||||||
|
|
||||||
m_bitmapDirWarn = new wxStaticBitmap( m_wizPage1, wxID_ANY, wxArtProvider::GetBitmap( wxART_ERROR, wxART_OTHER ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizerWarnMsg->Add( m_bitmapDirWarn, 0, wxALL, 5 );
|
|
||||||
|
|
||||||
m_invalidDirWarningText = new wxStaticText( m_wizPage1, wxID_ANY, _("It is not possible to write in the selected directory.\nPlease choose another one."), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE );
|
|
||||||
m_invalidDirWarningText->Wrap( -1 );
|
|
||||||
m_invalidDirWarningText->SetForegroundColour( wxColour( 255, 0, 0 ) );
|
|
||||||
|
|
||||||
bSizerWarnMsg->Add( m_invalidDirWarningText, 0, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
fgSizerLocalFolder->Add( bSizerWarnMsg, 1, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
fgSizerLocalFolder->Add( 10, 40, 0, 0, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer19->Add( fgSizerLocalFolder, 1, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer1->Add( bSizer19, 1, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizerOfficialRepo;
|
|
||||||
bSizerOfficialRepo = new wxBoxSizer( wxHORIZONTAL );
|
|
||||||
|
|
||||||
m_bitmapRepo = new wxStaticBitmap( m_wizPage1, wxID_ANY, wxArtProvider::GetBitmap( wxART_INFORMATION, wxART_OTHER ), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizerOfficialRepo->Add( m_bitmapRepo, 0, wxALL, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizerOfficialRepo->Add( 0, 0, 0, wxRIGHT|wxLEFT, 10 );
|
|
||||||
|
|
||||||
m_hyperlinkGithubKicad = new wxHyperlinkCtrl( m_wizPage1, wxID_ANY, _("Visit our official Kicad repository on Github and get more libraries"), wxT("https://github.com/KiCad"), wxDefaultPosition, wxDefaultSize, wxHL_DEFAULT_STYLE );
|
|
||||||
bSizerOfficialRepo->Add( m_hyperlinkGithubKicad, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer1->Add( bSizerOfficialRepo, 0, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
m_wizPage1->SetSizer( bSizer1 );
|
|
||||||
m_wizPage1->Layout();
|
|
||||||
wxWizardPageSimple* m_wizPage2_Github = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
|
||||||
m_pages.Add( m_wizPage2_Github );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizer111;
|
|
||||||
bSizer111 = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_staticText112 = new wxStaticText( m_wizPage2_Github, wxID_ANY, _("Select Github libraries to add:"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticText112->Wrap( -1 );
|
|
||||||
bSizer111->Add( m_staticText112, 0, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
wxArrayString m_checkList3DlibnamesChoices;
|
|
||||||
m_checkList3Dlibnames = new wxCheckListBox( m_wizPage2_Github, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_checkList3DlibnamesChoices, wxLB_MULTIPLE|wxLB_NEEDED_SB );
|
|
||||||
bSizer111->Add( m_checkList3Dlibnames, 1, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizer7;
|
|
||||||
bSizer7 = new wxBoxSizer( wxHORIZONTAL );
|
|
||||||
|
|
||||||
m_btnSelectAll3Dlibs = new wxButton( m_wizPage2_Github, wxID_ANY, _("Select all"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizer7->Add( m_btnSelectAll3Dlibs, 1, wxALL, 5 );
|
|
||||||
|
|
||||||
m_btnUnselectAll3Dlibs = new wxButton( m_wizPage2_Github, wxID_ANY, _("Unselect all"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
bSizer7->Add( m_btnUnselectAll3Dlibs, 1, wxALL, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer7->Add( 0, 0, 1, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
m_searchCtrl3Dlibs = new wxSearchCtrl( m_wizPage2_Github, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
#ifndef __WXMAC__
|
|
||||||
m_searchCtrl3Dlibs->ShowSearchButton( true );
|
|
||||||
#endif
|
|
||||||
m_searchCtrl3Dlibs->ShowCancelButton( false );
|
|
||||||
bSizer7->Add( m_searchCtrl3Dlibs, 2, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
bSizer111->Add( bSizer7, 0, wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
m_wizPage2_Github->SetSizer( bSizer111 );
|
|
||||||
m_wizPage2_Github->Layout();
|
|
||||||
bSizer111->Fit( m_wizPage2_Github );
|
|
||||||
wxWizardPageSimple* m_wizPage3_SelectTarget = new wxWizardPageSimple( this, NULL, NULL, wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ) );
|
|
||||||
m_pages.Add( m_wizPage3_SelectTarget );
|
|
||||||
|
|
||||||
wxBoxSizer* bSizer12;
|
|
||||||
bSizer12 = new wxBoxSizer( wxVERTICAL );
|
|
||||||
|
|
||||||
m_staticTextlocalfolder = new wxStaticText( m_wizPage3_SelectTarget, wxID_ANY, _("Local library folder:"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticTextlocalfolder->Wrap( -1 );
|
|
||||||
bSizer12->Add( m_staticTextlocalfolder, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
m_LocalFolderInfo = new wxStaticText( m_wizPage3_SelectTarget, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_LocalFolderInfo->Wrap( -1 );
|
|
||||||
bSizer12->Add( m_LocalFolderInfo, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
m_staticText12 = new wxStaticText( m_wizPage3_SelectTarget, wxID_ANY, _("3D shape libraries to be downloaded:"), wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
m_staticText12->Wrap( -1 );
|
|
||||||
bSizer12->Add( m_staticText12, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
|
||||||
|
|
||||||
m_gridLibReview = new wxGrid( m_wizPage3_SelectTarget, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
|
||||||
|
|
||||||
// Grid
|
|
||||||
m_gridLibReview->CreateGrid( 1, 2 );
|
|
||||||
m_gridLibReview->EnableEditing( false );
|
|
||||||
m_gridLibReview->EnableGridLines( true );
|
|
||||||
m_gridLibReview->EnableDragGridSize( false );
|
|
||||||
m_gridLibReview->SetMargins( 5, 0 );
|
|
||||||
|
|
||||||
// Columns
|
|
||||||
m_gridLibReview->SetColSize( 0, 150 );
|
|
||||||
m_gridLibReview->SetColSize( 1, 300 );
|
|
||||||
m_gridLibReview->EnableDragColMove( false );
|
|
||||||
m_gridLibReview->EnableDragColSize( true );
|
|
||||||
m_gridLibReview->SetColLabelSize( 30 );
|
|
||||||
m_gridLibReview->SetColLabelValue( 0, _("Status") );
|
|
||||||
m_gridLibReview->SetColLabelValue( 1, _("Libraries") );
|
|
||||||
m_gridLibReview->SetColLabelValue( 2, wxEmptyString );
|
|
||||||
m_gridLibReview->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
|
||||||
|
|
||||||
// Rows
|
|
||||||
m_gridLibReview->AutoSizeRows();
|
|
||||||
m_gridLibReview->EnableDragRowSize( true );
|
|
||||||
m_gridLibReview->SetRowLabelSize( 30 );
|
|
||||||
m_gridLibReview->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
|
|
||||||
|
|
||||||
// Label Appearance
|
|
||||||
|
|
||||||
// Cell Defaults
|
|
||||||
m_gridLibReview->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
|
|
||||||
bSizer12->Add( m_gridLibReview, 1, wxALL|wxEXPAND, 5 );
|
|
||||||
|
|
||||||
|
|
||||||
m_wizPage3_SelectTarget->SetSizer( bSizer12 );
|
|
||||||
m_wizPage3_SelectTarget->Layout();
|
|
||||||
bSizer12->Fit( m_wizPage3_SelectTarget );
|
|
||||||
|
|
||||||
this->Centre( wxBOTH );
|
|
||||||
|
|
||||||
for ( unsigned int i = 1; i < m_pages.GetCount(); i++ )
|
|
||||||
{
|
|
||||||
m_pages.Item( i )->SetPrev( m_pages.Item( i - 1 ) );
|
|
||||||
m_pages.Item( i - 1 )->SetNext( m_pages.Item( i ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Connect Events
|
|
||||||
this->Connect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnWizardFinished ) );
|
|
||||||
this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnPageChanged ) );
|
|
||||||
this->Connect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnPageChanging ) );
|
|
||||||
m_downloadDir->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnLocalFolderChange ), NULL, this );
|
|
||||||
m_btnBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnBrowseButtonClick ), NULL, this );
|
|
||||||
m_buttonDefault3DPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnDefault3DPathButtonClick ), NULL, this );
|
|
||||||
m_btnSelectAll3Dlibs->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnSelectAll3Dlibs ), NULL, this );
|
|
||||||
m_btnUnselectAll3Dlibs->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnUnselectAll3Dlibs ), NULL, this );
|
|
||||||
m_searchCtrl3Dlibs->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnChangeSearch ), NULL, this );
|
|
||||||
m_gridLibReview->Connect( wxEVT_SIZE, wxSizeEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnGridLibReviewSize ), NULL, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::~WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE()
|
|
||||||
{
|
|
||||||
// Disconnect Events
|
|
||||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_FINISHED, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnWizardFinished ) );
|
|
||||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGED, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnPageChanged ) );
|
|
||||||
this->Disconnect( wxID_ANY, wxEVT_WIZARD_PAGE_CHANGING, wxWizardEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnPageChanging ) );
|
|
||||||
m_downloadDir->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnLocalFolderChange ), NULL, this );
|
|
||||||
m_btnBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnBrowseButtonClick ), NULL, this );
|
|
||||||
m_buttonDefault3DPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnDefault3DPathButtonClick ), NULL, this );
|
|
||||||
m_btnSelectAll3Dlibs->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnSelectAll3Dlibs ), NULL, this );
|
|
||||||
m_btnUnselectAll3Dlibs->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnUnselectAll3Dlibs ), NULL, this );
|
|
||||||
m_searchCtrl3Dlibs->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnChangeSearch ), NULL, this );
|
|
||||||
m_gridLibReview->Disconnect( wxEVT_SIZE, wxSizeEventHandler( WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE::OnGridLibReviewSize ), NULL, this );
|
|
||||||
|
|
||||||
m_pages.Clear();
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,88 +0,0 @@
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
// C++ code generated with wxFormBuilder (version Aug 4 2017)
|
|
||||||
// http://www.wxformbuilder.org/
|
|
||||||
//
|
|
||||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef __WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE_H__
|
|
||||||
#define __WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE_H__
|
|
||||||
|
|
||||||
#include <wx/artprov.h>
|
|
||||||
#include <wx/xrc/xmlres.h>
|
|
||||||
#include <wx/intl.h>
|
|
||||||
#include <wx/string.h>
|
|
||||||
#include <wx/stattext.h>
|
|
||||||
#include <wx/gdicmn.h>
|
|
||||||
#include <wx/font.h>
|
|
||||||
#include <wx/colour.h>
|
|
||||||
#include <wx/settings.h>
|
|
||||||
#include <wx/textctrl.h>
|
|
||||||
#include <wx/sizer.h>
|
|
||||||
#include <wx/button.h>
|
|
||||||
#include <wx/bitmap.h>
|
|
||||||
#include <wx/image.h>
|
|
||||||
#include <wx/icon.h>
|
|
||||||
#include <wx/statbmp.h>
|
|
||||||
#include <wx/hyperlink.h>
|
|
||||||
#include <wx/checklst.h>
|
|
||||||
#include <wx/srchctrl.h>
|
|
||||||
#include <wx/grid.h>
|
|
||||||
#include <wx/wizard.h>
|
|
||||||
#include <wx/dynarray.h>
|
|
||||||
WX_DEFINE_ARRAY_PTR( wxWizardPageSimple*, WizardPages );
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
/// Class WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
class WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE : public wxWizard
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
protected:
|
|
||||||
wxStaticText* m_staticTextWelcome;
|
|
||||||
wxStaticText* m_staticText8;
|
|
||||||
wxTextCtrl* m_textCtrlGithubURL;
|
|
||||||
wxStaticText* m_staticText9;
|
|
||||||
wxTextCtrl* m_downloadDir;
|
|
||||||
wxButton* m_btnBrowse;
|
|
||||||
wxButton* m_buttonDefault3DPath;
|
|
||||||
wxStaticBitmap* m_bitmapDirWarn;
|
|
||||||
wxStaticText* m_invalidDirWarningText;
|
|
||||||
wxStaticBitmap* m_bitmapRepo;
|
|
||||||
wxHyperlinkCtrl* m_hyperlinkGithubKicad;
|
|
||||||
wxStaticText* m_staticText112;
|
|
||||||
wxCheckListBox* m_checkList3Dlibnames;
|
|
||||||
wxButton* m_btnSelectAll3Dlibs;
|
|
||||||
wxButton* m_btnUnselectAll3Dlibs;
|
|
||||||
wxSearchCtrl* m_searchCtrl3Dlibs;
|
|
||||||
wxStaticText* m_staticTextlocalfolder;
|
|
||||||
wxStaticText* m_LocalFolderInfo;
|
|
||||||
wxStaticText* m_staticText12;
|
|
||||||
wxGrid* m_gridLibReview;
|
|
||||||
|
|
||||||
// Virtual event handlers, overide them in your derived class
|
|
||||||
virtual void OnWizardFinished( wxWizardEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnPageChanged( wxWizardEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnPageChanging( wxWizardEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnLocalFolderChange( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnBrowseButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnDefault3DPathButtonClick( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnSelectAll3Dlibs( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnUnselectAll3Dlibs( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnChangeSearch( wxCommandEvent& event ) { event.Skip(); }
|
|
||||||
virtual void OnGridLibReviewSize( wxSizeEvent& event ) { event.Skip(); }
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Add 3D Shape Libraries Wizard"), const wxBitmap& bitmap = wxArtProvider::GetBitmap( wxART_HELP_BOOK, wxART_FRAME_ICON ), const wxPoint& pos = wxDefaultPosition, long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxRESIZE_BORDER );
|
|
||||||
WizardPages m_pages;
|
|
||||||
~WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE();
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //__WIZARD_3DSHAPE_LIBS_DOWNLOADER_BASE_H__
|
|
|
@ -1,46 +0,0 @@
|
||||||
# This program source code file is part of KICAD, a free EDA CAD application.
|
|
||||||
#
|
|
||||||
# Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
||||||
# Copyright (C) 2013-2015 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
|
|
||||||
|
|
||||||
# These are additions to any inherited from pcbnew dir:
|
|
||||||
include_directories( . )
|
|
||||||
|
|
||||||
include_directories( ${CURL_INCLUDE_DIRS} )
|
|
||||||
|
|
||||||
set( GITHUB_PLUGIN_SRCS
|
|
||||||
github_plugin.cpp
|
|
||||||
github_getliblist.cpp
|
|
||||||
html_link_parser.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library( github_plugin STATIC ${GITHUB_PLUGIN_SRCS} )
|
|
||||||
|
|
||||||
target_link_libraries( github_plugin
|
|
||||||
common
|
|
||||||
)
|
|
||||||
|
|
||||||
if( MINGW )
|
|
||||||
target_link_libraries( github_plugin
|
|
||||||
${wxWidgets_LIBRARIES}
|
|
||||||
ws2_32
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,242 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
||||||
* Copyright (C) 2015-2020 KiCad Developers, see CHANGELOG.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
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* While creating a wizard to edit the fp lib tables, and mainly the web viewer
|
|
||||||
* which can read the list of pretty library on a github repos, I was told there is
|
|
||||||
* this URL to retrieve info from any particular repo:
|
|
||||||
*
|
|
||||||
* https://api.github.com/orgs/KiCad/repos
|
|
||||||
* or
|
|
||||||
* https://api.github.com/users/KiCad/repos
|
|
||||||
*
|
|
||||||
* This gets just information on the repo in JSON format.
|
|
||||||
*
|
|
||||||
* I used avhttp, already used in the pcbnew Github plugin to download
|
|
||||||
* the json file.
|
|
||||||
*
|
|
||||||
* JP Charras.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <kicad_curl/kicad_curl_easy.h> // Include before any wx file
|
|
||||||
#include <wx/uri.h>
|
|
||||||
|
|
||||||
#include <github_getliblist.h>
|
|
||||||
#include <macros.h>
|
|
||||||
#include <richio.h>
|
|
||||||
#include <html_link_parser.h>
|
|
||||||
|
|
||||||
|
|
||||||
GITHUB_GETLIBLIST::GITHUB_GETLIBLIST( const wxString& aRepoURL )
|
|
||||||
{
|
|
||||||
m_repoURL = aRepoURL;
|
|
||||||
m_libs_ext = wxT( ".pretty" );
|
|
||||||
strcpy( m_option_string, "application/json" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_GETLIBLIST::Get3DshapesLibsList( wxArrayString* aList,
|
|
||||||
bool (*aFilter)( const wxString& aData ) )
|
|
||||||
{
|
|
||||||
std::string fullURLCommand;
|
|
||||||
|
|
||||||
strcpy( m_option_string, "text/html" );
|
|
||||||
|
|
||||||
wxString errorMsg;
|
|
||||||
|
|
||||||
wxString repoURL = m_repoURL;
|
|
||||||
fullURLCommand = repoURL.utf8_str();
|
|
||||||
bool success = remoteGetJSON( fullURLCommand, &errorMsg );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
{
|
|
||||||
wxMessageBox( errorMsg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aFilter && aList )
|
|
||||||
{
|
|
||||||
//Convert m_image (std::string) to a wxString for HTML_LINK_PARSER
|
|
||||||
wxString buffer( GetBuffer() );
|
|
||||||
|
|
||||||
HTML_LINK_PARSER html_parser( buffer, *aList );
|
|
||||||
html_parser.ParseLinks( aFilter );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_GETLIBLIST::GetFootprintLibraryList( wxArrayString& aList )
|
|
||||||
{
|
|
||||||
std::string fullURLCommand;
|
|
||||||
int page = 1;
|
|
||||||
int itemCountMax = 99; // Do not use a value >= 100, it does not work
|
|
||||||
|
|
||||||
strcpy( m_option_string, "application/json" );
|
|
||||||
|
|
||||||
// Github max items returned is 100 per page
|
|
||||||
|
|
||||||
if( !repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page ) )
|
|
||||||
{
|
|
||||||
wxString msg = wxString::Format( _( "malformed URL:\n\"%s\"" ), m_repoURL );
|
|
||||||
wxMessageBox( msg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The URL lib names are relative to the server name.
|
|
||||||
// so add the server name to them.
|
|
||||||
wxURI repo( m_repoURL );
|
|
||||||
wxString urlPrefix = repo.GetScheme() + wxT( "://" ) + repo.GetServer() + wxT( "/" );
|
|
||||||
|
|
||||||
wxString errorMsg;
|
|
||||||
const char sep = ','; // Separator fields, in json returned file
|
|
||||||
wxString tmp;
|
|
||||||
int items_count_per_page = 0;
|
|
||||||
std::string& json_image = GetBuffer();
|
|
||||||
|
|
||||||
while( 1 )
|
|
||||||
{
|
|
||||||
bool success = remoteGetJSON( fullURLCommand, &errorMsg );
|
|
||||||
|
|
||||||
if( !success )
|
|
||||||
{
|
|
||||||
wxMessageBox( errorMsg );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for( unsigned ii = 0; ii < json_image.size(); ii++ )
|
|
||||||
{
|
|
||||||
if( json_image[ii] == sep || ii == json_image.size() - 1 )
|
|
||||||
{
|
|
||||||
if( tmp.StartsWith( wxT( "\"full_name\"" ) ) )
|
|
||||||
{
|
|
||||||
#define QUOTE '\"'
|
|
||||||
// Remove useless quotes:
|
|
||||||
if( tmp[tmp.Length() - 1] == QUOTE )
|
|
||||||
tmp.RemoveLast();
|
|
||||||
|
|
||||||
if( tmp.EndsWith( m_libs_ext ) )
|
|
||||||
{
|
|
||||||
aList.Add( tmp.AfterLast( ':' ) );
|
|
||||||
int idx = aList.GetCount() - 1;
|
|
||||||
|
|
||||||
if( aList[idx][0] == QUOTE )
|
|
||||||
aList[idx].Remove( 0, 1 );
|
|
||||||
|
|
||||||
aList[idx].Prepend( urlPrefix );
|
|
||||||
}
|
|
||||||
|
|
||||||
items_count_per_page++;
|
|
||||||
}
|
|
||||||
|
|
||||||
tmp.Clear();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tmp << json_image[ii];
|
|
||||||
}
|
|
||||||
|
|
||||||
if( items_count_per_page >= itemCountMax )
|
|
||||||
{
|
|
||||||
page++;
|
|
||||||
repoURL2listURL( m_repoURL, &fullURLCommand, itemCountMax, page );
|
|
||||||
items_count_per_page = 0;
|
|
||||||
ClearBuffer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
aList.Sort();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL,
|
|
||||||
std::string* aFullURLCommand,
|
|
||||||
int aItemCountMax, int aPage )
|
|
||||||
{
|
|
||||||
// aListURL is e.g. "https://api.github.com/orgs/KiCad/repos"
|
|
||||||
// or "https://api.github.com/users/KiCad/repos"
|
|
||||||
// aRepoURL is e.g. "https://github.com/KiCad"
|
|
||||||
// Github has a default pagination set to 30 items.
|
|
||||||
// but allows up to 100 items max if we add the "?per_page=100" option
|
|
||||||
|
|
||||||
wxURI repo( aRepoURL );
|
|
||||||
|
|
||||||
if( repo.HasServer() && repo.HasPath() )
|
|
||||||
{
|
|
||||||
// goal: "https://api.github.com/users/KiCad"
|
|
||||||
// or "https://api.github.com/orgs/KiCad"
|
|
||||||
// "https://api.github.com/users/..." works both for orgs and users
|
|
||||||
// if we just retrieve the .pretty list
|
|
||||||
wxString target_url( wxT( "https://api.github.com/users" ) );
|
|
||||||
target_url += repo.GetPath();
|
|
||||||
target_url += wxT( "/repos" );
|
|
||||||
|
|
||||||
// Github has a default pagination set to 30 items.
|
|
||||||
// but allows up to 100 items max. Use this limit
|
|
||||||
target_url += wxString::Format( "?per_page=%d&page=%d", aItemCountMax, aPage );
|
|
||||||
|
|
||||||
*aFullURLCommand = target_url.utf8_str();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_GETLIBLIST::remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError )
|
|
||||||
{
|
|
||||||
KICAD_CURL_EASY kcurl;
|
|
||||||
|
|
||||||
kcurl.SetURL( aFullURLCommand );
|
|
||||||
kcurl.SetUserAgent( "http://kicad-pcb.org" );
|
|
||||||
kcurl.SetHeader( "Accept", m_option_string );
|
|
||||||
kcurl.SetFollowRedirects( true );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
kcurl.Perform();
|
|
||||||
m_image = kcurl.GetBuffer();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& ioe )
|
|
||||||
{
|
|
||||||
if( aMsgError )
|
|
||||||
{
|
|
||||||
UTF8 fmt( _( "Error fetching JSON data from URL \"%s\".\nReason: \"%s\"" ) );
|
|
||||||
|
|
||||||
std::string msg = StrPrintf( fmt.c_str(),
|
|
||||||
aFullURLCommand.c_str(),
|
|
||||||
TO_UTF8( ioe.What() ) );
|
|
||||||
|
|
||||||
*aMsgError = FROM_UTF8( msg.c_str() );
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,124 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 Jean-Pierre Charras jp.charras at wanadoo.fr
|
|
||||||
* Copyright (C) 2015-2017 KiCad Developers, see CHANGELOG.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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GITHUB_GETLIBLIST_H_
|
|
||||||
#define GITHUB_GETLIBLIST_H_
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GITHUB_GETLIBLIST
|
|
||||||
* implements a portion of pcbnew's PLUGIN interface to provide read only access
|
|
||||||
* to a github repo to extract pretty footprints library list, in json format,
|
|
||||||
* or extract 3D shapes libraries list (.3dshapes folders) and download the 3d shapes files
|
|
||||||
*
|
|
||||||
* To extract pretty footprints library list, this plugin simply reads in
|
|
||||||
* a zip file of the repo and unzips it from RAM as needed.
|
|
||||||
* Therefore this "Github" plugin is <b>read only</b> for accessing remote
|
|
||||||
* at "https://api.github.com/orgs/KiCad/repos"
|
|
||||||
*
|
|
||||||
* To extract 3D shapes libraries list (.3dshapes folders) we cannot use api.github.com
|
|
||||||
* to read this list, because it is in a subdirectory of "https://github.com/KiCad".
|
|
||||||
* The corresponding html page of the server is read, and URLs of all .3dshapes folders
|
|
||||||
* are extracted.
|
|
||||||
* files are then read from "https://raw.githubusercontent.com/<lib path>", but not zipped
|
|
||||||
* because they are not accessible in zipped form.
|
|
||||||
*/
|
|
||||||
class GITHUB_GETLIBLIST
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// -----<API>----------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills aList by the name of footprint libraries found on the github repo
|
|
||||||
*/
|
|
||||||
bool GetFootprintLibraryList( wxArrayString& aList );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fills aList by the URL of libraries found on the github repo
|
|
||||||
* @param aList = a reference to a wxArrayString to fill with names
|
|
||||||
* @param aFilter( const wxString& aData ) = a callback funtion to
|
|
||||||
* to filter URLs to put in aList.
|
|
||||||
* If NULL, no URL will be stored in aList
|
|
||||||
*/
|
|
||||||
bool Get3DshapesLibsList( wxArrayString* aList,
|
|
||||||
bool (*aFilter)( const wxString& aData ) );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the buffer which stores all the downloaded raw data
|
|
||||||
*/
|
|
||||||
std::string& GetBuffer() { return m_image; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear the buffer which stores all the downloaded raw data
|
|
||||||
*/
|
|
||||||
void ClearBuffer() { m_image.clear(); }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The library names are expecting ending by .pretty
|
|
||||||
* SetLibraryExt set the extension to aExt
|
|
||||||
*/
|
|
||||||
void SetLibraryExt( const wxString& aExt ) { m_libs_ext = aExt; }
|
|
||||||
|
|
||||||
// -----</API>---------------------------------------------------------
|
|
||||||
|
|
||||||
GITHUB_GETLIBLIST( const wxString& aRepoURL );
|
|
||||||
~GITHUB_GETLIBLIST() {}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function repoURL2listURL
|
|
||||||
* translates a repo URL to the URL name which gives the state of repos URL
|
|
||||||
* as commonly seen on github.com
|
|
||||||
*
|
|
||||||
* @param aRepoURL points to the base of the repo.
|
|
||||||
* @param aFullURLCommand is URL the full URL command (URL+options).
|
|
||||||
* @param aItemCountMax is the max item count in a page,
|
|
||||||
* and is 100 for github repo.
|
|
||||||
* @param aPage is the page number, if there are more than one page in repo.
|
|
||||||
* @return bool - true if @a aRepoULR was parseable, else false
|
|
||||||
*/
|
|
||||||
bool repoURL2listURL( const wxString& aRepoURL, std::string* aFullURLCommand,
|
|
||||||
int aItemCountMax, int aPage = 1 );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function remoteGetJSON
|
|
||||||
* Download a json text from a github repo. The text image
|
|
||||||
* is received into the m_input_stream.
|
|
||||||
* @param aFullURLCommand the full command, i.e. the url with options like
|
|
||||||
* "https://api.github.com/users/KiCad/repos?per_page=100?page=1"
|
|
||||||
* @param aMsgError a pointer to a wxString which can store an error message
|
|
||||||
* @return true if OK, false if error (which an error message in *aMsgError
|
|
||||||
*/
|
|
||||||
bool remoteGetJSON( const std::string& aFullURLCommand, wxString* aMsgError );
|
|
||||||
|
|
||||||
wxString m_github_path; ///< Something like https://api.github.com/orgs/KiCad
|
|
||||||
std::string m_image; ///< image of the downloaded data in its entirety.
|
|
||||||
wxString m_repoURL; ///< the URL of the Github repo
|
|
||||||
wxString m_libs_ext; ///< the extension of the name of libraries (default = .pretty)
|
|
||||||
char m_option_string[64]; ///< option for transfert type, like "application/json"
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GITHUB_GETLIBLIST_H_
|
|
|
@ -1,632 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2015 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
||||||
* Copyright (C) 2016-2020 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Note:
|
|
||||||
If you are using this plugin without the supporting nginx caching server, then you
|
|
||||||
will never be happy with its performance. However, it is the fastest plugin in
|
|
||||||
existence when used with a local nginx and the nginx configuration file in this
|
|
||||||
directory. Nginx can be running in house on your network anywhere for this statement
|
|
||||||
to be true.
|
|
||||||
|
|
||||||
Comments below pertain to use without nginx, so are not relevant in every case:
|
|
||||||
|
|
||||||
While exploring the possibility of local caching of the zip file, I discovered
|
|
||||||
this command to retrieve the time stamp of the last commit into any particular
|
|
||||||
repo:
|
|
||||||
|
|
||||||
$time curl -I -i https://api.github.com/repos/KiCad/Mounting_Holes.pretty/commits
|
|
||||||
|
|
||||||
This gets just the header to what would otherwise return information on the repo
|
|
||||||
in JSON format, and is reasonably faster than actually getting the repo
|
|
||||||
in zip form. However it still takes 5 seconds or more when github is busy, so
|
|
||||||
I have lost my enthusiasm for local caching until a faster time stamp retrieval
|
|
||||||
mechanism can be found, or github gets more servers. But note that the occasionally
|
|
||||||
slow response is the exception rather than the norm. Normally the response is
|
|
||||||
down around a 1/3 of a second. The information we would use is in the header
|
|
||||||
named "Last-Modified" as seen below.
|
|
||||||
|
|
||||||
HTTP/1.1 200 OK
|
|
||||||
Server: GitHub.com
|
|
||||||
Date: Mon, 27 Jan 2014 15:46:46 GMT
|
|
||||||
Content-Type: application/json; charset=utf-8
|
|
||||||
Status: 200 OK
|
|
||||||
X-RateLimit-Limit: 60
|
|
||||||
X-RateLimit-Remaining: 49
|
|
||||||
X-RateLimit-Reset: 1390839612
|
|
||||||
Cache-Control: public, max-age=60, s-maxage=60
|
|
||||||
Last-Modified: Mon, 02 Dec 2013 10:08:51 GMT
|
|
||||||
ETag: "3d04d760f469f2516a51a56eac63bbd5"
|
|
||||||
Vary: Accept
|
|
||||||
X-GitHub-Media-Type: github.beta
|
|
||||||
X-Content-Type-Options: nosniff
|
|
||||||
Content-Length: 6310
|
|
||||||
Access-Control-Allow-Credentials: true
|
|
||||||
Access-Control-Expose-Headers: ETag, Link, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval
|
|
||||||
Access-Control-Allow-Origin: *
|
|
||||||
X-GitHub-Request-Id: 411087C2:659E:50FD6E6:52E67F66
|
|
||||||
Vary: Accept-Encoding
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <boost/ptr_container/ptr_map.hpp>
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include <kicad_curl/kicad_curl_easy.h> // Include before any wx file
|
|
||||||
|
|
||||||
#include <wx/zipstrm.h>
|
|
||||||
#include <wx/mstream.h>
|
|
||||||
#include <wx/uri.h>
|
|
||||||
|
|
||||||
#include <io_mgr.h>
|
|
||||||
#include <richio.h>
|
|
||||||
#include <plugins/kicad/pcb_parser.h>
|
|
||||||
#include <class_board.h>
|
|
||||||
#include <github_plugin.h>
|
|
||||||
#include <class_module.h>
|
|
||||||
#include <fp_lib_table.h> // ExpandSubstitutions()
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
static const char* PRETTY_DIR = "allow_pretty_writing_to_this_dir";
|
|
||||||
|
|
||||||
|
|
||||||
typedef boost::ptr_map< wxString, wxZipEntry > MODULE_MAP;
|
|
||||||
typedef MODULE_MAP::iterator MODULE_ITER;
|
|
||||||
typedef MODULE_MAP::const_iterator MODULE_CITER;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* GH_CACHE
|
|
||||||
* assists only within GITHUB_PLUGIN and holds a map of footprint name to wxZipEntry
|
|
||||||
*/
|
|
||||||
struct GH_CACHE : public MODULE_MAP
|
|
||||||
{
|
|
||||||
// MODULE_MAP is a boost::ptr_map template, made into a class hereby.
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
GITHUB_PLUGIN::GITHUB_PLUGIN() :
|
|
||||||
PCB_IO(),
|
|
||||||
m_gh_cache( 0 )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
GITHUB_PLUGIN::~GITHUB_PLUGIN()
|
|
||||||
{
|
|
||||||
delete m_gh_cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const wxString GITHUB_PLUGIN::PluginName() const
|
|
||||||
{
|
|
||||||
return "Github";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const wxString GITHUB_PLUGIN::GetFileExtension() const
|
|
||||||
{
|
|
||||||
return wxEmptyString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
|
||||||
bool aBestEfforts, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cacheLib( aLibPath, aProperties );
|
|
||||||
|
|
||||||
typedef std::set<wxString> MYSET;
|
|
||||||
|
|
||||||
MYSET unique;
|
|
||||||
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
{
|
|
||||||
wxArrayString locals;
|
|
||||||
|
|
||||||
PCB_IO::FootprintEnumerate( locals, m_pretty_dir, aBestEfforts );
|
|
||||||
|
|
||||||
for( unsigned i=0; i<locals.GetCount(); ++i )
|
|
||||||
unique.insert( locals[i] );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( MODULE_ITER it = m_gh_cache->begin(); it!=m_gh_cache->end(); ++it )
|
|
||||||
unique.insert( it->first );
|
|
||||||
|
|
||||||
for( MYSET::const_iterator it = unique.begin(); it != unique.end(); ++it )
|
|
||||||
aFootprintNames.Add( *it );
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& ioe )
|
|
||||||
{
|
|
||||||
if( !aBestEfforts )
|
|
||||||
throw ioe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::PrefetchLib(
|
|
||||||
const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
if( m_lib_path != aLibraryPath )
|
|
||||||
{
|
|
||||||
m_zip_image.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
remoteGetZip( aLibraryPath );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
MODULE* GITHUB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
|
|
||||||
const wxString& aFootprintName, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// clear or set to valid the variable m_pretty_dir
|
|
||||||
cacheLib( aLibraryPath, aProperties );
|
|
||||||
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
{
|
|
||||||
// API has FootprintLoad() *not* throwing an exception if footprint not found.
|
|
||||||
MODULE* local = PCB_IO::FootprintLoad( m_pretty_dir, aFootprintName, aProperties );
|
|
||||||
|
|
||||||
if( local )
|
|
||||||
{
|
|
||||||
// It has worked, see <src>/scripts/test_kicad_plugin.py. So this was not firing:
|
|
||||||
// wxASSERT( aFootprintName == FROM_UTF8( local->GetFPID().GetLibItemName().c_str() ) );
|
|
||||||
// Moving it to higher API layer FP_LIB_TABLE::FootprintLoad().
|
|
||||||
|
|
||||||
return local;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MODULE_CITER it = m_gh_cache->find( aFootprintName );
|
|
||||||
|
|
||||||
if( it != m_gh_cache->end() ) // fp_name is present
|
|
||||||
{
|
|
||||||
//std::string::data() ensures that the referenced data block is contiguous.
|
|
||||||
wxMemoryInputStream mis( m_zip_image.data(), m_zip_image.size() );
|
|
||||||
|
|
||||||
// This decoder should always be UTF8, since it was saved that way by git.
|
|
||||||
// That is, since pretty footprints are UTF8, and they were pushed to the
|
|
||||||
// github repo, they are still UTF8.
|
|
||||||
wxZipInputStream zis( mis, wxConvUTF8 );
|
|
||||||
wxZipEntry* entry = (wxZipEntry*) it->second; // remove "const"-ness
|
|
||||||
|
|
||||||
if( zis.OpenEntry( *entry ) )
|
|
||||||
{
|
|
||||||
INPUTSTREAM_LINE_READER reader( &zis, aLibraryPath );
|
|
||||||
|
|
||||||
// I am a PCB_IO derivative with my own PCB_PARSER
|
|
||||||
m_parser->SetLineReader( &reader ); // ownership not passed
|
|
||||||
|
|
||||||
MODULE* ret = (MODULE*) m_parser->Parse();
|
|
||||||
|
|
||||||
// In a github library, (as well as in a "KiCad" library) the name of
|
|
||||||
// the pretty file defines the footprint name. That filename trumps
|
|
||||||
// any name found in the pretty file; any name in the pretty file
|
|
||||||
// must be ignored here. Also, the library nickname is unknown in
|
|
||||||
// this context so clear it just in case.
|
|
||||||
ret->SetFPID( LIB_ID( wxEmptyString, aFootprintName ) );
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL; // this API function returns NULL for "not found", per spec.
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
|
|
||||||
{
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
return PCB_IO::IsFootprintLibWritable( m_pretty_dir );
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::FootprintSave( const wxString& aLibraryPath,
|
|
||||||
const MODULE* aFootprint, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// set m_pretty_dir to either empty or something in aProperties
|
|
||||||
cacheLib( aLibraryPath, aProperties );
|
|
||||||
|
|
||||||
if( GITHUB_PLUGIN::IsFootprintLibWritable( aLibraryPath ) )
|
|
||||||
{
|
|
||||||
PCB_IO::FootprintSave( m_pretty_dir, aFootprint, aProperties );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This typically will not happen if the caller first properly calls
|
|
||||||
// IsFootprintLibWritable() to determine if calling FootprintSave() is
|
|
||||||
// even legal, so I spend no time on internationalization here:
|
|
||||||
|
|
||||||
string msg = StrPrintf( "Github library\n\"%s\"\nis only writable if you set option \"%s\" in Library Tables dialog.",
|
|
||||||
TO_UTF8( aLibraryPath ), PRETTY_DIR );
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
||||||
const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// set m_pretty_dir to either empty or something in aProperties
|
|
||||||
cacheLib( aLibraryPath, aProperties );
|
|
||||||
|
|
||||||
if( GITHUB_PLUGIN::IsFootprintLibWritable( aLibraryPath ) )
|
|
||||||
{
|
|
||||||
// Does the PCB_IO base class have this footprint?
|
|
||||||
// We cannot write to github.
|
|
||||||
|
|
||||||
wxArrayString pretties;
|
|
||||||
|
|
||||||
PCB_IO::FootprintEnumerate( pretties, m_pretty_dir, aProperties );
|
|
||||||
|
|
||||||
if( pretties.Index( aFootprintName ) != wxNOT_FOUND )
|
|
||||||
{
|
|
||||||
PCB_IO::FootprintDelete( m_pretty_dir, aFootprintName, aProperties );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxString msg = wxString::Format(
|
|
||||||
_( "Footprint\n\"%s\"\nis not in the writable portion of this Github library\n\"%s\"" ),
|
|
||||||
aFootprintName,
|
|
||||||
aLibraryPath
|
|
||||||
);
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// This typically will not happen if the caller first properly calls
|
|
||||||
// IsFootprintLibWritable() to determine if calling FootprintSave() is
|
|
||||||
// even legal, so I spend no time on internationalization here:
|
|
||||||
|
|
||||||
string msg = StrPrintf( "Github library\n\"%s\"\nis only writable if you set option \"%s\" in Library Tables dialog.",
|
|
||||||
TO_UTF8( aLibraryPath ), PRETTY_DIR );
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// set m_pretty_dir to either empty or something in aProperties
|
|
||||||
cacheLib( aLibraryPath, aProperties );
|
|
||||||
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
PCB_IO::FootprintLibCreate( m_pretty_dir, aProperties );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// set m_pretty_dir to either empty or something in aProperties
|
|
||||||
cacheLib( aLibraryPath, aProperties );
|
|
||||||
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
return PCB_IO::FootprintLibDelete( m_pretty_dir, aProperties );
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
|
|
||||||
{
|
|
||||||
// inherit options supported by all PLUGINs.
|
|
||||||
PLUGIN::FootprintLibOptions( aListToAppendTo );
|
|
||||||
|
|
||||||
(*aListToAppendTo)[ PRETTY_DIR ] = UTF8( _(
|
|
||||||
"Set this property to a directory where footprints are to be written as pretty "
|
|
||||||
"footprints when saving to this library. Anything saved will take precedence over "
|
|
||||||
"footprints by the same name in the github repo. These saved footprints can then "
|
|
||||||
"be sent to the library maintainer as updates. "
|
|
||||||
"<p>The directory <b>must</b> have a <b>.pretty</b> file extension because the "
|
|
||||||
"format of the save is pretty.</p>"
|
|
||||||
));
|
|
||||||
|
|
||||||
/*
|
|
||||||
(*aListToAppendTo)["cache_github_zip_in_this_dir"] = UTF8( _(
|
|
||||||
"Set this property to a directory where the github *.zip file will be cached. "
|
|
||||||
"This should speed up subsequent visits to this library."
|
|
||||||
));
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties )
|
|
||||||
{
|
|
||||||
// This is edge triggered based on a change in 'aLibraryPath',
|
|
||||||
// usually it does nothing. When the edge fires, m_pretty_dir is set
|
|
||||||
// to either:
|
|
||||||
// 1) empty or
|
|
||||||
// 2) a verified and validated, writable, *.pretty directory.
|
|
||||||
|
|
||||||
if( !m_gh_cache || m_lib_path != aLibraryPath )
|
|
||||||
{
|
|
||||||
delete m_gh_cache;
|
|
||||||
m_gh_cache = 0;
|
|
||||||
m_pretty_dir.clear();
|
|
||||||
|
|
||||||
if( !m_lib_path.empty() )
|
|
||||||
{
|
|
||||||
// Library path wasn't empty before - it's been changed. Flush out the prefetch cache.
|
|
||||||
m_zip_image.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( aProperties )
|
|
||||||
{
|
|
||||||
UTF8 pretty_dir;
|
|
||||||
|
|
||||||
if( aProperties->Value( PRETTY_DIR, &pretty_dir ) )
|
|
||||||
{
|
|
||||||
wxString wx_pretty_dir = pretty_dir;
|
|
||||||
|
|
||||||
wx_pretty_dir = ExpandEnvVarSubstitutions( wx_pretty_dir, nullptr );
|
|
||||||
|
|
||||||
wxFileName wx_pretty_fn = wx_pretty_dir;
|
|
||||||
|
|
||||||
if( !wx_pretty_fn.IsOk() ||
|
|
||||||
!wx_pretty_fn.IsDirWritable() ||
|
|
||||||
wx_pretty_fn.GetExt() != "pretty"
|
|
||||||
)
|
|
||||||
{
|
|
||||||
wxString msg = wxString::Format(
|
|
||||||
_( "option \"%s\" for Github library \"%s\" must point to a writable directory ending with '.pretty'." ),
|
|
||||||
FROM_UTF8( PRETTY_DIR ),
|
|
||||||
aLibraryPath
|
|
||||||
);
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_pretty_dir = wx_pretty_dir;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// operator==( wxString, wxChar* ) does not exist, construct wxString once here.
|
|
||||||
const wxString kicad_mod( "kicad_mod" );
|
|
||||||
|
|
||||||
m_gh_cache = new GH_CACHE();
|
|
||||||
|
|
||||||
// INIT_LOGGER( "/tmp", "test.log" );
|
|
||||||
remoteGetZip( aLibraryPath );
|
|
||||||
// UNINIT_LOGGER();
|
|
||||||
|
|
||||||
m_lib_path = aLibraryPath;
|
|
||||||
|
|
||||||
wxMemoryInputStream mis( &m_zip_image[0], m_zip_image.size() );
|
|
||||||
|
|
||||||
// Recently the zip standard adopted UTF8 encoded filenames within the
|
|
||||||
// internal zip directory block. Please only use zip files that conform
|
|
||||||
// to that standard. Github seems to now, but may not have earlier.
|
|
||||||
wxZipInputStream zis( mis, wxConvUTF8 );
|
|
||||||
|
|
||||||
wxZipEntry* entry;
|
|
||||||
wxString fp_name;
|
|
||||||
|
|
||||||
while( ( entry = zis.GetNextEntry() ) != NULL )
|
|
||||||
{
|
|
||||||
wxFileName fn( entry->GetName() ); // chop long name into parts
|
|
||||||
|
|
||||||
if( fn.GetExt() == kicad_mod )
|
|
||||||
{
|
|
||||||
fp_name = fn.GetName(); // omit extension & path
|
|
||||||
|
|
||||||
m_gh_cache->insert( fp_name, entry );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
delete entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
long long GITHUB_PLUGIN::GetLibraryTimestamp( const wxString& aLibraryPath ) const
|
|
||||||
{
|
|
||||||
// This plugin currently relies on the nginx server for caching (see comments
|
|
||||||
// at top of file).
|
|
||||||
// Since only the nginx server holds the timestamp information, we must defeat
|
|
||||||
// all caching above the nginx server.
|
|
||||||
return wxDateTime::Now().GetValue().GetValue();
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// If we have no cache, return a number which won't match any stored timestamps
|
|
||||||
if( !m_gh_cache || m_lib_path != aLibraryPath )
|
|
||||||
return wxDateTime::Now().GetValue().GetValue();
|
|
||||||
|
|
||||||
long long hash = m_gh_cache->GetTimestamp();
|
|
||||||
|
|
||||||
if( m_pretty_dir.size() )
|
|
||||||
hash += PCB_IO::GetLibraryTimestamp( m_pretty_dir );
|
|
||||||
|
|
||||||
return hash;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GITHUB_PLUGIN::repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL )
|
|
||||||
{
|
|
||||||
// e.g. "https://github.com/liftoff-sr/pretty_footprints"
|
|
||||||
|
|
||||||
wxURI repo( aRepoURL );
|
|
||||||
|
|
||||||
if( repo.HasServer() && repo.HasPath() )
|
|
||||||
{
|
|
||||||
// scheme might be "http" or if truly github.com then "https".
|
|
||||||
wxString zip_url;
|
|
||||||
|
|
||||||
if( repo.GetServer() == "github.com" )
|
|
||||||
{
|
|
||||||
//codeload.github.com only supports https
|
|
||||||
zip_url = "https://";
|
|
||||||
#if 0 // A proper code path would be this one, but it is not the fastest.
|
|
||||||
zip_url += repo.GetServer();
|
|
||||||
zip_url += repo.GetPath(); // path comes with a leading '/'
|
|
||||||
zip_url += "/archive/master.zip";
|
|
||||||
#else
|
|
||||||
// Github issues a redirect for the "master.zip". i.e.
|
|
||||||
// "https://github.com/liftoff-sr/pretty_footprints/archive/master.zip"
|
|
||||||
// would be redirected to:
|
|
||||||
// "https://codeload.github.com/liftoff-sr/pretty_footprints/zip/master"
|
|
||||||
|
|
||||||
// In order to bypass this redirect, saving time, we use the
|
|
||||||
// redirected URL on first attempt to save one HTTP GET hit.
|
|
||||||
zip_url += "codeload.github.com";
|
|
||||||
zip_url += repo.GetPath(); // path comes with a leading '/'
|
|
||||||
zip_url += "/zip/master";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
zip_url = repo.GetScheme();
|
|
||||||
zip_url += "://";
|
|
||||||
|
|
||||||
// This is the generic code path for any server which can serve
|
|
||||||
// up zip files. The schemes tested include: http and https.
|
|
||||||
|
|
||||||
// zip_url goal: "<scheme>://<server>[:<port>]/<path>"
|
|
||||||
|
|
||||||
// Remember that <scheme>, <server>, <port> if present, and <path> all came
|
|
||||||
// from the lib_path in the fp-lib-table row.
|
|
||||||
|
|
||||||
// This code path is used with the nginx proxy setup, but is useful
|
|
||||||
// beyond that.
|
|
||||||
|
|
||||||
zip_url += repo.GetServer();
|
|
||||||
|
|
||||||
if( repo.HasPort() )
|
|
||||||
{
|
|
||||||
zip_url += ':';
|
|
||||||
zip_url += repo.GetPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
zip_url += repo.GetPath(); // path comes with a leading '/'
|
|
||||||
|
|
||||||
// Do not modify the path, we cannot anticipate the needs of all
|
|
||||||
// servers which are serving up zip files directly. URL modifications
|
|
||||||
// are more generally done in the server, rather than contaminating
|
|
||||||
// this code path with the needs of one particular inflexible server.
|
|
||||||
}
|
|
||||||
|
|
||||||
*aZipURL = zip_url.utf8_str();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void GITHUB_PLUGIN::remoteGetZip( const wxString& aRepoURL )
|
|
||||||
{
|
|
||||||
std::string zip_url;
|
|
||||||
|
|
||||||
if( !m_zip_image.empty() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
if( !repoURL_zipURL( aRepoURL, &zip_url ) )
|
|
||||||
{
|
|
||||||
wxString msg = wxString::Format( _( "Unable to parse URL:\n\"%s\"" ), aRepoURL );
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
KICAD_CURL_EASY kcurl; // this can THROW_IO_ERROR
|
|
||||||
|
|
||||||
kcurl.SetURL( zip_url.c_str() );
|
|
||||||
kcurl.SetUserAgent( "http://kicad-pcb.org" );
|
|
||||||
kcurl.SetHeader( "Accept", "application/zip" );
|
|
||||||
kcurl.SetFollowRedirects( true );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
kcurl.Perform();
|
|
||||||
m_zip_image = kcurl.GetBuffer();
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& ioe )
|
|
||||||
{
|
|
||||||
// https "GET" has failed, report this to API caller.
|
|
||||||
// Note: kcurl.Perform() does not return an error if the file to download is not found
|
|
||||||
static const char errorcmd[] = "http GET command failed"; // Do not translate this message
|
|
||||||
|
|
||||||
UTF8 fmt( _( "%s\nCannot get/download Zip archive: \"%s\"\nfor library path: \"%s\".\nReason: \"%s\"" ) );
|
|
||||||
|
|
||||||
std::string msg = StrPrintf( fmt.c_str(),
|
|
||||||
errorcmd,
|
|
||||||
zip_url.c_str(),
|
|
||||||
TO_UTF8( aRepoURL ),
|
|
||||||
TO_UTF8( ioe.What() )
|
|
||||||
);
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the zip archive is not existing, the received data is "Not Found" or "404: Not Found",
|
|
||||||
// and no error is returned by kcurl.Perform().
|
|
||||||
if( ( m_zip_image.compare( 0, 9, "Not Found", 9 ) == 0 ) ||
|
|
||||||
( m_zip_image.compare( 0, 14, "404: Not Found", 14 ) == 0 ) )
|
|
||||||
{
|
|
||||||
UTF8 fmt( _( "Cannot download library \"%s\".\nThe library does not exist on the server" ) );
|
|
||||||
std::string msg = StrPrintf( fmt.c_str(), TO_UTF8( aRepoURL ) );
|
|
||||||
|
|
||||||
THROW_IO_ERROR( msg );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0 && defined(STANDALONE)
|
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
|
||||||
{
|
|
||||||
INIT_LOGGER( ".", "test.log" );
|
|
||||||
|
|
||||||
GITHUB_PLUGIN gh;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
wxArrayString fps = gh.FootprintEnumerate(
|
|
||||||
"https://github.com/liftoff-sr/pretty_footprints",
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
for( int i=0; i<(int)fps.Count(); ++i )
|
|
||||||
{
|
|
||||||
printf("[%d]:%s\n", i, TO_UTF8( fps[i] ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( const IO_ERROR& ioe )
|
|
||||||
{
|
|
||||||
printf( "%s\n", TO_UTF8(ioe.What()) );
|
|
||||||
}
|
|
||||||
|
|
||||||
UNINIT_LOGGER();
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,235 +0,0 @@
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
||||||
* Copyright (C) 2016-2017 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GITHUB_PLUGIN_H_
|
|
||||||
#define GITHUB_PLUGIN_H_
|
|
||||||
|
|
||||||
#include <plugins/kicad/kicad_plugin.h>
|
|
||||||
|
|
||||||
struct GH_CACHE;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Class GITHUB_PLUGIN
|
|
||||||
implements a portion of pcbnew's PLUGIN interface to provide read only access
|
|
||||||
to a github repo consisting of pretty footprints, and optionally provides "Copy On Write"
|
|
||||||
support of edited footprints.
|
|
||||||
|
|
||||||
<p>It could have used version 3 of the github.com API documented here:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
http://developer.github.com/v3/
|
|
||||||
https://help.github.com/articles/creating-an-access-token-for-command-line-use
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
but it does not, since a better technique was discovered. Cleverly this
|
|
||||||
plugin simply reads in a zip file of the repo and unzips it from RAM as
|
|
||||||
needed. Therefore this "Github" plugin is <b>read only for accessing remote
|
|
||||||
pretty libraries at https://github.com.</b>
|
|
||||||
|
|
||||||
<p>The fp-lib-table dialog is entered via menu choice "Preferences | Library
|
|
||||||
Tables". For easy options editing in the current row, click on the "Edit
|
|
||||||
Options" button. The "Library Path" in the fp-lib-table row for a Github
|
|
||||||
library should be set to the full https:// URL.
|
|
||||||
|
|
||||||
<p>For example:
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
https://github.com/liftoff-sr/pretty_footprints
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
This is typically
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
https://github.com/user_name/repo_name
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
|
|
||||||
The "Plugin Type" should be set to "Github".
|
|
||||||
|
|
||||||
<p>This plugin also supports "Copy On Write", a.k.a. "COW". Thus a Github
|
|
||||||
library may take an optional option called
|
|
||||||
<b>allow_pretty_writing_to_this_dir</b>. This option is essentially the
|
|
||||||
"Library Path" for a local "KiCad" (pretty) type library which is combined to
|
|
||||||
make up the Github library found in the same fp-lib-table row. If the option
|
|
||||||
is missing, then the Github library is read only as always. If the option is
|
|
||||||
present for a Github library, then any writes to this hybrid library will go
|
|
||||||
to the local *.pretty directory. Note that the github.com resident portion of
|
|
||||||
this hybrid COW library is always read only, meaning you cannot delete
|
|
||||||
anything or modify any footprint at github directly. The aggregate library
|
|
||||||
type remains "Github" in your discussions, but it consists of a local R/W
|
|
||||||
portion and a remote R/O portion.
|
|
||||||
|
|
||||||
<p>Below is an fp-lib-table entry for the case without option
|
|
||||||
<b>allow_pretty_writing_to_this_dir</b>:
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>Nickname</th><th>Library Path</th><th>Plugin Type</th><th>Options</th><th>Description</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<td>github</td><td>https://github.com/liftoff-sr/pretty_footprints</td><td>Github</td>
|
|
||||||
<td></td><td>Liftoff's GH footprints</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
Below is an fp-lib-table entry with the COW option given. Note the use of the environment variable
|
|
||||||
${HOME}, as an example only. The github.pretty directory is based in ${HOME}/pretty/. Anytime you
|
|
||||||
use option allow_pretty_writing_to_this_dir, you will create that directory manually and it must
|
|
||||||
end in extension <b>.pretty</b>.
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<th>Nickname</th><th>Library Path</th><th>Plugin Type</th><th>Options</th><th>Description</th>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td>github</td><td>https://github.com/liftoff-sr/pretty_footprints</td><td>Github</td>
|
|
||||||
<td>allow_pretty_writing_to_this_dir=${HOME}/pretty/github.pretty</td>
|
|
||||||
<td>Liftoff's GH footprints</td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>Any footprint loads will always give precedence to the local footprints
|
|
||||||
found in the pretty dir given by option
|
|
||||||
<b>allow_pretty_writing_to_this_dir</b>. So once you have written to the COW
|
|
||||||
library's local directory by doing a footprint save, no github updates will
|
|
||||||
be seen when loading a footprint by the same name as one for which you've
|
|
||||||
written locally.
|
|
||||||
|
|
||||||
<p>Always keep a separate local *.pretty directory for each Github library,
|
|
||||||
never combine them by referring to the same directory more than once. Also,
|
|
||||||
do not also use the same COW (*.pretty) directory in a "KiCad" fp-lib-table
|
|
||||||
entry. This would likely create a mess. The COW directory should be manually
|
|
||||||
created in advance, and the directory name must end with ".pretty". The value
|
|
||||||
of the option <b>allow_pretty_writing_to_this_dir</b> will be path
|
|
||||||
substituted with any environment variable strings embedded, just like the
|
|
||||||
"Library Path" is.
|
|
||||||
|
|
||||||
<p>What's the point of COW? It is to turbo-charge the sharing of footprints.
|
|
||||||
If you periodically email your COW pretty footprint modifications to the
|
|
||||||
Github repo maintainer, you can help update the Github copy. Simply email the
|
|
||||||
individual *.kicad_mod files you find in your COW directories. After you've
|
|
||||||
received confirmation that your changes have been committed up at github.com,
|
|
||||||
you can safely delete your COW file(s) and those from github.com will flow
|
|
||||||
down. Your goal should be to keep the COW file set as small as possible by
|
|
||||||
contributing frequently to the shared master copies at https://github.com.
|
|
||||||
|
|
||||||
<p>Note that if you use the module editor to delete a footprint and it is
|
|
||||||
present in the COW local dir, it will get deleted from there. However, it may
|
|
||||||
not be deleted from the library as a whole if the footprint of the same name
|
|
||||||
also exists in the github repo. In this case deleting the local copy will
|
|
||||||
simply unmask the one at the github repo. Remember, it is masked out if there
|
|
||||||
is a local COW copy, since the local copy always takes precedence. And
|
|
||||||
remember you cannot modify the github copy except by emailing a COW
|
|
||||||
modification to the repo maintainer.
|
|
||||||
|
|
||||||
<p>If you happen to be the repo maintainer, then the obvious solution for you
|
|
||||||
is to make your COW directory <b>be</b> your working copy directory. From
|
|
||||||
there you can push to github. And you can receive *.kicad_mod files by email
|
|
||||||
and put them into your local working copy directory also and do diffs,
|
|
||||||
reverting or denying when appropriate, editing when appropriate before
|
|
||||||
pushing or denying the change. Ultimately you would owe the sender either a
|
|
||||||
note of acceptance or denial by email.
|
|
||||||
|
|
||||||
@author Dick Hollenbeck
|
|
||||||
@date Original date: 10-Sep-2013
|
|
||||||
|
|
||||||
*/
|
|
||||||
class GITHUB_PLUGIN : public PCB_IO
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
//-----<PLUGIN API>----------------------------------------------------------
|
|
||||||
const wxString PluginName() const override;
|
|
||||||
|
|
||||||
const wxString GetFileExtension() const override;
|
|
||||||
|
|
||||||
void FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
|
|
||||||
bool aBestEfforts, const PROPERTIES* aProperties = NULL ) override;
|
|
||||||
|
|
||||||
void PrefetchLib( const wxString& aLibraryPath,
|
|
||||||
const PROPERTIES* aProperties = NULL ) override;
|
|
||||||
|
|
||||||
MODULE* FootprintLoad( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
||||||
const PROPERTIES* aProperties ) override;
|
|
||||||
|
|
||||||
void FootprintSave( const wxString& aLibraryPath, const MODULE* aFootprint,
|
|
||||||
const PROPERTIES* aProperties = NULL ) override;
|
|
||||||
|
|
||||||
void FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
|
|
||||||
const PROPERTIES* aProperties = NULL ) override;
|
|
||||||
|
|
||||||
bool IsFootprintLibWritable( const wxString& aLibraryPath ) override;
|
|
||||||
|
|
||||||
long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override;
|
|
||||||
|
|
||||||
void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const override;
|
|
||||||
|
|
||||||
// Since I derive from PCB_IO, I have to implement this, else I'd inherit his, which is bad since
|
|
||||||
// my lib_path is not his. Note: it is impossible to create a Github library, but can the C.O.W. portion.
|
|
||||||
void FootprintLibCreate( const wxString& aLibraryPath, const PROPERTIES* aProperties ) override;
|
|
||||||
|
|
||||||
// Since I derive from PCB_IO, I have to implement this, else I'd inherit his, which is bad since
|
|
||||||
// my lib_path is not his. Note: it is impossible to delete a Github library, but can the C.O.W portion.
|
|
||||||
bool FootprintLibDelete( const wxString& aLibraryPath, const PROPERTIES* aProperties ) override;
|
|
||||||
|
|
||||||
//-----</PLUGIN API>---------------------------------------------------------
|
|
||||||
|
|
||||||
GITHUB_PLUGIN(); // constructor, if any, must be zero arg
|
|
||||||
~GITHUB_PLUGIN();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
void init( const PROPERTIES* aProperties );
|
|
||||||
|
|
||||||
void cacheLib( const wxString& aLibraryPath, const PROPERTIES* aProperties );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function repoURL_zipURL
|
|
||||||
* translates a repo URL to a zipfile URL name as commonly seen on github.com
|
|
||||||
*
|
|
||||||
* @param aRepoURL points to the base of the repo.
|
|
||||||
* @param aZipURL is where to put the zip file URL.
|
|
||||||
* @return bool - true if @a aRepoULR was parseable, else false
|
|
||||||
*/
|
|
||||||
static bool repoURL_zipURL( const wxString& aRepoURL, std::string* aZipURL );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function remoteGetZip
|
|
||||||
* fetches a zip file image from a github repo synchronously. The byte image
|
|
||||||
* is received into the m_input_stream. If the image has already been stored,
|
|
||||||
* do nothing.
|
|
||||||
*/
|
|
||||||
void remoteGetZip( const wxString& aRepoURL );
|
|
||||||
|
|
||||||
wxString m_lib_path; ///< from aLibraryPath, something like https://github.com/liftoff-sr/pretty_footprints
|
|
||||||
std::string m_zip_image; ///< byte image of the zip file in its entirety.
|
|
||||||
GH_CACHE* m_gh_cache;
|
|
||||||
wxString m_pretty_dir;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // GITHUB_PLUGIN_H_
|
|
|
@ -1,69 +0,0 @@
|
||||||
/**
|
|
||||||
* @file html_link_parser.cpp
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1992-2014 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wxWidgets gives very few info about wxwebkit. For more info and more comments:
|
|
||||||
* see https://forums.wxwidgets.org/viewtopic.php?f=1&t=1119#
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <html_link_parser.h>
|
|
||||||
|
|
||||||
bool LINK_TAGHANDLER::HandleTag(const wxHtmlTag& tag)
|
|
||||||
{
|
|
||||||
if( tag.HasParam( wxT("HREF") ) )
|
|
||||||
{
|
|
||||||
wxString href( tag.GetParam( wxT("HREF") ) );
|
|
||||||
// Add the first parameter (the link)
|
|
||||||
m_Parser->AddString( href );
|
|
||||||
// Parse other params, but do nothing, because the AddText() callback
|
|
||||||
// do nothing
|
|
||||||
ParseInner(tag);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
HTML_LINK_PARSER::HTML_LINK_PARSER( const wxString& aSrc, wxArrayString& aUrls )
|
|
||||||
: m_src( aSrc ), stringUrls( aUrls )
|
|
||||||
{
|
|
||||||
m_filter = NULL;
|
|
||||||
AddTagHandler( new LINK_TAGHANDLER(this) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void HTML_LINK_PARSER::AddString( const wxString& aText )
|
|
||||||
{
|
|
||||||
wxString text = aText;
|
|
||||||
text.Trim( true );
|
|
||||||
text.Trim( false );
|
|
||||||
|
|
||||||
if( ! m_filter || m_filter( text ) )
|
|
||||||
{
|
|
||||||
stringUrls.Add( text );
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,109 +0,0 @@
|
||||||
/**
|
|
||||||
* @file html_link_parser.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
||||||
*
|
|
||||||
* Copyright (C) 1992-2014 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* wxWidgets gives very few info about wxwebkit. For more info and more comments:
|
|
||||||
* see https://forums.wxwidgets.org/viewtopic.php?f=1&t=1119#
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HTML_LINK_PARSE_H
|
|
||||||
#define HTML_LINK_PARSE_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <wx/wx.h>
|
|
||||||
#include <wx/html/htmlpars.h>
|
|
||||||
|
|
||||||
class HTML_LINK_PARSER ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* a Tag parser, to extract tagged data in html text.
|
|
||||||
* this tag handler extract a url link, givent by tag "A"
|
|
||||||
* like:
|
|
||||||
* "<a href="/KiCad/Valves.pretty" itemprop="name codeRepository"> Valves.pretty</a>"
|
|
||||||
* the tag is "a"
|
|
||||||
* and the link is the parameter given by "href"
|
|
||||||
*/
|
|
||||||
class LINK_TAGHANDLER : public wxHtmlTagHandler
|
|
||||||
{
|
|
||||||
HTML_LINK_PARSER* m_Parser;
|
|
||||||
|
|
||||||
public:
|
|
||||||
LINK_TAGHANDLER() : m_Parser( NULL )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LINK_TAGHANDLER( HTML_LINK_PARSER* aParser ) : m_Parser( aParser )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString GetSupportedTags() override
|
|
||||||
{
|
|
||||||
return "A";
|
|
||||||
}
|
|
||||||
|
|
||||||
bool HandleTag(const wxHtmlTag& tag) override;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The engine to parse a html text and extract useful data
|
|
||||||
* Here, the useful data are url links
|
|
||||||
*/
|
|
||||||
class HTML_LINK_PARSER : public wxHtmlParser
|
|
||||||
{
|
|
||||||
const wxString& m_src; // the html text to parse
|
|
||||||
wxArrayString& stringUrls; // the strings extracted from html text
|
|
||||||
bool (*m_filter)( const wxString& aData ); // a callback function to filter strings
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
HTML_LINK_PARSER( const wxString& aSrc, wxArrayString& aUrls );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parse the html text and store links in stringUrls
|
|
||||||
* Stored links can be filtered if aFilter is non NULL
|
|
||||||
* @param aFilter a filtering function ( bool aFilter( const wxString& aData ) )
|
|
||||||
* which return true if the text aData must be stored.
|
|
||||||
*/
|
|
||||||
void ParseLinks( bool (*aFilter)( const wxString& aData ) )
|
|
||||||
{
|
|
||||||
m_filter = aFilter;
|
|
||||||
Parse(m_src);
|
|
||||||
}
|
|
||||||
|
|
||||||
// virtual pure from wxHtmlParser, do nothing here, but needed.
|
|
||||||
void AddText( const wxString& aText ) override {}
|
|
||||||
|
|
||||||
// Our "AddText" used to store selected text (the url link)
|
|
||||||
void AddString( const wxString& aText );
|
|
||||||
|
|
||||||
wxObject* GetProduct() override
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // ifndef HTML_LINK_PARSE_H
|
|
|
@ -1,68 +0,0 @@
|
||||||
# Author: <Dick Hollenbeck> dick@softplc.com
|
|
||||||
# Configuration file for nginx. Nginx works as a nice cache-ing proxy for
|
|
||||||
# the github footprint repos in a local nginx instance.
|
|
||||||
|
|
||||||
|
|
||||||
# In my case I also added a small RAM disk on a linux server to hold the cache.
|
|
||||||
# This line in /etc/fstab adds my RAM disk, this is 10 mbytes but 5mb would
|
|
||||||
# probably suffice:
|
|
||||||
# none /var/cache/nginx tmpfs size=10m
|
|
||||||
|
|
||||||
# I then set my KIGITHUB environment variable to
|
|
||||||
# export KIGITHUB=http://my_server:54321/KiCad
|
|
||||||
|
|
||||||
# Note that http is used between kicad and nginx, not https. However nginx uses
|
|
||||||
# https when refreshing from github. http is faster than https.
|
|
||||||
|
|
||||||
# You can run nginx either on your local machine, or on a server on your network,
|
|
||||||
# or a server on the Internet. In my case I run it on my network. I imagine
|
|
||||||
# that even a Raspery Pi would act as a decent caching server so long as you
|
|
||||||
# install nginx and give the machine Internet access.
|
|
||||||
|
|
||||||
|
|
||||||
worker_processes 2;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
http {
|
|
||||||
proxy_cache_path /var/cache/nginx keys_zone=cache_zone:10m inactive=1w;
|
|
||||||
|
|
||||||
server {
|
|
||||||
# nginx will listen on this port:
|
|
||||||
listen 54321;
|
|
||||||
|
|
||||||
proxy_cache cache_zone;
|
|
||||||
|
|
||||||
# hold the stuff for one week, then mark it as out of date which will
|
|
||||||
# cause it to be reloaded from github.
|
|
||||||
proxy_cache_valid any 1w;
|
|
||||||
|
|
||||||
location /KiCad/ {
|
|
||||||
rewrite /KiCad/(.+) /KiCad/$1/zip/master break;
|
|
||||||
|
|
||||||
# Skip past the redirect issued by https://github.com
|
|
||||||
proxy_pass https://codeload.github.com;
|
|
||||||
|
|
||||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
|
||||||
proxy_cache_lock on;
|
|
||||||
|
|
||||||
proxy_set_header Proxy-Connection "Keep-Alive";
|
|
||||||
|
|
||||||
proxy_ignore_headers "Set-Cookie";
|
|
||||||
proxy_ignore_headers "Cache-Control";
|
|
||||||
proxy_ignore_headers "Expires";
|
|
||||||
|
|
||||||
proxy_cache_bypass $http_secret_header;
|
|
||||||
|
|
||||||
add_header X-Cache-Status $upstream_cache_status;
|
|
||||||
|
|
||||||
# This line causes github.com to return a "502 Bad Gateway Error"
|
|
||||||
# so do not include it:
|
|
||||||
# proxy_set_header Host $http_host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -72,15 +72,6 @@ class KIWAY;
|
||||||
*/
|
*/
|
||||||
void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller );
|
void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function Invoke3DShapeLibsDownloaderWizard
|
|
||||||
* Runs the downloader wizard for easy 3D shape libraries download from
|
|
||||||
* the official Kicad Github repository of *.3Dshape libraries.
|
|
||||||
*
|
|
||||||
* @param aCaller is the wxWindow which is invoking the dialog.
|
|
||||||
*/
|
|
||||||
void Invoke3DShapeLibsDownloaderWizard( wxWindow* aCaller );
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function InvokePluginOptionsEditor
|
* Function InvokePluginOptionsEditor
|
||||||
|
|
|
@ -36,11 +36,6 @@
|
||||||
#include <plugins/altium/altium_circuit_studio_plugin.h>
|
#include <plugins/altium/altium_circuit_studio_plugin.h>
|
||||||
#include <plugins/altium/altium_designer_plugin.h>
|
#include <plugins/altium/altium_designer_plugin.h>
|
||||||
#include <plugins/cadstar/cadstar_pcb_archive_plugin.h>
|
#include <plugins/cadstar/cadstar_pcb_archive_plugin.h>
|
||||||
|
|
||||||
#if defined(BUILD_GITHUB_PLUGIN)
|
|
||||||
#include <github/github_plugin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <wildcards_and_files_ext.h>
|
#include <wildcards_and_files_ext.h>
|
||||||
|
|
||||||
#define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
|
#define FMT_UNIMPLEMENTED _( "Plugin \"%s\" does not implement the \"%s\" function." )
|
||||||
|
@ -150,25 +145,10 @@ IO_MGR::PCB_FILE_T IO_MGR::GuessPluginTypeFromLibPath( const wxString& aLibPath
|
||||||
// *.pretty/ with *.kicad_mod in there., and I don't want to return -1,
|
// *.pretty/ with *.kicad_mod in there., and I don't want to return -1,
|
||||||
// since we only claimed to be guessing.
|
// since we only claimed to be guessing.
|
||||||
//
|
//
|
||||||
// However libraries on GitHub have names ending by .pretty
|
else if( fn.GetExt() == KiCadFootprintLibPathExtension )
|
||||||
// so test also this is not a name starting by http (including https).
|
|
||||||
else if( fn.GetExt() == KiCadFootprintLibPathExtension &&
|
|
||||||
!aLibPath.StartsWith( wxT( "http" ) ) )
|
|
||||||
{
|
{
|
||||||
ret = KICAD_SEXP;
|
ret = KICAD_SEXP;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
#if defined(BUILD_GITHUB_PLUGIN)
|
|
||||||
// There is no extension for a remote repo, so test the server name.
|
|
||||||
wxURI uri( aLibPath );
|
|
||||||
|
|
||||||
if( uri.HasServer() && uri.GetServer() == wxT( "github.com" ) )
|
|
||||||
{
|
|
||||||
ret = GITHUB;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -218,8 +198,5 @@ static IO_MGR::REGISTER_PLUGIN registerAltiumCircuitMakerPlugin( IO_MGR::ALTIUM_
|
||||||
[]() -> PLUGIN* { return new ALTIUM_CIRCUIT_MAKER_PLUGIN; } );
|
[]() -> PLUGIN* { return new ALTIUM_CIRCUIT_MAKER_PLUGIN; } );
|
||||||
static IO_MGR::REGISTER_PLUGIN registerCadstarArchivePlugin( IO_MGR::CADSTAR_PCB_ARCHIVE,
|
static IO_MGR::REGISTER_PLUGIN registerCadstarArchivePlugin( IO_MGR::CADSTAR_PCB_ARCHIVE,
|
||||||
wxT( "CADSTAR PCB Archive" ), []() -> PLUGIN* { return new CADSTAR_PCB_ARCHIVE_PLUGIN; } );
|
wxT( "CADSTAR PCB Archive" ), []() -> PLUGIN* { return new CADSTAR_PCB_ARCHIVE_PLUGIN; } );
|
||||||
#ifdef BUILD_GITHUB_PLUGIN
|
|
||||||
static IO_MGR::REGISTER_PLUGIN registerGithubPlugin( IO_MGR::GITHUB, wxT("Github"), []() -> PLUGIN* { return new GITHUB_PLUGIN; } );
|
|
||||||
#endif /* BUILD_GITHUB_PLUGIN */
|
|
||||||
static IO_MGR::REGISTER_PLUGIN registerLegacyPlugin( IO_MGR::LEGACY, wxT("Legacy"), []() -> PLUGIN* { return new LEGACY_PLUGIN; } );
|
static IO_MGR::REGISTER_PLUGIN registerLegacyPlugin( IO_MGR::LEGACY, wxT("Legacy"), []() -> PLUGIN* { return new LEGACY_PLUGIN; } );
|
||||||
static IO_MGR::REGISTER_PLUGIN registerGPCBPlugin( IO_MGR::GEDA_PCB, wxT("GEDA/Pcb"), []() -> PLUGIN* { return new GPCB_PLUGIN; } );
|
static IO_MGR::REGISTER_PLUGIN registerGPCBPlugin( IO_MGR::GEDA_PCB, wxT("GEDA/Pcb"), []() -> PLUGIN* { return new GPCB_PLUGIN; } );
|
||||||
|
|
|
@ -62,11 +62,6 @@ public:
|
||||||
ALTIUM_CIRCUIT_MAKER,
|
ALTIUM_CIRCUIT_MAKER,
|
||||||
CADSTAR_PCB_ARCHIVE,
|
CADSTAR_PCB_ARCHIVE,
|
||||||
GEDA_PCB, ///< Geda PCB file formats.
|
GEDA_PCB, ///< Geda PCB file formats.
|
||||||
|
|
||||||
//N.B. This needs to be commented out to ensure compile-type errors
|
|
||||||
#if defined(BUILD_GITHUB_PLUGIN)
|
|
||||||
GITHUB, ///< Read only http://github.com repo holding pretty footprints
|
|
||||||
#endif
|
|
||||||
// add your type here.
|
// add your type here.
|
||||||
|
|
||||||
// etc.
|
// etc.
|
||||||
|
|
|
@ -431,12 +431,6 @@ void PCB_EDIT_FRAME::ReCreateMenuBar()
|
||||||
prefsMenu->Add( ACTIONS::configurePaths );
|
prefsMenu->Add( ACTIONS::configurePaths );
|
||||||
prefsMenu->Add( ACTIONS::showFootprintLibTable );
|
prefsMenu->Add( ACTIONS::showFootprintLibTable );
|
||||||
|
|
||||||
#ifdef BUILD_GITHUB_PLUGIN
|
|
||||||
prefsMenu->Add( _( "Add &3D Shapes Libraries Wizard..." ),
|
|
||||||
_( "Download 3D shape libraries from GitHub" ),
|
|
||||||
ID_PCB_3DSHAPELIB_WIZARD,
|
|
||||||
import3d_xpm );
|
|
||||||
#endif
|
|
||||||
prefsMenu->Add( _( "Preferences...\tCTRL+," ),
|
prefsMenu->Add( _( "Preferences...\tCTRL+," ),
|
||||||
_( "Show preferences for all open tools" ),
|
_( "Show preferences for all open tools" ),
|
||||||
wxID_PREFERENCES,
|
wxID_PREFERENCES,
|
||||||
|
|
|
@ -135,7 +135,6 @@ BEGIN_EVENT_TABLE( PCB_EDIT_FRAME, PCB_BASE_FRAME )
|
||||||
EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
|
EVT_MENU( wxID_CLOSE, PCB_EDIT_FRAME::OnQuit )
|
||||||
|
|
||||||
// menu Config
|
// menu Config
|
||||||
EVT_MENU( ID_PCB_3DSHAPELIB_WIZARD, PCB_EDIT_FRAME::On3DShapeLibWizard )
|
|
||||||
EVT_MENU( ID_GRID_SETTINGS, PCB_EDIT_FRAME::OnGridSettings )
|
EVT_MENU( ID_GRID_SETTINGS, PCB_EDIT_FRAME::OnGridSettings )
|
||||||
|
|
||||||
// menu Postprocess
|
// menu Postprocess
|
||||||
|
|
|
@ -881,8 +881,6 @@ public:
|
||||||
*/
|
*/
|
||||||
void UpdateTitle();
|
void UpdateTitle();
|
||||||
|
|
||||||
void On3DShapeLibWizard( wxCommandEvent& event );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows Pcbnew to install its preferences panel into the preferences dialog.
|
* Allows Pcbnew to install its preferences panel into the preferences dialog.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -45,13 +45,6 @@
|
||||||
#include <project/project_local_settings.h>
|
#include <project/project_local_settings.h>
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::On3DShapeLibWizard( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
#ifdef BUILD_GITHUB_PLUGIN
|
|
||||||
Invoke3DShapeLibsDownloaderWizard( this );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
void PCB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
||||||
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
||||||
|
|
|
@ -94,7 +94,6 @@ enum pcbnew_ids
|
||||||
|
|
||||||
ID_PCB_GEN_CMP_FILE,
|
ID_PCB_GEN_CMP_FILE,
|
||||||
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
ID_PCB_GEN_BOM_FILE_FROM_BOARD,
|
||||||
ID_PCB_3DSHAPELIB_WIZARD,
|
|
||||||
|
|
||||||
ID_TOOLBARH_PCB_SELECT_LAYER,
|
ID_TOOLBARH_PCB_SELECT_LAYER,
|
||||||
|
|
||||||
|
|
|
@ -27,12 +27,6 @@ find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc R
|
||||||
|
|
||||||
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DDRC_PROTO -DTEST_APP_NO_MAIN)
|
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DDRC_PROTO -DTEST_APP_NO_MAIN)
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_executable( drc_proto
|
add_executable( drc_proto
|
||||||
drc_proto_test.cpp
|
drc_proto_test.cpp
|
||||||
drc_proto.cpp
|
drc_proto.cpp
|
||||||
|
@ -66,7 +60,7 @@ add_executable( drc_proto
|
||||||
../../common/base_units.cpp
|
../../common/base_units.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_dependencies( drc_proto pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} )
|
add_dependencies( drc_proto pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} )
|
||||||
|
|
||||||
include_directories( BEFORE ${INC_BEFORE} )
|
include_directories( BEFORE ${INC_BEFORE} )
|
||||||
include_directories(
|
include_directories(
|
||||||
|
@ -107,9 +101,8 @@ target_link_libraries( drc_proto
|
||||||
unit_test_utils
|
unit_test_utils
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${Boost_LIBRARIES} # must follow GITHUB
|
${Boost_LIBRARIES}
|
||||||
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
||||||
)
|
)
|
||||||
|
|
|
@ -27,11 +27,7 @@ find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc R
|
||||||
|
|
||||||
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DUSE_TOOL_MANAGER -DQA_TEST)
|
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW -DUSE_TOOL_MANAGER -DQA_TEST)
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} )
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} )
|
|
||||||
|
|
||||||
add_executable(test_gal_pixel_alignment WIN32
|
add_executable(test_gal_pixel_alignment WIN32
|
||||||
test_gal_pixel_alignment.cpp
|
test_gal_pixel_alignment.cpp
|
||||||
|
@ -76,7 +72,6 @@ target_link_libraries( test_gal_pixel_alignment
|
||||||
gal
|
gal
|
||||||
common
|
common
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||||
|
|
|
@ -59,7 +59,6 @@ target_link_libraries( qa_gerbview
|
||||||
qa_utils
|
qa_utils
|
||||||
unit_test_utils
|
unit_test_utils
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${Boost_LIBRARIES} # must follow GITHUB
|
${Boost_LIBRARIES} # must follow GITHUB
|
||||||
|
|
|
@ -26,11 +26,7 @@ find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc R
|
||||||
|
|
||||||
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW)
|
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW)
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} )
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} )
|
|
||||||
|
|
||||||
add_executable( libeval_compiler_test
|
add_executable( libeval_compiler_test
|
||||||
libeval_compiler_test.cpp
|
libeval_compiler_test.cpp
|
||||||
|
@ -78,7 +74,6 @@ target_link_libraries( libeval_compiler_test
|
||||||
common
|
common
|
||||||
pcbcommon
|
pcbcommon
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
common
|
common
|
||||||
pcbcommon
|
pcbcommon
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
|
|
|
@ -27,11 +27,7 @@ find_package( wxWidgets 3.0.0 COMPONENTS gl aui adv html core net base xml stc R
|
||||||
|
|
||||||
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW)
|
add_definitions(-DBOOST_TEST_DYN_LINK -DPCBNEW)
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} )
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_dependencies( pnsrouter pcbcommon ${PCBNEW_IO_LIBRARIES} ${GITHUB_PLUGIN_LIBRARIES} )
|
|
||||||
|
|
||||||
add_executable(test_window WIN32
|
add_executable(test_window WIN32
|
||||||
test.cpp
|
test.cpp
|
||||||
|
@ -68,7 +64,6 @@ target_link_libraries( test_window
|
||||||
gal
|
gal
|
||||||
common
|
common
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
# or you may write to the Free Software Foundation, Inc.,
|
# or you may write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
set( QA_PCBNEW_SRCS
|
set( QA_PCBNEW_SRCS
|
||||||
# The main test entry points
|
# The main test entry points
|
||||||
test_module.cpp
|
test_module.cpp
|
||||||
|
@ -85,10 +80,9 @@ target_link_libraries( qa_pcbnew
|
||||||
markdown_lib
|
markdown_lib
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${Boost_LIBRARIES} # must follow GITHUB
|
${Boost_LIBRARIES}
|
||||||
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,6 @@
|
||||||
# or you may write to the Free Software Foundation, Inc.,
|
# or you may write to the Free Software Foundation, Inc.,
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
|
||||||
|
|
||||||
if( BUILD_GITHUB_PLUGIN )
|
|
||||||
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_executable( qa_pcbnew_tools
|
add_executable( qa_pcbnew_tools
|
||||||
|
|
||||||
# The main entry point
|
# The main entry point
|
||||||
|
@ -62,10 +57,9 @@ target_link_libraries( qa_pcbnew_tools
|
||||||
markdown_lib
|
markdown_lib
|
||||||
${PCBNEW_IO_LIBRARIES}
|
${PCBNEW_IO_LIBRARIES}
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
${GDI_PLUS_LIBRARIES}
|
${GDI_PLUS_LIBRARIES}
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${Boost_LIBRARIES} # must follow GITHUB
|
${Boost_LIBRARIES}
|
||||||
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
${PCBNEW_EXTRA_LIBS} # -lrt must follow Boost
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,6 @@ target_link_libraries( qa_pcbnew_utils PUBLIC
|
||||||
# unit_test_utils
|
# unit_test_utils
|
||||||
# ${PCBNEW_IO_LIBRARIES}
|
# ${PCBNEW_IO_LIBRARIES}
|
||||||
# ${wxWidgets_LIBRARIES}
|
# ${wxWidgets_LIBRARIES}
|
||||||
# ${GITHUB_PLUGIN_LIBRARIES}
|
|
||||||
# ${GDI_PLUS_LIBRARIES}
|
# ${GDI_PLUS_LIBRARIES}
|
||||||
# ${PYTHON_LIBRARIES}
|
# ${PYTHON_LIBRARIES}
|
||||||
# ${Boost_LIBRARIES} # must follow GITHUB
|
# ${Boost_LIBRARIES} # must follow GITHUB
|
||||||
|
|
|
@ -214,7 +214,6 @@ bool S3D_RESOLVER::createPathList( void )
|
||||||
{
|
{
|
||||||
// filter out URLs, template directories, and known system paths
|
// filter out URLs, template directories, and known system paths
|
||||||
if( mS->first == wxString( "KICAD_PTEMPLATES" )
|
if( mS->first == wxString( "KICAD_PTEMPLATES" )
|
||||||
|| mS->first == wxString( "KIGITHUB" )
|
|
||||||
|| mS->first == wxString( "KISYSMOD" ) )
|
|| mS->first == wxString( "KISYSMOD" ) )
|
||||||
{
|
{
|
||||||
++mS;
|
++mS;
|
||||||
|
|
Loading…
Reference in New Issue