17#include <QSvgRenderer>
22#include "moc_qgsmeshrenderer3daveragingwidget.cpp"
40 connect( mAveragingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
41 this, &QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged );
44 connect( mSingleVerticalLayerIndexTopSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
48 connect( mSingleVerticalLayerIndexBottomSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
52 connect( mMultiTopVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
54 connect( mMultiTopVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
58 connect( mMultiBottomVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
60 connect( mMultiBottomVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
64 connect( mSigmaStartFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
66 connect( mSigmaEndFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
70 connect( mDepthStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
72 connect( mDepthEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
76 connect( mHeightStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
78 connect( mHeightEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
83 connect( mElevationStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
85 connect( mElevationEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
99 std::unique_ptr<QgsMesh3DAveragingMethod> averaging;
101 switch ( mAveragingMethodComboBox->currentIndex() )
105 const int verticalLevel = mSingleVerticalLayerIndexTopSpinBox->value();
111 const int verticalLevel = mSingleVerticalLayerIndexBottomSpinBox->value();
117 const int startVerticalLevel = mMultiTopVerticalLayerStartIndexSpinBox->value();
118 const int endVerticalLevel = mMultiTopVerticalLayerEndIndexSpinBox->value();
124 const int startVerticalLevel = mMultiBottomVerticalLayerStartIndexSpinBox->value();
125 const int endVerticalLevel = mMultiBottomVerticalLayerEndIndexSpinBox->value();
131 const double startFraction = mSigmaStartFractionSpinBox->value();
132 const double endFraction = mSigmaEndFractionSpinBox->value();
138 const double startDepth = mDepthStartSpinBox->value();
139 const double endDepth = mDepthEndSpinBox->value();
145 const double startHeight = mHeightStartSpinBox->value();
146 const double endHeight = mHeightEndSpinBox->value();
152 const double startVerticalLevel = mElevationStartSpinBox->value();
153 const double endVerticalLevel = mElevationEndSpinBox->value();
246 whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
247 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
251void QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged(
int methodIndex )
253 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( methodIndex );
257void QgsMeshRenderer3DAveragingWidget::updateGraphics()
259 setLabelSvg( mSingleTopPngLabel, QStringLiteral(
"SingleTop.svg" ) );
260 mSingleTopGroup->adjustSize();
262 setLabelSvg( mSingleBottomPngLabel, QStringLiteral(
"SingleBottom.svg" ) );
263 setLabelSvg( mMultiTopPngLabel, QStringLiteral(
"MultiTop.svg" ) );
264 setLabelSvg( mMultiBottomPngLabel, QStringLiteral(
"MultiBottom.svg" ) );
265 setLabelSvg( mSigmaPngLabel, QStringLiteral(
"Sigma.svg" ) );
266 setLabelSvg( mDepthPngLabel, QStringLiteral(
"Depth.svg" ) );
267 setLabelSvg( mHeightPngLabel, QStringLiteral(
"Height.svg" ) );
268 setLabelSvg( mElevationPngLabel, QStringLiteral(
"Elevation.svg" ) );
271void QgsMeshRenderer3DAveragingWidget::setLabelSvg( QLabel *imageLabel,
const QString &imgName )
273 const qreal dpi = mScreenHelper->
screenDpi();
274 const int desiredWidth =
static_cast<int>( 100 * dpi / 25.4 );
276 QSvgRenderer renderer( QStringLiteral(
":/images/themes/default/mesh/%1" ).arg( imgName ) );
277 if ( renderer.isValid() )
279 const QSize defaultSvgSize = renderer.defaultSize();
280 const int desiredHeight = defaultSvgSize.height() * desiredWidth / defaultSvgSize.width();
282 QPixmap pixmap( QSize( desiredWidth, desiredHeight ) );
283 pixmap.fill( Qt::transparent );
286 painter.begin( &pixmap );
287 renderer.render( &painter );
289 imageLabel->setPixmap( pixmap );
Abstract class to interpolate 3d stacked mesh data to 2d data.
Method method() const
Returns type of averaging method.
Method
Type of averaging method.
@ RelativeHeightAveragingMethod
Method to average values defined by range of relative length units to the surface or bed level.
@ MultiLevelsAveragingMethod
Method to average values from selected vertical layers.
@ ElevationAveragingMethod
Method to average values defined by range of absolute length units to the model's datum.
@ SigmaAveragingMethod
Method to average values between 0 (bed level) and 1 (surface)
Elevation averaging method averages the values based on range defined absolute value to the model's d...
double startElevation() const
Returns start elevation.
double endElevation() const
Returns end elevation.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Multi level averaging method specifies limits of vertical layers from the top layer down or reversed.
Relative height averaging method averages the values based on range defined relative to bed elevation...
Represents all mesh renderer settings.
QgsMesh3DAveragingMethod * averagingMethod() const
Returns averaging method for conversion of 3d stacked mesh data to 2d data.
Sigma averages over the values between 0 (bed level) and 1 (surface).
double endFraction() const
Returns ending fraction.
double startFraction() const
Returns starting fraction.
A utility class for dynamic handling of changes to screen properties.
double screenDpi() const
Returns the current screen DPI for the screen that the parent widget appears on.
void screenDpiChanged(double dpi)
Emitted whenever the screen dpi associated with the widget is changed.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.