Commit e7ea0480 authored by Maciej Suminski's avatar Maciej Suminski

Upstream merge.

parents bff37e50 8e6713ca
......@@ -364,13 +364,13 @@ check_find_package_result( OPENGL_FOUND "OpenGL" )
# https://www.mail-archive.com/cmake@cmake.org/msg47501.html
# Handle target used to specify if a target needs wx-widgets or other libraries
# Always defined, empty if no libraries are to be build
# Always defined, empty if no libraries are to be built
add_custom_target( lib-dependencies )
if( KICAD_BUILD_STATIC OR KICAD_BUILD_DYNAMIC )
# This should be build in all cases, if swig exec is not avaiable
# will be impossible also enable SCRIPTING being for PCBNEW required immediatly
# This should be built in all cases, if swig exec is not avaiable
# will be impossible also enable SCRIPTING being for PCBNEW required immediately
include( download_pcre )
include( download_swig )
......
......@@ -172,6 +172,7 @@ set( COMMON_SRCS
eda_dde.cpp
eda_doc.cpp
filter_reader.cpp
# findkicadhelppath.cpp.notused deprecated, use searchhelpfilefullpath.cpp
gestfich.cpp
getrunningmicrosecs.cpp
grid_tricks.cpp
......@@ -189,6 +190,7 @@ set( COMMON_SRCS
ptree.cpp
reporter.cpp
richio.cpp
searchhelpfilefullpath.cpp
search_stack.cpp
selcolor.cpp
systemdirsappend.cpp
......
......@@ -271,6 +271,18 @@ wxConfigBase* EDA_BASE_FRAME::config()
}
const SEARCH_STACK& EDA_BASE_FRAME::sys_search()
{
return Kiface().KifaceSearch();
}
wxString EDA_BASE_FRAME::help_name()
{
return Kiface().GetHelpFileName();
}
void EDA_BASE_FRAME::PrintMsg( const wxString& text )
{
SetStatusText( text );
......@@ -327,33 +339,28 @@ wxString EDA_BASE_FRAME::GetFileFromHistory( int cmdId, const wxString& type,
void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
{
wxString msg;
const SEARCH_STACK& search = sys_search();
/* We have to get document for beginners,
* or the the full specific doc
* or the full specific doc
* if event id is wxID_INDEX, we want the document for beginners.
* else the specific doc file (its name is in Kiface().GetHelpFileName())
* The document for beginners is the same for all KiCad utilities
*/
if( event.GetId() == wxID_INDEX )
{
// Temporarily change the help filename
wxString tmp = Kiface().GetHelpFileName();
// Search for "getting_started_in_kicad.pdf" or "Getting_Started_in_KiCad.pdf"
Kiface().SetHelpFileName( wxT( "getting_started_in_kicad.pdf" ) );
wxString helpFile = Kiface().GetHelpFile();
wxString helpFile = SearchHelpFileFullPath( search, wxT( "getting_started_in_kicad.pdf" ) );
if( !helpFile )
{ // Try to find "Getting_Started_in_KiCad.pdf"
Kiface().SetHelpFileName( wxT( "Getting_Started_in_KiCad.pdf" ) );
helpFile = Kiface().GetHelpFile();
}
helpFile = SearchHelpFileFullPath( search, wxT( "Getting_Started_in_KiCad.pdf" ) );
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( Kiface().GetHelpFileName() ) );
wxString msg = wxString::Format( _(
"Help file '%s' could not be found." ),
wxT( "getting_started_in_kicad.pdf" )
);
wxMessageBox( msg );
}
else
......@@ -361,36 +368,36 @@ void EDA_BASE_FRAME::GetKicadHelp( wxCommandEvent& event )
GetAssociatedDocument( this, helpFile );
}
Kiface().SetHelpFileName( tmp );
return;
}
wxString base_name = help_name();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
if( Kiface().GetHtmlHelpController() == NULL )
{
Kiface().InitOnLineHelp();
}
wxHtmlHelpController* hc = Pgm().GetHtmlHelpController();
wxString helpFile = SearchHelpFileFullPath( search, );
if( Kiface().GetHtmlHelpController() )
if( !!helpFile )
{
Kiface().GetHtmlHelpController()->DisplayContents();
Kiface().GetHtmlHelpController()->Display( Kiface().GetHelpFileName() );
}
else
{
msg.Printf( _( "Help file %s could not be found." ), GetChars( Kiface().GetHelpFileName() ) );
wxMessageBox( msg );
hc->UseConfig( Pgm().CommonSettings() );
hc->SetTitleFormat( wxT( "KiCad Help" ) );
hc->AddBook( helpFile );
}
hc->DisplayContents();
hc->Display( helpFile );
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
wxString helpFile = Kiface().GetHelpFile();
wxString helpFile = SearchHelpFileFullPath( search, base_name );
if( !helpFile )
{
msg.Printf( _( "Help file %s could not be found." ),
GetChars( Kiface().GetHelpFileName() ) );
wxString msg = wxString::Format( _(
"Help file '%s' could not be found." ),
GetChars( base_name )
);
wxMessageBox( msg );
}
else
......
......@@ -64,15 +64,19 @@ bool GetAssociatedDocument( wxFrame* aFrame,
const wxPathList* aPaths)
{
wxString docname, fullfilename, file_ext;
wxString docname, fullfilename;
wxString msg;
wxString command;
bool success = false;
// Is an internet url
static const wxString url_header[3] = { wxT( "http:" ), wxT( "ftp:" ), wxT( "www." ) };
static const wxChar* url_header[3] = {
wxT( "http:" ),
wxT( "ftp:" ),
wxT( "www." )
};
for( int ii = 0; ii < 3; ii++ )
for( unsigned ii = 0; ii < DIM(url_header); ii++ )
{
if( aDocName.First( url_header[ii] ) == 0 ) //. seems an internet url
{
......@@ -133,8 +137,9 @@ bool GetAssociatedDocument( wxFrame* aFrame,
return false;
}
wxFileName CurrentFileName( fullfilename );
file_ext = CurrentFileName.GetExt();
wxFileName currentFileName( fullfilename );
wxString file_ext = currentFileName.GetExt();
if( file_ext == wxT( "pdf" ) )
{
......
#include <fctsys.h>
#include <pgm_base.h>
#include <macros.h>
#include <gestfich.h>
/**
* Function FindKicadHelpPath
* finds the absolute path for KiCad "help" (or "help/&ltlanguage&gt")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*/
wxString FindKicadHelpPath()
{
bool found = false;
wxString bin_dir = Pgm().GetExecutablePath();
if( bin_dir.Last() == '/' )
bin_dir.RemoveLast();
wxString fullPath = bin_dir.BeforeLast( '/' ); // cd ..
fullPath += wxT( "/doc/help/" );
wxString localeString = Pgm().GetLocale()->GetCanonicalName();
wxString path_tmp = fullPath;
#ifdef __WINDOWS__
path_tmp.MakeLower();
#endif
if( path_tmp.Contains( wxT( "kicad" ) ) )
{
if( wxDirExists( fullPath ) )
found = true;
}
// find kicad/help/ from environment variable KICAD
if( !found && Pgm().IsKicadEnvVariableDefined() )
{
fullPath = Pgm().GetKicadEnvVariable() + wxT( "/doc/help/" );
if( wxDirExists( fullPath ) )
found = true;
}
if( !found )
{
// Possibilities online help
const static wxChar* possibilities[] = {
#ifdef __WINDOWS__
wxT( "c:/kicad/doc/help/" ),
wxT( "d:/kicad/doc/help/" ),
wxT( "c:/Program Files/kicad/doc/help/" ),
wxT( "d:/Program Files/kicad/doc/help/" ),
#else
wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/share/doc/kicad/help/" ),
wxT( "/usr/local/kicad/doc/help/" ), // default install for "universal
// tarballs" and build for a server
// (new)
wxT( "/usr/local/kicad/help/" ), // default install for "universal
// tarballs" and build for a server
// (old)
#endif
};
for( unsigned i=0; i<DIM(possibilities); ++i )
{
fullPath = possibilities[i];
if( wxDirExists( fullPath ) )
{
found = true;
break;
}
}
}
if( found )
{
wxString langFullPath = fullPath + localeString + UNIX_STRING_DIR_SEP;
if( wxDirExists( langFullPath ) )
return langFullPath;
langFullPath = fullPath + localeString.Left( 2 ) + UNIX_STRING_DIR_SEP;
if( wxDirExists( langFullPath ) )
return langFullPath;
langFullPath = fullPath + wxT( "en/" );
if( wxDirExists( langFullPath ) )
{
return langFullPath;
}
else
{
langFullPath = fullPath + wxT( "fr/" );
if( wxDirExists( langFullPath ) )
return langFullPath;
}
return fullPath;
}
return wxEmptyString;
}
......@@ -622,8 +622,6 @@ const FP_LIB_TABLE::ROW* FP_LIB_TABLE::FindRow( const wxString& aNickname )
// wxGetenv( wchar_t* ) is not re-entrant on linux.
// Put a lock on multithreaded use of wxGetenv( wchar_t* ), called from wxEpandEnvVars(),
// needed by bool ReadFootprintFiles( FP_LIB_TABLE* aTable, const wxString* aNickname = NULL );
#if 1
#include <ki_mutex.h>
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
......@@ -637,177 +635,44 @@ const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
return wxExpandEnvVars( aString );
}
#else
const wxString FP_LIB_TABLE::ExpandSubstitutions( const wxString& aString )
{
// We reserve the right to do this another way, by providing our own member
// function.
return wxExpandEnvVars( aString );
}
#endif
bool FP_LIB_TABLE::IsEmpty( bool aIncludeFallback )
{
if( !aIncludeFallback || (fallBack == NULL) )
if( !aIncludeFallback || !fallBack )
return rows.empty();
return fallBack->IsEmpty() && rows.empty();
return rows.empty() && fallBack->IsEmpty( true );
}
bool FP_LIB_TABLE::ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
const wxArrayString& aLibNames, REPORTER* aReporter ) throw( IO_ERROR )
MODULE* FP_LIB_TABLE::FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
throw( IO_ERROR, PARSE_ERROR )
{
wxString msg;
FPID lastFPID;
COMPONENT* component;
MODULE* module = 0;
bool retv = true;
if( aNetList.IsEmpty() )
return true;
aNetList.SortByFPID();
wxString libPath;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::LEGACY ) );
wxString nickname = aFootprintId.GetLibNickname();
wxString fpname = aFootprintId.GetFootprintName();
for( unsigned ii = 0; ii < aNetList.GetCount(); ii++ )
if( nickname.size() )
{
component = aNetList.GetComponent( ii );
// The footprint hasn't been assigned yet so ignore it.
if( component->GetFPID().empty() )
continue;
if( component->GetFPID() != lastFPID )
{
module = NULL;
for( unsigned ii = 0; ii < aLibNames.GetCount(); ii++ )
{
wxFileName fn( wxEmptyString, aLibNames[ii], LegacyFootprintLibPathExtension );
libPath = aSStack.FindValidPath( fn );
if( !libPath )
{
if( aReporter )
{
msg.Printf( _( "Cannot find footprint library file '%s' in any of the "
"KiCad legacy library search paths.\n" ),
GetChars( fn.GetFullPath() ) );
aReporter->Report( msg );
}
retv = false;
continue;
}
module = pi->FootprintLoad( libPath, component->GetFPID().GetFootprintName() );
return FootprintLoad( nickname, fpname );
}
if( module )
{
lastFPID = component->GetFPID();
break;
}
}
}
// nickname is empty, sequentially search (alphabetically) all libs/nicks for first match:
else
{
std::vector<wxString> nicks = GetLogicalLibs();
if( !module )
// Search each library going through libraries alphabetically.
for( unsigned i = 0; i<nicks.size(); ++i )
{
if( aReporter )
{
msg.Printf( _( "Component `%s` footprint '%s' was not found in any legacy "
"library.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg );
}
// Clear the footprint assignment since the old library lookup method is no
// longer valid.
FPID emptyFPID;
component->SetFPID( emptyFPID );
retv = false;
continue;
// FootprintLoad() returns NULL on not found, does not throw exception
// unless there's an IO_ERROR.
MODULE* ret = FootprintLoad( nicks[i], fpname );
if( ret )
return ret;
}
else
{
wxString libNickname;
FP_LIB_TABLE* cur = this;
do
{
cur->ensureIndex();
for( unsigned i = 0; i < cur->rows.size(); i++ )
{
wxString uri = cur->rows[i].GetFullURI( true );
if( wxFileName::GetPathSeparator() == wxChar( '\\' )
&& uri.Find( wxChar( '/' ) ) >= 0 )
{
uri.Replace( wxT( "/"), wxT( "\\" ) );
}
#ifdef __WINDOWS__
if( uri.CmpNoCase( libPath ) )
#else
if( uri == libPath )
#endif
{
libNickname = cur->rows[i].GetNickName();
break;
}
}
} while( ( cur = cur->fallBack ) != 0 && libNickname.IsEmpty() );
if( libNickname.IsEmpty() )
{
if( aReporter )
{
msg.Printf( _( "Component '%s' footprint '%s' legacy library path '%s' "
"was not found in the footprint library table.\n" ),
GetChars( component->GetReference() ),
GetChars( component->GetFPID().Format() ) );
aReporter->Report( msg );
}
retv = false;
}
else
{
FPID newFPID = lastFPID;
newFPID.SetLibNickname( libNickname );
if( !newFPID.IsValid() )
{
if( aReporter )
{
msg.Printf( _( "Component '%s' FPID '%s' is not valid.\n" ),
GetChars( component->GetReference() ),
GetChars( newFPID.Format() ) );
aReporter->Report( msg );
}
retv = false;
}
else
{
// The footprint name should already be set.
component->SetFPID( newFPID );
}
}
}
return NULL;
}
return retv;
}
......@@ -839,17 +704,14 @@ bool FP_LIB_TABLE::LoadGlobalTable( FP_LIB_TABLE& aTable ) throw (IO_ERROR, PARS
// The fallback is to create an empty global footprint table for the user to populate.
if( fileName.IsEmpty() || !::wxCopyFile( fileName, fn.GetFullPath(), false ) )
{
FP_LIB_TABLE emptyTable;
FILE_OUTPUTFORMATTER sf( fn.GetFullPath() );
FP_LIB_TABLE emptyTable;
emptyTable.Format( &sf, 0 );
emptyTable.Save( fn.GetFullPath() );
}
}
FILE_LINE_READER reader( fn.GetFullPath() );
FP_LIB_TABLE_LEXER lexer( &reader );
aTable.Load( fn.GetFullPath() );
aTable.Parse( &lexer );
return tableExists;
}
......
This diff is collapsed.
......@@ -55,10 +55,11 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
// we must add <kicad path>/library and <kicad path>/library/doc
if( aId == KIWAY::FACE_SCH )
{
// Add schematic doc file path (library/doc) to search path list.
fn.AppendDir( wxT( "library" ) );
aDst->AddPaths( fn.GetPath() );
// Add schematic doc file path (library/doc)to search path list.
fn.AppendDir( wxT( "doc" ) );
aDst->AddPaths( fn.GetPath() );
......@@ -85,8 +86,10 @@ static void setSearchPaths( SEARCH_STACK* aDst, KIWAY::FACE_T aId )
aDst->AddPaths( fn.GetPath() );
}
aDst->AddPaths( wxT( "/usr/local/share" ) );
#if 1 && defined(DEBUG)
aDst->Show( "kiway" );
aDst->Show( "kiface" );
#endif
}
......@@ -121,86 +124,3 @@ void KIFACE_I::end_common()
m_bm.End();
}
wxString KIFACE_I::GetHelpFile()
{
wxString fn;
wxArrayString subdirs;
wxArrayString altsubdirs;
// FIXME: This is not the ideal way to handle this. Unfortunately, the
// CMake install paths seem to be a moving target so this crude
// hack solves the problem of install path differences between
// Windows and non-Windows platforms.
// Partially fixed, but must be enhanced
// Create subdir tree for "standard" linux distributions, when KiCad comes
// from a distribution files are in /usr/share/doc/kicad/help and binaries
// in /usr/bin or /usr/local/bin
subdirs.Add( wxT( "share" ) );
subdirs.Add( wxT( "doc" ) );
subdirs.Add( wxT( "kicad" ) );
subdirs.Add( wxT( "help" ) );
// Create subdir tree for linux and Windows KiCad pack.
// Note the pack form under linux is also useful if a user wants to
// install KiCad to a server because there is only one path to mount
// or export (something like /usr/local/kicad).
// files are in <install dir>/kicad/doc/help
// (often /usr/local/kicad/kicad/doc/help)
// <install dir>/kicad/ is retrieved from m_BinDir
altsubdirs.Add( wxT( "doc" ) );
altsubdirs.Add( wxT( "help" ) );
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale* i18n = Pgm().GetLocale();
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( i18n->GetCanonicalName() );
altsubdirs.Add( i18n->GetCanonicalName() );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
// Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
// wxLocale::GetName() does not return always the short name
subdirs.Add( i18n->GetName().BeforeLast( '_' ) );
altsubdirs.Add( i18n->GetName().BeforeLast( '_' ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( wxT( "en" ) );
altsubdirs.Add( wxT( "en" ) );
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &altsubdirs );
if( !fn )
fn = m_bm.m_search.FindFileInSearchPaths( m_bm.m_help_file, &subdirs );
}
return fn;
}
......@@ -744,7 +744,7 @@ void WORKSHEET_LAYOUT::SetDefaultLayout()
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogMessage( ioe.errorText );
}
......@@ -765,7 +765,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const char* aPageLayout, bool Append )
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogMessage( ioe.errorText );
}
......@@ -828,7 +828,7 @@ void WORKSHEET_LAYOUT::SetPageLayout( const wxString& aFullFileName, bool Append
{
lp_parser.Parse( this );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogMessage( ioe.errorText );
}
......
......@@ -297,6 +297,13 @@ void PGM_BASE::destroy()
delete m_locale;
m_locale = 0;
/*
// Close the help frame
if( m_html_ctrl && m_html_ctrl->GetFrame() ) // returns NULL if no help frame active
m_html_ctrl->GetFrame()->Close( true );
}
*/
delete m_html_ctrl;
m_html_ctrl = 0;
}
......@@ -415,30 +422,18 @@ bool PGM_BASE::initPgm()
}
void PGM_BASE::SetHtmlHelpController( wxHtmlHelpController* aController )
void PGM_BASE::initHtmlHelpController()
{
delete m_html_ctrl;
m_html_ctrl = aController;
}
void PGM_BASE::InitOnLineHelp()
{
wxString fullfilename = FindKicadHelpPath();
#if defined ONLINE_HELP_FILES_FORMAT_IS_HTML
m_HelpFileName = fullfilename + wxT( ".html" );
fullfilename += wxT( "kicad.hhp" );
if( wxFileExists( fullfilename ) )
{
m_html_ctrl = new wxHtmlHelpController( wxHF_TOOLBAR | wxHF_CONTENTS |
wxHF_PRINT | wxHF_OPEN_FILES
/*| wxHF_SEARCH */ );
m_html_ctrl->UseConfig( m_common_settings );
m_html_ctrl->SetTitleFormat( wxT( "KiCad Help" ) );
m_html_ctrl->AddBook( fullfilename );
}
if( !m_html_ctrl )
m_html_ctrl = new wxHtmlHelpController(
wxHF_TOOLBAR | wxHF_CONTENTS |
wxHF_PRINT | wxHF_OPEN_FILES
// | wxHF_SEARCH
);
wxASSERT( m_html_ctrl ); // may not leave here as NULL
#elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF
m_html_ctrl = NULL;
......@@ -449,10 +444,22 @@ void PGM_BASE::InitOnLineHelp()
}
wxHtmlHelpController* PGM_BASE::HtmlHelpController()
{
if( !m_html_ctrl )
initHtmlHelpController();
// there should not be calls to this unless ONLINE_HELP_FILES_FORMAT_IS_HTML is defined
wxASSERT( m_html_ctrl );
return m_html_ctrl;
}
bool PGM_BASE::setExecutablePath()
{
// Apple MacOSx
#ifdef __APPLE__
#ifdef __APPLE__ // Apple MacOSx
// Derive path from location of the app bundle
CFBundleRef mainBundle = CFBundleGetMainBundle();
......
......@@ -23,18 +23,19 @@
*/
#include <wx/stdpaths.h>
#include <fctsys.h>
#include <macros.h>
#include <gr_basic.h>
#include <pgm_base.h>
#include <project.h>
#include <wx/stdpaths.h>
#include <confirm.h>
#include <kicad_string.h>
#include <config_params.h>
#include <wildcards_and_files_ext.h>
PROJECT::PROJECT()
{
memset( m_elems, 0, sizeof(m_elems) );
......@@ -198,18 +199,18 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
const wxString& aGroupName, bool aForceUseLocalConfig )
{
wxConfigBase* cfg = 0;
wxFileName fn = aFileName;
wxFileName fn = aFileName;
fn.SetExt( ProjectFileExtension );
wxString cur_pro_fn = fn.GetFullPath();
// is there an edge transition, a change in m_project_filename?
if( m_project_name != fn )
if( m_project_name != cur_pro_fn )
{
m_sch_search.Clear();
SetProjectFullName( fn.GetFullPath() );
// to the empty list, add project dir as first
// to the empty lists, add project dir as first
m_sch_search.AddPaths( fn.GetPath() );
// append all paths from aSList
......@@ -228,8 +229,6 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
// Init local config filename
if( aForceUseLocalConfig || fn.FileExists() )
{
wxString cur_pro_fn = fn.GetFullPath();
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
......@@ -262,31 +261,43 @@ wxConfigBase* PROJECT::configCreate( const SEARCH_STACK& aSList, const wxString&
}
else // Version incorrect
{
wxLogDebug( wxT( "Project file version is zero, not using this old project file, going with template." ) );
delete cfg;
cfg = 0;
}
}
// Search for the template kicad.pro file by using caller's SEARCH_STACK.
// No suitable pro file was found, either does not exist, or is too old.
// Use the template kicad.pro file. Find it by using caller's SEARCH_STACK.
wxString kicad_pro_template = aSList.FindValidPath( wxT( "kicad.pro" ) );
if( !kicad_pro_template )
{
wxLogDebug( wxT( "Template file <kicad.pro> not found." ) );
wxLogDebug( wxT( "Template file <kicad.pro> not found using search paths." ) );
fn = wxFileName( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
}
else
{
fn = kicad_pro_template;
wxFileName templ( wxStandardPaths::Get().GetDocumentsDir(),
wxT( "kicad" ), ProjectFileExtension );
if( !templ.IsFileReadable() )
{
wxString msg = wxString::Format( _( "Unable to find kicad.pro template file." ) );
DisplayError( NULL, msg );
return NULL;
}
kicad_pro_template = templ.GetFullPath();
}
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, wxEmptyString, fn.GetFullPath() );
// copy the template to cur_pro_fn, and open it at that destination.
wxCopyFile( kicad_pro_template, cur_pro_fn );
cfg = new wxFileConfig( wxEmptyString, wxEmptyString, cur_pro_fn, wxEmptyString );
cfg->DontCreateOnDemand();
SetProjectFullName( fn.GetFullPath() );
SetProjectFullName( cur_pro_fn );
return cfg;
}
......@@ -296,6 +307,12 @@ void PROJECT::ConfigSave( const SEARCH_STACK& aSList, const wxString& aFileName
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, FORCE_LOCAL_CONFIG ) );
if( !cfg.get() )
{
// could not find template
return;
}
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
cfg->Write( wxT( "update" ), DateAndTime() );
......@@ -326,6 +343,12 @@ bool PROJECT::ConfigLoad( const SEARCH_STACK& aSList, const wxString& aFileName,
{
std::auto_ptr<wxConfigBase> cfg( configCreate( aSList, aFileName, aGroupName, false ) );
if( !cfg.get() )
{
// could not find template
return false;
}
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
wxString timestamp = cfg->Read( wxT( "update" ) );
......
......@@ -104,31 +104,6 @@ void SEARCH_STACK::AddPaths( const wxString& aPaths, int aIndex )
}
wxString SEARCH_STACK::FindFileInSearchPaths(
const wxString& aFilename, const wxArrayString* aSubdirs )
{
wxPathList paths;
for( unsigned i = 0; i < GetCount(); ++i )
{
wxFileName fn( (*this)[i] );
if( aSubdirs )
{
for( unsigned j = 0; j < aSubdirs->GetCount(); j++ )
fn.AppendDir( (*aSubdirs)[j] );
}
if( fn.DirExists() )
{
paths.Add( fn.GetPath() );
}
}
return paths.FindValidPath( aFilename );
}
void RETAINED_PATH::Clear()
{
m_retained_path.Clear();
......
#include <pgm_base.h>
#include <common.h>
/**
* Function FindFileInSearchPaths
* looks in "this" for \a aFilename, but first modifies every search
* path by appending a list of path fragments from aSubdirs. That modification
* is not rentative.
*/
wxString FindFileInSearchPaths( const SEARCH_STACK& aStack,
const wxString& aFilename, const wxArrayString* aSubdirs )
{
wxPathList paths;
for( unsigned i = 0; i < aStack.GetCount(); ++i )
{
wxFileName fn( aStack[i], wxEmptyString );
if( aSubdirs )
{
for( unsigned j = 0; j < aSubdirs->GetCount(); j++ )
fn.AppendDir( (*aSubdirs)[j] );
}
if( fn.DirExists() )
{
paths.Add( fn.GetPath() );
}
}
return paths.FindValidPath( aFilename );
}
// See also FindKicadHelpPath.cpp.notused.
wxString SearchHelpFileFullPath( const SEARCH_STACK& aSStack, const wxString& aBaseName )
{
wxArrayString subdirs;
wxArrayString altsubdirs;
SEARCH_STACK ss = aSStack;
// It might already be in aSStack, but why depend on other code
// far away when it's so easy to add it again (to our copy) as the first place to look.
// This is CMAKE_INSTALL_PREFIX:
ss.AddPaths( wxT( DEFAULT_INSTALL_PATH ), 0 );
// If there's a KICAD environment variable set, use that guy's path also
ss.AddPaths( Pgm().GetKicadEnvVariable(), 0 );
#if 1 // && defined(__linux__)
// Based on kicad-doc.bzr/CMakeLists.txt, line 20, the help files are
// installed into "<CMAKE_INSTALL_PREFIX>/share/doc/kicad/help" for linux.
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
// Below we account for an international subdirectory.
subdirs.Add( wxT( "share" ) );
subdirs.Add( wxT( "doc" ) );
subdirs.Add( wxT( "kicad" ) );
subdirs.Add( wxT( "help" ) );
#endif
#if 1 // && defined(__WINDOWS__)
// Based on kicad-doc.bzr/CMakeLists.txt, line 35, the help files are
// installed into "<CMAKE_INSTALL_PREFIX>/doc/help" for Windows.
// This is ${KICAD_HELP} var in that CMakeLists.txt file.
// Below we account for an international subdirectory.
altsubdirs.Add( wxT( "doc" ) );
altsubdirs.Add( wxT( "help" ) );
#endif
/* Search for a help file.
* we *must* find a help file.
* so help is searched in directories in this order:
* help/<canonical name> like help/en_GB
* help/<short name> like help/en
* help/en
*/
wxLocale* i18n = Pgm().GetLocale();
// Step 1 : Try to find help file in help/<canonical name>
subdirs.Add( i18n->GetCanonicalName() );
altsubdirs.Add( i18n->GetCanonicalName() );
#if defined(DEBUG) && 0
ss.Show( __func__ );
printf( "%s: m_help_file:'%s'\n", __func__, TO_UTF8( aBaseName ) );
#endif
wxString fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs );
if( !fn )
fn = FindFileInSearchPaths( ss, aBaseName, &subdirs );
// Step 2 : if not found Try to find help file in help/<short name>
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
// wxLocale::GetName() does not return always the short name
subdirs.Add( i18n->GetName().BeforeLast( '_' ) );
altsubdirs.Add( i18n->GetName().BeforeLast( '_' ) );
fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs );
if( !fn )
fn = FindFileInSearchPaths( ss, aBaseName, &subdirs );
}
// Step 3 : if not found Try to find help file in help/en
if( !fn )
{
subdirs.RemoveAt( subdirs.GetCount() - 1 );
altsubdirs.RemoveAt( altsubdirs.GetCount() - 1 );
subdirs.Add( wxT( "en" ) );
altsubdirs.Add( wxT( "en" ) );
fn = FindFileInSearchPaths( ss, aBaseName, &altsubdirs );
if( !fn )
fn = FindFileInSearchPaths( ss, aBaseName, &subdirs );
}
return fn;
}
......@@ -34,6 +34,7 @@
*/
#include <typeinfo>
#include <macros.h>
#include <fctsys.h>
#include <wx/dynlib.h>
......@@ -182,10 +183,6 @@ static const wxString dso_full_path( const wxString& aAbsoluteArgv0 )
return fn.GetFullPath();
}
// Use of this is arbitrary, remember single_top only knows about a single DSO.
// Could have used one from the KIWAY also.
static wxDynamicLibrary dso;
// Only a single KIWAY is supported in this single_top top level component,
// which is dedicated to loading only a single DSO.
......@@ -230,6 +227,32 @@ struct APP_SINGLE_TOP : public wxApp
return wxApp::OnExit();
}
int OnRun() // overload wxApp virtual
{
try
{
return wxApp::OnRun();
}
catch( const std::exception& e )
{
wxLogError( wxT( "Unhandled exception class: %s what: %s" ),
GetChars( FROM_UTF8( typeid(e).name() )),
GetChars( FROM_UTF8( e.what() ) ) );;
}
catch( const IO_ERROR& ioe )
{
wxLogError( wxT( "Unhandled exception class: %s what: %s" ),
GetChars( FROM_UTF8( typeid( ioe ).name() ) ),
GetChars( ioe.errorText ) );
}
catch(...)
{
wxLogError( wxT( "Unhandled exception of unknown type" ) );
}
return -1;
}
/**
* Function MacOpenFile
* is specific to MacOSX (not used under Linux or Windows).
......@@ -261,6 +284,15 @@ IMPLEMENT_APP( APP_SINGLE_TOP );
static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
{
#if defined(BUILD_KIWAY_DLL)
// Remember single_top only knows about a single DSO. Using an automatic
// with a defeated destructor, see Detach() below, so that the DSO program
// image stays in RAM until process termination, and specifically
// beyond the point in time at which static destructors are run. Otherwise
// a static wxDynamicLibrary's destructor might create an out of sequence
// problem. This was never detected, so it's only a preventative strategy.
wxDynamicLibrary dso;
void* addr = NULL;
if( !dso.Load( aDSOName, wxDL_VERBATIM | wxDL_NOW ) )
......@@ -275,6 +307,9 @@ static KIFACE_GETTER_FUNC* get_kiface_getter( const wxString& aDSOName )
// No further reporting required here.
}
// Tell dso's wxDynamicLibrary destructor not to Unload() the program image.
(void) dso.Detach();
return (KIFACE_GETTER_FUNC*) addr;
#else
......
......@@ -107,7 +107,7 @@ void CVPCB_MAINFRAME::AssocieModule( wxCommandEvent& event )
{
fn.SetExt( fn.GetExt() + wxT( "." ) + FootprintAliasFileExtension );
}
tmp = search.FindValidPath( fn );
tmp = search.FindValidPath( fn.GetFullPath() );
if( !tmp )
{
......
......@@ -27,7 +27,7 @@
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <fp_lib_table.h>
#include <id.h>
#include <common.h>
......@@ -42,29 +42,24 @@
#include <class_DisplayFootprintsFrame.h>
#define GROUP wxT("/cvpcb")
#define GROUPLIB wxT("/pcbnew/libraries")
#define GROUPEQU wxT("/cvpcb/libraries")
PARAM_CFG_ARRAY& CVPCB_MAINFRAME::GetProjectFileParameters()
{
if( !m_projectFileParams.empty() )
return m_projectFileParams;
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUPLIB, PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_BASE( GROUP_PCB_LIBS, PARAM_COMMAND_ERASE ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "LibName" ), &m_ModuleLibNames, GROUPLIB ) );
wxT( "LibName" ), &m_ModuleLibNames, GROUP_PCB_LIBS ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST(
wxT( "EquName" ), &m_AliasLibNames, GROUPEQU ) );
wxT( "EquName" ), &m_AliasLibNames, GROUP_CVP_EQU ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING(
wxT( "NetIExt" ), &m_NetlistFileExtension ) );
m_projectFileParams.push_back( new PARAM_CFG_FILENAME(
wxT( "LibDir" ), &m_UserLibraryPath, GROUPLIB ) );
wxT( "LibDir" ), &m_UserLibraryPath, GROUP_PCB_LIBS ) );
return m_projectFileParams;
}
......@@ -81,7 +76,7 @@ void CVPCB_MAINFRAME::LoadProjectFile( const wxString& aFileName )
fn.SetExt( ProjectFileExtension );
// was: Pgm().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( prj.PcbSearchS(), fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
prj.ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_CVP, GetProjectFileParameters(), false );
if( m_NetlistFileExtension.IsEmpty() )
m_NetlistFileExtension = wxT( "net" );
......@@ -133,7 +128,7 @@ void CVPCB_MAINFRAME::SaveProjectFile( wxCommandEvent& aEvent )
// Pgm().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
PROJECT& prj = Prj();
SEARCH_STACK& search = prj.SchSearchS();
prj.ConfigSave( search, fn.GetFullPath(), GROUP, GetProjectFileParameters() );
prj.ConfigSave( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_CVP, GetProjectFileParameters() );
}
......@@ -490,7 +490,7 @@ MODULE* DISPLAY_FOOTPRINTS_FRAME::Get_Module( const wxString& aFootprintName )
footprint = FootprintLibs()->FootprintLoad( FROM_UTF8( nickname.c_str() ), FROM_UTF8( fpname.c_str() ) );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
......
......@@ -301,13 +301,6 @@ void CVPCB_MAINFRAME::OnCloseWindow( wxCloseEvent& Event )
}
}
// Close the help frame
if( Pgm().GetHtmlHelpController() )
{
if( Pgm().GetHtmlHelpController()->GetFrame() )// returns NULL if no help frame active
Pgm().GetHtmlHelpController()->GetFrame()->Close( true );
}
if( m_NetlistFileName.IsOk() )
{
UpdateFileHistory( m_NetlistFileName.GetFullPath() );
......@@ -846,7 +839,7 @@ int CVPCB_MAINFRAME::ReadSchematicNetlist()
else
wxMessageBox( _( "Unknown netlist format." ), wxEmptyString, wxOK | wxICON_ERROR );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
msg = wxString::Format( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
......
This diff is collapsed.
......@@ -136,7 +136,7 @@ bool LIB_ALIAS::SaveDoc( OUTPUTFORMATTER& aFormatter )
aFormatter.Print( 0, "$ENDCMP\n" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
return false;
}
......
......@@ -731,7 +731,7 @@ bool CMP_LIBRARY::Save( OUTPUTFORMATTER& aFormatter )
aFormatter.Print( 0, "#\n#End Library\n" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
success = false;
}
......@@ -756,7 +756,7 @@ bool CMP_LIBRARY::SaveDocs( OUTPUTFORMATTER& aFormatter )
aFormatter.Print( 0, "#\n#End Doc Library\n" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
success = false;
}
......
......@@ -249,7 +249,7 @@ void DIALOG_BOM::installPluginsList()
{
cfg_parser.Parse();
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
// wxLogMessage( ioe.errorText );
}
......
......@@ -62,7 +62,7 @@ void SCH_EDIT_FRAME::LoadLibraries()
if( !fn.FileExists() )
{
tmp = lib_search.FindValidPath( fn );
tmp = lib_search.FindValidPath( fn.GetFullPath() );
if( !tmp )
{
......
......@@ -368,7 +368,7 @@ PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
&m_userLibraryPath ) );
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
&m_componentLibFiles,
GROUPLIB ) );
GROUP_SCH_LIBS ) );
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ),
&m_netListFormat) );
......@@ -408,7 +408,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceRere
// extension (.pro).
fn.SetExt( ProjectFileExtension );
if( !prj.ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP,
if( !prj.ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_SCH,
GetProjectFileParametersList(), !aForceReread ) )
{
m_componentLibFiles = liblist_tmp;
......@@ -427,7 +427,7 @@ bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceRere
pglayout.SetPageLayout(BASE_SCREEN::m_PageLayoutDescrFileName);
// libraries in the *.pro file take precedence over standard library search paths,
// but not over the director of the project, which is at index 0.
// but not over the directory of the project, which is at index 0.
prj.SchSearchS().AddPaths( m_userLibraryPath, 1 );
// If the list is empty, force loading the standard power symbol library.
......@@ -464,7 +464,7 @@ void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
}
prj.ConfigSave( Kiface().KifaceSearch(),
fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
fn.GetFullPath(), GROUP_SCH, GetProjectFileParametersList() );
}
......@@ -666,7 +666,7 @@ void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg )
{
m_TemplateFieldNames.Parse( &lexer );
}
catch( IO_ERROR& e )
catch( const IO_ERROR& e )
{
// @todo show error msg
DBG( printf( "templatefieldnames parsing error: '%s'\n",
......
......@@ -4,9 +4,6 @@
#include <config_params.h>
#define GROUP wxT( "/eeschema" )
#define GROUPCOMMON wxT( "/common" )
#define GROUPLIB wxT( "libraries" )
/* saving parameters option : */
#define INSETUP true /* used when the parameter is saved in general config
......
......@@ -1049,7 +1049,7 @@ bool NETLIST_EXPORT_TOOL::WriteKiCadNetList( const wxString& aOutFileName )
xroot->Format( &formatter, 0 );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( NULL, ioe.errorText );
return false;
......
......@@ -868,7 +868,7 @@ void SCH_EDIT_FRAME::OnPrint( wxCommandEvent& event )
// was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
Prj().ConfigSave( Kiface().KifaceSearch(),
fn.GetFullPath(), GROUP, GetProjectFileParametersList() );
fn.GetFullPath(), GROUP_SCH, GetProjectFileParametersList() );
}
}
......
......@@ -225,14 +225,14 @@ void LIB_EDIT_FRAME::SaveOneSymbol()
formatter.Print( 0, "ENDDRAW\n" );
formatter.Print( 0, "ENDDEF\n" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "An error occurred attempting to save symbol file '%s'" ),
GetChars( fn.GetFullPath() ) );
DisplayError( this, msg );
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return;
......
......@@ -59,6 +59,8 @@ struct BIN_MOD
wxString m_help_file;
SEARCH_STACK m_search;
};
#endif // BIN_MOD_H_
......@@ -589,4 +589,25 @@ wxString FormatDateLong( const wxDateTime &aDate );
*/
void SystemDirsAppend( SEARCH_STACK* aSearchStack );
/**
* Function SearchHelpFileFullPath
* returns the help file's full path.
* <p>
* Return the KiCad help file with path.
* If the help file for the current locale is not found, an attempt to find
* the English version of the help file is made.
* Help file is searched in directories in this order:
* help/\<canonical name\> like help/en_GB
* help/\<short name\> like help/en
* help/en
* </p>
* @param aSearchStack contains some possible base dirs that may be above the
* the one actually holding @a aBaseName. These are starting points for nested searches.
* @param aBaseName is the name of the help file to search for.
* @return wxEmptyString is returned if aBaseName is not found, else the full path & filename.
*/
wxString SearchHelpFileFullPath( const SEARCH_STACK& aSearchStack, const wxString& aBaseName );
#endif // INCLUDE__COMMON_H_
......@@ -37,6 +37,17 @@
#include <limits>
#define GROUP_PCB wxT( "/pcbnew" )
#define GROUP_SCH wxT( "/eeschema" )
#define GROUP_PCB_LIBS wxT( "/pcbnew/libraries" )
#define GROUP_SCH_LIBS wxT( "/eeschema/libraries" )
#define GROUP_COMMON wxT( "/common" )
#define GROUP_CVP wxT("/cvpcb")
//#define GROUP_CVP_LIBS wxT("/pcbnew/libraries")
#define GROUP_CVP_EQU wxT("/cvpcb/libraries")
#define CONFIG_VERSION 1
#define FORCE_LOCAL_CONFIG true
......
......@@ -38,6 +38,7 @@ class wxFileName;
class OUTPUTFORMATTER;
class MODULE;
class FP_LIB_TABLE_LEXER;
class FPID;
class NETLIST;
class REPORTER;
class SEARCH_STACK;
......@@ -455,6 +456,21 @@ public:
//-----</PLUGIN API SUBSET, REBASED ON aNickname>---------------------------
/**
* Function FootprintLoadWithOptionalNickname
* loads a footprint having @a aFootprintId with possibly an empty nickname.
*
* @param aFootprintId the [nickname] & fooprint name of the footprint to load.
*
* @return MODULE* - if found caller owns it, else NULL if not found.
*
* @throw IO_ERROR if the library cannot be found or read. No exception
* is thrown in the case where aFootprintName cannot be found.
* @throw PARSE_ERROR if @a aFootprintId is not parsed OK.
*/
MODULE* FootprintLoadWithOptionalNickname( const FPID& aFootprintId )
throw( IO_ERROR, PARSE_ERROR );
/**
* Function GetDescription
* returns the library desicription from @a aNickname, or an empty string
......@@ -499,19 +515,6 @@ public:
*/
bool IsEmpty( bool aIncludeFallback = true );
/**
* Function ConvertFromLegacy
* converts the footprint names in \a aNetList from the legacy format to the #FPID format.
*
* @param aNetList is the #NETLIST object to convert.
* @param aLibNames is the list of legacy footprint library names from the currently loaded
* project.
* @param aReporter is the #REPORTER object to dump messages into.
* @return true if all footprint names were successfully converted to a valid FPID.
*/
bool ConvertFromLegacy( SEARCH_STACK& aSStack, NETLIST& aNetList,
const wxArrayString& aLibNames, REPORTER* aReporter = NULL ) throw( IO_ERROR );
/**
* Function ExpandSubstitutions
* replaces any environment variable references with their values and is
......
......@@ -153,7 +153,6 @@ public:
*/
bool IsValid() const { return !nickname.empty() && !footprint.empty(); }
/**
* Function IsLegacy
* @return true if the #FPID only has the #footprint name defined.
......
......@@ -89,28 +89,6 @@ int ExecuteFile( wxWindow* frame, const wxString& ExecFile,
*/
void AddDelimiterString( wxString& string );
/**
* Function FindKicadHelpPath
* finds the absolute path for KiCad "help" (or "help/&ltlanguage&gt")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
* from BinDir
* else from environment variable KICAD
* else from one of s_HelpPathList
* typically c:/kicad/doc/help or /usr/share/kicad/help
* or /usr/local/share/kicad/help
* (must have kicad in path name)
*
* xx = iso639-1 language id (2 letters (generic) or 4 letters):
* fr = french (or fr_FR)
* en = English (or en_GB or en_US ...)
* de = deutch
* es = spanish
* pt = portuguese (or pt_BR ...)
*
* default = en (if not found = fr)
*/
wxString FindKicadHelpPath();
/**
* Function KicadDatasPath
* returns the data path common to KiCad.
......
......@@ -100,33 +100,17 @@ public:
wxConfigBase* KifaceSettings() const { return m_bm.m_config; }
const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
void SetHelpFileName( const wxString& aFileName ) { m_bm.m_help_file = aFileName; }
/**
* Function GetHelpFile
* gets the help file path.
* <p>
* Return the KiCad help file with path. The base paths defined in
* m_searchPaths are tested for a valid file. The path returned can
* be relative depending on the paths added to m_searchPaths. See the
* documentation for wxPathList for more information. If the help file
* for the current locale is not found, an attempt to find the English
* version of the help file is made.
* wxEmptyString is returned if help file not found.
* Help file is searched in directories in this order:
* help/\<canonical name\> like help/en_GB
* help/\<short name\> like help/en
* help/en
* </p>
* Function GetHelpFileName
* returns just the basename portion of the current help file.
*/
wxString GetHelpFile();
const wxString& GetHelpFileName() const { return m_bm.m_help_file; }
wxFileHistory& GetFileHistory() { return m_bm.m_history; }
wxFileHistory& GetFileHistory() { return m_bm.m_history; }
/// Only for DSO specific 'non-library' files.
/// (The library search path is in the PROJECT class.)
SEARCH_STACK& KifaceSearch() { return m_bm.m_search; }
SEARCH_STACK& KifaceSearch() { return m_bm.m_search; }
private:
KIWAY::FACE_T m_id;
......
......@@ -86,9 +86,7 @@ public:
//----<Cross Module API>-----------------------------------------------------
VTBL_ENTRY wxHtmlHelpController* GetHtmlHelpController() { return m_html_ctrl; }
VTBL_ENTRY void SetHtmlHelpController( wxHtmlHelpController* aController );
VTBL_ENTRY wxHtmlHelpController* HtmlHelpController();
VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings; }
......@@ -161,12 +159,6 @@ public:
VTBL_ENTRY void SetLanguagePath();
/**
* Function InitOnLineHelp
* initializes KiCad's online help.
*/
VTBL_ENTRY void InitOnLineHelp();
/**
* Function ReadPdfBrowserInfos
* reads the PDF browser choice from the common configuration.
......@@ -217,6 +209,8 @@ protected:
*/
bool initPgm();
void initHtmlHelpController();
/**
* Function loadCommonSettings
* loads the program (process) settings subset which are stored in .kicad_common
......
......@@ -131,15 +131,6 @@ public:
/// Accessor for Eeschema search stack.
VTBL_ENTRY SEARCH_STACK& SchSearchS() { return m_sch_search; }
/**
* Function PcbSearchS
* returns the obsolete footprint library search stack.
* Projects created before the FP_LIB_TABLE support will have footprint
* search paths in the *.pro files. Projects created after the FP_LIB_TABLE
* support will not. This stack is used for conversion from old to new only.
*/
VTBL_ENTRY SEARCH_STACK& PcbSearchS() { return m_pcb_search; }
VTBL_ENTRY wxString GetModuleLibraryNickname() { return m_module_library_nickname; }
VTBL_ENTRY void SetModuleLibraryNickname( const wxString& aNickName ) { m_module_library_nickname = aNickName; }
......
......@@ -78,7 +78,7 @@ typedef const PTREE CPTREE;
* PTREE doc;
* Scan( &doc, &lexer );
* }
* catch( IO_ERROR ioe )
* catch( const IO_ERROR& ioe )
* {
* fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
* }
......
......@@ -39,21 +39,6 @@ public:
return wxPathList::FindValidPath( aFileName );
}
/**
* Function FindValidPath
* KiCad saves user defined library files that are not in the standard
* library search path list with the full file path. Calling the library
* search path list with a user library file will fail. This helper method
* solves that problem.
* @param fileName
* @return a wxEmptyString if library file is not found.
*/
wxString FindValidPath( const wxFileName& aFileName ) const
{
// call wxPathList::FindValidPath( const wxString& );
return wxPathList::FindValidPath( aFileName.GetFullPath() );
}
/**
* Function AddPaths
* insert or append path(s)
......@@ -72,15 +57,6 @@ public:
* ";" on windows, or ":" | ";" on unix.
*/
void RemovePaths( const wxString& aPaths );
/**
* Function FindFileInSearchPaths
* looks in "this" for \a aFilename, but first modifies every search
* path by appending a list of path fragments from aSubdirs. That modification
* is not rentative.
*/
wxString FindFileInSearchPaths( const wxString& aFilename,
const wxArrayString* aSubdirs = NULL );
};
......
......@@ -186,6 +186,15 @@ protected:
*/
virtual wxConfigBase* config();
/**
* Function sys_search
* returns a SEARCH_STACK pertaining to entire program, and is overloaded in
* KICAD_MANAGER_FRAME
*/
virtual const SEARCH_STACK& sys_search();
virtual wxString help_name();
public:
EDA_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
......
......@@ -123,6 +123,11 @@ class KICAD_MANAGER_FRAME : public EDA_BASE_FRAME
protected:
wxConfigBase* config(); // override EDA_BASE_FRAME virtual
const SEARCH_STACK& sys_search(); // override EDA_BASE_FRAME virtual
wxString help_name(); // override EDA_BASE_FRAME virtual
public:
TREE_PROJECT_FRAME* m_LeftWin;
LAUNCHER_PANEL* m_Launcher;
......
......@@ -123,6 +123,18 @@ wxConfigBase* KICAD_MANAGER_FRAME::config()
}
const SEARCH_STACK& KICAD_MANAGER_FRAME::sys_search()
{
return Pgm().SysSearch();
}
wxString KICAD_MANAGER_FRAME::help_name()
{
return Pgm().GetHelpFileName();
}
void KICAD_MANAGER_FRAME::PrintMsg( const wxString& aText )
{
m_MessagesBox->AppendText( aText );
......@@ -157,15 +169,6 @@ void KICAD_MANAGER_FRAME::OnCloseWindow( wxCloseEvent& Event )
Event.SetCanVeto( true );
// Close the help frame
if( Pgm().GetHtmlHelpController() )
{
if( Pgm().GetHtmlHelpController()->GetFrame() ) // returns NULL if no help frame active
Pgm().GetHtmlHelpController()->GetFrame()->Close( true );
Pgm().SetHtmlHelpController( NULL );
}
m_LeftWin->Show( false );
Destroy();
......
......@@ -58,6 +58,8 @@ public:
SEARCH_STACK& SysSearch() { return m_bm.m_search; }
wxString GetHelpFileName() { return m_bm.m_help_file; }
protected:
// The PGM_* classes can have difficulties at termination if they
......
......@@ -94,10 +94,10 @@ static const wxChar* s_allowedExtensionsToList[] =
*/
/* File extension definitions. */
const wxString TextFileExtension( wxT( "txt" ) );
const wxChar TextFileExtension[] = wxT( "txt" );
/* File wildcard definitions. */
const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) );
const wxChar TextFileWildcard[] = wxT( "Text files (*.txt)|*.txt" );
/**
......@@ -177,7 +177,6 @@ void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
}
/**
* Called by the popup menu in the tree frame
* Creates a new subdirectory inside the current kicad project directory
......
......@@ -716,7 +716,7 @@ void DIR_LIB_SOURCE::Test( int argc, char** argv )
printf( "std::exception\n" );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
printf( "exception: %s\n", (const char*) ioe.errorText.ToUTF8() ) );
}
......
......@@ -118,7 +118,7 @@ int main( int argc, char** argv )
printf( "%*s^\n", ioe.byteIndex>=1 ? ioe.byteIndex-1 : 0, "" );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
printf( "%s\n", (const char*) ioe.errorText.ToUTF8() );
}
......
......@@ -98,7 +98,7 @@ public:
m_fileout = new FILE_OUTPUTFORMATTER( aFilename );
m_out = m_fileout;
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
}
......@@ -125,7 +125,7 @@ public:
m_writer = new STRING_FORMATTER();
m_out = m_writer;
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxMessageBox( ioe.errorText, _("Error writing page layout descr file" ) );
}
......
......@@ -66,13 +66,16 @@ bool PCB_CALCULATOR_FRAME::ReadDataFile()
{
datafile_parser.Parse( datafile );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
delete datafile;
ioe.errorText += '\n';
ioe.errorText += _("Data file error.");
wxMessageBox( ioe.errorText );
wxString msg = ioe.errorText;
msg += wxChar('\n');
msg += _("Data file error.");
wxMessageBox( msg );
return false;
}
......@@ -99,7 +102,7 @@ bool PCB_CALCULATOR_FRAME::WriteDataFile()
while( nestlevel-- )
formatter.Print( nestlevel, ")\n" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
return false;
}
......
......@@ -346,13 +346,10 @@ if( KICAD_SCRIPTING )
COMMAND ${SWIG_EXECUTABLE} ${SWIG_OPTS} -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_wrap.cxx scripting/pcbnew.i
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/fix_swig_imports.py ${CMAKE_CURRENT_BINARY_DIR}/pcbnew.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
)
endif()
###
# _pcbnew DLL/DSO file creation
###
if( BUILD_GITHUB_PLUGIN )
set( GITHUB_PLUGIN_LIBRARIES github_plugin )
......@@ -401,9 +398,14 @@ if( KICAD_SCRIPTING_MODULES )
if( MAKE_LINK_MAPS )
set_target_properties( _pcbnew PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.so.map" )
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.so.map"
)
endif()
if( ${OPENMP_FOUND} )
set_property( TARGET _pcbnew APPEND_STRING
PROPERTY LINK_FLAGS " ${OpenMP_CXX_FLAGS}" )
endif()
endif()
......@@ -422,14 +424,13 @@ if( DOXYGEN_FOUND )
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS Doxyfile_xml
COMMENT "building doxygen docs into directory doxygen-python/html"
)
)
# create .i files from XML doxygen parsing, docstrings.i will include all of them
add_custom_target( xml-to-docstrings
COMMAND ${CMAKE_COMMAND} -E remove_directory docstrings
COMMAND ${CMAKE_COMMAND} -E make_directory docstrings
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripting/build_tools/extract_docstrings.py pcbnew.py doxygen-xml/xml docstrings
COMMAND ${CMAKE_COMMAND} -E remove pcbnew.py # force removal so it will be recreated later with the new docstrings
COMMENT "building docstring files"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
......@@ -445,16 +446,14 @@ if( DOXYGEN_FOUND )
DEPENDS Doxyfile_python
DEPENDS xml-to-docstrings
DEPENDS pcbnew.py
COMMENT "building doxygen docs into directory doxygen-python/html"
)
)
endif()
else()
message( STATUS "WARNING: Doxygen not found - doxygen-docs (Source Docs) target not created" )
endif()
if( MINGW )
# PCBNEW_RESOURCES variable is set by the macro.
mingw_resource_compiler( pcbnew )
......@@ -485,9 +484,8 @@ add_custom_command(
from ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help.html"
)
set_source_files_properties( dialogs/dialog_freeroute_exchange.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
set_source_files_properties( dialogs/dialog_freeroute_exchange.cpp PROPERTIES
OBJECT_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dialogs/dialog_freeroute_exchange_help_html.h
)
......@@ -511,14 +509,14 @@ endif()
if( USE_KIWAY_DLLS )
#if( false )
# a very small program launcher for pcbnew_kiface
add_executable( pcbnew WIN32 MACOSX_BUNDLE
../common/single_top.cpp
../common/pgm_base.cpp
${PCBNEW_RESOURCES}
)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
set_source_files_properties( ../common/single_top.cpp pcbnew.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=PCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"kicad_pcb\";BUILD_KIWAY_DLL"
)
target_link_libraries( pcbnew
......@@ -539,9 +537,7 @@ if( USE_KIWAY_DLLS )
${PCBNEW_SRCS}
${PCBNEW_COMMON_SRCS}
${PCBNEW_SCRIPTING_SRCS}
# ${PCBNEW_RESOURCES}
)
set_target_properties( pcbnew_kiface PROPERTIES
# Decorate OUTPUT_NAME with PREFIX and SUFFIX, creating something like
# _pcbnew.so, _pcbnew.dll, or _pcbnew.kiface
......@@ -552,7 +548,7 @@ if( USE_KIWAY_DLLS )
if( ${OPENMP_FOUND} )
set_target_properties( pcbnew_kiface PROPERTIES
COMPILE_FLAGS ${OpenMP_CXX_FLAGS}
)
)
endif()
target_link_libraries( pcbnew_kiface
......@@ -583,7 +579,11 @@ if( USE_KIWAY_DLLS )
)
if( MAKE_LINK_MAPS )
set_target_properties( pcbnew_kiface PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_pcbnew.kiface.map" )
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=_pcbnew.kiface.map"
)
set_target_properties( pcbnew PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map"
)
endif()
# if building pcbnew, then also build pcbnew_kiface if out of date.
......@@ -605,18 +605,22 @@ if( USE_KIWAY_DLLS )
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.kiface "${CMAKE_BINARY_DIR}/pcbnew/pcbnew.app/Contents/MacOS/"
DEPENDS pcbnew_kiface
COMMENT "Copying kiface into pcbnew"
)
)
endif()
else() # milestone A) kills this off:
add_executable( pcbnew WIN32 MACOSX_BUNDLE
../common/single_top.cpp
pcbnew.cpp
${PCBNEW_SRCS}
${PCBNEW_COMMON_SRCS}
${PCBNEW_SCRIPTING_SRCS}
${PCBNEW_RESOURCES}
)
set_source_files_properties( ../common/single_top.cpp PROPERTIES
COMPILE_DEFINITIONS "TOP_FRAME=PCB_FRAME_TYPE;PGM_DATA_FILE_EXT=\"kicad_pcb\""
)
target_link_libraries( pcbnew
3d-viewer
pcbcommon
......@@ -651,28 +655,25 @@ else() # milestone A) kills this off:
)
endif()
if( MAKE_LINK_MAPS )
# generate a link map with cross reference
set_target_properties( pcbnew PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map"
)
endif()
install( TARGETS pcbnew
DESTINATION ${KICAD_BIN}
COMPONENT binary
)
endif()
add_dependencies( pcbnew lib-dependencies )
###
# Set properties for APPLE on pcbnew target
###
if( APPLE )
set_target_properties( pcbnew PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist )
endif()
if( MAKE_LINK_MAPS )
# generate a link map with cross reference
set_target_properties( pcbnew PROPERTIES
LINK_FLAGS "${TO_LINKER},-cref ${TO_LINKER},-Map=pcbnew.map" )
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist
)
endif()
......@@ -691,19 +692,19 @@ if( KICAD_SCRIPTING )
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pcbnew/pcbnew.py "${PYTHON_DEST}/wx-3.0-osx_cocoa/"
DEPENDS FixSwigImportsScripting
COMMENT "Copying pcbnew.py into PYTHON_DEST/wx-3.0-osx_cocoa/"
)
)
add_custom_target( pcbnew_copy_wxpython_scripting ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBWXPYTHON_ROOT}/wxPython/ ${CMAKE_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/Frameworks/wxPython/
DEPENDS FixSwigImportsScripting _pcbnew_py_copy
COMMENT "Copying wxPython into pcbnew.app Framework"
)
)
add_custom_target( pcbnew_copy_plugins ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/pcbnew/scripting/plugins ${PROJECT_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/PlugIns/scripting/plugins
DEPENDS pcbnew_copy_wxpython_scripting
COMMENT "Copying plugins into bundle"
)
)
# fix bundle after copying wxpython, fixing and copying
add_dependencies( osx_fix_bundles pcbnew_copy_wxpython_scripting )
......@@ -738,13 +739,13 @@ if( KICAD_SCRIPTING_MODULES )
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/pcbnew/_pcbnew.so "${PYTHON_DEST}"
DEPENDS _pcbnew FixSwigImportsModuleScripting
COMMENT "Copying _pcbnew.so into PYTHON_DEST"
)
)
add_custom_target( pcbnew_copy_wxpython_module ALL
COMMAND ${CMAKE_COMMAND} -E copy_directory ${LIBWXPYTHON_ROOT}/wxPython/ ${PROJECT_SOURCE_DIR}/pcbnew/pcbnew.app/Contents/Frameworks/wxPython/
DEPENDS FixSwigImportsModuleScripting _pcbnew_so_copy
COMMENT "Copying wxPython into pcbnew.app Frameworks"
)
)
if( KICAD_BUILD_DYNAMIC )
# Tell that we have to run osx_fix_bundles fix after building _pcbnew and migrating wxPython
......@@ -755,14 +756,15 @@ if( KICAD_SCRIPTING_MODULES )
endif()
# This one gets made only when testing.
add_executable( specctra_test EXCLUDE_FROM_ALL specctra_test.cpp specctra.cpp )
target_link_libraries( specctra_test common ${wxWidgets_LIBRARIES} )
if( false ) # haven't been used in years.
# This one gets made only when testing.
add_executable( specctra_test EXCLUDE_FROM_ALL specctra_test.cpp specctra.cpp )
target_link_libraries( specctra_test common ${wxWidgets_LIBRARIES} )
# This one gets made only when testing.
add_executable( layer_widget_test WIN32 EXCLUDE_FROM_ALL
layer_widget.cpp
)
target_link_libraries( layer_widget_test common ${wxWidgets_LIBRARIES} )
# This one gets made only when testing.
add_executable( layer_widget_test WIN32 EXCLUDE_FROM_ALL
layer_widget.cpp
)
target_link_libraries( layer_widget_test common ${wxWidgets_LIBRARIES} )
endif()
......@@ -36,7 +36,7 @@
// This will get mapped to "kicad_default" in the specctra_export.
const wxString NETCLASS::Default = wxT("Default");
const wxChar NETCLASS::Default[] = wxT( "Default" );
// Initial values for netclass initialization
int NETCLASS::DEFAULT_CLEARANCE = DMils2iu( 100 ); // track to track and track to pads clearance
......
......@@ -80,7 +80,7 @@ protected:
public:
static const wxString Default; ///< the name of the default NETCLASS
static const wxChar Default[]; ///< the name of the default NETCLASS
/**
* Constructor
......
......@@ -41,37 +41,20 @@
#include <ratsnest_data.h>
// Helper class used to clean tracks and vias
class TRACKS_CLEANER : CONNECTIONS
class TRACKS_CLEANER: CONNECTIONS
{
private:
BOARD* m_Brd;
bool m_deleteUnconnectedTracks;
bool m_mergeSegments;
bool m_cleanVias;
BOARD * m_Brd;
public:
TRACKS_CLEANER( BOARD* aPcb );
TRACKS_CLEANER( BOARD * aPcb );
/**
* the cleanup function.
* return true if some item was modified
*/
bool CleanupBoard();
void SetdeleteUnconnectedTracksOpt( bool aDelete )
{
m_deleteUnconnectedTracks = aDelete;
}
void SetMergeSegmentsOpt( bool aMerge )
{
m_mergeSegments = aMerge;
}
void SetCleanViasOpt( bool aClean )
{
m_cleanVias = aClean;
}
bool CleanupBoard(PCB_EDIT_FRAME *aFrame, bool aCleanVias,
bool aMergeSegments, bool aDeleteUnconnected);
private:
......@@ -89,7 +72,7 @@ private:
/**
* Merge colinear segments and remove null len segments
*/
bool clean_segments();
bool clean_segments();
/**
* helper function
......@@ -103,7 +86,8 @@ private:
* merge aTrackRef and aCandidate, when possible,
* i.e. when they are colinear, same width, and obviously same layer
*/
TRACK* mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* aCandidate, int aEndType );
TRACK* mergeCollinearSegmentIfPossible( TRACK* aTrackRef,
TRACK* aCandidate, int aEndType );
};
/* Install the cleanup dialog frame to know what should be cleaned
......@@ -117,19 +101,9 @@ void PCB_EDIT_FRAME::Clean_Pcb()
wxBusyCursor( dummy );
TRACKS_CLEANER cleaner( GetBoard() );
cleaner.SetdeleteUnconnectedTracksOpt( dlg.m_deleteUnconnectedSegm );
cleaner.SetMergeSegmentsOpt( dlg.m_mergeSegments );
cleaner.SetCleanViasOpt( dlg.m_cleanVias );
if( cleaner.CleanupBoard() )
{
// Clear undo and redo lists to avoid inconsistencies between lists
GetScreen()->ClearUndoRedoList();
SetCurItem( NULL );
Compile_Ratsnest( NULL, true );
OnModify();
}
cleaner.CleanupBoard( this, dlg.m_cleanVias, dlg.m_mergeSegments,
dlg.m_deleteUnconnectedSegm );
m_canvas->Refresh( true );
}
......@@ -142,30 +116,38 @@ void PCB_EDIT_FRAME::Clean_Pcb()
* Create segments when track ends are incorrectly connected:
* i.e. when a track end covers a pad or a via but is not exactly on the pad or the via center
*/
bool TRACKS_CLEANER::CleanupBoard()
bool TRACKS_CLEANER::CleanupBoard( PCB_EDIT_FRAME *aFrame,
bool aCleanVias,
bool aMergeSegments,
bool aDeleteUnconnected )
{
bool modified = false;
// delete redundant vias
if( m_cleanVias && clean_vias() )
modified = true;
modified |= (aCleanVias && clean_vias());
// Remove null segments and intermediate points on aligned segments
if( m_mergeSegments && clean_segments() )
modified = true;
modified |= (aMergeSegments && clean_segments());
// Delete dangling tracks
if( m_deleteUnconnectedTracks && deleteUnconnectedTracks() )
modified = true;
modified |= (aDeleteUnconnected && deleteUnconnectedTracks());
if( modified )
{
// Clear undo and redo lists to avoid inconsistencies between lists
// XXX This is very involved... maybe a member in PCB_EDIT_FRAME
// would be better?
aFrame->GetScreen()->ClearUndoRedoList();
aFrame->SetCurItem( NULL );
aFrame->Compile_Ratsnest( NULL, true );
aFrame->OnModify();
}
return modified;
}
TRACKS_CLEANER::TRACKS_CLEANER( BOARD* aPcb ) : CONNECTIONS( aPcb )
TRACKS_CLEANER::TRACKS_CLEANER( BOARD * aPcb ): CONNECTIONS( aPcb )
{
m_Brd = aPcb;
m_deleteUnconnectedTracks = false;
m_mergeSegments = false;
// Build connections info
BuildPadsList();
......@@ -177,22 +159,22 @@ void TRACKS_CLEANER::buildTrackConnectionInfo()
BuildTracksCandidatesList( m_Brd->m_Track, NULL);
// clear flags and variables used in cleanup
for( TRACK* track = m_Brd->m_Track; track; track = track->Next() )
for( TRACK * track = m_Brd->m_Track; track; track = track->Next() )
{
track->start = NULL;
track->end = NULL;
track->m_PadsConnected.clear();
track->SetState( START_ON_PAD | END_ON_PAD | BUSY, false );
track->SetState( START_ON_PAD|END_ON_PAD|BUSY, false );
}
// Build connections info tracks to pads
SearchTracksConnectedToPads();
for( TRACK* track = m_Brd->m_Track; track; track = track->Next() )
for( TRACK * track = m_Brd->m_Track; track; track = track->Next() )
{
// Mark track if connected to pads
for( unsigned jj = 0; jj < track->m_PadsConnected.size(); jj++ )
{
D_PAD* pad = track->m_PadsConnected[jj];
D_PAD * pad = track->m_PadsConnected[jj];
if( pad->HitTest( track->GetStart() ) )
{
......@@ -211,7 +193,6 @@ void TRACKS_CLEANER::buildTrackConnectionInfo()
bool TRACKS_CLEANER::clean_vias()
{
TRACK* next_track;
bool modified = false;
for( TRACK* track = m_Brd->m_Track; track; track = track->Next() )
......@@ -229,6 +210,7 @@ bool TRACKS_CLEANER::clean_vias()
// Search and delete others vias at same location
TRACK* alt_track = track->Next();
TRACK* next_track;
for( ; alt_track != NULL; alt_track = next_track )
{
next_track = alt_track->Next();
......@@ -249,6 +231,7 @@ bool TRACKS_CLEANER::clean_vias()
}
// Delete Via on pads at same location
TRACK* next_track;
for( TRACK* track = m_Brd->m_Track; track != NULL; track = next_track )
{
next_track = track->Next();
......@@ -260,9 +243,9 @@ bool TRACKS_CLEANER::clean_vias()
// if one pad through is found, the via can be removed
for( unsigned ii = 0; ii < track->m_PadsConnected.size(); ii++ )
{
D_PAD* pad = track->m_PadsConnected[ii];
D_PAD * pad = track->m_PadsConnected[ii];
if( ( pad->GetLayerMask() & ALL_CU_LAYERS ) == ALL_CU_LAYERS )
if( (pad->GetLayerMask() & ALL_CU_LAYERS) == ALL_CU_LAYERS )
{
// redundant: via delete it
m_Brd->GetRatsnest()->Remove( track );
......@@ -295,8 +278,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
{
item_erased = false;
TRACK* next_track;
for( TRACK* track = m_Brd->m_Track; track ; track = next_track )
for( TRACK * track = m_Brd->m_Track; track ; track = next_track )
{
next_track = track->Next();
......@@ -317,7 +299,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
LAYER_NUM top_layer, bottom_layer;
ZONE_CONTAINER* zone;
if( ( type_end & START_ON_PAD ) == 0 )
if( (type_end & START_ON_PAD ) == 0 )
{
TRACK* other = track->GetTrace( m_Brd->m_Track, NULL, FLG_START );
......@@ -339,7 +321,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
}
}
if( ( other == NULL ) && ( zone == NULL ) )
if( (other == NULL) && (zone == NULL) )
{
flag_erase |= 1;
}
......@@ -427,7 +409,7 @@ bool TRACKS_CLEANER::deleteUnconnectedTracks()
via->GetNetCode() );
}
if( ( other == NULL ) && ( zone == NULL ) )
if( (other == NULL) && (zone == NULL) )
flag_erase |= 0x20;
track->SetState( BUSY, false );
......@@ -459,8 +441,6 @@ bool TRACKS_CLEANER::clean_segments()
bool modified = false;
TRACK* segment, * nextsegment;
TRACK* other;
int flag, no_inc;
// Delete null segments
for( segment = m_Brd->m_Track; segment; segment = nextsegment )
......@@ -472,6 +452,7 @@ bool TRACKS_CLEANER::clean_segments()
m_Brd->GetRatsnest()->Remove( segment );
segment->ViewRelease();
segment->DeleteStructure();
modified = true;
}
}
......@@ -524,7 +505,8 @@ bool TRACKS_CLEANER::clean_segments()
if( segment->Type() != PCB_TRACE_T )
continue;
flag = no_inc = 0;
unsigned flag = 0;
bool no_inc = false;
// search for a possible point connected to the START point of the current segment
for( segStart = segment->Next(); ; )
......@@ -603,7 +585,7 @@ bool TRACKS_CLEANER::clean_segments()
if( segDelete )
{
no_inc = 1;
no_inc = true;
m_Brd->GetRatsnest()->Remove( segDelete );
segDelete->ViewRelease();
segDelete->DeleteStructure();
......
......@@ -91,7 +91,7 @@ void PCB_EDIT_FRAME::InstallNetlistFrame( wxDC* DC )
// was: wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters() );
Prj().ConfigSave( Kiface().KifaceSearch(), fn.GetFullPath(),
GROUP, GetProjectFileParameters() );
GROUP_PCB, GetProjectFileParameters() );
}
}
......@@ -426,7 +426,7 @@ bool DIALOG_NETLIST::verifyFootprints( const wxString& aNetlistFilename,
std::auto_ptr< NETLIST_READER > nlr( netlistReader );
netlistReader->LoadNetlist();
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Error loading netlist file:\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
......
......@@ -403,7 +403,7 @@ bool Export_IDF3( BOARD* aPcb, const wxString& aFullFileName, double aUseThou )
idfBoard.Finish();
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping export to IDFv3.\n\nError: %s" ),
GetChars( ioe.errorText ) );
......
......@@ -713,7 +713,7 @@ bool PCB_EDIT_FRAME::DoGenFootprintsReport( const wxString& aFullFilename, bool
fprintf( rptfile, "$EndMODULE %s\n\n", TO_UTF8 (Module->GetReference() ) );
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( NULL, ioe.errorText );
}
......
......@@ -404,7 +404,7 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SetBoard( loadedBoard );
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _( "Error loading board.\n%s" ),
ioe.errorText.GetData() );
......@@ -692,7 +692,7 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool aCreateBackupF
pi->Save( pcbFileName.GetFullPath(), GetBoard(), NULL );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _( "Error saving board.\n%s" ),
ioe.errorText.GetData() );
......
......@@ -570,7 +570,7 @@ int main( int argc, char** argv )
printf("[%d]:%s\n", i, TO_UTF8( fps[i] ) );
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
printf( "%s\n", TO_UTF8(ioe.errorText) );
}
......
......@@ -204,7 +204,7 @@ public:
* or
* IO_MGR::Save(...);
* }
* catch( IO_ERROR ioe )
* catch( const IO_ERROR& ioe )
* {
* // grab text from ioe, show in error window.
* }
......
This diff is collapsed.
This diff is collapsed.
......@@ -199,7 +199,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
return NULL;
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
......@@ -222,7 +222,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
return NULL;
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
......@@ -259,7 +259,7 @@ MODULE* FOOTPRINT_EDIT_FRAME::Import_Module()
return NULL;
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return NULL;
......@@ -334,7 +334,7 @@ void FOOTPRINT_EDIT_FRAME::Export_Module( MODULE* aModule )
fprintf( fp, "%s", pcb_io.GetStringOutput( false ).c_str() );
fclose( fp );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return;
......@@ -357,7 +357,7 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
pi->FootprintSave( libPath, GetBoard()->m_Modules );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return false;
......@@ -429,7 +429,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
writable = pi->IsFootprintLibWritable( libPath );
exists = true; // no exception was thrown, lib must exist.
}
catch( IO_ERROR )
catch( const IO_ERROR& )
{
// ignore, original values of 'writable' and 'exists' are accurate.
}
......@@ -455,7 +455,7 @@ wxString FOOTPRINT_EDIT_FRAME::CreateNewLibrary()
pi->FootprintLibCreate( libPath );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return wxEmptyString;
......@@ -499,7 +499,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
{
FootprintLibs()->FootprintDelete( nickname, fpname );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return false;
......@@ -568,7 +568,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aNewModulesOnly )
}
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
}
......@@ -655,7 +655,7 @@ bool PCB_BASE_FRAME::Save_Module_In_Library( const wxString& aLibrary,
// own if the library or footprint is not writable.
FootprintLibs()->FootprintSave( aLibrary, aModule );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return false;
......
......@@ -220,7 +220,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
{
module = loadFootprint( fpid );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
fpid.Format().c_str(), GetChars( ioe.errorText ) );
......@@ -252,7 +252,7 @@ MODULE* PCB_BASE_FRAME::LoadModuleFromLibrary( const wxString& aLibrary,
{
module = loadFootprint( fpid );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
fpid.Format().c_str(), GetChars( ioe.errorText ) );
......@@ -304,7 +304,7 @@ MODULE* PCB_BASE_FRAME::LoadFootprint( const FPID& aFootprintId )
{
module = loadFootprint( aFootprintId );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
wxLogDebug( wxT( "An error occurred attemping to load footprint '%s'.\n\nError: %s" ),
aFootprintId.Format().c_str(), GetChars( ioe.errorText ) );
......@@ -321,31 +321,7 @@ MODULE* PCB_BASE_FRAME::loadFootprint( const FPID& aFootprintId )
wxCHECK_MSG( fptbl, NULL, wxT( "Cannot look up FPID in NULL FP_LIB_TABLE." ) );
wxString nickname = aFootprintId.GetLibNickname();
wxString fpname = aFootprintId.GetFootprintName();
if( nickname.size() )
{
return fptbl->FootprintLoad( nickname, fpname );
}
// user did not enter a nickname, just a footprint name, help him out a little:
else
{
std::vector<wxString> nicks = fptbl->GetLogicalLibs();
// Search each library going through libraries alphabetically.
for( unsigned i = 0; i<nicks.size(); ++i )
{
// FootprintLoad() returns NULL on not found, does not throw exception
// unless there's an IO_ERROR.
MODULE* ret = fptbl->FootprintLoad( nicks[i], fpname );
if( ret )
return ret;
}
return NULL;
}
return fptbl->FootprintLoadWithOptionalNickname( aFootprintId );
}
......@@ -557,7 +533,7 @@ void FOOTPRINT_EDIT_FRAME::OnSaveLibraryAs( wxCommandEvent& aEvent )
// m is deleted here by auto_ptr.
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
DisplayError( this, ioe.errorText );
return;
......
......@@ -279,7 +279,7 @@ wxString FOOTPRINT_EDIT_FRAME::getLibPath()
return row->GetFullURI( true );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
return wxEmptyString;
}
......@@ -639,7 +639,7 @@ void FOOTPRINT_EDIT_FRAME::updateTitle()
if( !writable )
title += _( " [Read Only]" );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
// user may be bewildered as to why after selecting a library it is not showing up
// in the title, we could show an error message, but that should have been done at time
......
......@@ -85,7 +85,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
netlistReader->LoadNetlist();
loadFootprints( netlist, aReporter );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
msg.Printf( _( "Error loading netlist.\n%s" ), ioe.errorText.GetData() );
wxMessageBox( msg, _( "Netlist Load Error" ), wxOK | wxICON_ERROR );
......
......@@ -208,13 +208,13 @@ MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BA
return &kiface;
}
#if defined(BUILD_KIWAY_DLL)
PGM_BASE& Pgm()
{
wxASSERT( process ); // KIFACE_GETTER has already been called.
return *process;
}
#endif
/**
* Function set3DShapesPath
......@@ -484,6 +484,5 @@ void IFACE::OnKifaceEnd()
// This should only be called if python was setup correctly.
pcbnewFinishPythonScripting();
#endif
}
......@@ -29,7 +29,6 @@
*/
#include <fctsys.h>
//#include <pgm_base.h>
#include <kiface_i.h>
#include <project.h>
#include <class_drawpanel.h>
......@@ -239,7 +238,7 @@ bool PCB_EDIT_FRAME::LoadProjectSettings( const wxString& aProjectFileName )
fn.SetExt( ProjectFileExtension );
// was: wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
Prj().ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP, GetProjectFileParameters(), false );
Prj().ConfigLoad( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_PCB, GetProjectFileParameters(), false );
// Dick 5-Feb-2012: I don't agree with this, the BOARD contents should dictate
// what is visible or not, even initially. And since PCB_EDIT_FRAME projects settings
......@@ -302,9 +301,7 @@ void PCB_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
fn = dlg.GetPath();
}
SEARCH_STACK& search = Kiface().KifaceSearch();
Prj().ConfigSave( search, fn.GetFullPath(), GROUP, GetProjectFileParameters() );
Prj().ConfigSave( Kiface().KifaceSearch(), fn.GetFullPath(), GROUP_PCB, GetProjectFileParameters() );
}
......@@ -315,7 +312,7 @@ PARAM_CFG_ARRAY PCB_EDIT_FRAME::GetProjectFileParameters()
pca.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ), &g_UserLibDirBuffer, GROUPLIB ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ), &g_UserLibDirBuffer, GROUP_PCB_LIBS ) );
pca.push_back( new PARAM_CFG_FILENAME( wxT( "LastNetListRead" ), &m_lastNetListRead ) );
......
/**
* @file pcbnew_config.h
* @brief Cconfiguration parameters for Pcbnew.
* @brief Configuration parameters for Pcbnew.
*/
#ifndef _PCBNEW_CONFIG_H_
......@@ -9,10 +9,6 @@
#include <config_params.h>
#include <colors_selection.h>
#define GROUP wxT( "/pcbnew" )
#define GROUPLIB wxT( "/pcbnew/libraries" )
#define GROUPCOMMON wxT( "/common" )
/* Useful macro : */
#define LOC_COLOR(layer) &g_ColorsSettings.m_LayersColors[layer]
#define ITEM_COLOR(item_visible) &g_ColorsSettings.m_ItemsColors[item_visible]
......
......@@ -162,7 +162,7 @@ bool PCB_EDIT_FRAME::ExportSpecctraFile( const wxString& aFullFilename )
// if an exception is thrown by FromBOARD or ExportPCB(), then
// ~SPECCTRA_DB() will close the file.
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
ok = false;
......@@ -1322,7 +1322,7 @@ bool SPECCTRA_DB::GetBoardPolygonOutlines( BOARD* aBoard,
aHoles.CloseLastContour();
}
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
// Creates a valid polygon outline is not possible.
// So uses the board edge cuts bounding box to create a
......
......@@ -102,14 +102,15 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
db.LoadSESSION( fullFileName );
db.FromSESSION( GetBoard() );
}
catch( IO_ERROR& ioe )
catch( const IO_ERROR& ioe )
{
ioe.errorText += '\n';
ioe.errorText += _("BOARD may be corrupted, do not save it.");
ioe.errorText += '\n';
ioe.errorText += _("Fix problem and try again.");
wxString msg = ioe.errorText;
msg += '\n';
msg += _("BOARD may be corrupted, do not save it.");
msg += '\n';
msg += _("Fix problem and try again.");
DisplayError( this, ioe.errorText );
DisplayError( this, msg );
return;
}
......
......@@ -63,7 +63,7 @@ int main( int argc, char** argv )
// db.LoadPCB( filename );
db.LoadSESSION( filename );
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
fprintf( stderr, "%s\n", TO_UTF8(ioe.errorText) );
failed = true;
......
......@@ -125,7 +125,10 @@ install_prerequisites()
fi
# ensure bzr name and email are set. No message since bzr prints an excellent diagnostic.
bzr whoami || exit 2
bzr whoami || {
echo "WARNING: You have not set bzr whoami, so I will set a dummy."
export BZR_EMAIL="Kicad Build <nobody@foo>"
}
}
......@@ -270,10 +273,12 @@ install_or_update()
echo " kicad-lib.bzr installed."
echo "step 9) as non-root, install user configuration files..."
echo "step 9) as non-root, install global fp-lib-table if none already installed..."
# install ~/fp-lib-table
make install_github_fp-lib-table
echo " kicad user-configuration files installed."
if [ ! -e ~/fp-lib-table ]; then
make install_github_fp-lib-table
echo " global fp-lib-table installed."
fi
echo "step 10) installing documentation..."
......
......@@ -83,7 +83,7 @@ int main( int argc, char** argv )
#endif
}
catch( IO_ERROR ioe )
catch( const IO_ERROR& ioe )
{
fprintf( stderr, "%s\n", TO_UTF8( ioe.errorText ) );
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment