QGIS API Documentation
2.4.0-Chugiak
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
24
class
CORE_EXPORT
QgsMapUnitScale
25
{
26
public
:
27
QgsMapUnitScale
() : minScale( 0.0 ), maxScale( 0.0 ) {}
28
QgsMapUnitScale
(
float
_minScale,
float
_maxScale ) : minScale( _minScale ), maxScale( _maxScale ) {}
29
31
double
minScale
;
33
double
maxScale
;
34
35
double
computeMapUnitsPerPixel
(
const
QgsRenderContext
& c )
const
36
{
37
double
mup = c.
mapToPixel
().
mapUnitsPerPixel
();
38
double
renderScale = c.
rendererScale
();
// Note: this value is 1 / scale
39
if
( minScale != 0 )
40
{
41
mup = qMin( mup / ( minScale * renderScale ), mup );
42
}
43
if
( maxScale != 0 )
44
{
45
mup = qMax( mup / ( maxScale * renderScale ), mup );
46
}
47
return
mup;
48
}
49
50
bool
operator==
(
const
QgsMapUnitScale
& other )
const
51
{
52
return
minScale == other.
minScale
&& maxScale == other.
maxScale
;
53
}
54
55
bool
operator!=
(
const
QgsMapUnitScale
& other )
const
56
{
57
return
minScale != other.
minScale
|| maxScale != other.
maxScale
;
58
}
59
};
60
61
62
#endif // QGSMAPUNITSCALE_H
63
64
65
qgsrendercontext.h
QgsMapUnitScale::operator==
bool operator==(const QgsMapUnitScale &other) const
Definition:
qgsmapunitscale.h:50
QgsRenderContext::rendererScale
double rendererScale() const
Definition:
qgsrendercontext.h:77
QgsMapUnitScale::computeMapUnitsPerPixel
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Definition:
qgsmapunitscale.h:35
QgsMapUnitScale::maxScale
double maxScale
The maximum scale, or 0.0 if unset.
Definition:
qgsmapunitscale.h:33
QgsMapUnitScale::QgsMapUnitScale
QgsMapUnitScale()
Definition:
qgsmapunitscale.h:27
QgsMapToPixel::mapUnitsPerPixel
double mapUnitsPerPixel() const
Return current map units per pixel.
Definition:
qgsmaptopixel.cpp:68
QgsRenderContext
Contains information about the context of a rendering operation.
Definition:
qgsrendercontext.h:39
QgsMapUnitScale
Definition:
qgsmapunitscale.h:24
QgsMapUnitScale::QgsMapUnitScale
QgsMapUnitScale(float _minScale, float _maxScale)
Definition:
qgsmapunitscale.h:28
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Definition:
qgsrendercontext.h:58
QgsMapUnitScale::operator!=
bool operator!=(const QgsMapUnitScale &other) const
Definition:
qgsmapunitscale.h:55
QgsMapUnitScale::minScale
double minScale
The minimum scale, or 0.0 if unset.
Definition:
qgsmapunitscale.h:31
Generated on Wed Mar 18 2015 11:40:12 for QGIS API Documentation by
1.8.9.1