29#include <QSvgRenderer>
31#include "moc_qgsmeshrenderer3daveragingwidget.cpp"
41 connect( mAveragingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged );
85 std::unique_ptr<QgsMesh3DAveragingMethod> averaging;
87 switch ( mAveragingMethodComboBox->currentIndex() )
91 const int verticalLevel = mSingleVerticalLayerIndexTopSpinBox->value();
92 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( verticalLevel,
true );
97 const int verticalLevel = mSingleVerticalLayerIndexBottomSpinBox->value();
98 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( verticalLevel,
false );
103 const int startVerticalLevel = mMultiTopVerticalLayerStartIndexSpinBox->value();
104 const int endVerticalLevel = mMultiTopVerticalLayerEndIndexSpinBox->value();
105 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( startVerticalLevel, endVerticalLevel,
true );
110 const int startVerticalLevel = mMultiBottomVerticalLayerStartIndexSpinBox->value();
111 const int endVerticalLevel = mMultiBottomVerticalLayerEndIndexSpinBox->value();
112 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( startVerticalLevel, endVerticalLevel,
false );
117 const double startFraction = mSigmaStartFractionSpinBox->value();
118 const double endFraction = mSigmaEndFractionSpinBox->value();
119 averaging = std::make_unique<QgsMeshSigmaAveragingMethod>( startFraction, endFraction );
124 const double startDepth = mDepthStartSpinBox->value();
125 const double endDepth = mDepthEndSpinBox->value();
126 averaging = std::make_unique<QgsMeshRelativeHeightAveragingMethod>( startDepth, endDepth,
true );
131 const double startHeight = mHeightStartSpinBox->value();
132 const double endHeight = mHeightEndSpinBox->value();
133 averaging = std::make_unique<QgsMeshRelativeHeightAveragingMethod>( startHeight, endHeight,
false );
138 const double startVerticalLevel = mElevationStartSpinBox->value();
139 const double endVerticalLevel = mElevationEndSpinBox->value();
140 averaging = std::make_unique<QgsMeshElevationAveragingMethod>( startVerticalLevel, endVerticalLevel );
232 whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
233 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
237void QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged(
int methodIndex )
239 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( methodIndex );
243void QgsMeshRenderer3DAveragingWidget::updateGraphics()
245 setLabelSvg( mSingleTopPngLabel, QStringLiteral(
"SingleTop.svg" ) );
246 mSingleTopGroup->adjustSize();
248 setLabelSvg( mSingleBottomPngLabel, QStringLiteral(
"SingleBottom.svg" ) );
249 setLabelSvg( mMultiTopPngLabel, QStringLiteral(
"MultiTop.svg" ) );
250 setLabelSvg( mMultiBottomPngLabel, QStringLiteral(
"MultiBottom.svg" ) );
251 setLabelSvg( mSigmaPngLabel, QStringLiteral(
"Sigma.svg" ) );
252 setLabelSvg( mDepthPngLabel, QStringLiteral(
"Depth.svg" ) );
253 setLabelSvg( mHeightPngLabel, QStringLiteral(
"Height.svg" ) );
254 setLabelSvg( mElevationPngLabel, QStringLiteral(
"Elevation.svg" ) );
257void QgsMeshRenderer3DAveragingWidget::setLabelSvg( QLabel *imageLabel,
const QString &imgName )
259 const qreal dpi = mScreenHelper->screenDpi();
260 const int desiredWidth =
static_cast<int>( 100 * dpi / 25.4 );
262 QSvgRenderer renderer( QStringLiteral(
":/images/themes/default/mesh/%1" ).arg( imgName ) );
263 if ( renderer.isValid() )
265 const QSize defaultSvgSize = renderer.defaultSize();
266 const int desiredHeight = defaultSvgSize.height() * desiredWidth / defaultSvgSize.width();
268 QPixmap pixmap( QSize( desiredWidth, desiredHeight ) );
269 pixmap.fill( Qt::transparent );
272 painter.begin( &pixmap );
273 renderer.render( &painter );
275 imageLabel->setPixmap( pixmap );
Abstract class for interpolating 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.
Multi level averaging method specifies limits of vertical layers from the top layer down or reversed.
Relative height averaging method which averages the values based on range defined relative to bed ele...
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.
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.