diff --git a/common/edaappl.cpp b/common/edaappl.cpp index bfd76267fe..66f3eade07 100644 --- a/common/edaappl.cpp +++ b/common/edaappl.cpp @@ -65,8 +65,8 @@ static const wxChar* CommonConfigPath = wxT( "kicad_common" ); * the size of the array. */ #define LANGUAGE_DESCR_COUNT ( sizeof( s_Language_List ) / sizeof( struct LANGUAGE_DESCR ) ) -/* Default font size */ -#define FONT_DEFAULT_SIZE 10 /* Default font size. */ +// Default font size +#define FONT_DEFAULT_SIZE 10 // Default font size. static wxString languageCfgKey( wxT( "LanguageID" ) ); @@ -108,7 +108,7 @@ struct LANGUAGE_DESCR */ static struct LANGUAGE_DESCR s_Language_List[] = { - /* Default language */ + // Default language { wxLANGUAGE_DEFAULT, ID_LANGUAGE_DEFAULT, @@ -116,7 +116,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Default" ) }, - /* English language */ + // English language { wxLANGUAGE_ENGLISH, ID_LANGUAGE_ENGLISH, @@ -125,7 +125,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = true }, - /* French language */ + // French language { wxLANGUAGE_FRENCH, ID_LANGUAGE_FRENCH, @@ -133,7 +133,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "French" ) }, - /* Finnish language */ + // Finnish language { wxLANGUAGE_FINNISH, ID_LANGUAGE_FINNISH, @@ -141,7 +141,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Finnish" ) }, - /* Spanish language */ + // Spanish language { wxLANGUAGE_SPANISH, ID_LANGUAGE_SPANISH, @@ -149,7 +149,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Spanish" ) }, - /* Portuguese language */ + // Portuguese language { wxLANGUAGE_PORTUGUESE, ID_LANGUAGE_PORTUGUESE, @@ -157,7 +157,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Portuguese" ) }, - /* Italian language */ + // Italian language { wxLANGUAGE_ITALIAN, ID_LANGUAGE_ITALIAN, @@ -165,7 +165,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Italian" ) }, - /* German language */ + // German language { wxLANGUAGE_GERMAN, ID_LANGUAGE_GERMAN, @@ -173,7 +173,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "German" ) }, - /* Greek language */ + // Greek language { wxLANGUAGE_GREEK, ID_LANGUAGE_GREEK, @@ -181,7 +181,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Greek" ) }, - /* Slovenian language */ + // Slovenian language { wxLANGUAGE_SLOVENIAN, ID_LANGUAGE_SLOVENIAN, @@ -189,7 +189,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Slovenian" ) }, - /* Hungarian language */ + // Hungarian language { wxLANGUAGE_HUNGARIAN, ID_LANGUAGE_HUNGARIAN, @@ -197,7 +197,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Hungarian" ) }, - /* Polish language */ + // Polish language { wxLANGUAGE_POLISH, ID_LANGUAGE_POLISH, @@ -205,7 +205,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Polish" ) }, - /* Czech language */ + // Czech language { wxLANGUAGE_CZECH, ID_LANGUAGE_CZECH, @@ -213,7 +213,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Czech" ) }, - /* Russian language */ + // Russian language { wxLANGUAGE_RUSSIAN, ID_LANGUAGE_RUSSIAN, @@ -221,7 +221,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Russian" ) }, - /* Korean language */ + // Korean language { wxLANGUAGE_KOREAN, ID_LANGUAGE_KOREAN, @@ -229,7 +229,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Korean" ) }, - /* Chinese simplified */ + // Chinese simplified { wxLANGUAGE_CHINESE_SIMPLIFIED, ID_LANGUAGE_CHINESE_SIMPLIFIED, @@ -237,7 +237,7 @@ static struct LANGUAGE_DESCR s_Language_List[] = _( "Chinese simplified" ) }, - /* Catalan language */ + // Catalan language { wxLANGUAGE_CATALAN, ID_LANGUAGE_CATALAN, @@ -286,7 +286,7 @@ EDA_APP::~EDA_APP() { SaveSettings(); - /* delete user datas */ + // delete user datas if( m_projectSettings ) delete m_projectSettings; @@ -309,10 +309,9 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) m_Id = aId; m_Checker = new wxSingleInstanceChecker( aName.Lower() + wxT( "-" ) + wxGetUserId() ); - /* Init KiCad environment - * the environment variable KICAD (if exists) gives the kicad path: - * something like set KICAD=d:\kicad - */ + // Init KiCad environment + // the environment variable KICAD (if exists) gives the kicad path: + // something like set KICAD=d:\kicad bool isDefined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv ); if( isDefined ) // ensure m_KicadEnv ends by "/" @@ -323,8 +322,8 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) m_KicadEnv += UNIX_STRING_DIR_SEP; } -/* Prepare On Line Help. Use only lower case for help file names, in order to - * avoid problems with upper/lower case file names under windows and unix */ + // Prepare On Line Help. Use only lower case for help file names, in order to + // avoid problems with upper/lower case file names under windows and unix. #if defined ONLINE_HELP_FILES_FORMAT_IS_HTML m_HelpFileName = aName.Lower() + wxT( ".html" ); #elif defined ONLINE_HELP_FILES_FORMAT_IS_PDF @@ -333,7 +332,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) #error Help files format not defined #endif - /* Init parameters for configuration */ + // Init parameters for configuration SetVendorName( wxT( "KiCad" ) ); SetAppName( aName.Lower() ); SetTitle( aName ); @@ -342,7 +341,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) m_commonSettings = new wxConfig( CommonConfigPath ); wxASSERT( m_commonSettings != NULL ); - /* Install some image handlers, mainly for help */ + // Install some image handlers, mainly for help wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxGIFHandler ); wxImage::AddHandler( new wxJPEGHandler ); @@ -375,7 +374,7 @@ void EDA_APP::InitEDA_Appl( const wxString& aName, EDA_APP_T aId ) { } - /* Set locale option for separator used in float numbers */ + // Set locale option for separator used in float numbers SetLocaleTo_Default(); } @@ -418,10 +417,10 @@ void EDA_APP::InitOnLineHelp() bool EDA_APP::SetBinDir() { -/* Apple MacOSx */ +// Apple MacOSx #ifdef __APPLE__ - /* Derive path from location of the app bundle */ + // Derive path from location of the app bundle CFBundleRef mainBundle = CFBundleGetMainBundle(); if( mainBundle == NULL ) @@ -446,12 +445,12 @@ bool EDA_APP::SetBinDir() m_BinDir = FROM_UTF8( native_str ); delete[] native_str; -/* Linux and Unix */ + // Linux and Unix #elif defined(__UNIX__) m_BinDir = wxStandardPaths().GetExecutablePath(); #else m_BinDir = argv[0]; -#endif /* __UNIX__ */ +#endif // __UNIX__ /* Use unix notation for paths. I am not sure this is a good idea, * but it simplify compatibility between Windows and Unices @@ -493,16 +492,16 @@ void EDA_APP::SetDefaultSearchPaths( void ) if( ::wxGetEnv( wxT( "KICAD" ), NULL ) ) m_searchPaths.AddEnvList( wxT( "KICAD" ) ); - /* Add the user's home path. */ + // Add the user's home path. m_searchPaths.Add( GetTraits()->GetStandardPaths().GetUserDataDir() ); - /* Standard application data path if it is different from the binary path. */ + // Standard application data path if it is different from the binary path. if( fn.GetPath() != GetTraits()->GetStandardPaths().GetDataDir() ) { m_searchPaths.Add( GetTraits()->GetStandardPaths().GetDataDir() ); } - /* Up one level relative to binary path with "share" appended for Windows. */ + // Up one level relative to binary path with "share" appended for Windows. fn.RemoveLastDir(); m_searchPaths.Add( fn.GetPath() ); fn.AppendDir( wxT( "share" ) ); @@ -511,10 +510,11 @@ void EDA_APP::SetDefaultSearchPaths( void ) m_searchPaths.Add( fn.GetPath() ); /* The normal OS program file install paths allow for binary to be - * installed in a different path from the library files. This is - * useful for development purposes so the library and documentation - * files do not need to be installed separately. If someone can - * figure out a way to implement this without #ifdef, please do. */ + * installed in a different path from the library files. This is + * useful for development purposes so the library and documentation + * files do not need to be installed separately. If someone can + * figure out a way to implement this without #ifdef, please do. + */ #ifdef __WXMSW__ tmp.AddEnvList( wxT( "PROGRAMFILES" ) ); #elif __WXMAC__ @@ -545,7 +545,7 @@ void EDA_APP::SetDefaultSearchPaths( void ) m_searchPaths.Add( fn.GetPath() ); } - /* Remove all non-existent paths from the list. */ + // Remove all non-existent paths from the list. for( i = 0; i < m_searchPaths.GetCount(); i++ ) { if( !wxFileName::IsDirReadable( m_searchPaths[i] ) ) @@ -570,7 +570,7 @@ void EDA_APP::SetDefaultSearchPaths( void ) m_libSearchPaths.Add( fn.GetPath() ); } - /* Add schematic doc file path (library/doc)to search path list. */ + // Add schematic doc file path (library/doc)to search path list. fn.AppendDir( wxT( "doc" ) ); if( fn.IsDirReadable() ) @@ -582,7 +582,7 @@ void EDA_APP::SetDefaultSearchPaths( void ) fn.RemoveLastDir(); // point to } - /* Add PCB library file path to search path list. */ + // Add PCB library file path to search path list. if( ( m_Id == APP_PCBNEW_T ) || ( m_Id == APP_CVPCB_T ) ) { fn.AppendDir( wxT( "modules" ) ); @@ -592,7 +592,7 @@ void EDA_APP::SetDefaultSearchPaths( void ) m_libSearchPaths.Add( fn.GetPath() ); } - /* Add 3D module library file path to search path list. */ + // Add 3D module library file path to search path list. fn.AppendDir( wxT( "packages3d" ) ); if( fn.IsDirReadable() ) @@ -604,7 +604,7 @@ void EDA_APP::SetDefaultSearchPaths( void ) fn.RemoveLastDir(); // point to } - /* Add KiCad template file path to search path list. */ + // Add KiCad template file path to search path list. fn.AppendDir( wxT( "template" ) ); if( fn.IsDirReadable() ) @@ -656,6 +656,7 @@ void EDA_APP::GetSettings( bool aReopenLastUsedDirectory ) } int draw_bg_color; + // FIXME OSX Mountain Lion (10.8) // Seems that Read doesn't found anything and ColorFromInt Asserts - I'm unable to reproduce on 10.7 // In general terms i think is better have a failsafe BLACK default than an uninit variable @@ -688,7 +689,7 @@ void EDA_APP::SaveSettings() m_settings->Write( wxT( "WorkingDir" ), wxGetCwd() ); m_settings->Write( wxT( "BgColor" ), (long) g_DrawBgColor ); - /* Save the file history list */ + // Save the file history list m_fileHistory.Save( *m_settings ); } @@ -771,7 +772,7 @@ bool EDA_APP::SetLanguage( bool first_time ) void EDA_APP::SetLanguageIdentifier( int menu_id ) { - wxLogDebug( wxT( "Select language ID %d from %d possible languages." ), + wxLogDebug( wxT( "Select language ID %d from %zd possible languages." ), menu_id, LANGUAGE_DESCR_COUNT ); for( unsigned int ii = 0; ii < LANGUAGE_DESCR_COUNT; ii++ ) @@ -789,7 +790,7 @@ void EDA_APP::SetLanguagePath( void ) { size_t i; - /* Add defined search paths to locale paths */ + // Add defined search paths to locale paths if( !m_searchPaths.IsEmpty() ) { for( i = 0; i < m_searchPaths.GetCount(); i++ ) diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 9ca6d13c59..9333495683 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -376,38 +376,38 @@ wxString BOARD::GetLayerName( int aLayerIndex, bool aTranslate ) const // Default layer names are statically initialized, -// because we want the English name and the translation +// because we want the English name and the translation. // The English name is stored here, and to get the translation -// wxGetTranslation must be called explicitly -static const wxChar * layer_FRONT_name = _( "Front" ); -static const wxChar * layer_INNER1_name = _( "Inner1" ); -static const wxChar * layer_INNER2_name = _( "Inner2" ); -static const wxChar * layer_INNER3_name = _( "Inner3" ); -static const wxChar * layer_INNER4_name = _( "Inner4" ); -static const wxChar * layer_INNER5_name = _( "Inner5" ); -static const wxChar * layer_INNER6_name = _( "Inner6" ); -static const wxChar * layer_INNER7_name = _( "Inner7" ); -static const wxChar * layer_INNER8_name = _( "Inner8" ); -static const wxChar * layer_INNER9_name = _( "Inner9" ); -static const wxChar * layer_INNER10_name = _( "Inner10" ); -static const wxChar * layer_INNER11_name = _( "Inner11" ); -static const wxChar * layer_INNER12_name = _( "Inner12" ); -static const wxChar * layer_INNER13_name = _( "Inner13" ); -static const wxChar * layer_INNER14_name = _( "Inner14" ); -static const wxChar * layer_BACK_name = _( "Back" ); -static const wxChar * layer_ADHESIVE_BACK_name = _( "Adhes_Back" ); -static const wxChar * layer_ADHESIVE_FRONT_name = _( "Adhes_Front" ); -static const wxChar * layer_SOLDERPASTE_BACK_namet = _( "SoldP_Back" ); -static const wxChar * layer_SOLDERPASTE_FRONT_name = _( "SoldP_Front" ); -static const wxChar * layer_SILKSCREEN_BACK_name = _( "SilkS_Back" ); -static const wxChar * layer_SILKSCREEN_FRONT_name = _( "SilkS_Front" ); -static const wxChar * layer_SOLDERMASK_BACK_name = _( "Mask_Back" ); -static const wxChar * layer_SOLDERMASK_FRONT_name = _( "Mask_Front" ); -static const wxChar * layer_DRAW_name = _( "Drawings" ); -static const wxChar * layer_COMMENT_name = _( "Comments" ); -static const wxChar * layer_ECO1_name = _( "Eco1" ); -static const wxChar * layer_ECO2_name = _( "Eco2" ); -static const wxChar * layer_EDGE_name = _( "PCB_Edges" ); +// wxGetTranslation must be called explicitly. +static const wxChar* layer_FRONT_name = _( "Front" ); +static const wxChar* layer_INNER1_name = _( "Inner1" ); +static const wxChar* layer_INNER2_name = _( "Inner2" ); +static const wxChar* layer_INNER3_name = _( "Inner3" ); +static const wxChar* layer_INNER4_name = _( "Inner4" ); +static const wxChar* layer_INNER5_name = _( "Inner5" ); +static const wxChar* layer_INNER6_name = _( "Inner6" ); +static const wxChar* layer_INNER7_name = _( "Inner7" ); +static const wxChar* layer_INNER8_name = _( "Inner8" ); +static const wxChar* layer_INNER9_name = _( "Inner9" ); +static const wxChar* layer_INNER10_name = _( "Inner10" ); +static const wxChar* layer_INNER11_name = _( "Inner11" ); +static const wxChar* layer_INNER12_name = _( "Inner12" ); +static const wxChar* layer_INNER13_name = _( "Inner13" ); +static const wxChar* layer_INNER14_name = _( "Inner14" ); +static const wxChar* layer_BACK_name = _( "Back" ); +static const wxChar* layer_ADHESIVE_BACK_name = _( "Adhes_Back" ); +static const wxChar* layer_ADHESIVE_FRONT_name = _( "Adhes_Front" ); +static const wxChar* layer_SOLDERPASTE_BACK_name = _( "SoldP_Back" ); +static const wxChar* layer_SOLDERPASTE_FRONT_name = _( "SoldP_Front" ); +static const wxChar* layer_SILKSCREEN_BACK_name = _( "SilkS_Back" ); +static const wxChar* layer_SILKSCREEN_FRONT_name = _( "SilkS_Front" ); +static const wxChar* layer_SOLDERMASK_BACK_name = _( "Mask_Back" ); +static const wxChar* layer_SOLDERMASK_FRONT_name = _( "Mask_Front" ); +static const wxChar* layer_DRAW_name = _( "Drawings" ); +static const wxChar* layer_COMMENT_name = _( "Comments" ); +static const wxChar* layer_ECO1_name = _( "Eco1" ); +static const wxChar* layer_ECO2_name = _( "Eco2" ); +static const wxChar* layer_EDGE_name = _( "PCB_Edges" ); wxString BOARD::GetDefaultLayerName( int aLayerNumber, bool aTranslate ) { @@ -428,40 +428,42 @@ wxString BOARD::GetDefaultLayerName( int aLayerNumber, bool aTranslate ) case LAYER_N_7: txt = layer_INNER6_name; break; case LAYER_N_8: txt = layer_INNER7_name; break; case LAYER_N_9: txt = layer_INNER8_name; break; - case LAYER_N_10: txt = layer_INNER9_name; break; + case LAYER_N_10: txt = layer_INNER9_name; break; case LAYER_N_11: txt = layer_INNER10_name; break; case LAYER_N_12: txt = layer_INNER11_name; break; case LAYER_N_13: txt = layer_INNER12_name; break; case LAYER_N_14: txt = layer_INNER13_name; break; case LAYER_N_15: txt = layer_INNER14_name; break; case LAYER_N_BACK: txt = layer_BACK_name; break; - case ADHESIVE_N_BACK: txt =layer_ADHESIVE_BACK_name; break; - case ADHESIVE_N_FRONT: txt = layer_ADHESIVE_FRONT_name; break; - case SOLDERPASTE_N_BACK: txt = layer_SOLDERPASTE_BACK_namet; break; - case SOLDERPASTE_N_FRONT: txt = layer_SOLDERPASTE_FRONT_name; break; - case SILKSCREEN_N_BACK: txt = layer_SILKSCREEN_BACK_name; break; - case SILKSCREEN_N_FRONT: txt = layer_SILKSCREEN_FRONT_name; break; - case SOLDERMASK_N_BACK: txt = layer_SOLDERMASK_BACK_name; break; - case SOLDERMASK_N_FRONT: txt = layer_SOLDERMASK_FRONT_name; break; - case DRAW_N: txt = layer_DRAW_name; break; - case COMMENT_N: txt = layer_COMMENT_name; break; + case ADHESIVE_N_BACK: txt = layer_ADHESIVE_BACK_name; break; + case ADHESIVE_N_FRONT: txt = layer_ADHESIVE_FRONT_name; break; + case SOLDERPASTE_N_BACK: txt = layer_SOLDERPASTE_BACK_name; break; + case SOLDERPASTE_N_FRONT: txt = layer_SOLDERPASTE_FRONT_name; break; + case SILKSCREEN_N_BACK: txt = layer_SILKSCREEN_BACK_name; break; + case SILKSCREEN_N_FRONT: txt = layer_SILKSCREEN_FRONT_name; break; + case SOLDERMASK_N_BACK: txt = layer_SOLDERMASK_BACK_name; break; + case SOLDERMASK_N_FRONT: txt = layer_SOLDERMASK_FRONT_name; break; + case DRAW_N: txt = layer_DRAW_name; break; + case COMMENT_N: txt = layer_COMMENT_name; break; case ECO1_N: txt = layer_ECO1_name; break; case ECO2_N: txt = layer_ECO2_name; break; - case EDGE_N: txt = layer_EDGE_name; break; - default: txt = wxT( "BAD_INDEX" ); break; + case EDGE_N: txt = layer_EDGE_name; break; + default: txt = wxT( "BAD_INDEX" ); break; } - wxString name; if( aTranslate ) { - name = wxGetTranslation( txt ); + wxString name = wxGetTranslation( txt ); + + /* would someone translate into a name with leading or trailing spaces? name.Trim( true ); name.Trim( false ); + */ + + return name; } else - name = txt; - - return name; + return txt; } @@ -573,55 +575,6 @@ LAYER_T LAYER::ParseType( const char* aType ) } -int LAYER::GetDefaultIndex( const wxString& aName ) -{ - static LAYER_INDEX_HASH_MAP layerIndices; - - if( layerIndices.empty() ) - { - // These are only default layer names. The copper names may be over-ridden in - // the BOARD (*.brd) file. - - layerIndices[ _( "Front" ) ] = LAYER_N_FRONT; - layerIndices[ _( "Inner2" ) ] = LAYER_N_2; - layerIndices[ _( "Inner3" ) ] = LAYER_N_3; - layerIndices[ _( "Inner4" ) ] = LAYER_N_4; - layerIndices[ _( "Inner5" ) ] = LAYER_N_5; - layerIndices[ _( "Inner6" ) ] = LAYER_N_6; - layerIndices[ _( "Inner7" ) ] = LAYER_N_7; - layerIndices[ _( "Inner8" ) ] = LAYER_N_8; - layerIndices[ _( "Inner9" ) ] = LAYER_N_9; - layerIndices[ _( "Inner10" ) ] = LAYER_N_10; - layerIndices[ _( "Inner11" ) ] = LAYER_N_11; - layerIndices[ _( "Inner12" ) ] = LAYER_N_12; - layerIndices[ _( "Inner13" ) ] = LAYER_N_13; - layerIndices[ _( "Inner14" ) ] = LAYER_N_14; - layerIndices[ _( "Inner15" ) ] = LAYER_N_15; - layerIndices[ _( "Back" ) ] = LAYER_N_BACK; - layerIndices[ _( "Adhes_Back" ) ] = ADHESIVE_N_BACK; - layerIndices[ _( "Adhes_Front" ) ] = ADHESIVE_N_FRONT; - layerIndices[ _( "SoldP_Back" ) ] = SOLDERPASTE_N_BACK; - layerIndices[ _( "SoldP_Front" ) ] = SOLDERPASTE_N_FRONT; - layerIndices[ _( "SilkS_Back" ) ] = SILKSCREEN_N_BACK; - layerIndices[ _( "SilkS_Front" ) ] = SILKSCREEN_N_FRONT; - layerIndices[ _( "Mask_Back" ) ] = SOLDERMASK_N_BACK; - layerIndices[ _( "Mask_Front" ) ] = SOLDERMASK_N_FRONT; - layerIndices[ _( "Drawings" ) ] = DRAW_N; - layerIndices[ _( "Comments" ) ] = COMMENT_N; - layerIndices[ _( "Eco1" ) ] = ECO1_N; - layerIndices[ _( "Eco2" ) ] = ECO2_N; - layerIndices[ _( "PCB_Edges" ) ] = EDGE_N; - } - - const LAYER_INDEX_HASH_MAP::iterator it = layerIndices.find( aName ); - - if( it == layerIndices.end() ) - return UNDEFINED_LAYER; - - return layerIndices[ aName ]; -} - - int BOARD::GetCopperLayerCount() const { return m_designSettings.GetCopperLayerCount(); diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 37c33ff5a2..fcbab40978 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -19,8 +19,6 @@ #include #include -#include - class PCB_BASE_FRAME; class PCB_EDIT_FRAME; @@ -34,10 +32,9 @@ class MARKER_PCB; // non-owning container of item candidates when searching for items on the same track. -typedef std::vector< TRACK* > TRACK_PTRS; +typedef std::vector< TRACK* > TRACK_PTRS; - -#define HISTORY_MAX_COUNT 8 +#define HISTORY_MAX_COUNT 8 /** @@ -101,24 +98,12 @@ public: */ static LAYER_T ParseType( const char* aType ); - /** - * Function GetDefaultIndex - * returns the layer index of the layer \a aName. - * - * @param aName A reference to a wxString object containing the default layer name. - * @return The index of the layer \a aName if found otherwise #UNDEFINED_LAYER_INDEX. - */ - static int GetDefaultIndex( const wxString& aName ); - private: - bool m_visible; - int m_fixedListIndex; + bool m_visible; + int m_fixedListIndex; }; -WX_DECLARE_STRING_HASH_MAP( int, LAYER_INDEX_HASH_MAP ); - - /** * Struct VIA_DIMENSION * is a small helper container to handle a stock of specific vias each with diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 6c2d64547e..bb713e2b92 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -56,7 +56,14 @@ void PCB_PARSER::init() { m_layerMap.clear(); - // @todo add default layernames here. + // Add untranslated default (i.e. english) layernames. + // Some may be overridden later if parsing a board rather than a footprint. + // The english name will survive if parsing only a footprint. + for( int layerNdx = 0; layerNdx < NB_LAYERS; ++layerNdx ) + { + wxString untranslated = BOARD::GetDefaultLayerName( layerNdx, false ); + m_layerMap[ untranslated ] = layerNdx; + } } @@ -594,38 +601,38 @@ void PCB_PARSER::parseTITLE_BLOCK() throw( IO_ERROR, PARSE_ERROR ) break; case T_comment: - { - int commentNumber = parseInt( "comment" ); - - switch( commentNumber ) { - case 1: - NextTok(); - titleBlock.SetComment1( FromUTF8() ); + int commentNumber = parseInt( "comment" ); + + switch( commentNumber ) + { + case 1: + NextTok(); + titleBlock.SetComment1( FromUTF8() ); + break; + + case 2: + NextTok(); + titleBlock.SetComment2( FromUTF8() ); + break; + + case 3: + NextTok(); + titleBlock.SetComment3( FromUTF8() ); + break; + + case 4: + NextTok(); + titleBlock.SetComment4( FromUTF8() ); + break; + + default: + wxString err; + err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber ); + THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); + } + break; - - case 2: - NextTok(); - titleBlock.SetComment2( FromUTF8() ); - break; - - case 3: - NextTok(); - titleBlock.SetComment3( FromUTF8() ); - break; - - case 4: - NextTok(); - titleBlock.SetComment4( FromUTF8() ); - break; - - default: - wxString err; - err.Printf( wxT( "%d is not a valid title block comment number" ), commentNumber ); - THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); - } - - break; } default: @@ -644,14 +651,14 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) wxCHECK_RET( CurTok() == T_layers, wxT( "Cannot parse " ) + GetTokenString( CurTok() ) + wxT( " as layers." ) ); - T token; - wxString name; - wxString type; - int layerIndex; - bool isVisible = true; - int visibleLayers = 0; - int enabledLayers = 0; - int copperLayerCount = 0; + T token; + wxString name; + std::string type; + int layerIndex; + bool isVisible = true; + int visibleLayers = 0; + int enabledLayers = 0; + int copperLayerCount = 0; for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -662,8 +669,9 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) NeedSYMBOL(); name = FromUTF8(); + NeedSYMBOL(); - type = FromUTF8(); + type = CurText(); token = NextTok(); @@ -686,7 +694,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) if( isVisible ) visibleLayers |= 1 << layerIndex; - enum LAYER_T layerType = LAYER::ParseType( TO_UTF8( type ) ); + enum LAYER_T layerType = LAYER::ParseType( type.c_str() ); LAYER layer( name, layerType, isVisible ); layer.SetFixedListIndex( layerIndex ); @@ -694,7 +702,7 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) m_layerMap[ name ] = layerIndex; - wxLogDebug( wxT( "Mapping layer %s index index %d" ), + wxLogDebug( wxT( "Mapping layer %s to index %d" ), GetChars( name ), layerIndex ); if( layerType != LT_UNDEFINED ) @@ -704,8 +712,9 @@ void PCB_PARSER::parseLayers() throw( IO_ERROR, PARSE_ERROR ) // We need at least 2 copper layers and there must be an even number of them. if( (copperLayerCount < 2) || ((copperLayerCount % 2) != 0) ) { - wxString err; - err.Printf( _( "%d is not a valid layer count" ), copperLayerCount ); + wxString err = wxString::Format( + _( "%d is not a valid layer count" ), copperLayerCount ); + THROW_PARSE_ERROR( err, CurSource(), CurLine(), CurLineNumber(), CurOffset() ); } @@ -722,13 +731,14 @@ int PCB_PARSER::lookUpLayer() throw( PARSE_ERROR, IO_ERROR ) if( it == m_layerMap.end() ) { - wxString error; - error.Printf( wxT( "Layer '%s' in file <%s> at line %d, position %d was not defined in the layers section" ), - GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() ); + wxString error = wxString::Format( + _( "Layer '%s' in file <%s> at line %d, position %d, was not defined in the layers section" ), + GetChars( name ), GetChars( CurSource() ), CurLineNumber(), CurOffset() ); + THROW_IO_ERROR( error ); } - return m_layerMap[ name ]; + return it->second; } diff --git a/pcbnew/pcb_parser.h b/pcbnew/pcb_parser.h index 243fae811a..615bf372e4 100644 --- a/pcbnew/pcb_parser.h +++ b/pcbnew/pcb_parser.h @@ -64,7 +64,7 @@ WX_DECLARE_STRING_HASH_MAP( int, LAYER_HASH_MAP ); class PCB_PARSER : public PCB_LEXER { BOARD* m_board; - LAYER_HASH_MAP m_layerMap; //< Map layer name to it's index saved in BOARD::m_Layer. + LAYER_HASH_MAP m_layerMap; ///< Map layer name to it's index saved in BOARD::m_Layer. /** @@ -220,6 +220,7 @@ public: PCB_LEXER( aReader ), m_board( 0 ) { + init(); }