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 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
2022-12-03 19:31:41 +00:00
|
|
|
* Copyright (C) 1992-2022 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-07-29 09:56:22 +00:00
|
|
|
#include <string_utils.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <footprint_editor_settings.h>
|
|
|
|
#include <panel_edit_options.h>
|
2021-06-03 15:41:26 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2022-12-03 19:31:41 +00:00
|
|
|
PANEL_EDIT_OPTIONS::PANEL_EDIT_OPTIONS( wxWindow* aParent, UNITS_PROVIDER* aUnitsProvider,
|
|
|
|
wxWindow* aEventSource, bool isFootprintEditor ) :
|
2021-08-29 23:33:08 +00:00
|
|
|
PANEL_EDIT_OPTIONS_BASE( aParent ),
|
2022-01-19 13:24:02 +00:00
|
|
|
m_isFootprintEditor( isFootprintEditor ),
|
2022-12-03 19:31:41 +00:00
|
|
|
m_rotationAngle( aUnitsProvider, aEventSource, m_rotationAngleLabel, m_rotationAngleCtrl,
|
2022-01-19 13:24:02 +00:00
|
|
|
m_rotationAngleUnits )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
m_magneticPads->Show( m_isFootprintEditor );
|
|
|
|
m_magneticGraphics->Show( m_isFootprintEditor );
|
2022-12-05 18:27:00 +00:00
|
|
|
m_sizerBoardEdit->Show( !m_isFootprintEditor );
|
2020-12-05 15:04:42 +00:00
|
|
|
|
2022-01-19 19:17:14 +00:00
|
|
|
m_rotationAngle.SetUnits( EDA_UNITS::DEGREES );
|
|
|
|
|
2020-12-05 15:04:42 +00:00
|
|
|
#ifdef __WXOSX_MAC__
|
2020-12-19 00:19:47 +00:00
|
|
|
m_mouseCmdsOSX->Show( true );
|
|
|
|
m_mouseCmdsWinLin->Show( false );
|
2022-06-16 17:05:48 +00:00
|
|
|
// Disable highlight net option for footprint editor
|
|
|
|
m_rbCtrlClickActionMac->Enable( 1, !m_isFootprintEditor );
|
2020-12-05 15:04:42 +00:00
|
|
|
#else
|
2020-12-19 00:19:47 +00:00
|
|
|
m_mouseCmdsWinLin->Show( true );
|
|
|
|
m_mouseCmdsOSX->Show( false );
|
2022-06-16 17:05:48 +00:00
|
|
|
// Disable highlight net option for footprint editor
|
|
|
|
m_rbCtrlClickAction->Enable( 1, !m_isFootprintEditor );
|
2020-12-05 15:04:42 +00:00
|
|
|
#endif
|
2020-06-17 20:45:03 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
m_optionsBook->SetSelection( isFootprintEditor ? 0 : 1 );
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_EDIT_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg )
|
|
|
|
{
|
2023-07-10 16:15:37 +00:00
|
|
|
m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45DegreeLimit );
|
2022-01-19 13:24:02 +00:00
|
|
|
m_rotationAngle.SetAngleValue( aCfg->m_RotationAngle );
|
2023-07-10 16:15:37 +00:00
|
|
|
m_arcEditMode->SetSelection( (int) aCfg->m_ArcEditMode );
|
|
|
|
m_trackMouseDragCtrl->SetSelection( (int) aCfg->m_TrackDragAction );
|
|
|
|
m_flipLeftRight->SetValue( aCfg->m_FlipLeftRight );
|
|
|
|
m_allowFreePads->SetValue( aCfg->m_AllowFreePads );
|
|
|
|
m_autoRefillZones->SetValue( aCfg->m_AutoRefillZones );
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
m_magneticPadChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.pads ) );
|
|
|
|
m_magneticTrackChoice->SetSelection( static_cast<int>( aCfg->m_MagneticItems.tracks ) );
|
|
|
|
m_magneticGraphicsChoice->SetSelection( !aCfg->m_MagneticItems.graphics );
|
|
|
|
|
|
|
|
/* Set display options */
|
|
|
|
m_OptDisplayCurvedRatsnestLines->SetValue( aCfg->m_Display.m_DisplayRatsnestLinesCurved );
|
|
|
|
m_showSelectedRatsnest->SetValue( aCfg->m_Display.m_ShowModuleRatsnest );
|
2023-05-20 23:06:51 +00:00
|
|
|
m_ratsnestThickness->SetValue( aCfg->m_Display.m_RatsnestThickness );
|
2021-11-01 11:20:13 +00:00
|
|
|
|
2022-06-16 17:05:48 +00:00
|
|
|
#ifdef __WXOSX_MAC__
|
|
|
|
m_rbCtrlClickActionMac->SetSelection( aCfg->m_CtrlClickHighlight );
|
|
|
|
#else
|
|
|
|
m_rbCtrlClickAction->SetSelection( aCfg->m_CtrlClickHighlight );
|
|
|
|
#endif
|
|
|
|
|
2023-07-10 16:15:37 +00:00
|
|
|
m_escClearsNetHighlight->SetValue( aCfg->m_ESCClearsNetHighlight );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_showPageLimits->SetValue( aCfg->m_ShowPageLimits );
|
2023-07-10 16:15:37 +00:00
|
|
|
m_cbCourtyardCollisions->SetValue( aCfg->m_ShowCourtyardCollisions );
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void PANEL_EDIT_OPTIONS::loadFPSettings( FOOTPRINT_EDITOR_SETTINGS* aCfg )
|
|
|
|
{
|
2022-01-19 13:24:02 +00:00
|
|
|
m_rotationAngle.SetAngleValue( aCfg->m_RotationAngle );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_magneticPads->SetValue( aCfg->m_MagneticItems.pads == MAGNETIC_OPTIONS::CAPTURE_ALWAYS );
|
|
|
|
m_magneticGraphics->SetValue( aCfg->m_MagneticItems.graphics );
|
2022-10-19 10:32:16 +00:00
|
|
|
m_cbConstrainHV45Mode->SetValue( aCfg->m_Use45Limit );
|
2022-12-05 18:27:00 +00:00
|
|
|
m_arcEditMode->SetSelection(
|
|
|
|
aCfg->m_ArcEditMode == ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS ? 0 : 1 );
|
2021-11-01 11:20:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_EDIT_OPTIONS::TransferDataToWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
2021-04-10 00:20:31 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
loadFPSettings( cfg );
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
|
2020-06-17 20:45:03 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
loadPCBSettings( cfg );
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2021-10-01 11:11:03 +00:00
|
|
|
return true;
|
2018-05-14 17:34:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_EDIT_OPTIONS::TransferDataFromWindow()
|
2018-05-14 17:34:18 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
if( m_isFootprintEditor )
|
2020-08-15 00:04:52 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
FOOTPRINT_EDITOR_SETTINGS* cfg = mgr.GetAppSettings<FOOTPRINT_EDITOR_SETTINGS>();
|
2020-05-22 18:27:05 +00:00
|
|
|
|
2022-01-19 13:24:02 +00:00
|
|
|
cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
|
2018-05-14 17:34:18 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_MagneticItems.pads = m_magneticPads->GetValue() ? MAGNETIC_OPTIONS::CAPTURE_ALWAYS
|
|
|
|
: MAGNETIC_OPTIONS::NO_EFFECT;
|
|
|
|
cfg->m_MagneticItems.graphics = m_magneticGraphics->GetValue();
|
2021-04-10 00:20:31 +00:00
|
|
|
|
2022-10-19 10:32:16 +00:00
|
|
|
cfg->m_Use45Limit = m_cbConstrainHV45Mode->GetValue();
|
2023-07-10 16:15:37 +00:00
|
|
|
cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
|
2020-08-15 00:04:52 +00:00
|
|
|
}
|
2021-08-29 23:33:08 +00:00
|
|
|
else
|
2020-08-15 00:04:52 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
|
2020-12-19 00:19:47 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_Display.m_DisplayRatsnestLinesCurved = m_OptDisplayCurvedRatsnestLines->GetValue();
|
|
|
|
cfg->m_Display.m_ShowModuleRatsnest = m_showSelectedRatsnest->GetValue();
|
2023-05-20 23:06:51 +00:00
|
|
|
cfg->m_Display.m_RatsnestThickness = m_ratsnestThickness->GetValue();
|
2020-06-21 19:39:27 +00:00
|
|
|
|
2023-07-10 16:15:37 +00:00
|
|
|
cfg->m_Use45DegreeLimit = m_cbConstrainHV45Mode->GetValue();
|
2022-01-19 13:24:02 +00:00
|
|
|
cfg->m_RotationAngle = m_rotationAngle.GetAngleValue();
|
2023-07-10 16:15:37 +00:00
|
|
|
cfg->m_ArcEditMode = (ARC_EDIT_MODE) m_arcEditMode->GetSelection();
|
|
|
|
cfg->m_TrackDragAction = (TRACK_DRAG_ACTION) m_trackMouseDragCtrl->GetSelection();
|
|
|
|
cfg->m_FlipLeftRight = m_flipLeftRight->GetValue();
|
|
|
|
cfg->m_AllowFreePads = m_allowFreePads->GetValue();
|
|
|
|
cfg->m_AutoRefillZones = m_autoRefillZones->GetValue();
|
2021-10-01 11:11:03 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_MagneticItems.pads = static_cast<MAGNETIC_OPTIONS>( m_magneticPadChoice->GetSelection() );
|
|
|
|
cfg->m_MagneticItems.tracks = static_cast<MAGNETIC_OPTIONS>( m_magneticTrackChoice->GetSelection() );
|
|
|
|
cfg->m_MagneticItems.graphics = !m_magneticGraphicsChoice->GetSelection();
|
2019-06-01 10:39:39 +00:00
|
|
|
|
2022-08-09 07:45:29 +00:00
|
|
|
cfg->m_ESCClearsNetHighlight = m_escClearsNetHighlight->GetValue();
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_ShowPageLimits = m_showPageLimits->GetValue();
|
2023-07-10 16:15:37 +00:00
|
|
|
cfg->m_ShowCourtyardCollisions = m_cbCourtyardCollisions->GetValue();
|
|
|
|
|
2019-06-13 00:32:47 +00:00
|
|
|
|
2022-06-16 17:05:48 +00:00
|
|
|
#ifdef __WXOSX_MAC__
|
|
|
|
cfg->m_CtrlClickHighlight = m_rbCtrlClickActionMac->GetSelection();
|
|
|
|
#else
|
|
|
|
cfg->m_CtrlClickHighlight = m_rbCtrlClickAction->GetSelection();
|
|
|
|
#endif
|
2021-08-29 23:33:08 +00:00
|
|
|
}
|
2018-07-01 08:24:57 +00:00
|
|
|
|
2018-05-14 17:34:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_EDIT_OPTIONS::ResetPanel()
|
|
|
|
{
|
|
|
|
if( m_isFootprintEditor )
|
|
|
|
{
|
|
|
|
FOOTPRINT_EDITOR_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
loadFPSettings( &cfg );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
loadPCBSettings( &cfg );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|