QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | Static Public Member Functions | List of all members
QgsLayoutPoint Class Reference

This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts. More...

#include <qgslayoutpoint.h>

Public Member Functions

 QgsLayoutPoint (double x, double y, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for QgsLayoutPoint. More...
 
 QgsLayoutPoint (Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for an empty point, where both x and y are set to 0. More...
 
 QgsLayoutPoint (QPointF point, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for QgsLayoutPoint. More...
 
QString encodePoint () const
 Encodes the layout point to a string. More...
 
bool isNull () const
 Tests whether the position is null, ie both its x and y coordinates are zero. More...
 
bool operator!= (const QgsLayoutPoint &other) const
 
QgsLayoutPoint operator* (double v) const
 Multiplies the x and y by a scalar value. More...
 
QgsLayoutPoint operator*= (double v)
 Multiplies the x and y by a scalar value. More...
 
QgsLayoutPoint operator/ (double v) const
 Divides the x and y by a scalar value. More...
 
QgsLayoutPoint operator/= (double v)
 Divides the x and y by a scalar value. More...
 
bool operator== (const QgsLayoutPoint &other) const
 
void setPoint (const double x, const double y)
 Sets new x and y coordinates for the point. More...
 
void setUnits (const Qgis::LayoutUnit units)
 Sets the units for the point. More...
 
void setX (const double x)
 Sets the x coordinate of point. More...
 
void setY (const double y)
 Sets y coordinate of point. More...
 
QPointF toQPointF () const
 Converts the layout point to a QPointF. More...
 
Qgis::LayoutUnit units () const
 Returns the units for the point. More...
 
double x () const
 Returns x coordinate of point. More...
 
double y () const
 Returns y coordinate of point. More...
 

Static Public Member Functions

static QgsLayoutPoint decodePoint (const QString &string)
 Decodes a point from a string. More...
 

Detailed Description

This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.

Measurement units are stored alongside the position.

See also
QgsLayoutMeasurementConverter
Note
This class does not inherit from QPointF since QPointF includes methods which should not apply to positions with units. For instance, the + and - operators would mislead users of this class to believe that addition of two QgsLayoutPoints with different unit types would automatically convert units. Instead, all unit conversion must be handled by a QgsLayoutMeasurementConverter so that conversion between paper and screen units can be correctly performed.

Definition at line 38 of file qgslayoutpoint.h.

Constructor & Destructor Documentation

◆ QgsLayoutPoint() [1/3]

QgsLayoutPoint::QgsLayoutPoint ( double  x,
double  y,
Qgis::LayoutUnit  units = Qgis::LayoutUnit::Millimeters 
)

Constructor for QgsLayoutPoint.

Definition at line 24 of file qgslayoutpoint.cpp.

◆ QgsLayoutPoint() [2/3]

QgsLayoutPoint::QgsLayoutPoint ( QPointF  point,
Qgis::LayoutUnit  units = Qgis::LayoutUnit::Millimeters 
)
explicit

Constructor for QgsLayoutPoint.

Definition at line 32 of file qgslayoutpoint.cpp.

◆ QgsLayoutPoint() [3/3]

QgsLayoutPoint::QgsLayoutPoint ( Qgis::LayoutUnit  units = Qgis::LayoutUnit::Millimeters)
explicit

Constructor for an empty point, where both x and y are set to 0.

Parameters
unitsunits for measurement

Definition at line 40 of file qgslayoutpoint.cpp.

Member Function Documentation

◆ decodePoint()

QgsLayoutPoint QgsLayoutPoint::decodePoint ( const QString &  string)
static

Decodes a point from a string.

See also
encodePoint()

Definition at line 61 of file qgslayoutpoint.cpp.

◆ encodePoint()

QString QgsLayoutPoint::encodePoint ( ) const

Encodes the layout point to a string.

See also
decodePoint()

Definition at line 56 of file qgslayoutpoint.cpp.

◆ isNull()

bool QgsLayoutPoint::isNull ( ) const

Tests whether the position is null, ie both its x and y coordinates are zero.

Returns
true if point is null

Definition at line 46 of file qgslayoutpoint.cpp.

◆ operator!=()

bool QgsLayoutPoint::operator!= ( const QgsLayoutPoint other) const

Definition at line 76 of file qgslayoutpoint.cpp.

◆ operator*()

QgsLayoutPoint QgsLayoutPoint::operator* ( double  v) const

Multiplies the x and y by a scalar value.

Definition at line 81 of file qgslayoutpoint.cpp.

◆ operator*=()

QgsLayoutPoint QgsLayoutPoint::operator*= ( double  v)

Multiplies the x and y by a scalar value.

Definition at line 86 of file qgslayoutpoint.cpp.

◆ operator/()

QgsLayoutPoint QgsLayoutPoint::operator/ ( double  v) const

Divides the x and y by a scalar value.

Definition at line 92 of file qgslayoutpoint.cpp.

◆ operator/=()

QgsLayoutPoint QgsLayoutPoint::operator/= ( double  v)

Divides the x and y by a scalar value.

Definition at line 97 of file qgslayoutpoint.cpp.

◆ operator==()

bool QgsLayoutPoint::operator== ( const QgsLayoutPoint other) const

Definition at line 71 of file qgslayoutpoint.cpp.

◆ setPoint()

void QgsLayoutPoint::setPoint ( const double  x,
const double  y 
)
inline

Sets new x and y coordinates for the point.

See also
setX()
setY()
setUnits()

Definition at line 64 of file qgslayoutpoint.h.

◆ setUnits()

void QgsLayoutPoint::setUnits ( const Qgis::LayoutUnit  units)
inline

Sets the units for the point.

Does not alter the stored coordinates, ie. no conversion is done.

See also
units()

Definition at line 105 of file qgslayoutpoint.h.

◆ setX()

void QgsLayoutPoint::setX ( const double  x)
inline

Sets the x coordinate of point.

See also
x()
setY()

Definition at line 78 of file qgslayoutpoint.h.

◆ setY()

void QgsLayoutPoint::setY ( const double  y)
inline

Sets y coordinate of point.

See also
y()
setX()

Definition at line 92 of file qgslayoutpoint.h.

◆ toQPointF()

QPointF QgsLayoutPoint::toQPointF ( ) const

Converts the layout point to a QPointF.

The unit information is discarded during this operation.

Returns
QPointF with same x and y coordinates as layout point

Definition at line 51 of file qgslayoutpoint.cpp.

◆ units()

Qgis::LayoutUnit QgsLayoutPoint::units ( ) const
inline

Returns the units for the point.

See also
setUnits()

Definition at line 98 of file qgslayoutpoint.h.

◆ x()

double QgsLayoutPoint::x ( ) const
inline

Returns x coordinate of point.

See also
setX()
y()

Definition at line 71 of file qgslayoutpoint.h.

◆ y()

double QgsLayoutPoint::y ( ) const
inline

Returns y coordinate of point.

See also
setY()
x()

Definition at line 85 of file qgslayoutpoint.h.


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