Fix issues in fp lib table wizard

This commit is contained in:
jean-pierre charras 2015-01-16 09:10:23 +01:00
parent 0b1a6fd7c3
commit c27b2fbf4c
4 changed files with 116 additions and 93 deletions

View File

@ -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 <stambaughw@verizon.net>
* 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 ) );

View File

@ -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
/**

View File

@ -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<class ShapeAType, class ShapeBType>
template<class ShapeAType, class ShapeBType>
inline bool CollCase( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
{
return Collide (*static_cast<const ShapeAType*>( aA ),
*static_cast<const ShapeBType*>( aB ),
aClearance, aNeedMTV, aMTV);
return Collide (*static_cast<const ShapeAType*>( aA ),
*static_cast<const ShapeBType*>( aB ),
aClearance, aNeedMTV, aMTV);
}
template<class ShapeAType, class ShapeBType>
template<class ShapeAType, class ShapeBType>
inline bool CollCaseReversed ( const SHAPE* aA, const SHAPE* aB, int aClearance, bool aNeedMTV, VECTOR2I& aMTV )
{
bool rv = Collide (*static_cast<const ShapeBType*>( aB ),
*static_cast<const ShapeAType*>( 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<SHAPE_RECT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
{
switch( aA->Type() )
{
case SH_RECT:
switch( aB->Type() )
{
case SH_CIRCLE:
return CollCase<SHAPE_RECT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
break;
}
case SH_CIRCLE:
switch( aB->Type() )
{
case SH_RECT:
return CollCaseReversed<SHAPE_CIRCLE, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
break;
}
break;
}
case SH_LINE_CHAIN:
switch( aB->Type() )
{
case SH_RECT:
return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
switch( aB->Type() )
{
case SH_RECT:
return CollCaseReversed<SHAPE_CIRCLE, SHAPE_RECT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_CIRCLE, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
break;
}
default:
break;
}
case SH_SEGMENT:
switch( aB->Type() )
{
case SH_RECT:
return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
switch( aB->Type() )
{
case SH_RECT:
return CollCase<SHAPE_RECT, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
case SH_CIRCLE:
return CollCase<SHAPE_CIRCLE, SHAPE_LINE_CHAIN>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_LINE_CHAIN>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
default:
break;
}
case SH_SEGMENT:
switch( aB->Type() )
{
case SH_RECT:
return CollCase<SHAPE_RECT, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_CIRCLE:
return CollCaseReversed<SHAPE_SEGMENT, SHAPE_CIRCLE>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_LINE_CHAIN:
return CollCase<SHAPE_LINE_CHAIN, SHAPE_SEGMENT>( aB, aA, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_SEGMENT, SHAPE_SEGMENT>( aA, aB, aClearance, aNeedMTV, aMTV );
case SH_SEGMENT:
return CollCase<SHAPE_SEGMENT, SHAPE_SEGMENT>( 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;
}

View File

@ -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" ) );