Loading common/common.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) */ { #if 0 && defined(DEBUG) #if 1 && defined(DEBUG) // Dick: this code is working fine, but we have no place to store the layer names yet. Loading common/edaappl.cpp +13 −7 Original line number Diff line number Diff line Loading @@ -270,7 +270,8 @@ void WinEDA_App::GetSettings() wxString Line, Ident; unsigned ii; m_HelpSize.x = 500; m_HelpSize.y = 400; m_HelpSize.x = 500; m_HelpSize.y = 400; if( m_EDA_CommonConfig ) { Loading @@ -285,8 +286,11 @@ void WinEDA_App::GetSettings() for( ii = 0; ii < 10; ii++ ) { Ident = wxT( "LastProject" ); if( ii ) Ident = wxT( "LastProject" ); if( ii ) Ident << ii; if( m_EDA_Config->Read( Ident, &Line ) ) m_LastProject.Add( Line ); } Loading @@ -299,6 +303,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_StdFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "SdtFontStyle" ), wxFONTFAMILY_ROMAN ); g_StdFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL ); Loading @@ -309,6 +314,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "MsgFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_MsgFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "MsgFontStyle" ), wxFONTFAMILY_ROMAN ); g_MsgFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL ); Loading @@ -318,6 +324,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_DialogFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "DialogFontStyle" ), wxFONTFAMILY_ROMAN ); g_DialogFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "DialogFontWeight" ), wxNORMAL ); Loading @@ -343,7 +350,6 @@ void WinEDA_App::SaveSettings() { unsigned int ii; if( m_EDA_Config == NULL ) return; Loading common/projet_config.cpp +452 −397 Original line number Diff line number Diff line Loading @@ -16,23 +16,27 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename, const wxString& GroupName, bool ForceUseLocalConfig ) /*********************************************************************/ /* Cree ou recree la configuration locale de kicad (filename.pro) initialise: g_Prj_Config g_Prj_Config_LocalFilename g_Prj_Default_Config_FullFilename return: TRUE si config locale FALSE si default config * initialise: * g_Prj_Config * g_Prj_Config_LocalFilename * g_Prj_Default_Config_FullFilename * return: * TRUE si config locale * FALSE si default config */ { // free old config if ( g_Prj_Config ) delete g_Prj_Config; if( g_Prj_Config ) delete g_Prj_Config; g_Prj_Config = NULL; // Init local Config filename if ( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT("kicad"); else g_Prj_Config_LocalFilename = local_config_filename; if( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT( "kicad" ); else g_Prj_Config_LocalFilename = local_config_filename; ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext ); Loading @@ -43,17 +47,21 @@ static bool ReCreatePrjConfig(const wxString & local_config_filename, g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString, g_Prj_Config_LocalFilename, wxEmptyString, wxCONFIG_USE_RELATIVE_PATH ); g_Prj_Config->DontCreateOnDemand(); if ( ForceUseLocalConfig ) return TRUE; if( ForceUseLocalConfig ) return TRUE; // Test de la bonne version du fichier (ou groupe) de configuration int version = -1, def_version = 0; g_Prj_Config->SetPath( GroupName ); version = g_Prj_Config->Read( wxT( "version" ), def_version ); g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); if ( version > 0 ) return TRUE; else delete g_Prj_Config; // Version incorrecte if( version > 0 ) return TRUE; else delete g_Prj_Config; // Version incorrecte } Loading @@ -68,6 +76,7 @@ static bool ReCreatePrjConfig(const wxString & local_config_filename, g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString, wxEmptyString, g_Prj_Default_Config_FullFilename, wxCONFIG_USE_RELATIVE_PATH ); g_Prj_Config->DontCreateOnDemand(); return FALSE; Loading @@ -85,13 +94,16 @@ wxString msg; ReCreatePrjConfig( local_config_filename, GroupName, FORCE_LOCAL_CONFIG ); /* Write date ( surtout pour eviter bug de wxFileConfig qui se trompe de rubrique si declaration [xx] en premiere ligne (en fait si groupe vide) */ * qui se trompe de rubrique si declaration [xx] en premiere ligne * (en fait si groupe vide) */ g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); msg = DateAndTime(); g_Prj_Config->Write( wxT( "update" ), msg ); msg = GetAppName(); g_Prj_Config->Write( wxT( "last_client" ), msg ); /* ecriture de la configuration */ Loading @@ -105,15 +117,19 @@ wxString msg; for( ; *List != NULL; List++ ) { pt_cfg = *List; if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); else g_Prj_Config->SetPath(GroupName); if( pt_cfg->m_Group ) g_Prj_Config->SetPath( pt_cfg->m_Group ); else g_Prj_Config->SetPath( GroupName ); switch( pt_cfg->m_Type ) { case PARAM_INT: #undef PTCFG #define PTCFG ( (PARAM_CFG_INT*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -123,7 +139,9 @@ wxString msg; case PARAM_SETCOLOR: #undef PTCFG #define PTCFG ( (PARAM_CFG_SETCOLOR*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -133,7 +151,9 @@ wxString msg; case PARAM_DOUBLE: #undef PTCFG #define PTCFG ( (PARAM_CFG_DOUBLE*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -143,7 +163,9 @@ wxString msg; case PARAM_BOOL: #undef PTCFG #define PTCFG ( (PARAM_CFG_BOOL*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, (int) *PTCFG->m_Pt_param ); else Loading @@ -153,7 +175,9 @@ wxString msg; case PARAM_WXSTRING: #undef PTCFG #define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -164,18 +188,24 @@ wxString msg; { #undef PTCFG #define PTCFG ( (PARAM_CFG_LIBNAME_LIST*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; wxArrayString* libname_list = PTCFG->m_Pt_param; if ( libname_list == NULL ) break; if( libname_list == NULL ) break; unsigned indexlib = 0; wxString cle_config; for( ; indexlib < libname_list->GetCount(); indexlib++ ) { cle_config = pt_cfg->m_Ident; // We use indexlib+1 because first lib name is LibName1 cle_config << (indexlib + 1); g_Prj_Config->Write( cle_config, libname_list->Item( indexlib ) ); } break; } Loading @@ -200,28 +230,30 @@ bool WinEDA_App::ReadProjectConfig(const wxString & local_config_filename, const wxString& GroupName, PARAM_CFG_BASE** List, bool Load_Only_if_New ) /***************************************************************************************/ /* Lecture de la config "projet" *** si Load_Only_if_New == TRUE, elle n'est lue que si elle *** est differente de la config actuelle (dates differentes) return: TRUE si lue. Met a jour en plus: g_EDA_Appl->m_CurrentOptionFileDateAndTime g_EDA_Appl->m_CurrentOptionFile * * return: * TRUE si lue. * Met a jour en plus: * g_EDA_Appl->m_CurrentOptionFileDateAndTime * g_EDA_Appl->m_CurrentOptionFile */ { const PARAM_CFG_BASE* pt_cfg; wxString timestamp; if ( List == NULL )return FALSE; if( List == NULL ) return FALSE; ReCreatePrjConfig( local_config_filename, GroupName, FALSE ); g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); timestamp = g_Prj_Config->Read( wxT( "update" ) ); if ( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) ) if( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) ) { return FALSE; } Loading @@ -242,8 +274,11 @@ wxString timestamp; for( ; *List != NULL; List++ ) { pt_cfg = *List; if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); else g_Prj_Config->SetPath(GroupName); if( pt_cfg->m_Group ) g_Prj_Config->SetPath( pt_cfg->m_Group ); else g_Prj_Config->SetPath( GroupName ); switch( pt_cfg->m_Type ) { case PARAM_INT: Loading @@ -255,8 +290,10 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); if( (itmp < PTCFG->m_Min) || (itmp > PTCFG->m_Max) ) itmp = PTCFG->m_Default; *PTCFG->m_Pt_param = itmp; break; } Loading @@ -270,8 +307,10 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); if( (itmp < 0) || (itmp > MAX_COLOR) ) itmp = PTCFG->m_Default; *PTCFG->m_Pt_param = itmp; break; } Loading @@ -286,7 +325,8 @@ wxString timestamp; else msg = g_Prj_Config->Read( pt_cfg->m_Ident, wxT( "" ) ); if ( msg.IsEmpty() ) ftmp = PTCFG->m_Default; if( msg.IsEmpty() ) ftmp = PTCFG->m_Default; else { msg.ToDouble( &ftmp ); Loading @@ -306,6 +346,7 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); *PTCFG->m_Pt_param = itmp ? TRUE : FALSE; break; } Loading @@ -314,7 +355,9 @@ wxString timestamp; { #undef PTCFG #define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) *PTCFG->m_Pt_param = m_EDA_Config->Read( pt_cfg->m_Ident ); else Loading @@ -333,9 +376,11 @@ wxString timestamp; { id_lib = pt_cfg->m_Ident; id_lib << indexlib; indexlib++; libname = g_Prj_Config->Read( id_lib, wxT( "" ) ); if( libname.IsEmpty() ) break; if( libname.IsEmpty() ) break; libname_list->Add( libname ); } break; } Loading Loading @@ -367,8 +412,8 @@ PARAM_CFG_BASE::PARAM_CFG_BASE(const wxChar * ident, const paramcfg_id type, PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam, int default_val, int min, int max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_INT, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_INT, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -376,10 +421,11 @@ PARAM_CFG_INT::PARAM_CFG_INT(const wxChar * ident, int * ptparam, m_Max = max; } PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, int default_val, int min, int max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_INT, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_INT, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -388,37 +434,42 @@ PARAM_CFG_INT::PARAM_CFG_INT(bool Insetup, const wxChar * ident, int * ptparam, m_Setup = Insetup; } PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; } PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; m_Setup = Insetup; } PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam, double default_val, double min, double max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; m_Min = min; m_Max = max; } PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam, double default_val, double min, double max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -427,42 +478,46 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(bool Insetup, const wxChar * ident, double * m_Setup = Insetup; } PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_BOOL, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_BOOL, group ) { m_Pt_param = ptparam; m_Default = default_val ? TRUE : FALSE; } PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_BOOL, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_BOOL, group ) { m_Pt_param = ptparam; m_Default = default_val ? TRUE : FALSE; m_Setup = Insetup; } PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident, wxString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) wxString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; } PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident, wxString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) wxString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; m_Setup = Insetup; } PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_LIBNAME_LIST, group) wxArrayString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group ) { m_Pt_param = ptparam; } pcbnew/pcbcfg.cpp +166 −159 Original line number Diff line number Diff line Loading @@ -29,13 +29,16 @@ void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event) { int id = event.GetId(); wxPoint pos; wxClientDC dc( DrawPanel ); wxString FullFileName; DrawPanel->PrepareGraphicContext( &dc ); pos = GetPosition(); pos.x += 20; pos.y += 20; pos.x += 20; pos.y += 20; switch( id ) { Loading Loading @@ -74,7 +77,8 @@ wxString FullFileName; wxFD_OPEN, TRUE /* ne change pas de repertoire courant */ ); if ( FullFileName.IsEmpty()) break; if( FullFileName.IsEmpty() ) break; if( !wxFileExists( FullFileName ) ) { wxString msg; Loading Loading @@ -124,11 +128,13 @@ wxString FullFileName; /***************************************************************/ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ) /***************************************************************/ /* * Read the hotkey files config for pcbnew and module_edit */ { wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); FullFileName += HOTKEY_FILENAME; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; return frame->ReadHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose ); Loading @@ -138,12 +144,13 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) /**************************************************************************/ bool Read_Config( const wxString& project_name ) /*************************************************************************/ /* lit la configuration, si elle n'a pas deja ete lue 1 - lit <nom fichier brd>.pro 2 - si non trouve lit <chemin de *.exe>/kicad.pro 3 - si non trouve: init des variables aux valeurs par defaut Retourne TRUE si lu, FALSE si config non lue ou non modifie /* lit la configuration, si elle n'a pas deja ete lue * 1 - lit <nom fichier brd>.pro * 2 - si non trouve lit <chemin de *.exe>/kicad.pro * 3 - si non trouve: init des variables aux valeurs par defaut * * Retourne TRUE si lu, FALSE si config non lue ou non modifie */ { wxString FullFileName; Loading Loading @@ -181,6 +188,7 @@ int ii; return TRUE; } /**********************************************************/ void WinEDA_PcbFrame::Update_config( wxWindow* displayframe ) /***********************************************************/ Loading @@ -202,12 +210,11 @@ wxString mask; wxFD_SAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; if( FullFileName.IsEmpty() ) return; Pcbdiv_grille = GetScreen()->m_Diviseur_Grille; /* ecriture de la configuration */ g_EDA_Appl->WriteProjectConfig( FullFileName, wxT( "/pcbnew" ), ParamCfgList ); } Loading
common/common.cpp +18 −18 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ wxString ReturnPcbLayerName( int layer_number, bool omitSpacePadding ) */ { #if 0 && defined(DEBUG) #if 1 && defined(DEBUG) // Dick: this code is working fine, but we have no place to store the layer names yet. Loading
common/edaappl.cpp +13 −7 Original line number Diff line number Diff line Loading @@ -270,7 +270,8 @@ void WinEDA_App::GetSettings() wxString Line, Ident; unsigned ii; m_HelpSize.x = 500; m_HelpSize.y = 400; m_HelpSize.x = 500; m_HelpSize.y = 400; if( m_EDA_CommonConfig ) { Loading @@ -285,8 +286,11 @@ void WinEDA_App::GetSettings() for( ii = 0; ii < 10; ii++ ) { Ident = wxT( "LastProject" ); if( ii ) Ident = wxT( "LastProject" ); if( ii ) Ident << ii; if( m_EDA_Config->Read( Ident, &Line ) ) m_LastProject.Add( Line ); } Loading @@ -299,6 +303,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "SdtFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_StdFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "SdtFontStyle" ), wxFONTFAMILY_ROMAN ); g_StdFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "SdtFontWeight" ), wxNORMAL ); Loading @@ -309,6 +314,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "MsgFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_MsgFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "MsgFontStyle" ), wxFONTFAMILY_ROMAN ); g_MsgFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "MsgFontWeight" ), wxNORMAL ); Loading @@ -318,6 +324,7 @@ void WinEDA_App::GetSettings() Line = m_EDA_Config->Read( wxT( "DialogFontType" ), wxEmptyString ); if( !Line.IsEmpty() ) g_DialogFont->SetFaceName( Line ); ii = m_EDA_Config->Read( wxT( "DialogFontStyle" ), wxFONTFAMILY_ROMAN ); g_DialogFont->SetStyle( ii ); ii = m_EDA_Config->Read( wxT( "DialogFontWeight" ), wxNORMAL ); Loading @@ -343,7 +350,6 @@ void WinEDA_App::SaveSettings() { unsigned int ii; if( m_EDA_Config == NULL ) return; Loading
common/projet_config.cpp +452 −397 Original line number Diff line number Diff line Loading @@ -16,23 +16,27 @@ static bool ReCreatePrjConfig( const wxString& local_config_filename, const wxString& GroupName, bool ForceUseLocalConfig ) /*********************************************************************/ /* Cree ou recree la configuration locale de kicad (filename.pro) initialise: g_Prj_Config g_Prj_Config_LocalFilename g_Prj_Default_Config_FullFilename return: TRUE si config locale FALSE si default config * initialise: * g_Prj_Config * g_Prj_Config_LocalFilename * g_Prj_Default_Config_FullFilename * return: * TRUE si config locale * FALSE si default config */ { // free old config if ( g_Prj_Config ) delete g_Prj_Config; if( g_Prj_Config ) delete g_Prj_Config; g_Prj_Config = NULL; // Init local Config filename if ( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT("kicad"); else g_Prj_Config_LocalFilename = local_config_filename; if( local_config_filename.IsEmpty() ) g_Prj_Config_LocalFilename = wxT( "kicad" ); else g_Prj_Config_LocalFilename = local_config_filename; ChangeFileNameExt( g_Prj_Config_LocalFilename, g_Prj_Config_Filename_ext ); Loading @@ -43,17 +47,21 @@ static bool ReCreatePrjConfig(const wxString & local_config_filename, g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString, g_Prj_Config_LocalFilename, wxEmptyString, wxCONFIG_USE_RELATIVE_PATH ); g_Prj_Config->DontCreateOnDemand(); if ( ForceUseLocalConfig ) return TRUE; if( ForceUseLocalConfig ) return TRUE; // Test de la bonne version du fichier (ou groupe) de configuration int version = -1, def_version = 0; g_Prj_Config->SetPath( GroupName ); version = g_Prj_Config->Read( wxT( "version" ), def_version ); g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); if ( version > 0 ) return TRUE; else delete g_Prj_Config; // Version incorrecte if( version > 0 ) return TRUE; else delete g_Prj_Config; // Version incorrecte } Loading @@ -68,6 +76,7 @@ static bool ReCreatePrjConfig(const wxString & local_config_filename, g_Prj_Config = new wxFileConfig( wxEmptyString, wxEmptyString, wxEmptyString, g_Prj_Default_Config_FullFilename, wxCONFIG_USE_RELATIVE_PATH ); g_Prj_Config->DontCreateOnDemand(); return FALSE; Loading @@ -85,13 +94,16 @@ wxString msg; ReCreatePrjConfig( local_config_filename, GroupName, FORCE_LOCAL_CONFIG ); /* Write date ( surtout pour eviter bug de wxFileConfig qui se trompe de rubrique si declaration [xx] en premiere ligne (en fait si groupe vide) */ * qui se trompe de rubrique si declaration [xx] en premiere ligne * (en fait si groupe vide) */ g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); msg = DateAndTime(); g_Prj_Config->Write( wxT( "update" ), msg ); msg = GetAppName(); g_Prj_Config->Write( wxT( "last_client" ), msg ); /* ecriture de la configuration */ Loading @@ -105,15 +117,19 @@ wxString msg; for( ; *List != NULL; List++ ) { pt_cfg = *List; if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); else g_Prj_Config->SetPath(GroupName); if( pt_cfg->m_Group ) g_Prj_Config->SetPath( pt_cfg->m_Group ); else g_Prj_Config->SetPath( GroupName ); switch( pt_cfg->m_Type ) { case PARAM_INT: #undef PTCFG #define PTCFG ( (PARAM_CFG_INT*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -123,7 +139,9 @@ wxString msg; case PARAM_SETCOLOR: #undef PTCFG #define PTCFG ( (PARAM_CFG_SETCOLOR*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -133,7 +151,9 @@ wxString msg; case PARAM_DOUBLE: #undef PTCFG #define PTCFG ( (PARAM_CFG_DOUBLE*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -143,7 +163,9 @@ wxString msg; case PARAM_BOOL: #undef PTCFG #define PTCFG ( (PARAM_CFG_BOOL*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, (int) *PTCFG->m_Pt_param ); else Loading @@ -153,7 +175,9 @@ wxString msg; case PARAM_WXSTRING: #undef PTCFG #define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) m_EDA_Config->Write( pt_cfg->m_Ident, *PTCFG->m_Pt_param ); else Loading @@ -164,18 +188,24 @@ wxString msg; { #undef PTCFG #define PTCFG ( (PARAM_CFG_LIBNAME_LIST*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; wxArrayString* libname_list = PTCFG->m_Pt_param; if ( libname_list == NULL ) break; if( libname_list == NULL ) break; unsigned indexlib = 0; wxString cle_config; for( ; indexlib < libname_list->GetCount(); indexlib++ ) { cle_config = pt_cfg->m_Ident; // We use indexlib+1 because first lib name is LibName1 cle_config << (indexlib + 1); g_Prj_Config->Write( cle_config, libname_list->Item( indexlib ) ); } break; } Loading @@ -200,28 +230,30 @@ bool WinEDA_App::ReadProjectConfig(const wxString & local_config_filename, const wxString& GroupName, PARAM_CFG_BASE** List, bool Load_Only_if_New ) /***************************************************************************************/ /* Lecture de la config "projet" *** si Load_Only_if_New == TRUE, elle n'est lue que si elle *** est differente de la config actuelle (dates differentes) return: TRUE si lue. Met a jour en plus: g_EDA_Appl->m_CurrentOptionFileDateAndTime g_EDA_Appl->m_CurrentOptionFile * * return: * TRUE si lue. * Met a jour en plus: * g_EDA_Appl->m_CurrentOptionFileDateAndTime * g_EDA_Appl->m_CurrentOptionFile */ { const PARAM_CFG_BASE* pt_cfg; wxString timestamp; if ( List == NULL )return FALSE; if( List == NULL ) return FALSE; ReCreatePrjConfig( local_config_filename, GroupName, FALSE ); g_Prj_Config->SetPath( UNIX_STRING_DIR_SEP ); timestamp = g_Prj_Config->Read( wxT( "update" ) ); if ( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) ) if( Load_Only_if_New && ( !timestamp.IsEmpty() ) && (timestamp == g_EDA_Appl->m_CurrentOptionFileDateAndTime) ) { return FALSE; } Loading @@ -242,8 +274,11 @@ wxString timestamp; for( ; *List != NULL; List++ ) { pt_cfg = *List; if ( pt_cfg->m_Group ) g_Prj_Config->SetPath(pt_cfg->m_Group); else g_Prj_Config->SetPath(GroupName); if( pt_cfg->m_Group ) g_Prj_Config->SetPath( pt_cfg->m_Group ); else g_Prj_Config->SetPath( GroupName ); switch( pt_cfg->m_Type ) { case PARAM_INT: Loading @@ -255,8 +290,10 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); if( (itmp < PTCFG->m_Min) || (itmp > PTCFG->m_Max) ) itmp = PTCFG->m_Default; *PTCFG->m_Pt_param = itmp; break; } Loading @@ -270,8 +307,10 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); if( (itmp < 0) || (itmp > MAX_COLOR) ) itmp = PTCFG->m_Default; *PTCFG->m_Pt_param = itmp; break; } Loading @@ -286,7 +325,8 @@ wxString timestamp; else msg = g_Prj_Config->Read( pt_cfg->m_Ident, wxT( "" ) ); if ( msg.IsEmpty() ) ftmp = PTCFG->m_Default; if( msg.IsEmpty() ) ftmp = PTCFG->m_Default; else { msg.ToDouble( &ftmp ); Loading @@ -306,6 +346,7 @@ wxString timestamp; itmp = m_EDA_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); else itmp = g_Prj_Config->Read( pt_cfg->m_Ident, PTCFG->m_Default ); *PTCFG->m_Pt_param = itmp ? TRUE : FALSE; break; } Loading @@ -314,7 +355,9 @@ wxString timestamp; { #undef PTCFG #define PTCFG ( (PARAM_CFG_WXSTRING*) pt_cfg ) if (PTCFG->m_Pt_param == NULL) break; if( PTCFG->m_Pt_param == NULL ) break; if( pt_cfg->m_Setup ) *PTCFG->m_Pt_param = m_EDA_Config->Read( pt_cfg->m_Ident ); else Loading @@ -333,9 +376,11 @@ wxString timestamp; { id_lib = pt_cfg->m_Ident; id_lib << indexlib; indexlib++; libname = g_Prj_Config->Read( id_lib, wxT( "" ) ); if( libname.IsEmpty() ) break; if( libname.IsEmpty() ) break; libname_list->Add( libname ); } break; } Loading Loading @@ -367,8 +412,8 @@ PARAM_CFG_BASE::PARAM_CFG_BASE(const wxChar * ident, const paramcfg_id type, PARAM_CFG_INT::PARAM_CFG_INT( const wxChar* ident, int* ptparam, int default_val, int min, int max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_INT, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_INT, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -376,10 +421,11 @@ PARAM_CFG_INT::PARAM_CFG_INT(const wxChar * ident, int * ptparam, m_Max = max; } PARAM_CFG_INT::PARAM_CFG_INT( bool Insetup, const wxChar* ident, int* ptparam, int default_val, int min, int max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_INT, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_INT, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -388,37 +434,42 @@ PARAM_CFG_INT::PARAM_CFG_INT(bool Insetup, const wxChar * ident, int * ptparam, m_Setup = Insetup; } PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( const wxChar* ident, int* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; } PARAM_CFG_SETCOLOR::PARAM_CFG_SETCOLOR( bool Insetup, const wxChar* ident, int* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_SETCOLOR, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_SETCOLOR, group ) { m_Pt_param = ptparam; m_Default = default_val; m_Setup = Insetup; } PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( const wxChar* ident, double* ptparam, double default_val, double min, double max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; m_Min = min; m_Max = max; } PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE( bool Insetup, const wxChar* ident, double* ptparam, double default_val, double min, double max, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_DOUBLE, group) const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_DOUBLE, group ) { m_Pt_param = ptparam; m_Default = default_val; Loading @@ -427,42 +478,46 @@ PARAM_CFG_DOUBLE::PARAM_CFG_DOUBLE(bool Insetup, const wxChar * ident, double * m_Setup = Insetup; } PARAM_CFG_BOOL::PARAM_CFG_BOOL( const wxChar* ident, bool* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_BOOL, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_BOOL, group ) { m_Pt_param = ptparam; m_Default = default_val ? TRUE : FALSE; } PARAM_CFG_BOOL::PARAM_CFG_BOOL( bool Insetup, const wxChar* ident, bool* ptparam, int default_val, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_BOOL, group) int default_val, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_BOOL, group ) { m_Pt_param = ptparam; m_Default = default_val ? TRUE : FALSE; m_Setup = Insetup; } PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( const wxChar* ident, wxString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) wxString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; } PARAM_CFG_WXSTRING::PARAM_CFG_WXSTRING( bool Insetup, const wxChar* ident, wxString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_WXSTRING, group) wxString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_WXSTRING, group ) { m_Pt_param = ptparam; m_Setup = Insetup; } PARAM_CFG_LIBNAME_LIST::PARAM_CFG_LIBNAME_LIST( const wxChar* ident, wxArrayString * ptparam, const wxChar * group) : PARAM_CFG_BASE(ident, PARAM_LIBNAME_LIST, group) wxArrayString* ptparam, const wxChar* group ) : PARAM_CFG_BASE( ident, PARAM_LIBNAME_LIST, group ) { m_Pt_param = ptparam; }
pcbnew/pcbcfg.cpp +166 −159 Original line number Diff line number Diff line Loading @@ -29,13 +29,16 @@ void WinEDA_PcbFrame::Process_Config(wxCommandEvent& event) { int id = event.GetId(); wxPoint pos; wxClientDC dc( DrawPanel ); wxString FullFileName; DrawPanel->PrepareGraphicContext( &dc ); pos = GetPosition(); pos.x += 20; pos.y += 20; pos.x += 20; pos.y += 20; switch( id ) { Loading Loading @@ -74,7 +77,8 @@ wxString FullFileName; wxFD_OPEN, TRUE /* ne change pas de repertoire courant */ ); if ( FullFileName.IsEmpty()) break; if( FullFileName.IsEmpty() ) break; if( !wxFileExists( FullFileName ) ) { wxString msg; Loading Loading @@ -124,11 +128,13 @@ wxString FullFileName; /***************************************************************/ bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose ) /***************************************************************/ /* * Read the hotkey files config for pcbnew and module_edit */ { wxString FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ); FullFileName += HOTKEY_FILENAME; FullFileName += DEFAULT_HOTKEY_FILENAME_EXT; return frame->ReadHotkeyConfigFile( FullFileName, s_Pcbnew_Editor_Hokeys_Descr, verbose ); Loading @@ -138,12 +144,13 @@ bool Read_Hotkey_Config( WinEDA_DrawFrame * frame, bool verbose ) /**************************************************************************/ bool Read_Config( const wxString& project_name ) /*************************************************************************/ /* lit la configuration, si elle n'a pas deja ete lue 1 - lit <nom fichier brd>.pro 2 - si non trouve lit <chemin de *.exe>/kicad.pro 3 - si non trouve: init des variables aux valeurs par defaut Retourne TRUE si lu, FALSE si config non lue ou non modifie /* lit la configuration, si elle n'a pas deja ete lue * 1 - lit <nom fichier brd>.pro * 2 - si non trouve lit <chemin de *.exe>/kicad.pro * 3 - si non trouve: init des variables aux valeurs par defaut * * Retourne TRUE si lu, FALSE si config non lue ou non modifie */ { wxString FullFileName; Loading Loading @@ -181,6 +188,7 @@ int ii; return TRUE; } /**********************************************************/ void WinEDA_PcbFrame::Update_config( wxWindow* displayframe ) /***********************************************************/ Loading @@ -202,12 +210,11 @@ wxString mask; wxFD_SAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; if( FullFileName.IsEmpty() ) return; Pcbdiv_grille = GetScreen()->m_Diviseur_Grille; /* ecriture de la configuration */ g_EDA_Appl->WriteProjectConfig( FullFileName, wxT( "/pcbnew" ), ParamCfgList ); }