18#include <QDomDocument>
24 : mMode( other.mMode )
25 , mHorizontalPosition( other.mHorizontalPosition )
26 , mVerticalPosition( other.mVerticalPosition )
33 this->mMode = rhs.mMode;
34 this->mHorizontalPosition = rhs.mHorizontalPosition;
35 this->mVerticalPosition = rhs.mVerticalPosition;
42 out &= this->mMode == rhs.mMode;
43 out &= this->mHorizontalPosition == rhs.mHorizontalPosition;
44 out &= this->mVerticalPosition == rhs.mVerticalPosition;
55 QString sizeStr = element.attribute( QStringLiteral(
"defaultViewportSize" ) );
56 if ( !sizeStr.isEmpty() )
57 mDefaultViewportSize = sizeStr.toInt();
59 sizeStr = element.attribute( QStringLiteral(
"minViewportRatio" ) );
60 if ( !sizeStr.isEmpty() )
61 mMinViewportRatio = sizeStr.toInt();
63 sizeStr = element.attribute( QStringLiteral(
"maxViewportRatio" ) );
64 if ( !sizeStr.isEmpty() )
65 mMaxViewportRatio = sizeStr.toInt();
67 const QString modeStr = element.attribute( QStringLiteral(
"mode" ) );
68 if ( modeStr == QLatin1String(
"Off" ) )
70 else if ( modeStr == QLatin1String(
"Crs" ) )
72 else if ( modeStr == QLatin1String(
"Cube" ) )
75 const QString horizontalStr = element.attribute( QStringLiteral(
"horizontal" ) );
76 if ( horizontalStr == QLatin1String(
"Left" ) )
77 mHorizontalPosition = Qt::AnchorPoint::AnchorLeft;
78 else if ( horizontalStr == QLatin1String(
"Middle" ) )
79 mHorizontalPosition = Qt::AnchorPoint::AnchorHorizontalCenter;
80 else if ( horizontalStr == QLatin1String(
"Right" ) )
81 mHorizontalPosition = Qt::AnchorPoint::AnchorRight;
83 const QString verticalStr = element.attribute( QStringLiteral(
"vertical" ) );
84 if ( verticalStr == QLatin1String(
"Top" ) )
85 mVerticalPosition = Qt::AnchorPoint::AnchorTop;
86 else if ( verticalStr == QLatin1String(
"Middle" ) )
87 mVerticalPosition = Qt::AnchorPoint::AnchorVerticalCenter;
88 else if ( verticalStr == QLatin1String(
"Bottom" ) )
89 mVerticalPosition = Qt::AnchorPoint::AnchorBottom;
96 str = QString::number( mDefaultViewportSize );
97 element.setAttribute( QStringLiteral(
"defaultViewportSize" ),
str );
99 str = QString::number( mMinViewportRatio );
100 element.setAttribute( QStringLiteral(
"minViewportRatio" ),
str );
102 str = QString::number( mMaxViewportRatio );
103 element.setAttribute( QStringLiteral(
"maxViewportRatio" ),
str );
108 str = QLatin1String(
"Crs" );
111 str = QLatin1String(
"Cube" );
116 str = QLatin1String(
"Off" );
119 element.setAttribute( QStringLiteral(
"mode" ),
str );
121 switch ( mHorizontalPosition )
123 case Qt::AnchorPoint::AnchorLeft:
124 str = QLatin1String(
"Left" );
126 case Qt::AnchorPoint::AnchorHorizontalCenter:
127 str = QLatin1String(
"Middle" );
129 case Qt::AnchorPoint::AnchorRight:
131 str = QLatin1String(
"End" );
134 element.setAttribute( QStringLiteral(
"horizontal" ),
str );
136 switch ( mVerticalPosition )
138 case Qt::AnchorPoint::AnchorBottom:
139 str = QLatin1String(
"Bottom" );
141 case Qt::AnchorPoint::AnchorVerticalCenter:
142 str = QLatin1String(
"Middle" );
144 case Qt::AnchorPoint::AnchorTop:
146 str = QLatin1String(
"Top" );
149 element.setAttribute( QStringLiteral(
"vertical" ),
str );
155 if ( ratio < mMaxViewportRatio )
157 mMinViewportRatio = std::clamp( ratio, 0.0, 1.0 );
163 if ( ratio > mMinViewportRatio )
165 mMaxViewportRatio = std::clamp( ratio, 0.0, 1.0 );
Contains the configuration of a 3d axis.
Qgs3DAxisSettings()=default
default constructor
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads settings from a DOM element.
Qgs3DAxisSettings & operator=(Qgs3DAxisSettings const &rhs)
delete assignment operator
@ 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.