2009-11-18 12:52:19 +00:00
|
|
|
/****************************************/
|
|
|
|
/** pcbnew_config.cpp : configuration **/
|
|
|
|
/****************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#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"
|
2009-07-30 11:04:07 +00:00
|
|
|
#include "wxPcbStruct.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbplot.h"
|
2009-10-27 19:30:32 +00:00
|
|
|
#include "pcbnew_config.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "worksheet.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h"
|
2007-09-06 11:52:26 +00:00
|
|
|
#include "hotkeys.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
#include "dialog_mask_clearance.h"
|
|
|
|
#include "dialog_general_options.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
#define HOTKEY_FILENAME wxT( "pcbnew" )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +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;
|
|
|
|
|
2009-10-18 23:22:26 +00:00
|
|
|
case ID_PCB_LAYERS_SETUP:
|
|
|
|
DisplayDialogLayerSetup( this );
|
|
|
|
break;
|
2009-09-17 17:48:40 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
case ID_CONFIG_REQ:
|
2008-02-19 00:35:45 +00:00
|
|
|
InstallConfigFrame( pos );
|
|
|
|
break;
|
|
|
|
|
2009-10-30 17:58:15 +00:00
|
|
|
case ID_PCB_MASK_CLEARANCE:
|
|
|
|
{
|
|
|
|
DIALOG_PADS_MASK_CLEARANCE dlg( this );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
case ID_OPTIONS_SETUP:
|
2009-10-30 17:58:15 +00:00
|
|
|
{
|
|
|
|
Dialog_GeneralOptions dlg( this, &dc );
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2008-02-19 00:35:45 +00:00
|
|
|
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-10-13 09:00:46 +00:00
|
|
|
msg.Printf( _( "File %s not found" ), GetChars( dlg.GetPath() ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
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;
|
|
|
|
}
|
2009-10-27 13:48:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
|
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;
|
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
|
2008-02-19 00:35:45 +00:00
|
|
|
Read_Hotkey_Config( this, true );
|
|
|
|
break;
|
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG:
|
2008-02-19 00:35:45 +00:00
|
|
|
{
|
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
|
|
|
/*
|
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
|
|
|
*/
|
2009-11-18 12:52:19 +00:00
|
|
|
bool Read_Hotkey_Config( WinEDA_DrawFrame* frame, bool verbose )
|
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;
|
2009-06-19 20:13:22 +00:00
|
|
|
FullFileName += wxT(".");
|
2008-02-19 00:35:45 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
2009-10-21 19:16:25 +00:00
|
|
|
/** Function Read_Config
|
|
|
|
* Read the project configuration file
|
|
|
|
* @param projectFileName = the config filename
|
|
|
|
* if not found use kicad.pro
|
|
|
|
* if not found : initialize default values
|
|
|
|
* @return true if the current config is modified, false if no change
|
2008-02-19 00:35:45 +00:00
|
|
|
*/
|
2009-10-21 19:16:25 +00:00
|
|
|
bool WinEDA_PcbFrame::Read_Config( const wxString& projectFileName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn = projectFileName;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.GetExt() != ProjectFileExtension )
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
wxGetApp().RemoveLibraryPath( g_UserLibDirBuffer );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-11-18 12:52:19 +00:00
|
|
|
/* Initialize default values. */
|
2008-02-19 00:35:45 +00:00
|
|
|
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-10-21 19:16:25 +00:00
|
|
|
/* Reset the items visibility flag when loading a new config
|
2009-10-10 01:25:53 +00:00
|
|
|
* Because it could creates SERIOUS mistakes for the user,
|
2009-06-04 19:39:50 +00:00
|
|
|
* if some items are not visible after loading a board...
|
2009-10-10 01:25:53 +00:00
|
|
|
*/
|
2009-11-12 12:54:56 +00:00
|
|
|
g_DesignSettings.SetVisibleLayers( FULL_LAYERS );
|
2009-10-10 01:25:53 +00:00
|
|
|
|
2009-06-04 19:39:50 +00:00
|
|
|
DisplayOpt.Show_Modules_Cmp = true;
|
|
|
|
DisplayOpt.Show_Modules_Cu = true;
|
2009-10-10 01:25:53 +00:00
|
|
|
g_DesignSettings.SetElementVisibility( MODULE_TEXT_NOV_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( MODULE_TEXT_CMP_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( MODULE_TEXT_CU_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( PAD_CMP_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( PAD_CU_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( VIA_THROUGH_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( VIA_BLIND_BURIED_VISIBLE, true );
|
|
|
|
g_DesignSettings.SetElementVisibility( VIA_MICROVIA_VISIBLE, true );
|
2009-10-21 19:16:25 +00:00
|
|
|
|
|
|
|
// Items that can remain not visible: comment them if you want.
|
2009-10-10 01:25:53 +00:00
|
|
|
g_DesignSettings.SetElementVisibility( ANCHOR_VISIBLE, true );
|
|
|
|
|
2009-06-04 19:39:50 +00:00
|
|
|
DisplayOpt.DisplayPadNoConn = true;
|
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
|
|
|
|
|
|
|
void WinEDA_PcbFrame::Update_config( wxWindow* displayframe )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
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;
|
|
|
|
|
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
|
|
|
}
|