21#include "moc_qgsvectorfieldsettingswidget.cpp"
28 QVector<QgsDoubleSpinBox *> widgets;
34 << mMinimumShaftSpinBox
35 << mMaximumShaftSpinBox
36 << mScaleShaftByFactorOfSpinBox
37 << mShaftLengthSpinBox
38 << mWindBarbLengthSpinBox
39 << mWindBarbMagnitudeMultiplierSpinBox;
42 for (
const auto &widget : std::as_const( widgets ) )
45 widget->setSpecialValueText( QString() );
46 widget->setValue( widget->minimum() );
49 mShaftLengthComboBox->setCurrentIndex( -1 );
54 mXSpacingSpinBox->setClearValue( 10.0 );
55 mYSpacingSpinBox->setClearValue( 10.0 );
56 mStreamlinesDensitySpinBox->setClearValue( 15.0 );
57 mTracesParticlesCountSpinBox->setClearValue( 1000 );
58 mTracesMaxLengthSpinBox->setClearValue( 100.0 );
60 mWindBarbLengthSpinBox->setClearValue( 10.0 );
61 mWindBarbMagnitudeMultiplierSpinBox->setValue( 1.0 );
62 mWindBarbMagnitudeMultiplierSpinBox->setClearValue( 1.0 );
65 connect( mColoringMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsVectorFieldSettingsWidget::onColoringMethodChanged );
67 connect( mColorRampShaderMinimumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsVectorFieldSettingsWidget::onColorRampMinMaxChanged );
68 connect( mColorRampShaderMaximumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsVectorFieldSettingsWidget::onColorRampMinMaxChanged );
74 connect( mShaftLengthComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), mShaftOptionsStackedWidget, &QStackedWidget::setCurrentIndex );
78 connect( mColorRampShaderLoadButton, &QPushButton::clicked,
this, &QgsVectorFieldSettingsWidget::loadColorRampShader );
80 onColoringMethodChanged();
82 for (
const auto &widget : std::as_const( widgets ) )
90 connect( mSymbologyVectorComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsVectorFieldSettingsWidget::onSymbologyChanged );
91 onSymbologyChanged( 0 );
95 connect( mStreamlinesSeedingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsVectorFieldSettingsWidget::onStreamLineSeedingMethodChanged );
96 onStreamLineSeedingMethodChanged( 0 );
113 connect( mWindBarbUnitsComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsVectorFieldSettingsWidget::onWindBarbUnitsChanged );
114 onWindBarbUnitsChanged( 0 );
131 settings.setColor( mColorWidget->color() );
132 settings.setLineWidth( mLineWidthSpinBox->value() );
134 settings.setColorRampShader( mColorRampShaderWidget->shader() );
137 double val = filterValue( mMinMagSpinBox, -1 );
140 val = filterValue( mMaxMagSpinBox, -1 );
151 bool enabled = mDisplayVectorsOnGridGroupBox->isChecked();
152 settings.setOnUserDefinedGrid( enabled );
153 settings.setUserGridCellWidth( mXSpacingSpinBox->value() );
154 settings.setUserGridCellHeight( mYSpacingSpinBox->value() );
160 val = filterValue( mMinimumShaftSpinBox, arrowSettings.
minShaftLength() );
163 val = filterValue( mMaximumShaftSpinBox, arrowSettings.
maxShaftLength() );
166 val = filterValue( mScaleShaftByFactorOfSpinBox, arrowSettings.
scaleFactor() );
172 settings.setArrowsSettings( arrowSettings );
178 streamlineSettings.
setSeedingDensity( mStreamlinesDensitySpinBox->value() / 100 );
180 settings.setStreamLinesSettings( streamlineSettings );
187 settings.setTracesSettings( tracesSettings );
191 windBarbSettings.
setShaftLength( mWindBarbLengthSpinBox->value() );
195 settings.setWindBarbSettings( windBarbSettings );
202 if ( !mMeshLayer || !mMeshLayer->dataProvider() )
205 if ( mActiveDatasetGroup < 0 )
213 symbologyLabel->setVisible( hasFaces );
214 mSymbologyVectorComboBox->setVisible( hasFaces );
215 mSymbologyVectorComboBox->setCurrentIndex( hasFaces ?
static_cast< int >(
settings.symbology() ) : 0 );
221 mColorWidget->setColor(
settings.color() );
222 mLineWidthSpinBox->setValue(
settings.lineWidth() );
223 mColoringMethodComboBox->setCurrentIndex( mColoringMethodComboBox->findData(
settings.coloringMethod() ) );
224 mColorRampShaderWidget->setFromShader(
settings.colorRampShader() );
225 mColorRampShaderMinimumSpinBox->setValue(
settings.colorRampShader().minimumValue() );
226 mColorRampShaderMaximumSpinBox->setValue(
settings.colorRampShader().maximumValue() );
231 mMinMagSpinBox->setValue(
settings.filterMin() );
235 mMaxMagSpinBox->setValue(
settings.filterMax() );
243 mDisplayVectorsOnGridGroupBox->setVisible( hasFaces );
244 mDisplayVectorsOnGridGroupBox->setChecked(
settings.isOnUserDefinedGrid() && hasFaces );
245 mXSpacingSpinBox->setValue(
settings.userGridCellWidth() );
246 mYSpacingSpinBox->setValue(
settings.userGridCellHeight() );
249 mShaftLengthComboBox->setCurrentIndex(
static_cast< int >( arrowSettings.
shaftLengthMethod() ) );
253 mScaleShaftByFactorOfSpinBox->setValue( arrowSettings.
scaleFactor() );
259 mStreamlinesSeedingMethodComboBox->setCurrentIndex(
static_cast< int >( streamlinesSettings.
seedingMethod() ) );
260 mStreamlinesDensitySpinBox->setValue( streamlinesSettings.
seedingDensity() * 100 );
267 mTracesParticlesCountSpinBox->setValue( tracesSettings.
particlesCount() );
271 mWindBarbLengthSpinBox->setValue( windBarbSettings.
shaftLength() );
272 mWindBarbUnitsComboBox->setCurrentIndex(
static_cast<int>( windBarbSettings.
magnitudeUnits() ) );
277void QgsVectorFieldSettingsWidget::onSymbologyChanged(
int currentIndex )
292 mDisplayVectorsOnGridGroupBox->setEnabled(
299void QgsVectorFieldSettingsWidget::onStreamLineSeedingMethodChanged(
int currentIndex )
302 mStreamlinesDensityLabel->setEnabled( enabled );
303 mStreamlinesDensitySpinBox->setEnabled( enabled );
305 mDisplayVectorsOnGridGroupBox->setEnabled( !enabled );
308void QgsVectorFieldSettingsWidget::onWindBarbUnitsChanged(
int currentIndex )
318void QgsVectorFieldSettingsWidget::onColoringMethodChanged()
324 if ( mColorRampShaderWidget->shader().colorRampItemList().isEmpty() )
325 loadColorRampShader();
330void QgsVectorFieldSettingsWidget::onColorRampMinMaxChanged()
332 mColorRampShaderWidget->setMinimumMaximumAndClassify( filterValue( mColorRampShaderMinimumSpinBox, 0 ), filterValue( mColorRampShaderMaximumSpinBox, 0 ) );
335void QgsVectorFieldSettingsWidget::loadColorRampShader()
340 int currentVectorDataSetGroupIndex = mMeshLayer->rendererSettings().activeVectorDatasetGroup();
341 if ( currentVectorDataSetGroupIndex < 0 || !mMeshLayer->datasetGroupMetadata( currentVectorDataSetGroupIndex ).isVector() )
344 const QgsMeshDatasetGroupMetadata meta = mMeshLayer->datasetGroupMetadata( currentVectorDataSetGroupIndex );
348 mColorRampShaderWidget->setMinimumMaximumAndClassify( min, max );
349 whileBlocking( mColorRampShaderMinimumSpinBox )->setValue( min );
350 whileBlocking( mColorRampShaderMaximumSpinBox )->setValue( max );
353double QgsVectorFieldSettingsWidget::filterValue(
const QgsDoubleSpinBox *spinBox,
double errVal )
const
355 if ( spinBox->value() == spinBox->
clearValue() )
358 return spinBox->value();
VectorFieldSeedingMethod
Method used to define start points that are used to draw streamlines.
@ Gridded
Seeds start points on data grid or user regular grid.
@ Random
Seeds start points randomly.
VectorFieldSymbology
Defines the symbology of vector field rendering.
@ WindBarbs
Displaying vector dataset with wind barbs.
@ Arrows
Displaying vector dataset with arrows.
@ Traces
Displaying vector dataset with particle traces.
@ Streamlines
Displaying vector dataset with streamlines.
WindSpeedUnit
Wind speed units.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ MetersInMapUnits
Meters value as Map units.
VectorFieldArrowScalingMethod
Algorithm to transform vector magnitude to length of arrow on the device in pixels.
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.
QgsVectorFieldSettings 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).
double minShaftLength() const
Returns mininimum shaft length (in millimeters).
Qgis::VectorFieldArrowScalingMethod shaftLengthMethod() const
Returns method used for drawing arrows.
void setMinShaftLength(double minShaftLength)
Sets mininimum shaft length (in millimeters).
double arrowHeadLengthRatio() const
Returns ratio of the head length of the arrow (range 0-1).
void setShaftLengthMethod(Qgis::VectorFieldArrowScalingMethod shaftLengthMethod)
Sets method used for drawing arrows.
void setScaleFactor(double scaleFactor)
Sets scale factor.
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).
void setMaxShaftLength(double maxShaftLength)
Sets maximum shaft length (in millimeters).
double arrowHeadWidthRatio() const
Returns ratio of the head width of the arrow (range 0-1).
double maxShaftLength() const
Returns maximum shaft length (in millimeters).
double scaleFactor() const
Returns scale factor.
void setArrowHeadLengthRatio(double arrowHeadLengthRatio)
Sets ratio of the head length of the arrow (range 0-1).
Represents a renderer settings for vector datasets.
Represents a streamline renderer settings for vector datasets displayed by streamlines.
void setSeedingMethod(const Qgis::VectorFieldSeedingMethod &seedingMethod)
Sets the method used for seeding start points of strealines.
Qgis::VectorFieldSeedingMethod seedingMethod() const
Returns the method used for seeding start points of strealines.
double seedingDensity() const
Returns the density used for seeding start points.
void setSeedingDensity(double seedingDensity)
Sets 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.
int particlesCount() const
Returns particles count.
void setMaximumTailLengthUnit(Qgis::RenderUnit maximumTailLengthUnit)
Sets the maximum tail length unit.
double maximumTailLength() const
Returns the maximum tail length.
void setParticlesCount(int value)
Sets particles count.
void setMaximumTailLength(double maximumTailLength)
Sets the maximums tail length.
Represents a mesh renderer settings for vector datasets displayed with wind barbs.
Qgis::WindSpeedUnit magnitudeUnits() const
Returns the units that the data are in.
double shaftLength() const
Returns the shaft length (in millimeters).
void setMagnitudeMultiplier(double magnitudeMultiplier)
Sets a multiplier for the magnitude to convert it to knots.
void setMagnitudeUnits(Qgis::WindSpeedUnit units)
Sets the units that the data are in.
double magnitudeMultiplier() const
Returns the multiplier for the magnitude to convert it to knots, according to the units set with setM...
void setShaftLength(double shaftLength)
Sets the shaft length (in millimeters).
void setShaftLengthUnits(Qgis::RenderUnit shaftLengthUnit)
Sets the units for the shaft length.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.