2008-02-19 00:35:45 +00:00
|
|
|
|
/***********************************/
|
|
|
|
|
/** pcbcfg() : configuration **/
|
|
|
|
|
/***********************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/* lit ou met a jour la configuration de PCBNEW */
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "appl_wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
|
#include "confirm.h"
|
|
|
|
|
#include "gestfich.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "pcbnew.h"
|
|
|
|
|
#include "pcbplot.h"
|
|
|
|
|
#include "pcbcfg.h"
|
|
|
|
|
#include "worksheet.h"
|
|
|
|
|
#include "id.h"
|
2007-09-06 11:52:26 +00:00
|
|
|
|
#include "hotkeys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
/* Routines Locales */
|
|
|
|
|
|
|
|
|
|
/* Variables locales */
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
#define HOTKEY_FILENAME wxT( "pcbnew" )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
/***********************************************************/
|
2008-02-19 00:35:45 +00:00
|
|
|
|
void WinEDA_PcbFrame::Process_Config( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***********************************************************/
|
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
|
int id = event.GetId();
|
|
|
|
|
wxPoint pos;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
|
|
wxClientDC dc( DrawPanel );
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxFileName fn;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
|
|
DrawPanel->PrepareGraphicContext( &dc );
|
|
|
|
|
|
|
|
|
|
pos = GetPosition();
|
|
|
|
|
pos.x += 20;
|
|
|
|
|
pos.y += 20;
|
|
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
|
{
|
|
|
|
|
case ID_COLORS_SETUP:
|
|
|
|
|
DisplayColorSetupFrame( this, pos );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_CONFIG_REQ: // Creation de la fenetre de configuration
|
|
|
|
|
InstallConfigFrame( pos );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_PCB_TRACK_SIZE_SETUP:
|
|
|
|
|
case ID_PCB_LOOK_SETUP:
|
|
|
|
|
case ID_OPTIONS_SETUP:
|
|
|
|
|
case ID_PCB_DRAWINGS_WIDTHS_SETUP:
|
|
|
|
|
InstallPcbOptionsFrame( pos, &dc, id );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_PCB_PAD_SETUP:
|
|
|
|
|
InstallPadOptionsFrame( NULL, NULL, pos );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_CONFIG_SAVE:
|
|
|
|
|
Update_config( this );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
2009-04-05 20:49:15 +00:00
|
|
|
|
{
|
|
|
|
|
fn = GetScreen()->m_FileName;
|
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
|
|
|
|
fn.GetFullName(), ProjectFileWildcard,
|
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-19 00:35:45 +00:00
|
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
|
if( !wxFileExists( dlg.GetPath() ) )
|
2008-02-19 00:35:45 +00:00
|
|
|
|
{
|
|
|
|
|
wxString msg;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
msg.Printf( _( "File %s not found" ), dlg.GetPath().c_str() );
|
|
|
|
|
DisplayError( this, msg );
|
|
|
|
|
break;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
Read_Config( dlg.GetPath() );
|
|
|
|
|
break;
|
|
|
|
|
}
|
2008-02-19 00:35:45 +00:00
|
|
|
|
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
2009-04-05 20:49:15 +00:00
|
|
|
|
fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) );
|
|
|
|
|
fn.SetName( HOTKEY_FILENAME );
|
|
|
|
|
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
|
WriteHotkeyConfigFile( fn.GetFullPath(), s_Pcbnew_Editor_Hokeys_Descr,
|
2008-12-08 15:27:13 +00:00
|
|
|
|
true );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
|
|
|
|
Read_Hotkey_Config( this, true );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
fn.SetPath( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ) );
|
|
|
|
|
fn.SetName( HOTKEY_FILENAME );
|
|
|
|
|
fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
|
|
|
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
2008-02-19 00:35:45 +00:00
|
|
|
|
if( !editorname.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
|
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
|
|
|
|
HandleHotkeyConfigMenuSelection( this, id );
|
|
|
|
|
break;
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
2008-02-19 00:35:45 +00:00
|
|
|
|
DisplayHotkeyList( this, s_Board_Editor_Hokeys_Descr );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2008-12-08 15:27:13 +00:00
|
|
|
|
DisplayError( this,
|
|
|
|
|
wxT( "WinEDA_PcbFrame::Process_Config internal error" ) );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
|
/***************************************************************/
|
2008-02-19 00:35:45 +00:00
|
|
|
|
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
|
2007-08-21 19:37:31 +00:00
|
|
|
|
/***************************************************************/
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
|
/*
|
2007-08-23 01:40:50 +00:00
|
|
|
|
* Read the hotkey files config for pcbnew and module_edit
|
2008-02-19 00:35:45 +00:00
|
|
|
|
*/
|
2007-08-21 19:37:31 +00:00
|
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
|
wxString FullFileName = ReturnHotkeyConfigFilePath(
|
|
|
|
|
g_ConfigFileLocationChoice );
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
|
|
|
|
FullFileName += HOTKEY_FILENAME;
|
|
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2008-12-08 15:27:13 +00:00
|
|
|
|
return frame->ReadHotkeyConfigFile( FullFileName,
|
|
|
|
|
s_Pcbnew_Editor_Hokeys_Descr,
|
|
|
|
|
verbose );
|
2007-08-23 01:40:50 +00:00
|
|
|
|
}
|
2007-08-21 19:37:31 +00:00
|
|
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**************************************************************************/
|
2009-04-05 20:49:15 +00:00
|
|
|
|
bool Read_Config( const wxString& projectFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
/* lit la configuration, si elle n'a pas deja ete lue
|
2008-12-08 15:27:13 +00:00
|
|
|
|
* 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
|
2008-02-19 00:35:45 +00:00
|
|
|
|
*
|
2008-12-08 15:27:13 +00:00
|
|
|
|
* Retourne TRUE si lu, FALSE si config non lue ou non modifi<EFBFBD>e
|
2008-02-19 00:35:45 +00:00
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxFileName fn = projectFileName;
|
2008-02-19 00:35:45 +00:00
|
|
|
|
int ii;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
if( fn.GetExt() != ProjectFileExtension )
|
|
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
|
wxLogDebug( wxT( "Attempting to open project file <%s>. Changing \
|
|
|
|
|
file extension to a Kicad project file extension (.pro)." ),
|
|
|
|
|
fn.GetFullPath().c_str() );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
|
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
/* Init des valeurs par defaut */
|
|
|
|
|
g_LibName_List.Clear();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxGetApp().ReadProjectConfig( fn.GetFullPath(),
|
2008-12-08 15:27:13 +00:00
|
|
|
|
GROUP, ParamCfgList, FALSE );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
|
/* User library path takes precedent over default library search paths. */
|
|
|
|
|
wxGetApp().InsertLibraryPath( g_UserLibDirBuffer, 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
|
/* Traitement des variables particulieres: */
|
2009-02-26 00:37:04 +00:00
|
|
|
|
g_DesignSettings.m_TrackWidthHistory[0] = g_DesignSettings.m_CurrentTrackWidth;
|
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[0] = g_DesignSettings.m_CurrentViaSize;
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
for( ii = 1; ii < HISTORY_NUMBER; ii++ )
|
|
|
|
|
{
|
|
|
|
|
g_DesignSettings.m_TrackWidthHistory[ii] = 0;
|
|
|
|
|
g_DesignSettings.m_ViaSizeHistory[ii] = 0;
|
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
return TRUE;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/**********************************************************/
|
2008-02-19 00:35:45 +00:00
|
|
|
|
void WinEDA_PcbFrame::Update_config( wxWindow* displayframe )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
/***********************************************************/
|
|
|
|
|
/* enregistrement de la config */
|
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
|
|
fn = GetScreen()->m_FileName;
|
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save Project File" ), fn.GetPath(),
|
|
|
|
|
fn.GetFullName(), ProjectFileWildcard,
|
|
|
|
|
wxFD_SAVE | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-19 00:35:45 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* ecriture de la configuration */
|
2009-04-05 20:49:15 +00:00
|
|
|
|
wxGetApp().WriteProjectConfig( fn.GetFullPath(), wxT( "/pcbnew" ),
|
2008-12-08 15:27:13 +00:00
|
|
|
|
ParamCfgList );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
}
|