QGIS API Documentation 3.41.0-Master (3c143d501a8)
Loading...
Searching...
No Matches
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.
 
 QgsLayoutPoint (Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for an empty point, where both x and y are set to 0.
 
 QgsLayoutPoint (QPointF point, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for QgsLayoutPoint.
 
QString encodePoint () const
 Encodes the layout point to a string.
 
bool isNull () const
 Tests whether the position is null, ie both its x and y coordinates are zero.
 
bool operator!= (const QgsLayoutPoint &other) const
 
QgsLayoutPoint operator* (double v) const
 Multiplies the x and y by a scalar value.
 
QgsLayoutPoint operator*= (double v)
 Multiplies the x and y by a scalar value.
 
QgsLayoutPoint operator/ (double v) const
 Divides the x and y by a scalar value.
 
QgsLayoutPoint operator/= (double v)
 Divides the x and y by a scalar value.
 
bool operator== (const QgsLayoutPoint &other) const
 
void setPoint (const double x, const double y)
 Sets new x and y coordinates for the point.
 
void setUnits (const Qgis::LayoutUnit units)
 Sets the units for the point.
 
void setX (const double x)
 Sets the x coordinate of point.
 
void setY (const double y)
 Sets y coordinate of point.
 
QPointF toQPointF () const
 Converts the layout point to a QPointF.
 
Qgis::LayoutUnit units () const
 Returns the units for the point.
 
double x () const
 Returns x coordinate of point.
 
double y () const
 Returns y coordinate of point.
 

Static Public Member Functions

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

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 39 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 34 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 42 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 63 of file qgslayoutpoint.cpp.

◆ encodePoint()

QString QgsLayoutPoint::encodePoint ( ) const

Encodes the layout point to a string.

See also
decodePoint()

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

◆ operator!=()

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

Definition at line 87 of file qgslayoutpoint.cpp.

◆ operator*()

QgsLayoutPoint QgsLayoutPoint::operator* ( double  v) const

Multiplies the x and y by a scalar value.

Definition at line 92 of file qgslayoutpoint.cpp.

◆ operator*=()

QgsLayoutPoint QgsLayoutPoint::operator*= ( double  v)

Multiplies the x and y by a scalar value.

Definition at line 97 of file qgslayoutpoint.cpp.

◆ operator/()

QgsLayoutPoint QgsLayoutPoint::operator/ ( double  v) const

Divides the x and y by a scalar value.

Definition at line 103 of file qgslayoutpoint.cpp.

◆ operator/=()

QgsLayoutPoint QgsLayoutPoint::operator/= ( double  v)

Divides the x and y by a scalar value.

Definition at line 108 of file qgslayoutpoint.cpp.

◆ operator==()

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

Definition at line 82 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 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 118 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 99 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 53 of file qgslayoutpoint.cpp.

◆ units()

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

Returns the units for the point.

See also
setUnits()

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


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