QGIS API Documentation 4.1.0-Master (60fea48833c)
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 public:
42
47 explicit QgsScreenProperties( const QScreen *screen );
48
49 bool operator==( const QgsScreenProperties &other ) const { return mValid == other.mValid && mDevicePixelRatio == other.mDevicePixelRatio && mPhysicalDpi == other.mPhysicalDpi; }
50
51 bool operator!=( const QgsScreenProperties &other ) const { return !( *this == other ); }
52
56 bool isValid() const { return mValid; }
57
67 double devicePixelRatio() const { return mDevicePixelRatio; }
68
78 void setDevicePixelRatio( double ratio );
79
91 double physicalDpi() const { return mPhysicalDpi; }
92
104 void setPhysicalDpi( double dpi );
105
110 void updateRenderContextForScreen( QgsRenderContext &context ) const;
111
112 private:
113 bool mValid = false;
114 double mDevicePixelRatio = 1;
115 double mPhysicalDpi = 96;
116};
117
118#ifndef SIP_RUN
119#if ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) ) || defined( __clang__ )
120#pragma GCC diagnostic push
121#pragma GCC diagnostic ignored "-Wattributes"
122#elif defined( _MSC_VER )
123__pragma( warning( push ) ) __pragma( warning( disable : 4273 ) )
124#endif
125#endif
126
132CORE_EXPORT inline uint qHash( const QgsScreenProperties &properties ) SIP_SKIP
133{
134 return qHash( properties.devicePixelRatio() ) + qHash( properties.physicalDpi() );
135}
136
137#ifndef SIP_RUN
138#if ( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 6 ) ) || defined( __clang__ )
139#pragma GCC diagnostic pop
140#elif defined( _MSC_VER )
141__pragma( warning( pop ) )
142#endif
143#endif
144
145#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:133
CORE_EXPORT uint qHash(const QgsScreenProperties &properties)
Returns a hash for a screen properties.