KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_gal_options.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
27#include <eda_draw_frame.h>
28
29#include <config_map.h>
30
31/*
32 * Spin control parameters
33 */
34static const double gridThicknessMin = 0.5;
35static const double gridThicknessMax = 10.0;
36static const double gridThicknessStep = 0.5;
37
38static const int gridMinSpacingMin = 5;
39static const int gridMinSpacingMax = 200;
40static const int gridMinSpacingStep = 5;
41
42
50
51
58
59
60PANEL_GAL_OPTIONS::PANEL_GAL_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
61 PANEL_GAL_OPTIONS_BASE( aParent ),
62 m_cfg( aAppSettings )
63{
64 // Grid settings subpanel
65 int selection = 0; // default selection
66
67 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
68 {
69 m_gridThicknessList.push_back( size );
70 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
71
72 if( m_cfg->m_Window.grid.line_width == size )
73 selection = m_gridLineWidth->GetCount() - 1;
74 }
75
76 m_gridLineWidth->SetSelection( selection );
77
79 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
80}
81
82
84{
85 m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap );
86
87 if( m_cfg->m_Window.grid.style == 0 )
88 m_rbDots->SetValue( true );
89 else if( m_cfg->m_Window.grid.style == 1 )
90 m_rbLines->SetValue( true );
91 else
92 m_rbCrosses->SetValue( true );
93
94 m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing );
95
96 if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::SMALL_CROSS )
97 m_rbSmallCrosshairs->SetValue( true );
98 else if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL )
99 m_rb45DegreeCrosshairs->SetValue( true );
100 else
101 m_rbFullWindowCrosshairs->SetValue( true );
102
103 m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor );
104
105 return true;
106}
107
108
110{
111 m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection();
112
113 if( m_rbDots->GetValue() )
114 m_cfg->m_Window.grid.style = 0;
115 else if( m_rbLines->GetValue() )
116 m_cfg->m_Window.grid.style = 1;
117 else
118 m_cfg->m_Window.grid.style = 2;
119
120 if( m_gridLineWidth->GetSelection() >= 0 )
121 m_cfg->m_Window.grid.line_width = m_gridThicknessList[ m_gridLineWidth->GetSelection() ];
122
123 m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue();
124
125 if( m_rbFullWindowCrosshairs->GetValue() )
126 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_CROSS;
127 else if( m_rb45DegreeCrosshairs->GetValue() )
128 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL;
129 else
130 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::SMALL_CROSS;
131 m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue();
132
133 return true;
134}
135
136
138{
139 APP_SETTINGS_BASE* saved = m_cfg;
140
141 m_cfg = aAppSettings;
143 m_cfg = saved;
144
145 return true;
146}
147
148
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
PANEL_GAL_OPTIONS_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
wxRadioButton * m_rbFullWindowCrosshairs
wxRadioButton * m_rb45DegreeCrosshairs
bool TransferDataFromWindow() override
Read the options set in the UI into the given options object.
bool ResetPanel(APP_SETTINGS_BASE *aAppSettings)
std::vector< double > m_gridThicknessList
APP_SETTINGS_BASE * m_cfg
PANEL_GAL_OPTIONS(wxWindow *aParent, APP_SETTINGS_BASE *aAppSettings)
bool TransferDataToWindow() override
Load the panel controls from the given opt.
@ 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
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