19#include "moc_qgspointcloudlayerelevationproperties.cpp"
34 if ( mRespectLayerColors )
47 QDomElement element = document.createElement( QStringLiteral(
"elevation" ) );
50 element.setAttribute( QStringLiteral(
"max_screen_error" ),
qgsDoubleToString( mMaximumScreenError ) );
51 element.setAttribute( QStringLiteral(
"max_screen_error_unit" ),
QgsUnitTypes::encodeUnit( mMaximumScreenErrorUnit ) );
52 element.setAttribute( QStringLiteral(
"point_size" ),
qgsDoubleToString( mPointSize ) );
54 element.setAttribute( QStringLiteral(
"point_symbol" ),
qgsEnumValueToKey( mPointSymbol ) );
56 element.setAttribute( QStringLiteral(
"respect_layer_colors" ), mRespectLayerColors ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
57 element.setAttribute( QStringLiteral(
"opacity_by_distance" ), mApplyOpacityByDistanceEffect ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
59 parentElement.appendChild( element );
65 const QDomElement elevationElement = element.firstChildElement( QStringLiteral(
"elevation" ) ).toElement();
68 mMaximumScreenError = elevationElement.attribute( QStringLiteral(
"max_screen_error" ), QStringLiteral(
"0.3" ) ).toDouble();
73 mPointSize = elevationElement.attribute( QStringLiteral(
"point_size" ), QStringLiteral(
"0.6" ) ).toDouble();
78 const QString colorString = elevationElement.attribute( QStringLiteral(
"point_color" ) );
79 if ( !colorString.isEmpty() )
87 mRespectLayerColors = elevationElement.attribute( QStringLiteral(
"respect_layer_colors" ), QStringLiteral(
"1" ) ).toInt();
88 mApplyOpacityByDistanceEffect = elevationElement.attribute( QStringLiteral(
"opacity_by_distance" ) ).toInt();
95 std::unique_ptr< QgsPointCloudLayerElevationProperties > res = std::make_unique< QgsPointCloudLayerElevationProperties >(
nullptr );
96 res->copyCommonProperties(
this );
98 res->mMaximumScreenError = mMaximumScreenError;
99 res->mMaximumScreenErrorUnit = mMaximumScreenErrorUnit;
100 res->mPointSize = mPointSize;
101 res->mPointSizeUnit = mPointSizeUnit;
102 res->mPointSymbol = mPointSymbol;
103 res->mPointColor = mPointColor;
104 res->mRespectLayerColors = mRespectLayerColors;
105 res->mApplyOpacityByDistanceEffect = mApplyOpacityByDistanceEffect;
107 return res.release();
112 QStringList properties;
113 properties << tr(
"Scale: %1" ).arg(
mZScale );
114 properties << tr(
"Offset: %1" ).arg(
mZOffset );
115 return QStringLiteral(
"<ul><li>%1</li></ul>" ).arg( properties.join( QLatin1String(
"</li><li>" ) ) );
128 if ( pcLayer->dataProvider() )
133 const double zMin = stats.
minimum( QStringLiteral(
"Z" ) );
134 const double zMax = stats.
maximum( QStringLiteral(
"Z" ) );
135 if ( !std::isnan( zMin ) && !std::isnan( zMax ) )
151 return {range.
lower() };
166 mMaximumScreenError = error;
173 if ( unit == mMaximumScreenErrorUnit )
176 mMaximumScreenErrorUnit = unit;
188 if ( mPointSymbol == symbol )
191 mPointSymbol = symbol;
198 if ( color == mPointColor )
208 if ( apply == mApplyOpacityByDistanceEffect )
211 mApplyOpacityByDistanceEffect = apply;
215 if ( mApplyOpacityByDistanceEffect )
233 if ( mPointSizeUnit == units )
236 mPointSizeUnit = units;
243 if ( mRespectLayerColors == enabled )
246 mRespectLayerColors = enabled;
250 if ( mRespectLayerColors )
PointCloudSymbol
Rendering symbols for point cloud points.
@ Square
Renders points as squares.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
QgsRange which stores a range of double values.
bool isInfinite() const
Returns true if the range consists of all possible values.
Base class for storage of map layer elevation properties.
void writeCommonProperties(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)
Writes common class properties to a DOM element, to be used later with readXml().
void profileGenerationPropertyChanged()
Emitted when any of the elevation properties which relate solely to generation of elevation profiles ...
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common class properties from a DOM element previously written by writeXml().
void changed()
Emitted when any of the elevation properties have changed.
void profileRenderingPropertyChanged()
Emitted when any of the elevation properties which relate solely to presentation of elevation results...
Base class for all map layer types.
void rendererChanged()
Signal emitted when renderer is changed.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
void setRespectLayerColors(bool enabled)
Sets whether layer coloring should be respected when rendering elevation profile plots.
QString htmlSummary() const override
Returns a HTML formatted summary of the properties.
void setPointColor(const QColor &color)
Sets the color used drawing points in elevation profile charts.
bool showByDefaultInElevationProfilePlots() const override
Returns true if the layer should be visible by default in newly created elevation profile plots.
bool hasElevation() const override
Returns true if the layer has an elevation or z component.
void setApplyOpacityByDistanceEffect(bool apply)
Sets whether a reduced opacity by distance from profile curve effect should be applied when drawing p...
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
void setPointSize(double size)
Sets the point size used for drawing points in elevation profile charts.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the elevation properties from a DOM element previously written by writeXml().
void setPointSymbol(Qgis::PointCloudSymbol symbol)
Sets the symbol used drawing points in elevation profile charts.
QgsDoubleRange calculateZRange(QgsMapLayer *layer) const override
Attempts to calculate the overall elevation or z range for the specified layer, using the settings de...
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when generating elevation profiles for the point cloud.
bool isVisibleInZRange(const QgsDoubleRange &range, QgsMapLayer *layer=nullptr) const override
Returns true if the layer should be visible and rendered for the specified z range.
void setPointSizeUnit(const Qgis::RenderUnit units)
Sets the units used for the point size used for drawing points in elevation profile charts.
QgsPointCloudLayerElevationProperties * clone() const override
Creates a clone of the properties.
void setMaximumScreenErrorUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum screen error allowed when generating elevation profiles for the point c...
QList< double > significantZValues(QgsMapLayer *layer) const override
Returns a list of significant elevation/z-values for the specified layer, using the settings defined ...
Qgis::PointCloudSymbol pointSymbol() const
Returns the symbol used drawing points in elevation profile charts.
QgsPointCloudLayerElevationProperties(QObject *parent)
Constructor for QgsPointCloudLayerElevationProperties, with the specified parent object.
Represents a map layer supporting display of point clouds.
Class used to store statistics of a point cloud dataset.
double maximum(const QString &attribute) const
Returns the maximum value for the attribute attribute If no matching statistic is available then NaN ...
double minimum(const QString &attribute) const
Returns the minimum value for the attribute attribute If no matching statistic is available then NaN ...
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
The class is used as a container of context for various read/write operations on other objects.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)