QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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
22
24{
25 if ( screen )
26 {
27 mValid = true;
28 mDevicePixelRatio = screen->devicePixelRatio();
29 mPhysicalDpi = screen->physicalDotsPerInch();
30 }
31}
32
34{
35 mValid = true;
36 mDevicePixelRatio = ratio;
37}
38
40{
41 mValid = true;
42 mPhysicalDpi = dpi;
43}
44
46{
47 if ( !mValid )
48 return;
49
50 context.setScaleFactor( mPhysicalDpi / 25.4 );
51 context.setDevicePixelRatio( mDevicePixelRatio );
52}
Contains information about the context of a rendering operation.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
void setDevicePixelRatio(float ratio)
Sets the device pixel ratio.
QgsScreenProperties()
Constructor for invalid properties.
void setPhysicalDpi(double dpi)
Sets number of physical dots or pixels per inch.
void setDevicePixelRatio(double ratio)
Sets the ratio between physical pixels and device-independent pixels for the screen.
void updateRenderContextForScreen(QgsRenderContext &context) const
Updates the settings in a render context to match the screen settings.