2007-09-19 15:29:50 +00:00
|
|
|
/************************************************/
|
|
|
|
/** gerbview_config.cpp : Gerbview configuration*/
|
|
|
|
/************************************************/
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* Functions to handle Gerbview configuration */
|
2007-09-11 07:34:46 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2007-09-11 07:34:46 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "pcbcommon.h"
|
2007-09-11 07:34:46 +00:00
|
|
|
#include "gerbview.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "id.h"
|
|
|
|
#include "hotkeys.h"
|
|
|
|
#include "gerbview_config.h"
|
|
|
|
#include "protos.h"
|
|
|
|
|
2008-03-04 04:22:27 +00:00
|
|
|
|
|
|
|
#define HOTKEY_FILENAME wxT( "gerbview" )
|
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
const wxString GerbviewProjectFileExt( wxT( "cnf" ) );
|
2009-05-21 17:42:42 +00:00
|
|
|
const wxString GerbviewProjectFileWildcard( _( "GerbView project files (.cnf)|*.cnf" ) );
|
2007-09-11 07:34:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
void WinEDA_GerberFrame::Process_Config( wxCommandEvent& event )
|
2007-09-11 07:34:46 +00:00
|
|
|
/*************************************************************/
|
|
|
|
{
|
2007-09-19 15:29:50 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
wxString FullFileName;
|
|
|
|
|
|
|
|
pos = GetPosition();
|
2008-03-04 04:22:27 +00:00
|
|
|
pos.x += 20;
|
|
|
|
pos.y += 20;
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
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:
|
2009-06-18 20:51:01 +00:00
|
|
|
case ID_PCB_DISPLAY_OPTIONS_SETUP:
|
2007-09-19 15:29:50 +00:00
|
|
|
case ID_OPTIONS_SETUP:
|
|
|
|
InstallPcbOptionsFrame( pos, id );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_SAVE:
|
|
|
|
Update_config();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_CREATE_CONFIG_HOTKEYS:
|
|
|
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2009-06-19 20:13:22 +00:00
|
|
|
FullFileName += wxT(".");
|
2007-09-19 15:29:50 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
|
|
|
WriteHotkeyConfigFile( FullFileName, s_Gerbview_Hokeys_Descr, true );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_READ_CONFIG_HOTKEYS:
|
|
|
|
Read_Hotkey_Config( this, true );
|
|
|
|
break;
|
|
|
|
|
2008-09-03 16:19:06 +00:00
|
|
|
case ID_PREFERENCES_EDIT_CONFIG_HOTKEYS:
|
|
|
|
{
|
|
|
|
FullFileName = ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice );
|
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2009-06-19 20:13:22 +00:00
|
|
|
FullFileName += wxT(".");
|
2008-09-03 16:19:06 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2008-12-08 15:27:13 +00:00
|
|
|
AddDelimiterString( FullFileName );
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
2008-09-03 16:19:06 +00:00
|
|
|
if( !editorname.IsEmpty() )
|
|
|
|
ExecuteFile( this, editorname, FullFileName );
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2008-09-03 16:19:06 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
2008-03-04 04:22:27 +00:00
|
|
|
HandleHotkeyConfigMenuSelection( this, id );
|
2007-09-19 15:29:50 +00:00
|
|
|
break;
|
|
|
|
|
2008-09-03 16:19:06 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST: // Display Current hotkey list for gerbview
|
|
|
|
DisplayHotkeyList( this, s_Gerbview_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
default:
|
2008-12-08 15:27:13 +00:00
|
|
|
DisplayError( this,
|
|
|
|
wxT( "WinEDA_GerberFrame::Process_Config internal error" ) );
|
2007-09-19 15:29:50 +00:00
|
|
|
}
|
2007-09-11 07:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
bool Read_Config()
|
2007-09-11 07:34:46 +00:00
|
|
|
/*****************************************************/
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
/* lit la configuration, si elle n'a pas deja etee lue
|
2008-12-08 15:27:13 +00:00
|
|
|
* 1 - lit gerbview.cnf
|
|
|
|
* 2 - si non trouve lit <chemin de gerbview.exe>/gerbview.cnf
|
|
|
|
* 3 - si non trouve: init des variables aux valeurs par defaut
|
2007-09-19 15:29:50 +00:00
|
|
|
*
|
2008-12-08 15:27:13 +00:00
|
|
|
* Retourne un pointeur su le message d'erreur a afficher
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxGetApp().ReadProjectConfig( wxT( "gerbview.cnf" ), GROUP, ParamCfgList,
|
2008-12-08 15:27:13 +00:00
|
|
|
FALSE );
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
/* Inits autres variables */
|
|
|
|
if( g_PhotoFilenameExt.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
g_PhotoFilenameExt = wxT( "pho" );
|
2007-09-19 15:29:50 +00:00
|
|
|
if( g_DrillFilenameExt.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
g_DrillFilenameExt = wxT( "drl" );
|
2007-09-19 15:29:50 +00:00
|
|
|
if( g_PenFilenameExt.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
g_PenFilenameExt = wxT( "pen" );
|
2007-09-19 15:29:50 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2007-09-11 07:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_GerberFrame::Update_config()
|
2007-09-11 07:34:46 +00:00
|
|
|
/******************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
/*
|
2008-12-08 15:27:13 +00:00
|
|
|
* creation du fichier de config
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn = wxFileName( wxEmptyString, wxT( "gerbview" ),
|
|
|
|
GerbviewProjectFileExt );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Save GerbView Project File" ), wxEmptyString,
|
|
|
|
fn.GetFullName(), GerbviewProjectFileWildcard,
|
|
|
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2007-09-19 15:29:50 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* ecriture de la configuration */
|
2009-04-05 20:49:15 +00:00
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP, ParamCfgList );
|
2007-09-11 07:34:46 +00:00
|
|
|
}
|
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
/***************************************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
|
2007-09-11 07:34:46 +00:00
|
|
|
/***************************************************************/
|
2007-09-19 15:29:50 +00:00
|
|
|
|
2007-09-11 07:34:46 +00:00
|
|
|
/*
|
|
|
|
* Read the hotkey files config for pcbnew and module_edit
|
2007-09-19 15:29:50 +00:00
|
|
|
*/
|
2007-09-11 07:34:46 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxString FullFileName = ReturnHotkeyConfigFilePath(
|
|
|
|
g_ConfigFileLocationChoice );
|
2007-09-11 07:34:46 +00:00
|
|
|
|
2007-09-19 15:29:50 +00:00
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2009-06-19 20:13:22 +00:00
|
|
|
FullFileName += wxT(".");
|
2007-09-19 15:29:50 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2008-12-08 15:27:13 +00:00
|
|
|
return frame->ReadHotkeyConfigFile( FullFileName,
|
|
|
|
s_Gerbview_Hokeys_Descr,
|
|
|
|
verbose );
|
2007-09-19 15:29:50 +00:00
|
|
|
}
|