27 mWidthMethodComboBox->addItem( tr(
"Fixed Width" ),
false );
28 mWidthMethodComboBox->addItem( tr(
"Varying Width" ),
true );
37 mWidthStartFieldExpression->setLayer( layer );
38 mWidthEndFieldExpression->setLayer( layer );
39 mColorStartFieldExpression->setLayer( layer );
40 mColorEndFieldExpression->setLayer( layer );
42 mWidthUnitSelectionFixed->setUnits(
52 mWidthUnitSelectionVarying->setUnits(
62 connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
63 this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
64 connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
65 this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
68 connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
69 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
70 connect( mDoubleSpinBoxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
71 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
73 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer );
75 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer );
76 connect( mButtonLoadMinMaxValueWidth, &QPushButton::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth );
77 connect( mLineEditWidthMinValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
78 connect( mLineEditWidthMaxValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
79 connect( mDoubleSpinBoxMinWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
80 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
81 connect( mDoubleSpinBoxMaxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
82 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
88 whileBlocking( mWidthUnitSelectionFixed )->setUnit( mWidthUnitSelectionVarying->unit() );
93 whileBlocking( mWidthUnitSelectionVarying )->setUnit( mWidthUnitSelectionFixed->unit() );
96 connect( mCheckBoxAbsoluteValue, &QCheckBox::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
97 connect( mCheckBoxOutOfrange, &QCheckBox::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
100 connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
101 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
106 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer );
108 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer );
110 connect( mLineEditColorMinValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
111 connect( mLineEditColorMinValue, &QLineEdit::textEdited,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
112 connect( mLineEditColorMaxValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
113 connect( mLineEditColorMaxValue, &QLineEdit::textEdited,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
114 connect( mButtonLoadMinMaxValueColor, &QPushButton::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor );
121 if ( !layer || layer->
layerType() != QLatin1String(
"InterpolatedLine" ) )
132 setLineEditValue( mLineEditWidthMinValue, interpolatedWidth.
minimumValue() );
133 setLineEditValue( mLineEditWidthMaxValue, interpolatedWidth.
maximumValue() );
152 updateVisibleWidget();
163void QgsInterpolatedLineSymbolLayerWidget::apply()
168 bool isExpression =
false;
169 QString fieldOrExpression = mWidthStartFieldExpression->currentField( &isExpression );
171 fieldOrExpression = mWidthEndFieldExpression->currentField( &isExpression );
175 if ( mWidthMethodComboBox->currentData().toBool() )
176 mLayer->
setWidthUnit( mWidthUnitSelectionVarying->unit() );
178 mLayer->
setWidthUnit( mWidthUnitSelectionFixed->unit() );
180 fieldOrExpression = mColorStartFieldExpression->currentField( &isExpression );
182 fieldOrExpression = mColorEndFieldExpression->currentField( &isExpression );
190void QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget()
192 mFixedWidthWidget->setVisible( !mWidthMethodComboBox->currentData().toBool() );
193 mVaryingWidthWidget->setVisible( mWidthMethodComboBox->currentData().toBool() );
195 mFixedColorWidget->setVisible(
197 mVaryingColorWidget->setVisible(
201void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth()
203 reloadMinMaxWidthFromLayer();
204 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
205 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
209void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor()
211 reloadMinMaxColorFromLayer();
212 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
213 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
214 onColorMinMaxLineTextEdited();
217void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer()
221 QgsExpression expressionStart( mWidthStartFieldExpression->expression() );
222 if ( !expressionStart.prepare( &expressionContext ) )
228 QgsExpression expressionEnd( mWidthEndFieldExpression->expression() );
229 if ( !expressionEnd.prepare( &expressionContext ) )
243 mMinimumForWidthFromLayer = std::numeric_limits<double>::max();
244 mMaximumForWidthFromLayer = -std::numeric_limits<double>::max();
248 double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
249 double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
251 if ( mCheckBoxAbsoluteValue->isChecked() )
253 startValue = fabs( startValue );
254 endValue = fabs( endValue );
257 if ( startValue < mMinimumForWidthFromLayer )
258 mMinimumForWidthFromLayer = startValue;
259 if ( startValue > mMaximumForWidthFromLayer )
260 mMaximumForWidthFromLayer = startValue;
262 if ( endValue < mMinimumForWidthFromLayer )
263 mMinimumForWidthFromLayer = endValue;
264 if ( endValue > mMaximumForWidthFromLayer )
265 mMaximumForWidthFromLayer = endValue;
268 if ( mLineEditWidthMinValue->text().isEmpty() && !std::isnan( mMinimumForWidthFromLayer ) )
270 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
273 if ( mLineEditWidthMaxValue->text().isEmpty() && !std::isnan( mMaximumForWidthFromLayer ) )
275 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
281void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer()
285 QgsExpression expressionStart( mColorStartFieldExpression->expression() );
286 if ( !expressionStart.prepare( &expressionContext ) )
292 QgsExpression expressionEnd( mColorEndFieldExpression->expression() );
293 if ( !expressionEnd.prepare( &expressionContext ) )
307 mMinimumForColorFromLayer = std::numeric_limits<double>::max();
308 mMaximumForColorFromLayer = -std::numeric_limits<double>::max();
312 const double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
313 const double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
315 if ( startValue < mMinimumForColorFromLayer )
316 mMinimumForColorFromLayer = startValue;
317 if ( startValue > mMaximumForColorFromLayer )
318 mMaximumForColorFromLayer = startValue;
320 if ( endValue < mMinimumForColorFromLayer )
321 mMinimumForColorFromLayer = endValue;
322 if ( endValue > mMaximumForColorFromLayer )
323 mMaximumForColorFromLayer = endValue;
326 bool minMaxColorChanged =
false;
327 if ( mLineEditColorMinValue->text().isEmpty() && !std::isnan( mMinimumForColorFromLayer ) )
329 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
330 minMaxColorChanged =
true;
333 if ( mLineEditColorMaxValue->text().isEmpty() && !std::isnan( mMaximumForColorFromLayer ) )
335 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
336 minMaxColorChanged =
true;
339 if ( minMaxColorChanged )
340 onColorMinMaxLineTextEdited();
345void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged()
347 const double min = lineEditValue( mLineEditColorMinValue );
348 const double max = lineEditValue( mLineEditColorMaxValue );
349 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( min, max );
353void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited()
355 const double min = lineEditValue( mLineEditColorMinValue );
356 const double max = lineEditValue( mLineEditColorMaxValue );
357 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( min, max );
379 interColor.
setColor( mColorButton->color() );
381 interColor.
setColor( colorRampShader );
387double QgsInterpolatedLineSymbolLayerWidget::lineEditValue( QLineEdit *lineEdit )
389 if ( lineEdit->text().isEmpty() )
391 return std::numeric_limits<double>::quiet_NaN();
397void QgsInterpolatedLineSymbolLayerWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
400 if ( !std::isnan( value ) )
401 strValue = QLocale().toString( value );
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
static double toDouble(const QString &input, bool *ok)
Converts input string to double value.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
@ Numeric
All numeric fields.
Class defining color to render mesh datasets.
QgsInterpolatedLineColor::ColoringMethod coloringMethod() const
Returns the coloring method used.
QgsColorRampShader colorRampShader() const
Returns the color ramp shader.
void setColor(const QgsColorRampShader &colorRampShader)
Sets the color ramp to define the coloring.
QColor singleColor() const
Returns the single color that is used if SingleColor coloring mode is set.
void setColoringMethod(ColoringMethod coloringMethod)
Sets the coloring method used.
ColoringMethod
Defines how the color is defined.
@ ColorRamp
Render with a color ramp.
@ SingleColor
Render with a single color.
A symbol layer that represents vector layer line feature as interpolated line The interpolation is do...
Qgis::RenderUnit widthUnit() const
Returns the width unit.
QgsInterpolatedLineColor interpolatedColor() const
Returns the interpolated color used to render the colors of lines, see QgsInterpolatedLineColor.
void setInterpolatedWidth(const QgsInterpolatedLineWidth &interpolatedLineWidth)
Sets the interpolated width used to render the width of lines, see QgsInterpolatedLineWidth.
void setInterpolatedColor(const QgsInterpolatedLineColor &interpolatedLineColor)
Sets the interpolated color used to render the colors of lines, see QgsInterpolatedLineColor.
QgsInterpolatedLineWidth interpolatedWidth() const
Returns the interpolated width used to render the width of lines, see QgsInterpolatedLineWidth.
void setWidthUnit(Qgis::RenderUnit strokeWidthUnit)
Sets the width unit.
Represents a width than can vary depending on values.
void setFixedStrokeWidth(double fixedWidth)
Sets the fixed width.
void setUseAbsoluteValue(bool useAbsoluteValue)
Sets whether absolute value are used as input.
double minimumValue() const
Returns the minimum value used to defined the variable width.
void setIgnoreOutOfRange(bool ignoreOutOfRange)
Sets whether the variable width ignores out of range value.
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
bool useAbsoluteValue() const
Returns whether absolute value are used as input.
void setIsVariableWidth(bool isVariableWidth)
Returns whether the width is variable.
void setMinimumValue(double minimumValue)
Sets the minimum value used to defined the variable width.
double maximumWidth() const
Returns the maximum width used to defined the variable width.
void setMaximumWidth(double maximumWidth)
Sets the maximum width used to defined the variable width.
double maximumValue() const
Returns the maximum value used to defined the variable width.
void setMinimumWidth(double minimumWidth)
Sets the minimum width used to defined the variable width.
bool ignoreOutOfRange() const
Returns whether the variable width ignores out of range value.
double minimumWidth() const
Returns the minimum width used to defined the variable width.
double fixedStrokeWidth() const
Returns the fixed width.
bool isVariableWidth() const
Returns whether the width is variable.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
A store for object properties.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
double maximumValue() const
Returns the minimum value for the raster shader.
double minimumValue() const
Returns the maximum value for the raster shader.
@ PropertyLineEndWidthValue
End line width for interpolated line renderer (since QGIS 3.22)
@ PropertyLineEndColorValue
End line color for interpolated line renderer (since QGIS 3.22)
@ PropertyLineStartColorValue
Start line color for interpolated line renderer (since QGIS 3.22)
@ PropertyLineStartWidthValue
Start line width for interpolated line renderer (since QGIS 3.22)
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Represents a vector layer which manages a vector based data sets.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.