2009-11-03 13:26:31 +00:00
|
|
|
/******************/
|
|
|
|
/** eeconfig.cpp **/
|
|
|
|
/******************/
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-01-29 14:26:20 +00:00
|
|
|
#include "gr_basic.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "eeschema_id.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 "program.h"
|
|
|
|
#include "general.h"
|
|
|
|
#include "protos.h"
|
2009-10-27 19:30:32 +00:00
|
|
|
#include "eeschema_config.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "worksheet.h"
|
2007-09-06 11:52:26 +00:00
|
|
|
#include "hotkeys.h"
|
2009-12-01 15:14:18 +00:00
|
|
|
#include "dialog_eeschema_options.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
#define HOTKEY_FILENAME wxT( "eeschema" )
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
void WinEDA_SchematicFrame::Process_Config( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxPoint pos;
|
|
|
|
wxFileName fn;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
wxGetMousePosition( &pos.x, &pos.y );
|
|
|
|
|
|
|
|
pos.y += 5;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
|
|
|
case ID_COLORS_SETUP:
|
|
|
|
DisplayColorSetupFrame( this, pos );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case ID_CONFIG_REQ: // Display the configuration window.
|
2008-02-26 19:19:54 +00:00
|
|
|
InstallConfigFrame( pos );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_SAVE:
|
2010-01-08 12:28:13 +00:00
|
|
|
SaveProjectFile( this, false );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
|
|
|
wxFileDialog dlg( this, _( "Read Project File" ), fn.GetPath(),
|
|
|
|
fn.GetFullName(), ProjectFileWildcard,
|
|
|
|
wxFD_OPEN | wxFD_FILE_MUST_EXIST );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
LoadProjectFile( fn.GetFullPath(), TRUE );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
|
|
|
|
/* Hotkey IDs */
|
|
|
|
case ID_PREFERENCES_HOTKEY_CREATE_CONFIG:
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
|
|
|
|
HOTKEY_FILENAME,
|
|
|
|
DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
WriteHotkeyConfigFile( fn.GetFullPath(), s_Eeschema_Hokeys_Descr, true );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_READ_CONFIG:
|
2008-02-26 19:19:54 +00:00
|
|
|
Read_Hotkey_Config( this, true );
|
|
|
|
break;
|
|
|
|
|
2009-10-27 13:48:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_EDIT_CONFIG:
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = wxFileName( ReturnHotkeyConfigFilePath( g_ConfigFileLocationChoice ),
|
|
|
|
HOTKEY_FILENAME, DEFAULT_HOTKEY_FILENAME_EXT );
|
|
|
|
wxString editorname = wxGetApp().GetEditorName();
|
2008-02-26 19:19:54 +00:00
|
|
|
if( !editorname.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
ExecuteFile( this, editorname, QuoteFullPath( fn ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
break;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_HOME:
|
|
|
|
case ID_PREFERENCES_HOTKEY_PATH_IS_KICAD:
|
|
|
|
HandleHotkeyConfigMenuSelection( this, id );
|
|
|
|
break;
|
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
|
|
|
// Display current hotkey list for eeschema.
|
2008-02-26 19:19:54 +00:00
|
|
|
DisplayHotkeyList( this, s_Schematic_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-05-21 17:42:42 +00:00
|
|
|
DisplayError( this, wxT( "WinEDA_SchematicFrame::Process_Config internal error" ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-01 15:14:18 +00:00
|
|
|
void WinEDA_SchematicFrame::OnSetOptions( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
wxArrayString units;
|
|
|
|
GridArray& grid_list = GetBaseScreen()->m_GridList;
|
|
|
|
|
|
|
|
DIALOG_EESCHEMA_OPTIONS dlg( this );
|
|
|
|
|
2009-12-02 09:59:49 +00:00
|
|
|
wxLogDebug( wxT( "Current grid array index %d." ),
|
2009-12-01 15:14:18 +00:00
|
|
|
grid_list.Index( GetBaseScreen()->GetGrid() ) );
|
|
|
|
units.Add( GetUnitsLabel( INCHES ) );
|
|
|
|
units.Add( GetUnitsLabel( MILLIMETRE ) );
|
|
|
|
|
|
|
|
dlg.SetUnits( units, g_UnitMetric );
|
|
|
|
dlg.SetGridSizes( grid_list, GetBaseScreen()->GetGridId() );
|
|
|
|
dlg.SetLineWidth( g_DrawDefaultLineThickness );
|
|
|
|
dlg.SetTextSize( g_DefaultTextLabelSize );
|
|
|
|
dlg.SetRepeatHorizontal( g_RepeatStep.x );
|
|
|
|
dlg.SetRepeatVertical( g_RepeatStep.y );
|
|
|
|
dlg.SetRepeatLabel( g_RepeatDeltaLabel );
|
2010-02-01 21:23:27 +00:00
|
|
|
dlg.SetShowGrid( IsGridVisible() );
|
2009-12-01 15:14:18 +00:00
|
|
|
dlg.SetShowHiddenPins( m_ShowAllPins );
|
|
|
|
dlg.SetEnableAutoPan( DrawPanel->m_AutoPAN_Enable );
|
2010-02-12 17:15:47 +00:00
|
|
|
dlg.SetEnableHVBusOrientation( g_HVLines );
|
2009-12-01 15:14:18 +00:00
|
|
|
dlg.SetShowPageLimits( g_ShowPageLimits );
|
|
|
|
dlg.Layout();
|
|
|
|
dlg.Fit();
|
|
|
|
dlg.SetMinSize( dlg.GetSize() );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
g_UnitMetric = dlg.GetUnitsSelection();
|
|
|
|
GetBaseScreen()->SetGrid(
|
|
|
|
grid_list[ (size_t) dlg.GetGridSelection() ].m_Size );
|
|
|
|
g_DrawDefaultLineThickness = dlg.GetLineWidth();
|
|
|
|
g_DefaultTextLabelSize = dlg.GetTextSize();
|
|
|
|
g_RepeatStep.x = dlg.GetRepeatHorizontal();
|
|
|
|
g_RepeatStep.y = dlg.GetRepeatVertical();
|
|
|
|
g_RepeatDeltaLabel = dlg.GetRepeatLabel();
|
2010-02-01 21:23:27 +00:00
|
|
|
SetGridVisibility( dlg.GetShowGrid() );
|
2009-12-01 15:14:18 +00:00
|
|
|
m_ShowAllPins = dlg.GetShowHiddenPins();
|
|
|
|
DrawPanel->m_AutoPAN_Enable = dlg.GetEnableAutoPan();
|
2010-02-12 19:15:58 +00:00
|
|
|
g_HVLines = dlg.GetEnableHVBusOrientation();
|
2009-12-01 15:14:18 +00:00
|
|
|
g_ShowPageLimits = dlg.GetShowPageLimits();
|
|
|
|
DrawPanel->Refresh( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 19:37:31 +00:00
|
|
|
/*
|
|
|
|
* Read the hotkey files config for eeschema and libedit
|
2008-02-26 19:19:54 +00:00
|
|
|
*/
|
2009-04-29 17:09:00 +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 );
|
2007-08-23 01:40:50 +00:00
|
|
|
|
2008-02-26 19:19:54 +00:00
|
|
|
FullFileName += HOTKEY_FILENAME;
|
2009-12-01 15:14:18 +00:00
|
|
|
FullFileName += wxT( "." );
|
2008-02-26 19:19:54 +00:00
|
|
|
FullFileName += DEFAULT_HOTKEY_FILENAME_EXT;
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->ReadHotkeyConfigFile( FullFileName,
|
|
|
|
s_Eeschema_Hokeys_Descr,
|
|
|
|
verbose );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2007-08-21 19:37:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
/**
|
|
|
|
* Return project file parameter list for EESchema.
|
2008-02-26 19:19:54 +00:00
|
|
|
*
|
2009-04-29 17:09:00 +00:00
|
|
|
* Populate the project file parameter array specific to EESchema if it hasn't
|
|
|
|
* already been populated and return a reference to the array to the caller.
|
|
|
|
* Creating the parameter list at run time has the advantage of being able
|
|
|
|
* to define local variables. The old method of statically building the array
|
|
|
|
* at compile time requiring global variable definitions.
|
|
|
|
*/
|
2009-05-21 17:42:42 +00:00
|
|
|
PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetProjectFileParameters( void )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( !m_projectFileParams.empty() )
|
2009-04-29 17:09:00 +00:00
|
|
|
return m_projectFileParams;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "LibDir" ),
|
|
|
|
&m_UserLibraryPath ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
|
|
|
|
&m_ComponentLibFiles,
|
|
|
|
GROUPLIB ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "NetFmt" ),
|
|
|
|
&m_NetlistFormat,
|
|
|
|
NET_TYPE_PCBNEW,
|
|
|
|
NET_TYPE_PCBNEW,
|
|
|
|
NET_TYPE_CUSTOM_MAX ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
/* NOTE: Left as global until supporting code can be fixed. */
|
2009-05-21 17:42:42 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLSpd" ),
|
|
|
|
&g_HPGL_Pen_Descr.m_Pen_Speed,
|
|
|
|
20, 2, 45 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLDm" ),
|
|
|
|
&g_HPGL_Pen_Descr.m_Pen_Diam,
|
|
|
|
15, 1, 150 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "HPGLNum" ),
|
|
|
|
&g_HPGL_Pen_Descr.m_Pen_Num,
|
|
|
|
1, 1, 8 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A4" ),
|
|
|
|
&g_Sheet_A4.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A4" ),
|
|
|
|
&g_Sheet_A4.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A3" ),
|
|
|
|
&g_Sheet_A3.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A3" ),
|
|
|
|
&g_Sheet_A3.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A2" ),
|
|
|
|
&g_Sheet_A2.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A2" ),
|
|
|
|
&g_Sheet_A2.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A1" ),
|
|
|
|
&g_Sheet_A1.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A1" ),
|
|
|
|
&g_Sheet_A1.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A0" ),
|
|
|
|
&g_Sheet_A0.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A0" ),
|
|
|
|
&g_Sheet_A0.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_A" ),
|
|
|
|
&g_Sheet_A.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_A" ),
|
|
|
|
&g_Sheet_A.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_B" ),
|
|
|
|
&g_Sheet_B.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_B" ),
|
|
|
|
&g_Sheet_B.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_C" ),
|
|
|
|
&g_Sheet_C.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_C" ),
|
|
|
|
&g_Sheet_C.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_D" ),
|
|
|
|
&g_Sheet_D.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_D" ),
|
|
|
|
&g_Sheet_D.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offX_E" ),
|
|
|
|
&g_Sheet_E.m_Offset.x ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "offY_E" ),
|
|
|
|
&g_Sheet_E.m_Offset.y ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptD_X" ),
|
|
|
|
&g_RepeatStep.x,
|
|
|
|
0, -1000, +1000 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptD_Y" ),
|
|
|
|
&g_RepeatStep.y,
|
|
|
|
100, -1000, +1000 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "RptLab" ),
|
|
|
|
&g_RepeatDeltaLabel,
|
|
|
|
1, -10, +10 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "SimCmd" ),
|
|
|
|
&g_SimulatorCommandLine ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "UseNetN" ),
|
|
|
|
&g_OptNetListUseNames,
|
|
|
|
0, 0, 1 ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "LabSize" ),
|
|
|
|
&g_DefaultTextLabelSize,
|
|
|
|
DEFAULT_SIZE_TEXT, 0,
|
|
|
|
1000 ) );
|
2010-02-02 15:01:09 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "PrintMonochrome" ),
|
|
|
|
&m_printMonochrome, true ) );
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_BOOL( wxT( "ShowSheetReferenceAndTitleBlock" ),
|
|
|
|
&m_showSheetReference, true ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
return m_projectFileParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the Kicad project file (*.pro) settings specific to EESchema.
|
2008-02-26 19:19:54 +00:00
|
|
|
*/
|
2009-04-29 17:09:00 +00:00
|
|
|
bool WinEDA_SchematicFrame::LoadProjectFile( const wxString& CfgFileName,
|
|
|
|
bool ForceRereadConfig )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2008-12-08 15:27:13 +00:00
|
|
|
bool IsRead = TRUE;
|
2009-04-29 17:09:00 +00:00
|
|
|
wxArrayString liblist_tmp = m_ComponentLibFiles;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
if( CfgFileName.IsEmpty() )
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName;
|
2008-02-26 19:19:54 +00:00
|
|
|
else
|
2009-04-05 20:49:15 +00:00
|
|
|
fn = CfgFileName;
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
m_ComponentLibFiles.Clear();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
/* Change the schematic file extension (.sch) to the project file
|
|
|
|
* extension (.pro). */
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
wxGetApp().RemoveLibraryPath( m_UserLibraryPath );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
if( !wxGetApp().ReadProjectConfig( fn.GetFullPath(), GROUP,
|
|
|
|
GetProjectFileParameters(),
|
2009-04-05 20:49:15 +00:00
|
|
|
ForceRereadConfig ? FALSE : TRUE ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
m_ComponentLibFiles = liblist_tmp;
|
2008-02-26 19:19:54 +00:00
|
|
|
IsRead = FALSE;
|
|
|
|
}
|
|
|
|
|
2009-04-09 18:39:39 +00:00
|
|
|
/* User library path takes precedent over default library search paths. */
|
2009-04-29 17:09:00 +00:00
|
|
|
wxGetApp().InsertLibraryPath( m_UserLibraryPath, 1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-11-03 13:26:31 +00:00
|
|
|
/* If the list is void, force loadind the library "power.lib" that is
|
|
|
|
* the "standard" library for power symbols.
|
|
|
|
*/
|
2009-04-29 17:09:00 +00:00
|
|
|
if( m_ComponentLibFiles.GetCount() == 0 )
|
|
|
|
m_ComponentLibFiles.Add( wxT( "power" ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2009-09-18 14:56:05 +00:00
|
|
|
LoadLibraries();
|
2009-10-14 19:43:31 +00:00
|
|
|
GetBaseScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
return IsRead;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
/*
|
|
|
|
* Save the Kicad project file (*.pro) settings specific to EESchema.
|
|
|
|
*/
|
2010-01-08 12:28:13 +00:00
|
|
|
void WinEDA_SchematicFrame::SaveProjectFile( wxWindow* displayframe, bool askoverwrite )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
fn = g_RootSheet->m_AssociatedScreen->m_FileName /*ConfigFileName*/;
|
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2010-01-08 12:28:13 +00:00
|
|
|
int options = wxFD_SAVE;
|
|
|
|
if( askoverwrite )
|
|
|
|
options |= wxFD_OVERWRITE_PROMPT;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileDialog dlg( this, _( "Save Project Settings" ), wxGetCwd(),
|
2010-01-08 12:28:13 +00:00
|
|
|
fn.GetFullName(), ProjectFileWildcard, options );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
|
|
|
|
GetProjectFileParameters() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
static const wxString DefaultDrawLineWidthEntry( wxT( "DefaultDrawLineWidth" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
static const wxString ShowHiddenPinsEntry( wxT( "ShowHiddenPins" ) );
|
2009-05-01 18:06:03 +00:00
|
|
|
static const wxString HorzVertLinesOnlyEntry( wxT( "HorizVertLinesOnly" ) );
|
2010-02-02 15:01:09 +00:00
|
|
|
static const wxString PreviewFramePositionXEntry( wxT( "PreviewFramePositionX" ) );
|
|
|
|
static const wxString PreviewFramePositionYEntry( wxT( "PreviewFramePositionY" ) );
|
|
|
|
static const wxString PreviewFrameWidthEntry( wxT( "PreviewFrameWidth" ) );
|
|
|
|
static const wxString PreviewFrameHeightEntry( wxT( "PreviewFrameHeight" ) );
|
|
|
|
static const wxString PrintDialogPositionXEntry( wxT( "PrintDialogPositionX" ) );
|
|
|
|
static const wxString PrintDialogPositionYEntry( wxT( "PrintDialogPositionY" ) );
|
|
|
|
static const wxString PrintDialogWidthEntry( wxT( "PrintDialogWidth" ) );
|
|
|
|
static const wxString PrintDialogHeightEntry( wxT( "PrintDialogHeight" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the EESchema applications settings list.
|
|
|
|
*
|
|
|
|
* This replaces the old statically define list that had the project
|
|
|
|
* file settings and the application settings mixed together. This
|
|
|
|
* was confusing and caused some settings to get saved and loaded
|
|
|
|
* incorrectly. Currently, only the settings that are needed at start
|
|
|
|
* up by the main window are defined here. There are other locally used
|
|
|
|
* settings scattered thoughout the EESchema source code. If you need
|
|
|
|
* to define a configuration setting that need to be loaded at run time,
|
|
|
|
* this is the place to define it.
|
|
|
|
*
|
|
|
|
* TODO: Define the configuration variables as member variables instead of
|
|
|
|
* global variables or move them to the object class where they are
|
|
|
|
* used.
|
|
|
|
*/
|
2009-05-21 17:42:42 +00:00
|
|
|
PARAM_CFG_ARRAY& WinEDA_SchematicFrame::GetConfigurationSettings( void )
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2009-05-21 17:42:42 +00:00
|
|
|
if( !m_configSettings.empty() )
|
2009-04-29 17:09:00 +00:00
|
|
|
return m_configSettings;
|
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Unite" ),
|
|
|
|
&g_UnitMetric, 0, 0, 1 ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColWire" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_WIRE],
|
|
|
|
GREEN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBus" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_BUS],
|
|
|
|
BLUE ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConn" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_JUNCTION],
|
|
|
|
GREEN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLlab" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_LOCLABEL],
|
|
|
|
BLACK ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHlab" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_HIERLABEL],
|
|
|
|
BROWN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGbllab" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_GLOBLABEL],
|
|
|
|
RED ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinF" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_PINFUN],
|
|
|
|
MAGENTA ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColPinN" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_PINNUM],
|
|
|
|
RED ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPNam" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_PINNAM],
|
|
|
|
CYAN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorField" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_FIELDS],
|
|
|
|
MAGENTA ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorRef" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_REFERENCEPART],
|
|
|
|
CYAN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValue" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_VALUEPART],
|
|
|
|
CYAN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNote" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_NOTES],
|
|
|
|
LIGHTBLUE ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBody" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_DEVICE],
|
|
|
|
RED ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBg" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_DEVICE_BACKGROUND],
|
|
|
|
LIGHTYELLOW ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetN" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_NETNAM],
|
|
|
|
DARKGRAY ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPin" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_PIN],
|
|
|
|
RED ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheet" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_SHEET],
|
|
|
|
MAGENTA ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
|
|
|
|
wxT( "ColorSheetFileName" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_SHEETFILENAME],
|
|
|
|
BROWN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetName" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_SHEETNAME],
|
|
|
|
CYAN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLab" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_SHEETLABEL],
|
|
|
|
BROWN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoCo" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_NOCONNECT],
|
|
|
|
BLUE ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcW" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_ERC_WARN],
|
|
|
|
GREEN ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcE" ),
|
|
|
|
&g_LayerDescr.LayerColor[LAYER_ERC_ERR],
|
|
|
|
RED ) );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
return m_configSettings;
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Load the EESchema configuration parameters.
|
|
|
|
*/
|
|
|
|
void WinEDA_SchematicFrame::LoadSettings()
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
long tmp;
|
|
|
|
|
2009-04-29 17:09:00 +00:00
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
WinEDA_DrawFrame::LoadSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2009-12-01 15:14:18 +00:00
|
|
|
g_DrawDefaultLineThickness = cfg->Read( DefaultDrawLineWidthEntry,
|
|
|
|
(long) 6 );
|
2009-04-29 17:09:00 +00:00
|
|
|
cfg->Read( ShowHiddenPinsEntry, &m_ShowAllPins, false );
|
2009-05-01 18:06:03 +00:00
|
|
|
cfg->Read( HorzVertLinesOnlyEntry, &g_HVLines, true );
|
2010-02-02 15:01:09 +00:00
|
|
|
cfg->Read( PreviewFramePositionXEntry, &tmp, -1 );
|
|
|
|
m_previewPosition.x = (int) tmp;
|
|
|
|
cfg->Read( PreviewFramePositionYEntry, &tmp, -1 );
|
|
|
|
m_previewPosition.y = (int) tmp;
|
|
|
|
cfg->Read( PreviewFrameWidthEntry, &tmp, -1 );
|
|
|
|
m_previewSize.SetWidth( (int) tmp );
|
|
|
|
cfg->Read( PreviewFrameHeightEntry, &tmp, -1 );
|
|
|
|
m_previewSize.SetHeight( (int) tmp );
|
|
|
|
|
|
|
|
cfg->Read( PrintDialogPositionXEntry, &tmp, -1 );
|
|
|
|
m_printDialogPosition.x = (int) tmp;
|
|
|
|
cfg->Read( PrintDialogPositionYEntry, &tmp, -1 );
|
|
|
|
m_printDialogPosition.y = (int) tmp;
|
|
|
|
cfg->Read( PrintDialogWidthEntry, &tmp, -1 );
|
|
|
|
m_printDialogSize.SetWidth( (int) tmp );
|
|
|
|
cfg->Read( PrintDialogHeightEntry, &tmp, -1 );
|
|
|
|
m_printDialogSize.SetHeight( (int) tmp );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Save the EESchema configuration parameters.
|
|
|
|
*/
|
|
|
|
void WinEDA_SchematicFrame::SaveSettings()
|
|
|
|
{
|
2009-04-29 17:09:00 +00:00
|
|
|
wxASSERT( wxGetApp().m_EDA_Config != NULL );
|
|
|
|
|
|
|
|
wxConfig* cfg = wxGetApp().m_EDA_Config;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
WinEDA_DrawFrame::SaveSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2009-06-02 07:26:49 +00:00
|
|
|
cfg->Write( DefaultDrawLineWidthEntry, (long) g_DrawDefaultLineThickness );
|
2009-04-29 17:09:00 +00:00
|
|
|
cfg->Write( ShowHiddenPinsEntry, m_ShowAllPins );
|
2009-05-01 18:06:03 +00:00
|
|
|
cfg->Write( HorzVertLinesOnlyEntry, g_HVLines );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
|
|
|
cfg->Write( PreviewFramePositionXEntry, m_previewPosition.x );
|
|
|
|
cfg->Write( PreviewFramePositionYEntry, m_previewPosition.y );
|
|
|
|
cfg->Write( PreviewFrameWidthEntry, m_previewSize.GetWidth() );
|
|
|
|
cfg->Write( PreviewFrameHeightEntry, m_previewSize.GetHeight() );
|
|
|
|
|
|
|
|
cfg->Write( PrintDialogPositionXEntry, m_printDialogPosition.x );
|
|
|
|
cfg->Write( PrintDialogPositionYEntry, m_printDialogPosition.y );
|
|
|
|
cfg->Write( PrintDialogWidthEntry, m_printDialogSize.GetWidth() );
|
|
|
|
cfg->Write( PrintDialogHeightEntry, m_printDialogSize.GetHeight() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|