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 The 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 // Grid settings subpanel
64 int selection = 0; // default selection
65
66 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
67 {
68 m_gridThicknessList.push_back( size );
69 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
70
71 if( m_cfg->m_Window.grid.line_width == size )
72 selection = m_gridLineWidth->GetCount() - 1;
73 }
74
75 m_gridLineWidth->SetSelection( selection );
76
78 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
79}
80
81
83{
84 m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap );
85
86 if( m_cfg->m_Window.grid.style == 0 )
87 m_rbDots->SetValue( true );
88 else if( m_cfg->m_Window.grid.style == 1 )
89 m_rbLines->SetValue( true );
90 else
91 m_rbCrosses->SetValue( true );
92
94
96 m_rbFullWindowCrosshairs->SetValue( true );
97 else
98 m_rbSmallCrosshairs->SetValue( true );
99
101
102 return true;
103}
104
105
107{
108 m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection();
109
110 if( m_rbDots->GetValue() )
112 else if( m_rbLines->GetValue() )
114 else
116
117 if( m_gridLineWidth->GetSelection() >= 0 )
119
121
124
125 return true;
126}
127
128
130{
131 APP_SETTINGS_BASE* saved = m_cfg;
132
133 m_cfg = aAppSettings;
135 m_cfg = saved;
136
137 return true;
138}
139
140
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:108
WINDOW_SETTINGS m_Window
Definition: app_settings.h:233
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:96
GRID_SETTINGS grid
Definition: app_settings.h:97