17 #include <QSvgRenderer>
21 #include <QDesktopWidget>
32 static void _setSvg( QLabel *imageLabel,
33 const QString &imgName )
35 const qreal dpi = QgsApplication::desktop()->logicalDpiX();
36 const int desiredWidth =
static_cast<int>( 100 * dpi / 25.4 );
38 QSvgRenderer renderer( QStringLiteral(
":/images/themes/default/mesh/%1" ).arg( imgName ) );
39 if ( renderer.isValid() )
41 const QSize defaultSvgSize = renderer.defaultSize();
42 const int desiredHeight = defaultSvgSize.height() * desiredWidth / defaultSvgSize.width();
44 QPixmap pixmap( QSize( desiredWidth, desiredHeight ) );
45 pixmap.fill( Qt::transparent );
48 painter.begin( &pixmap );
49 renderer.render( &painter );
51 imageLabel->setPixmap( pixmap );
60 connect( mAveragingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
61 this, &QgsMeshRenderer3dAveragingWidget::onAveragingMethodChanged );
64 connect( mSingleVerticalLayerIndexTopSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
66 _setSvg( mSingleTopPngLabel,
67 QStringLiteral(
"SingleTop.svg" )
69 mSingleTopGroup->adjustSize();
72 connect( mSingleVerticalLayerIndexBottomSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
74 _setSvg( mSingleBottomPngLabel,
75 QStringLiteral(
"SingleBottom.svg" )
79 connect( mMultiTopVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
81 connect( mMultiTopVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
83 _setSvg( mMultiTopPngLabel,
84 QStringLiteral(
"MultiTop.svg" )
88 connect( mMultiBottomVerticalLayerStartIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
90 connect( mMultiBottomVerticalLayerEndIndexSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
92 _setSvg( mMultiBottomPngLabel,
93 QStringLiteral(
"MultiBottom.svg" )
97 connect( mSigmaStartFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
99 connect( mSigmaEndFractionSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
101 _setSvg( mSigmaPngLabel,
102 QStringLiteral(
"Sigma.svg" )
106 connect( mDepthStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
108 connect( mDepthEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
110 _setSvg( mDepthPngLabel,
111 QStringLiteral(
"Depth.svg" )
115 connect( mHeightStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
117 connect( mHeightEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
119 _setSvg( mHeightPngLabel,
120 QStringLiteral(
"Height.svg" )
124 connect( mElevationStartSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
126 connect( mElevationEndSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
128 _setSvg( mElevationPngLabel,
129 QStringLiteral(
"Elevation.svg" )
140 std::unique_ptr<QgsMesh3dAveragingMethod> averaging;
142 switch ( mAveragingMethodComboBox->currentIndex() )
146 const int verticalLevel = mSingleVerticalLayerIndexTopSpinBox->value();
152 const int verticalLevel = mSingleVerticalLayerIndexBottomSpinBox->value();
158 const int startVerticalLevel = mMultiTopVerticalLayerStartIndexSpinBox->value();
159 const int endVerticalLevel = mMultiTopVerticalLayerEndIndexSpinBox->value();
165 const int startVerticalLevel = mMultiBottomVerticalLayerStartIndexSpinBox->value();
166 const int endVerticalLevel = mMultiBottomVerticalLayerEndIndexSpinBox->value();
172 const double startFraction = mSigmaStartFractionSpinBox->value();
173 const double endFraction = mSigmaEndFractionSpinBox->value();
179 const double startDepth = mDepthStartSpinBox->value();
180 const double endDepth = mDepthEndSpinBox->value();
186 const double startHeight = mHeightStartSpinBox->value();
187 const double endHeight = mHeightEndSpinBox->value();
193 const double startVerticalLevel = mElevationStartSpinBox->value();
194 const double endVerticalLevel = mElevationEndSpinBox->value();
287 whileBlocking( mAveragingMethodComboBox )->setCurrentIndex( pageIndex );
288 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( pageIndex );
292 void QgsMeshRenderer3dAveragingWidget::onAveragingMethodChanged(
int methodIndex )
294 whileBlocking( mAveragingMethodStackedWidget )->setCurrentIndex( methodIndex );
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.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.