QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
34 setDefaultProfileLineSymbol( color );
35 setDefaultProfileFillSymbol( color );
36 setDefaultProfileMarkerSymbol( color );
51 QDomElement element = document.createElement( QStringLiteral(
"elevation" ) );
54 element.setAttribute( QStringLiteral(
"extrusionEnabled" ), mEnableExtrusion ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
55 element.setAttribute( QStringLiteral(
"extrusion" ),
qgsDoubleToString( mExtrusionHeight ) );
56 element.setAttribute( QStringLiteral(
"clamping" ),
qgsEnumValueToKey( mClamping ) );
57 element.setAttribute( QStringLiteral(
"binding" ),
qgsEnumValueToKey( mBinding ) );
59 element.setAttribute( QStringLiteral(
"symbology" ),
qgsEnumValueToKey( mSymbology ) );
60 element.setAttribute( QStringLiteral(
"respectLayerSymbol" ), mRespectLayerSymbology ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
61 element.setAttribute( QStringLiteral(
"showMarkerSymbolInSurfacePlots" ), mShowMarkerSymbolInSurfacePlots ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
63 QDomElement profileLineSymbolElement = document.createElement( QStringLiteral(
"profileLineSymbol" ) );
65 element.appendChild( profileLineSymbolElement );
67 QDomElement profileFillSymbolElement = document.createElement( QStringLiteral(
"profileFillSymbol" ) );
69 element.appendChild( profileFillSymbolElement );
71 QDomElement profileMarkerSymbolElement = document.createElement( QStringLiteral(
"profileMarkerSymbol" ) );
73 element.appendChild( profileMarkerSymbolElement );
75 parentElement.appendChild( element );
81 const QDomElement elevationElement = element.firstChildElement( QStringLiteral(
"elevation" ) ).toElement();
82 if ( elevationElement.isNull() )
90 mEnableExtrusion = elevationElement.attribute( QStringLiteral(
"extrusionEnabled" ), QStringLiteral(
"0" ) ).toInt();
91 mExtrusionHeight = elevationElement.attribute( QStringLiteral(
"extrusion" ), QStringLiteral(
"0" ) ).toDouble();
93 mShowMarkerSymbolInSurfacePlots = elevationElement.attribute( QStringLiteral(
"showMarkerSymbolInSurfacePlots" ), QStringLiteral(
"0" ) ).toInt();
95 mRespectLayerSymbology = elevationElement.attribute( QStringLiteral(
"respectLayerSymbol" ), QStringLiteral(
"1" ) ).toInt();
99 const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileLineSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
100 mProfileLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( profileLineSymbolElement, context ) );
101 if ( !mProfileLineSymbol )
102 setDefaultProfileLineSymbol( color );
104 const QDomElement profileFillSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileFillSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
105 mProfileFillSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( profileFillSymbolElement, context ) );
106 if ( !mProfileFillSymbol )
107 setDefaultProfileFillSymbol( color );
109 const QDomElement profileMarkerSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileMarkerSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
110 mProfileMarkerSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( profileMarkerSymbolElement, context ) );
111 if ( !mProfileMarkerSymbol )
112 setDefaultProfileMarkerSymbol( color );
119 QgsVectorLayer *vlayer = qobject_cast< QgsVectorLayer * >( layer );
126 mEnableExtrusion =
false;
127 mExtrusionHeight = 0;
145 std::unique_ptr< QgsVectorLayerElevationProperties > res = std::make_unique< QgsVectorLayerElevationProperties >(
nullptr );
146 res->setClamping( mClamping );
147 res->setBinding( mBinding );
148 res->setType( mType );
149 res->setExtrusionEnabled( mEnableExtrusion );
150 res->setExtrusionHeight( mExtrusionHeight );
151 res->setProfileLineSymbol( mProfileLineSymbol->clone() );
152 res->setProfileFillSymbol( mProfileFillSymbol->clone() );
153 res->setProfileMarkerSymbol( mProfileMarkerSymbol->clone() );
154 res->setRespectLayerSymbology( mRespectLayerSymbology );
155 res->setProfileSymbology( mSymbology );
156 res->setShowMarkerSymbolInSurfacePlots( mShowMarkerSymbolInSurfacePlots );
157 res->copyCommonProperties(
this );
158 return res.release();
163 QStringList properties;
168 properties << tr(
"Clamped to Terrain" );
171 properties << tr(
"Relative to Terrain" );
174 properties << tr(
"Absolute" );
195 properties << tr(
"Offset: %1" ).arg(
mZOffset );
198 if ( mEnableExtrusion )
217 properties << tr(
"Extrusion: %1" ).arg( mExtrusionHeight );
221 properties << tr(
"Scale: %1" ).arg(
mZScale );
223 return QStringLiteral(
"<li>%1</li>" ).arg( properties.join( QLatin1String(
"</li><li>" ) ) );
280 if ( mEnableExtrusion == enabled )
283 mEnableExtrusion = enabled;
290 if ( mExtrusionHeight == height )
293 mExtrusionHeight = height;
300 if ( mRespectLayerSymbology == enabled )
303 mRespectLayerSymbology = enabled;
310 return mProfileLineSymbol.get();
315 mProfileLineSymbol.reset( symbol );
322 return mProfileFillSymbol.get();
327 mProfileFillSymbol.reset( symbol );
334 return mProfileMarkerSymbol.get();
339 mProfileMarkerSymbol.reset( symbol );
346 if ( mSymbology == symbology )
349 mSymbology = symbology;
356 if ( show == mShowMarkerSymbolInSurfacePlots )
359 mShowMarkerSymbolInSurfacePlots = show;
364 void QgsVectorLayerElevationProperties::setDefaultProfileLineSymbol(
const QColor &color )
366 std::unique_ptr< QgsSimpleLineSymbolLayer > profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( color, 0.6 );
367 mProfileLineSymbol = std::make_unique< QgsLineSymbol>(
QgsSymbolLayerList( { profileLineLayer.release() } ) );
370 void QgsVectorLayerElevationProperties::setDefaultProfileMarkerSymbol(
const QColor &color )
372 std::unique_ptr< QgsSimpleMarkerSymbolLayer > profileMarkerLayer = std::make_unique< QgsSimpleMarkerSymbolLayer >(
Qgis::MarkerShape::Diamond, 3 );
373 profileMarkerLayer->setColor( color );
374 profileMarkerLayer->setStrokeWidth( 0.2 );
375 profileMarkerLayer->setStrokeColor( color.darker( 140 ) );
376 mProfileMarkerSymbol = std::make_unique< QgsMarkerSymbol>(
QgsSymbolLayerList( { profileMarkerLayer.release() } ) );
379 void QgsVectorLayerElevationProperties::setDefaultProfileFillSymbol(
const QColor &color )
381 std::unique_ptr< QgsSimpleFillSymbolLayer > profileFillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( color );
382 profileFillLayer->setStrokeWidth( 0.2 );
383 profileFillLayer->setStrokeColor( color.darker( 140 ) );
384 mProfileFillSymbol = std::make_unique< QgsFillSymbol>(
QgsSymbolLayerList( { profileFillLayer.release() } ) );
void setProfileMarkerSymbol(QgsMarkerSymbol *symbol)
Sets the marker symbol used to render points for the layer in elevation profile plots.
void setBinding(Qgis::AltitudeBinding binding)
Sets the altitude binding method, which determines how altitude is bound to individual vertices in fe...
@ Terrain
Elevation is clamped to terrain (final elevation = terrain elevation)
~QgsVectorLayerElevationProperties() override
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
void setProfileLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render lines for the layer in elevation profile plots.
The class is used as a container of context for various read/write operations on other objects.
Qgis::VectorProfileType type() const
Returns the type of profile the layer represents.
@ Centroid
Clamp just centroid of feature.
Base class for storage of map layer elevation properties.
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
@ FieldBasedProperty
Field based property (QgsFieldBasedProperty)
void setExtrusionEnabled(bool enabled)
Sets whether extrusion is enabled.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
void setRespectLayerSymbology(bool enabled)
Sets whether layer symbology should be respected when rendering elevation profile plots.
@ Relative
Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation)
Type propertyType() const
Returns the property type.
void clear() override
Removes all properties from the collection.
Qgis::AltitudeClamping clamping() const
Returns the altitude clamping method, which dictates how feature heights are interpreted with respect...
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
void setProfileFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render polygons for the layer in elevation profile plots.
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common class properties from a DOM element previously written by writeXml().
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QString expressionString() const
Returns the expression used for the property value.
bool hasElevation() const override
Returns true if the layer has an elevation or z component.
void setProfileSymbology(Qgis::ProfileSurfaceSymbology symbology)
Sets the symbology option used to render the vector profile in elevation profile plots.
@ Line
The elevation surface will be rendered using a line symbol.
void setClamping(Qgis::AltitudeClamping clamping)
Sets the altitude clamping method, which dictates how feature heights are interpreted with respect to...
bool showByDefaultInElevationProfilePlots() const override
Returns true if the layer should be visible by default in newly created elevation profile plots.
@ ExpressionBasedProperty
Expression based property (QgsExpressionBasedProperty)
AltitudeBinding
Altitude binding.
QgsFillSymbol * profileFillSymbol() const
Returns the symbol used to render polygons for the layer in elevation profile plots.
bool isVisibleInZRange(const QgsDoubleRange &range) const override
Returns true if the layer should be visible and rendered for the specified z range.
A marker symbol type, for rendering Point and MultiPoint geometries.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
@ IndividualFeatures
Treat each feature as an individual object (eg buildings)
QgsPropertyCollection mDataDefinedProperties
Property collection for data defined elevation settings.
A line symbol type, for rendering LineString and MultiLineString geometries.
VectorProfileType
Types of elevation profiles to generate for vector sources.
Vector layer specific subclass of QgsMapLayerElevationProperties.
void setShowMarkerSymbolInSurfacePlots(bool show)
Sets whehter the marker symbol should also be shown in continuous surface plots.
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the 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 profileRenderingPropertyChanged()
Emitted when any of the elevation properties which relate solely to presentation of elevation results...
QgsVectorLayerElevationProperties * clone() const override
Creates a clone of the properties.
QgsRange which stores a range of double values.
void setExtrusionHeight(double height)
Sets the feature extrusion height.
Represents a vector layer which manages a vector based data sets.
QList< QgsSymbolLayer * > QgsSymbolLayerList
Base class for all map layer types. This is the base class for all map layer types (vector,...
QString field() const
Returns the current field name the property references.
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.
QgsVectorLayerElevationProperties(QObject *parent)
Constructor for QgsVectorLayerElevationProperties, with the specified parent object.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the elevation properties from a DOM element previously written by writeXml().
void changed()
Emitted when any of the elevation properties have changed.
static bool hasZ(Type type) SIP_HOLDGIL
Tests whether a WKB type contains the z-dimension.
Qgis::AltitudeBinding binding() const
Returns the altitude binding method, which determines how altitude is bound to individual vertices in...
@ Absolute
Elevation is taken directly from feature and is independent of terrain height (final elevation = feat...
void writeCommonProperties(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)
Writes common class properties to a DOM element, to be used later with readXml().
void setType(Qgis::VectorProfileType type)
Sets the type of profile the layer represents.
@ StaticProperty
Static property (QgsStaticProperty)
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
AltitudeClamping
Altitude clamping.
QString htmlSummary() const override
Returns a HTML formatted summary of the properties.
QgsMarkerSymbol * profileMarkerSymbol() const
Returns the symbol used to render points for the layer in elevation profile plots.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
void setDefaultsFromLayer(QgsMapLayer *layer) override
Sets default properties based on sensible choices for the given map layer.
QgsLineSymbol * profileLineSymbol() const
Returns the symbol used to render lines for the layer in elevation profile plots.
QgsDoubleRange calculateZRange(QgsMapLayer *layer) const override
Attempts to calculate the overall elevation or z range for the specified layer, using the settings de...
@ InvalidProperty
Invalid (not set) property.