QGIS API Documentation
3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
src
core
qgsscreenproperties.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsscreenproperties.cpp
3
---------------
4
Date : June 2023
5
Copyright : (C) 2023 by Nyall Dawson
6
Email : nyall dot dawson at gmail dot com
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#include "
qgsscreenproperties.h
"
17
#include "
qgsrendercontext.h
"
18
19
#include <QScreen>
20
21
QgsScreenProperties::QgsScreenProperties
() =
default
;
22
23
QgsScreenProperties::QgsScreenProperties
(
const
QScreen *screen )
24
{
25
if
( screen )
26
{
27
mValid =
true
;
28
mDevicePixelRatio = screen->devicePixelRatio();
29
mPhysicalDpi = screen->physicalDotsPerInch();
30
}
31
}
32
33
void
QgsScreenProperties::setDevicePixelRatio
(
double
ratio )
34
{
35
mValid =
true
;
36
mDevicePixelRatio = ratio;
37
}
38
39
void
QgsScreenProperties::setPhysicalDpi
(
double
dpi )
40
{
41
mValid =
true
;
42
mPhysicalDpi = dpi;
43
}
44
45
void
QgsScreenProperties::updateRenderContextForScreen
(
QgsRenderContext
&context )
const
46
{
47
if
( !mValid )
48
return
;
49
50
context.
setScaleFactor
( mPhysicalDpi / 25.4 );
51
context.
setDevicePixelRatio
( mDevicePixelRatio );
52
}
QgsRenderContext
Contains information about the context of a rendering operation.
Definition
qgsrendercontext.h:62
QgsRenderContext::setScaleFactor
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
Definition
qgsrendercontext.h:522
QgsRenderContext::setDevicePixelRatio
void setDevicePixelRatio(float ratio)
Sets the device pixel ratio.
Definition
qgsrendercontext.cpp:811
QgsScreenProperties::QgsScreenProperties
QgsScreenProperties()
Constructor for invalid properties.
QgsScreenProperties::setPhysicalDpi
void setPhysicalDpi(double dpi)
Sets number of physical dots or pixels per inch.
Definition
qgsscreenproperties.cpp:39
QgsScreenProperties::setDevicePixelRatio
void setDevicePixelRatio(double ratio)
Sets the ratio between physical pixels and device-independent pixels for the screen.
Definition
qgsscreenproperties.cpp:33
QgsScreenProperties::updateRenderContextForScreen
void updateRenderContextForScreen(QgsRenderContext &context) const
Updates the settings in a render context to match the screen settings.
Definition
qgsscreenproperties.cpp:45
qgsrendercontext.h
qgsscreenproperties.h
Generated on Sun Nov 10 2024 14:15:43 for QGIS API Documentation by
1.9.8