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 <settings/app_settings.h>
27 
28 #include <wx/log.h>
29 
30 #include <config_map.h>
31 #include <dpi_scaling.h>
32 
33 using namespace KIGFX;
34 
36 {
40 };
41 
42 
50 static const wxChar* traceGalDispOpts = wxT( "KICAD_GAL_DISPLAY_OPTIONS" );
51 
52 
54  : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
55  cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
56  m_dpi( nullptr, nullptr ),
57  m_gridStyle( GRID_STYLE::DOTS ),
58  m_gridLineWidth( 1.0 ),
59  m_gridMinSpacing( 10.0 ),
60  m_axesEnabled( false ),
61  m_fullscreenCursor( false ),
62  m_forceDisplayCursor( false ),
63  m_scaleFactor( DPI_SCALING::GetDefaultScaleFactor() )
64 {}
65 
66 
68 {
69  wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
70 
75 
78 
79  NotifyChanged();
80 }
81 
82 
83 void GAL_DISPLAY_OPTIONS::ReadCommonConfig( COMMON_SETTINGS& aSettings, wxWindow* aWindow )
84 {
85  wxLogTrace( traceGalDispOpts, "Reading common config" );
86 
87  gl_antialiasing_mode = static_cast<KIGFX::OPENGL_ANTIALIASING_MODE>(
88  aSettings.m_Graphics.opengl_aa_mode );
89 
90  cairo_antialiasing_mode = static_cast<KIGFX::CAIRO_ANTIALIASING_MODE>(
91  aSettings.m_Graphics.cairo_aa_mode );
92 
93  m_dpi = DPI_SCALING( &aSettings, aWindow );
94 
95  // Also calls NotifyChanged
97 }
98 
99 
101  WINDOW_SETTINGS& aWindowConfig, wxWindow* aWindow )
102 {
103  wxLogTrace( traceGalDispOpts, "Reading common and app config" );
104 
105  ReadWindowSettings( aWindowConfig );
106 
107  ReadCommonConfig( aCommonConfig, aWindow );
108 }
109 
110 
112 {
113  wxLogTrace( traceGalDispOpts, "Writing window settings" );
114 
121 }
122 
123 
125 {
127  NotifyChanged();
128 }
129 
130 
132 {
133  wxLogTrace( traceGalDispOpts, "Change notification" );
134 
136 }
bool fullscreen_cursor
Definition: app_settings.h:33
Use lines for the grid.
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:131
KIGFX::GRID_STYLE m_gridStyle
The grid style to draw the grid in
double min_spacing
Definition: app_settings.h:44
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleConfigVals
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS logging.
bool m_forceDisplayCursor
Force cursor display
double m_gridMinSpacing
Minimum pixel distance between displayed grid lines
void Notify(void(GAL_DISPLAY_OPTIONS_OBSERVER ::*Ptr)(Args1...), Args2 &&... aArgs)
Function Notify Notifies event to all subscribed observers.
Definition: observable.h:183
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
bool always_show_cursor
Definition: app_settings.h:32
double GetScaleFactor() const
Get the DPI scale from all known sources in order:
double line_width
Definition: app_settings.h:43
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
Definition: dpi_scaling.h:36
bool m_axesEnabled
Whether or not to draw the coordinate system axes
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:52
CURSOR_SETTINGS cursor
Definition: app_settings.h:62
void WriteConfig(WINDOW_SETTINGS &aCfg)
GRID_SETTINGS grid
Definition: app_settings.h:63
void ReadCommonConfig(COMMON_SETTINGS &aCommonSettings, wxWindow *aWindow)
Read GAL config options from the common config store.
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.
virtual void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &)=0
double m_scaleFactor
The pixel scale factor (>1 for hi-DPI scaled displays)
double m_gridLineWidth
Thickness to render grid lines/dots
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
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
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from applicaton-level config.
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