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(
 
   54  mWidthUnitSelectionVarying->setUnits(
 
   65  connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
 
   66  connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget );
 
   69  connect( mWidthMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   70  connect( mDoubleSpinBoxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   73  connect( mButtonLoadMinMaxValueWidth, &QPushButton::clicked, 
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth );
 
   74  connect( mLineEditWidthMinValue, &QLineEdit::textChanged, 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   75  connect( mLineEditWidthMaxValue, &QLineEdit::textChanged, 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   76  connect( mDoubleSpinBoxMinWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   77  connect( mDoubleSpinBoxMaxWidth, qOverload<double>( &QDoubleSpinBox::valueChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   82    whileBlocking( mWidthUnitSelectionFixed )->setUnit( mWidthUnitSelectionVarying->unit() );
 
   86    whileBlocking( mWidthUnitSelectionVarying )->setUnit( mWidthUnitSelectionFixed->unit() );
 
   89  connect( mCheckBoxAbsoluteValue, &QCheckBox::clicked, 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   90  connect( mCheckBoxOutOfrange, &QCheckBox::clicked, 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
   93  connect( mColorMethodComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), 
this, &QgsInterpolatedLineSymbolLayerWidget::apply );
 
  100  connect( mLineEditColorMinValue, &QLineEdit::textChanged, 
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
 
  101  connect( mLineEditColorMinValue, &QLineEdit::textEdited, 
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
 
  102  connect( mLineEditColorMaxValue, &QLineEdit::textChanged, 
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged );
 
  103  connect( mLineEditColorMaxValue, &QLineEdit::textEdited, 
this, &QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited );
 
  104  connect( mButtonLoadMinMaxValueColor, &QPushButton::clicked, 
this, &QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor );
 
 
  110  if ( !layer || layer->
layerType() != QLatin1String( 
"InterpolatedLine" ) )
 
  121  setLineEditValue( mLineEditWidthMinValue, interpolatedWidth.
minimumValue() );
 
  122  setLineEditValue( mLineEditWidthMaxValue, interpolatedWidth.
maximumValue() );
 
  141  updateVisibleWidget();
 
 
  152void QgsInterpolatedLineSymbolLayerWidget::apply()
 
  157  bool isExpression = 
false;
 
  158  QString fieldOrExpression = mWidthStartFieldExpression->currentField( &isExpression );
 
  160  fieldOrExpression = mWidthEndFieldExpression->currentField( &isExpression );
 
  164  if ( mWidthMethodComboBox->currentData().toBool() )
 
  165    mLayer->
setWidthUnit( mWidthUnitSelectionVarying->unit() );
 
  167    mLayer->
setWidthUnit( mWidthUnitSelectionFixed->unit() );
 
  169  fieldOrExpression = mColorStartFieldExpression->currentField( &isExpression );
 
  171  fieldOrExpression = mColorEndFieldExpression->currentField( &isExpression );
 
  179void QgsInterpolatedLineSymbolLayerWidget::updateVisibleWidget()
 
  181  mFixedWidthWidget->setVisible( !mWidthMethodComboBox->currentData().toBool() );
 
  182  mVaryingWidthWidget->setVisible( mWidthMethodComboBox->currentData().toBool() );
 
  184  mFixedColorWidget->setVisible(
 
  187  mVaryingColorWidget->setVisible(
 
  192void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueWidth()
 
  194  reloadMinMaxWidthFromLayer();
 
  195  setLineEditValue( mLineEditWidthMinValue, mMinimumForWidthFromLayer );
 
  196  setLineEditValue( mLineEditWidthMaxValue, mMaximumForWidthFromLayer );
 
  200void QgsInterpolatedLineSymbolLayerWidget::onReloadMinMaxValueColor()
 
  202  reloadMinMaxColorFromLayer();
 
  203  setLineEditValue( mLineEditColorMinValue, mMinimumForColorFromLayer );
 
  204  setLineEditValue( mLineEditColorMaxValue, mMaximumForColorFromLayer );
 
  205  onColorMinMaxLineTextEdited();
 
  208void 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 );
 
  272void 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    const double startValue = expressionStart.evaluate( &expressionContext ).toDouble();
 
  304    const 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();
 
  336void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextChanged()
 
  338  const double min = lineEditValue( mLineEditColorMinValue );
 
  339  const double max = lineEditValue( mLineEditColorMaxValue );
 
  340  whileBlocking( mColorRampShaderWidget )->setMinimumMaximum( min, max );
 
  344void QgsInterpolatedLineSymbolLayerWidget::onColorMinMaxLineTextEdited()
 
  346  const double min = lineEditValue( mLineEditColorMinValue );
 
  347  const double max = lineEditValue( mLineEditColorMaxValue );
 
  348  whileBlocking( mColorRampShaderWidget )->setMinimumMaximumAndClassify( min, max );
 
  370  interColor.
setColor( mColorButton->color() );
 
  372  interColor.
setColor( colorRampShader );
 
  378double QgsInterpolatedLineSymbolLayerWidget::lineEditValue( QLineEdit *lineEdit )
 
  380  if ( lineEdit->text().isEmpty() )
 
  382    return std::numeric_limits<double>::quiet_NaN();
 
  388void QgsInterpolatedLineSymbolLayerWidget::setLineEditValue( QLineEdit *lineEdit, 
double value )
 
  391  if ( !std::isnan( value ) )
 
  392    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.
 
Handles 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.
 
Defines color interpolation for rendering 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 features as interpolated lines.
 
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 that 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.
 
Abstract base class for symbol layers.
 
@ 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 dataset.
 
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.