26 QVector<QgsDoubleSpinBox *> widgets;
27 widgets << mMinMagSpinBox << mMaxMagSpinBox
28 << mHeadWidthSpinBox << mHeadLengthSpinBox
29 << mMinimumShaftSpinBox << mMaximumShaftSpinBox
30 << mScaleShaftByFactorOfSpinBox << mShaftLengthSpinBox
31 << mWindBarbLengthSpinBox << mWindBarbMagnitudeMultiplierSpinBox;
34 for (
const auto &widget : std::as_const( widgets ) )
37 widget->setSpecialValueText( QString( ) );
38 widget->setValue( widget->minimum() );
41 mShaftLengthComboBox->setCurrentIndex( -1 );
46 mXSpacingSpinBox->setClearValue( 10.0 );
47 mYSpacingSpinBox->setClearValue( 10.0 );
48 mStreamlinesDensitySpinBox->setClearValue( 15.0 );
49 mTracesParticlesCountSpinBox->setClearValue( 1000 );
50 mTracesMaxLengthSpinBox->setClearValue( 100.0 );
52 mWindBarbLengthSpinBox->setClearValue( 10.0 );
53 mWindBarbMagnitudeMultiplierSpinBox->setValue( 1.0 );
54 mWindBarbMagnitudeMultiplierSpinBox->setClearValue( 1.0 );
57 connect( mColoringMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
58 this, &QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged );
61 connect( mColorRampShaderMinimumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
62 this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
63 connect( mColorRampShaderMaximumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
64 this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
66 connect( mLineWidthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
69 connect( mShaftLengthComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
72 connect( mShaftLengthComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
73 mShaftOptionsStackedWidget, &QStackedWidget::setCurrentIndex );
77 connect( mColorRampShaderLoadButton, &QPushButton::clicked,
this, &QgsMeshRendererVectorSettingsWidget::loadColorRampShader );
79 onColoringMethodChanged();
81 for (
const auto &widget : std::as_const( widgets ) )
89 connect( mSymbologyVectorComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
90 this, &QgsMeshRendererVectorSettingsWidget::onSymbologyChanged );
91 onSymbologyChanged( 0 );
93 connect( mSymbologyVectorComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
96 connect( mStreamlinesSeedingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
97 this, &QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged );
98 onStreamLineSeedingMethodChanged( 0 );
100 connect( mStreamlinesSeedingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
103 connect( mStreamlinesDensitySpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
106 connect( mTracesMaxLengthSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
109 connect( mTracesParticlesCountSpinBox, qOverload<int>( &QgsSpinBox::valueChanged ),
112 mTracesTailLengthMapUnitWidget->setUnits(
123 mWindBarbLengthMapUnitWidget->setUnits(
132 connect( mWindBarbUnitsComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
133 this, &QgsMeshRendererVectorSettingsWidget::onWindBarbUnitsChanged );
134 onWindBarbUnitsChanged( 0 );
155 ( mColoringMethodComboBox->currentData().toInt() ) );
159 double val = filterValue( mMinMagSpinBox, -1 );
162 val = filterValue( mMaxMagSpinBox, -1 );
173 bool enabled = mDisplayVectorsOnGridGroupBox->isChecked();
182 val = filterValue( mMinimumShaftSpinBox, arrowSettings.
minShaftLength() );
185 val = filterValue( mMaximumShaftSpinBox, arrowSettings.
maxShaftLength() );
188 val = filterValue( mScaleShaftByFactorOfSpinBox, arrowSettings.
scaleFactor() );
201 streamlineSettings.
setSeedingDensity( mStreamlinesDensitySpinBox->value() / 100 );
214 windBarbSettings.
setShaftLength( mWindBarbLengthSpinBox->value() );
229 if ( mActiveDatasetGroup < 0 )
238 symbologyLabel->setVisible( hasFaces );
239 mSymbologyVectorComboBox->setVisible( hasFaces );
240 mSymbologyVectorComboBox->setCurrentIndex( hasFaces ?
settings.
symbology() : 0 );
248 mColoringMethodComboBox->setCurrentIndex( mColoringMethodComboBox->findData(
settings.
coloringMethod() ) );
268 mDisplayVectorsOnGridGroupBox->setVisible( hasFaces );
278 mScaleShaftByFactorOfSpinBox->setValue( arrowSettings.
scaleFactor() );
284 mStreamlinesSeedingMethodComboBox->setCurrentIndex( streamlinesSettings.
seedingMethod() );
285 mStreamlinesDensitySpinBox->setValue( streamlinesSettings.
seedingDensity() * 100 );
292 mTracesParticlesCountSpinBox->setValue( tracesSettings.
particlesCount() );
296 mWindBarbLengthSpinBox->setValue( windBarbSettings.
shaftLength() );
297 mWindBarbUnitsComboBox->setCurrentIndex(
static_cast<int>( windBarbSettings.
magnitudeUnits() ) );
302void QgsMeshRendererVectorSettingsWidget::onSymbologyChanged(
int currentIndex )
317 mDisplayVectorsOnGridGroupBox->setEnabled(
324void QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged(
int currentIndex )
327 mStreamlinesDensityLabel->setEnabled( enabled );
328 mStreamlinesDensitySpinBox->setEnabled( enabled );
330 mDisplayVectorsOnGridGroupBox->setEnabled( !enabled );
333void QgsMeshRendererVectorSettingsWidget::onWindBarbUnitsChanged(
int currentIndex )
344void QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged()
350 if ( mColorRampShaderWidget->shader().colorRampItemList().isEmpty() )
351 loadColorRampShader();
356void QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged()
358 mColorRampShaderWidget->setMinimumMaximumAndClassify(
359 filterValue( mColorRampShaderMinimumSpinBox, 0 ),
360 filterValue( mColorRampShaderMaximumSpinBox, 0 ) );
363void QgsMeshRendererVectorSettingsWidget::loadColorRampShader()
369 if ( currentVectorDataSetGroupIndex < 0 ||
377 mColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
378 whileBlocking( mColorRampShaderMinimumSpinBox )->setValue( min );
379 whileBlocking( mColorRampShaderMaximumSpinBox )->setValue( max );
382double QgsMeshRendererVectorSettingsWidget::filterValue(
const QgsDoubleSpinBox *spinBox,
double errVal )
const
384 if ( spinBox->value() == spinBox->
clearValue() )
387 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.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
Represents all mesh renderer settings.
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
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.
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Returns the color ramp shader used to render vector datasets.
void setStreamLinesSettings(const QgsMeshRendererVectorStreamlineSettings &streamLinesSettings)
Sets settings for vector rendered with streamlines.
int userGridCellWidth() const
Returns width in pixels of user grid cell.
void setArrowsSettings(const QgsMeshRendererVectorArrowSettings &arrowSettings)
Sets settings for vector rendered with arrows.
void setUserGridCellWidth(int width)
Sets width of user grid cell (in pixels)
void setColor(const QColor &color)
Sets color used for drawing arrows.
QgsMeshRendererVectorTracesSettings tracesSettings() const
Returns settings for vector rendered with traces.
QColor color() const
Returns color used for drawing arrows.
int userGridCellHeight() const
Returns height in pixels of user grid cell.
void setOnUserDefinedGrid(bool enabled)
Toggles drawing of vectors on user defined grid.
double lineWidth() const
Returns line width of the arrow (in millimeters)
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.
void setUserGridCellHeight(int height)
Sets height of user grid cell (in pixels)
Symbology symbology() const
Returns the displaying method used to render vector datasets.
double filterMax() const
Returns filter value for vector magnitudes.
QgsColorRampShader colorRampShader() const
Sets the color ramp shader used to render vector datasets.
void setSymbology(const Symbology &symbology)
Sets the displaying method used to render vector datasets.
void setFilterMin(double filterMin)
Sets filter value for vector magnitudes.
QgsMeshRendererVectorArrowSettings arrowSettings() const
Returns settings for vector rendered with arrows.
void setFilterMax(double filterMax)
Sets filter value for vector magnitudes.
void setTracesSettings(const QgsMeshRendererVectorTracesSettings &tracesSettings)
Sets settings for vector rendered with traces.
void setColoringMethod(const QgsInterpolatedLineColor::ColoringMethod &coloringMethod)
Sets the coloring method used to render vector datasets.
QgsInterpolatedLineColor::ColoringMethod coloringMethod() const
Returns the coloring method used to render vector datasets.
QgsMeshRendererVectorWindBarbSettings windBarbSettings() const
Returns settings for vector rendered with wind barbs.
void setLineWidth(double lineWidth)
Sets line width of the arrow in pixels (in millimeters)
bool isOnUserDefinedGrid() const
Returns whether vectors are drawn on user-defined grid.
double filterMin() const
Returns filter value for vector magnitudes.
void setWindBarbSettings(const QgsMeshRendererVectorWindBarbSettings &windBarbSettings)
Sets settings for vector rendered with wind barbs.
QgsMeshRendererVectorStreamlineSettings streamLinesSettings() const
Returns settings for vector rendered 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...
double maximumValue() const
Returns the minimum value for the raster shader.
double minimumValue() const
Returns the maximum value for the raster shader.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.