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() );
109 if ( mUserDefinedRadioButton->isChecked() )
122 edgeStrokeWidth.
setIsVariableWidth( mScalarEdgeStrokeWidthVariableRadioButton->isChecked() );
136 if ( mActiveDatasetGroup < 0 )
149 whileBlocking( mMinMaxValueTypeComboBox )->setCurrentIndex( mMinMaxValueTypeComboBox->findData( QVariant::fromValue(
settings.
extent() ) ) );
153 whileBlocking( mUserDefinedRadioButton )->setChecked(
false );
155 mScalarMinSpinBox->setEnabled(
false );
156 mScalarMaxSpinBox->setEnabled(
false );
157 mMinMaxValueTypeComboBox->setEnabled(
true );
161 whileBlocking( mUserDefinedRadioButton )->setChecked(
true );
163 mScalarMinSpinBox->setEnabled(
true );
164 mScalarMaxSpinBox->setEnabled(
true );
165 mMinMaxValueTypeComboBox->setEnabled(
false );
168 whileBlocking( mScalarColorRampShaderWidget )->setFromShader( shader );
169 whileBlocking( mScalarColorRampShaderWidget )->setMinimumMaximum( min, max );
172 whileBlocking( mScalarInterpolationTypeComboBox )->setCurrentIndex( index );
177 mScalarResamplingWidget->setVisible( hasFaces );
179 mEdgeWidthGroupBox->setVisible( hasEdges );
184 whileBlocking( mScalarEdgeStrokeWidthVariablePushButton )->setVariableStrokeWidth( edgeStrokeWidth );
189 mOpacityContainerWidget->setVisible(
false );
192 const double min = metadata.
minimum();
193 const double max = metadata.
maximum();
194 mScalarEdgeStrokeWidthVariablePushButton->setDefaultMinMaxValue( min, max );
197 onEdgeStrokeWidthMethodChanged();
200double QgsMeshRendererScalarSettingsWidget::spinBoxValue(
const QgsDoubleSpinBox *spinBox )
const
202 if ( spinBox->value() == spinBox->
clearValue() )
204 return std::numeric_limits<double>::quiet_NaN();
207 return spinBox->value();
210void QgsMeshRendererScalarSettingsWidget::minMaxChanged()
212 const double min = spinBoxValue( mScalarMinSpinBox );
213 const double max = spinBoxValue( mScalarMaxSpinBox );
214 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
217void QgsMeshRendererScalarSettingsWidget::recalculateMinMaxButtonClicked()
220 const double min = metadata.
minimum();
221 const double max = metadata.
maximum();
224 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
227void QgsMeshRendererScalarSettingsWidget::onEdgeStrokeWidthMethodChanged()
229 const bool variableWidth = mScalarEdgeStrokeWidthVariableRadioButton->isChecked();
230 mScalarEdgeStrokeWidthVariablePushButton->setVisible( variableWidth );
231 mScalarEdgeStrokeWidthSpinBox->setVisible( !variableWidth );
236 const int data = mScalarInterpolationTypeComboBox->currentData().toInt();
241bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnFaces()
const
246 if ( mActiveDatasetGroup < 0 )
254bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnEdges()
const
259 if ( mActiveDatasetGroup < 0 )
272void QgsMeshRendererScalarSettingsWidget::recalculateMinMax()
278 switch ( extentRange )
282 searchExtent = mMeshLayer->
extent();
289 searchExtent = mCanvas->
extent();
292 searchExtent = ct.
transform( searchExtent );
298 searchExtent = mMeshLayer->
extent();
322void QgsMeshRendererScalarSettingsWidget::mUserDefinedRadioButton_toggled(
bool toggled )
324 mMinMaxValueTypeComboBox->setEnabled( !toggled );
325 mScalarMinSpinBox->setEnabled( toggled );
326 mScalarMaxSpinBox->setEnabled( toggled );
327 mScalarRecalculateMinMaxButton->setEnabled( toggled );
331void QgsMeshRendererScalarSettingsWidget::mMinMaxRadioButton_toggled(
bool toggled )
333 mMinMaxValueTypeComboBox->setEnabled( toggled );
334 mScalarMinSpinBox->setEnabled( !toggled );
335 mScalarMaxSpinBox->setEnabled( !toggled );
336 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 that 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.
An 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, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
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.