QGIS API Documentation 3.99.0-Master (21b3aa880ba)
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.h"
19#include "qgis_core.h"
20#include "qgis_sip.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
129#ifndef SIP_RUN
130#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
131#pragma GCC diagnostic push
132#pragma GCC diagnostic ignored "-Wattributes"
133#elif defined(_MSC_VER)
134__pragma( warning( push ) )
135__pragma( warning( disable: 4273 ) )
136#endif
137#endif
138
144CORE_EXPORT inline uint qHash( const QgsScreenProperties &properties ) SIP_SKIP
145{
146 return qHash( properties.devicePixelRatio() ) + qHash( properties.physicalDpi() );
147}
148
149#ifndef SIP_RUN
150#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) || defined(__clang__)
151#pragma GCC diagnostic pop
152#elif defined(_MSC_VER)
153__pragma( warning( pop ) )
154#endif
155#endif
156
157#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:134
CORE_EXPORT uint qHash(const QgsScreenProperties &properties)
Returns a hash for a screen properties.