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
54
55
56PANEL_GAL_OPTIONS::PANEL_GAL_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
57 PANEL_GAL_OPTIONS_BASE( aParent ),
58 m_cfg( aAppSettings )
59{
60 // Grid settings subpanel
61 int selection = 0; // default selection
62
63 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
64 {
65 m_gridThicknessList.push_back( size );
66 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
67
68 if( m_cfg->m_Window.grid.line_width == size )
69 selection = m_gridLineWidth->GetCount() - 1;
70 }
71
72 m_gridLineWidth->SetSelection( selection );
73
75 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
76}
77
78
80{
81 m_gridSnapOptions->SetSelection( m_cfg->m_Window.grid.snap );
82
83 if( m_cfg->m_Window.grid.style == 0 )
84 m_rbDots->SetValue( true );
85 else if( m_cfg->m_Window.grid.style == 1 )
86 m_rbLines->SetValue( true );
87 else
88 m_rbCrosses->SetValue( true );
89
90 m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing );
91
92 if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::SMALL_CROSS )
93 m_rbSmallCrosshairs->SetValue( true );
94 else if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL )
95 m_rb45DegreeCrosshairs->SetValue( true );
96 else
97 m_rbFullWindowCrosshairs->SetValue( true );
98
99 m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor );
100
101 return true;
102}
103
104
106{
107 m_cfg->m_Window.grid.snap = m_gridSnapOptions->GetSelection();
108
109 if( m_rbDots->GetValue() )
110 m_cfg->m_Window.grid.style = 0;
111 else if( m_rbLines->GetValue() )
112 m_cfg->m_Window.grid.style = 1;
113 else
114 m_cfg->m_Window.grid.style = 2;
115
116 if( m_gridLineWidth->GetSelection() >= 0 )
117 m_cfg->m_Window.grid.line_width = m_gridThicknessList[ m_gridLineWidth->GetSelection() ];
118
119 m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue();
120
121 if( m_rbFullWindowCrosshairs->GetValue() )
122 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_CROSS;
123 else if( m_rb45DegreeCrosshairs->GetValue() )
124 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL;
125 else
126 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::SMALL_CROSS;
127 m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue();
128
129 return true;
130}
131
132
134{
135 APP_SETTINGS_BASE* saved = m_cfg;
136
137 m_cfg = aAppSettings;
139 m_cfg = saved;
140
141 return true;
142}
143
144
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 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