21#include "moc_qgsmeshrenderervectorsettingswidget.cpp"
28 QVector<QgsDoubleSpinBox *> widgets;
29 widgets << mMinMagSpinBox << mMaxMagSpinBox
30 << mHeadWidthSpinBox << mHeadLengthSpinBox
31 << mMinimumShaftSpinBox << mMaximumShaftSpinBox
32 << mScaleShaftByFactorOfSpinBox << mShaftLengthSpinBox
33 << mWindBarbLengthSpinBox << mWindBarbMagnitudeMultiplierSpinBox;
36 for (
const auto &widget : std::as_const( widgets ) )
39 widget->setSpecialValueText( QString() );
40 widget->setValue( widget->minimum() );
43 mShaftLengthComboBox->setCurrentIndex( -1 );
48 mXSpacingSpinBox->setClearValue( 10.0 );
49 mYSpacingSpinBox->setClearValue( 10.0 );
50 mStreamlinesDensitySpinBox->setClearValue( 15.0 );
51 mTracesParticlesCountSpinBox->setClearValue( 1000 );
52 mTracesMaxLengthSpinBox->setClearValue( 100.0 );
54 mWindBarbLengthSpinBox->setClearValue( 10.0 );
55 mWindBarbMagnitudeMultiplierSpinBox->setValue( 1.0 );
56 mWindBarbMagnitudeMultiplierSpinBox->setClearValue( 1.0 );
59 connect( mColoringMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged );
61 connect( mColorRampShaderMinimumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
62 connect( mColorRampShaderMaximumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
68 connect( mShaftLengthComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), mShaftOptionsStackedWidget, &QStackedWidget::setCurrentIndex );
72 connect( mColorRampShaderLoadButton, &QPushButton::clicked,
this, &QgsMeshRendererVectorSettingsWidget::loadColorRampShader );
74 onColoringMethodChanged();
76 for (
const auto &widget : std::as_const( widgets ) )
84 connect( mSymbologyVectorComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onSymbologyChanged );
85 onSymbologyChanged( 0 );
89 connect( mStreamlinesSeedingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged );
90 onStreamLineSeedingMethodChanged( 0 );
100 mTracesTailLengthMapUnitWidget->setUnits(
110 mWindBarbLengthMapUnitWidget->setUnits(
118 connect( mWindBarbUnitsComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onWindBarbUnitsChanged );
119 onWindBarbUnitsChanged( 0 );
138 settings.setColor( mColorWidget->color() );
139 settings.setLineWidth( mLineWidthSpinBox->value() );
141 settings.setColorRampShader( mColorRampShaderWidget->shader() );
144 double val = filterValue( mMinMagSpinBox, -1 );
147 val = filterValue( mMaxMagSpinBox, -1 );
158 bool enabled = mDisplayVectorsOnGridGroupBox->isChecked();
159 settings.setOnUserDefinedGrid( enabled );
160 settings.setUserGridCellWidth( mXSpacingSpinBox->value() );
161 settings.setUserGridCellHeight( mYSpacingSpinBox->value() );
167 val = filterValue( mMinimumShaftSpinBox, arrowSettings.
minShaftLength() );
170 val = filterValue( mMaximumShaftSpinBox, arrowSettings.
maxShaftLength() );
173 val = filterValue( mScaleShaftByFactorOfSpinBox, arrowSettings.
scaleFactor() );
179 settings.setArrowsSettings( arrowSettings );
187 streamlineSettings.
setSeedingDensity( mStreamlinesDensitySpinBox->value() / 100 );
189 settings.setStreamLinesSettings( streamlineSettings );
196 settings.setTracesSettings( tracesSettings );
200 windBarbSettings.
setShaftLength( mWindBarbLengthSpinBox->value() );
206 settings.setWindBarbSettings( windBarbSettings );
213 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
216 if ( mActiveDatasetGroup < 0 )
224 symbologyLabel->setVisible( hasFaces );
225 mSymbologyVectorComboBox->setVisible( hasFaces );
226 mSymbologyVectorComboBox->setCurrentIndex( hasFaces ?
settings.symbology() : 0 );
232 mColorWidget->setColor(
settings.color() );
233 mLineWidthSpinBox->setValue(
settings.lineWidth() );
234 mColoringMethodComboBox->setCurrentIndex( mColoringMethodComboBox->findData(
settings.coloringMethod() ) );
235 mColorRampShaderWidget->setFromShader(
settings.colorRampShader() );
236 mColorRampShaderMinimumSpinBox->setValue(
settings.colorRampShader().minimumValue() );
237 mColorRampShaderMaximumSpinBox->setValue(
settings.colorRampShader().maximumValue() );
242 mMinMagSpinBox->setValue(
settings.filterMin() );
246 mMaxMagSpinBox->setValue(
settings.filterMax() );
254 mDisplayVectorsOnGridGroupBox->setVisible( hasFaces );
255 mDisplayVectorsOnGridGroupBox->setChecked(
settings.isOnUserDefinedGrid() && hasFaces );
256 mXSpacingSpinBox->setValue(
settings.userGridCellWidth() );
257 mYSpacingSpinBox->setValue(
settings.userGridCellHeight() );
264 mScaleShaftByFactorOfSpinBox->setValue( arrowSettings.
scaleFactor() );
270 mStreamlinesSeedingMethodComboBox->setCurrentIndex( streamlinesSettings.
seedingMethod() );
271 mStreamlinesDensitySpinBox->setValue( streamlinesSettings.
seedingDensity() * 100 );
278 mTracesParticlesCountSpinBox->setValue( tracesSettings.
particlesCount() );
282 mWindBarbLengthSpinBox->setValue( windBarbSettings.
shaftLength() );
283 mWindBarbUnitsComboBox->setCurrentIndex(
static_cast<int>( windBarbSettings.
magnitudeUnits() ) );
288void QgsMeshRendererVectorSettingsWidget::onSymbologyChanged(
int currentIndex )
303 mDisplayVectorsOnGridGroupBox->setEnabled(
308void QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged(
int currentIndex )
311 mStreamlinesDensityLabel->setEnabled( enabled );
312 mStreamlinesDensitySpinBox->setEnabled( enabled );
314 mDisplayVectorsOnGridGroupBox->setEnabled( !enabled );
317void QgsMeshRendererVectorSettingsWidget::onWindBarbUnitsChanged(
int currentIndex )
327void QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged()
333 if ( mColorRampShaderWidget->shader().colorRampItemList().isEmpty() )
334 loadColorRampShader();
339void QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged()
341 mColorRampShaderWidget->setMinimumMaximumAndClassify(
342 filterValue( mColorRampShaderMinimumSpinBox, 0 ),
343 filterValue( mColorRampShaderMaximumSpinBox, 0 )
347void QgsMeshRendererVectorSettingsWidget::loadColorRampShader()
352 int currentVectorDataSetGroupIndex = mMeshLayer->rendererSettings().activeVectorDatasetGroup();
353 if ( currentVectorDataSetGroupIndex < 0 || !mMeshLayer->datasetGroupMetadata( currentVectorDataSetGroupIndex ).isVector() )
356 const QgsMeshDatasetGroupMetadata meta = mMeshLayer->datasetGroupMetadata( currentVectorDataSetGroupIndex );
360 mColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
361 whileBlocking( mColorRampShaderMinimumSpinBox )->setValue( min );
362 whileBlocking( mColorRampShaderMaximumSpinBox )->setValue( max );
365double QgsMeshRendererVectorSettingsWidget::filterValue(
const QgsDoubleSpinBox *spinBox,
double errVal )
const
367 if ( spinBox->value() == spinBox->
clearValue() )
370 return spinBox->value();
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
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().
ColoringMethod
Defines how the color is defined.
@ ColorRamp
Render with a color ramp.
@ SingleColor
Render with a single color.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Represents all mesh renderer settings.
QgsMeshRendererVectorSettings vectorSettings(int groupIndex) const
Returns renderer settings.
Represents a mesh renderer settings for vector datasets displayed with arrows.
void setFixedShaftLength(double fixedShaftLength)
Sets fixed length (in millimeters).
void setMaxShaftLength(double maxShaftLength)
Sets maximum shaft length (in millimeters).
QgsMeshRendererVectorArrowSettings::ArrowScalingMethod shaftLengthMethod() const
Returns method used for drawing arrows.
void setMinShaftLength(double minShaftLength)
Sets mininimum shaft length (in millimeters).
double fixedShaftLength() const
Returns fixed arrow length (in millimeters).
void setArrowHeadWidthRatio(double arrowHeadWidthRatio)
Sets ratio of the head width of the arrow (range 0-1).
double scaleFactor() const
Returns scale factor.
double maxShaftLength() const
Returns maximum shaft length (in millimeters).
double arrowHeadWidthRatio() const
Returns ratio of the head width of the arrow (range 0-1).
void setArrowHeadLengthRatio(double arrowHeadLengthRatio)
Sets ratio of the head length of the arrow (range 0-1).
void setScaleFactor(double scaleFactor)
Sets scale factor.
void setShaftLengthMethod(ArrowScalingMethod shaftLengthMethod)
Sets method used for drawing arrows.
ArrowScalingMethod
Algorithm how to transform vector magnitude to length of arrow on the device in pixels.
double minShaftLength() const
Returns mininimum shaft length (in millimeters).
double arrowHeadLengthRatio() const
Returns ratio of the head length of the arrow (range 0-1).
Represents a renderer settings for vector datasets.
Symbology
Defines the symbology of vector rendering.
@ Traces
Displaying vector dataset with particle traces.
@ Arrows
Displaying vector dataset with arrows.
@ WindBarbs
Displaying vector dataset with wind barbs.
@ Streamlines
Displaying vector dataset with streamlines.
Represents a streamline renderer settings for vector datasets displayed by streamlines.
void setSeedingDensity(double seedingDensity)
Sets the density used for seeding start points.
SeedingStartPointsMethod seedingMethod() const
Returns the method used for seeding start points of strealines.
void setSeedingMethod(const SeedingStartPointsMethod &seedingMethod)
Sets the method used for seeding start points of strealines.
SeedingStartPointsMethod
Method used to define start points that are used to draw streamlines.
@ Random
Seeds start points randomly on the mesh.
@ MeshGridded
Seeds start points on the vertices mesh or user regular grid.
double seedingDensity() const
Returns the density used for seeding start points.
Represents a trace renderer settings for vector datasets displayed by particle traces.
Qgis::RenderUnit maximumTailLengthUnit() const
Returns the maximum tail length unit.
void setMaximumTailLength(double maximumTailLength)
Sets the maximums tail length.
void setMaximumTailLengthUnit(Qgis::RenderUnit maximumTailLengthUnit)
Sets the maximum tail length unit.
double maximumTailLength() const
Returns the maximum tail length.
int particlesCount() const
Returns particles count.
void setParticlesCount(int value)
Sets particles count.
Represents a mesh renderer settings for vector datasets displayed with wind barbs.
void setShaftLengthUnits(Qgis::RenderUnit shaftLengthUnit)
Sets the units for the shaft length.
WindSpeedUnit magnitudeUnits() const
Returns the units that the data are in.
void setMagnitudeUnits(WindSpeedUnit units)
Sets the units that the data are in.
void setMagnitudeMultiplier(double magnitudeMultiplier)
Sets a multiplier for the magnitude to convert it to knots.
double shaftLength() const
Returns the shaft length (in millimeters).
void setShaftLength(double shaftLength)
Sets the shaft length (in millimeters).
WindSpeedUnit
Wind speed units. Wind barbs use knots so we use this enum for preset conversion values.
double magnitudeMultiplier() const
Returns the multiplier for the magnitude to convert it to knots, according to the units set with setM...
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.