18#include "QDialogButtonBox"
34 mScalarMinSpinBox->setClearValueMode( QgsDoubleSpinBox::ClearValueMode::MinimumValue );
35 mScalarMinSpinBox->setSpecialValueText( QString( ) );
36 mScalarMaxSpinBox->setClearValueMode( QgsDoubleSpinBox::ClearValueMode::MinimumValue );
37 mScalarMaxSpinBox->setSpecialValueText( QString( ) );
42 mScalarInterpolationTypeComboBox->setCurrentIndex( 0 );
51 connect( mScalarRecalculateMinMaxButton, &QPushButton::clicked,
this, &QgsMeshRendererScalarSettingsWidget::recalculateMinMaxButtonClicked );
52 connect( mScalarMinSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
double ) { minMaxChanged(); } );
53 connect( mScalarMaxSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, [ = ](
double ) { minMaxChanged(); } );
54 connect( mScalarEdgeStrokeWidthVariableRadioButton, &QRadioButton::toggled,
this, &QgsMeshRendererScalarSettingsWidget::onEdgeStrokeWidthMethodChanged );
62 connect( mScalarEdgeStrokeWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
73 mScalarInterpolationTypeComboBox->setEnabled( !dataIsDefinedOnEdges() );
78 mActiveDatasetGroup = groupIndex;
79 mScalarInterpolationTypeComboBox->setEnabled( !dataIsDefinedOnEdges() );
90 const bool hasEdges = ( mMeshLayer->
contains( QgsMesh::ElementType::Edge ) );
95 edgeStrokeWidth.
setIsVariableWidth( mScalarEdgeStrokeWidthVariableRadioButton->isChecked() );
109 if ( mActiveDatasetGroup < 0 )
120 whileBlocking( mScalarColorRampShaderWidget )->setFromShader( shader );
121 whileBlocking( mScalarColorRampShaderWidget )->setMinimumMaximum( min, max );
124 whileBlocking( mScalarInterpolationTypeComboBox )->setCurrentIndex( index );
126 const bool hasEdges = ( mMeshLayer->
contains( QgsMesh::ElementType::Edge ) );
127 const bool hasFaces = ( mMeshLayer->
contains( QgsMesh::ElementType::Face ) );
129 mScalarResamplingWidget->setVisible( hasFaces );
131 mEdgeWidthGroupBox->setVisible( hasEdges );
136 whileBlocking( mScalarEdgeStrokeWidthVariablePushButton )->setVariableStrokeWidth( edgeStrokeWidth );
141 mOpacityContainerWidget->setVisible(
false );
144 const double min = metadata.
minimum();
145 const double max = metadata.
maximum();
146 mScalarEdgeStrokeWidthVariablePushButton->setDefaultMinMaxValue( min, max );
149 onEdgeStrokeWidthMethodChanged();
152double QgsMeshRendererScalarSettingsWidget::spinBoxValue(
const QgsDoubleSpinBox *spinBox )
const
154 if ( spinBox->value() == spinBox->
clearValue() )
156 return std::numeric_limits<double>::quiet_NaN();
159 return spinBox->value();
162void QgsMeshRendererScalarSettingsWidget::minMaxChanged()
164 const double min = spinBoxValue( mScalarMinSpinBox );
165 const double max = spinBoxValue( mScalarMaxSpinBox );
166 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
169void QgsMeshRendererScalarSettingsWidget::recalculateMinMaxButtonClicked()
172 const double min = metadata.
minimum();
173 const double max = metadata.
maximum();
176 mScalarColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
179void QgsMeshRendererScalarSettingsWidget::onEdgeStrokeWidthMethodChanged()
181 const bool variableWidth = mScalarEdgeStrokeWidthVariableRadioButton->isChecked();
182 mScalarEdgeStrokeWidthVariablePushButton->setVisible( variableWidth );
183 mScalarEdgeStrokeWidthSpinBox->setVisible( !variableWidth );
188 const int data = mScalarInterpolationTypeComboBox->currentData().toInt();
193bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnFaces()
const
198 if ( mActiveDatasetGroup < 0 )
206bool QgsMeshRendererScalarSettingsWidget::dataIsDefinedOnEdges()
const
211 if ( mActiveDatasetGroup < 0 )
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
The QgsSpinBox is a spin box with a clear button that will set the value to the defined clear value.
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.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
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.
double opacity() const
Returns opacity.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
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.
@ None
Does not use resampling.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
DataResamplingMethod dataResamplingMethod() const
Returns the type of interpolation to use to convert face defined datasets to values on vertices.
void setEdgeStrokeWidthUnit(const QgsUnitTypes::RenderUnit &edgeStrokeWidthUnit)
Sets the stroke width unit used to render edges scalar dataset.
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.
QgsUnitTypes::RenderUnit edgeStrokeWidthUnit() const
Returns the stroke width unit used to render edges scalar dataset.
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.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.