2014-06-20 11:13:04 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-02-02 08:06:39 +00:00
|
|
|
* Copyright (C) 2015 Jean-Pierre Charras, jean-pierre.charras at wanadoo.fr
|
2022-01-16 20:29:03 +00:00
|
|
|
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +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 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* 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.
|
2014-06-20 11:13:04 +00:00
|
|
|
*
|
2018-01-08 04:05:03 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2014-06-20 11:13:04 +00:00
|
|
|
*/
|
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
#include <pgm_base.h>
|
|
|
|
#include <settings/settings_manager.h>
|
2020-06-28 02:48:48 +00:00
|
|
|
#include <pcbnew_settings.h>
|
2017-02-16 05:03:26 +00:00
|
|
|
#include <config_map.h>
|
2020-06-17 20:45:03 +00:00
|
|
|
#include <panel_display_options.h>
|
2017-03-13 09:42:12 +00:00
|
|
|
#include <widgets/gal_options_panel.h>
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2011-09-30 08:24:10 +00:00
|
|
|
|
2021-12-26 00:36:12 +00:00
|
|
|
static const UTIL::CFG_MAP<TRACK_CLEARANCE_MODE> clearanceModeMap =
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2022-02-12 16:32:55 +00:00
|
|
|
{ SHOW_WITH_VIA_WHILE_ROUTING, 2 }, // Default
|
|
|
|
{ DO_NOT_SHOW_CLEARANCE, 0 },
|
|
|
|
{ SHOW_WHILE_ROUTING, 1 },
|
|
|
|
{ SHOW_WITH_VIA_WHILE_ROUTING_OR_DRAGGING, 3 },
|
|
|
|
{ SHOW_WITH_VIA_ALWAYS, 4 },
|
2017-02-16 05:03:26 +00:00
|
|
|
};
|
2017-01-11 15:19:58 +00:00
|
|
|
|
2017-02-14 05:16:47 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
PANEL_DISPLAY_OPTIONS::PANEL_DISPLAY_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
|
|
|
|
PANEL_DISPLAY_OPTIONS_BASE( aParent ),
|
|
|
|
m_isPCBEdit( dynamic_cast<PCBNEW_SETTINGS*>( aAppSettings ) != nullptr )
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
m_galOptsPanel = new GAL_OPTIONS_PANEL( this, aAppSettings );
|
2018-05-14 17:34:18 +00:00
|
|
|
m_galOptionsSizer->Add( m_galOptsPanel, 1, wxEXPAND, 0 );
|
2020-06-17 20:45:03 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
m_optionsBook->SetSelection( m_isPCBEdit ? 1 : 0 );
|
2017-02-14 05:16:47 +00:00
|
|
|
}
|
|
|
|
|
2017-02-14 10:03:08 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_DISPLAY_OPTIONS::loadPCBSettings( PCBNEW_SETTINGS* aCfg )
|
|
|
|
{
|
2022-02-12 16:32:55 +00:00
|
|
|
int i = UTIL::GetConfigForVal( clearanceModeMap, aCfg->m_Display.m_TrackClearance );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_OptDisplayTracksClearance->SetSelection( i );
|
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
m_OptDisplayPadClearence->SetValue( aCfg->m_Display.m_PadClearance );
|
2022-07-23 08:34:31 +00:00
|
|
|
m_OptDisplayPadNumber->SetValue( aCfg->m_ViewersDisplay.m_DisplayPadNumbers );
|
2022-02-12 16:32:55 +00:00
|
|
|
m_ShowNetNamesOption->SetSelection( aCfg->m_Display.m_NetNames );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_live3Drefresh->SetValue( aCfg->m_Display.m_Live3DRefresh );
|
2022-01-16 20:29:03 +00:00
|
|
|
m_checkCrossProbeOnSelection->SetValue( aCfg->m_CrossProbing.on_selection );
|
2021-11-01 11:20:13 +00:00
|
|
|
m_checkCrossProbeCenter->SetValue( aCfg->m_CrossProbing.center_on_items );
|
|
|
|
m_checkCrossProbeZoom->SetValue( aCfg->m_CrossProbing.zoom_to_fit );
|
|
|
|
m_checkCrossProbeAutoHighlight->SetValue( aCfg->m_CrossProbing.auto_highlight );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_DISPLAY_OPTIONS::TransferDataToWindow()
|
2017-02-14 05:16:47 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
if( m_isPCBEdit )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2021-08-29 23:33:08 +00:00
|
|
|
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
|
|
|
|
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>();
|
2017-02-14 05:16:47 +00:00
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
loadPCBSettings( cfg );
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
2017-02-14 05:16:47 +00:00
|
|
|
|
2017-03-13 09:42:12 +00:00
|
|
|
m_galOptsPanel->TransferDataToWindow();
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
return true;
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
|
|
|
|
2011-09-24 18:33:28 +00:00
|
|
|
|
2017-02-16 05:03:26 +00:00
|
|
|
/*
|
|
|
|
* Update variables with new options
|
|
|
|
*/
|
2020-06-17 20:45:03 +00:00
|
|
|
bool PANEL_DISPLAY_OPTIONS::TransferDataFromWindow()
|
2009-06-18 17:32:27 +00:00
|
|
|
{
|
2017-03-13 09:42:12 +00:00
|
|
|
m_galOptsPanel->TransferDataFromWindow();
|
2016-12-23 15:21:00 +00:00
|
|
|
|
2021-08-29 23:33:08 +00:00
|
|
|
if( m_isPCBEdit )
|
2020-06-17 20:45:03 +00:00
|
|
|
{
|
2022-07-24 15:49:46 +00:00
|
|
|
PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2021-09-07 20:34:10 +00:00
|
|
|
int i = m_OptDisplayTracksClearance->GetSelection();
|
2022-02-12 16:32:55 +00:00
|
|
|
cfg->m_Display.m_TrackClearance = UTIL::GetValFromConfig( clearanceModeMap, i );
|
2021-08-29 23:33:08 +00:00
|
|
|
|
2022-02-12 16:32:55 +00:00
|
|
|
cfg->m_Display.m_PadClearance = m_OptDisplayPadClearence->GetValue();
|
2022-07-23 08:34:31 +00:00
|
|
|
cfg->m_ViewersDisplay.m_DisplayPadNumbers = m_OptDisplayPadNumber->GetValue();
|
2022-02-12 16:32:55 +00:00
|
|
|
cfg->m_Display.m_NetNames = m_ShowNetNamesOption->GetSelection();
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_Display.m_Live3DRefresh = m_live3Drefresh->GetValue();
|
2022-01-16 20:29:03 +00:00
|
|
|
cfg->m_CrossProbing.on_selection = m_checkCrossProbeOnSelection->GetValue();
|
2022-05-20 21:41:20 +00:00
|
|
|
cfg->m_CrossProbing.center_on_items = m_checkCrossProbeCenter->GetValue();
|
2021-08-29 23:33:08 +00:00
|
|
|
cfg->m_CrossProbing.zoom_to_fit = m_checkCrossProbeZoom->GetValue();
|
|
|
|
cfg->m_CrossProbing.auto_highlight = m_checkCrossProbeAutoHighlight->GetValue();
|
2020-06-17 20:45:03 +00:00
|
|
|
}
|
2019-06-13 00:32:47 +00:00
|
|
|
|
2017-03-13 16:13:04 +00:00
|
|
|
return true;
|
2009-06-18 17:32:27 +00:00
|
|
|
}
|
2018-01-08 04:05:03 +00:00
|
|
|
|
|
|
|
|
2021-11-01 11:20:13 +00:00
|
|
|
void PANEL_DISPLAY_OPTIONS::ResetPanel()
|
|
|
|
{
|
|
|
|
PCBNEW_SETTINGS cfg;
|
|
|
|
cfg.Load(); // Loading without a file will init to defaults
|
|
|
|
|
|
|
|
if( m_isPCBEdit )
|
|
|
|
loadPCBSettings( &cfg );
|
|
|
|
|
|
|
|
m_galOptsPanel->ResetPanel( &cfg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|