QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
quickgui
qgsquickmaptransform.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsquickmaptransform.cpp
3
--------------------------------------
4
Date : 27.12.2014
5
Copyright : (C) 2014 by Matthias Kuhn
6
Email : matthias (at) opengis.ch
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
16
#include "
qgsquickmaptransform.h
"
17
18
#include "moc_qgsquickmaptransform.cpp"
19
20
void
QgsQuickMapTransform::applyTo
( QMatrix4x4 *matrix )
const
21
{
22
*matrix *= mMatrix;
23
matrix->optimize();
24
}
25
26
QgsQuickMapSettings
*
QgsQuickMapTransform::mapSettings
()
const
27
{
28
return
mMapSettings;
29
}
30
31
void
QgsQuickMapTransform::setMapSettings
(
QgsQuickMapSettings
*
mapSettings
)
32
{
33
if
(
mapSettings
== mMapSettings )
34
return
;
35
36
if
( mMapSettings )
37
disconnect( mMapSettings, &
QgsQuickMapSettings::visibleExtentChanged
,
this
, &QgsQuickMapTransform::updateMatrix );
38
39
mMapSettings =
mapSettings
;
40
41
if
( mMapSettings )
42
connect( mMapSettings, &
QgsQuickMapSettings::visibleExtentChanged
,
this
, &QgsQuickMapTransform::updateMatrix );
43
44
updateMatrix();
45
46
emit
mapSettingsChanged
();
47
}
48
49
void
QgsQuickMapTransform::updateMatrix()
50
{
51
QMatrix4x4 matrix;
52
float
scaleFactor =
static_cast<
float
>
( ( 1.0 / mMapSettings->
mapUnitsPerPixel
() ) / mMapSettings->
devicePixelRatio
() );
53
54
matrix.scale( scaleFactor, -scaleFactor );
55
matrix.translate(
static_cast<
float
>
( -mMapSettings->
visibleExtent
().
xMinimum
() ),
static_cast<
float
>
( -mMapSettings->
visibleExtent
().
yMaximum
() ) );
56
57
mMatrix = matrix;
58
update();
59
}
QgsQuickMapSettings
Encapsulates QgsMapSettings class to offer settings of configuration of map rendering via QML propert...
Definition
qgsquickmapsettings.h:45
QgsQuickMapSettings::visibleExtent
QgsRectangle visibleExtent
Returns the actual extent derived from requested extent that takes output image size into account.
Definition
qgsquickmapsettings.h:72
QgsQuickMapSettings::visibleExtentChanged
void visibleExtentChanged()
Returns the actual extent derived from requested extent that takes output image size into account.
QgsQuickMapSettings::mapUnitsPerPixel
double mapUnitsPerPixel
Returns the distance in geographical coordinates that equals to one pixel in the map.
Definition
qgsquickmapsettings.h:74
QgsQuickMapSettings::devicePixelRatio
qreal devicePixelRatio() const
Returns the ratio between physical pixels and device-independent pixels.
Definition
qgsquickmapsettings.cpp:310
QgsQuickMapTransform::setMapSettings
void setMapSettings(QgsQuickMapSettings *mapSettings)
Associated map settings.
Definition
qgsquickmaptransform.cpp:31
QgsQuickMapTransform::applyTo
void applyTo(QMatrix4x4 *matrix) const override
Applies transformation based on current map settings to a matrix.
Definition
qgsquickmaptransform.cpp:20
QgsQuickMapTransform::mapSettings
QgsQuickMapSettings * mapSettings
Associated map settings.
Definition
qgsquickmaptransform.h:43
QgsQuickMapTransform::mapSettingsChanged
void mapSettingsChanged()
Associated map settings.
QgsRectangle::xMinimum
double xMinimum
Definition
qgsrectangle.h:50
QgsRectangle::yMaximum
double yMaximum
Definition
qgsrectangle.h:53
qgsquickmaptransform.h
Generated on
for QGIS API Documentation by
1.17.0