QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
qgsscreenproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsscreenproperties.h
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#ifndef QGSSCREENPROPERTIES_H
16#define QGSSCREENPROPERTIES_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include "qgis.h"
21
22class QScreen;
24
35class CORE_EXPORT QgsScreenProperties
36{
37
38 public:
39
44
49 explicit QgsScreenProperties( const QScreen *screen );
50
51 bool operator==( const QgsScreenProperties &other ) const
52 {
53 return mValid == other.mValid
54 && mDevicePixelRatio == other.mDevicePixelRatio
55 && mPhysicalDpi == other.mPhysicalDpi;
56 }
57
58 bool operator!=( const QgsScreenProperties &other ) const
59 {
60 return !( *this == other );
61 }
62
66 bool isValid() const { return mValid; }
67
77 double devicePixelRatio() const { return mDevicePixelRatio; }
78
88 void setDevicePixelRatio( double ratio );
89
101 double physicalDpi() const { return mPhysicalDpi; }
102
114 void setPhysicalDpi( double dpi );
115
120 void updateRenderContextForScreen( QgsRenderContext &context ) const;
121
122 private:
123
124 bool mValid = false;
125 double mDevicePixelRatio = 1;
126 double mPhysicalDpi = 96;
127};
128
134CORE_EXPORT inline uint qHash( const QgsScreenProperties &properties ) SIP_SKIP
135{
136 return qHash( properties.devicePixelRatio() ) + qHash( properties.physicalDpi() );
137}
138
139#endif // QGSSCREENPROPERTIES_H
Contains information about the context of a rendering operation.
Stores properties relating to a screen.
QgsScreenProperties()
Constructor for invalid properties.
double physicalDpi() const
This property holds the number of physical dots or pixels per inch.
double devicePixelRatio() const
Returns the ratio between physical pixels and device-independent pixels for the screen.
bool isValid() const
Returns true if the properties are valid.
bool operator==(const QgsScreenProperties &other) const
bool operator!=(const QgsScreenProperties &other) const
#define SIP_SKIP
Definition qgis_sip.h:126
CORE_EXPORT uint qHash(const QgsScreenProperties &properties)
Returns a hash for a screen properties.