2017-03-13 17:42:12 +08:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2017-03-13 17:42:12 +08: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
|
|
|
|
*/
|
|
|
|
|
2025-08-25 12:13:38 +01:00
|
|
|
#include <dialogs/panel_gal_options.h>
|
2021-08-30 00:33:08 +01:00
|
|
|
#include <settings/app_settings.h>
|
2025-08-22 18:19:28 -07:00
|
|
|
#include <gal/gal_display_options.h>
|
2021-02-21 20:11:44 +00:00
|
|
|
#include <eda_draw_frame.h>
|
2017-03-13 17:42:12 +08:00
|
|
|
|
|
|
|
#include <config_map.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Spin control parameters
|
|
|
|
*/
|
2024-01-19 20:35:56 +00:00
|
|
|
static const double gridThicknessMin = 0.5;
|
2017-03-13 17:42:12 +08:00
|
|
|
static const double gridThicknessMax = 10.0;
|
2019-05-15 18:17:37 -04:00
|
|
|
static const double gridThicknessStep = 0.5;
|
2017-03-13 17:42:12 +08:00
|
|
|
|
2023-09-04 11:32:13 +02:00
|
|
|
static const int gridMinSpacingMin = 5;
|
|
|
|
static const int gridMinSpacingMax = 200;
|
|
|
|
static const int gridMinSpacingStep = 5;
|
2017-03-13 17:42:12 +08:00
|
|
|
|
2021-07-02 11:32:11 -04:00
|
|
|
|
2020-09-10 20:07:56 -07:00
|
|
|
///TODO: These are duplicated in gal_display_options - Unify!
|
2017-03-13 17:42:12 +08:00
|
|
|
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
|
|
|
|
{
|
|
|
|
{ KIGFX::GRID_STYLE::DOTS, 0 }, // Default
|
|
|
|
{ KIGFX::GRID_STYLE::LINES, 1 },
|
|
|
|
{ KIGFX::GRID_STYLE::SMALL_CROSS, 2 },
|
|
|
|
};
|
|
|
|
|
2021-07-02 11:32:11 -04:00
|
|
|
|
2020-09-10 20:07:56 -07:00
|
|
|
static const UTIL::CFG_MAP<KIGFX::GRID_SNAPPING> gridSnapConfigVals =
|
|
|
|
{
|
|
|
|
{ KIGFX::GRID_SNAPPING::ALWAYS, 0 },
|
|
|
|
{ KIGFX::GRID_SNAPPING::WITH_GRID, 1 },
|
|
|
|
{ KIGFX::GRID_SNAPPING::NEVER, 2 }
|
|
|
|
};
|
2017-03-13 17:42:12 +08:00
|
|
|
|
2021-07-02 11:32:11 -04:00
|
|
|
|
2025-08-25 12:13:38 +01:00
|
|
|
PANEL_GAL_OPTIONS::PANEL_GAL_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
|
|
|
|
PANEL_GAL_OPTIONS_BASE( aParent ),
|
2025-07-28 19:37:32 +01:00
|
|
|
m_cfg( aAppSettings )
|
2017-03-13 17:42:12 +08:00
|
|
|
{
|
2023-09-04 11:32:13 +02:00
|
|
|
// Grid settings subpanel
|
|
|
|
int selection = 0; // default selection
|
|
|
|
|
|
|
|
for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
|
2017-03-13 17:42:12 +08:00
|
|
|
{
|
2023-09-04 11:32:13 +02:00
|
|
|
m_gridThicknessList.push_back( size );
|
|
|
|
m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
|
2023-01-11 01:00:47 +00:00
|
|
|
|
2023-09-04 11:32:13 +02:00
|
|
|
if( m_cfg->m_Window.grid.line_width == size )
|
|
|
|
selection = m_gridLineWidth->GetCount() - 1;
|
|
|
|
}
|
2017-03-20 04:51:59 +08:00
|
|
|
|
2023-09-04 11:32:13 +02:00
|
|
|
m_gridLineWidth->SetSelection( selection );
|
2017-03-20 04:51:59 +08:00
|
|
|
|
2023-09-04 11:32:13 +02:00
|
|
|
m_gridMinSpacing->SetRange( gridMinSpacingMin, gridMinSpacingMax );
|
|
|
|
m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
|
2017-03-13 17:42:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-08-25 12:13:38 +01:00
|
|
|
bool PANEL_GAL_OPTIONS::TransferDataToWindow()
|
2017-03-13 17:42:12 +08:00
|
|
|
{
|
2021-08-30 00:33:08 +01:00
|
|
|
m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap );
|
2023-09-04 12:46:52 +01:00
|
|
|
|
|
|
|
if( m_cfg->m_Window.grid.style == 0 )
|
|
|
|
m_rbDots->SetValue( true );
|
|
|
|
else if( m_cfg->m_Window.grid.style == 1 )
|
|
|
|
m_rbLines->SetValue( true );
|
|
|
|
else
|
|
|
|
m_rbCrosses->SetValue( true );
|
2023-09-04 11:32:13 +02:00
|
|
|
|
2021-08-30 00:33:08 +01:00
|
|
|
m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing );
|
2017-03-20 04:51:59 +08:00
|
|
|
|
2025-08-22 18:19:28 -07:00
|
|
|
if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::SMALL_CROSS )
|
2023-09-04 12:46:52 +01:00
|
|
|
m_rbSmallCrosshairs->SetValue( true );
|
2025-08-22 18:19:28 -07:00
|
|
|
else if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL )
|
|
|
|
m_rb45DegreeCrosshairs->SetValue( true );
|
|
|
|
else
|
|
|
|
m_rbFullWindowCrosshairs->SetValue( true );
|
2023-09-04 12:46:52 +01:00
|
|
|
|
2021-08-30 00:33:08 +01:00
|
|
|
m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor );
|
2017-03-19 04:03:24 +08:00
|
|
|
|
2017-03-13 17:42:12 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2025-08-25 12:13:38 +01:00
|
|
|
bool PANEL_GAL_OPTIONS::TransferDataFromWindow()
|
2017-03-13 17:42:12 +08:00
|
|
|
{
|
2021-08-30 00:33:08 +01:00
|
|
|
m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection();
|
2023-09-04 12:46:52 +01:00
|
|
|
|
|
|
|
if( m_rbDots->GetValue() )
|
|
|
|
m_cfg->m_Window.grid.style = 0;
|
|
|
|
else if( m_rbLines->GetValue() )
|
|
|
|
m_cfg->m_Window.grid.style = 1;
|
|
|
|
else
|
|
|
|
m_cfg->m_Window.grid.style = 2;
|
2023-09-04 11:32:13 +02:00
|
|
|
|
|
|
|
if( m_gridLineWidth->GetSelection() >= 0 )
|
|
|
|
m_cfg->m_Window.grid.line_width = m_gridThicknessList[ m_gridLineWidth->GetSelection() ];
|
|
|
|
|
2021-08-30 00:33:08 +01:00
|
|
|
m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue();
|
2020-09-10 20:07:56 -07:00
|
|
|
|
2025-08-22 18:19:28 -07:00
|
|
|
if( m_rbFullWindowCrosshairs->GetValue() )
|
|
|
|
m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_CROSS;
|
|
|
|
else if( m_rb45DegreeCrosshairs->GetValue() )
|
|
|
|
m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL;
|
|
|
|
else
|
|
|
|
m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::SMALL_CROSS;
|
2021-08-30 00:33:08 +01:00
|
|
|
m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue();
|
2017-03-19 04:03:24 +08:00
|
|
|
|
2017-03-13 17:42:12 +08:00
|
|
|
return true;
|
|
|
|
}
|
2021-11-01 11:20:13 +00:00
|
|
|
|
|
|
|
|
2025-08-25 12:13:38 +01:00
|
|
|
bool PANEL_GAL_OPTIONS::ResetPanel( APP_SETTINGS_BASE* aAppSettings )
|
2021-11-01 11:20:13 +00:00
|
|
|
{
|
|
|
|
APP_SETTINGS_BASE* saved = m_cfg;
|
|
|
|
|
|
|
|
m_cfg = aAppSettings;
|
|
|
|
TransferDataToWindow();
|
|
|
|
m_cfg = saved;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|