QGIS API Documentation
3.2.0-Bonn (bc43194)
|
Perform transforms between map coordinates and device coordinates. More...
#include <qgsmaptopixel.h>
Public Member Functions | |
QgsMapToPixel (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation) | |
Constructor. More... | |
QgsMapToPixel (double mapUnitsPerPixel) | |
Constructor. More... | |
QgsMapToPixel () | |
Constructor. More... | |
int | mapHeight () const |
Returns current map height in pixels. More... | |
double | mapRotation () const |
Returns current map rotation in degrees. More... | |
double | mapUnitsPerPixel () const |
Returns current map units per pixel. More... | |
int | mapWidth () const |
Returns current map width in pixels The information is only known if setRotation was used. More... | |
void | setMapRotation (double degrees, double cx, double cy) |
Set map rotation in degrees (clockwise) More... | |
void | setMapUnitsPerPixel (double mapUnitsPerPixel) |
Set map units per pixel. More... | |
void | setParameters (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation) |
Set parameters for use in transforming coordinates. More... | |
QString | showParameters () const |
String representation of the parameters used in the transform. More... | |
QgsPointXY | toMapCoordinates (int x, int y) const |
QgsPointXY | toMapCoordinates (QPoint p) const |
Transform device coordinates to map (world) coordinates. More... | |
QgsPointXY | toMapCoordinatesF (double x, double y) const |
Transform device coordinates to map (world) coordinates. More... | |
QgsPointXY | toMapPoint (double x, double y) const |
QgsPointXY | transform (const QgsPointXY &p) const |
Transform the point from map (world) coordinates to device coordinates. More... | |
void | transform (QgsPointXY *p) const |
QgsPointXY | transform (qreal x, qreal y) const |
Transform the point specified by x,y from map (world) coordinates to device coordinates. More... | |
QTransform | transform () const |
void | transformInPlace (double &x, double &y) const |
Transform device coordinates to map coordinates. More... | |
void | transformInPlace (float &x, float &y) const |
template<class T > | |
void | transformInPlace (QVector< T > &x, QVector< T > &y) const |
Transform device coordinates to map coordinates. More... | |
double | xCenter () const |
Returns the center x-coordinate for the transform. More... | |
double | yCenter () const |
Returns the center y-coordinate for the transform. More... | |
Static Public Member Functions | |
static QgsMapToPixel | fromScale (double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi=96) |
Returns a new QgsMapToPixel created using a specified scale and distance unit. More... | |
Perform transforms between map coordinates and device coordinates.
This class can convert device coordinates to map coordinates and vice versa.
Definition at line 36 of file qgsmaptopixel.h.
QgsMapToPixel::QgsMapToPixel | ( | double | mapUnitsPerPixel, |
double | centerX, | ||
double | centerY, | ||
int | widthPixels, | ||
int | heightPixels, | ||
double | rotation | ||
) |
Constructor.
mapUnitsPerPixel | Map units per pixel |
centerX | X coordinate of map center, in geographical units |
centerY | Y coordinate of map center, in geographical units |
widthPixels | Output width, in pixels |
heightPixels | Output height, in pixels |
rotation | clockwise rotation in degrees |
Definition at line 28 of file qgsmaptopixel.cpp.
QgsMapToPixel::QgsMapToPixel | ( | double | mapUnitsPerPixel | ) |
Constructor.
mapUnitsPerPixel | Map units per pixel |
Definition at line 47 of file qgsmaptopixel.cpp.
QgsMapToPixel::QgsMapToPixel | ( | ) |
|
static |
Returns a new QgsMapToPixel created using a specified scale and distance unit.
scale | map scale denominator, e.g. 1000.0 for a 1:1000 map. |
dpi | screen DPI |
mapUnits | map units |
Definition at line 57 of file qgsmaptopixel.cpp.
int QgsMapToPixel::mapHeight | ( | ) | const |
Returns current map height in pixels.
Definition at line 69 of file qgsmaptopixel.cpp.
double QgsMapToPixel::mapRotation | ( | ) | const |
Returns current map rotation in degrees.
Definition at line 159 of file qgsmaptopixel.cpp.
double QgsMapToPixel::mapUnitsPerPixel | ( | ) | const |
Returns current map units per pixel.
Definition at line 129 of file qgsmaptopixel.cpp.
int QgsMapToPixel::mapWidth | ( | ) | const |
Returns current map width in pixels The information is only known if setRotation was used.
Definition at line 74 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setMapRotation | ( | double | degrees, |
double | cx, | ||
double | cy | ||
) |
Set map rotation in degrees (clockwise)
degrees | clockwise rotation in degrees |
cx | X ordinate of map center in geographical units |
cy | Y ordinate of map center in geographical units |
Definition at line 134 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setMapUnitsPerPixel | ( | double | mapUnitsPerPixel | ) |
Set map units per pixel.
mapUnitsPerPixel | Map units per pixel |
Definition at line 119 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setParameters | ( | double | mapUnitsPerPixel, |
double | centerX, | ||
double | centerY, | ||
int | widthPixels, | ||
int | heightPixels, | ||
double | rotation | ||
) |
Set parameters for use in transforming coordinates.
mapUnitsPerPixel | Map units per pixel |
centerX | X coordinate of map center, in geographical units |
centerY | Y coordinate of map center, in geographical units |
widthPixels | Output width, in pixels |
heightPixels | Output height, in pixels |
rotation | clockwise rotation in degrees |
Definition at line 164 of file qgsmaptopixel.cpp.
QString QgsMapToPixel::showParameters | ( | ) | const |
String representation of the parameters used in the transform.
Definition at line 202 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::toMapCoordinates | ( | int | x, |
int | y | ||
) | const |
Definition at line 109 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::toMapCoordinates | ( | QPoint | p | ) | const |
Transform device coordinates to map (world) coordinates.
p | Point to be converted to map cooordinates |
Definition at line 103 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::toMapCoordinatesF | ( | double | x, |
double | y | ||
) | const |
Transform device coordinates to map (world) coordinates.
Definition at line 114 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::toMapPoint | ( | double | x, |
double | y | ||
) | const |
Definition at line 91 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::transform | ( | const QgsPointXY & | p | ) | const |
Transform the point from map (world) coordinates to device coordinates.
p | Point to transform |
Definition at line 218 of file qgsmaptopixel.cpp.
void QgsMapToPixel::transform | ( | QgsPointXY * | p | ) | const |
Definition at line 226 of file qgsmaptopixel.cpp.
QgsPointXY QgsMapToPixel::transform | ( | qreal | x, |
qreal | y | ||
) | const |
Transform the point specified by x,y from map (world) coordinates to device coordinates.
x | x cordinate o point to transform |
y | y coordinate of point to transform |
Definition at line 212 of file qgsmaptopixel.cpp.
QTransform QgsMapToPixel::transform | ( | ) | const |
Definition at line 253 of file qgsmaptopixel.cpp.
void QgsMapToPixel::transformInPlace | ( | double & | x, |
double & | y | ||
) | const |
Transform device coordinates to map coordinates.
Modifies the given coordinates in place. Intended as a fast way to do the transform.
Definition at line 234 of file qgsmaptopixel.cpp.
void QgsMapToPixel::transformInPlace | ( | float & | x, |
float & | y | ||
) | const |
Definition at line 245 of file qgsmaptopixel.cpp.
|
inline |
Transform device coordinates to map coordinates.
Modifies the given coordinates in place. Intended as a fast way to do the transform.
Definition at line 112 of file qgsmaptopixel.h.
|
inline |
Returns the center x-coordinate for the transform.
Definition at line 193 of file qgsmaptopixel.h.
|
inline |
Returns the center y-coordinate for the transform.
Definition at line 200 of file qgsmaptopixel.h.