Add QgsMeshLayerElevationProperties subclass of

QgsMapLayerElevationProperties
This commit is contained in:
Nyall Dawson 2022-03-31 11:59:08 +10:00
parent 9ff504f614
commit 77b9066e92
19 changed files with 674 additions and 3 deletions

View File

@ -155,6 +155,8 @@ QgsMeshLayer cannot be copied.
virtual QgsMapLayerTemporalProperties *temporalProperties();
virtual QgsMapLayerElevationProperties *elevationProperties();
virtual void reload();
virtual QStringList subLayers() const;

View File

@ -0,0 +1,68 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmeshlayerelevationproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
class QgsMeshLayerElevationProperties : QgsMapLayerElevationProperties
{
%Docstring(signature="appended")
Mesh layer specific subclass of :py:class:`QgsMapLayerElevationProperties`.
.. versionadded:: 3.26
%End
%TypeHeaderCode
#include "qgsmeshlayerelevationproperties.h"
%End
public:
QgsMeshLayerElevationProperties( QObject *parent /TransferThis/ );
%Docstring
Constructor for QgsMeshLayerElevationProperties, with the specified ``parent`` object.
%End
~QgsMeshLayerElevationProperties();
virtual bool hasElevation() const;
virtual QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context );
virtual bool readXml( const QDomElement &element, const QgsReadWriteContext &context );
virtual bool isVisibleInZRange( const QgsDoubleRange &range ) const;
virtual QgsDoubleRange calculateZRange( QgsMapLayer *layer ) const;
QgsLineSymbol *profileLineSymbol() const;
%Docstring
Returns the line symbol used to render the mesh profile in elevation profile plots.
.. seealso:: :py:func:`setProfileLineSymbol`
%End
void setProfileLineSymbol( QgsLineSymbol *symbol /Transfer/ );
%Docstring
Sets the line ``symbol`` used to render the mesh profile in elevation profile plots.
Ownership of ``symbol`` is transferred to the plot.
.. seealso:: :py:func:`profileLineSymbol`
%End
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/mesh/qgsmeshlayerelevationproperties.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

View File

@ -27,6 +27,7 @@ how an individual :py:class:`QgsMapLayer` behaves with relation to z values or e
#include "qgspointcloudlayerelevationproperties.h"
#include "qgsrasterlayerelevationproperties.h"
#include "qgsvectorlayerelevationproperties.h"
#include "qgsmeshlayerelevationproperties.h"
%End
%ConvertToSubClassCode
if ( qobject_cast<QgsPointCloudLayerElevationProperties *>( sipCpp ) )
@ -41,6 +42,10 @@ how an individual :py:class:`QgsMapLayer` behaves with relation to z values or e
{
sipType = sipType_QgsRasterLayerElevationProperties;
}
else if ( qobject_cast<QgsMeshLayerElevationProperties *>( sipCpp ) )
{
sipType = sipType_QgsMeshLayerElevationProperties;
}
else
{
sipType = 0;

View File

@ -444,6 +444,7 @@
%Include auto_generated/mesh/qgsmeshdataprovidertemporalcapabilities.sip
%Include auto_generated/mesh/qgsmeshdataset.sip
%Include auto_generated/mesh/qgsmeshlayer.sip
%Include auto_generated/mesh/qgsmeshlayerelevationproperties.sip
%Include auto_generated/mesh/qgsmeshlayerinterpolator.sip
%Include auto_generated/mesh/qgsmeshlayertemporalproperties.sip
%Include auto_generated/mesh/qgsmeshrenderersettings.sip

View File

@ -259,6 +259,7 @@ set(QGIS_APP_SRCS
mesh/qgsmeshcalculatordialog.cpp
mesh/qgsnewmeshlayerdialog.cpp
mesh/qgsmaptooleditmeshframe.cpp
mesh/qgsmeshelevationpropertieswidget.cpp
mesh/qgsmeshtransformcoordinatesdockwidget.cpp
mesh/qgsmeshselectbyexpressiondialog.cpp

View File

@ -0,0 +1,109 @@
/***************************************************************************
qgsmeshelevationpropertieswidget.cpp
---------------------
begin : February 2022
copyright : (C) 2022 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsmeshelevationpropertieswidget.h"
#include "qgsstyle.h"
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgsmeshlayer.h"
#include "qgsmeshlayerelevationproperties.h"
#include "qgslinesymbol.h"
QgsMeshElevationPropertiesWidget::QgsMeshElevationPropertiesWidget( QgsMeshLayer *layer, QgsMapCanvas *canvas, QWidget *parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
{
setupUi( this );
mOffsetZSpinBox->setClearValue( 0 );
mScaleZSpinBox->setClearValue( 1 );
mLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
syncToLayer( layer );
connect( mOffsetZSpinBox, qOverload<double >( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged );
connect( mScaleZSpinBox, qOverload<double >( &QDoubleSpinBox::valueChanged ), this, &QgsMeshElevationPropertiesWidget::onChanged );
connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsMeshElevationPropertiesWidget::onChanged );
}
void QgsMeshElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer )
{
mLayer = qobject_cast< QgsMeshLayer * >( layer );
if ( !mLayer )
return;
mBlockUpdates = true;
const QgsMeshLayerElevationProperties *props = qgis::down_cast< const QgsMeshLayerElevationProperties * >( mLayer->elevationProperties() );
mOffsetZSpinBox->setValue( props->zOffset() );
mScaleZSpinBox->setValue( props->zScale() );
mLineStyleButton->setSymbol( props->profileLineSymbol()->clone() );
mBlockUpdates = false;
}
void QgsMeshElevationPropertiesWidget::apply()
{
if ( !mLayer )
return;
QgsMeshLayerElevationProperties *props = qgis::down_cast< QgsMeshLayerElevationProperties * >( mLayer->elevationProperties() );
props->setZOffset( mOffsetZSpinBox->value() );
props->setZScale( mScaleZSpinBox->value() );
props->setProfileLineSymbol( mLineStyleButton->clonedSymbol< QgsLineSymbol >() );
mLayer->trigger3DUpdate();
}
void QgsMeshElevationPropertiesWidget::onChanged()
{
if ( !mBlockUpdates )
emit widgetChanged();
}
//
// QgsMeshElevationPropertiesWidgetFactory
//
QgsMeshElevationPropertiesWidgetFactory::QgsMeshElevationPropertiesWidgetFactory( QObject *parent )
: QObject( parent )
{
setIcon( QgsApplication::getThemeIcon( QStringLiteral( "propertyicons/elevationscale.svg" ) ) );
setTitle( tr( "Elevation" ) );
}
QgsMapLayerConfigWidget *QgsMeshElevationPropertiesWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool, QWidget *parent ) const
{
return new QgsMeshElevationPropertiesWidget( qobject_cast< QgsMeshLayer * >( layer ), canvas, parent );
}
bool QgsMeshElevationPropertiesWidgetFactory::supportLayerPropertiesDialog() const
{
return true;
}
bool QgsMeshElevationPropertiesWidgetFactory::supportsStyleDock() const
{
return false;
}
bool QgsMeshElevationPropertiesWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
{
return layer->type() == QgsMapLayerType::MeshLayer;
}
QString QgsMeshElevationPropertiesWidgetFactory::layerPropertiesPagePositionHint() const
{
return QStringLiteral( "mOptsPage_Metadata" );
}

View File

@ -0,0 +1,65 @@
/***************************************************************************
qgsmeshelevationpropertieswidget.h
---------------------
begin : February 2022
copyright : (C) 2022 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMESHELEVATIONPROPERTIESWIDGET_H
#define QGSMESHELEVATIONPROPERTIESWIDGET_H
#include "qgsmaplayerconfigwidget.h"
#include "qgsmaplayerconfigwidgetfactory.h"
#include "ui_qgsmeshelevationpropertieswidgetbase.h"
class QgsMeshLayer;
class QgsMeshElevationPropertiesWidget : public QgsMapLayerConfigWidget, private Ui::QgsMeshElevationPropertiesWidgetBase
{
Q_OBJECT
public:
QgsMeshElevationPropertiesWidget( QgsMeshLayer *layer, QgsMapCanvas *canvas, QWidget *parent );
void syncToLayer( QgsMapLayer *layer ) override;
public slots:
void apply() override;
private slots:
void onChanged();
private:
QgsMeshLayer *mLayer = nullptr;
bool mBlockUpdates = false;
};
class QgsMeshElevationPropertiesWidgetFactory : public QObject, public QgsMapLayerConfigWidgetFactory
{
Q_OBJECT
public:
explicit QgsMeshElevationPropertiesWidgetFactory( QObject *parent = nullptr );
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget, QWidget *parent ) const override;
bool supportLayerPropertiesDialog() const override;
bool supportsStyleDock() const override;
bool supportsLayer( QgsMapLayer *layer ) const override;
QString layerPropertiesPagePositionHint() const override;
};
#endif // QGSMESHELEVATIONPROPERTIESWIDGET_H

View File

@ -120,6 +120,7 @@
#include "raster/qgsrasterelevationpropertieswidget.h"
#include "vector/qgsvectorelevationpropertieswidget.h"
#include "mesh/qgsmeshelevationpropertieswidget.h"
#ifdef HAVE_3D
#include "qgs3d.h"
@ -1487,6 +1488,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipBadLayers
registerMapLayerPropertiesFactory( new QgsPointCloudElevationPropertiesWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsRasterElevationPropertiesWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsVectorElevationPropertiesWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsMeshElevationPropertiesWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsAnnotationItemPropertiesWidgetFactory( this ) );
registerMapLayerPropertiesFactory( new QgsLayerTreeGroupPropertiesWidgetFactory( this ) );

View File

@ -19,6 +19,7 @@
#include "qgsmaplayer.h"
#include "qgsrasterlayer.h"
#include "qgsrasterlayerelevationproperties.h"
#include "qgslinesymbol.h"
QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent )
: QgsMapLayerConfigWidget( layer, canvas, parent )
@ -28,12 +29,14 @@ QgsRasterElevationPropertiesWidget::QgsRasterElevationPropertiesWidget( QgsRaste
mOffsetZSpinBox->setClearValue( 0 );
mScaleZSpinBox->setClearValue( 1 );
mElevationGroupBox->setChecked( false );
mLineStyleButton->setSymbolType( Qgis::SymbolType::Line );
syncToLayer( layer );
connect( mOffsetZSpinBox, qOverload<double >( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged );
connect( mScaleZSpinBox, qOverload<double >( &QDoubleSpinBox::valueChanged ), this, &QgsRasterElevationPropertiesWidget::onChanged );
connect( mElevationGroupBox, &QGroupBox::toggled, this, &QgsRasterElevationPropertiesWidget::onChanged );
connect( mLineStyleButton, &QgsSymbolButton::changed, this, &QgsRasterElevationPropertiesWidget::onChanged );
}
void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer )
@ -47,6 +50,8 @@ void QgsRasterElevationPropertiesWidget::syncToLayer( QgsMapLayer *layer )
mElevationGroupBox->setChecked( props->isEnabled() );
mOffsetZSpinBox->setValue( props->zOffset() );
mScaleZSpinBox->setValue( props->zScale() );
mLineStyleButton->setSymbol( props->profileLineSymbol()->clone() );
mBlockUpdates = false;
}
@ -59,6 +64,7 @@ void QgsRasterElevationPropertiesWidget::apply()
props->setEnabled( mElevationGroupBox->isChecked() );
props->setZOffset( mOffsetZSpinBox->value() );
props->setZScale( mScaleZSpinBox->value() );
props->setProfileLineSymbol( mLineStyleButton->clonedSymbol< QgsLineSymbol >() );
mLayer->trigger3DUpdate();
}

View File

@ -705,6 +705,7 @@ set(QGIS_CORE_SRCS
mesh/qgsmeshdataset.cpp
mesh/qgsmeshdatasetgroupstore.cpp
mesh/qgsmeshlayer.cpp
mesh/qgsmeshlayerelevationproperties.cpp
mesh/qgsmeshlayerinterpolator.cpp
mesh/qgsmeshlayerprofilegenerator.cpp
mesh/qgsmeshlayerrenderer.cpp
@ -1477,6 +1478,7 @@ set(QGIS_CORE_HDRS
mesh/qgsmeshdataset.h
mesh/qgsmeshdatasetgroupstore.h
mesh/qgsmeshlayer.h
mesh/qgsmeshlayerelevationproperties.h
mesh/qgsmeshlayerinterpolator.h
mesh/qgsmeshlayerprofilegenerator.h
mesh/qgsmeshlayerrenderer.h

View File

@ -44,14 +44,16 @@
#include "qgsmessagelog.h"
#include "qgsexpressioncontextutils.h"
#include "qgsmeshlayerprofilegenerator.h"
#include "qgsmeshlayerelevationproperties.h"
QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &baseName,
const QString &providerKey,
const QgsMeshLayer::LayerOptions &options )
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath ),
mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) ),
mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) )
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath )
, mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) )
, mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) )
, mElevationProperties( new QgsMeshLayerElevationProperties( this ) )
{
mShouldValidateCrs = !options.skipCrsValidation;
@ -1805,3 +1807,8 @@ QgsMapLayerTemporalProperties *QgsMeshLayer::temporalProperties()
{
return mTemporalProperties;
}
QgsMapLayerElevationProperties *QgsMeshLayer::elevationProperties()
{
return mElevationProperties;
}

View File

@ -40,6 +40,7 @@ class QgsMesh3dAveragingMethod;
class QgsMeshLayerTemporalProperties;
class QgsMeshDatasetGroupStore;
class QgsMeshEditor;
class QgsMeshLayerElevationProperties;
/**
* \ingroup core
@ -188,6 +189,7 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer, public QgsAbstractProfileSo
bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) override;
bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
QgsMapLayerTemporalProperties *temporalProperties() override;
QgsMapLayerElevationProperties *elevationProperties() override;
void reload() override;
QStringList subLayers() const override;
QString htmlMetadata() const override;
@ -958,6 +960,7 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer, public QgsAbstractProfileSo
QgsMeshSimplificationSettings mSimplificationSettings;
QgsMeshLayerTemporalProperties *mTemporalProperties = nullptr;
QgsMeshLayerElevationProperties *mElevationProperties = nullptr;
//! Temporal unit used by the provider
QgsUnitTypes::TemporalUnit mTemporalUnit = QgsUnitTypes::TemporalHours;

View File

@ -0,0 +1,93 @@
/***************************************************************************
qgsmeshlayerelevationproperties.cpp
---------------
begin : February 2022
copyright : (C) 2022 by Nyall Dawson
email : nyall dot dawson dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsmeshlayerelevationproperties.h"
#include "qgsmeshlayer.h"
#include "qgslinesymbol.h"
#include "qgssymbollayerutils.h"
#include "qgslinesymbollayer.h"
#include "qgsapplication.h"
#include "qgscolorschemeregistry.h"
QgsMeshLayerElevationProperties::QgsMeshLayerElevationProperties( QObject *parent )
: QgsMapLayerElevationProperties( parent )
{
setDefaultProfileLineSymbol();
}
QgsMeshLayerElevationProperties::~QgsMeshLayerElevationProperties() = default;
bool QgsMeshLayerElevationProperties::hasElevation() const
{
return true;
}
QDomElement QgsMeshLayerElevationProperties::writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context )
{
QDomElement element = document.createElement( QStringLiteral( "elevation" ) );
element.setAttribute( QStringLiteral( "zoffset" ), qgsDoubleToString( mZOffset ) );
element.setAttribute( QStringLiteral( "zscale" ), qgsDoubleToString( mZScale ) );
QDomElement profileLineSymbolElement = document.createElement( QStringLiteral( "profileLineSymbol" ) );
profileLineSymbolElement.appendChild( QgsSymbolLayerUtils::saveSymbol( QString(), mProfileLineSymbol.get(), document, context ) );
element.appendChild( profileLineSymbolElement );
parentElement.appendChild( element );
return element;
}
bool QgsMeshLayerElevationProperties::readXml( const QDomElement &element, const QgsReadWriteContext &context )
{
const QDomElement elevationElement = element.firstChildElement( QStringLiteral( "elevation" ) ).toElement();
mZOffset = elevationElement.attribute( QStringLiteral( "zoffset" ), QStringLiteral( "0" ) ).toDouble();
mZScale = elevationElement.attribute( QStringLiteral( "zscale" ), QStringLiteral( "1" ) ).toDouble();
const QDomElement profileLineSymbolElement = elevationElement.firstChildElement( QStringLiteral( "profileLineSymbol" ) ).firstChildElement( QStringLiteral( "symbol" ) );
mProfileLineSymbol.reset( QgsSymbolLayerUtils::loadSymbol< QgsLineSymbol >( profileLineSymbolElement, context ) );
if ( !mProfileLineSymbol )
setDefaultProfileLineSymbol();
return true;
}
bool QgsMeshLayerElevationProperties::isVisibleInZRange( const QgsDoubleRange & ) const
{
// TODO -- test actual raster z range
return true;
}
QgsDoubleRange QgsMeshLayerElevationProperties::calculateZRange( QgsMapLayer * ) const
{
// TODO -- determine actual z range from raster statistics
return QgsDoubleRange();
}
QgsLineSymbol *QgsMeshLayerElevationProperties::profileLineSymbol() const
{
return mProfileLineSymbol.get();
}
void QgsMeshLayerElevationProperties::setProfileLineSymbol( QgsLineSymbol *symbol )
{
mProfileLineSymbol.reset( symbol );
}
void QgsMeshLayerElevationProperties::setDefaultProfileLineSymbol()
{
std::unique_ptr< QgsSimpleLineSymbolLayer > profileLineLayer = std::make_unique< QgsSimpleLineSymbolLayer >( QgsApplication::colorSchemeRegistry()->fetchRandomStyleColor(), 0.6 );
mProfileLineSymbol = std::make_unique< QgsLineSymbol>( QgsSymbolLayerList( { profileLineLayer.release() } ) );
}

View File

@ -0,0 +1,78 @@
/***************************************************************************
qgsmeshlayerelevationproperties.h
---------------
begin : February 2022
copyright : (C) 2022 by Nyall Dawson
email : nyall dot dawson dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSMESHLAYERELEVATIONPROPERTIES_H
#define QGSMESHLAYERELEVATIONPROPERTIES_H
#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgsmaplayerelevationproperties.h"
class QgsLineSymbol;
/**
* \class QgsMeshLayerElevationProperties
* \ingroup core
* \brief Mesh layer specific subclass of QgsMapLayerElevationProperties.
*
* \since QGIS 3.26
*/
class CORE_EXPORT QgsMeshLayerElevationProperties : public QgsMapLayerElevationProperties
{
Q_OBJECT
public:
/**
* Constructor for QgsMeshLayerElevationProperties, with the specified \a parent object.
*/
QgsMeshLayerElevationProperties( QObject *parent SIP_TRANSFERTHIS );
~QgsMeshLayerElevationProperties() override;
bool hasElevation() const override;
QDomElement writeXml( QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context ) override;
bool readXml( const QDomElement &element, const QgsReadWriteContext &context ) override;
bool isVisibleInZRange( const QgsDoubleRange &range ) const override;
QgsDoubleRange calculateZRange( QgsMapLayer *layer ) const override;
/**
* Returns the line symbol used to render the mesh profile in elevation profile plots.
*
* \see setProfileLineSymbol()
*/
QgsLineSymbol *profileLineSymbol() const;
/**
* Sets the line \a symbol used to render the mesh profile in elevation profile plots.
*
* Ownership of \a symbol is transferred to the plot.
*
* \see profileLineSymbol()
*/
void setProfileLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
private:
void setDefaultProfileLineSymbol();
std::unique_ptr< QgsLineSymbol > mProfileLineSymbol;
};
#endif // QGSMESHLAYERELEVATIONPROPERTIES_H

View File

@ -43,6 +43,7 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
#include "qgspointcloudlayerelevationproperties.h"
#include "qgsrasterlayerelevationproperties.h"
#include "qgsvectorlayerelevationproperties.h"
#include "qgsmeshlayerelevationproperties.h"
#endif
Q_OBJECT
@ -61,6 +62,10 @@ class CORE_EXPORT QgsMapLayerElevationProperties : public QObject
{
sipType = sipType_QgsRasterLayerElevationProperties;
}
else if ( qobject_cast<QgsMeshLayerElevationProperties *>( sipCpp ) )
{
sipType = sipType_QgsMeshLayerElevationProperties;
}
else
{
sipType = 0;

View File

@ -22,6 +22,7 @@
#include "qgsrasteriterator.h"
#include "qgsgeometryengine.h"
#include "qgsgeos.h"
#include "qgslinesymbol.h"
#include "qgsapplication.h"
#include "qgscolorschemeregistry.h"

View File

@ -0,0 +1,163 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>QgsMeshElevationPropertiesWidgetBase</class>
<widget class="QWidget" name="QgsMeshElevationPropertiesWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>592</width>
<height>447</height>
</rect>
</property>
<property name="windowTitle">
<string>Raster Elevation Properties</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QGroupBox" name="mElevationGroupBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
<property name="title">
<string>Elevation Surface</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="syncGroup" stdset="0">
<string notr="true">vectorgeneral</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="1" colspan="2">
<widget class="QgsDoubleSpinBox" name="mOffsetZSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>-99999999999.000000000000000</double>
</property>
<property name="maximum">
<double>99999999999.000000000000000</double>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Offset</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Scale</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QgsDoubleSpinBox" name="mScaleZSpinBox">
<property name="decimals">
<number>6</number>
</property>
<property name="minimum">
<double>0.000000000000000</double>
</property>
<property name="maximum">
<double>99999999999.000000000000000</double>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Elevation scaling and offset can be used to manually correct elevation values from the layer.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;The scale is applied to the mesh values before adding the offset.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Profile Chart Appearance</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Line style</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsSymbolButton" name="mLineStyleButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgsdoublespinbox.h</header>
</customwidget>
<customwidget>
<class>QgsSymbolButton</class>
<extends>QToolButton</extends>
<header>qgssymbolbutton.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mElevationGroupBox</tabstop>
<tabstop>mScaleZSpinBox</tabstop>
<tabstop>mOffsetZSpinBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>

View File

@ -209,6 +209,7 @@ ADD_PYTHON_TEST(PyQgsMapUnitScale test_qgsmapunitscale.py)
ADD_PYTHON_TEST(PyQgsMargins test_qgsmargins.py)
ADD_PYTHON_TEST(PyQgsMarkerLineSymbolLayer test_qgsmarkerlinesymbollayer.py)
ADD_PYTHON_TEST(PyQgsMergedFeatureRenderer test_qgsmergedfeaturerenderer.py)
ADD_PYTHON_TEST(PyQgsMeshLayerElevationProperties test_qgsmeshlayerelevationproperties.py)
ADD_PYTHON_TEST(PyQgsMessageLog test_qgsmessagelog.py)
ADD_PYTHON_TEST(PyQgsMetadataBase test_qgsmetadatabase.py)
ADD_PYTHON_TEST(PyQgsMetadataUtils test_qgsmetadatautils.py)

View File

@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsMeshLayerElevationProperties
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
__author__ = 'Nyall Dawson'
__date__ = '09/11/2020'
__copyright__ = 'Copyright 2020, The QGIS Project'
import qgis # NOQA
from qgis.core import (
QgsMeshLayerElevationProperties,
QgsReadWriteContext,
QgsLineSymbol
)
from qgis.PyQt.QtXml import QDomDocument
from qgis.testing import start_app, unittest
start_app()
class TestQgsMeshLayerElevationProperties(unittest.TestCase):
def testBasic(self):
props = QgsMeshLayerElevationProperties(None)
self.assertEqual(props.zScale(), 1)
self.assertEqual(props.zOffset(), 0)
self.assertTrue(props.hasElevation())
self.assertIsInstance(props.profileLineSymbol(), QgsLineSymbol)
props.setZOffset(0.5)
props.setZScale(2)
self.assertEqual(props.zScale(), 2)
self.assertEqual(props.zOffset(), 0.5)
self.assertTrue(props.hasElevation())
sym = QgsLineSymbol.createSimple({'outline_color': '#ff4433', 'outline_width': 0.5})
props.setProfileLineSymbol(sym)
self.assertEqual(props.profileLineSymbol().color().name(), '#ff4433')
doc = QDomDocument("testdoc")
elem = doc.createElement('test')
props.writeXml(elem, doc, QgsReadWriteContext())
props2 = QgsMeshLayerElevationProperties(None)
props2.readXml(elem, QgsReadWriteContext())
self.assertEqual(props2.zScale(), 2)
self.assertEqual(props2.zOffset(), 0.5)
self.assertEqual(props2.profileLineSymbol().color().name(), '#ff4433')
if __name__ == '__main__':
unittest.main()