2012-02-16 20:03:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2020-10-07 13:15:31 +00:00
|
|
|
* Copyright (C) 2014-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
2012-02-16 20:03:33 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <class_library.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <confirm.h>
|
2020-02-03 16:46:58 +00:00
|
|
|
#include <dialogs/panel_eeschema_color_settings.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <dialogs/panel_eeschema_display_options.h>
|
2020-10-25 19:24:00 +00:00
|
|
|
#include <dialogs/panel_eeschema_editing_options.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <dialogs/panel_eeschema_template_fieldnames.h>
|
2020-10-25 19:24:00 +00:00
|
|
|
#include <dialogs/panel_sym_color_settings.h>
|
|
|
|
#include <dialogs/panel_sym_editing_options.h>
|
2020-07-17 20:04:14 +00:00
|
|
|
#include <dialogs/dialog_schematic_setup.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <eeschema_config.h>
|
2020-10-07 13:15:31 +00:00
|
|
|
#include <erc_settings.h>
|
2020-07-17 20:04:14 +00:00
|
|
|
#include <kiway.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <lib_edit_frame.h>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <panel_gal_display_options.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <panel_hotkeys_editor.h>
|
|
|
|
#include <pgm_base.h>
|
2020-06-08 02:19:46 +00:00
|
|
|
#include <project/project_file.h>
|
2020-07-07 10:17:30 +00:00
|
|
|
#include <project/net_settings.h>
|
2018-01-30 10:49:51 +00:00
|
|
|
#include <sch_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <sch_painter.h>
|
2020-05-13 02:00:37 +00:00
|
|
|
#include <schematic.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/app_settings.h>
|
2020-02-03 16:46:58 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2017-03-05 22:31:31 +00:00
|
|
|
#include <symbol_lib_table.h>
|
2018-05-14 17:34:18 +00:00
|
|
|
#include <widgets/paged_dialog.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <wildcards_and_files_ext.h>
|
2020-10-14 00:23:36 +00:00
|
|
|
#include <page_layout/ws_data_model.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
#define FieldNameTemplatesKey wxT( "FieldNameTemplates" )
|
|
|
|
|
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
PARAM_CFG_FIELDNAMES::PARAM_CFG_FIELDNAMES( TEMPLATES * ptparam, const wxChar* group ) :
|
|
|
|
PARAM_CFG( wxEmptyString, PARAM_SEVERITIES, group )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2020-03-13 09:53:44 +00:00
|
|
|
m_Pt_param = ptparam;
|
|
|
|
}
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
void PARAM_CFG_FIELDNAMES::ReadParam( wxConfigBase* aConfig ) const
|
|
|
|
{
|
|
|
|
if( !m_Pt_param || !aConfig )
|
|
|
|
return;
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
wxString templateFieldNames = aConfig->Read( FieldNameTemplatesKey, wxEmptyString );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
if( !templateFieldNames.IsEmpty() )
|
|
|
|
{
|
|
|
|
TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
try
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2020-03-13 09:53:44 +00:00
|
|
|
m_Pt_param->Parse( &lexer, false );
|
|
|
|
}
|
2020-08-18 14:17:16 +00:00
|
|
|
catch( const IO_ERROR& )
|
2020-03-13 09:53:44 +00:00
|
|
|
{
|
|
|
|
// @todo show error msg
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-13 09:53:44 +00:00
|
|
|
}
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
void PARAM_CFG_FIELDNAMES::SaveParam( wxConfigBase* aConfig ) const
|
|
|
|
{
|
|
|
|
if( !m_Pt_param || !aConfig )
|
|
|
|
return;
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
STRING_FORMATTER sf;
|
|
|
|
m_Pt_param->Format( &sf, 0, false );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
wxString record = FROM_UTF8( sf.GetString().c_str() );
|
|
|
|
record.Replace( wxT("\n"), wxT(""), true ); // strip all newlines
|
|
|
|
record.Replace( wxT(" "), wxT(" "), true ); // double space to single
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
aConfig->Write( FieldNameTemplatesKey, record );
|
|
|
|
}
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
class PARAM_CFG_SEVERITIES : public PARAM_CFG
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
ERC_SETTINGS* m_Pt_param; ///< Pointer to the parameter value
|
|
|
|
|
|
|
|
public:
|
|
|
|
PARAM_CFG_SEVERITIES( ERC_SETTINGS* ptparam, const wxChar* group = nullptr ) :
|
|
|
|
PARAM_CFG( wxEmptyString, PARAM_SEVERITIES, group )
|
|
|
|
{
|
|
|
|
m_Pt_param = ptparam;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReadParam( wxConfigBase* aConfig ) const override
|
|
|
|
{
|
|
|
|
if( !m_Pt_param || !aConfig )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString oldPath = aConfig->GetPath();
|
|
|
|
|
|
|
|
// Read legacy settings first so that modern settings will overwrite them
|
|
|
|
bool flag;
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_TestSimilarLabels" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_SIMILAR_LABELS ] = RPT_SEVERITY_WARNING;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_SIMILAR_LABELS ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_CheckUniqueGlobalLabels" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_GLOBLABEL ] = RPT_SEVERITY_WARNING;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_GLOBLABEL ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_CheckBusDriverConflicts" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_DRIVER_CONFLICT ] = RPT_SEVERITY_WARNING;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_DRIVER_CONFLICT ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_CheckBusEntryConflicts" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_ENTRY_CONFLICT ] = RPT_SEVERITY_WARNING;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_ENTRY_CONFLICT ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_CheckBusToBusConflicts" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_TO_BUS_CONFLICT ] = RPT_SEVERITY_ERROR;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_TO_BUS_CONFLICT ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( aConfig->Read( wxT( "ERC_CheckBusToNetConflicts" ), &flag, true ) )
|
|
|
|
{
|
|
|
|
if( flag )
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_TO_NET_CONFLICT ] = RPT_SEVERITY_ERROR;
|
|
|
|
else
|
|
|
|
m_Pt_param->m_Severities[ ERCE_BUS_TO_NET_CONFLICT ] = RPT_SEVERITY_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TO DO: figure out what we're going to use as keys here so we can read/write these....
|
|
|
|
|
|
|
|
aConfig->SetPath( oldPath );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveParam( wxConfigBase* aConfig ) const override
|
|
|
|
{
|
|
|
|
if( !m_Pt_param || !aConfig )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxString oldPath = aConfig->GetPath();
|
|
|
|
|
|
|
|
// TO DO: figure out what we're going to use as keys here so we can read/write these....
|
|
|
|
|
|
|
|
// TO DO: for now just write out the legacy ones so we don't lose them
|
|
|
|
// TO DO: remove this once the new scheme is in place
|
|
|
|
aConfig->Write( wxT( "ERC_TestSimilarLabels" ),
|
2020-03-16 11:05:01 +00:00
|
|
|
m_Pt_param->IsTestEnabled( ERCE_SIMILAR_LABELS ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
aConfig->Write( wxT( "ERC_CheckUniqueGlobalLabels" ),
|
|
|
|
m_Pt_param->IsTestEnabled( ERCE_GLOBLABEL ) );
|
|
|
|
aConfig->Write( wxT( "ERC_CheckBusDriverConflicts" ),
|
|
|
|
m_Pt_param->IsTestEnabled( ERCE_DRIVER_CONFLICT ) );
|
|
|
|
aConfig->Write( wxT( "ERC_CheckBusEntryConflicts" ),
|
|
|
|
m_Pt_param->IsTestEnabled( ERCE_BUS_ENTRY_CONFLICT ) );
|
|
|
|
aConfig->Write( wxT( "ERC_CheckBusToBusConflicts" ),
|
|
|
|
m_Pt_param->IsTestEnabled( ERCE_BUS_TO_BUS_CONFLICT ) );
|
|
|
|
aConfig->Write( wxT( "ERC_CheckBusToNetConflicts" ),
|
|
|
|
m_Pt_param->IsTestEnabled( ERCE_BUS_TO_NET_CONFLICT ) );
|
|
|
|
|
|
|
|
aConfig->SetPath( oldPath );
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-02-03 16:46:58 +00:00
|
|
|
/// Helper for all the old plotting/printing code while it still exists
|
|
|
|
COLOR4D GetLayerColor( SCH_LAYER_ID aLayer )
|
2012-09-28 17:47:41 +00:00
|
|
|
{
|
2020-02-03 16:46:58 +00:00
|
|
|
return Pgm().GetSettingsManager().GetColorSettings()->GetColor( aLayer );
|
2012-09-28 17:47:41 +00:00
|
|
|
}
|
|
|
|
|
2014-08-13 13:15:15 +00:00
|
|
|
|
2019-06-10 22:27:34 +00:00
|
|
|
// Color to draw items flagged invisible, in libedit (they are invisible in Eeschema)
|
2017-02-20 16:57:41 +00:00
|
|
|
COLOR4D GetInvisibleItemColor()
|
2012-09-28 17:47:41 +00:00
|
|
|
{
|
2017-02-20 16:57:41 +00:00
|
|
|
return COLOR4D( DARKGRAY );
|
2012-09-28 17:47:41 +00:00
|
|
|
}
|
|
|
|
|
2010-11-19 16:28:46 +00:00
|
|
|
|
2019-08-01 17:26:21 +00:00
|
|
|
void SCH_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
2019-06-09 21:57:23 +00:00
|
|
|
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2020-08-29 19:52:39 +00:00
|
|
|
wxTreebook* book = aParent->GetTreebook();
|
2018-07-15 23:15:48 +00:00
|
|
|
|
2020-08-29 19:52:39 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Eeschema" ) );
|
2018-07-15 23:15:48 +00:00
|
|
|
book->AddSubPage( new PANEL_EESCHEMA_DISPLAY_OPTIONS( this, book ), _( "Display Options" ) );
|
2020-10-25 19:24:00 +00:00
|
|
|
book->AddSubPage( new PANEL_EESCHEMA_EDITING_OPTIONS( this, book ), _( "Editing Options" ) );
|
2020-02-03 16:46:58 +00:00
|
|
|
book->AddSubPage( new PANEL_EESCHEMA_COLOR_SETTINGS( this, book ), _( "Colors" ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
book->AddSubPage( new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( this, book, true ),
|
2019-08-01 17:26:21 +00:00
|
|
|
_( "Field Name Templates" ) );
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
aHotkeysPanel->AddHotKeys( GetToolManager() );
|
2009-12-01 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
bool SCH_EDIT_FRAME::LoadProjectSettings()
|
2009-04-29 17:09:00 +00:00
|
|
|
{
|
2020-05-23 15:50:08 +00:00
|
|
|
GetRenderSettings()->SetDefaultPenWidth( m_defaults->m_DefaultLineWidth );
|
|
|
|
GetRenderSettings()->m_DefaultWireThickness = m_defaults->m_DefaultWireThickness;
|
|
|
|
GetRenderSettings()->m_DefaultBusThickness = m_defaults->m_DefaultBusThickness;
|
2020-05-20 03:34:55 +00:00
|
|
|
GetRenderSettings()->m_TextOffsetRatio = m_defaults->m_TextOffsetRatio;
|
|
|
|
GetRenderSettings()->m_PinSymbolSize = m_defaults->m_PinSymbolSize;
|
|
|
|
GetRenderSettings()->m_JunctionSize = m_defaults->m_JunctionSize;
|
2020-04-04 20:32:14 +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:
|
2019-05-25 11:05:39 +00:00
|
|
|
LIB_PART::SetSubpartIdNotation( LIB_PART::GetSubpartIdSeparator(),
|
|
|
|
LIB_PART::GetSubpartFirstId() );
|
2013-07-19 18:27:22 +00:00
|
|
|
|
|
|
|
// Load the page layout decr file, from the filename stored in
|
|
|
|
// BASE_SCREEN::m_PageLayoutDescrFileName, read in config project file
|
2014-12-31 12:31:19 +00:00
|
|
|
// If empty, or not existing, the default descr is loaded
|
2019-05-25 11:05:39 +00:00
|
|
|
WS_DATA_MODEL& pglayout = WS_DATA_MODEL::GetTheInstance();
|
|
|
|
wxString filename = WS_DATA_MODEL::MakeFullFileName( BASE_SCREEN::m_PageLayoutDescrFileName,
|
|
|
|
Prj().GetProjectPath() );
|
2014-12-23 13:01:59 +00:00
|
|
|
|
2019-05-25 11:05:39 +00:00
|
|
|
pglayout.SetPageLayout( filename );
|
2008-02-26 19:19:54 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-05-24 14:54:26 +00:00
|
|
|
void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
|
|
|
DIALOG_SCHEMATIC_SETUP dlg( this );
|
|
|
|
|
|
|
|
if( !aInitialPage.IsEmpty() )
|
2020-05-24 14:54:26 +00:00
|
|
|
dlg.SetInitialPage( aInitialPage, wxEmptyString );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
if( dlg.ShowQuasiModal() == wxID_OK )
|
|
|
|
{
|
2020-07-19 21:22:49 +00:00
|
|
|
Prj().GetProjectFile().NetSettings().ResolveNetClassAssignments( true );
|
2020-03-10 18:46:57 +00:00
|
|
|
SaveProjectSettings();
|
|
|
|
|
2020-07-17 20:04:14 +00:00
|
|
|
Kiway().CommonSettingsChanged( false, true );
|
2020-03-10 18:46:57 +00:00
|
|
|
GetCanvas()->Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-28 00:05:40 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveProjectSettings()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2020-06-08 02:19:46 +00:00
|
|
|
wxFileName fn = Schematic().RootScreen()->GetFileName(); //ConfigFileName
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
fn.SetExt( ProjectFileExtension );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-04-24 01:55:20 +00:00
|
|
|
if( !fn.HasName() || !IsWritable( fn ) )
|
2008-02-26 19:19:54 +00:00
|
|
|
return;
|
|
|
|
|
2020-06-08 02:19:46 +00:00
|
|
|
GetSettingsManager()->SaveProject( fn.GetFullPath() );
|
2009-04-29 17:09:00 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2020-01-13 01:44:19 +00:00
|
|
|
void SCH_EDIT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2020-06-19 21:22:25 +00:00
|
|
|
// For now, axes are forced off in eeschema even if turned on in config
|
|
|
|
eeconfig()->m_Window.grid.axes_enabled = false;
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
SCH_BASE_FRAME::LoadSettings( eeconfig() );
|
|
|
|
|
2020-04-23 11:44:56 +00:00
|
|
|
GetRenderSettings()->m_ShowPinsElectricalType = false;
|
|
|
|
GetRenderSettings()->m_ShowHiddenText = false;
|
|
|
|
GetRenderSettings()->m_ShowHiddenPins = false;
|
|
|
|
GetRenderSettings()->m_ShowHiddenText = false;
|
|
|
|
GetRenderSettings()->SetShowPageLimits( true );
|
|
|
|
GetRenderSettings()->m_ShowUmbilicals = true;
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
if( eeconfig() )
|
|
|
|
{
|
|
|
|
GetRenderSettings()->m_ShowHiddenPins = eeconfig()->m_Appearance.show_hidden_pins;
|
2020-04-18 15:36:29 +00:00
|
|
|
GetRenderSettings()->m_ShowHiddenText = eeconfig()->m_Appearance.show_hidden_fields;
|
2020-04-12 23:09:17 +00:00
|
|
|
GetRenderSettings()->SetShowPageLimits( eeconfig()->m_Appearance.show_page_limits );
|
|
|
|
}
|
|
|
|
}
|
2009-04-29 17:09:00 +00:00
|
|
|
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
void SCH_EDIT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
|
|
|
SCH_BASE_FRAME::SaveSettings( eeconfig() );
|
|
|
|
|
2020-05-16 14:47:43 +00:00
|
|
|
// TODO(JE) do we need to keep m_userUnits around?
|
2020-04-12 23:09:17 +00:00
|
|
|
if( eeconfig() )
|
2020-05-16 14:47:43 +00:00
|
|
|
eeconfig()->m_System.units = static_cast<int>( m_userUnits );
|
2020-04-12 23:09:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SCH_BASE_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
|
|
{
|
2020-05-10 22:02:58 +00:00
|
|
|
wxCHECK_RET( aCfg, "Call to SCH_BASE_FRAME::SaveSettings with null settings" );
|
|
|
|
|
|
|
|
EDA_DRAW_FRAME::LoadSettings( aCfg );
|
2020-04-12 23:09:17 +00:00
|
|
|
|
2020-06-14 15:08:47 +00:00
|
|
|
if( aCfg->m_Window.grid.sizes.empty() )
|
2020-06-12 10:58:56 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Do NOT add others values (mainly grid values in mm), because they can break the
|
|
|
|
* schematic: Because wires and pins are considered as connected when the are to the
|
|
|
|
* same coordinate we cannot mix coordinates in mils (internal units) and mm (that
|
|
|
|
* cannot exactly converted in mils in many cases). In fact schematic must only use
|
|
|
|
* 50 and 25 mils to place labels, wires and components others values are useful only
|
|
|
|
* for graphic items (mainly in library editor) so use integer values in mils only.
|
|
|
|
* The 100 mil grid is added to help conform to the KiCad Library Convention which
|
|
|
|
* states: "Using a 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
|
|
|
|
*/
|
2020-06-14 15:08:47 +00:00
|
|
|
aCfg->m_Window.grid.sizes = { "100 mil",
|
|
|
|
"50 mil",
|
|
|
|
"25 mil",
|
|
|
|
"10 mil",
|
|
|
|
"5 mil",
|
|
|
|
"2 mil",
|
|
|
|
"1 mil" };
|
2020-06-12 10:58:56 +00:00
|
|
|
}
|
|
|
|
|
2020-06-13 21:09:02 +00:00
|
|
|
if( aCfg->m_Window.zoom_factors.empty() )
|
|
|
|
{
|
2020-06-27 14:44:26 +00:00
|
|
|
aCfg->m_Window.zoom_factors = { 0.1,
|
|
|
|
0.15,
|
|
|
|
0.2,
|
|
|
|
0.3,
|
|
|
|
0.5,
|
2020-06-13 21:09:02 +00:00
|
|
|
0.7,
|
|
|
|
1.0,
|
|
|
|
1.5,
|
|
|
|
2.0,
|
|
|
|
3.0,
|
|
|
|
4.5,
|
|
|
|
6.5,
|
|
|
|
10.0,
|
|
|
|
15.0,
|
|
|
|
20.0,
|
|
|
|
30.0,
|
|
|
|
45.0,
|
|
|
|
65.0,
|
|
|
|
100.0,
|
|
|
|
150.0 };
|
|
|
|
}
|
|
|
|
|
|
|
|
for( double& factor : aCfg->m_Window.zoom_factors )
|
|
|
|
factor = std::min( factor, MAX_ZOOM_FACTOR );
|
2009-04-05 20:49:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
void SCH_BASE_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2020-05-10 22:02:58 +00:00
|
|
|
wxCHECK_RET( aCfg, "Call to SCH_BASE_FRAME::SaveSettings with null settings" );
|
|
|
|
|
|
|
|
EDA_DRAW_FRAME::SaveSettings( aCfg );
|
2014-08-25 16:31:32 +00:00
|
|
|
}
|
|
|
|
|
2015-04-22 11:39:00 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
void LIB_EDIT_FRAME::InstallPreferences( PAGED_DIALOG* aParent,
|
|
|
|
PANEL_HOTKEYS_EDITOR* aHotkeysPanel )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2020-08-29 19:52:39 +00:00
|
|
|
wxTreebook* book = aParent->GetTreebook();
|
2018-07-15 23:15:48 +00:00
|
|
|
|
2020-08-29 19:52:39 +00:00
|
|
|
book->AddPage( new wxPanel( book ), _( "Symbol Editor" ) );
|
2020-06-17 20:45:03 +00:00
|
|
|
book->AddSubPage( new PANEL_GAL_DISPLAY_OPTIONS( this, aParent ), _( "Display Options" ) );
|
2020-10-25 19:24:00 +00:00
|
|
|
book->AddSubPage( new PANEL_SYM_EDITING_OPTIONS( this, book ), _( "Editing Options" ) );
|
|
|
|
book->AddSubPage( new PANEL_SYM_COLOR_SETTINGS( this, book ), _( "Colors" ) );
|
2019-06-09 21:57:23 +00:00
|
|
|
|
|
|
|
aHotkeysPanel->AddHotKeys( GetToolManager() );
|
2014-08-25 16:31:32 +00:00
|
|
|
}
|
|
|
|
|
2017-03-05 22:31:31 +00:00
|
|
|
|
|
|
|
SYMBOL_LIB_TABLE* PROJECT::SchSymbolLibTable()
|
|
|
|
{
|
|
|
|
// This is a lazy loading function, it loads the project specific table when
|
|
|
|
// that table is asked for, not before.
|
|
|
|
SYMBOL_LIB_TABLE* tbl = (SYMBOL_LIB_TABLE*) GetElem( ELEM_SYMBOL_LIB_TABLE );
|
|
|
|
|
|
|
|
// its gotta be NULL or a SYMBOL_LIB_TABLE, or a bug.
|
2018-09-15 11:05:54 +00:00
|
|
|
wxASSERT( !tbl || tbl->Type() == SYMBOL_LIB_TABLE_T );
|
2017-03-05 22:31:31 +00:00
|
|
|
|
|
|
|
if( !tbl )
|
|
|
|
{
|
|
|
|
// Stack the project specific SYMBOL_LIB_TABLE overlay on top of the global table.
|
|
|
|
// ~SYMBOL_LIB_TABLE() will not touch the fallback table, so multiple projects may
|
|
|
|
// stack this way, all using the same global fallback table.
|
|
|
|
tbl = new SYMBOL_LIB_TABLE( &SYMBOL_LIB_TABLE::GetGlobalLibTable() );
|
|
|
|
|
|
|
|
SetElem( ELEM_SYMBOL_LIB_TABLE, tbl );
|
|
|
|
|
|
|
|
wxString prjPath;
|
|
|
|
|
2017-11-10 22:55:37 +00:00
|
|
|
wxGetEnv( PROJECT_VAR_NAME, &prjPath );
|
|
|
|
|
2018-05-31 07:08:58 +00:00
|
|
|
if( !prjPath.IsEmpty() )
|
2017-03-05 22:31:31 +00:00
|
|
|
{
|
2018-05-31 07:08:58 +00:00
|
|
|
wxFileName fn( prjPath, SYMBOL_LIB_TABLE::GetSymbolLibTableFileName() );
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
tbl->Load( fn.GetFullPath() );
|
|
|
|
}
|
|
|
|
catch( const IO_ERROR& ioe )
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
msg.Printf( _( "An error occurred loading the symbol library table \"%s\"." ),
|
|
|
|
fn.GetFullPath() );
|
|
|
|
DisplayErrorMessage( NULL, msg, ioe.What() );
|
|
|
|
}
|
2017-03-05 22:31:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tbl;
|
|
|
|
}
|