QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
32 setDefaultProfileLineSymbol( color );
33 setDefaultProfileFillSymbol( color );
45 QDomElement element = document.createElement( QStringLiteral(
"elevation" ) );
46 element.setAttribute( QStringLiteral(
"enabled" ), mEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
47 element.setAttribute( QStringLiteral(
"symbology" ),
qgsEnumValueToKey( mSymbology ) );
50 element.setAttribute( QStringLiteral(
"band" ), mBandNumber );
52 QDomElement profileLineSymbolElement = document.createElement( QStringLiteral(
"profileLineSymbol" ) );
54 element.appendChild( profileLineSymbolElement );
56 QDomElement profileFillSymbolElement = document.createElement( QStringLiteral(
"profileFillSymbol" ) );
58 element.appendChild( profileFillSymbolElement );
60 parentElement.appendChild( element );
66 const QDomElement elevationElement = element.firstChildElement( QStringLiteral(
"elevation" ) ).toElement();
67 mEnabled = elevationElement.attribute( QStringLiteral(
"enabled" ), QStringLiteral(
"0" ) ).toInt();
71 mBandNumber = elevationElement.attribute( QStringLiteral(
"band" ), QStringLiteral(
"1" ) ).toInt();
75 const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileLineSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
76 mProfileLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( profileLineSymbolElement, context ) );
77 if ( !mProfileLineSymbol )
78 setDefaultProfileLineSymbol( defaultColor );
80 const QDomElement profileFillSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileFillSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
81 mProfileFillSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( profileFillSymbolElement, context ) );
82 if ( !mProfileFillSymbol )
83 setDefaultProfileFillSymbol( defaultColor );
90 std::unique_ptr< QgsRasterLayerElevationProperties > res = std::make_unique< QgsRasterLayerElevationProperties >(
nullptr );
91 res->setEnabled( mEnabled );
92 res->setProfileLineSymbol( mProfileLineSymbol->clone() );
93 res->setProfileFillSymbol( mProfileFillSymbol->clone() );
94 res->setProfileSymbology( mSymbology );
95 res->setBandNumber( mBandNumber );
96 res->copyCommonProperties(
this );
102 QStringList properties;
103 properties << tr(
"Elevation band: %1" ).arg( mBandNumber );
104 properties << tr(
"Scale: %1" ).arg(
mZScale );
105 properties << tr(
"Offset: %1" ).arg(
mZOffset );
106 return QStringLiteral(
"<li>%1</li>" ).arg( properties.join( QLatin1String(
"</li><li>" ) ) );
128 if ( enabled == mEnabled )
138 if ( mBandNumber == band )
148 return mProfileLineSymbol.get();
153 mProfileLineSymbol.reset( symbol );
160 return mProfileFillSymbol.get();
165 mProfileFillSymbol.reset( symbol );
170 mSymbology = symbology;
173 void QgsRasterLayerElevationProperties::setDefaultProfileLineSymbol(
const QColor &color )
175 std::unique_ptr< QgsSimpleLineSymbolLayer > profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( color, 0.6 );
176 mProfileLineSymbol = std::make_unique< QgsLineSymbol>(
QgsSymbolLayerList( { profileLineLayer.release() } ) );
179 void QgsRasterLayerElevationProperties::setDefaultProfileFillSymbol(
const QColor &color )
181 std::unique_ptr< QgsSimpleFillSymbolLayer > profileFillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( color );
182 profileFillLayer->setStrokeStyle( Qt::NoPen );
183 mProfileFillSymbol = std::make_unique< QgsFillSymbol>(
QgsSymbolLayerList( { profileFillLayer.release() } ) );
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
QgsRasterLayerElevationProperties(QObject *parent)
Constructor for QgsRasterLayerElevationProperties, with the specified parent object.
The class is used as a container of context for various read/write operations on other objects.
QString htmlSummary() const override
Returns a HTML formatted summary of the properties.
Base class for storage of map layer elevation properties.
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
bool showByDefaultInElevationProfilePlots() const override
Returns true if the layer should be visible by default in newly created elevation profile plots.
void setProfileFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render the raster profile in elevation profile plots.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
void setBandNumber(int band)
Sets the band number from which the elevation should be taken.
QgsFillSymbol * profileFillSymbol() const
Returns the fill symbol used to render the raster profile in elevation profile plots.
void readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common class properties from a DOM element previously written by writeXml().
void setProfileSymbology(Qgis::ProfileSurfaceSymbology symbology)
Sets the symbology option used to render the raster profile in elevation profile plots.
@ Line
The elevation surface will be rendered using a line symbol.
void setProfileLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the raster profile in elevation profile plots.
Raster layer specific subclass of QgsMapLayerElevationProperties.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the elevation properties from a DOM element previously written by writeXml().
bool hasElevation() const override
Returns true if the layer has an elevation or z component.
A line symbol type, for rendering LineString and MultiLineString geometries.
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
QgsRasterLayerElevationProperties * clone() const override
Creates a clone of the properties.
QgsLineSymbol * profileLineSymbol() const
Returns the line symbol used to render the raster profile in elevation profile plots.
void profileGenerationPropertyChanged()
Emitted when any of the elevation properties which relate solely to generation of elevation profiles ...
~QgsRasterLayerElevationProperties() override
bool isVisibleInZRange(const QgsDoubleRange &range) const override
Returns true if the layer should be visible and rendered for the specified z range.
void profileRenderingPropertyChanged()
Emitted when any of the elevation properties which relate solely to presentation of elevation results...
QgsRange which stores a range of double values.
QList< QgsSymbolLayer * > QgsSymbolLayerList
Base class for all map layer types. This is the base class for all map layer types (vector,...
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.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
void changed()
Emitted when any of the elevation properties have changed.
QgsDoubleRange calculateZRange(QgsMapLayer *layer) const override
Attempts to calculate the overall elevation or z range for the specified layer, using the settings de...
void writeCommonProperties(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context)
Writes common class properties to a DOM element, to be used later with readXml().
void setEnabled(bool enabled)
Sets whether the elevation properties are enabled, i.e.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.