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 GalGridStyleConfig( "GridStyle" );
35 static const wxString GalGridLineWidthConfig( "GridLineWidth" );
36 static const wxString GalGridMaxDensityConfig( "GridMaxDensity" );
37 static const wxString GalGridAxesEnabledConfig( "GridAxesEnabled" );
38 static const wxString GalFullscreenCursorConfig( "CursorFullscreen" );
39 static const wxString GalForceDisplayCursorConfig( "ForceDisplayCursor" );
40 
41 
43 {
47 };
48 
49 
51  : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
52  m_gridStyle( GRID_STYLE::DOTS ),
53  m_gridLineWidth( 0.5 ),
54  m_gridMinSpacing( 10.0 ),
55  m_axesEnabled( false ),
56  m_fullscreenCursor( false ),
57  m_forceDisplayCursor( false )
58 {}
59 
60 
61 void GAL_DISPLAY_OPTIONS::ReadConfig( wxConfigBase* aCfg, const wxString& aBaseName )
62 {
63  long readLong; // Temp value buffer
64 
65  aCfg->Read( aBaseName + GalGridStyleConfig, &readLong,
66  static_cast<long>( KIGFX::GRID_STYLE::DOTS ) );
68 
69  aCfg->Read( aBaseName + GalGridLineWidthConfig, &m_gridLineWidth, 0.5 );
70  aCfg->Read( aBaseName + GalGridMaxDensityConfig, &m_gridMinSpacing, 10 );
71  aCfg->Read( aBaseName + GalGridAxesEnabledConfig, &m_axesEnabled, false );
72  aCfg->Read( aBaseName + GalFullscreenCursorConfig, &m_fullscreenCursor, false );
73  aCfg->Read( aBaseName + GalForceDisplayCursorConfig, &m_forceDisplayCursor, false );
74 
75  NotifyChanged();
76 }
77 
78 
79 void GAL_DISPLAY_OPTIONS::WriteConfig( wxConfigBase* aCfg, const wxString& aBaseName )
80 {
81  aCfg->Write( aBaseName + GalGridStyleConfig,
83 
84  aCfg->Write( aBaseName + GalGridLineWidthConfig, m_gridLineWidth );
85  aCfg->Write( aBaseName + GalGridMaxDensityConfig, m_gridMinSpacing );
86  aCfg->Write( aBaseName + GalGridAxesEnabledConfig, m_axesEnabled );
87  aCfg->Write( aBaseName + GalFullscreenCursorConfig, m_fullscreenCursor );
88  aCfg->Write( aBaseName + GalForceDisplayCursorConfig, m_forceDisplayCursor );
89 }
90 
91 
93 {
95 }
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:58
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
bool m_axesEnabled
Whether or not to draw the coordinate system axes
void ReadConfig(wxConfigBase *aCfg, const wxString &aBaseName)
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 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 WriteConfig(wxConfigBase *aCfg, const wxString &aBaseName)
static const wxString GalFullscreenCursorConfig("CursorFullscreen")
virtual void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &)=0
double m_gridLineWidth
Thickness to render grid lines/dots
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