QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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, QgsUnitTypes::LayoutUnit units=QgsUnitTypes::LayoutMillimeters)
 Constructor for QgsLayoutPoint. More...
 
 QgsLayoutPoint (QPointF point, QgsUnitTypes::LayoutUnit units=QgsUnitTypes::LayoutMillimeters)
 Constructor for QgsLayoutPoint. More...
 
 QgsLayoutPoint (QgsUnitTypes::LayoutUnit units=QgsUnitTypes::LayoutMillimeters)
 Constructor for an empty point, where both x and y are set to 0. 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 QgsUnitTypes::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...
 
QgsUnitTypes::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 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.
Since
QGIS 3.0

Definition at line 39 of file qgslayoutpoint.h.

Constructor & Destructor Documentation

◆ QgsLayoutPoint() [1/3]

QgsLayoutPoint::QgsLayoutPoint ( double  x,
double  y,
QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters 
)

Constructor for QgsLayoutPoint.

Definition at line 23 of file qgslayoutpoint.cpp.

◆ QgsLayoutPoint() [2/3]

QgsLayoutPoint::QgsLayoutPoint ( QPointF  point,
QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters 
)
explicit

Constructor for QgsLayoutPoint.

Definition at line 31 of file qgslayoutpoint.cpp.

◆ QgsLayoutPoint() [3/3]

QgsLayoutPoint::QgsLayoutPoint ( QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters)
explicit

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

Parameters
unitsunits for measurement

Definition at line 39 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 60 of file qgslayoutpoint.cpp.

◆ encodePoint()

QString QgsLayoutPoint::encodePoint ( ) const

Encodes the layout point to a string.

See also
decodePoint()

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

◆ operator!=()

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

Definition at line 75 of file qgslayoutpoint.cpp.

◆ operator*()

QgsLayoutPoint QgsLayoutPoint::operator* ( double  v) const

Multiplies the x and y by a scalar value.

Definition at line 80 of file qgslayoutpoint.cpp.

◆ operator*=()

QgsLayoutPoint QgsLayoutPoint::operator*= ( double  v)

Multiplies the x and y by a scalar value.

Definition at line 85 of file qgslayoutpoint.cpp.

◆ operator/()

QgsLayoutPoint QgsLayoutPoint::operator/ ( double  v) const

Divides the x and y by a scalar value.

Definition at line 91 of file qgslayoutpoint.cpp.

◆ operator/=()

QgsLayoutPoint QgsLayoutPoint::operator/= ( double  v)

Divides the x and y by a scalar value.

Definition at line 96 of file qgslayoutpoint.cpp.

◆ operator==()

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

Definition at line 70 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 65 of file qgslayoutpoint.h.

◆ setUnits()

void QgsLayoutPoint::setUnits ( const QgsUnitTypes::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 106 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 79 of file qgslayoutpoint.h.

◆ setY()

void QgsLayoutPoint::setY ( const double  y)
inline

Sets y coordinate of point.

See also
y()
setX()

Definition at line 93 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 50 of file qgslayoutpoint.cpp.

◆ units()

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

Returns the units for the point.

See also
setUnits()

Definition at line 99 of file qgslayoutpoint.h.

◆ x()

double QgsLayoutPoint::x ( ) const
inline

Returns x coordinate of point.

See also
setX()
y()

Definition at line 72 of file qgslayoutpoint.h.

◆ y()

double QgsLayoutPoint::y ( ) const
inline

Returns y coordinate of point.

See also
setY()
x()

Definition at line 86 of file qgslayoutpoint.h.


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