31 mWidthMethodComboBox->addItem( tr(
"Fixed width" ),
false );
32 mWidthMethodComboBox->addItem( tr(
"Varying width" ),
true );
41 mWidthStartFieldExpression->setLayer( layer );
42 mWidthEndFieldExpression->setLayer( layer );
43 mColorStartFieldExpression->setLayer( layer );
44 mColorEndFieldExpression->setLayer( layer );
47 << QgsUnitTypes::RenderUnit::RenderInches
48 << QgsUnitTypes::RenderUnit::RenderMapUnits
49 << QgsUnitTypes::RenderUnit::RenderMetersInMapUnits
50 << QgsUnitTypes::RenderUnit::RenderMillimeters
51 << QgsUnitTypes::RenderUnit::RenderPixels
52 << QgsUnitTypes::RenderUnit::RenderPoints );
55 << QgsUnitTypes::RenderUnit::RenderInches
56 << QgsUnitTypes::RenderUnit::RenderMapUnits
57 << QgsUnitTypes::RenderUnit::RenderMetersInMapUnits
58 << QgsUnitTypes::RenderUnit::RenderMillimeters
59 << QgsUnitTypes::RenderUnit::RenderPixels
60 << QgsUnitTypes::RenderUnit::RenderPoints );
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() );
139 whileBlocking( mCheckBoxOutOfrange )->setChecked( interpolatedLineWidth().ignoreOutOfRange() );
152 updateVisibleWidget();
163 void QgsInterpolatedLineSymbolLayerWidget::apply()
170 if ( mWidthMethodComboBox->currentData().toBool() )
171 mLayer->
setWidthUnit( mWidthUnitSelectionVarying->unit() );
173 mLayer->
setWidthUnit( mWidthUnitSelectionFixed->unit() );
181 void QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget()
183 mFixedWidthWidget->setVisible( !mWidthMethodComboBox->currentData().toBool() );
184 mVaryingWidthWidget->setVisible( mWidthMethodComboBox->currentData().toBool() );
186 mFixedColorWidget->setVisible(
188 mVaryingColorWidget->setVisible(
192 void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth()
194 reloadMinMaxWidthFromLayer();
195 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
196 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
200 void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor()
202 reloadMinMaxColorFromLayer();
203 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
204 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
205 onColorMinMaxLineTextEdited();
208 void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxWidthFromLayer()
212 QgsExpression expressionStart( mWidthStartFieldExpression->expression() );
213 if ( !expressionStart.prepare( &expressionContext ) )
219 QgsExpression expressionEnd( mWidthEndFieldExpression->expression() );
220 if ( !expressionEnd.prepare( &expressionContext ) )
234 mMinimumForWidthFromLayer = std::numeric_limits<double>::max();
235 mMaximumForWidthFromLayer = -std::numeric_limits<double>::max();
239 double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
240 double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
242 if ( mCheckBoxAbsoluteValue->isChecked() )
244 startValue = fabs( startValue );
245 endValue = fabs( endValue );
248 if ( startValue < mMinimumForWidthFromLayer )
249 mMinimumForWidthFromLayer = startValue;
250 if ( startValue > mMaximumForWidthFromLayer )
251 mMaximumForWidthFromLayer = startValue;
253 if ( endValue < mMinimumForWidthFromLayer )
254 mMinimumForWidthFromLayer = endValue;
255 if ( endValue > mMaximumForWidthFromLayer )
256 mMaximumForWidthFromLayer = endValue;
259 if ( mLineEditWidthMinValue->text().isEmpty() && !std::isnan( mMinimumForWidthFromLayer ) )
261 setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
264 if ( mLineEditWidthMaxValue->text().isEmpty() && !std::isnan( mMaximumForWidthFromLayer ) )
266 setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
272 void QgsInterpolatedLineSymbolLayerWidget::reloadMinMaxColorFromLayer()
276 QgsExpression expressionStart( mColorStartFieldExpression->expression() );
277 if ( !expressionStart.prepare( &expressionContext ) )
283 QgsExpression expressionEnd( mColorEndFieldExpression->expression() );
284 if ( !expressionEnd.prepare( &expressionContext ) )
298 mMinimumForColorFromLayer = std::numeric_limits<double>::max();
299 mMaximumForColorFromLayer = -std::numeric_limits<double>::max();
303 double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
304 double endValue = expressionEnd.evaluate( &expressionContext ).toDouble();
306 if ( startValue < mMinimumForColorFromLayer )
307 mMinimumForColorFromLayer = startValue;
308 if ( startValue > mMaximumForColorFromLayer )
309 mMaximumForColorFromLayer = startValue;
311 if ( endValue < mMinimumForColorFromLayer )
312 mMinimumForColorFromLayer = endValue;
313 if ( endValue > mMaximumForColorFromLayer )
314 mMaximumForColorFromLayer = endValue;
317 bool minMaxColorChanged =
false;
318 if ( mLineEditColorMinValue->text().isEmpty() && !std::isnan( mMinimumForColorFromLayer ) )
320 setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
321 minMaxColorChanged =
true;
324 if ( mLineEditColorMaxValue->text().isEmpty() && !std::isnan( mMaximumForColorFromLayer ) )
326 setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
327 minMaxColorChanged =
true;
330 if ( minMaxColorChanged )
331 onColorMinMaxLineTextEdited();
336 void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged()
338 double min = lineEditValue( mLineEditColorMinValue );
339 double max = lineEditValue( mLineEditColorMaxValue );
340 whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( min, max );
344 void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited()
346 double min = lineEditValue( mLineEditColorMinValue );
347 double max = lineEditValue( mLineEditColorMaxValue );
348 whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( min, max );
370 interColor.
setColor( mColorButton->color() );
372 interColor.
setColor( colorRampShader );
378 double QgsInterpolatedLineSymbolLayerWidget::lineEditValue( QLineEdit *lineEdit )
380 if ( lineEdit->text().isEmpty() )
382 return std::numeric_limits<double>::quiet_NaN();
388 void QgsInterpolatedLineSymbolLayerWidget::setLineEditValue( QLineEdit *lineEdit,
double value )
391 if ( !std::isnan( value ) )
392 strValue = QString::number( value );
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 setColoringMethod(const QgsInterpolatedLineColor::ColoringMethod &coloringMethod)
Sets the coloring method used.
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.
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...
QString endValueExpressionForWidth() const
Returns the expression related to the end extremity value for width.
QgsInterpolatedLineColor interpolatedColor() const
Returns the interpolated color used to render the colors of lines, see QgsInterpolatedLineColor.
void setWidthUnit(const QgsUnitTypes::RenderUnit &strokeWidthUnit)
Sets the width unit.
void setExpressionsStringForWidth(QString start, QString end)
Sets the expressions (as string) that define the extremety values af the line feature for width.
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.
QString startValueExpressionForWidth() const
Returns the epression related to the start extremity value for width.
void setExpressionsStringForColor(QString start, QString end)
Sets the expressions (as string) that define the extremety values af the line feature for color.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the width unit.
QgsInterpolatedLineWidth interpolatedWidth() const
Returns the interpolated width used to render the width of lines, see QgsInterpolatedLineWidth.
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.
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.
double maximumValue() const
Returns the minimum value for the raster shader.
double minimumValue() const
Returns the maximum value for the raster shader.
virtual QString layerType() const =0
Returns a string that represents this layer type.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
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.