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/*
26 * Spin control parameters
27 */
28static const double gridThicknessMin = 0.5;
29static const double gridThicknessMax = 10.0;
30static const double gridThicknessStep = 0.5;
31
32static const int gridMinSpacingMin = 5;
33static const int gridMinSpacingMax = 200;
34static const int gridMinSpacingStep = 5;
35
36
37PANEL_GAL_OPTIONS::PANEL_GAL_OPTIONS( wxWindow* aParent, APP_SETTINGS_BASE* aAppSettings ) :
38 PANEL_GAL_OPTIONS_BASE( aParent ),
39 m_cfg( aAppSettings )
40{
41 // Grid settings subpanel
42 int selection = 0; // default selection
43
44 for( double size = gridThicknessMin; size <= gridThicknessMax; size += gridThicknessStep )
45 {
46 m_gridThicknessList.push_back( size );
47 m_gridLineWidth->Append( wxString::Format( wxT( "%.1f" ), size ) );
48
49 if( m_cfg->m_Window.grid.line_width == size )
50 selection = m_gridLineWidth->GetCount() - 1;
51 }
52
53 m_gridLineWidth->SetSelection( selection );
54
56 m_gridMinSpacing->SetIncrement( gridMinSpacingStep );
57}
58
59
61{
62 if( m_cfg->m_Window.grid.style == KIGFX::GRID_STYLE::DOTS )
63 m_rbDots->SetValue( true );
64 else if( m_cfg->m_Window.grid.style == KIGFX::GRID_STYLE::LINES )
65 m_rbLines->SetValue( true );
66 else
67 m_rbCrosses->SetValue( true );
68
69 m_gridMinSpacing->SetValue( m_cfg->m_Window.grid.min_spacing );
70
71 m_cbShowMajor->SetValue( m_cfg->m_Window.grid.show_major );
72
73 if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::SMALL_CROSS )
74 m_rbSmallCrosshairs->SetValue( true );
75 else if( m_cfg->m_Window.cursor.cross_hair_mode == KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL )
76 m_rb45DegreeCrosshairs->SetValue( true );
77 else
78 m_rbFullWindowCrosshairs->SetValue( true );
79
80 m_forceCursorDisplay->SetValue( m_cfg->m_Window.cursor.always_show_cursor );
81
82 return true;
83}
84
85
87{
88 if( m_rbDots->GetValue() )
89 m_cfg->m_Window.grid.style = KIGFX::GRID_STYLE::DOTS;
90 else if( m_rbLines->GetValue() )
91 m_cfg->m_Window.grid.style = KIGFX::GRID_STYLE::LINES;
92 else
93 m_cfg->m_Window.grid.style = KIGFX::GRID_STYLE::SMALL_CROSS;
94
95 if( m_gridLineWidth->GetSelection() >= 0 )
96 m_cfg->m_Window.grid.line_width = m_gridThicknessList[ m_gridLineWidth->GetSelection() ];
97
98 m_cfg->m_Window.grid.min_spacing = m_gridMinSpacing->GetValue();
99
100 m_cfg->m_Window.grid.show_major = m_cbShowMajor->GetValue();
101
102 if( m_rbFullWindowCrosshairs->GetValue() )
103 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_CROSS;
104 else if( m_rb45DegreeCrosshairs->GetValue() )
105 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::FULLSCREEN_DIAGONAL;
106 else
107 m_cfg->m_Window.cursor.cross_hair_mode = KIGFX::CROSS_HAIR_MODE::SMALL_CROSS;
108 m_cfg->m_Window.cursor.always_show_cursor = m_forceCursorDisplay->GetValue();
109
110 return true;
111}
112
113
115{
116 APP_SETTINGS_BASE* saved = m_cfg;
117
118 m_cfg = aAppSettings;
120 m_cfg = saved;
121
122 return true;
123}
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.
static const int gridMinSpacingStep
static const double gridThicknessStep
static const int gridMinSpacingMin
static const double gridThicknessMax
static const double gridThicknessMin
static const int gridMinSpacingMax