Quantum GIS API Documentation  1.8
Public Member Functions | Private Attributes
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
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 (std::vector< double > &x, std::vector< 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.
void setYMaximum (double ymax)
 Set maximum y value.
void setYMinimum (double ymin)
 Set minimum y value.
void setXMinimum (double xmin)
 set minimum x value
void setParameters (double mapUnitsPerPixel, double xmin, double ymin, double ymax)
QString showParameters ()
 String representation of the parameters used in the transform.

Private Attributes

double mMapUnitsPerPixel
double yMax
double yMin
double xMin
double xMax

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 22 of file qgsmaptopixel.cpp.

destructor

Definition at line 34 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 61 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 86 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 81 of file qgsmaptopixel.cpp.

References xMin.

void QgsMapToPixel::setYMaximum ( double  ymax)

Set maximum y value.

Definition at line 71 of file qgsmaptopixel.cpp.

References yMax.

Referenced by QgsMapRenderer::render().

void QgsMapToPixel::setYMinimum ( double  ymin)

Set minimum y value.

Definition at line 76 of file qgsmaptopixel.cpp.

References yMin.

String representation of the parameters used in the transform.

Definition at line 95 of file qgsmaptopixel.cpp.

References mMapUnitsPerPixel, xMin, yMax, and yMin.

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

Tranform device coordinates to map (world) coordinates

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

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

References toMapPoint().

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

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

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

Parameters:
pPoint to transform
Returns:
QgsPoint in device coordinates

Definition at line 111 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 121 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 105 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 133 of file qgsmaptopixel.cpp.

References mMapUnitsPerPixel, xMin, yMax, and yMin.

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

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

Definition at line 139 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 Friends Defines