2011-02-26 08:35:22 +00:00
|
|
|
/**
|
|
|
|
* @file eeschema_config.cpp
|
|
|
|
*/
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2012-02-16 20:03:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
#include <wxEeschemaStruct.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <eeschema_id.h>
|
|
|
|
#include <general.h>
|
|
|
|
#include <libeditframe.h>
|
|
|
|
#include <eeschema_config.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
#include <sch_sheet.h>
|
2013-05-22 08:45:25 +00:00
|
|
|
#include <class_libentry.h>
|
2013-07-19 18:27:22 +00:00
|
|
|
#include <worksheet_shape_builder.h>
|
2010-11-10 15:30:12 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialog_hotkeys_editor.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <dialogs/dialog_color_config.h>
|
|
|
|
#include <dialogs/dialog_eeschema_config.h>
|
|
|
|
#include <dialogs/dialog_eeschema_options.h>
|
|
|
|
#include <dialogs/dialog_schematic_find.h>
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-02-16 20:03:33 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
#define HOTKEY_FILENAME wxT( "eeschema" )
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
#define FR_HISTORY_LIST_CNT 10 ///< Maximum number of find and replace strings.
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2013-04-06 05:01:48 +00:00
|
|
|
static EDA_COLOR_T s_layerColor[NB_SCH_LAYERS];
|
2012-09-28 17:47:41 +00:00
|
|
|
|
|
|
|
// The width to draw busses that do not have a specific width
|
|
|
|
static int s_defaultBusThickness;
|
|
|
|
|
|
|
|
int GetDefaultBusThickness()
|
|
|
|
{
|
|
|
|
return s_defaultBusThickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDefaultBusThickness( int aThickness)
|
|
|
|
{
|
2013-04-06 05:01:48 +00:00
|
|
|
if( aThickness >= 1 )
|
2012-09-28 17:47:41 +00:00
|
|
|
s_defaultBusThickness = aThickness;
|
|
|
|
else
|
|
|
|
s_defaultBusThickness = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Default line (in Eeschema units) thickness used to draw/plot items having a
|
|
|
|
* default thickness line value (i.e. = 0 ).
|
|
|
|
*/
|
|
|
|
static int s_drawDefaultLineThickness;
|
|
|
|
|
|
|
|
int GetDefaultLineThickness()
|
|
|
|
{
|
|
|
|
return s_drawDefaultLineThickness;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDefaultLineThickness( int aThickness)
|
|
|
|
{
|
|
|
|
if( aThickness >=1 )
|
|
|
|
s_drawDefaultLineThickness = aThickness;
|
|
|
|
else
|
|
|
|
s_drawDefaultLineThickness = 1;
|
|
|
|
}
|
|
|
|
|
2013-04-06 05:01:48 +00:00
|
|
|
EDA_COLOR_T GetLayerColor( LayerNumber aLayer )
|
2012-09-28 17:47:41 +00:00
|
|
|
{
|
|
|
|
return s_layerColor[aLayer];
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLayerColor( EDA_COLOR_T aColor, int aLayer )
|
|
|
|
{
|
|
|
|
s_layerColor[aLayer] = aColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Color to draw selected items
|
|
|
|
EDA_COLOR_T GetItemSelectedColor()
|
|
|
|
{
|
|
|
|
return BROWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Color to draw items flagged invisible, in libedit (they are invisible
|
|
|
|
// in Eeschema
|
|
|
|
EDA_COLOR_T GetInvisibleItemColor()
|
|
|
|
{
|
|
|
|
return DARKGRAY;
|
|
|
|
}
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
|
|
|
|
void LIB_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
|
|
|
|
{
|
2010-12-08 20:12:46 +00:00
|
|
|
DIALOG_EESCHEMA_CONFIG CfgFrame( (SCH_EDIT_FRAME *)GetParent(), this );
|
2010-11-19 16:28:46 +00:00
|
|
|
|
|
|
|
CfgFrame.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-02 21:41:56 +00:00
|
|
|
void LIB_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
|
|
|
|
{
|
|
|
|
DIALOG_COLOR_CONFIG dlg( this );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
void LIB_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
int id = event.GetId();
|
|
|
|
wxFileName fn;
|
2010-12-08 20:12:46 +00:00
|
|
|
SCH_EDIT_FRAME* schFrame = ( SCH_EDIT_FRAME* ) GetParent();
|
2008-02-26 19:19:54 +00:00
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2010-03-20 19:57:59 +00:00
|
|
|
case ID_CONFIG_SAVE:
|
2013-07-19 18:27:22 +00:00
|
|
|
schFrame->SaveProjectSettings( false );
|
2010-03-20 19:57:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2010-03-20 19:57:59 +00:00
|
|
|
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 )
|
|
|
|
break;
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
schFrame->LoadProjectFile( dlg.GetPath(), true );
|
2010-03-20 19:57:59 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Hotkey IDs
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
|
|
|
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
|
2010-03-20 19:57:59 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
|
|
|
|
ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
|
2010-03-20 19:57:59 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
|
|
|
|
ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
|
2010-03-20 19:57:59 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_CURRENT_LIST:
|
|
|
|
// Display current hotkey list for LibEdit.
|
|
|
|
DisplayHotkeyList( this, s_Libedit_Hokeys_Descr );
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2010-11-19 16:28:46 +00:00
|
|
|
DisplayError( this, wxT( "LIB_EDIT_FRAME::Process_Config error" ) );
|
2010-03-20 19:57:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnColorConfig( wxCommandEvent& aEvent )
|
2010-12-02 21:41:56 +00:00
|
|
|
{
|
|
|
|
DIALOG_COLOR_CONFIG dlg( this );
|
|
|
|
|
|
|
|
dlg.ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::InstallConfigFrame( wxCommandEvent& event )
|
2010-11-19 16:28:46 +00:00
|
|
|
{
|
|
|
|
DIALOG_EESCHEMA_CONFIG CfgFrame( this, this );
|
|
|
|
|
|
|
|
CfgFrame.ShowModal();
|
|
|
|
}
|
|
|
|
|
2010-03-20 19:57:59 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::Process_Config( wxCommandEvent& event )
|
2010-03-20 19:57:59 +00:00
|
|
|
{
|
|
|
|
int id = event.GetId();
|
|
|
|
wxFileName fn;
|
|
|
|
|
|
|
|
switch( id )
|
|
|
|
{
|
2008-02-26 19:19:54 +00:00
|
|
|
case ID_CONFIG_SAVE:
|
2013-07-19 18:27:22 +00:00
|
|
|
SaveProjectSettings( false );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_CONFIG_READ:
|
|
|
|
{
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2009-04-05 20:49:15 +00:00
|
|
|
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
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
LoadProjectFile( dlg.GetPath(), 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
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Hotkey IDs
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_EXPORT_CONFIG:
|
|
|
|
ExportHotkeyConfigToFile( s_Eeschema_Hokeys_Descr );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_IMPORT_CONFIG:
|
|
|
|
ImportHotkeyConfigFromFile( s_Eeschema_Hokeys_Descr );
|
2008-02-26 19:19:54 +00:00
|
|
|
break;
|
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
case ID_PREFERENCES_HOTKEY_SHOW_EDITOR:
|
|
|
|
InstallHotkeyFrame( this, s_Eeschema_Hokeys_Descr );
|
2008-02-26 19:19:54 +00:00
|
|
|
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:
|
2010-12-08 20:12:46 +00:00
|
|
|
DisplayError( this, wxT( "SCH_EDIT_FRAME::Process_Config error" ) );
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::OnSetOptions( wxCommandEvent& event )
|
2009-12-01 15:14:18 +00:00
|
|
|
{
|
|
|
|
wxArrayString units;
|
2010-12-08 20:12:46 +00:00
|
|
|
GRIDS grid_list;
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
GetScreen()->GetGrids( grid_list );
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
DIALOG_EESCHEMA_OPTIONS dlg( this );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2009-12-01 15:14:18 +00:00
|
|
|
units.Add( GetUnitsLabel( INCHES ) );
|
2010-07-12 14:07:09 +00:00
|
|
|
units.Add( GetUnitsLabel( MILLIMETRES ) );
|
2009-12-01 15:14:18 +00:00
|
|
|
|
2010-07-12 14:07:09 +00:00
|
|
|
dlg.SetUnits( units, g_UserUnit );
|
2011-02-05 02:21:11 +00:00
|
|
|
dlg.SetGridSizes( grid_list, GetScreen()->GetGridId() );
|
2012-09-28 17:47:41 +00:00
|
|
|
dlg.SetBusWidth( GetDefaultBusThickness() );
|
|
|
|
dlg.SetLineWidth( GetDefaultLineThickness() );
|
|
|
|
dlg.SetTextSize( GetDefaultLabelSize() );
|
2009-12-01 15:14:18 +00:00
|
|
|
dlg.SetRepeatHorizontal( g_RepeatStep.x );
|
|
|
|
dlg.SetRepeatVertical( g_RepeatStep.y );
|
|
|
|
dlg.SetRepeatLabel( g_RepeatDeltaLabel );
|
2011-10-15 13:25:57 +00:00
|
|
|
dlg.SetAutoSaveInterval( GetAutoSaveInterval() / 60 );
|
2013-05-22 08:45:25 +00:00
|
|
|
dlg.SetRefIdSeparator( LIB_COMPONENT::GetSubpartIdSeparator( ),
|
|
|
|
LIB_COMPONENT::GetSubpartFirstId() );
|
|
|
|
|
2010-02-01 21:23:27 +00:00
|
|
|
dlg.SetShowGrid( IsGridVisible() );
|
2011-12-09 16:37:11 +00:00
|
|
|
dlg.SetShowHiddenPins( m_showAllPins );
|
2012-04-11 18:54:20 +00:00
|
|
|
dlg.SetEnableMiddleButtonPan( m_canvas->GetEnableMiddleButtonPan() );
|
2013-02-02 19:10:48 +00:00
|
|
|
dlg.SetEnableZoomNoCenter( m_canvas->GetEnableZoomNoCenter() );
|
2012-04-11 18:54:20 +00:00
|
|
|
dlg.SetMiddleButtonPanLimited( m_canvas->GetMiddleButtonPanLimited() );
|
2011-12-29 20:11:42 +00:00
|
|
|
dlg.SetEnableAutoPan( m_canvas->GetEnableAutoPan() );
|
2012-09-28 17:47:41 +00:00
|
|
|
dlg.SetEnableHVBusOrientation( GetForceHVLines() );
|
2009-12-01 15:14:18 +00:00
|
|
|
dlg.SetShowPageLimits( g_ShowPageLimits );
|
|
|
|
dlg.Layout();
|
|
|
|
dlg.Fit();
|
|
|
|
dlg.SetMinSize( dlg.GetSize() );
|
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
const TEMPLATE_FIELDNAMES& tfnames = m_TemplateFieldNames.GetTemplateFieldNames();
|
|
|
|
|
|
|
|
for( unsigned i=0; i<tfnames.size(); ++i )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
D(printf("dlg.SetFieldName(%d, '%s')\n", i, TO_UTF8( tfnames[i].m_Name) );)
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
dlg.SetFieldName( i, tfnames[i].m_Name );
|
|
|
|
}
|
|
|
|
|
2009-12-01 15:14:18 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
2011-09-06 19:42:46 +00:00
|
|
|
g_UserUnit = (EDA_UNITS_T)dlg.GetUnitsSelection();
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2011-02-05 02:21:11 +00:00
|
|
|
GetScreen()->SetGrid( grid_list[ (size_t) dlg.GetGridSelection() ].m_Size );
|
2010-06-17 16:30:10 +00:00
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
int sep, firstId;
|
|
|
|
dlg.GetRefIdSeparator( sep, firstId);
|
|
|
|
if( sep != (int)LIB_COMPONENT::GetSubpartIdSeparator() ||
|
|
|
|
firstId != (int)LIB_COMPONENT::GetSubpartFirstId() )
|
|
|
|
{
|
|
|
|
LIB_COMPONENT::SetSubpartIdNotation( sep, firstId );
|
|
|
|
SaveProjectSettings( true );
|
|
|
|
}
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
SetDefaultBusThickness( dlg.GetBusWidth() );
|
|
|
|
SetDefaultLineThickness( dlg.GetLineWidth() );
|
|
|
|
SetDefaultLabelSize( dlg.GetTextSize() );
|
2009-12-01 15:14:18 +00:00
|
|
|
g_RepeatStep.x = dlg.GetRepeatHorizontal();
|
|
|
|
g_RepeatStep.y = dlg.GetRepeatVertical();
|
|
|
|
g_RepeatDeltaLabel = dlg.GetRepeatLabel();
|
2011-10-15 13:25:57 +00:00
|
|
|
SetAutoSaveInterval( dlg.GetAutoSaveInterval() * 60 );
|
2010-02-01 21:23:27 +00:00
|
|
|
SetGridVisibility( dlg.GetShowGrid() );
|
2011-12-09 16:37:11 +00:00
|
|
|
m_showAllPins = dlg.GetShowHiddenPins();
|
2012-04-11 18:54:20 +00:00
|
|
|
m_canvas->SetEnableMiddleButtonPan( dlg.GetEnableMiddleButtonPan() );
|
2013-02-02 19:10:48 +00:00
|
|
|
m_canvas->SetEnableZoomNoCenter( dlg.GetEnableZoomNoCenter() );
|
2012-04-11 18:54:20 +00:00
|
|
|
m_canvas->SetMiddleButtonPanLimited( dlg.GetMiddleButtonPanLimited() );
|
2011-12-29 20:11:42 +00:00
|
|
|
m_canvas->SetEnableAutoPan( dlg.GetEnableAutoPan() );
|
2012-09-28 17:47:41 +00:00
|
|
|
SetForceHVLines( dlg.GetEnableHVBusOrientation() );
|
2009-12-01 15:14:18 +00:00
|
|
|
g_ShowPageLimits = dlg.GetShowPageLimits();
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
wxString templateFieldName;
|
|
|
|
|
|
|
|
// @todo this will change when the template field editor is redone to
|
|
|
|
// look like the component field property editor, showing visibility and value also
|
|
|
|
|
|
|
|
DeleteAllTemplateFieldNames();
|
2010-12-08 20:12:46 +00:00
|
|
|
|
2010-06-17 16:30:10 +00:00
|
|
|
for( int i=0; i<8; ++i ) // no. fields in this dialog window
|
|
|
|
{
|
|
|
|
templateFieldName = dlg.GetFieldName( i );
|
|
|
|
|
|
|
|
if( !templateFieldName.IsEmpty() )
|
|
|
|
{
|
|
|
|
TEMPLATE_FIELDNAME fld( dlg.GetFieldName( i ) );
|
|
|
|
|
|
|
|
// @todo set visibility and value also from a better editor
|
|
|
|
|
|
|
|
AddTemplateFieldName( fld );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-22 13:28:11 +00:00
|
|
|
m_canvas->Refresh( true );
|
2009-12-01 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::GetProjectFileParametersList()
|
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;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "PageLayoutDescrFile" ),
|
|
|
|
&BASE_SCREEN::m_PageLayoutDescrFileName ) );
|
|
|
|
|
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartIdSeparator" ),
|
|
|
|
LIB_COMPONENT::SubpartIdSeparatorPtr(),
|
2013-10-11 16:24:43 +00:00
|
|
|
0, 0, 126 ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_INT( wxT( "SubpartFirstId" ),
|
|
|
|
LIB_COMPONENT::SubpartFirstIdPtr(),
|
2013-10-11 16:24:43 +00:00
|
|
|
'A', '1', 'z' ) );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
2011-02-26 08:35:22 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_FILENAME( wxT( "LibDir" ),
|
2011-12-09 16:37:11 +00:00
|
|
|
&m_userLibraryPath ) );
|
2009-05-21 17:42:42 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_LIBNAME_LIST( wxT( "LibName" ),
|
2011-12-09 16:37:11 +00:00
|
|
|
&m_componentLibFiles,
|
2009-05-21 17:42:42 +00:00
|
|
|
GROUPLIB ) );
|
2012-03-12 10:04:40 +00:00
|
|
|
m_projectFileParams.push_back( new PARAM_CFG_WXSTRING( wxT( "NetFmtName" ),
|
|
|
|
&m_netListFormat) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2009-05-21 17:42:42 +00:00
|
|
|
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_INT( wxT( "LabSize" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&m_defaultLabelSize,
|
|
|
|
DEFAULT_SIZE_TEXT, 5,
|
2009-05-21 17:42:42 +00:00
|
|
|
1000 ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
return m_projectFileParams;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
bool SCH_EDIT_FRAME::LoadProjectFile( const wxString& aFileName, bool aForceReread )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2011-08-18 19:25:12 +00:00
|
|
|
bool IsRead = true;
|
2011-12-09 16:37:11 +00:00
|
|
|
wxArrayString liblist_tmp = m_componentLibFiles;
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
if( aFileName.IsEmpty() )
|
2011-01-20 16:34:57 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName();
|
2008-02-26 19:19:54 +00:00
|
|
|
else
|
2011-08-18 19:25:12 +00:00
|
|
|
fn = aFileName;
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2011-12-09 16:37:11 +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 );
|
|
|
|
|
2011-12-09 16:37:11 +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,
|
2013-07-19 18:27:22 +00:00
|
|
|
GetProjectFileParametersList(),
|
2011-08-18 19:25:12 +00:00
|
|
|
!aForceReread ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
{
|
2011-12-09 16:37:11 +00:00
|
|
|
m_componentLibFiles = liblist_tmp;
|
2011-08-18 19:25:12 +00:00
|
|
|
IsRead = false;
|
2008-02-26 19:19:54 +00:00
|
|
|
}
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
// Verify some values, because the config file can be edited by hand,
|
|
|
|
// and have bad values:
|
|
|
|
LIB_COMPONENT::SetSubpartIdNotation( LIB_COMPONENT::GetSubpartIdSeparator(),
|
|
|
|
LIB_COMPONENT::GetSubpartFirstId() );
|
|
|
|
|
|
|
|
// Load the page layout decr file, from the filename stored in
|
|
|
|
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
|
|
|
|
// If empty, the default descr is loaded
|
|
|
|
WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance();
|
|
|
|
pglayout.SetPageLayout(BASE_SCREEN::m_PageLayoutDescrFileName);
|
|
|
|
|
|
|
|
// Load libraries.
|
2012-01-05 08:07:11 +00:00
|
|
|
// User library path takes precedent over default library search paths.
|
2011-12-09 16:37:11 +00:00
|
|
|
wxGetApp().InsertLibraryPath( m_userLibraryPath, 1 );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
/* If the list is void, force loading the library "power.lib" that is
|
2009-11-03 13:26:31 +00:00
|
|
|
* the "standard" library for power symbols.
|
|
|
|
*/
|
2011-12-09 16:37:11 +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();
|
2011-02-05 02:21:11 +00:00
|
|
|
GetScreen()->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
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveProjectSettings( bool aAskForSave )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
fn = g_RootSheet->GetScreen()->GetFileName(); //ConfigFileName
|
2009-04-05 20:49:15 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
if( !IsWritable( fn ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
|
|
|
|
2013-07-19 18:27:22 +00:00
|
|
|
if( aAskForSave )
|
|
|
|
{
|
|
|
|
wxFileDialog dlg( this, _( "Save Project File" ),
|
|
|
|
fn.GetPath(), fn.GetFullName(),
|
|
|
|
ProjectFileWildcard, wxFD_SAVE | wxFD_CHANGE_DIR );
|
|
|
|
|
|
|
|
if( dlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxGetApp().WriteProjectConfig( dlg.GetPath(), GROUP,
|
|
|
|
GetProjectFileParametersList() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
wxGetApp().WriteProjectConfig( fn.GetFullPath(), GROUP,
|
|
|
|
GetProjectFileParametersList() );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
|
2012-05-24 06:51:52 +00:00
|
|
|
static const wxString DefaultBusWidthEntry( wxT( "DefaultBusWidth" ) );
|
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" ) );
|
2010-03-16 18:22:59 +00:00
|
|
|
static const wxString FindDialogPositionXEntry( wxT( "FindDialogPositionX" ) );
|
|
|
|
static const wxString FindDialogPositionYEntry( wxT( "FindDialogPositionY" ) );
|
|
|
|
static const wxString FindDialogWidthEntry( wxT( "FindDialogWidth" ) );
|
|
|
|
static const wxString FindDialogHeightEntry( wxT( "FindDialogHeight" ) );
|
|
|
|
static const wxString FindReplaceFlagsEntry( wxT( "LastFindReplaceFlags" ) );
|
|
|
|
static const wxString FindStringEntry( wxT( "LastFindString" ) );
|
|
|
|
static const wxString ReplaceStringEntry( wxT( "LastReplaceString" ) );
|
|
|
|
static const wxString FindStringHistoryEntry( wxT( "FindStringHistoryList%d" ) );
|
|
|
|
static const wxString ReplaceStringHistoryEntry( wxT( "ReplaceStringHistoryList%d" ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
static const wxString FieldNamesEntry( wxT( "FieldNames" ) );
|
2010-07-14 13:24:36 +00:00
|
|
|
static const wxString SimulatorCommandEntry( wxT( "SimCmdLine" ) );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-08-18 19:25:12 +00:00
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
PARAM_CFG_ARRAY& SCH_EDIT_FRAME::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;
|
|
|
|
|
2012-03-26 21:45:05 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_INT( true, wxT( "Units" ),
|
|
|
|
(int*)&g_UserUnit, MILLIMETRES ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorWireEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_WIRE],
|
2009-05-21 17:42:42 +00:00
|
|
|
GREEN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBusEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_BUS],
|
2009-05-21 17:42:42 +00:00
|
|
|
BLUE ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorConnEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_JUNCTION],
|
2009-05-21 17:42:42 +00:00
|
|
|
GREEN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorLLabelEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_LOCLABEL],
|
2009-05-21 17:42:42 +00:00
|
|
|
BLACK ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorHLabelEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_HIERLABEL],
|
2009-05-21 17:42:42 +00:00
|
|
|
BROWN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGLabelEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_GLOBLABEL],
|
2009-05-21 17:42:42 +00:00
|
|
|
RED ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNumEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_PINNUM],
|
2009-05-21 17:42:42 +00:00
|
|
|
RED ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinNameEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_PINNAM],
|
2009-05-21 17:42:42 +00:00
|
|
|
CYAN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorFieldEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_FIELDS],
|
2009-05-21 17:42:42 +00:00
|
|
|
MAGENTA ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorReferenceEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_REFERENCEPART],
|
2009-05-21 17:42:42 +00:00
|
|
|
CYAN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorValueEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_VALUEPART],
|
2009-05-21 17:42:42 +00:00
|
|
|
CYAN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoteEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_NOTES],
|
2009-05-21 17:42:42 +00:00
|
|
|
LIGHTBLUE ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_DEVICE],
|
2009-05-21 17:42:42 +00:00
|
|
|
RED ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorBodyBgEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_DEVICE_BACKGROUND],
|
2009-05-21 17:42:42 +00:00
|
|
|
LIGHTYELLOW ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNetNameEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_NETNAM],
|
2009-05-21 17:42:42 +00:00
|
|
|
DARKGRAY ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorPinEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_PIN],
|
2009-05-21 17:42:42 +00:00
|
|
|
RED ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_SHEET],
|
2009-05-21 17:42:42 +00:00
|
|
|
MAGENTA ) );
|
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true,
|
2013-04-04 21:35:01 +00:00
|
|
|
wxT( "ColorSheetFileNameEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_SHEETFILENAME],
|
2009-05-21 17:42:42 +00:00
|
|
|
BROWN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetNameEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_SHEETNAME],
|
2009-05-21 17:42:42 +00:00
|
|
|
CYAN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorSheetLabelEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_SHEETLABEL],
|
2009-05-21 17:42:42 +00:00
|
|
|
BROWN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorNoConnectEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_NOCONNECT],
|
2009-05-21 17:42:42 +00:00
|
|
|
BLUE ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcWEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_ERC_WARN],
|
2009-05-21 17:42:42 +00:00
|
|
|
GREEN ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorErcEEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_ERC_ERR],
|
2009-05-21 17:42:42 +00:00
|
|
|
RED ) );
|
2013-04-04 21:35:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_SETCOLOR( true, wxT( "ColorGridEx" ),
|
2012-09-28 17:47:41 +00:00
|
|
|
&s_layerColor[LAYER_GRID],
|
2010-12-20 16:42:34 +00:00
|
|
|
DARKGRAY ) );
|
2010-11-29 15:05:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintMonochrome" ),
|
2010-12-20 16:42:34 +00:00
|
|
|
&m_printMonochrome, true ) );
|
2010-11-29 15:05:01 +00:00
|
|
|
m_configSettings.push_back( new PARAM_CFG_BOOL( true, wxT( "PrintSheetReferenceAndTitleBlock" ),
|
2010-12-20 16:42:34 +00:00
|
|
|
&m_printSheetReference, true ) );
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::LoadSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
wxASSERT( wxGetApp().GetSettings() != NULL );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2010-02-02 15:01:09 +00:00
|
|
|
long tmp;
|
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* cfg = wxGetApp().GetSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::LoadSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
wxGetApp().ReadCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
// This is required until someone gets rid of the global variable s_layerColor.
|
2013-04-04 21:35:01 +00:00
|
|
|
m_GridColor = GetLayerColor( LAYER_GRID );
|
2010-12-20 16:42:34 +00:00
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
SetDefaultBusThickness( cfg->Read( DefaultBusWidthEntry, 12l ) );
|
|
|
|
SetDefaultLineThickness( cfg->Read( DefaultDrawLineWidthEntry, 6l ) );
|
2011-12-09 16:37:11 +00:00
|
|
|
cfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false );
|
2012-09-28 17:47:41 +00:00
|
|
|
cfg->Read( HorzVertLinesOnlyEntry, &m_forceHVLines, true );
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Load print preview window session settings.
|
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 );
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Load print dialog session settings.
|
2010-02-02 15:01:09 +00:00
|
|
|
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 );
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
// Load netlists options:
|
2011-06-15 18:44:24 +00:00
|
|
|
cfg->Read( SimulatorCommandEntry, &m_simulatorCommand );
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Load find dialog session setting.
|
2010-03-16 18:22:59 +00:00
|
|
|
cfg->Read( FindDialogPositionXEntry, &tmp, -1 );
|
|
|
|
m_findDialogPosition.x = (int) tmp;
|
|
|
|
cfg->Read( FindDialogPositionYEntry, &tmp, -1 );
|
|
|
|
m_findDialogPosition.y = (int) tmp;
|
|
|
|
cfg->Read( FindDialogWidthEntry, &tmp, -1 );
|
|
|
|
m_findDialogSize.SetWidth( (int) tmp );
|
|
|
|
cfg->Read( FindDialogHeightEntry, &tmp, -1 );
|
|
|
|
m_findDialogSize.SetHeight( (int) tmp );
|
|
|
|
wxASSERT_MSG( m_findReplaceData,
|
|
|
|
wxT( "Find dialog data settings object not created. Bad programmer!" ) );
|
|
|
|
cfg->Read( FindReplaceFlagsEntry, &tmp, (long) wxFR_DOWN );
|
2011-12-13 15:37:33 +00:00
|
|
|
m_findReplaceData->SetFlags( (wxUint32) tmp & ~FR_REPLACE_ITEM_FOUND );
|
2010-03-16 18:22:59 +00:00
|
|
|
m_findReplaceData->SetFindString( cfg->Read( FindStringEntry, wxEmptyString ) );
|
|
|
|
m_findReplaceData->SetReplaceString( cfg->Read( ReplaceStringEntry, wxEmptyString ) );
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Load the find and replace string history list.
|
2012-02-16 06:17:01 +00:00
|
|
|
for( int i = 0; i < FR_HISTORY_LIST_CNT; ++i )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
wxString tmpHistory;
|
|
|
|
wxString entry;
|
|
|
|
entry.Printf( FindStringHistoryEntry, i );
|
|
|
|
tmpHistory = cfg->Read( entry, wxEmptyString );
|
|
|
|
|
|
|
|
if( !tmpHistory.IsEmpty() )
|
|
|
|
m_findStringHistoryList.Add( tmpHistory );
|
|
|
|
|
|
|
|
entry.Printf( ReplaceStringHistoryEntry, i );
|
|
|
|
tmpHistory = cfg->Read( entry, wxEmptyString );
|
|
|
|
|
|
|
|
if( !tmpHistory.IsEmpty() )
|
|
|
|
m_replaceStringHistoryList.Add( tmpHistory );
|
|
|
|
}
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
wxString templateFieldNames = cfg->Read( FieldNamesEntry, wxEmptyString );
|
|
|
|
|
|
|
|
if( !templateFieldNames.IsEmpty() )
|
|
|
|
{
|
2011-02-28 18:36:19 +00:00
|
|
|
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
|
2010-06-17 16:30:10 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_TemplateFieldNames.Parse( &lexer );
|
|
|
|
}
|
2011-01-05 21:13:47 +00:00
|
|
|
catch( IO_ERROR& e )
|
2010-06-17 16:30:10 +00:00
|
|
|
{
|
|
|
|
// @todo show error msg
|
2010-12-20 16:42:34 +00:00
|
|
|
D( printf( "templatefieldnames parsing error: '%s'\n",
|
2011-02-28 18:36:19 +00:00
|
|
|
TO_UTF8( e.errorText ) ); )
|
2010-06-17 16:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-08 20:12:46 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveSettings()
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2011-12-16 20:12:49 +00:00
|
|
|
wxASSERT( wxGetApp().GetSettings() != NULL );
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-12-16 20:12:49 +00:00
|
|
|
wxConfig* cfg = wxGetApp().GetSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
2011-01-21 19:30:59 +00:00
|
|
|
EDA_DRAW_FRAME::SaveSettings();
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
wxGetApp().SaveCurrentSetupValues( GetConfigurationSettings() );
|
|
|
|
|
2012-09-28 17:47:41 +00:00
|
|
|
cfg->Write( DefaultBusWidthEntry, (long) GetDefaultBusThickness() );
|
|
|
|
cfg->Write( DefaultDrawLineWidthEntry, (long) GetDefaultLineThickness() );
|
2011-12-09 16:37:11 +00:00
|
|
|
cfg->Write( ShowHiddenPinsEntry, m_showAllPins );
|
2012-09-28 17:47:41 +00:00
|
|
|
cfg->Write( HorzVertLinesOnlyEntry, GetForceHVLines() );
|
2010-02-02 15:01:09 +00:00
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Save print preview window session settings.
|
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() );
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Save print dialog session settings.
|
2010-02-02 15:01:09 +00:00
|
|
|
cfg->Write( PrintDialogPositionXEntry, m_printDialogPosition.x );
|
|
|
|
cfg->Write( PrintDialogPositionYEntry, m_printDialogPosition.y );
|
|
|
|
cfg->Write( PrintDialogWidthEntry, m_printDialogSize.GetWidth() );
|
|
|
|
cfg->Write( PrintDialogHeightEntry, m_printDialogSize.GetHeight() );
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2010-07-14 13:24:36 +00:00
|
|
|
// Save netlists options:
|
2011-06-15 18:44:24 +00:00
|
|
|
cfg->Write( SimulatorCommandEntry, m_simulatorCommand );
|
2010-07-14 13:24:36 +00:00
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Save find dialog session setting.
|
2010-03-16 18:22:59 +00:00
|
|
|
cfg->Write( FindDialogPositionXEntry, m_findDialogPosition.x );
|
|
|
|
cfg->Write( FindDialogPositionYEntry, m_findDialogPosition.y );
|
|
|
|
cfg->Write( FindDialogWidthEntry, m_findDialogSize.GetWidth() );
|
|
|
|
cfg->Write( FindDialogHeightEntry, m_findDialogSize.GetHeight() );
|
|
|
|
wxASSERT_MSG( m_findReplaceData,
|
|
|
|
wxT( "Find dialog data settings object not created. Bad programmer!" ) );
|
2011-12-13 15:37:33 +00:00
|
|
|
cfg->Write( FindReplaceFlagsEntry,
|
|
|
|
(long) m_findReplaceData->GetFlags() & ~FR_REPLACE_ITEM_FOUND );
|
2010-03-16 18:22:59 +00:00
|
|
|
cfg->Write( FindStringEntry, m_findReplaceData->GetFindString() );
|
|
|
|
cfg->Write( ReplaceStringEntry, m_findReplaceData->GetReplaceString() );
|
|
|
|
|
2012-01-05 08:07:11 +00:00
|
|
|
// Save the find and replace string history list.
|
2012-02-16 06:17:01 +00:00
|
|
|
unsigned i;
|
2010-03-16 18:22:59 +00:00
|
|
|
wxString tmpHistory;
|
2010-06-17 16:30:10 +00:00
|
|
|
wxString entry; // invoke constructor outside of any loops
|
2010-03-16 18:22:59 +00:00
|
|
|
|
2012-02-16 06:17:01 +00:00
|
|
|
for( i = 0; i < m_findStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
entry.Printf( FindStringHistoryEntry, i );
|
|
|
|
cfg->Write( entry, m_findStringHistoryList[ i ] );
|
|
|
|
}
|
|
|
|
|
2012-02-16 06:17:01 +00:00
|
|
|
for( i = 0; i < m_replaceStringHistoryList.GetCount() && i < FR_HISTORY_LIST_CNT; i++ )
|
2010-03-16 18:22:59 +00:00
|
|
|
{
|
|
|
|
entry.Printf( ReplaceStringHistoryEntry, i );
|
|
|
|
cfg->Write( entry, m_replaceStringHistoryList[ i ] );
|
|
|
|
}
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
// Save template fieldnames
|
2010-08-09 02:03:16 +00:00
|
|
|
STRING_FORMATTER sf;
|
2010-06-17 16:30:10 +00:00
|
|
|
|
|
|
|
m_TemplateFieldNames.Format( &sf, 0 );
|
|
|
|
|
2011-08-16 15:36:25 +00:00
|
|
|
D(printf("saving formatted template fieldnames:'%s'\n", sf.GetString().c_str() );)
|
|
|
|
|
2011-02-28 18:36:19 +00:00
|
|
|
wxString record = FROM_UTF8( sf.GetString().c_str() );
|
2010-06-17 16:30:10 +00:00
|
|
|
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
|
|
|
|
record.Replace( wxT(" "), wxT(" "), true ); // double space to single
|
|
|
|
|
|
|
|
cfg->Write( FieldNamesEntry, record );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|