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, see <https://www.gnu.org/licenses/>.
18 */
19
23#include <eda_draw_frame.h>
24
25#include <config_map.h>
26
27/*
28 * Spin control parameters
29 */
30static const double gridThicknessMin = 0.5;
31static const double gridThicknessMax = 10.0;
32static const double gridThicknessStep = 0.5;
33
34static const int gridMinSpacingMin = 5;
35static const int gridMinSpacingMax = 200;
36static const int gridMinSpacingStep = 5;
37
38
46
47
48PANEL_GAL_OPTIONS::PANEL_GAL_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
49 PANEL_GAL_OPTIONS_BASE( aParent ),
50 m_cfg( aAppSettings )
51{
52 // Grid settings subpanel
53 int selection = 0; // default selection
54
55 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
56 {
57 m_gridThicknessList.push_back( size );
58 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
59
60 if( m_cfg->m_Window.grid.line_width == size )
61 selection = m_gridLineWidth->GetCount() - 1;
62 }
63
64 m_gridLineWidth->SetSelection( selection );
65
67 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
68}
69
70
72{
73 if( m_cfg->m_Window.grid.style == 0 )
74 m_rbDots->SetValue( true );
75 else if( m_cfg->m_Window.grid.style == 1 )
76 m_rbLines->SetValue( true );
77 else
78 m_rbCrosses->SetValue( true );
79
80 m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing );
81
82 if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::SMALL_CROSS )
83 m_rbSmallCrosshairs->SetValue( true );
84 else if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL )
85 m_rb45DegreeCrosshairs->SetValue( true );
86 else
87 m_rbFullWindowCrosshairs->SetValue( true );
88
89 m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor );
90
91 return true;
92}
93
94
96{
97 if( m_rbDots->GetValue() )
98 m_cfg->m_Window.grid.style = 0;
99 else if( m_rbLines->GetValue() )
100 m_cfg->m_Window.grid.style = 1;
101 else
102 m_cfg->m_Window.grid.style = 2;
103
104 if( m_gridLineWidth->GetSelection() >= 0 )
105 m_cfg->m_Window.grid.line_width = m_gridThicknessList[ m_gridLineWidth->GetSelection() ];
106
107 m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue();
108
109 if( m_rbFullWindowCrosshairs->GetValue() )
110 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_CROSS;
111 else if( m_rb45DegreeCrosshairs->GetValue() )
112 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL;
113 else
114 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::SMALL_CROSS;
115 m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue();
116
117 return true;
118}
119
120
122{
123 APP_SETTINGS_BASE* saved = m_cfg;
124
125 m_cfg = aAppSettings;
127 m_cfg = saved;
128
129 return true;
130}
131
132
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:45
static const int gridMinSpacingStep
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleSelectMap
TODO: These are duplicated in gal_display_options - Unify!
static const double gridThicknessStep
static const int gridMinSpacingMin
static const double gridThicknessMax
static const double gridThicknessMin
static const int gridMinSpacingMax