56 QgsMapToPixel(
double mapUnitsPerPixel,
double centerX,
double centerY,
int widthPixels,
int heightPixels,
double rotation );
90 transformInPlace( x, y );
101 transformInPlace( x, y );
114 transformInPlace( x, y );
127 mMatrix.map(
static_cast< qreal
>( x ),
static_cast< qreal
>( y ), &mx, &my );
142 QPointF topLeft = bounds.topLeft();
143 QPointF topRight = bounds.topRight();
144 QPointF bottomLeft = bounds.bottomLeft();
145 QPointF bottomRight = bounds.bottomRight();
147 transformInPlace( topLeft.rx(), topLeft.ry() );
148 transformInPlace( topRight.rx(), topRight.ry() );
149 transformInPlace( bottomLeft.rx(), bottomLeft.ry() );
150 transformInPlace( bottomRight.rx(), bottomRight.ry() );
152 auto minMaxX = std::minmax( { topLeft.x(), topRight.x(), bottomLeft.x(), bottomRight.x() } );
153 auto minMaxY = std::minmax( { topLeft.y(), topRight.y(), bottomLeft.y(), bottomRight.y() } );
155 const double left = minMaxX.first;
156 const double right = minMaxX.second;
157 const double top = minMaxY.first;
158 const double bottom = minMaxY.second;
159 return QRectF( left, top, right - left, bottom - top );
172 double mx = x, my = y;
173 transformInPlace( mx, my );
190 assert( x.size() == y.size() );
193 const auto size = x.size();
194 for (
int i = 0; i < size; ++i )
195 transformInPlace( *xData++, *yData++ );
204 return toMapCoordinates(
static_cast<double>( x ),
static_cast<double>( y ) );
213 const QTransform matrix = mMatrix.inverted( &invertible );
214 assert( invertible );
216 matrix.map(
static_cast< qreal
>( x ),
static_cast< qreal
>( y ), &mx, &my );
228 const QgsPointXY mapPt = toMapCoordinates(
static_cast<double>( p.x() ),
static_cast<double>( p.y() ) );
239 return toMapCoordinates( x, y );
251 void setMapUnitsPerPixel(
double mapUnitsPerPixel );
287 void setMapRotation(
double degrees,
double cx,
double cy );
310 void setParameters(
double mapUnitsPerPixel,
double centerX,
double centerY,
int widthPixels,
int heightPixels,
double rotation );
327 void setParameters(
double mapUnitsPerPixel,
double centerX,
double centerY,
int widthPixels,
int heightPixels,
double rotation,
bool *ok )
SIP_SKIP;
332 QString showParameters()
const;
337 QTransform transform()
const;
353 return mValid == other.mValid
354 && mMapUnitsPerPixel == other.mMapUnitsPerPixel
355 && mWidth == other.mWidth
356 && mHeight == other.mHeight
357 && mRotation == other.mRotation
358 && mXCenter == other.mXCenter
359 && mYCenter == other.mYCenter
360 && mXMin == other.mXMin
361 && mYMin == other.mYMin;
366 return !( *
this == other );
371 double mMapUnitsPerPixel = 1;
374 double mRotation = 0.0;
375 double mXCenter = 0.5;
376 double mYCenter = 0.5;
DistanceUnit
Units of distance.
Perform transforms between map coordinates and device coordinates.
QRectF transformBounds(const QRectF &bounds) const
Transforms a bounding box from map coordinates to device coordinates.
bool isValid() const
Returns true if the object is valid (i.e.
int mapHeight() const
Returns current map height in pixels.
double xCenter() const
Returns the center x-coordinate for the transform.
double yCenter() const
Returns the center y-coordinate for the transform.
QgsPointXY transform(qreal x, qreal y) const
Transforms the point specified by x,y from map (world) coordinates to device coordinates.
QgsPointXY toMapCoordinates(double x, double y) const
Transforms device coordinates to map (world) coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
bool operator==(const QgsMapToPixel &other) const
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
int mapWidth() const
Returns the current map width in pixels.
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.
void transformInPlace(QVector< T > &x, QVector< T > &y) const
Transforms map coordinates to device coordinates.
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
bool operator!=(const QgsMapToPixel &other) const
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.
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.
A class to represent a 2D point.
void set(double x, double y)
Sets the x and y value of the point.