30#include "qgsvirtualpointcloudprovider.h"
34#include "moc_qgspointcloudlayerelevationproperties.cpp"
36using namespace Qt::StringLiterals;
42 setDefaultProfileLineSymbol( mPointColor );
43 setDefaultProfileFillSymbol( mPointColor );
49 if ( mRespectLayerColors )
57 return mProfileLineSymbol.get();
65 mProfileLineSymbol.reset( symbol );
72 return mProfileFillSymbol.get();
80 mProfileFillSymbol.reset( symbol );
87 if ( mSymbology == symbology )
90 mSymbology = symbology;
97 return mElevationLimit;
105 mElevationLimit = limit;
110void QgsPointCloudLayerElevationProperties::setDefaultProfileLineSymbol(
const QColor &color )
112 auto profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( color, 0.6 );
113 mProfileLineSymbol = std::make_unique< QgsLineSymbol>(
QgsSymbolLayerList( { profileLineLayer.release() } ) );
116void QgsPointCloudLayerElevationProperties::setDefaultProfileFillSymbol(
const QColor &color )
118 auto profileFillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( color );
119 profileFillLayer->setStrokeWidth( 0.2 );
120 profileFillLayer->setStrokeColor( color.darker( 140 ) );
121 mProfileFillSymbol = std::make_unique< QgsFillSymbol>(
QgsSymbolLayerList( { profileFillLayer.release() } ) );
132 QDomElement element = document.createElement( u
"elevation"_s );
135 element.setAttribute( u
"max_screen_error"_s,
qgsDoubleToString( mMaximumScreenError ) );
142 element.setAttribute( u
"respect_layer_colors"_s, mRespectLayerColors ? u
"1"_s : u
"0"_s );
143 element.setAttribute( u
"opacity_by_distance"_s, mApplyOpacityByDistanceEffect ? u
"1"_s : u
"0"_s );
145 if ( !std::isnan( mElevationLimit ) )
146 element.setAttribute( u
"elevationLimit"_s,
qgsDoubleToString( mElevationLimit ) );
148 QDomElement profileLineSymbolElement = document.createElement( u
"profileLineSymbol"_s );
150 element.appendChild( profileLineSymbolElement );
152 QDomElement profileFillSymbolElement = document.createElement( u
"profileFillSymbol"_s );
154 element.appendChild( profileFillSymbolElement );
156 parentElement.appendChild( element );
162 const QDomElement elevationElement = element.firstChildElement( u
"elevation"_s ).toElement();
165 mMaximumScreenError = elevationElement.attribute( u
"max_screen_error"_s, u
"0.3"_s ).toDouble();
170 mPointSize = elevationElement.attribute( u
"point_size"_s, u
"0.6"_s ).toDouble();
176 const QString colorString = elevationElement.attribute( u
"point_color"_s );
177 if ( !colorString.isEmpty() )
186 mRespectLayerColors = elevationElement.attribute( u
"respect_layer_colors"_s, u
"1"_s ).toInt();
187 mApplyOpacityByDistanceEffect = elevationElement.attribute( u
"opacity_by_distance"_s ).toInt();
189 if ( elevationElement.hasAttribute( u
"elevationLimit"_s ) )
190 mElevationLimit = elevationElement.attribute( u
"elevationLimit"_s ).toDouble();
192 mElevationLimit = std::numeric_limits< double >::quiet_NaN();
196 const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( u
"profileLineSymbol"_s ).firstChildElement( u
"symbol"_s );
198 if ( !mProfileLineSymbol )
199 setDefaultProfileLineSymbol( color );
201 const QDomElement profileFillSymbolElement = elevationElement.firstChildElement( u
"profileFillSymbol"_s ).firstChildElement( u
"symbol"_s );
203 if ( !mProfileFillSymbol )
204 setDefaultProfileFillSymbol( color );
211 auto res = std::make_unique< QgsPointCloudLayerElevationProperties >(
nullptr );
212 res->copyCommonProperties(
this );
214 res->mMaximumScreenError = mMaximumScreenError;
215 res->mMaximumScreenErrorUnit = mMaximumScreenErrorUnit;
216 res->mPointSize = mPointSize;
217 res->mPointSizeUnit = mPointSizeUnit;
218 res->mPointSymbol = mPointSymbol;
219 res->mPointColor = mPointColor;
220 res->mRespectLayerColors = mRespectLayerColors;
222 res->mApplyOpacityByDistanceEffect = mApplyOpacityByDistanceEffect;
223 res->mElevationLimit = mElevationLimit;
224 res->mSymbology = mSymbology;
226 res->setProfileLineSymbol( mProfileLineSymbol->clone() );
227 res->setProfileFillSymbol( mProfileFillSymbol->clone() );
229 return res.release();
234 QStringList properties;
235 properties << tr(
"Scale: %1" ).arg(
mZScale );
236 properties << tr(
"Offset: %1" ).arg(
mZOffset );
237 return u
"<ul><li>%1</li></ul>"_s.arg( properties.join(
"</li><li>"_L1 ) );
250 if ( pcLayer->dataProvider() )
252 double zMin = std::numeric_limits<double>::quiet_NaN();
253 double zMax = std::numeric_limits<double>::quiet_NaN();
258 zMin = stats.
minimum( u
"Z"_s );
259 zMax = stats.
maximum( u
"Z"_s );
262 else if ( QgsVirtualPointCloudProvider *virtualProvider =
dynamic_cast< QgsVirtualPointCloudProvider *
>( pcLayer->dataProvider() ) )
264 for ( QgsPointCloudSubIndex subIndex : virtualProvider->subIndexes() )
268 zMin = std::isnan( zMin ) ? newRange.
lower() : std::min( zMin, newRange.
lower() );
269 zMax = std::isnan( zMax ) ? newRange.
upper() : std::max( zMax, newRange.
upper() );
273 if ( !std::isnan( zMin ) && !std::isnan( zMax ) )
289 return {range.
lower() };
304 mMaximumScreenError = error;
311 if ( unit == mMaximumScreenErrorUnit )
314 mMaximumScreenErrorUnit = unit;
326 if ( mPointSymbol == symbol )
329 mPointSymbol = symbol;
336 if ( color == mPointColor )
346 if ( apply == mApplyOpacityByDistanceEffect )
349 mApplyOpacityByDistanceEffect = apply;
353 if ( mApplyOpacityByDistanceEffect )
371 if ( mPointSizeUnit == units )
374 mPointSizeUnit = units;
381 if ( mRespectLayerColors == enabled )
384 mRespectLayerColors = enabled;
388 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