QGIS API Documentation  2.4.0-Chugiak
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
QgsMapToPixel Class Reference

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

#include <qgsmaptopixel.h>

Public Member Functions

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

Private Attributes

double mMapUnitsPerPixel
 
double yMax
 
double yMin
 
double xMin
 

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.

QgsMapToPixel::~QgsMapToPixel ( )

destructor

Definition at line 36 of file qgsmaptopixel.cpp.

Member Function Documentation

double QgsMapToPixel::mapUnitsPerPixel ( ) const
void QgsMapToPixel::setMapUnitsPerPixel ( double  mapUnitsPerPixel)

Set map units per pixel

Parameters
mapUnitsPerPixelMap units per pixel

Definition at line 63 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 88 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 83 of file qgsmaptopixel.cpp.

References xMin.

void QgsMapToPixel::setYMaximum ( double  ymax)

Set maximum y value.

Definition at line 73 of file qgsmaptopixel.cpp.

References yMax.

Referenced by QgsMapRenderer::render().

void QgsMapToPixel::setYMinimum ( double  ymin)

Set minimum y value.

Definition at line 78 of file qgsmaptopixel.cpp.

References yMin.

QString QgsMapToPixel::showParameters ( )

String representation of the parameters used in the transform.

Definition at line 97 of file qgsmaptopixel.cpp.

References mMapUnitsPerPixel, xMin, yMax, and yMin.

QgsPoint QgsMapToPixel::toMapCoordinates ( int  x,
int  y 
) const
QgsPoint QgsMapToPixel::toMapCoordinates ( QPoint  p) const

Tranform device coordinates to map (world) coordinates

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

Definition at line 47 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 58 of file qgsmaptopixel.cpp.

References toMapPoint().

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

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

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

Parameters
pPoint to transform
Returns
QgsPoint in device coordinates

Definition at line 113 of file qgsmaptopixel.cpp.

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

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

void QgsMapToPixel::transform ( QgsPoint p) const

Definition at line 123 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 107 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 135 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 149 of file qgsmaptopixel.cpp.

References transformInPlace().

Member Data Documentation

double QgsMapToPixel::mMapUnitsPerPixel
private
double QgsMapToPixel::xMin
private
double QgsMapToPixel::yMax
private
double QgsMapToPixel::yMin
private

The documentation for this class was generated from the following files: