KiCad PCB EDA Suite
gal_display_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 (C) 2016-2017 Kicad Developers, see change_log.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 
25 #include <wx/config.h>
26 
27 #include <config_map.h>
28 
29 using namespace KIGFX;
30 
31 /*
32  * Config option strings
33  */
34 static const wxString GalGLAntialiasingKeyword( "OpenGLAntialiasingMode" );
35 static const wxString GalGridStyleConfig( "GridStyle" );
36 static const wxString GalGridLineWidthConfig( "GridLineWidth" );
37 static const wxString GalGridMaxDensityConfig( "GridMaxDensity" );
38 static const wxString GalGridAxesEnabledConfig( "GridAxesEnabled" );
39 static const wxString GalFullscreenCursorConfig( "CursorFullscreen" );
40 static const wxString GalForceDisplayCursorConfig( "ForceDisplayCursor" );
41 
42 
44 {
50 };
51 
52 
54 {
58 };
59 
60 
62  : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
63  m_gridStyle( GRID_STYLE::DOTS ),
64  m_gridLineWidth( 0.5 ),
65  m_gridMinSpacing( 10.0 ),
66  m_axesEnabled( false ),
67  m_fullscreenCursor( false ),
68  m_forceDisplayCursor( false )
69 {}
70 
71 
72 void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, wxString aBaseName )
73 {
74  long readLong; // Temp value buffer
75 
76  aCfg->Read( aBaseName + GalGLAntialiasingKeyword, &readLong,
77  static_cast<long>( KIGFX::OPENGL_ANTIALIASING_MODE::NONE ) );
79 
80  aCfg->Read( aBaseName + GalGridStyleConfig, &readLong,
81  static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
83 
84  aCfg->Read( aBaseName + GalGridLineWidthConfig,
85  &m_gridLineWidth, 0.5 );
86 
87  aCfg->Read( aBaseName + GalGridMaxDensityConfig,
88  &m_gridMinSpacing, 10 );
89 
90  aCfg->Read( aBaseName + GalGridAxesEnabledConfig,
91  &m_axesEnabled, false );
92 
93  aCfg->Read( aBaseName + GalFullscreenCursorConfig,
94  &m_fullscreenCursor, false );
95 
96  aCfg->Read( aBaseName + GalForceDisplayCursorConfig,
97  &m_forceDisplayCursor, false );
98 
99  NotifyChanged();
100 }
101 
102 
103 void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, wxString aBaseName )
104 {
105  aCfg->Write( aBaseName + GalGLAntialiasingKeyword,
107 
108  aCfg->Write( aBaseName + GalGridStyleConfig,
110 
111  aCfg->Write( aBaseName + GalGridLineWidthConfig,
112  m_gridLineWidth );
113 
114  aCfg->Write( aBaseName + GalGridMaxDensityConfig,
116 
117  aCfg->Write( aBaseName + GalGridAxesEnabledConfig,
118  m_axesEnabled );
119 
120  aCfg->Write( aBaseName + GalFullscreenCursorConfig,
122 
123  aCfg->Write( aBaseName + GalForceDisplayCursorConfig,
125 }
126 
127 
129 {
131 }
Use lines for the grid.
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
static const wxString GalGridAxesEnabledConfig("GridAxesEnabled")
static const wxString GalGridLineWidthConfig("GridLineWidth")
static const wxString GalGridStyleConfig("GridStyle")
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:57
static const wxString GalForceDisplayCursorConfig("ForceDisplayCursor")
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleConfigVals
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
bool m_axesEnabled
Whether or not to draw the coordinate system axes
static const UTIL::CFG_MAP< KIGFX::OPENGL_ANTIALIASING_MODE > aaModeConfigVals
void Notify(void(GAL_DISPLAY_OPTIONS_OBSERVER::*Ptr)(Args1...), Args2 &&...aArgs)
Function Notify Notifies event to all subscribed observers.
Definition: observable.h:183
static const wxString GalGLAntialiasingKeyword("OpenGLAntialiasingMode")
static const wxString GalGridMaxDensityConfig("GridMaxDensity")
static CFG_NATIVE_VAL< MAP > GetValFromConfig(const MAP &aMap, long aConf)
Get the native value corresponding to the config value (read from file or UI, probably) and find it i...
Definition: config_map.h:96
Use dots for the grid.
Use small cross instead of dots for the grid.
void ReadConfig(wxConfigBase *aCfg, wxString aBaseName)
static const wxString GalFullscreenCursorConfig("CursorFullscreen")
virtual void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &)=0
double m_gridLineWidth
Thickness to render grid lines/dots
void WriteConfig(wxConfigBase *aCfg, wxString aBaseName)
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 m_fullscreenCursor
Fullscreen crosshair or small cross
static long GetConfigForVal(const MAP &aMap, CFG_NATIVE_VAL< MAP > aVal)
Get the mapped config value (the one to write to file, or use in an index) from the given native (pro...
Definition: config_map.h:69