QGIS API Documentation
2.8.6-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
src
core
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 <QtCore>
22
#include "
qgsrendercontext.h
"
23
33
class
CORE_EXPORT
QgsMapUnitScale
34
{
35
public
:
36
41
QgsMapUnitScale
(
double
minScale = 0.0,
double
maxScale = 0.0 ) : minScale( minScale ), maxScale( maxScale ) {}
42
44
double
minScale
;
46
double
maxScale
;
47
53
double
computeMapUnitsPerPixel
(
const
QgsRenderContext
& c )
const
54
{
55
double
mup = c.
mapToPixel
().
mapUnitsPerPixel
();
56
double
renderScale = c.
rendererScale
();
// Note: this value is 1 / scale
57
if
( minScale != 0 )
58
{
59
mup = qMin( mup / ( minScale * renderScale ), mup );
60
}
61
if
( maxScale != 0 )
62
{
63
mup = qMax( mup / ( maxScale * renderScale ), mup );
64
}
65
return
mup;
66
}
67
68
bool
operator==
(
const
QgsMapUnitScale
& other )
const
69
{
70
return
minScale == other.
minScale
&& maxScale == other.
maxScale
;
71
}
72
73
bool
operator!=
(
const
QgsMapUnitScale
& other )
const
74
{
75
return
minScale != other.
minScale
|| maxScale != other.
maxScale
;
76
}
77
};
78
79
80
#endif // QGSMAPUNITSCALE_H
81
82
83
qgsrendercontext.h
QgsMapUnitScale::operator==
bool operator==(const QgsMapUnitScale &other) const
Definition:
qgsmapunitscale.h:68
QgsRenderContext::rendererScale
double rendererScale() const
Definition:
qgsrendercontext.h:75
QgsMapUnitScale::computeMapUnitsPerPixel
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
Definition:
qgsmapunitscale.h:53
QgsMapUnitScale::maxScale
double maxScale
The maximum scale, or 0.0 if unset.
Definition:
qgsmapunitscale.h:46
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Return current map units per pixel.
Definition:
qgsmaptopixel.cpp:153
QgsRenderContext
Contains information about the context of a rendering operation.
Definition:
qgsrendercontext.h:39
QgsMapUnitScale::QgsMapUnitScale
QgsMapUnitScale(double minScale=0.0, double maxScale=0.0)
Constructor for QgsMapUnitScale.
Definition:
qgsmapunitscale.h:41
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition:
qgsmapunitscale.h:33
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Definition:
qgsrendercontext.h:58
QgsMapUnitScale::operator!=
bool operator!=(const QgsMapUnitScale &other) const
Definition:
qgsmapunitscale.h:73
QgsMapUnitScale::minScale
double minScale
The minimum scale, or 0.0 if unset.
Definition:
qgsmapunitscale.h:44
Generated on Wed Mar 30 2016 18:49:01 for QGIS API Documentation by
1.8.11