From c27b2fbf4c23610997d3e46805550ce16ceb62ad Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 16 Jan 2015 09:10:23 +0100 Subject: [PATCH] Fix issues in fp lib table wizard --- common/basicframe.cpp | 11 +- common/build_version.cpp | 6 +- common/geometry/shape_collisions.cpp | 156 +++++++++++++-------------- pcbnew/dialogs/wizard_add_fplib.cpp | 36 +++++-- 4 files changed, 116 insertions(+), 93 deletions(-) diff --git a/common/basicframe.cpp b/common/basicframe.cpp index 258d6ba008..ef6867fb34 100644 --- a/common/basicframe.cpp +++ b/common/basicframe.cpp @@ -1,9 +1,9 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * Copyright (C) 1992-2013 KiCad Developers, see AUTHORS.txt for contributors. + * 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 @@ -629,6 +629,13 @@ void EDA_BASE_FRAME::CopyVersionInfoToClipboard( wxCommandEvent& event ) tmp << wxT( "OFF\n" ); #endif + tmp << wxT( " KICAD_USE_WEBKIT=" ); +#ifdef KICAD_USE_WEBKIT + tmp << wxT( "ON\n" ); +#else + tmp << wxT( "OFF\n" ); +#endif + wxMessageBox( tmp, _("Version Information (copied to the clipboard)") ); wxTheClipboard->SetData( new wxTextDataObject( tmp ) ); diff --git a/common/build_version.cpp b/common/build_version.cpp index 77f401733d..b9e5868237 100644 --- a/common/build_version.cpp +++ b/common/build_version.cpp @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 2015 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 @@ -30,7 +30,7 @@ #endif #ifndef KICAD_BUILD_VERSION -# define KICAD_BUILD_VERSION "(2014-jul-16 BZR unknown)" +# define KICAD_BUILD_VERSION "(after 2015-jan-16 BZR unknown)" #endif /** diff --git a/common/geometry/shape_collisions.cpp b/common/geometry/shape_collisions.cpp index 806a50244b..c21ecc6054 100644 --- a/common/geometry/shape_collisions.cpp +++ b/common/geometry/shape_collisions.cpp @@ -171,7 +171,7 @@ static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_LINE_CHAIN& aB, static inline bool Collide( const SHAPE_CIRCLE& aA, const SHAPE_SEGMENT& aSeg, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { - bool col = aA.Collide( aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); + bool col = aA.Collide( aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2); if( col && aNeedMTV ) { @@ -210,134 +210,134 @@ static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_LINE_CHAIN& aB, in static inline bool Collide( const SHAPE_RECT& aA, const SHAPE_SEGMENT& aSeg, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { - return aA.Collide( aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2 ); + return aA.Collide( aSeg.GetSeg(), aClearance + aSeg.GetWidth() / 2 ); } static inline bool Collide( const SHAPE_SEGMENT& aA, const SHAPE_SEGMENT& aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { - return aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2 ); + return aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2 ); } static inline bool Collide( const SHAPE_LINE_CHAIN& aA, const SHAPE_SEGMENT& aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { - if( aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2 ) ) - return true; + if( aA.Collide( aB.GetSeg(), aClearance + aB.GetWidth() / 2 ) ) + return true; - return false; + return false; } -template +template inline bool CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { - return Collide (*static_cast( aA ), - *static_cast( aB ), - aClearance, aNeedMTV, aMTV); + return Collide (*static_cast( aA ), + *static_cast( aB ), + aClearance, aNeedMTV, aMTV); } -template +template inline bool CollCaseReversed ( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) { bool rv = Collide (*static_cast( aB ), *static_cast( aA ), aClearance, aNeedMTV, aMTV); - if(rv && aNeedMTV) + if(rv && aNeedMTV) aMTV = -aMTV; return rv; } bool CollideShapes( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV ) -{ - switch( aA->Type() ) - { - case SH_RECT: - switch( aB->Type() ) - { - case SH_CIRCLE: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); +{ + switch( aA->Type() ) + { + case SH_RECT: + switch( aB->Type() ) + { + case SH_CIRCLE: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_LINE_CHAIN: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_LINE_CHAIN: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_SEGMENT: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: - break; - } - - case SH_CIRCLE: - switch( aB->Type() ) - { - case SH_RECT: - return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); - - case SH_CIRCLE: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - - case SH_LINE_CHAIN: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - - case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: - break; - } + break; + } - case SH_LINE_CHAIN: - switch( aB->Type() ) - { - case SH_RECT: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + case SH_CIRCLE: + switch( aB->Type() ) + { + case SH_RECT: + return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_CIRCLE: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + case SH_CIRCLE: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_LINE_CHAIN: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_LINE_CHAIN: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_SEGMENT: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: - break; - } + default: + break; + } - case SH_SEGMENT: - switch( aB->Type() ) - { - case SH_RECT: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + case SH_LINE_CHAIN: + switch( aB->Type() ) + { + case SH_RECT: + return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); - case SH_CIRCLE: + case SH_CIRCLE: + return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + + case SH_LINE_CHAIN: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + + case SH_SEGMENT: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + + default: + break; + } + + case SH_SEGMENT: + switch( aB->Type() ) + { + case SH_RECT: + return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + + case SH_CIRCLE: return CollCaseReversed( aA, aB, aClearance, aNeedMTV, aMTV ); - case SH_LINE_CHAIN: - return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); + case SH_LINE_CHAIN: + return CollCase( aB, aA, aClearance, aNeedMTV, aMTV ); - case SH_SEGMENT: - return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); + case SH_SEGMENT: + return CollCase( aA, aB, aClearance, aNeedMTV, aMTV ); - default: - break; - } + default: + break; + } - default: - break; - } + default: + break; + } - bool unsupported_collision = true; + bool unsupported_collision = true; (void) unsupported_collision; // make gcc quiet - assert( unsupported_collision == false ); + assert( unsupported_collision == false ); - return false; + return false; } diff --git a/pcbnew/dialogs/wizard_add_fplib.cpp b/pcbnew/dialogs/wizard_add_fplib.cpp index 94f82a99bd..04d15ff6c7 100644 --- a/pcbnew/dialogs/wizard_add_fplib.cpp +++ b/pcbnew/dialogs/wizard_add_fplib.cpp @@ -136,14 +136,18 @@ void WIZARD_FPLIB_TABLE::initDlg( wxArrayString& aEnvVariableList ) wxString msg; wxConfigBase* cfg = Pgm().CommonSettings(); - cfg->Read( KICAD_FPLIBS_URL_KEY, &msg ); cfg->Read( WIZARD_LAST_PLUGIN_KEY, &m_last_plugin_choice ); cfg->Read( WIZARD_LAST_PATHOPTION_KEY, &m_last_defaultpath_choice ); + cfg->Read( KICAD_FPLIBS_URL_KEY, &msg ); - if( msg.IsEmpty() ) - m_textCtrlGithubURL->SetValue( wxT( "http://github.com/KiCad/" ) ); - else - m_textCtrlGithubURL->SetValue( msg ); + if( msg.IsEmpty() ) // Give our current KiCad github URL + msg = wxT( "http://github.com/KiCad" ); + + // Be sure there is no trailing '/' at the end of the repo name + if( msg.EndsWith( wxT("/" ) ) ) + msg.RemoveLast(); + + m_textCtrlGithubURL->SetValue( msg ); // KIGITHUB is frequently used (examples in docs, and other place) // So add it if it not yet in list, but if it is defined as env var @@ -744,11 +748,13 @@ void WIZARD_FPLIB_TABLE::selectLibsGithubWithWebViewer() // select a set of l defaultURL = wxT( "https://github.com/KiCad" ); #ifdef KICAD_USE_WEBKIT RunWebViewer( this, defaultURL, &urls ); - installGithubLibsFromList( urls ); #else - urls.Add( defaultURL + wxT("newlibname.pretty") ); + // If the Web Viewer is not available, just add a template + // to the fp lib table. + // The user have to edit it + urls.Add( defaultURL + wxT("/newlibname.pretty") ); #endif - + installGithubLibsFromList( urls ); } void WIZARD_FPLIB_TABLE::installGithubLibsFromList( wxArrayString& aUrlList ) @@ -843,12 +849,22 @@ void WIZARD_FPLIB_TABLE::OnGithubLibsList( wxCommandEvent& event ) void WIZARD_FPLIB_TABLE::getLibsListGithub( wxArrayString& aList ) { wxBeginBusyCursor(); - GITHUB_GETLIBLIST getter( m_textCtrlGithubURL->GetValue() ); - wxEndBusyCursor(); + + // 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 ); wxArrayString fullList; getter.GetLibraryList( fullList ); + wxEndBusyCursor(); + wxArrayInt choices; wxString msg( _( "Urls detected as footprint .pretty libraries.\n" "Selected urls will be added to the current footprint library list" ) );