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-2020 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
27
28#include <wx/log.h>
29
30#include <config_map.h>
31#include <gal/dpi_scaling.h>
32
33using namespace KIGFX;
34
36{
40};
41
43{
47};
48
49
57static const wxChar* traceGalDispOpts = wxT( "KICAD_GAL_DISPLAY_OPTIONS" );
58
59
60GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
61 : gl_antialiasing_mode( OPENGL_ANTIALIASING_MODE::NONE ),
62 cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
63 m_dpi( nullptr, nullptr ),
64 m_gridStyle( GRID_STYLE::DOTS ),
65 m_gridSnapping( GRID_SNAPPING::ALWAYS ),
66 m_gridLineWidth( 1.0 ),
67 m_gridMinSpacing( 10.0 ),
68 m_axesEnabled( false ),
69 m_fullscreenCursor( false ),
70 m_forceDisplayCursor( false ),
71 m_scaleFactor( DPI_SCALING::GetDefaultScaleFactor() )
72{}
73
74
76{
77 wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
78
84
87
89}
90
91
92void GAL_DISPLAY_OPTIONS::ReadCommonConfig( COMMON_SETTINGS& aSettings, wxWindow* aWindow )
93{
94 wxLogTrace( traceGalDispOpts, "Reading common config" );
95
97 aSettings.m_Graphics.opengl_aa_mode );
98
100 aSettings.m_Graphics.cairo_aa_mode );
101
102 m_dpi = DPI_SCALING( &aSettings, aWindow );
104
106}
107
108
110 WINDOW_SETTINGS& aWindowConfig, wxWindow* aWindow )
111{
112 wxLogTrace( traceGalDispOpts, "Reading common and app config" );
113
114 ReadWindowSettings( aWindowConfig );
115
116 ReadCommonConfig( aCommonConfig, aWindow );
117}
118
119
121{
122 wxLogTrace( traceGalDispOpts, "Writing window settings" );
123
131}
132
133
135{
137 {
140 }
141}
142
143
145{
146 wxLogTrace( traceGalDispOpts, "Change notification" );
147
149}
Class to handle configuration and automatic determination of the DPI scale to use for canvases.
Definition: dpi_scaling.h:37
double GetScaleFactor() const
Get the DPI scale from all known sources in order:
virtual void OnGalDisplayOptionsChanged(const GAL_DISPLAY_OPTIONS &)=0
void WriteConfig(WINDOW_SETTINGS &aCfg)
DPI_SCALING m_dpi
The grid style to draw the grid in.
double m_gridLineWidth
Minimum pixel distance between displayed grid lines.
void ReadWindowSettings(WINDOW_SETTINGS &aCfg)
Read GAL config options from application-level config.
double m_gridMinSpacing
Whether or not to draw the coordinate system axes.
OPENGL_ANTIALIASING_MODE gl_antialiasing_mode
void ReadCommonConfig(COMMON_SETTINGS &aCommonSettings, wxWindow *aWindow)
Read GAL config options from the common config store.
CAIRO_ANTIALIASING_MODE cairo_antialiasing_mode
void ReadConfig(COMMON_SETTINGS &aCommonConfig, WINDOW_SETTINGS &aWindowConfig, wxWindow *aWindow)
Read application and common configs.
bool m_forceDisplayCursor
The pixel scale factor (>1 for hi-DPI scaled displays)
KIGFX::GRID_STYLE m_gridStyle
Snapping options for the grid.
bool m_axesEnabled
Fullscreen crosshair or small cross.
bool m_fullscreenCursor
Force cursor display.
GRID_SNAPPING m_gridSnapping
Thickness to render grid lines/dots.
void Notify(void(ObserverInterface::*Ptr)(Args1...), Args2 &&... aArgs)
Notify event to all subscribed observers.
Definition: observable.h:182
static const UTIL::CFG_MAP< KIGFX::GRID_STYLE > gridStyleConfigVals
static const UTIL::CFG_MAP< KIGFX::GRID_SNAPPING > gridSnapConfigVals
static const wxChar * traceGalDispOpts
Flag to enable GAL_DISPLAY_OPTIONS logging.
@ NONE
Definition: kibis.h:53
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266
GRID_STYLE
GRID_STYLE: Type definition of the grid style.
@ 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:49
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
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
bool always_show_cursor
Definition: app_settings.h:43
bool fullscreen_cursor
Definition: app_settings.h:44
double line_width
Definition: app_settings.h:59
double min_spacing
Definition: app_settings.h:60
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:83
CURSOR_SETTINGS cursor
Definition: app_settings.h:89
GRID_SETTINGS grid
Definition: app_settings.h:90