30#include <QSvgRenderer>
32#include "moc_qgsmeshrenderer3daveragingwidget.cpp"
34using namespace Qt::StringLiterals;
44 connect( mAveragingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged );
88 std::unique_ptr<QgsMesh3DAveragingMethod> averaging;
90 switch ( mAveragingMethodComboBox->currentIndex() )
94 const int verticalLevel = mSingleVerticalLayerIndexTopSpinBox->value();
95 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( verticalLevel,
true );
100 const int verticalLevel = mSingleVerticalLayerIndexBottomSpinBox->value();
101 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( verticalLevel,
false );
106 const int startVerticalLevel = mMultiTopVerticalLayerStartIndexSpinBox->value();
107 const int endVerticalLevel = mMultiTopVerticalLayerEndIndexSpinBox->value();
108 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( startVerticalLevel, endVerticalLevel,
true );
113 const int startVerticalLevel = mMultiBottomVerticalLayerStartIndexSpinBox->value();
114 const int endVerticalLevel = mMultiBottomVerticalLayerEndIndexSpinBox->value();
115 averaging = std::make_unique<QgsMeshMultiLevelsAveragingMethod>( startVerticalLevel, endVerticalLevel,
false );
120 const double startFraction = mSigmaStartFractionSpinBox->value();
121 const double endFraction = mSigmaEndFractionSpinBox->value();
122 averaging = std::make_unique<QgsMeshSigmaAveragingMethod>( startFraction, endFraction );
127 const double startDepth = mDepthStartSpinBox->value();
128 const double endDepth = mDepthEndSpinBox->value();
129 averaging = std::make_unique<QgsMeshRelativeHeightAveragingMethod>( startDepth, endDepth,
true );
134 const double startHeight = mHeightStartSpinBox->value();
135 const double endHeight = mHeightEndSpinBox->value();
136 averaging = std::make_unique<QgsMeshRelativeHeightAveragingMethod>( startHeight, endHeight,
false );
141 const double startVerticalLevel = mElevationStartSpinBox->value();
142 const double endVerticalLevel = mElevationEndSpinBox->value();
143 averaging = std::make_unique<QgsMeshElevationAveragingMethod>( startVerticalLevel, endVerticalLevel );
235 whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
236 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
240void QgsMeshRenderer3DAveragingWidget::onAveragingMethodChanged(
int methodIndex )
242 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( methodIndex );
246void QgsMeshRenderer3DAveragingWidget::updateGraphics()
248 setLabelSvg( mSingleTopPngLabel, u
"SingleTop.svg"_s );
249 mSingleTopGroup->adjustSize();
251 setLabelSvg( mSingleBottomPngLabel, u
"SingleBottom.svg"_s );
252 setLabelSvg( mMultiTopPngLabel, u
"MultiTop.svg"_s );
253 setLabelSvg( mMultiBottomPngLabel, u
"MultiBottom.svg"_s );
254 setLabelSvg( mSigmaPngLabel, u
"Sigma.svg"_s );
255 setLabelSvg( mDepthPngLabel, u
"Depth.svg"_s );
256 setLabelSvg( mHeightPngLabel, u
"Height.svg"_s );
257 setLabelSvg( mElevationPngLabel, u
"Elevation.svg"_s );
260void QgsMeshRenderer3DAveragingWidget::setLabelSvg( QLabel *imageLabel,
const QString &imgName )
262 const qreal dpi = mScreenHelper->screenDpi();
263 const int desiredWidth =
static_cast<int>( 100 * dpi / 25.4 );
265 QSvgRenderer renderer( u
":/images/themes/default/mesh/%1"_s.arg( imgName ) );
266 if ( renderer.isValid() )
268 const QSize defaultSvgSize = renderer.defaultSize();
269 const int desiredHeight = defaultSvgSize.height() * desiredWidth / defaultSvgSize.width();
271 QPixmap pixmap( QSize( desiredWidth, desiredHeight ) );
272 pixmap.fill( Qt::transparent );
275 painter.begin( &pixmap );
276 renderer.render( &painter );
278 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.