Add signals for when layer elevation properties change

This commit is contained in:
Nyall Dawson 2022-04-26 09:36:56 +10:00
parent 7be1b02a71
commit 6f8d668acd
8 changed files with 170 additions and 12 deletions

View File

@ -228,7 +228,33 @@ Returns the definitions for data defined properties available for use in elevati
void changed();
%Docstring
Emitted when the elevation properties have changed.
Emitted when any of the elevation properties have changed.
See :py:func:`~QgsMapLayerElevationProperties.renderingPropertyChanged` and :py:func:`~QgsMapLayerElevationProperties.profileGenerationPropertyChanged` for more fine-grained signals.
%End
void renderingPropertyChanged();
%Docstring
Emitted when any of the elevation properties which relate solely to presentation of elevation
results have changed.
.. seealso:: :py:func:`changed`
.. seealso:: :py:func:`profileGenerationPropertyChanged`
.. versionadded:: 3.26
%End
void profileGenerationPropertyChanged();
%Docstring
Emitted when any of the elevation properties which relate solely to generation of elevation
profiles have changed.
.. seealso:: :py:func:`changed`
.. seealso:: :py:func:`renderingPropertyChanged`
.. versionadded:: 3.26
%End
protected:

View File

@ -104,6 +104,8 @@ QgsLineSymbol *QgsMeshLayerElevationProperties::profileLineSymbol() const
void QgsMeshLayerElevationProperties::setProfileLineSymbol( QgsLineSymbol *symbol )
{
mProfileLineSymbol.reset( symbol );
emit changed();
emit renderingPropertyChanged();
}
void QgsMeshLayerElevationProperties::setDefaultProfileLineSymbol()

View File

@ -83,6 +83,36 @@ bool QgsMapLayerElevationProperties::showByDefaultInElevationProfilePlots() cons
return false;
}
void QgsMapLayerElevationProperties::setZOffset( double offset )
{
if ( qgsDoubleNear( offset, mZOffset ) )
return;
mZOffset = offset;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsMapLayerElevationProperties::setZScale( double scale )
{
if ( qgsDoubleNear( scale, mZScale ) )
return;
mZScale = scale;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsMapLayerElevationProperties::setDataDefinedProperties( const QgsPropertyCollection &collection )
{
if ( mDataDefinedProperties == collection )
return;
mDataDefinedProperties = collection;
emit changed();
emit profileGenerationPropertyChanged();
}
QgsPropertiesDefinition QgsMapLayerElevationProperties::propertyDefinitions()
{
static std::once_flag initialized;

View File

@ -187,7 +187,7 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
*
* \see zOffset()
*/
void setZOffset( double offset ) { mZOffset = offset; }
void setZOffset( double offset );
/**
* Returns the z scale, which is a scaling factor which should be applied to z values from
@ -213,7 +213,7 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
*
* \see zScale()
*/
void setZScale( double scale ) { mZScale = scale; }
void setZScale( double scale );
/**
* Returns a reference to the object's property collection, used for data defined overrides.
@ -240,7 +240,7 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
* \see Property
* \since QGIS 3.26
*/
void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
void setDataDefinedProperties( const QgsPropertyCollection &collection );
/**
* Returns the definitions for data defined properties available for use in elevation properties.
@ -252,10 +252,32 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
signals:
/**
* Emitted when the elevation properties have changed.
* Emitted when any of the elevation properties have changed.
*
* See renderingPropertyChanged() and profileGenerationPropertyChanged() for more fine-grained signals.
*/
void changed();
/**
* Emitted when any of the elevation properties which relate solely to presentation of elevation
* results have changed.
*
* \see changed()
* \see profileGenerationPropertyChanged()
* \since QGIS 3.26
*/
void renderingPropertyChanged();
/**
* Emitted when any of the elevation properties which relate solely to generation of elevation
* profiles have changed.
*
* \see changed()
* \see renderingPropertyChanged()
* \since QGIS 3.26
*/
void profileGenerationPropertyChanged();
protected:
//! Z scale
double mZScale = 1.0;

View File

@ -104,6 +104,26 @@ bool QgsRasterLayerElevationProperties::showByDefaultInElevationProfilePlots() c
return mEnabled;
}
void QgsRasterLayerElevationProperties::setEnabled( bool enabled )
{
if ( enabled == mEnabled )
return;
mEnabled = enabled;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsRasterLayerElevationProperties::setBandNumber( int band )
{
if ( mBandNumber == band )
return;
mBandNumber = band;
emit changed();
emit profileGenerationPropertyChanged();
}
QgsLineSymbol *QgsRasterLayerElevationProperties::profileLineSymbol() const
{
return mProfileLineSymbol.get();
@ -112,6 +132,8 @@ QgsLineSymbol *QgsRasterLayerElevationProperties::profileLineSymbol() const
void QgsRasterLayerElevationProperties::setProfileLineSymbol( QgsLineSymbol *symbol )
{
mProfileLineSymbol.reset( symbol );
emit changed();
emit renderingPropertyChanged();
}
void QgsRasterLayerElevationProperties::setDefaultProfileLineSymbol()

View File

@ -65,7 +65,7 @@ class CORE_EXPORT QgsRasterLayerElevationProperties : public QgsMapLayerElevatio
*
* \see isEnabled()
*/
void setEnabled( bool enabled ) { mEnabled = enabled; }
void setEnabled( bool enabled );
/**
* Returns the band number from which the elevation should be taken.
@ -79,7 +79,7 @@ class CORE_EXPORT QgsRasterLayerElevationProperties : public QgsMapLayerElevatio
*
* \see bandNumber()
*/
void setBandNumber( int band ) { mBandNumber = band; }
void setBandNumber( int band );
/**
* Returns the line symbol used to render the raster profile in elevation profile plots.

View File

@ -237,6 +237,56 @@ bool QgsVectorLayerElevationProperties::showByDefaultInElevationProfilePlots() c
|| mClamping != Qgis::AltitudeClamping::Terrain;
}
void QgsVectorLayerElevationProperties::setClamping( Qgis::AltitudeClamping clamping )
{
if ( mClamping == clamping )
return;
mClamping = clamping;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsVectorLayerElevationProperties::setBinding( Qgis::AltitudeBinding binding )
{
if ( mBinding == binding )
return;
mBinding = binding;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsVectorLayerElevationProperties::setExtrusionEnabled( bool enabled )
{
if ( mEnableExtrusion == enabled )
return;
mEnableExtrusion = enabled;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsVectorLayerElevationProperties::setExtrusionHeight( double height )
{
if ( mExtrusionHeight == height )
return;
mExtrusionHeight = height;
emit changed();
emit profileGenerationPropertyChanged();
}
void QgsVectorLayerElevationProperties::setRespectLayerSymbology( bool enabled )
{
if ( mRespectLayerSymbology == enabled )
return;
mRespectLayerSymbology = enabled;
emit changed();
emit renderingPropertyChanged();
}
QgsLineSymbol *QgsVectorLayerElevationProperties::profileLineSymbol() const
{
return mProfileLineSymbol.get();
@ -245,6 +295,8 @@ QgsLineSymbol *QgsVectorLayerElevationProperties::profileLineSymbol() const
void QgsVectorLayerElevationProperties::setProfileLineSymbol( QgsLineSymbol *symbol )
{
mProfileLineSymbol.reset( symbol );
emit changed();
emit renderingPropertyChanged();
}
QgsFillSymbol *QgsVectorLayerElevationProperties::profileFillSymbol() const
@ -255,6 +307,8 @@ QgsFillSymbol *QgsVectorLayerElevationProperties::profileFillSymbol() const
void QgsVectorLayerElevationProperties::setProfileFillSymbol( QgsFillSymbol *symbol )
{
mProfileFillSymbol.reset( symbol );
emit changed();
emit renderingPropertyChanged();
}
QgsMarkerSymbol *QgsVectorLayerElevationProperties::profileMarkerSymbol() const
@ -265,6 +319,8 @@ QgsMarkerSymbol *QgsVectorLayerElevationProperties::profileMarkerSymbol() const
void QgsVectorLayerElevationProperties::setProfileMarkerSymbol( QgsMarkerSymbol *symbol )
{
mProfileMarkerSymbol.reset( symbol );
emit changed();
emit renderingPropertyChanged();
}
void QgsVectorLayerElevationProperties::setDefaultProfileLineSymbol( const QColor &color )

View File

@ -72,7 +72,7 @@ class CORE_EXPORT QgsVectorLayerElevationProperties : public QgsMapLayerElevatio
*
* \see clamping()
*/
void setClamping( Qgis::AltitudeClamping clamping ) { mClamping = clamping; }
void setClamping( Qgis::AltitudeClamping clamping );
/**
* Returns the altitude binding method, which determines how altitude is bound to individual vertices in features.
@ -90,7 +90,7 @@ class CORE_EXPORT QgsVectorLayerElevationProperties : public QgsMapLayerElevatio
*
* \see binding()
*/
void setBinding( Qgis::AltitudeBinding binding ) { mBinding = binding; }
void setBinding( Qgis::AltitudeBinding binding );
/**
* Returns TRUE if extrusion is enabled.
@ -106,7 +106,7 @@ class CORE_EXPORT QgsVectorLayerElevationProperties : public QgsMapLayerElevatio
* \see extrusionEnabled()
* \see setExtrusionHeight()
*/
void setExtrusionEnabled( bool enabled ) { mEnableExtrusion = enabled; }
void setExtrusionEnabled( bool enabled );
/**
* Returns the feature extrusion height.
@ -126,7 +126,7 @@ class CORE_EXPORT QgsVectorLayerElevationProperties : public QgsMapLayerElevatio
*
* \see extrusionHeight()
*/
void setExtrusionHeight( double height ) { mExtrusionHeight = height; }
void setExtrusionHeight( double height );
/**
* Returns TRUE if layer symbology should be respected when rendering elevation profile plots.
@ -146,7 +146,7 @@ class CORE_EXPORT QgsVectorLayerElevationProperties : public QgsMapLayerElevatio
*
* \see respectLayerSymbology()
*/
void setRespectLayerSymbology( bool enabled ) { mRespectLayerSymbology = enabled; }
void setRespectLayerSymbology( bool enabled );
/**
* Returns the symbol used to render lines for the layer in elevation profile plots.