QGIS API Documentation  master-28efcda
QgsMapToPixel Class Reference

Perform transforms between map coordinates and device coordinates. More...

#include <qgsmaptopixel.h>

List of all members.

Public Member Functions

 QgsMapToPixel (double mapUnitsPerPixel=0, double ymax=0, double ymin=0, double xmin=0)
 ~QgsMapToPixel ()
 destructor
double mapUnitsPerPixel () const
 Return current map units per pixel.
void setMapUnitsPerPixel (double mapUnitsPerPixel)
void setParameters (double mapUnitsPerPixel, double xmin, double ymin, double ymax)
void setXMinimum (double xmin)
 set minimum x value
void setYMaximum (double ymax)
 Set maximum y value.
void setYMinimum (double ymin)
 Set minimum y value.
QString showParameters ()
 String representation of the parameters used in the transform.
QgsPoint toMapCoordinates (int x, int y) const
QgsPoint toMapCoordinates (QPoint p) const
QgsPoint toMapCoordinatesF (double x, double y) const
QgsPoint toMapPoint (double x, double y) const
QgsPoint transform (const QgsPoint &p) const
void transform (QgsPoint *p) const
QgsPoint transform (double x, double y) const
void transformInPlace (double &x, double &y) const
void transformInPlace (QVector< double > &x, QVector< double > &y) const

Private Attributes

double mMapUnitsPerPixel
double xMax
double xMin
double yMax
double yMin

Detailed Description

Perform transforms between map coordinates and device coordinates.

This class can convert device coordinates to map coordinates and vice versa.

Definition at line 33 of file qgsmaptopixel.h.


Constructor & Destructor Documentation

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel = 0,
double  ymax = 0,
double  ymin = 0,
double  xmin = 0 
)

Definition at line 25 of file qgsmaptopixel.cpp.

destructor

Definition at line 37 of file qgsmaptopixel.cpp.


Member Function Documentation

void QgsMapToPixel::setMapUnitsPerPixel ( double  mapUnitsPerPixel)

Set map units per pixel

Parameters:
mapUnitsPerPixelMap units per pixel

Definition at line 64 of file qgsmaptopixel.cpp.

References mapUnitsPerPixel(), and mMapUnitsPerPixel.

Referenced by QgsMapRenderer::render().

void QgsMapToPixel::setParameters ( double  mapUnitsPerPixel,
double  xmin,
double  ymin,
double  ymax 
)

Set parameters for use in tranfsorming coordinates

Parameters:
mapUnitsPerPixelMap units per pixel
xminMinimum x value
yminMinimum y value
ymaxMaximum y value

Definition at line 89 of file qgsmaptopixel.cpp.

References mapUnitsPerPixel(), mMapUnitsPerPixel, xMin, yMax, and yMin.

Referenced by QgsMapRenderer::adjustExtentToSize().

void QgsMapToPixel::setXMinimum ( double  xmin)

set minimum x value

Definition at line 84 of file qgsmaptopixel.cpp.

References xMin.

void QgsMapToPixel::setYMaximum ( double  ymax)

Set maximum y value.

Definition at line 74 of file qgsmaptopixel.cpp.

References yMax.

Referenced by QgsMapRenderer::render().

void QgsMapToPixel::setYMinimum ( double  ymin)

Set minimum y value.

Definition at line 79 of file qgsmaptopixel.cpp.

References yMin.

String representation of the parameters used in the transform.

Definition at line 98 of file qgsmaptopixel.cpp.

References mMapUnitsPerPixel, xMin, yMax, and yMin.

Tranform device coordinates to map (world) coordinates

Parameters:
pPoint to be converted to map cooordinates
Returns:
QgsPoint in map coorndiates

Definition at line 48 of file qgsmaptopixel.cpp.

References toMapPoint().

QgsPoint QgsMapToPixel::toMapCoordinatesF ( double  x,
double  y 
) const

Transform device coordinates to map (world) coordinates

Note:
: this method was added in version 1.6

Definition at line 59 of file qgsmaptopixel.cpp.

References toMapPoint().

Referenced by QgsPalLayerSettings::calculateLabelSize(), QgsRasterLayer::draw(), and QgsPalGeometry::info().

Transform the point from map (world) coordinates to device coordinates

Parameters:
pPoint to transform
Returns:
QgsPoint in device coordinates

Definition at line 114 of file qgsmaptopixel.cpp.

References transformInPlace(), QgsPoint::x(), and QgsPoint::y().

Referenced by QgsRasterLayer::draw(), QgsMapOverviewCanvas::drawExtentRect(), QgsPalLabeling::drawLabel(), QgsPalLabeling::drawLabelCandidateRect(), QgsPalLabeling::drawLabeling(), and QgsLabel::renderLabel().

void QgsMapToPixel::transform ( QgsPoint p) const

Definition at line 124 of file qgsmaptopixel.cpp.

References QgsPoint::set(), transformInPlace(), QgsPoint::x(), and QgsPoint::y().

QgsPoint QgsMapToPixel::transform ( double  x,
double  y 
) const

Transform the point specified by x,y from map (world) coordinates to device coordinates

Parameters:
xx cordinate o point to transform
yy coordinate of point to transform
Returns:
QgsPoint in device coordinates

Definition at line 108 of file qgsmaptopixel.cpp.

References transformInPlace().

void QgsMapToPixel::transformInPlace ( double &  x,
double &  y 
) const

Tranform device coordinates to map (world) coordinates

Parameters:
xx coordinate of point to be converted to map cooordinates
yy coordinate of point to be converted to map cooordinates
Returns:
QgsPoint in map coordinates

Definition at line 136 of file qgsmaptopixel.cpp.

References mMapUnitsPerPixel, xMin, yMax, and yMin.

Referenced by QgsFeatureRendererV2::_getLineString(), QgsFeatureRendererV2::_getPoint(), QgsFeatureRendererV2::_getPolygon(), QgsMapCanvasItem::toCanvasCoordinates(), QgsMapTool::toCanvasCoordinates(), transform(), and transformInPlace().

void QgsMapToPixel::transformInPlace ( QVector< double > &  x,
QVector< double > &  y 
) const

Definition at line 142 of file qgsmaptopixel.cpp.

References transformInPlace().


Member Data Documentation

double QgsMapToPixel::xMax [private]

Definition at line 124 of file qgsmaptopixel.h.

double QgsMapToPixel::xMin [private]
double QgsMapToPixel::yMax [private]
double QgsMapToPixel::yMin [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines