19#include <QDomDocument>
24 out &= this->mMode == rhs.mMode;
25 out &= this->mHorizontalPosition == rhs.mHorizontalPosition;
26 out &= this->mVerticalPosition == rhs.mVerticalPosition;
27 out &= this->mDefaultViewportSize == rhs.mDefaultViewportSize;
28 out &= this->mMaxViewportRatio == rhs.mMaxViewportRatio;
29 out &= this->mMinViewportRatio == rhs.mMinViewportRatio;
40 QString sizeStr = element.attribute( QStringLiteral(
"defaultViewportSize" ) );
41 if ( !sizeStr.isEmpty() )
42 mDefaultViewportSize = sizeStr.toInt();
44 sizeStr = element.attribute( QStringLiteral(
"minViewportRatio" ) );
45 if ( !sizeStr.isEmpty() )
46 mMinViewportRatio = sizeStr.toInt();
48 sizeStr = element.attribute( QStringLiteral(
"maxViewportRatio" ) );
49 if ( !sizeStr.isEmpty() )
50 mMaxViewportRatio = sizeStr.toInt();
52 const QString modeStr = element.attribute( QStringLiteral(
"mode" ) );
53 if ( modeStr == QLatin1String(
"Off" ) )
55 else if ( modeStr == QLatin1String(
"Crs" ) )
57 else if ( modeStr == QLatin1String(
"Cube" ) )
60 const QString horizontalStr = element.attribute( QStringLiteral(
"horizontal" ) );
61 if ( horizontalStr == QLatin1String(
"Left" ) )
62 mHorizontalPosition = Qt::AnchorPoint::AnchorLeft;
63 else if ( horizontalStr == QLatin1String(
"Middle" ) )
64 mHorizontalPosition = Qt::AnchorPoint::AnchorHorizontalCenter;
65 else if ( horizontalStr == QLatin1String(
"Right" ) )
66 mHorizontalPosition = Qt::AnchorPoint::AnchorRight;
68 const QString verticalStr = element.attribute( QStringLiteral(
"vertical" ) );
69 if ( verticalStr == QLatin1String(
"Top" ) )
70 mVerticalPosition = Qt::AnchorPoint::AnchorTop;
71 else if ( verticalStr == QLatin1String(
"Middle" ) )
72 mVerticalPosition = Qt::AnchorPoint::AnchorVerticalCenter;
73 else if ( verticalStr == QLatin1String(
"Bottom" ) )
74 mVerticalPosition = Qt::AnchorPoint::AnchorBottom;
81 str = QString::number( mDefaultViewportSize );
82 element.setAttribute( QStringLiteral(
"defaultViewportSize" ),
str );
84 str = QString::number( mMinViewportRatio );
85 element.setAttribute( QStringLiteral(
"minViewportRatio" ),
str );
87 str = QString::number( mMaxViewportRatio );
88 element.setAttribute( QStringLiteral(
"maxViewportRatio" ),
str );
93 str = QLatin1String(
"Crs" );
96 str = QLatin1String(
"Cube" );
101 str = QLatin1String(
"Off" );
104 element.setAttribute( QStringLiteral(
"mode" ),
str );
106 switch ( mHorizontalPosition )
108 case Qt::AnchorPoint::AnchorLeft:
109 str = QLatin1String(
"Left" );
111 case Qt::AnchorPoint::AnchorHorizontalCenter:
112 str = QLatin1String(
"Middle" );
114 case Qt::AnchorPoint::AnchorRight:
116 str = QLatin1String(
"End" );
119 element.setAttribute( QStringLiteral(
"horizontal" ),
str );
121 switch ( mVerticalPosition )
123 case Qt::AnchorPoint::AnchorBottom:
124 str = QLatin1String(
"Bottom" );
126 case Qt::AnchorPoint::AnchorVerticalCenter:
127 str = QLatin1String(
"Middle" );
129 case Qt::AnchorPoint::AnchorTop:
131 str = QLatin1String(
"Top" );
134 element.setAttribute( QStringLiteral(
"vertical" ),
str );
140 if ( ratio < mMaxViewportRatio )
142 mMinViewportRatio = std::clamp( ratio, 0.0, 1.0 );
148 if ( ratio > mMinViewportRatio )
150 mMaxViewportRatio = std::clamp( ratio, 0.0, 1.0 );
Contains the configuration of a 3d axis.
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
@ Crs
Respect CRS directions.
@ Cube
Abstract cube mode.
bool operator!=(Qgs3DAxisSettings const &rhs) const
Returns true if objects are not equal.
void setMinViewportRatio(double ratio)
Sets the minimal axis viewport ratio between 0-1.
bool operator==(Qgs3DAxisSettings const &rhs) const
Returns true if both objects are equal.
void setMaxViewportRatio(double ratio)
Sets the maximal axis viewport ratio between 0-1.
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes settings to a DOM element.
The class is used as a container of context for various read/write operations on other objects.