29#include "qgsvirtualpointcloudprovider.h"
33#include "moc_qgspointcloudlayerelevationproperties.cpp"
35using namespace Qt::StringLiterals;
41 setDefaultProfileLineSymbol( mPointColor );
42 setDefaultProfileFillSymbol( mPointColor );
48 if ( mRespectLayerColors )
56 return mProfileLineSymbol.get();
64 mProfileLineSymbol.reset( symbol );
71 return mProfileFillSymbol.get();
79 mProfileFillSymbol.reset( symbol );
86 if ( mSymbology == symbology )
89 mSymbology = symbology;
96 return mElevationLimit;
104 mElevationLimit = limit;
109void QgsPointCloudLayerElevationProperties::setDefaultProfileLineSymbol(
const QColor &color )
111 auto profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( color, 0.6 );
112 mProfileLineSymbol = std::make_unique< QgsLineSymbol>(
QgsSymbolLayerList( { profileLineLayer.release() } ) );
115void QgsPointCloudLayerElevationProperties::setDefaultProfileFillSymbol(
const QColor &color )
117 auto profileFillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( color );
118 profileFillLayer->setStrokeWidth( 0.2 );
119 profileFillLayer->setStrokeColor( color.darker( 140 ) );
120 mProfileFillSymbol = std::make_unique< QgsFillSymbol>(
QgsSymbolLayerList( { profileFillLayer.release() } ) );
131 QDomElement element = document.createElement( u
"elevation"_s );
134 element.setAttribute( u
"max_screen_error"_s,
qgsDoubleToString( mMaximumScreenError ) );
141 element.setAttribute( u
"respect_layer_colors"_s, mRespectLayerColors ? u
"1"_s : u
"0"_s );
142 element.setAttribute( u
"opacity_by_distance"_s, mApplyOpacityByDistanceEffect ? u
"1"_s : u
"0"_s );
144 if ( !std::isnan( mElevationLimit ) )
145 element.setAttribute( u
"elevationLimit"_s,
qgsDoubleToString( mElevationLimit ) );
147 QDomElement profileLineSymbolElement = document.createElement( u
"profileLineSymbol"_s );
149 element.appendChild( profileLineSymbolElement );
151 QDomElement profileFillSymbolElement = document.createElement( u
"profileFillSymbol"_s );
153 element.appendChild( profileFillSymbolElement );
155 parentElement.appendChild( element );
161 const QDomElement elevationElement = element.firstChildElement( u
"elevation"_s ).toElement();
164 mMaximumScreenError = elevationElement.attribute( u
"max_screen_error"_s, u
"0.3"_s ).toDouble();
169 mPointSize = elevationElement.attribute( u
"point_size"_s, u
"0.6"_s ).toDouble();
175 const QString colorString = elevationElement.attribute( u
"point_color"_s );
176 if ( !colorString.isEmpty() )
185 mRespectLayerColors = elevationElement.attribute( u
"respect_layer_colors"_s, u
"1"_s ).toInt();
186 mApplyOpacityByDistanceEffect = elevationElement.attribute( u
"opacity_by_distance"_s ).toInt();
188 if ( elevationElement.hasAttribute( u
"elevationLimit"_s ) )
189 mElevationLimit = elevationElement.attribute( u
"elevationLimit"_s ).toDouble();
191 mElevationLimit = std::numeric_limits< double >::quiet_NaN();
195 const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( u
"profileLineSymbol"_s ).firstChildElement( u
"symbol"_s );
197 if ( !mProfileLineSymbol )
198 setDefaultProfileLineSymbol( color );
200 const QDomElement profileFillSymbolElement = elevationElement.firstChildElement( u
"profileFillSymbol"_s ).firstChildElement( u
"symbol"_s );
202 if ( !mProfileFillSymbol )
203 setDefaultProfileFillSymbol( color );
210 auto res = std::make_unique< QgsPointCloudLayerElevationProperties >(
nullptr );
211 res->copyCommonProperties(
this );
213 res->mMaximumScreenError = mMaximumScreenError;
214 res->mMaximumScreenErrorUnit = mMaximumScreenErrorUnit;
215 res->mPointSize = mPointSize;
216 res->mPointSizeUnit = mPointSizeUnit;
217 res->mPointSymbol = mPointSymbol;
218 res->mPointColor = mPointColor;
219 res->mRespectLayerColors = mRespectLayerColors;
221 res->mApplyOpacityByDistanceEffect = mApplyOpacityByDistanceEffect;
222 res->mElevationLimit = mElevationLimit;
223 res->mSymbology = mSymbology;
225 res->setProfileLineSymbol( mProfileLineSymbol->clone() );
226 res->setProfileFillSymbol( mProfileFillSymbol->clone() );
228 return res.release();
233 QStringList properties;
234 properties << tr(
"Scale: %1" ).arg(
mZScale );
235 properties << tr(
"Offset: %1" ).arg(
mZOffset );
236 return u
"<ul><li>%1</li></ul>"_s.arg( properties.join(
"</li><li>"_L1 ) );
249 if ( pcLayer->dataProvider() )
251 double zMin = std::numeric_limits<double>::quiet_NaN();
252 double zMax = std::numeric_limits<double>::quiet_NaN();
257 zMin = stats.
minimum( u
"Z"_s );
258 zMax = stats.
maximum( u
"Z"_s );
261 else if ( QgsVirtualPointCloudProvider *virtualProvider =
dynamic_cast< QgsVirtualPointCloudProvider *
>( pcLayer->dataProvider() ) )
263 for ( QgsPointCloudSubIndex subIndex : virtualProvider->subIndexes() )
267 zMin = std::isnan( zMin ) ? newRange.
lower() : std::min( zMin, newRange.
lower() );
268 zMax = std::isnan( zMax ) ? newRange.
upper() : std::max( zMax, newRange.
upper() );
272 if ( !std::isnan( zMin ) && !std::isnan( zMax ) )
288 return {range.
lower() };
303 mMaximumScreenError = error;
310 if ( unit == mMaximumScreenErrorUnit )
313 mMaximumScreenErrorUnit = unit;
325 if ( mPointSymbol == symbol )
328 mPointSymbol = symbol;
335 if ( color == mPointColor )
345 if ( apply == mApplyOpacityByDistanceEffect )
348 mApplyOpacityByDistanceEffect = apply;
352 if ( mApplyOpacityByDistanceEffect )
370 if ( mPointSizeUnit == units )
373 mPointSizeUnit = units;
380 if ( mRespectLayerColors == enabled )
383 mRespectLayerColors = enabled;
387 if ( mRespectLayerColors )
PointCloudSymbol
Rendering symbols for point cloud points.
@ Square
Renders points as squares.
@ IndividualPoints
Sample individual points from the point cloud.
RenderUnit
Rendering size units.
@ Millimeters
Millimeters.
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
@ FillBelow
The elevation surface will be rendered using a fill symbol below the surface level.
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.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
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 ...
QgsMapLayerElevationProperties(QObject *parent)
Constructor for QgsMapLayerElevationProperties, with the specified parent object.
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.
void setProfileFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render polygons for the layer in elevation profile plots.
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 setProfileLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render lines for the layer in elevation profile plots.
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.
double elevationLimit() const
Returns the elevation limit, which is used when profileSymbology() is Qgis::ProfileSurfaceSymbology::...
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...
QgsFillSymbol * profileFillSymbol() const
Returns the symbol used to render polygons for the layer in elevation profile plots.
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.
void setProfileSymbology(Qgis::ProfileSurfaceSymbology symbology)
Sets the symbology option used to render the point cloud profile in elevation profile plots.
void setElevationLimit(double limit)
Sets the elevation limit, which is used when profileSymbology() is Qgis::ProfileSurfaceSymbology::Fil...
QgsPointCloudLayerElevationProperties(QObject *parent)
Constructor for QgsPointCloudLayerElevationProperties, with the specified parent object.
QgsLineSymbol * profileLineSymbol() const
Returns the symbol used to render lines for the layer in elevation profile plots.
Represents a map layer supporting display of point clouds.
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 ...
QMap< QString, QgsPointCloudAttributeStatistics > statisticsMap() const
Returns a map object containing all the statistics.
T lower() const
Returns the lower bound of the range.
T upper() const
Returns the upper bound of the range.
A container for the context for various read/write operations on objects.
static std::unique_ptr< QgsSymbol > loadSymbol(const QDomElement &element, const QgsReadWriteContext &context)
Attempts to load a symbol from a DOM element.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
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).
QList< QgsSymbolLayer * > QgsSymbolLayerList