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-07-02 16:22:32 +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>
|
2021-12-24 22:29:14 +00:00
|
|
|
#include <widgets/ui_common.h>
|
2020-04-12 23:09:17 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-10-31 01:27:16 +00:00
|
|
|
#include <symbol_editor/symbol_editor_settings.h>
|
2020-10-25 19:24:00 +00:00
|
|
|
#include "panel_sym_editing_options.h"
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2023-07-02 16:22:32 +00:00
|
|
|
#define MIN_GRID 25
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
PANEL_SYM_EDITING_OPTIONS::PANEL_SYM_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_SYM_EDITING_OPTIONS_BASE( aWindow ),
|
2022-12-03 19:31:41 +00:00
|
|
|
m_lineWidth( aUnitsProvider, aEventSource, m_lineWidthLabel, m_lineWidthCtrl, m_lineWidthUnits ),
|
|
|
|
m_textSize( aUnitsProvider, aEventSource, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits ),
|
|
|
|
m_pinLength( aUnitsProvider, aEventSource, m_pinLengthLabel, m_pinLengthCtrl, m_pinLengthUnits ),
|
|
|
|
m_pinNameSize( aUnitsProvider, aEventSource ,m_pinNameSizeLabel, m_pinNameSizeCtrl, m_pinNameSizeUnits ),
|
2023-07-02 16:22:32 +00:00
|
|
|
m_pinNumberSize( aUnitsProvider, aEventSource, m_pinNumSizeLabel, m_pinNumSizeCtrl, m_pinNumSizeUnits ),
|
|
|
|
m_pinPitch( aUnitsProvider, aEventSource, m_pinPitchLabel, m_pinPitchCtrl, m_pinPitchUnits )
|
2021-12-24 22:29:14 +00:00
|
|
|
{
|
|
|
|
m_widthHelpText->SetFont( KIUI::GetInfoFont( this ).Italic() );
|
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_SYM_EDITING_OPTIONS::loadSymEditorSettings( SYMBOL_EDITOR_SETTINGS* aCfg )
|
|
|
|
{
|
2022-09-16 23:42:20 +00:00
|
|
|
m_lineWidth.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.line_width ) );
|
|
|
|
m_textSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.text_size ) );
|
|
|
|
m_pinLength.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_length ) );
|
|
|
|
m_pinNumberSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_num_size ) );
|
|
|
|
m_pinNameSize.SetValue( schIUScale.MilsToIU( aCfg->m_Defaults.pin_name_size ) );
|
2023-07-02 16:22:32 +00:00
|
|
|
m_pinPitch.SetValue( schIUScale.MilsToIU( aCfg->m_Repeat.pin_step ) );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_spinRepeatLabel->SetValue( aCfg->m_Repeat.label_delta );
|
|
|
|
m_cbShowPinElectricalType->SetValue( aCfg->m_ShowPinElectricalType );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-25 19:24:00 +00:00
|
|
|
bool PANEL_SYM_EDITING_OPTIONS::TransferDataToWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
SYMBOL_EDITOR_SETTINGS* settings = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
loadSymEditorSettings( settings );
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-25 19:24:00 +00:00
|
|
|
bool PANEL_SYM_EDITING_OPTIONS::TransferDataFromWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
SYMBOL_EDITOR_SETTINGS* settings = mgr.GetAppSettings<SYMBOL_EDITOR_SETTINGS>();
|
2020-04-12 23:09:17 +00:00
|
|
|
|
2023-07-02 16:22:32 +00:00
|
|
|
settings->m_Defaults.line_width = schIUScale.IUToMils( m_lineWidth.GetIntValue() );
|
|
|
|
settings->m_Defaults.text_size = schIUScale.IUToMils( m_textSize.GetIntValue() );
|
|
|
|
settings->m_Defaults.pin_length = schIUScale.IUToMils( m_pinLength.GetIntValue() );
|
|
|
|
settings->m_Defaults.pin_num_size = schIUScale.IUToMils( m_pinNumberSize.GetIntValue() );
|
|
|
|
settings->m_Defaults.pin_name_size = schIUScale.IUToMils( m_pinNameSize.GetIntValue() );
|
2020-04-12 23:09:17 +00:00
|
|
|
settings->m_Repeat.label_delta = m_spinRepeatLabel->GetValue();
|
2023-07-02 16:22:32 +00:00
|
|
|
settings->m_Repeat.pin_step = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
|
2021-08-29 23:33:08 +00:00
|
|
|
settings->m_ShowPinElectricalType = m_cbShowPinElectricalType->GetValue();
|
2018-08-29 18:31:43 +00:00
|
|
|
|
2023-07-02 16:22:32 +00:00
|
|
|
// Force pin_step to a grid multiple
|
|
|
|
settings->m_Repeat.pin_step = KiROUND( double( settings->m_Repeat.pin_step ) / MIN_GRID ) * MIN_GRID;
|
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-02 16:22:32 +00:00
|
|
|
void PANEL_SYM_EDITING_OPTIONS::onKillFocusPinPitch( wxFocusEvent& aEvent )
|
|
|
|
{
|
|
|
|
int pitch_mils = schIUScale.IUToMils( m_pinPitch.GetIntValue() );
|
|
|
|
|
|
|
|
// Force pin_step to a grid multiple
|
|
|
|
pitch_mils = KiROUND( double( pitch_mils ) / MIN_GRID ) * MIN_GRID;
|
|
|
|
|
|
|
|
m_pinPitch.SetValue( schIUScale.MilsToIU( pitch_mils ) );
|
2023-07-02 17:46:56 +00:00
|
|
|
|
|
|
|
aEvent.Skip();
|
2023-07-02 16:22:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_SYM_EDITING_OPTIONS::ResetPanel()
|
|
|
|
{
|
|
|
|
SYMBOL_EDITOR_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
loadSymEditorSettings( &cfg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|