21#include "moc_qgsmeshrenderervectorsettingswidget.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, &QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged );
67 connect( mColorRampShaderMinimumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
68 connect( mColorRampShaderMaximumSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged );
74 connect( mShaftLengthComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), mShaftOptionsStackedWidget, &QStackedWidget::setCurrentIndex );
78 connect( mColorRampShaderLoadButton, &QPushButton::clicked,
this, &QgsMeshRendererVectorSettingsWidget::loadColorRampShader );
80 onColoringMethodChanged();
82 for (
const auto &widget : std::as_const( widgets ) )
90 connect( mSymbologyVectorComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onSymbologyChanged );
91 onSymbologyChanged( 0 );
95 connect( mStreamlinesSeedingMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged );
96 onStreamLineSeedingMethodChanged( 0 );
113 connect( mWindBarbUnitsComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
this, &QgsMeshRendererVectorSettingsWidget::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 ?
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() );
253 mScaleShaftByFactorOfSpinBox->setValue( arrowSettings.
scaleFactor() );
259 mStreamlinesSeedingMethodComboBox->setCurrentIndex( 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 QgsMeshRendererVectorSettingsWidget::onSymbologyChanged(
int currentIndex )
292 mDisplayVectorsOnGridGroupBox->setEnabled(
299void QgsMeshRendererVectorSettingsWidget::onStreamLineSeedingMethodChanged(
int currentIndex )
302 mStreamlinesDensityLabel->setEnabled( enabled );
303 mStreamlinesDensitySpinBox->setEnabled( enabled );
305 mDisplayVectorsOnGridGroupBox->setEnabled( !enabled );
308void QgsMeshRendererVectorSettingsWidget::onWindBarbUnitsChanged(
int currentIndex )
318void QgsMeshRendererVectorSettingsWidget::onColoringMethodChanged()
324 if ( mColorRampShaderWidget->shader().colorRampItemList().isEmpty() )
325 loadColorRampShader();
330void QgsMeshRendererVectorSettingsWidget::onColorRampMinMaxChanged()
332 mColorRampShaderWidget->setMinimumMaximumAndClassify( filterValue( mColorRampShaderMinimumSpinBox, 0 ), filterValue( mColorRampShaderMaximumSpinBox, 0 ) );
335void QgsMeshRendererVectorSettingsWidget::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 QgsMeshRendererVectorSettingsWidget::filterValue(
const QgsDoubleSpinBox *spinBox,
double errVal )
const
355 if ( spinBox->value() == spinBox->
clearValue() )
358 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.