QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
Perform transforms between map coordinates and device coordinates. More...
#include <qgsmaptopixel.h>
Public Member Functions | |
QgsMapToPixel () | |
Constructor for an invalid QgsMapToPixel. | |
QgsMapToPixel (double mapUnitsPerPixel) | |
Constructor. | |
QgsMapToPixel (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation) | |
Constructor. | |
bool | isValid () const |
Returns true if the object is valid (i.e. | |
int | mapHeight () const |
Returns current map height in pixels. | |
double | mapRotation () const |
Returns the current map rotation in degrees (clockwise). | |
double | mapUnitsPerPixel () const |
Returns the current map units per pixel. | |
int | mapWidth () const |
Returns the current map width in pixels. | |
bool | operator!= (const QgsMapToPixel &other) const |
bool | operator== (const QgsMapToPixel &other) const |
void | setMapRotation (double degrees, double cx, double cy) |
Sets map rotation in degrees (clockwise). | |
void | setMapUnitsPerPixel (double mapUnitsPerPixel) |
Sets the map units per pixel. | |
void | setParameters (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation) |
Sets parameters for use in transforming coordinates. | |
void | setParameters (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation, bool *ok) |
Sets parameters for use in transforming coordinates. | |
QString | showParameters () const |
Returns a string representation of the parameters used in the transform. | |
QgsPointXY | toMapCoordinates (double x, double y) const |
Transforms device coordinates to map (world) coordinates. | |
QgsPointXY | toMapCoordinates (int x, int y) const |
Transforms device coordinates to map (world) coordinates. | |
QgsPointXY | toMapCoordinates (QPoint p) const |
Transforms device coordinates to map (world) coordinates. | |
Q_DECL_DEPRECATED QgsPointXY | toMapPoint (double x, double y) const |
Transforms device coordinates to map (world) coordinates. | |
QTransform | transform () const |
Returns a QTransform encapsulating the map to pixel conversion. | |
QgsPointXY | transform (const QgsPointXY &p) const |
Transforms a point p from map (world) coordinates to device coordinates. | |
void | transform (QgsPointXY *p) const |
Transforms a point p from map (world) coordinates to device coordinates in place. | |
QgsPointXY | transform (qreal x, qreal y) const |
Transforms the point specified by x,y from map (world) coordinates to device coordinates. | |
QRectF | transformBounds (const QRectF &bounds) const |
Transforms a bounding box from map coordinates to device coordinates. | |
void | transformInPlace (double &x, double &y) const |
Transforms map coordinates to device coordinates. | |
void | transformInPlace (float &x, float &y) const |
Transforms map coordinates to device coordinates. | |
template<class T > | |
void | transformInPlace (QVector< T > &x, QVector< T > &y) const |
Transforms map coordinates to device coordinates. | |
double | xCenter () const |
Returns the center x-coordinate for the transform. | |
double | yCenter () const |
Returns the center y-coordinate for the transform. | |
Static Public Member Functions | |
static QgsMapToPixel | fromScale (double scale, Qgis::DistanceUnit mapUnits, double dpi=96) |
Returns a new QgsMapToPixel created using a specified scale and distance unit. | |
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 | ( | ) |
Constructor for an invalid QgsMapToPixel.
A manual call to setParameters() is required to initialize the object.
Definition at line 63 of file qgsmaptopixel.cpp.
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 25 of file qgsmaptopixel.cpp.
QgsMapToPixel::QgsMapToPixel | ( | double | mapUnitsPerPixel | ) |
Constructor.
mapUnitsPerPixel | Map units per pixel |
Definition at line 45 of file qgsmaptopixel.cpp.
|
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 56 of file qgsmaptopixel.cpp.
|
inline |
Returns true
if the object is valid (i.e.
it has parameters set), or false
if the object is default constructed with no parameters set.
Definition at line 79 of file qgsmaptopixel.h.
|
inline |
Returns current map height in pixels.
Definition at line 274 of file qgsmaptopixel.h.
|
inline |
Returns the current map rotation in degrees (clockwise).
Definition at line 294 of file qgsmaptopixel.h.
|
inline |
Returns the current map units per pixel.
Definition at line 258 of file qgsmaptopixel.h.
|
inline |
Returns the current map width in pixels.
The information is only known if setRotation was used.
Definition at line 267 of file qgsmaptopixel.h.
|
inline |
Definition at line 364 of file qgsmaptopixel.h.
|
inline |
Definition at line 351 of file qgsmaptopixel.h.
void QgsMapToPixel::setMapRotation | ( | double | degrees, |
double | cx, | ||
double | cy | ||
) |
Sets map rotation in degrees (clockwise).
Calling this method will automatically set the object as valid.
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 92 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setMapUnitsPerPixel | ( | double | mapUnitsPerPixel | ) |
Sets the map units per pixel.
Calling this method will automatically set the object as valid.
mapUnitsPerPixel | Map units per pixel |
Definition at line 80 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setParameters | ( | double | mapUnitsPerPixel, |
double | centerX, | ||
double | centerY, | ||
int | widthPixels, | ||
int | heightPixels, | ||
double | rotation | ||
) |
Sets parameters for use in transforming coordinates.
Calling this method will automatically set the object as valid.
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 165 of file qgsmaptopixel.cpp.
void QgsMapToPixel::setParameters | ( | double | mapUnitsPerPixel, |
double | centerX, | ||
double | centerY, | ||
int | widthPixels, | ||
int | heightPixels, | ||
double | rotation, | ||
bool * | ok | ||
) |
Sets parameters for use in transforming coordinates.
Calling this method will automatically set the object as valid.
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 |
ok | will be set to true if the specified parameters result in a valid transform, otherwise the changes are ignored and ok will be set to false . |
Definition at line 119 of file qgsmaptopixel.cpp.
QString QgsMapToPixel::showParameters | ( | ) | const |
Returns a string representation of the parameters used in the transform.
Definition at line 177 of file qgsmaptopixel.cpp.
|
inline |
Transforms device coordinates to map (world) coordinates.
Definition at line 210 of file qgsmaptopixel.h.
|
inline |
Transforms device coordinates to map (world) coordinates.
Definition at line 202 of file qgsmaptopixel.h.
|
inline |
Transforms device coordinates to map (world) coordinates.
p | Point to be converted to map cooordinates |
Definition at line 226 of file qgsmaptopixel.h.
|
inline |
Transforms device coordinates to map (world) coordinates.
Definition at line 237 of file qgsmaptopixel.h.
QTransform QgsMapToPixel::transform | ( | ) | const |
Returns a QTransform encapsulating the map to pixel conversion.
Definition at line 187 of file qgsmaptopixel.cpp.
|
inline |
Transforms a point p from map (world) coordinates to device coordinates.
p | Point to transform |
Definition at line 86 of file qgsmaptopixel.h.
|
inline |
Transforms a point p from map (world) coordinates to device coordinates in place.
Definition at line 97 of file qgsmaptopixel.h.
|
inline |
Transforms the point specified by x,y from map (world) coordinates to device coordinates.
x | x coordinate of point to transform |
y | y coordinate of point to transform |
Definition at line 112 of file qgsmaptopixel.h.
|
inline |
Transforms a bounding box from map coordinates to device coordinates.
The returns bounding box will always completely enclose the transformed input bounding box (i.e. this method will grow the bounds wherever required).
Definition at line 140 of file qgsmaptopixel.h.
|
inline |
Transforms map coordinates to device coordinates.
This method modifies the given coordinates in place. It is intended as a fast way to do the transform.
Definition at line 124 of file qgsmaptopixel.h.
|
inline |
Transforms map coordinates to device coordinates.
This method modifies the given coordinates in place. It is intended as a fast way to do the transform.
Definition at line 170 of file qgsmaptopixel.h.
|
inline |
Transforms map coordinates to device coordinates.
This method modifies the given coordinates in place. It is intended as a fast way to do the transform.
Definition at line 188 of file qgsmaptopixel.h.
|
inline |
Returns the center x-coordinate for the transform.
Definition at line 343 of file qgsmaptopixel.h.
|
inline |
Returns the center y-coordinate for the transform.
Definition at line 349 of file qgsmaptopixel.h.