17#include <QSvgRenderer>
39 connect( mAveragingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
40 this, &QgsMeshRenderer3dAveragingWidget::onAveragingMethodChanged );
43 connect( mSingleVerticalLayerIndexTopSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
47 connect( mSingleVerticalLayerIndexBottomSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
51 connect( mMultiTopVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
53 connect( mMultiTopVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
57 connect( mMultiBottomVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
59 connect( mMultiBottomVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
63 connect( mSigmaStartFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
65 connect( mSigmaEndFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
69 connect( mDepthStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
71 connect( mDepthEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
75 connect( mHeightStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
77 connect( mHeightEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
82 connect( mElevationStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
84 connect( mElevationEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
98 std::unique_ptr<QgsMesh3dAveragingMethod> averaging;
100 switch ( mAveragingMethodComboBox->currentIndex() )
104 const int verticalLevel = mSingleVerticalLayerIndexTopSpinBox->value();
110 const int verticalLevel = mSingleVerticalLayerIndexBottomSpinBox->value();
116 const int startVerticalLevel = mMultiTopVerticalLayerStartIndexSpinBox->value();
117 const int endVerticalLevel = mMultiTopVerticalLayerEndIndexSpinBox->value();
123 const int startVerticalLevel = mMultiBottomVerticalLayerStartIndexSpinBox->value();
124 const int endVerticalLevel = mMultiBottomVerticalLayerEndIndexSpinBox->value();
130 const double startFraction = mSigmaStartFractionSpinBox->value();
131 const double endFraction = mSigmaEndFractionSpinBox->value();
137 const double startDepth = mDepthStartSpinBox->value();
138 const double endDepth = mDepthEndSpinBox->value();
144 const double startHeight = mHeightStartSpinBox->value();
145 const double endHeight = mHeightEndSpinBox->value();
151 const double startVerticalLevel = mElevationStartSpinBox->value();
152 const double endVerticalLevel = mElevationEndSpinBox->value();
245 whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
246 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
250void QgsMeshRenderer3dAveragingWidget::onAveragingMethodChanged(
int methodIndex )
252 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( methodIndex );
256void QgsMeshRenderer3dAveragingWidget::updateGraphics()
258 setLabelSvg( mSingleTopPngLabel, QStringLiteral(
"SingleTop.svg" ) );
259 mSingleTopGroup->adjustSize();
261 setLabelSvg( mSingleBottomPngLabel, QStringLiteral(
"SingleBottom.svg" ) );
262 setLabelSvg( mMultiTopPngLabel, QStringLiteral(
"MultiTop.svg" ) );
263 setLabelSvg( mMultiBottomPngLabel, QStringLiteral(
"MultiBottom.svg" ) );
264 setLabelSvg( mSigmaPngLabel, QStringLiteral(
"Sigma.svg" ) );
265 setLabelSvg( mDepthPngLabel, QStringLiteral(
"Depth.svg" ) );
266 setLabelSvg( mHeightPngLabel, QStringLiteral(
"Height.svg" ) );
267 setLabelSvg( mElevationPngLabel, QStringLiteral(
"Elevation.svg" ) );
270void QgsMeshRenderer3dAveragingWidget::setLabelSvg( QLabel *imageLabel,
const QString &imgName )
272 const qreal dpi = mScreenHelper->
screenDpi();
273 const int desiredWidth =
static_cast<int>( 100 * dpi / 25.4 );
275 QSvgRenderer renderer( QStringLiteral(
":/images/themes/default/mesh/%1" ).arg( imgName ) );
276 if ( renderer.isValid() )
278 const QSize defaultSvgSize = renderer.defaultSize();
279 const int desiredHeight = defaultSvgSize.height() * desiredWidth / defaultSvgSize.width();
281 QPixmap pixmap( QSize( desiredWidth, desiredHeight ) );
282 pixmap.fill( Qt::transparent );
285 painter.begin( &pixmap );
286 renderer.render( &painter );
288 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.