17#include "moc_qgsinterpolatedlinesymbollayerwidget.cpp"
28 mWidthMethodComboBox->addItem( tr(
"Fixed Width" ),
false );
29 mWidthMethodComboBox->addItem( tr(
"Varying Width" ),
true );
38 mWidthStartFieldExpression->setLayer( layer );
39 mWidthEndFieldExpression->setLayer( layer );
40 mColorStartFieldExpression->setLayer( layer );
41 mColorEndFieldExpression->setLayer( layer );
43 mWidthUnitSelectionFixed->setUnits(
53 mWidthUnitSelectionVarying->setUnits(
63 connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
64 this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
65 connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
66 this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
69 connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
70 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
71 connect( mDoubleSpinBoxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
72 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
74 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer );
76 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer );
77 connect( mButtonLoadMinMaxValueWidth, &QPushButton::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth );
78 connect( mLineEditWidthMinValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
79 connect( mLineEditWidthMaxValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
80 connect( mDoubleSpinBoxMinWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
81 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
82 connect( mDoubleSpinBoxMaxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ),
83 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
89 whileBlocking( mWidthUnitSelectionFixed )->setUnit( mWidthUnitSelectionVarying->unit() );
94 whileBlocking( mWidthUnitSelectionVarying )->setUnit( mWidthUnitSelectionFixed->unit() );
97 connect( mCheckBoxAbsoluteValue, &QCheckBox::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
98 connect( mCheckBoxOutOfrange, &QCheckBox::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
101 connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ),
102 this, &QgsInterpolatedLineSymbolLayerWidget::apply );
107 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer );
109 ,
this, &QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer );
111 connect( mLineEditColorMinValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
112 connect( mLineEditColorMinValue, &QLineEdit::textEdited,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
113 connect( mLineEditColorMaxValue, &QLineEdit::textChanged,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
114 connect( mLineEditColorMaxValue, &QLineEdit::textEdited,
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
115 connect( mButtonLoadMinMaxValueColor, &QPushButton::clicked,
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor );
122 if ( !layer || layer->
layerType() != QLatin1String(
"InterpolatedLine" ) )
133 setLineEditValue( mLineEditWidthMinValue, interpolatedWidth.
minimumValue() );
134 setLineEditValue( mLineEditWidthMaxValue, interpolatedWidth.
maximumValue() );
153 updateVisibleWidget();
164void QgsInterpolatedLineSymbolLayerWidget::apply()
169 bool isExpression =
false;
170 QString fieldOrExpression = mWidthStartFieldExpression->currentField( &isExpression );
172 fieldOrExpression = mWidthEndFieldExpression->currentField( &isExpression );
176 if ( mWidthMethodComboBox->currentData().toBool() )
177 mLayer->
setWidthUnit( mWidthUnitSelectionVarying->unit() );
179 mLayer->
setWidthUnit( mWidthUnitSelectionFixed->unit() );
181 fieldOrExpression = mColorStartFieldExpression->currentField( &isExpression );
183 fieldOrExpression = mColorEndFieldExpression->currentField( &isExpression );
191void QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget()
193 mFixedWidthWidget->setVisible( !mWidthMethodComboBox->currentData().toBool() );
194 mVaryingWidthWidget->setVisible( mWidthMethodComboBox->currentData().toBool() );
196 mFixedColorWidget->setVisible(
198 mVaryingColorWidget->setVisible(
202void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth()
204 reloadMinMaxWidthFromLayer();
205 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
206 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
210void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor()
212 reloadMinMaxColorFromLayer();
213 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
214 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
215 onColorMinMaxLineTextEdited();
218void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer()
222 QgsExpression expressionStart( mWidthStartFieldExpression->expression() );
223 if ( !expressionStart.prepare( &expressionContext ) )
229 QgsExpression expressionEnd( mWidthEndFieldExpression->expression() );
230 if ( !expressionEnd.prepare( &expressionContext ) )
244 mMinimumForWidthFromLayer = std::numeric_limits<double>::max();
245 mMaximumForWidthFromLayer = -std::numeric_limits<double>::max();
249 double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
250 double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
252 if ( mCheckBoxAbsoluteValue->isChecked() )
254 startValue = fabs( startValue );
255 endValue = fabs( endValue );
258 if ( startValue < mMinimumForWidthFromLayer )
259 mMinimumForWidthFromLayer = startValue;
260 if ( startValue > mMaximumForWidthFromLayer )
261 mMaximumForWidthFromLayer = startValue;
263 if ( endValue < mMinimumForWidthFromLayer )
264 mMinimumForWidthFromLayer = endValue;
265 if ( endValue > mMaximumForWidthFromLayer )
266 mMaximumForWidthFromLayer = endValue;
269 if ( mLineEditWidthMinValue->text().isEmpty() && !std::isnan( mMinimumForWidthFromLayer ) )
271 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
274 if ( mLineEditWidthMaxValue->text().isEmpty() && !std::isnan( mMaximumForWidthFromLayer ) )
276 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
282void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer()
286 QgsExpression expressionStart( mColorStartFieldExpression->expression() );
287 if ( !expressionStart.prepare( &expressionContext ) )
293 QgsExpression expressionEnd( mColorEndFieldExpression->expression() );
294 if ( !expressionEnd.prepare( &expressionContext ) )
308 mMinimumForColorFromLayer = std::numeric_limits<double>::max();
309 mMaximumForColorFromLayer = -std::numeric_limits<double>::max();
313 const double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
314 const double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
316 if ( startValue < mMinimumForColorFromLayer )
317 mMinimumForColorFromLayer = startValue;
318 if ( startValue > mMaximumForColorFromLayer )
319 mMaximumForColorFromLayer = startValue;
321 if ( endValue < mMinimumForColorFromLayer )
322 mMinimumForColorFromLayer = endValue;
323 if ( endValue > mMaximumForColorFromLayer )
324 mMaximumForColorFromLayer = endValue;
327 bool minMaxColorChanged =
false;
328 if ( mLineEditColorMinValue->text().isEmpty() && !std::isnan( mMinimumForColorFromLayer ) )
330 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
331 minMaxColorChanged =
true;
334 if ( mLineEditColorMaxValue->text().isEmpty() && !std::isnan( mMaximumForColorFromLayer ) )
336 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
337 minMaxColorChanged =
true;
340 if ( minMaxColorChanged )
341 onColorMinMaxLineTextEdited();
346void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged()
348 const double min = lineEditValue( mLineEditColorMinValue );
349 const double max = lineEditValue( mLineEditColorMaxValue );
350 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( min, max );
354void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited()
356 const double min = lineEditValue( mLineEditColorMinValue );
357 const double max = lineEditValue( mLineEditColorMaxValue );
358 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( min, max );
380 interColor.
setColor( mColorButton->color() );
382 interColor.
setColor( colorRampShader );
388double QgsInterpolatedLineSymbolLayerWidget::lineEditValue( QLineEdit *lineEdit )
390 if ( lineEdit->text().isEmpty() )
392 return std::numeric_limits<double>::quiet_NaN();
398void QgsInterpolatedLineSymbolLayerWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
401 if ( !std::isnan( value ) )
402 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)
Fetch next feature and stores in f, returns true on success.
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 final
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.
@ LineEndColorValue
End line color for interpolated line renderer.
@ LineStartColorValue
Start line color for interpolated line renderer.
@ LineEndWidthValue
End line width for interpolated line renderer.
@ LineStartWidthValue
Start line width for interpolated line renderer.
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.