2018-05-14 17:34:18 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Wayne Stambaugh <stambaughw@verizon.net>
|
2023-01-11 01:00:47 +00:00
|
|
|
* Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-05-14 17:34:18 +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
|
|
|
|
*/
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <pgm_base.h>
|
2020-04-02 12:57:07 +00:00
|
|
|
#include <settings/settings_manager.h>
|
|
|
|
#include <settings/color_settings.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <eeschema_settings.h>
|
2020-10-25 19:24:00 +00:00
|
|
|
#include "panel_eeschema_editing_options.h"
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
PANEL_EESCHEMA_EDITING_OPTIONS::PANEL_EESCHEMA_EDITING_OPTIONS( wxWindow* aWindow,
|
2022-12-03 19:31:41 +00:00
|
|
|
UNITS_PROVIDER* aUnitsProvider,
|
|
|
|
wxWindow* aEventSource ) :
|
2020-10-25 19:24:00 +00:00
|
|
|
PANEL_EESCHEMA_EDITING_OPTIONS_BASE( aWindow ),
|
2022-12-03 19:31:41 +00:00
|
|
|
m_hPitch( aUnitsProvider, aEventSource, m_hPitchLabel, m_hPitchCtrl, m_hPitchUnits ),
|
|
|
|
m_vPitch( aUnitsProvider, aEventSource, m_vPitchLabel, m_vPitchCtrl, m_vPitchUnits )
|
2021-01-15 19:39:06 +00:00
|
|
|
{
|
|
|
|
// Make the color swatch show "Clear Color" instead
|
|
|
|
m_borderColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
|
|
|
m_backgroundColorSwatch->SetDefaultColor( COLOR4D::UNSPECIFIED );
|
2021-02-23 19:40:22 +00:00
|
|
|
|
2023-01-11 01:00:47 +00:00
|
|
|
wxFont helpFont = KIUI::GetInfoFont( this ).Italic();
|
|
|
|
m_hint1->SetFont( helpFont );
|
|
|
|
m_hint2->SetFont( helpFont );
|
|
|
|
|
2022-09-09 17:05:59 +00:00
|
|
|
m_spinLabelRepeatStep->SetRange( -100000, 100000 );
|
2022-09-09 18:14:38 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 1, 6 )
|
2022-09-09 17:05:59 +00:00
|
|
|
m_spinLabelRepeatStep->SetIncrement( 1 );
|
2022-09-09 18:14:38 +00:00
|
|
|
#endif
|
2022-09-09 17:05:59 +00:00
|
|
|
|
2021-02-23 19:40:22 +00:00
|
|
|
#ifdef __WXOSX_MAC__
|
2021-03-12 23:59:17 +00:00
|
|
|
m_leftClickCmdsBook->SetSelection( 1 );
|
2021-02-23 19:40:22 +00:00
|
|
|
#else
|
2021-03-12 23:59:17 +00:00
|
|
|
m_leftClickCmdsBook->SetSelection( 0 );
|
2021-02-23 19:40:22 +00:00
|
|
|
#endif
|
2021-01-15 19:39:06 +00:00
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_EESCHEMA_EDITING_OPTIONS::loadEEschemaSettings( EESCHEMA_SETTINGS* aCfg )
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2022-09-16 23:42:20 +00:00
|
|
|
m_hPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Drawing.default_repeat_offset_x ) );
|
|
|
|
m_vPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Drawing.default_repeat_offset_y ) );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_spinLabelRepeatStep->SetValue( aCfg->m_Drawing.repeat_label_increment );
|
2020-04-12 23:09:17 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
COLOR_SETTINGS* settings = mgr.GetColorSettings();
|
|
|
|
COLOR4D schematicBackground = settings->GetColor( LAYER_SCHEMATIC_BACKGROUND );
|
2020-04-02 12:57:07 +00:00
|
|
|
|
|
|
|
m_borderColorSwatch->SetSwatchBackground( schematicBackground );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_borderColorSwatch->SetSwatchColor( aCfg->m_Drawing.default_sheet_border_color, false );
|
2020-04-02 12:57:07 +00:00
|
|
|
|
|
|
|
m_backgroundColorSwatch->SetSwatchBackground( schematicBackground );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_backgroundColorSwatch->SetSwatchColor( aCfg->m_Drawing.default_sheet_background_color, false );
|
2018-09-04 00:00:17 +00:00
|
|
|
|
2022-03-22 16:49:38 +00:00
|
|
|
m_choiceLineMode->SetSelection( aCfg->m_Drawing.line_mode );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_footprintPreview->SetValue( aCfg->m_Appearance.footprint_preview );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
m_checkAutoplaceFields->SetValue( aCfg->m_AutoplaceFields.enable );
|
|
|
|
m_checkAutoplaceJustify->SetValue( aCfg->m_AutoplaceFields.allow_rejustify );
|
|
|
|
m_checkAutoplaceAlign->SetValue( aCfg->m_AutoplaceFields.align_to_grid );
|
2019-05-15 11:02:30 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
m_mouseDragIsDrag->SetValue( !aCfg->m_Input.drag_is_move );
|
|
|
|
m_cbPinSelectionOpt->SetValue( aCfg->m_Selection.select_pin_selects_symbol );
|
2019-12-19 11:41:51 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
m_cbAutoStartWires->SetValue( aCfg->m_Drawing.auto_start_wires );
|
2022-07-23 09:32:21 +00:00
|
|
|
m_escClearsNetHighlight->SetValue( aCfg->m_Input.esc_clears_net_highlight );
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataToWindow()
|
|
|
|
{
|
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
|
|
|
|
|
|
|
|
loadEEschemaSettings( cfg );
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-25 19:24:00 +00:00
|
|
|
bool PANEL_EESCHEMA_EDITING_OPTIONS::TransferDataFromWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
EESCHEMA_SETTINGS* cfg = mgr.GetAppSettings<EESCHEMA_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
|
|
|
|
cfg->m_Drawing.default_sheet_border_color = m_borderColorSwatch->GetSwatchColor();
|
|
|
|
cfg->m_Drawing.default_sheet_background_color = m_backgroundColorSwatch->GetSwatchColor();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-09-16 23:53:06 +00:00
|
|
|
cfg->m_Drawing.default_repeat_offset_x = schIUScale.IUToMils( (int) m_hPitch.GetValue() );
|
|
|
|
cfg->m_Drawing.default_repeat_offset_y = schIUScale.IUToMils( (int) m_vPitch.GetValue() );
|
2020-04-12 23:09:17 +00:00
|
|
|
cfg->m_Drawing.repeat_label_increment = m_spinLabelRepeatStep->GetValue();
|
2018-09-04 00:00:17 +00:00
|
|
|
|
2022-03-22 16:49:38 +00:00
|
|
|
cfg->m_Drawing.line_mode = m_choiceLineMode->GetSelection();
|
2020-04-12 23:09:17 +00:00
|
|
|
cfg->m_Appearance.footprint_preview = m_footprintPreview->GetValue();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
cfg->m_AutoplaceFields.enable = m_checkAutoplaceFields->GetValue();
|
|
|
|
cfg->m_AutoplaceFields.allow_rejustify = m_checkAutoplaceJustify->GetValue();
|
|
|
|
cfg->m_AutoplaceFields.align_to_grid = m_checkAutoplaceAlign->GetValue();
|
2019-05-15 11:02:30 +00:00
|
|
|
|
2020-04-12 23:09:17 +00:00
|
|
|
cfg->m_Input.drag_is_move = !m_mouseDragIsDrag->GetValue();
|
|
|
|
cfg->m_Selection.select_pin_selects_symbol = m_cbPinSelectionOpt->GetValue();
|
2019-12-19 11:41:51 +00:00
|
|
|
|
2020-10-01 23:53:47 +00:00
|
|
|
cfg->m_Drawing.auto_start_wires = m_cbAutoStartWires->GetValue();
|
2022-07-23 09:32:21 +00:00
|
|
|
cfg->m_Input.esc_clears_net_highlight = m_escClearsNetHighlight->GetValue();
|
2020-10-01 23:53:47 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_EESCHEMA_EDITING_OPTIONS::ResetPanel()
|
|
|
|
{
|
|
|
|
EESCHEMA_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
loadEEschemaSettings( &cfg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|