QGIS API Documentation  2.99.0-Master (23ddace)
qgsmapunitscale.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmapunitscale.h
3  Struct for storing maximum and minimum scales for measurements in map units
4  -------------------
5  begin : April 2014
6  copyright : (C) Sandro Mani
7  email : smani at sourcepole dot ch
8 
9  ***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSMAPUNITSCALE_H
19 #define QGSMAPUNITSCALE_H
20 
21 #include "qgis_core.h"
22 #include "qgis.h"
23 #include <QtCore>
24 
25 class QgsRenderContext;
26 
36 class CORE_EXPORT QgsMapUnitScale
37 {
38  public:
39 
46  explicit QgsMapUnitScale( double minScale = 0.0, double maxScale = 0.0 )
47  : minScale( minScale )
48  , maxScale( maxScale )
49  , minSizeMMEnabled( false )
50  , minSizeMM( 0.0 )
51  , maxSizeMMEnabled( false )
52  , maxSizeMM( 0.0 )
53  {}
54 
59  double minScale;
60 
65  double maxScale;
66 
70  double minSizeMM;
74  double maxSizeMM;
75 
81  double computeMapUnitsPerPixel( const QgsRenderContext &c ) const;
82 
83  bool operator==( const QgsMapUnitScale &other ) const
84  {
85  return qgsDoubleNear( minScale, other.minScale )
86  && qgsDoubleNear( maxScale, other.maxScale )
87  && minSizeMMEnabled == other.minSizeMMEnabled
88  && qgsDoubleNear( minSizeMM, other.minSizeMM )
89  && maxSizeMMEnabled == other.maxSizeMMEnabled
90  && qgsDoubleNear( maxSizeMM, other.maxSizeMM );
91  }
92 
93  bool operator!=( const QgsMapUnitScale &other ) const
94  {
95  return !operator==( other );
96  }
97 };
98 
99 
100 #endif // QGSMAPUNITSCALE_H
101 
102 
103 
double minSizeMM
The minimum size in millimeters, or 0.0 if unset.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Definition: qgis.h:203
double maxScale
The maximum scale, or 0.0 if unset.
bool operator!=(const QgsMapUnitScale &other) const
bool minSizeMMEnabled
Whether the minimum size in mm should be respected.
bool operator==(const QgsMapUnitScale &other) const
Contains information about the context of a rendering operation.
QgsMapUnitScale(double minScale=0.0, double maxScale=0.0)
Constructor for QgsMapUnitScale.
double maxSizeMM
The maximum size in millimeters, or 0.0 if unset.
Struct for storing maximum and minimum scales for measurements in map units.
double minScale
The minimum scale, or 0.0 if unset.
bool maxSizeMMEnabled
Whether the maximum size in mm should be respected.