32 setDefaultProfileLineSymbol( color );
33 setDefaultProfileFillSymbol( color );
45 QDomElement element = document.createElement( QStringLiteral(
"elevation" ) );
46 element.setAttribute( QStringLiteral(
"symbology" ),
qgsEnumValueToKey( mSymbology ) );
49 QDomElement profileLineSymbolElement = document.createElement( QStringLiteral(
"profileLineSymbol" ) );
51 element.appendChild( profileLineSymbolElement );
53 QDomElement profileFillSymbolElement = document.createElement( QStringLiteral(
"profileFillSymbol" ) );
55 element.appendChild( profileFillSymbolElement );
57 parentElement.appendChild( element );
63 const QDomElement elevationElement = element.firstChildElement( QStringLiteral(
"elevation" ) ).toElement();
70 const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileLineSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
71 mProfileLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( profileLineSymbolElement, context ) );
72 if ( !mProfileLineSymbol )
73 setDefaultProfileLineSymbol( defaultColor );
75 const QDomElement profileFillSymbolElement = elevationElement.firstChildElement( QStringLiteral(
"profileFillSymbol" ) ).firstChildElement( QStringLiteral(
"symbol" ) );
76 mProfileFillSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( profileFillSymbolElement, context ) );
77 if ( !mProfileFillSymbol )
78 setDefaultProfileFillSymbol( defaultColor );
85 QStringList properties;
86 properties << tr(
"Scale: %1" ).arg(
mZScale );
87 properties << tr(
"Offset: %1" ).arg(
mZOffset );
88 return QStringLiteral(
"<li>%1</li>" ).arg( properties.join( QLatin1String(
"</li><li>" ) ) );
93 std::unique_ptr< QgsMeshLayerElevationProperties > res = std::make_unique< QgsMeshLayerElevationProperties >(
nullptr );
94 res->setProfileLineSymbol( mProfileLineSymbol->clone() );
95 res->setProfileFillSymbol( mProfileFillSymbol->clone() );
96 res->setProfileSymbology( mSymbology );
97 res->copyCommonProperties(
this );
120 return mProfileLineSymbol.get();
125 mProfileLineSymbol.reset( symbol );
132 return mProfileFillSymbol.get();
137 mProfileFillSymbol.reset( symbol );
142 mSymbology = symbology;
145void QgsMeshLayerElevationProperties::setDefaultProfileLineSymbol(
const QColor &color )
147 std::unique_ptr< QgsSimpleLineSymbolLayer > profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( color, 0.6 );
148 mProfileLineSymbol = std::make_unique< QgsLineSymbol>(
QgsSymbolLayerList( { profileLineLayer.release() } ) );
151void QgsMeshLayerElevationProperties::setDefaultProfileFillSymbol(
const QColor &color )
153 std::unique_ptr< QgsSimpleFillSymbolLayer > profileFillLayer = std::make_unique< QgsSimpleFillSymbolLayer >( color );
154 profileFillLayer->setStrokeStyle( Qt::NoPen );
155 mProfileFillSymbol = std::make_unique< QgsFillSymbol>(
QgsSymbolLayerList( { profileFillLayer.release() } ) );
ProfileSurfaceSymbology
Surface symbology type for elevation profile plots.
@ Line
The elevation surface will be rendered using a line symbol.
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.
QgsRange which stores a range of double values.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
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 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.
Mesh layer specific subclass of QgsMapLayerElevationProperties.
QDomElement writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) override
Writes the properties to a DOM element, to be used later with readXml().
QgsLineSymbol * profileLineSymbol() const
Returns the line symbol used to render the mesh profile in elevation profile plots.
bool hasElevation() const override
Returns true if the layer has an elevation or z component.
QgsMeshLayerElevationProperties * clone() const override
Creates a clone of the properties.
bool isVisibleInZRange(const QgsDoubleRange &range) const override
Returns true if the layer should be visible and rendered for the specified z range.
QgsFillSymbol * profileFillSymbol() const
Returns the fill symbol used to render the mesh profile in elevation profile plots.
void setProfileSymbology(Qgis::ProfileSurfaceSymbology symbology)
Sets the symbology option used to render the mesh profile in elevation profile plots.
void setProfileFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render the mesh profile in elevation profile plots.
void setProfileLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the mesh profile in elevation profile plots.
~QgsMeshLayerElevationProperties() override
QgsMeshLayerElevationProperties(QObject *parent)
Constructor for QgsMeshLayerElevationProperties, with the specified parent object.
QString htmlSummary() const override
Returns a HTML formatted summary of the properties.
bool showByDefaultInElevationProfilePlots() const override
Returns true if the layer should be visible by default in newly created elevation profile plots.
bool readXml(const QDomElement &element, const QgsReadWriteContext &context) override
Reads the elevation properties from a DOM element previously written by writeXml().
QgsDoubleRange calculateZRange(QgsMapLayer *layer) const override
Attempts to calculate the overall elevation or z range for the specified layer, using the settings de...
The class is used as a container of context for various read/write operations on other objects.
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
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 qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
QList< QgsSymbolLayer * > QgsSymbolLayerList