128 mMatrix.map(
static_cast< qreal
>( x ),
static_cast< qreal
>( y ), &mx, &my );
143 QPointF topLeft = bounds.topLeft();
144 QPointF topRight = bounds.topRight();
145 QPointF bottomLeft = bounds.bottomLeft();
146 QPointF bottomRight = bounds.bottomRight();
153 auto minMaxX = std::minmax( { topLeft.x(), topRight.x(), bottomLeft.x(), bottomRight.x() } );
154 auto minMaxY = std::minmax( { topLeft.y(), topRight.y(), bottomLeft.y(), bottomRight.y() } );
156 const double left = minMaxX.first;
157 const double right = minMaxX.second;
158 const double top = minMaxY.first;
159 const double bottom = minMaxY.second;
160 return QRectF( left, top, right - left, bottom - top );
173 double mx = x, my = y;
191 assert( x.size() == y.size() );
194 const auto size = x.size();
195 for (
int i = 0; i < size; ++i )
205 return toMapCoordinates(
static_cast<double>( x ),
static_cast<double>( y ) );
214 const QTransform matrix = mMatrix.inverted( &invertible );
215 assert( invertible );
217 matrix.map(
static_cast< qreal
>( x ),
static_cast< qreal
>( y ), &mx, &my );
252 void setMapUnitsPerPixel(
double mapUnitsPerPixel );
288 void setMapRotation(
double degrees,
double cx,
double cy );
311 void setParameters(
double mapUnitsPerPixel,
double centerX,
double centerY,
int widthPixels,
int heightPixels,
double rotation );
328 void setParameters(
double mapUnitsPerPixel,
double centerX,
double centerY,
int widthPixels,
int heightPixels,
double rotation,
bool *ok )
SIP_SKIP;
333 QString showParameters()
const;
338 QTransform transform()
const;
354 return mValid == other.mValid
355 && mMapUnitsPerPixel == other.mMapUnitsPerPixel
356 && mWidth == other.mWidth
357 && mHeight == other.mHeight
358 && mRotation == other.mRotation
359 && mXCenter == other.mXCenter
360 && mYCenter == other.mYCenter
361 && mXMin == other.mXMin
362 && mYMin == other.mYMin;
367 return !( *
this == other );
372 double mMapUnitsPerPixel = 1;
375 double mRotation = 0.0;
376 double mXCenter = 0.5;
377 double mYCenter = 0.5;
DistanceUnit
Units of distance.
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.
QgsMapToPixel()
Constructor for an invalid QgsMapToPixel.
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
static QgsMapToPixel fromScale(double scale, Qgis::DistanceUnit mapUnits, double dpi=96)
Returns a new QgsMapToPixel created using a specified scale and distance unit.
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.
void set(double x, double y)
Sets the x and y value of the point.