KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gal_options_panel.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
26#include <eda_draw_frame.h>
27
28#include <config_map.h>
29
30/*
31 * Spin control parameters
32 */
33static const double gridThicknessMin = 0.5;
34static const double gridThicknessMax = 10.0;
35static const double gridThicknessStep = 0.5;
36
37static const int gridMinSpacingMin = 5;
38static const int gridMinSpacingMax = 200;
39static const int gridMinSpacingStep = 5;
40
41
44{
45 { KIGFX::GRID_STYLE::DOTS, 0 }, // Default
48};
49
50
52{
56};
57
58
59GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
60 GAL_OPTIONS_PANEL_BASE( aParent ),
61 m_cfg( aAppSettings )
62{
63 // Rendering engine
64#ifdef __WXMAC__
65 // On MAC, Cairo render does not work.
66 m_renderingSizer->Show( false );
67#endif
68 // Grid settings subpanel
69 int selection = 0; // default selection
70
71 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
72 {
73 m_gridThicknessList.push_back( size );
74 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
75
76 if( m_cfg->m_Window.grid.line_width == size )
77 selection = m_gridLineWidth->GetCount() - 1;
78 }
79
80 m_gridLineWidth->SetSelection( selection );
81
83 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
84}
85
86
88{
89#ifndef __WXMAC__
90 auto canvasType = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( m_cfg->m_Graphics.canvas_type );
91
92 if( canvasType == EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL )
93 m_rbAccelerated->SetValue( true );
94 else
95 m_rbFallback->SetValue( true );
96#endif
97
98 m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap );
99
100 if( m_cfg->m_Window.grid.style == 0 )
101 m_rbDots->SetValue( true );
102 else if( m_cfg->m_Window.grid.style == 1 )
103 m_rbLines->SetValue( true );
104 else
105 m_rbCrosses->SetValue( true );
106
108
110 m_rbFullWindowCrosshairs->SetValue( true );
111 else
112 m_rbSmallCrosshairs->SetValue( true );
113
115
116 return true;
117}
118
119
121{
122 m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection();
123
124 if( m_rbDots->GetValue() )
126 else if( m_rbLines->GetValue() )
128 else
130
131 if( m_gridLineWidth->GetSelection() >= 0 )
133
135
138
139#ifndef __WXMAC__
143#endif
144
145 return true;
146}
147
148
150{
151 APP_SETTINGS_BASE* saved = m_cfg;
152
153 m_cfg = aAppSettings;
155 m_cfg = saved;
156
157 return true;
158}
159
160
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:92
WINDOW_SETTINGS m_Window
Definition: app_settings.h:186
@ GAL_TYPE_OPENGL
OpenGL implementation.
@ GAL_TYPE_CAIRO
Cairo implementation.
Class GAL_OPTIONS_PANEL_BASE.
wxRadioButton * m_rbSmallCrosshairs
wxRadioButton * m_rbFullWindowCrosshairs
bool ResetPanel(APP_SETTINGS_BASE *aAppSettings)
std::vector< double > m_gridThicknessList
bool TransferDataToWindow() override
Load the panel controls from the given opt.
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.
GAL_OPTIONS_PANEL(wxWindow *aParent, APP_SETTINGS_BASE *aAppSettings)
APP_SETTINGS_BASE * m_cfg
static const int gridMinSpacingStep
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleSelectMap
TODO: These are duplicated in gal_display_options - Unify!
static const UTIL::CFG_MAP< KIGFX::GRID_SNAPPING > gridSnapConfigVals
static const double gridThicknessStep
static const int gridMinSpacingMin
static const double gridThicknessMax
static const double gridThicknessMin
static const int gridMinSpacingMax
@ SMALL_CROSS
Use small cross instead of dots for the grid.
@ DOTS
Use dots for the grid.
@ LINES
Use lines for the grid.
std::vector< std::pair< T, long > > CFG_MAP
A config value table is a list of native values (usually enums) to a different set of values,...
Definition: config_map.h:49
bool always_show_cursor
Definition: app_settings.h:44
bool fullscreen_cursor
Definition: app_settings.h:45
double line_width
Definition: grid_settings.h:72
double min_spacing
Definition: grid_settings.h:73
CURSOR_SETTINGS cursor
Definition: app_settings.h:80
GRID_SETTINGS grid
Definition: app_settings.h:81