17#include "moc_qgsmeshrendererscalarsettingswidget.cpp"
19#include "QDialogButtonBox"
35 mScalarMinSpinBox->setSpecialValueText( QString() );
37 mScalarMaxSpinBox->setSpecialValueText( QString() );
39 mScalarMinSpinBox->setEnabled(
true );
40 mScalarMaxSpinBox->setEnabled(
true );
45 mScalarInterpolationTypeComboBox->setCurrentIndex( 0 );
50 mMinMaxValueTypeComboBox->setCurrentIndex( 0 );
52 mUserDefinedRadioButton->setChecked(
true );
53 mMinMaxValueTypeComboBox->setEnabled(
false );
55 mScalarEdgeStrokeWidthUnitSelectionWidget->setUnits(
65 connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked,
this, &QgsMeshRendererScalarSettingsWidget::recalculateMinMaxButtonClicked );
66 connect( mScalarMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
double ) { minMaxChanged(); } );
67 connect( mScalarMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [=](
double ) { minMaxChanged(); } );
68 connect( mScalarEdgeStrokeWidthVariableRadioButton, &QRadioButton::toggled,
this, &QgsMeshRendererScalarSettingsWidget::onEdgeStrokeWidthMethodChanged );
80 connect( mUserDefinedRadioButton, &QRadioButton::toggled,
this, &QgsMeshRendererScalarSettingsWidget::mUserDefinedRadioButton_toggled );
81 connect( mMinMaxRadioButton, &QRadioButton::toggled,
this, &QgsMeshRendererScalarSettingsWidget::mMinMaxRadioButton_toggled );
83 connect( mMinMaxValueTypeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererScalarSettingsWidget::recalculateMinMax );
90 mScalarInterpolationTypeComboBox->setEnabled( !dataIsDefinedOnEdges() );
95 mActiveDatasetGroup = groupIndex;
96 mScalarInterpolationTypeComboBox->setEnabled( !dataIsDefinedOnEdges() );
110 if ( mUserDefinedRadioButton->isChecked() )
123 edgeStrokeWidth.
setIsVariableWidth( mScalarEdgeStrokeWidthVariableRadioButton->isChecked() );
137 if ( mActiveDatasetGroup < 0 )
150 mMinMaxValueTypeComboBox->setCurrentIndex( mMinMaxValueTypeComboBox->findData( QVariant::fromValue(
settings.
extent() ) ) );
154 whileBlocking( mUserDefinedRadioButton )->setChecked(
false );
156 mScalarMinSpinBox->setEnabled(
false );
157 mScalarMaxSpinBox->setEnabled(
false );
158 mMinMaxValueTypeComboBox->setEnabled(
true );
162 whileBlocking( mUserDefinedRadioButton )->setChecked(
true );
164 mScalarMinSpinBox->setEnabled(
true );
165 mScalarMaxSpinBox->setEnabled(
true );
166 mMinMaxValueTypeComboBox->setEnabled(
false );
169 whileBlocking( mScalarColorRampShaderWidget )->setFromShader( shader );
170 whileBlocking( mScalarColorRampShaderWidget )->setMinimumMaximum( min, max );
173 whileBlocking( mScalarInterpolationTypeComboBox )->setCurrentIndex( index );
178 mScalarResamplingWidget->setVisible( hasFaces );
180 mEdgeWidthGroupBox->setVisible( hasEdges );
185 whileBlocking( mScalarEdgeStrokeWidthVariablePushButton )->setVariableStrokeWidth( edgeStrokeWidth );
190 mOpacityContainerWidget->setVisible(
false );
193 const double min = metadata.
minimum();
194 const double max = metadata.
maximum();
195 mScalarEdgeStrokeWidthVariablePushButton->setDefaultMinMaxValue( min, max );
198 onEdgeStrokeWidthMethodChanged();
201double QgsMeshRendererScalarSettingsWidget::spinBoxValue(
const QgsDoubleSpinBox *spinBox )
const
203 if ( spinBox->value() == spinBox->
clearValue() )
205 return std::numeric_limits<double>::quiet_NaN();
208 return spinBox->value();
211void QgsMeshRendererScalarSettingsWidget::minMaxChanged()
213 const double min = spinBoxValue( mScalarMinSpinBox );
214 const double max = spinBoxValue( mScalarMaxSpinBox );
215 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
218void QgsMeshRendererScalarSettingsWidget::recalculateMinMaxButtonClicked()
221 const double min = metadata.
minimum();
222 const double max = metadata.
maximum();
225 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
228void QgsMeshRendererScalarSettingsWidget::onEdgeStrokeWidthMethodChanged()
230 const bool variableWidth = mScalarEdgeStrokeWidthVariableRadioButton->isChecked();
231 mScalarEdgeStrokeWidthVariablePushButton->setVisible( variableWidth );
232 mScalarEdgeStrokeWidthSpinBox->setVisible( !variableWidth );
237 const int data = mScalarInterpolationTypeComboBox->currentData().toInt();
242bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnFaces()
const
247 if ( mActiveDatasetGroup < 0 )
255bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnEdges()
const
260 if ( mActiveDatasetGroup < 0 )
273void QgsMeshRendererScalarSettingsWidget::recalculateMinMax()
279 switch ( extentRange )
283 searchExtent = mMeshLayer->
extent();
290 searchExtent = mCanvas->
extent();
293 searchExtent = ct.
transform( searchExtent );
299 searchExtent = mMeshLayer->
extent();
323void QgsMeshRendererScalarSettingsWidget::mUserDefinedRadioButton_toggled(
bool toggled )
325 mMinMaxValueTypeComboBox->setEnabled( !toggled );
326 mScalarMinSpinBox->setEnabled( toggled );
327 mScalarMaxSpinBox->setEnabled( toggled );
328 mScalarRecalculateMinMaxButton->setEnabled( toggled );
332void QgsMeshRendererScalarSettingsWidget::mMinMaxRadioButton_toggled(
bool toggled )
334 mMinMaxValueTypeComboBox->setEnabled( toggled );
335 mScalarMinSpinBox->setEnabled( !toggled );
336 mScalarMaxSpinBox->setEnabled( !toggled );
337 mScalarRecalculateMinMaxButton->setEnabled( !toggled );
@ MinimumMaximum
Real min-max values.
MeshRangeExtent
Describes the extent used to compute mesh ranges (min/max values).
@ UpdatedCanvas
Constantly updated extent of the canvas is used to compute statistics.
@ WholeMesh
Whole mesh is used to compute statistics.
@ FixedCanvas
Current extent of the canvas (at the time of computation) is used to compute statistics.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Custom exception class for Coordinate Reference System related exceptions.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
@ MinimumValue
Reset value to minimum()
Represents a width than can vary depending on values.
void setFixedStrokeWidth(double fixedWidth)
Sets the fixed width.
void setIsVariableWidth(bool isVariableWidth)
Returns whether the width is variable.
double fixedStrokeWidth() const
Returns the fixed width.
bool isVariableWidth() const
Returns whether the width is variable.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsDateTimeRange & temporalRange() const
Returns map canvas datetime range.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
QgsCoordinateReferenceSystem crs
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QgsRectangle extent() const override
Returns the extent of the layer.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
bool minimumMaximumActiveScalarDataset(const QgsRectangle &extent, const QgsMeshDatasetIndex &datasetIndex, double &min, double &max)
Extracts minimum and maximum value for active scalar dataset on mesh faces.
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange, int group=-1) const
Returns dataset index from active scalar group depending on the time range.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
Represents a mesh renderer settings for scalar datasets.
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
Qgis::MeshRangeExtent extent() const
Returns the mesh extent for minimum maximum calculation.
double opacity() const
Returns opacity.
void setEdgeStrokeWidthUnit(Qgis::RenderUnit edgeStrokeWidthUnit)
Sets the stroke width unit used to render edges scalar dataset.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
Qgis::MeshRangeLimit limits() const
Returns the range limits type for minimum maximum calculation.
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
void setExtent(Qgis::MeshRangeExtent extent)
Sets the mesh extent for minimum maximum calculation.
double classificationMinimum() const
Returns min value used for creation of the color ramp shader.
void setOpacity(double opacity)
Sets opacity.
DataResamplingMethod
Resampling of value from dataset.
@ NoResampling
Does not use resampling.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
Qgis::RenderUnit edgeStrokeWidthUnit() const
Returns the stroke width unit used to render edges scalar dataset.
DataResamplingMethod dataResamplingMethod() const
Returns the type of interpolation to use to convert face defined datasets to values on vertices.
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
double classificationMaximum() const
Returns max value used for creation of the color ramp shader.
void setLimits(Qgis::MeshRangeLimit limits)
Sets the range limits type for minimum maximum calculation.
QgsInterpolatedLineWidth edgeStrokeWidth() const
Returns the stroke width used to render edges scalar dataset.
void setDataResamplingMethod(const DataResamplingMethod &dataResamplingMethod)
Sets data interpolation method.
Represents all mesh renderer settings.
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QgsProject * instance()
Returns the QgsProject singleton instance.
A rectangle specified with double values.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.