QGIS API Documentation  3.4.3-Madeira (2f64a3c)
qgssymbollayerwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerwidget.cpp - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgssymbollayerwidget.h"
18 
19 #include "qgslinesymbollayer.h"
20 #include "qgsmarkersymbollayer.h"
21 #include "qgsfillsymbollayer.h"
23 #include "qgssymbolslistwidget.h"
24 
25 #include "characterwidget.h"
26 #include "qgsdashspacedialog.h"
28 #include "qgssvgcache.h"
29 #include "qgssymbollayerutils.h"
30 #include "qgscolorramp.h"
31 #include "qgscolorrampbutton.h"
33 #include "qgsproperty.h"
34 #include "qgsstyle.h" //for symbol selector dialog
35 #include "qgsmapcanvas.h"
36 #include "qgsapplication.h"
37 #include "qgsvectorlayer.h"
38 #include "qgssvgselectorwidget.h"
39 #include "qgslogger.h"
40 #include "qgssettings.h"
43 #include "qgsauxiliarystorage.h"
44 
45 #include <QAbstractButton>
46 #include <QButtonGroup>
47 #include <QColorDialog>
48 #include <QCursor>
49 #include <QDir>
50 #include <QFileDialog>
51 #include <QPainter>
52 #include <QStandardItemModel>
53 #include <QSvgRenderer>
54 #include <QMessageBox>
55 #include <QMenu>
56 #include <QAction>
57 #include <QInputDialog>
58 
60 {
61  if ( mContext.expressionContext() )
62  return *mContext.expressionContext();
63 
65 
67  if ( const QgsSymbolLayer *symbolLayer = const_cast< QgsSymbolLayerWidget * >( this )->symbolLayer() )
68  {
69  //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
70  //color, but that's not accessible here). 99% of the time these will be the same anyway
72  }
73  expContext << symbolScope;
74  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT, 1, true ) );
75  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_PART_NUM, 1, true ) );
76  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_COUNT, 1, true ) );
77  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM, 1, true ) );
78 
79  // additional scopes
80  Q_FOREACH ( const QgsExpressionContextScope &scope, mContext.additionalExpressionContextScopes() )
81  {
82  expContext.appendScope( new QgsExpressionContextScope( scope ) );
83  }
84 
85  //TODO - show actual value
86  expContext.setOriginalValueVariable( QVariant() );
87 
88  expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
92 
93  return expContext;
94 }
95 
97 {
98  mContext = context;
99  Q_FOREACH ( QgsUnitSelectionWidget *unitWidget, findChildren<QgsUnitSelectionWidget *>() )
100  {
101  unitWidget->setMapCanvas( mContext.mapCanvas() );
102  }
103 #if 0
104  Q_FOREACH ( QgsPropertyOverrideButton *ddButton, findChildren<QgsPropertyOverrideButton *>() )
105  {
106  if ( ddButton->assistant() )
107  ddButton->assistant()->setMapCanvas( mContext.mapCanvas() );
108  }
109 #endif
110 }
111 
113 {
114  return mContext;
115 }
116 
118 {
119  button->init( key, symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
121  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
122 
123  button->registerExpressionContextGenerator( this );
124 }
125 
126 void QgsSymbolLayerWidget::createAuxiliaryField()
127 {
128  // try to create an auxiliary layer if not yet created
129  if ( !mVectorLayer->auxiliaryLayer() )
130  {
131  QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
132  dlg.exec();
133  }
134 
135  // return if still not exists
136  if ( !mVectorLayer->auxiliaryLayer() )
137  return;
138 
139  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
140  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
142 
143  // create property in auxiliary storage if necessary
144  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
145  {
146  QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer, true, this );
147  if ( dlg.exec() == QDialog::Accepted )
148  def = dlg.propertyDefinition();
149  }
150 
151  // return if still not exist
152  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
153  return;
154 
155  // update property with join field name from auxiliary storage
156  QgsProperty property = button->toProperty();
157  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
158  property.setActive( true );
159  button->updateFieldLists();
160  button->setToProperty( property );
161  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
162 
163  emit changed();
164 }
165 
167 {
168  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
169  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
170  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
171  emit changed();
172 }
173 
175  : QgsSymbolLayerWidget( parent, vl )
176 {
177  mLayer = nullptr;
178 
179  setupUi( this );
180  connect( mCustomCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
181  connect( mChangePatternButton, &QPushButton::clicked, this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
182  connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed );
183  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed );
184  connect( mDashPatternUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed );
185  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
192 
193  btnChangeColor->setAllowOpacity( true );
194  btnChangeColor->setColorDialogTitle( tr( "Select Line Color" ) );
195  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
196 
197  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
198  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
199  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
200  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
201  {
202  if ( mLayer )
203  {
204  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
205  emit changed();
206  }
207  } );
208 
209  spinOffset->setClearValue( 0.0 );
210 
211  if ( vl && vl->geometryType() != QgsWkbTypes::PolygonGeometry )
212  {
213  //draw inside polygon checkbox only makes sense for polygon layers
214  mDrawInsideCheckBox->hide();
215  mRingFilterComboBox->hide();
216  mRingsLabel->hide();
217  }
218 
219  //make a temporary symbol for the size assistant preview
220  mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
221 
222  if ( vectorLayer() )
223  mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
224 
225  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
226  connect( btnChangeColor, &QgsColorButton::colorChanged, this, &QgsSimpleLineSymbolLayerWidget::colorChanged );
227  connect( cboPenStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
228  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
229  connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
230  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
231 
233 
234  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol );
235 }
236 
237 void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
238 {
239  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
240  {
241  mAssistantPreviewSymbol->deleteSymbolLayer( i );
242  }
243  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
245  if ( ddWidth )
246  mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
247 }
248 
249 
251 {
252  if ( !layer || layer->layerType() != QLatin1String( "SimpleLine" ) )
253  return;
254 
255  // layer type is correct, we can do the cast
256  mLayer = static_cast<QgsSimpleLineSymbolLayer *>( layer );
257 
258  // set units
259  mPenWidthUnitWidget->blockSignals( true );
260  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
261  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
262  mPenWidthUnitWidget->blockSignals( false );
263  mOffsetUnitWidget->blockSignals( true );
264  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
265  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
266  mOffsetUnitWidget->blockSignals( false );
267  mDashPatternUnitWidget->blockSignals( true );
268  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
269  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
270  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
271  mDashPatternUnitWidget->blockSignals( false );
272 
273  // set values
274  spinWidth->blockSignals( true );
275  spinWidth->setValue( mLayer->width() );
276  spinWidth->blockSignals( false );
277  btnChangeColor->blockSignals( true );
278  btnChangeColor->setColor( mLayer->color() );
279  btnChangeColor->blockSignals( false );
280  spinOffset->blockSignals( true );
281  spinOffset->setValue( mLayer->offset() );
282  spinOffset->blockSignals( false );
283  cboPenStyle->blockSignals( true );
284  cboJoinStyle->blockSignals( true );
285  cboCapStyle->blockSignals( true );
286  cboPenStyle->setPenStyle( mLayer->penStyle() );
287  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
288  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
289  cboPenStyle->blockSignals( false );
290  cboJoinStyle->blockSignals( false );
291  cboCapStyle->blockSignals( false );
292 
293  //use a custom dash pattern?
294  bool useCustomDashPattern = mLayer->useCustomDashPattern();
295  mChangePatternButton->setEnabled( useCustomDashPattern );
296  label_3->setEnabled( !useCustomDashPattern );
297  cboPenStyle->setEnabled( !useCustomDashPattern );
298  mCustomCheckBox->blockSignals( true );
299  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
300  mCustomCheckBox->blockSignals( false );
301 
302  //draw inside polygon?
303  const bool drawInsidePolygon = mLayer->drawInsidePolygon();
304  whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
305 
306  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
307 
309 
317 
318  updateAssistantSymbol();
319 }
320 
322 {
323  return mLayer;
324 }
325 
326 void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
327 {
328  mLayer->setWidth( spinWidth->value() );
330  emit changed();
331 }
332 
333 void QgsSimpleLineSymbolLayerWidget::colorChanged( const QColor &color )
334 {
335  mLayer->setColor( color );
337  emit changed();
338 }
339 
340 void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
341 {
342  mLayer->setPenStyle( cboPenStyle->penStyle() );
343  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
344  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
345  emit changed();
346 }
347 
348 void QgsSimpleLineSymbolLayerWidget::offsetChanged()
349 {
350  mLayer->setOffset( spinOffset->value() );
352  emit changed();
353 }
354 
355 void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged( int state )
356 {
357  bool checked = ( state == Qt::Checked );
358  mChangePatternButton->setEnabled( checked );
359  label_3->setEnabled( !checked );
360  cboPenStyle->setEnabled( !checked );
361 
362  mLayer->setUseCustomDashPattern( checked );
363  emit changed();
364 }
365 
366 void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
367 {
369  if ( d.exec() == QDialog::Accepted )
370  {
371  mLayer->setCustomDashVector( d.dashDotVector() );
373  emit changed();
374  }
375 }
376 
377 void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
378 {
379  if ( mLayer )
380  {
381  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
382  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
383  emit changed();
384  }
385 }
386 
387 void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
388 {
389  if ( mLayer )
390  {
391  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
392  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
393  emit changed();
394  }
395 }
396 
397 void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
398 {
399  if ( mLayer )
400  {
401  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
402  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
403  emit changed();
404  }
405 }
406 
407 void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
408 {
409  bool checked = ( state == Qt::Checked );
410  mLayer->setDrawInsidePolygon( checked );
411  emit changed();
412 }
413 
414 
416 {
417  if ( !mLayer )
418  {
419  return;
420  }
421  QgsSimpleLineSymbolLayer *layerCopy = mLayer->clone();
422  if ( !layerCopy )
423  {
424  return;
425  }
426  layerCopy->setUseCustomDashPattern( true );
427  QIcon buttonIcon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( layerCopy, QgsUnitTypes::RenderMillimeters, mChangePatternButton->iconSize() );
428  mChangePatternButton->setIcon( buttonIcon );
429  delete layerCopy;
430 }
431 
432 
434 
435 
437  : QgsSymbolLayerWidget( parent, vl )
438 {
439  mLayer = nullptr;
440 
441  setupUi( this );
442  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
443  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
444  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
445  connect( mStrokeStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
446  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
447  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
448  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
455 
456  btnChangeColorFill->setAllowOpacity( true );
457  btnChangeColorFill->setColorDialogTitle( tr( "Select Fill Color" ) );
458  btnChangeColorFill->setContext( QStringLiteral( "symbology" ) );
459  btnChangeColorFill->setShowNoColor( true );
460  btnChangeColorFill->setNoColorString( tr( "Transparent Fill" ) );
461  btnChangeColorStroke->setAllowOpacity( true );
462  btnChangeColorStroke->setColorDialogTitle( tr( "Select Stroke Color" ) );
463  btnChangeColorStroke->setContext( QStringLiteral( "symbology" ) );
464  btnChangeColorStroke->setShowNoColor( true );
465  btnChangeColorStroke->setNoColorString( tr( "Transparent Stroke" ) );
466 
467  spinOffsetX->setClearValue( 0.0 );
468  spinOffsetY->setClearValue( 0.0 );
469  spinAngle->setClearValue( 0.0 );
470 
471  //make a temporary symbol for the size assistant preview
472  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
473 
474  if ( vectorLayer() )
475  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
476 
477  int size = lstNames->iconSize().width();
478  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXX" ) ) ) ) );
479  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
480  lstNames->setIconSize( QSize( size, size ) );
481 
482  double markerSize = size * 0.8;
484  {
485  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
487  lyr->setColor( QColor( 200, 200, 200 ) );
488  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
489  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
490  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
491  item->setData( Qt::UserRole, static_cast< int >( shape ) );
492  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
493  delete lyr;
494  }
495  // show at least 3 rows
496  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
497 
498  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
499  connect( btnChangeColorStroke, &QgsColorButton::colorChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setColorStroke );
501  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
502  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
503  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
504  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
505  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
506  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol );
507 }
508 
510 {
511  if ( layer->layerType() != QLatin1String( "SimpleMarker" ) )
512  return;
513 
514  // layer type is correct, we can do the cast
515  mLayer = static_cast<QgsSimpleMarkerSymbolLayer *>( layer );
516 
517  // set values
519  for ( int i = 0; i < lstNames->count(); ++i )
520  {
521  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
522  {
523  lstNames->setCurrentRow( i );
524  break;
525  }
526  }
527  btnChangeColorStroke->blockSignals( true );
528  btnChangeColorStroke->setColor( mLayer->strokeColor() );
529  btnChangeColorStroke->blockSignals( false );
530  btnChangeColorFill->blockSignals( true );
531  btnChangeColorFill->setColor( mLayer->fillColor() );
532  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
533  btnChangeColorFill->blockSignals( false );
534  spinSize->blockSignals( true );
535  spinSize->setValue( mLayer->size() );
536  spinSize->blockSignals( false );
537  spinAngle->blockSignals( true );
538  spinAngle->setValue( mLayer->angle() );
539  spinAngle->blockSignals( false );
540  mStrokeStyleComboBox->blockSignals( true );
541  mStrokeStyleComboBox->setPenStyle( mLayer->strokeStyle() );
542  mStrokeStyleComboBox->blockSignals( false );
543  mStrokeWidthSpinBox->blockSignals( true );
544  mStrokeWidthSpinBox->setValue( mLayer->strokeWidth() );
545  mStrokeWidthSpinBox->blockSignals( false );
546  cboJoinStyle->blockSignals( true );
547  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
548  cboJoinStyle->blockSignals( false );
549 
550  // without blocking signals the value gets changed because of slot setOffset()
551  spinOffsetX->blockSignals( true );
552  spinOffsetX->setValue( mLayer->offset().x() );
553  spinOffsetX->blockSignals( false );
554  spinOffsetY->blockSignals( true );
555  spinOffsetY->setValue( mLayer->offset().y() );
556  spinOffsetY->blockSignals( false );
557 
558  mSizeUnitWidget->blockSignals( true );
559  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
560  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
561  mSizeUnitWidget->blockSignals( false );
562  mOffsetUnitWidget->blockSignals( true );
563  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
564  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
565  mOffsetUnitWidget->blockSignals( false );
566  mStrokeWidthUnitWidget->blockSignals( true );
567  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
568  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
569  mStrokeWidthUnitWidget->blockSignals( false );
570 
571  //anchor points
572  mHorizontalAnchorComboBox->blockSignals( true );
573  mVerticalAnchorComboBox->blockSignals( true );
574  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
575  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
576  mHorizontalAnchorComboBox->blockSignals( false );
577  mVerticalAnchorComboBox->blockSignals( false );
578 
590 
591  updateAssistantSymbol();
592 }
593 
595 {
596  return mLayer;
597 }
598 
599 void QgsSimpleMarkerSymbolLayerWidget::setShape()
600 {
601  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
602  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
603  emit changed();
604 }
605 
607 {
608  mLayer->setStrokeColor( color );
609  emit changed();
610 }
611 
613 {
614  mLayer->setColor( color );
615  emit changed();
616 }
617 
618 void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
619 {
620  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
621  emit changed();
622 }
623 
624 void QgsSimpleMarkerSymbolLayerWidget::setSize()
625 {
626  mLayer->setSize( spinSize->value() );
627  emit changed();
628 }
629 
630 void QgsSimpleMarkerSymbolLayerWidget::setAngle()
631 {
632  mLayer->setAngle( spinAngle->value() );
633  emit changed();
634 }
635 
636 void QgsSimpleMarkerSymbolLayerWidget::setOffset()
637 {
638  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
639  emit changed();
640 }
641 
642 void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged( int index )
643 {
644  Q_UNUSED( index );
645 
646  if ( mLayer )
647  {
648  mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
649  emit changed();
650  }
651 }
652 
653 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
654 {
655  if ( mLayer )
656  {
657  mLayer->setStrokeWidth( d );
658  emit changed();
659  }
660 }
661 
662 void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
663 {
664  if ( mLayer )
665  {
666  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
667  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
668  emit changed();
669  }
670 }
671 
672 void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
673 {
674  if ( mLayer )
675  {
676  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
677  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
678  emit changed();
679  }
680 }
681 
682 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
683 {
684  if ( mLayer )
685  {
686  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
687  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
688  emit changed();
689  }
690 }
691 
692 void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
693 {
694  if ( mLayer )
695  {
697  emit changed();
698  }
699 }
700 
701 void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
702 {
703  if ( mLayer )
704  {
706  emit changed();
707  }
708 }
709 
710 void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
711 {
712  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
713  {
714  mAssistantPreviewSymbol->deleteSymbolLayer( i );
715  }
716  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
718  if ( ddSize )
719  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
720 }
721 
722 
724 
726  : QgsSymbolLayerWidget( parent, vl )
727 {
728  mLayer = nullptr;
729 
730  setupUi( this );
731  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
732  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed );
737 
738  btnChangeColor->setAllowOpacity( true );
739  btnChangeColor->setColorDialogTitle( tr( "Select Fill Color" ) );
740  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
741  btnChangeColor->setShowNoColor( true );
742  btnChangeColor->setNoColorString( tr( "Transparent Fill" ) );
743  btnChangeStrokeColor->setAllowOpacity( true );
744  btnChangeStrokeColor->setColorDialogTitle( tr( "Select Stroke Color" ) );
745  btnChangeStrokeColor->setContext( QStringLiteral( "symbology" ) );
746  btnChangeStrokeColor->setShowNoColor( true );
747  btnChangeStrokeColor->setNoColorString( tr( "Transparent Stroke" ) );
748 
749  spinOffsetX->setClearValue( 0.0 );
750  spinOffsetY->setClearValue( 0.0 );
751 
753  connect( cboFillStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
754  connect( btnChangeStrokeColor, &QgsColorButton::colorChanged, this, &QgsSimpleFillSymbolLayerWidget::setStrokeColor );
755  connect( spinStrokeWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
756  connect( cboStrokeStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
757  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
758  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
759  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
760 }
761 
763 {
764  if ( layer->layerType() != QLatin1String( "SimpleFill" ) )
765  return;
766 
767  // layer type is correct, we can do the cast
768  mLayer = static_cast<QgsSimpleFillSymbolLayer *>( layer );
769 
770  // set values
771  btnChangeColor->blockSignals( true );
772  btnChangeColor->setColor( mLayer->color() );
773  btnChangeColor->blockSignals( false );
774  cboFillStyle->blockSignals( true );
775  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
776  cboFillStyle->blockSignals( false );
777  btnChangeStrokeColor->blockSignals( true );
778  btnChangeStrokeColor->setColor( mLayer->strokeColor() );
779  btnChangeStrokeColor->blockSignals( false );
780  cboStrokeStyle->blockSignals( true );
781  cboStrokeStyle->setPenStyle( mLayer->strokeStyle() );
782  cboStrokeStyle->blockSignals( false );
783  spinStrokeWidth->blockSignals( true );
784  spinStrokeWidth->setValue( mLayer->strokeWidth() );
785  spinStrokeWidth->blockSignals( false );
786  cboJoinStyle->blockSignals( true );
787  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
788  cboJoinStyle->blockSignals( false );
789  spinOffsetX->blockSignals( true );
790  spinOffsetX->setValue( mLayer->offset().x() );
791  spinOffsetX->blockSignals( false );
792  spinOffsetY->blockSignals( true );
793  spinOffsetY->setValue( mLayer->offset().y() );
794  spinOffsetY->blockSignals( false );
795 
796  mStrokeWidthUnitWidget->blockSignals( true );
797  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
798  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
799  mStrokeWidthUnitWidget->blockSignals( false );
800  mOffsetUnitWidget->blockSignals( true );
801  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
802  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
803  mOffsetUnitWidget->blockSignals( false );
804 
811 
812 }
813 
815 {
816  return mLayer;
817 }
818 
819 void QgsSimpleFillSymbolLayerWidget::setColor( const QColor &color )
820 {
821  mLayer->setColor( color );
822  emit changed();
823 }
824 
826 {
827  mLayer->setStrokeColor( color );
828  emit changed();
829 }
830 
831 void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
832 {
833  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
834  emit changed();
835 }
836 
837 void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
838 {
839  mLayer->setStrokeWidth( spinStrokeWidth->value() );
840  emit changed();
841 }
842 
843 void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
844 {
845  mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
846  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
847  emit changed();
848 }
849 
850 void QgsSimpleFillSymbolLayerWidget::offsetChanged()
851 {
852  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
853  emit changed();
854 }
855 
856 void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
857 {
858  if ( mLayer )
859  {
860  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
861  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
862  emit changed();
863  }
864 }
865 
866 void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
867 {
868  if ( mLayer )
869  {
870  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
871  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
872  emit changed();
873  }
874 }
875 
877 
879  : QgsSymbolLayerWidget( parent, vl )
880 {
881  mLayer = nullptr;
882 
883  setupUi( this );
884  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
885  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
886  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
887  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
892 
893  spinOffsetX->setClearValue( 0.0 );
894  spinOffsetY->setClearValue( 0.0 );
895  spinAngle->setClearValue( 0.0 );
896 
897  //make a temporary symbol for the size assistant preview
898  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
899 
900  if ( vectorLayer() )
901  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
902 
903  QSize size = lstNames->iconSize();
904  double markerSize = DEFAULT_POINT_SIZE * 2;
906  {
908  continue;
909 
910  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
911  lyr->setColor( QColor( 200, 200, 200 ) );
912  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
914  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
915  item->setData( Qt::UserRole, static_cast< int >( shape ) );
916  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
917  delete lyr;
918  }
919 
920  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
921  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
922  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
923  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
924  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
925  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
926 }
927 
929 {
930  if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
931  return;
932 
933  // layer type is correct, we can do the cast
934  mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
935 
936  // set values
938  for ( int i = 0; i < lstNames->count(); ++i )
939  {
940  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
941  {
942  lstNames->setCurrentRow( i );
943  break;
944  }
945  }
946  whileBlocking( spinSize )->setValue( mLayer->size() );
947  whileBlocking( spinAngle )->setValue( mLayer->angle() );
948  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
949  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
950 
951  mSizeUnitWidget->blockSignals( true );
952  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
953  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
954  mSizeUnitWidget->blockSignals( false );
955  mOffsetUnitWidget->blockSignals( true );
956  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
957  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
958  mOffsetUnitWidget->blockSignals( false );
959 
960  //anchor points
961  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
962  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
963 
970 
971  updateAssistantSymbol();
972 }
973 
975 {
976  return mLayer;
977 }
978 
979 void QgsFilledMarkerSymbolLayerWidget::setShape()
980 {
981  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
982  emit changed();
983 }
984 
985 void QgsFilledMarkerSymbolLayerWidget::setSize()
986 {
987  mLayer->setSize( spinSize->value() );
988  emit changed();
989 }
990 
991 void QgsFilledMarkerSymbolLayerWidget::setAngle()
992 {
993  mLayer->setAngle( spinAngle->value() );
994  emit changed();
995 }
996 
997 void QgsFilledMarkerSymbolLayerWidget::setOffset()
998 {
999  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1000  emit changed();
1001 }
1002 
1003 void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1004 {
1005  if ( mLayer )
1006  {
1007  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1008  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1009  emit changed();
1010  }
1011 }
1012 
1013 void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1014 {
1015  if ( mLayer )
1016  {
1017  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1018  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1019  emit changed();
1020  }
1021 }
1022 
1023 void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
1024 {
1025  if ( mLayer )
1026  {
1028  emit changed();
1029  }
1030 }
1031 
1032 void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
1033 {
1034  if ( mLayer )
1035  {
1037  emit changed();
1038  }
1039 }
1040 
1041 void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1042 {
1043  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1044  {
1045  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1046  }
1047  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1049  if ( ddSize )
1050  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1051 }
1052 
1053 
1055 
1057  : QgsSymbolLayerWidget( parent, vl )
1058 {
1059  mLayer = nullptr;
1060 
1061  setupUi( this );
1062  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1063  connect( mSpinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1066 
1067  btnColorRamp->setShowGradientOnly( true );
1068 
1069  btnChangeColor->setAllowOpacity( true );
1070  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1071  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1072  btnChangeColor->setShowNoColor( true );
1073  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1074  btnChangeColor2->setAllowOpacity( true );
1075  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1076  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1077  btnChangeColor2->setShowNoColor( true );
1078  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1079 
1080  spinOffsetX->setClearValue( 0.0 );
1081  spinOffsetY->setClearValue( 0.0 );
1082  mSpinAngle->setClearValue( 0.0 );
1083 
1087  connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1088  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1089  connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1090  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1091  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1092  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1093  connect( spinRefPoint1X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1094  connect( spinRefPoint1Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1095  connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1096  connect( spinRefPoint2X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1097  connect( spinRefPoint2Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1098  connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1099 }
1100 
1102 {
1103  if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1104  return;
1105 
1106  // layer type is correct, we can do the cast
1107  mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1108 
1109  // set values
1110  btnChangeColor->blockSignals( true );
1111  btnChangeColor->setColor( mLayer->color() );
1112  btnChangeColor->blockSignals( false );
1113  btnChangeColor2->blockSignals( true );
1114  btnChangeColor2->setColor( mLayer->color2() );
1115  btnChangeColor2->blockSignals( false );
1116 
1118  {
1119  radioTwoColor->setChecked( true );
1120  btnColorRamp->setEnabled( false );
1121  }
1122  else
1123  {
1124  radioColorRamp->setChecked( true );
1125  btnChangeColor->setEnabled( false );
1126  btnChangeColor2->setEnabled( false );
1127  }
1128 
1129  // set source color ramp
1130  if ( mLayer->colorRamp() )
1131  {
1132  btnColorRamp->blockSignals( true );
1133  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1134  btnColorRamp->blockSignals( false );
1135  }
1136 
1137  cboGradientType->blockSignals( true );
1138  switch ( mLayer->gradientType() )
1139  {
1141  cboGradientType->setCurrentIndex( 0 );
1142  break;
1144  cboGradientType->setCurrentIndex( 1 );
1145  break;
1147  cboGradientType->setCurrentIndex( 2 );
1148  break;
1149  }
1150  cboGradientType->blockSignals( false );
1151 
1152  cboCoordinateMode->blockSignals( true );
1153  switch ( mLayer->coordinateMode() )
1154  {
1156  cboCoordinateMode->setCurrentIndex( 1 );
1157  checkRefPoint1Centroid->setEnabled( false );
1158  checkRefPoint2Centroid->setEnabled( false );
1159  break;
1161  default:
1162  cboCoordinateMode->setCurrentIndex( 0 );
1163  break;
1164  }
1165  cboCoordinateMode->blockSignals( false );
1166 
1167  cboGradientSpread->blockSignals( true );
1168  switch ( mLayer->gradientSpread() )
1169  {
1171  cboGradientSpread->setCurrentIndex( 0 );
1172  break;
1174  cboGradientSpread->setCurrentIndex( 1 );
1175  break;
1177  cboGradientSpread->setCurrentIndex( 2 );
1178  break;
1179  }
1180  cboGradientSpread->blockSignals( false );
1181 
1182  spinRefPoint1X->blockSignals( true );
1183  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1184  spinRefPoint1X->blockSignals( false );
1185  spinRefPoint1Y->blockSignals( true );
1186  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1187  spinRefPoint1Y->blockSignals( false );
1188  checkRefPoint1Centroid->blockSignals( true );
1189  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1191  {
1192  spinRefPoint1X->setEnabled( false );
1193  spinRefPoint1Y->setEnabled( false );
1194  }
1195  checkRefPoint1Centroid->blockSignals( false );
1196  spinRefPoint2X->blockSignals( true );
1197  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1198  spinRefPoint2X->blockSignals( false );
1199  spinRefPoint2Y->blockSignals( true );
1200  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1201  spinRefPoint2Y->blockSignals( false );
1202  checkRefPoint2Centroid->blockSignals( true );
1203  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1205  {
1206  spinRefPoint2X->setEnabled( false );
1207  spinRefPoint2Y->setEnabled( false );
1208  }
1209  checkRefPoint2Centroid->blockSignals( false );
1210 
1211  spinOffsetX->blockSignals( true );
1212  spinOffsetX->setValue( mLayer->offset().x() );
1213  spinOffsetX->blockSignals( false );
1214  spinOffsetY->blockSignals( true );
1215  spinOffsetY->setValue( mLayer->offset().y() );
1216  spinOffsetY->blockSignals( false );
1217  mSpinAngle->blockSignals( true );
1218  mSpinAngle->setValue( mLayer->angle() );
1219  mSpinAngle->blockSignals( false );
1220 
1221  mOffsetUnitWidget->blockSignals( true );
1222  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1223  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1224  mOffsetUnitWidget->blockSignals( false );
1225 
1238 }
1239 
1241 {
1242  return mLayer;
1243 }
1244 
1246 {
1247  mLayer->setColor( color );
1248  emit changed();
1249 }
1250 
1252 {
1253  mLayer->setColor2( color );
1254  emit changed();
1255 }
1256 
1257 void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1258 {
1259  if ( radioTwoColor->isChecked() )
1260  {
1262  }
1263  else
1264  {
1266  }
1267  emit changed();
1268 }
1269 
1271 {
1272  if ( btnColorRamp->isNull() )
1273  return;
1274 
1275  mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1276  emit changed();
1277 }
1278 
1280 {
1281  switch ( index )
1282  {
1283  case 0:
1285  //set sensible default reference points
1286  spinRefPoint1X->setValue( 0.5 );
1287  spinRefPoint1Y->setValue( 0 );
1288  spinRefPoint2X->setValue( 0.5 );
1289  spinRefPoint2Y->setValue( 1 );
1290  break;
1291  case 1:
1293  //set sensible default reference points
1294  spinRefPoint1X->setValue( 0 );
1295  spinRefPoint1Y->setValue( 0 );
1296  spinRefPoint2X->setValue( 1 );
1297  spinRefPoint2Y->setValue( 1 );
1298  break;
1299  case 2:
1301  spinRefPoint1X->setValue( 0.5 );
1302  spinRefPoint1Y->setValue( 0.5 );
1303  spinRefPoint2X->setValue( 1 );
1304  spinRefPoint2Y->setValue( 1 );
1305  break;
1306  }
1307  emit changed();
1308 }
1309 
1311 {
1312 
1313  switch ( index )
1314  {
1315  case 0:
1316  //feature coordinate mode
1318  //allow choice of centroid reference positions
1319  checkRefPoint1Centroid->setEnabled( true );
1320  checkRefPoint2Centroid->setEnabled( true );
1321  break;
1322  case 1:
1323  //viewport coordinate mode
1325  //disable choice of centroid reference positions
1326  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1327  checkRefPoint1Centroid->setEnabled( false );
1328  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1329  checkRefPoint2Centroid->setEnabled( false );
1330  break;
1331  }
1332 
1333  emit changed();
1334 }
1335 
1337 {
1338  switch ( index )
1339  {
1340  case 0:
1342  break;
1343  case 1:
1345  break;
1346  case 2:
1348  break;
1349  }
1350 
1351  emit changed();
1352 }
1353 
1354 void QgsGradientFillSymbolLayerWidget::offsetChanged()
1355 {
1356  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1357  emit changed();
1358 }
1359 
1360 void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1361 {
1362  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1363  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1364  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1365  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1366  emit changed();
1367 }
1368 
1369 void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1370 {
1371  mLayer->setAngle( value );
1372  emit changed();
1373 }
1374 
1375 void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1376 {
1377  if ( mLayer )
1378  {
1379  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1380  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1381  emit changed();
1382  }
1383 }
1384 
1386 
1388  : QgsSymbolLayerWidget( parent, vl )
1389 {
1390  mLayer = nullptr;
1391 
1392  setupUi( this );
1393  connect( mSpinBlurRadius, qgis::overload< int >::of( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1394  connect( mSpinMaxDistance, qgis::overload< double >::of( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1395  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1396  connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1397  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1398  connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1403 
1404  QButtonGroup *group1 = new QButtonGroup( this );
1405  group1->addButton( radioColorRamp );
1406  group1->addButton( radioTwoColor );
1407  QButtonGroup *group2 = new QButtonGroup( this );
1408  group2->addButton( mRadioUseMaxDistance );
1409  group2->addButton( mRadioUseWholeShape );
1410  btnChangeColor->setAllowOpacity( true );
1411  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1412  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1413  btnChangeColor->setShowNoColor( true );
1414  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1415  btnChangeColor2->setAllowOpacity( true );
1416  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1417  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1418  btnChangeColor2->setShowNoColor( true );
1419  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1420 
1421  spinOffsetX->setClearValue( 0.0 );
1422  spinOffsetY->setClearValue( 0.0 );
1423 
1424  btnColorRamp->setShowGradientOnly( true );
1425 
1426  connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1427 
1430  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1431  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1432  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1433 
1434  connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1435  connect( mSpinBlurRadius, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1436 }
1437 
1439 {
1440  if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1441  return;
1442 
1443  // layer type is correct, we can do the cast
1444  mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1445 
1446  // set values
1447  btnChangeColor->blockSignals( true );
1448  btnChangeColor->setColor( mLayer->color() );
1449  btnChangeColor->blockSignals( false );
1450  btnChangeColor2->blockSignals( true );
1451  btnChangeColor2->setColor( mLayer->color2() );
1452  btnChangeColor2->blockSignals( false );
1453 
1455  {
1456  radioTwoColor->setChecked( true );
1457  btnColorRamp->setEnabled( false );
1458  }
1459  else
1460  {
1461  radioColorRamp->setChecked( true );
1462  btnChangeColor->setEnabled( false );
1463  btnChangeColor2->setEnabled( false );
1464  }
1465 
1466  mSpinBlurRadius->blockSignals( true );
1467  mBlurSlider->blockSignals( true );
1468  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1469  mBlurSlider->setValue( mLayer->blurRadius() );
1470  mSpinBlurRadius->blockSignals( false );
1471  mBlurSlider->blockSignals( false );
1472 
1473  mSpinMaxDistance->blockSignals( true );
1474  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1475  mSpinMaxDistance->blockSignals( false );
1476 
1477  mRadioUseWholeShape->blockSignals( true );
1478  mRadioUseMaxDistance->blockSignals( true );
1479  if ( mLayer->useWholeShape() )
1480  {
1481  mRadioUseWholeShape->setChecked( true );
1482  mSpinMaxDistance->setEnabled( false );
1483  mDistanceUnitWidget->setEnabled( false );
1484  }
1485  else
1486  {
1487  mRadioUseMaxDistance->setChecked( true );
1488  mSpinMaxDistance->setEnabled( true );
1489  mDistanceUnitWidget->setEnabled( true );
1490  }
1491  mRadioUseWholeShape->blockSignals( false );
1492  mRadioUseMaxDistance->blockSignals( false );
1493 
1494  mDistanceUnitWidget->blockSignals( true );
1495  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1496  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1497  mDistanceUnitWidget->blockSignals( false );
1498 
1499  mIgnoreRingsCheckBox->blockSignals( true );
1500  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1501  mIgnoreRingsCheckBox->blockSignals( false );
1502 
1503  // set source color ramp
1504  if ( mLayer->colorRamp() )
1505  {
1506  btnColorRamp->blockSignals( true );
1507  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1508  btnColorRamp->blockSignals( false );
1509  }
1510 
1511  spinOffsetX->blockSignals( true );
1512  spinOffsetX->setValue( mLayer->offset().x() );
1513  spinOffsetX->blockSignals( false );
1514  spinOffsetY->blockSignals( true );
1515  spinOffsetY->setValue( mLayer->offset().y() );
1516  spinOffsetY->blockSignals( false );
1517  mOffsetUnitWidget->blockSignals( true );
1518  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1519  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1520  mOffsetUnitWidget->blockSignals( false );
1521 
1528 }
1529 
1531 {
1532  return mLayer;
1533 }
1534 
1536 {
1537  if ( mLayer )
1538  {
1539  mLayer->setColor( color );
1540  emit changed();
1541  }
1542 }
1543 
1545 {
1546  if ( mLayer )
1547  {
1548  mLayer->setColor2( color );
1549  emit changed();
1550  }
1551 }
1552 
1553 void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1554 {
1555  if ( !mLayer )
1556  {
1557  return;
1558  }
1559 
1560  if ( radioTwoColor->isChecked() )
1561  {
1563  }
1564  else
1565  {
1567  }
1568  emit changed();
1569 }
1570 
1571 void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1572 {
1573  if ( mLayer )
1574  {
1575  mLayer->setBlurRadius( value );
1576  emit changed();
1577  }
1578 }
1579 
1580 void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1581 {
1582  if ( mLayer )
1583  {
1584  mLayer->setMaxDistance( value );
1585  emit changed();
1586  }
1587 }
1588 
1589 void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1590 {
1591  if ( mLayer )
1592  {
1593  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1594  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1595  emit changed();
1596  }
1597 }
1598 
1599 void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1600 {
1601  if ( mLayer )
1602  {
1603  mLayer->setUseWholeShape( value );
1604  mDistanceUnitWidget->setEnabled( !value );
1605  emit changed();
1606  }
1607 }
1608 
1609 void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1610 {
1611  QgsColorRamp *ramp = btnColorRamp->colorRamp();
1612  if ( !ramp )
1613  return;
1614 
1615  mLayer->setColorRamp( ramp );
1616  emit changed();
1617 }
1618 
1619 void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1620 {
1621  if ( mLayer )
1622  {
1623  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1624  emit changed();
1625  }
1626 }
1627 
1628 void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1629 {
1630  if ( mLayer )
1631  {
1632  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1633  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1634  emit changed();
1635  }
1636 }
1637 
1638 
1639 void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1640 {
1641  bool checked = ( state == Qt::Checked );
1642  mLayer->setIgnoreRings( checked );
1643  emit changed();
1644 }
1645 
1647 
1649  : QgsSymbolLayerWidget( parent, vl )
1650 {
1651  mLayer = nullptr;
1652 
1653  setupUi( this );
1654  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1655  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1656  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1663 
1664  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1665  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1666  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1667  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
1668  {
1669  if ( mLayer )
1670  {
1671  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
1672  emit changed();
1673  }
1674  } );
1675 
1676  spinOffset->setClearValue( 0.0 );
1677 
1678 
1679  if ( vl && vl->geometryType() != QgsWkbTypes::PolygonGeometry )
1680  {
1681  mRingFilterComboBox->hide();
1682  mRingsLabel->hide();
1683  }
1684 
1685  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1686  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1687  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1688  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1689  connect( radInterval, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1690  connect( radVertex, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1691  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1692  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1693  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1694  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1695 }
1696 
1698 {
1699  if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1700  return;
1701 
1702  // layer type is correct, we can do the cast
1703  mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1704 
1705  // set values
1706  spinInterval->blockSignals( true );
1707  spinInterval->setValue( mLayer->interval() );
1708  spinInterval->blockSignals( false );
1709  mSpinOffsetAlongLine->blockSignals( true );
1710  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1711  mSpinOffsetAlongLine->blockSignals( false );
1712  chkRotateMarker->blockSignals( true );
1713  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1714  chkRotateMarker->blockSignals( false );
1715  spinOffset->blockSignals( true );
1716  spinOffset->setValue( mLayer->offset() );
1717  spinOffset->blockSignals( false );
1719  radInterval->setChecked( true );
1721  radVertex->setChecked( true );
1723  radVertexLast->setChecked( true );
1725  radCentralPoint->setChecked( true );
1727  radCurvePoint->setChecked( true );
1728  else
1729  radVertexFirst->setChecked( true );
1730 
1731  // set units
1732  mIntervalUnitWidget->blockSignals( true );
1733  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1734  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1735  mIntervalUnitWidget->blockSignals( false );
1736  mOffsetUnitWidget->blockSignals( true );
1737  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1738  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1739  mOffsetUnitWidget->blockSignals( false );
1740  mOffsetAlongLineUnitWidget->blockSignals( true );
1741  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1742  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1743  mOffsetAlongLineUnitWidget->blockSignals( false );
1744 
1745  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1746 
1747  setPlacement(); // update gui
1748 
1753 }
1754 
1756 {
1757  return mLayer;
1758 }
1759 
1761 {
1762  mLayer->setInterval( val );
1763  emit changed();
1764 }
1765 
1767 {
1768  mLayer->setOffsetAlongLine( val );
1769  emit changed();
1770 }
1771 
1772 void QgsMarkerLineSymbolLayerWidget::setRotate()
1773 {
1774  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1775  emit changed();
1776 }
1777 
1778 void QgsMarkerLineSymbolLayerWidget::setOffset()
1779 {
1780  mLayer->setOffset( spinOffset->value() );
1781  emit changed();
1782 }
1783 
1784 void QgsMarkerLineSymbolLayerWidget::setPlacement()
1785 {
1786  bool interval = radInterval->isChecked();
1787  spinInterval->setEnabled( interval );
1788  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1789  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
1790  if ( radInterval->isChecked() )
1792  else if ( radVertex->isChecked() )
1794  else if ( radVertexLast->isChecked() )
1796  else if ( radVertexFirst->isChecked() )
1798  else if ( radCurvePoint->isChecked() )
1800  else
1802 
1803  emit changed();
1804 }
1805 
1806 void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
1807 {
1808  if ( mLayer )
1809  {
1810  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1811  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1812  emit changed();
1813  }
1814 }
1815 
1816 void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
1817 {
1818  if ( mLayer )
1819  {
1820  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1821  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1822  emit changed();
1823  }
1824 }
1825 
1826 void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
1827 {
1828  if ( mLayer )
1829  {
1830  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1831  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1832  }
1833  emit changed();
1834 }
1835 
1837 
1838 
1840  : QgsSymbolLayerWidget( parent, vl )
1841 {
1842  mLayer = nullptr;
1843 
1844  setupUi( this );
1845 
1846  mSvgSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
1847 
1848  connect( mSvgSourceLineEdit, &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
1849  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
1850  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
1851  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
1852  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
1853  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
1854  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
1855  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1856  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1863  viewGroups->setHeaderHidden( true );
1864  mChangeColorButton->setAllowOpacity( true );
1865  mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
1866  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
1867  mChangeStrokeColorButton->setAllowOpacity( true );
1868  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
1869  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
1870 
1871  spinOffsetX->setClearValue( 0.0 );
1872  spinOffsetY->setClearValue( 0.0 );
1873  spinAngle->setClearValue( 0.0 );
1874 
1875  mIconSize = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXXX" ) ) ) ) );
1876  viewImages->setGridSize( QSize( mIconSize * 1.2, mIconSize * 1.2 ) );
1877 
1878  populateList();
1879 
1880  connect( viewImages->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::setName );
1881  connect( viewGroups->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::populateIcons );
1882  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
1883  connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
1884  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
1885  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
1886  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
1887  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
1888  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
1889 
1890 
1891  //make a temporary symbol for the size assistant preview
1892  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1893 
1894  if ( vectorLayer() )
1895  {
1896  mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
1897  mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
1898  }
1899 }
1900 
1901 #include <QTime>
1902 #include <QAbstractListModel>
1903 #include <QPixmapCache>
1904 #include <QStyle>
1905 
1906 
1908 {
1909  QAbstractItemModel *oldModel = viewGroups->model();
1911  viewGroups->setModel( g );
1912  delete oldModel;
1913 
1914  // Set the tree expanded at the first level
1915  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1916  for ( int i = 0; i < rows; i++ )
1917  {
1918  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1919  }
1920 
1921  // Initially load the icons in the List view without any grouping
1922  oldModel = viewImages->model();
1923  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, mIconSize );
1924  viewImages->setModel( m );
1925  delete oldModel;
1926 }
1927 
1928 void QgsSvgMarkerSymbolLayerWidget::populateIcons( const QModelIndex &idx )
1929 {
1930  QString path = idx.data( Qt::UserRole + 1 ).toString();
1931 
1932  QAbstractItemModel *oldModel = viewImages->model();
1933  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, path );
1934  viewImages->setModel( m );
1935  delete oldModel;
1936 
1937  connect( viewImages->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::setName );
1938 }
1939 
1941 {
1942  if ( !layer )
1943  {
1944  return;
1945  }
1946 
1947  //activate gui for svg parameters only if supported by the svg file
1948  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
1949  QColor defaultFill, defaultStroke;
1950  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
1951  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
1952  QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
1953  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
1954  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
1955  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
1956  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
1957  mChangeColorButton->setEnabled( hasFillParam );
1958  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
1959  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
1960  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
1961  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
1962 
1963  if ( hasFillParam )
1964  {
1965  QColor fill = layer->fillColor();
1966  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
1967  if ( hasDefaultFillColor )
1968  {
1969  fill = defaultFill;
1970  }
1971  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
1972  mChangeColorButton->setColor( fill );
1973  }
1974  if ( hasStrokeParam )
1975  {
1976  QColor stroke = layer->strokeColor();
1977  double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
1978  if ( hasDefaultStrokeColor )
1979  {
1980  stroke = defaultStroke;
1981  }
1982  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
1983  mChangeStrokeColorButton->setColor( stroke );
1984  }
1985 
1986  whileBlocking( mSvgSourceLineEdit )->setSource( layer->path() );
1987 
1988  mStrokeWidthSpinBox->blockSignals( true );
1989  mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
1990  mStrokeWidthSpinBox->blockSignals( false );
1991 
1992  bool preservedAspectRatio = layer->preservedAspectRatio();
1993  spinHeight->blockSignals( true );
1994  if ( preservedAspectRatio )
1995  {
1996  spinHeight->setValue( layer->size() );
1997  }
1998  else
1999  {
2000  spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2001  }
2002  spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2003  spinHeight->blockSignals( false );
2004  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2005 }
2006 
2007 void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2008 {
2009  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2010  {
2011  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2012  }
2013  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2015  if ( ddSize )
2016  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2017 }
2018 
2019 
2021 {
2022  if ( !layer )
2023  {
2024  return;
2025  }
2026 
2027  if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2028  return;
2029 
2030  // layer type is correct, we can do the cast
2031  mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2032 
2033  // set values
2034 
2035  QAbstractItemModel *m = viewImages->model();
2036  QItemSelectionModel *selModel = viewImages->selectionModel();
2037  for ( int i = 0; i < m->rowCount(); i++ )
2038  {
2039  QModelIndex idx( m->index( i, 0 ) );
2040  if ( m->data( idx ).toString() == mLayer->path() )
2041  {
2042  selModel->select( idx, QItemSelectionModel::SelectCurrent );
2043  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
2044  setName( idx );
2045  break;
2046  }
2047  }
2048 
2049  spinWidth->blockSignals( true );
2050  spinWidth->setValue( mLayer->size() );
2051  spinWidth->blockSignals( false );
2052  spinAngle->blockSignals( true );
2053  spinAngle->setValue( mLayer->angle() );
2054  spinAngle->blockSignals( false );
2055 
2056  // without blocking signals the value gets changed because of slot setOffset()
2057  spinOffsetX->blockSignals( true );
2058  spinOffsetX->setValue( mLayer->offset().x() );
2059  spinOffsetX->blockSignals( false );
2060  spinOffsetY->blockSignals( true );
2061  spinOffsetY->setValue( mLayer->offset().y() );
2062  spinOffsetY->blockSignals( false );
2063 
2064  mSizeUnitWidget->blockSignals( true );
2065  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2066  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2067  mSizeUnitWidget->blockSignals( false );
2068  mStrokeWidthUnitWidget->blockSignals( true );
2069  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2070  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2071  mStrokeWidthUnitWidget->blockSignals( false );
2072  mOffsetUnitWidget->blockSignals( true );
2073  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2074  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2075  mOffsetUnitWidget->blockSignals( false );
2076 
2077  //anchor points
2078  mHorizontalAnchorComboBox->blockSignals( true );
2079  mVerticalAnchorComboBox->blockSignals( true );
2080  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2081  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2082  mHorizontalAnchorComboBox->blockSignals( false );
2083  mVerticalAnchorComboBox->blockSignals( false );
2084 
2085  setGuiForSvg( mLayer );
2086 
2097 
2098  updateAssistantSymbol();
2099 }
2100 
2102 {
2103  return mLayer;
2104 }
2105 
2106 void QgsSvgMarkerSymbolLayerWidget::setName( const QModelIndex &idx )
2107 {
2108  QString name = idx.data( Qt::UserRole ).toString();
2109  mLayer->setPath( name );
2110  whileBlocking( mSvgSourceLineEdit )->setSource( name );
2111 
2112  setGuiForSvg( mLayer );
2113  emit changed();
2114 }
2115 
2116 void QgsSvgMarkerSymbolLayerWidget::setWidth()
2117 {
2118  double defaultAspectRatio = mLayer->defaultAspectRatio();
2119  double fixedAspectRatio = 0.0;
2120  spinHeight->blockSignals( true );
2121  if ( defaultAspectRatio <= 0.0 )
2122  {
2123  spinHeight->setValue( spinWidth->value() );
2124  }
2125  else if ( mLockAspectRatio->locked() )
2126  {
2127  spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2128  }
2129  else
2130  {
2131  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2132  }
2133  spinHeight->blockSignals( false );
2134  mLayer->setSize( spinWidth->value() );
2135  mLayer->setFixedAspectRatio( fixedAspectRatio );
2136  emit changed();
2137 }
2138 
2139 void QgsSvgMarkerSymbolLayerWidget::setHeight()
2140 {
2141  double defaultAspectRatio = mLayer->defaultAspectRatio();
2142  double fixedAspectRatio = 0.0;
2143  spinWidth->blockSignals( true );
2144  if ( defaultAspectRatio <= 0.0 )
2145  {
2146  spinWidth->setValue( spinHeight->value() );
2147  }
2148  else if ( mLockAspectRatio->locked() )
2149  {
2150  spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2151  }
2152  else
2153  {
2154  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2155  }
2156  spinWidth->blockSignals( false );
2157  mLayer->setSize( spinWidth->value() );
2158  mLayer->setFixedAspectRatio( fixedAspectRatio );
2159  emit changed();
2160 }
2161 
2162 void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2163 {
2164  //spinHeight->setEnabled( !locked );
2165  double defaultAspectRatio = mLayer->defaultAspectRatio();
2166  if ( defaultAspectRatio <= 0.0 )
2167  {
2168  whileBlocking( mLockAspectRatio )->setLocked( true );
2169  }
2170  else if ( locked )
2171  {
2172  mLayer->setFixedAspectRatio( 0.0 );
2173  setWidth();
2174  }
2175  else
2176  {
2177  mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2178  }
2179  //emit changed();
2180 }
2181 
2182 void QgsSvgMarkerSymbolLayerWidget::setAngle()
2183 {
2184  mLayer->setAngle( spinAngle->value() );
2185  emit changed();
2186 }
2187 
2188 void QgsSvgMarkerSymbolLayerWidget::setOffset()
2189 {
2190  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2191  emit changed();
2192 }
2193 
2194 void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2195 {
2196  mLayer->setPath( text );
2197  setGuiForSvg( mLayer );
2198  emit changed();
2199 }
2200 
2201 void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2202 {
2203  if ( !mLayer )
2204  {
2205  return;
2206  }
2207 
2208  mLayer->setFillColor( color );
2209  emit changed();
2210 }
2211 
2212 void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2213 {
2214  if ( !mLayer )
2215  {
2216  return;
2217  }
2218 
2219  mLayer->setStrokeColor( color );
2220  emit changed();
2221 }
2222 
2223 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2224 {
2225  if ( mLayer )
2226  {
2227  mLayer->setStrokeWidth( d );
2228  emit changed();
2229  }
2230 }
2231 
2232 void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2233 {
2234  if ( mLayer )
2235  {
2236  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2237  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2238  emit changed();
2239  }
2240 }
2241 
2242 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2243 {
2244  if ( mLayer )
2245  {
2246  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2247  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2248  emit changed();
2249  }
2250 }
2251 
2252 void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2253 {
2254  if ( mLayer )
2255  {
2256  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2257  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2258  emit changed();
2259  }
2260 }
2261 
2262 void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2263 {
2264  if ( mLayer )
2265  {
2267  emit changed();
2268  }
2269 }
2270 
2271 void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
2272 {
2273  if ( mLayer )
2274  {
2276  emit changed();
2277  }
2278 }
2279 
2281 
2283 {
2284  mLayer = nullptr;
2285  setupUi( this );
2286  connect( mTextureWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2287  connect( mSvgSourceLineEdit, &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2288  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2289  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2290  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2291  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2292  connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2293  connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2298  mSvgTreeView->setHeaderHidden( true );
2299  insertIcons();
2300 
2301  mRotationSpinBox->setClearValue( 0.0 );
2302 
2303  mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2304  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2305  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2306  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2307 
2308  connect( mSvgListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::setFile );
2309  connect( mSvgTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::populateIcons );
2310 }
2311 
2313 {
2314  if ( !layer )
2315  {
2316  return;
2317  }
2318 
2319  if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2320  {
2321  return;
2322  }
2323 
2324  mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2325  if ( mLayer )
2326  {
2327  double width = mLayer->patternWidth();
2328  mTextureWidthSpinBox->blockSignals( true );
2329  mTextureWidthSpinBox->setValue( width );
2330  mTextureWidthSpinBox->blockSignals( false );
2331  whileBlocking( mSvgSourceLineEdit )->setSource( mLayer->svgFilePath() );
2332  mRotationSpinBox->blockSignals( true );
2333  mRotationSpinBox->setValue( mLayer->angle() );
2334  mRotationSpinBox->blockSignals( false );
2335  mTextureWidthUnitWidget->blockSignals( true );
2336  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2337  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2338  mTextureWidthUnitWidget->blockSignals( false );
2339  mSvgStrokeWidthUnitWidget->blockSignals( true );
2340  mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2341  mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2342  mSvgStrokeWidthUnitWidget->blockSignals( false );
2343  mChangeColorButton->blockSignals( true );
2344  mChangeColorButton->setColor( mLayer->svgFillColor() );
2345  mChangeColorButton->blockSignals( false );
2346  mChangeStrokeColorButton->blockSignals( true );
2347  mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2348  mChangeStrokeColorButton->blockSignals( false );
2349  mStrokeWidthSpinBox->blockSignals( true );
2350  mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2351  mStrokeWidthSpinBox->blockSignals( false );
2352  }
2353  updateParamGui( false );
2354 
2361 }
2362 
2364 {
2365  return mLayer;
2366 }
2367 
2368 void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2369 {
2370  if ( mLayer )
2371  {
2372  mLayer->setPatternWidth( d );
2373  emit changed();
2374  }
2375 }
2376 
2377 void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2378 {
2379  if ( !mLayer )
2380  {
2381  return;
2382  }
2383 
2384  mLayer->setSvgFilePath( text );
2385  updateParamGui();
2386  emit changed();
2387 }
2388 
2389 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex &item )
2390 {
2391  QString file = item.data( Qt::UserRole ).toString();
2392  mLayer->setSvgFilePath( file );
2393  whileBlocking( mSvgSourceLineEdit )->setSource( file );
2394 
2395  updateParamGui();
2396  emit changed();
2397 }
2398 
2400 {
2401  QAbstractItemModel *oldModel = mSvgTreeView->model();
2402  QgsSvgSelectorGroupsModel *g = new QgsSvgSelectorGroupsModel( mSvgTreeView );
2403  mSvgTreeView->setModel( g );
2404  delete oldModel;
2405 
2406  // Set the tree expanded at the first level
2407  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2408  for ( int i = 0; i < rows; i++ )
2409  {
2410  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2411  }
2412 
2413  oldModel = mSvgListView->model();
2414  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView );
2415  mSvgListView->setModel( m );
2416  delete oldModel;
2417 }
2418 
2419 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex &idx )
2420 {
2421  QString path = idx.data( Qt::UserRole + 1 ).toString();
2422 
2423  QAbstractItemModel *oldModel = mSvgListView->model();
2424  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, path );
2425  mSvgListView->setModel( m );
2426  delete oldModel;
2427 
2428  connect( mSvgListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::setFile );
2429 }
2430 
2431 
2432 void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2433 {
2434  if ( mLayer )
2435  {
2436  mLayer->setAngle( d );
2437  emit changed();
2438  }
2439 }
2440 
2442 {
2443  //activate gui for svg parameters only if supported by the svg file
2444  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2445  QColor defaultFill, defaultStroke;
2446  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2447  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2448  QgsApplication::svgCache()->containsParams( mSvgSourceLineEdit->source(), hasFillParam, hasDefaultFillColor, defaultFill,
2449  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2450  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2451  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2452  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2453  if ( resetValues )
2454  {
2455  QColor fill = mChangeColorButton->color();
2456  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2457  if ( hasDefaultFillColor )
2458  {
2459  fill = defaultFill;
2460  }
2461  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2462  mChangeColorButton->setColor( fill );
2463  }
2464  mChangeColorButton->setEnabled( hasFillParam );
2465  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2466  if ( resetValues )
2467  {
2468  QColor stroke = mChangeStrokeColorButton->color();
2469  double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2470  if ( hasDefaultStrokeColor )
2471  {
2472  stroke = defaultStroke;
2473  }
2474  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
2475  mChangeStrokeColorButton->setColor( stroke );
2476  }
2477  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2478  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2479  if ( hasDefaultStrokeWidth && resetValues )
2480  {
2481  mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
2482  }
2483  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2484 }
2485 
2486 void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2487 {
2488  if ( !mLayer )
2489  {
2490  return;
2491  }
2492 
2493  mLayer->setSvgFillColor( color );
2494  emit changed();
2495 }
2496 
2497 void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2498 {
2499  if ( !mLayer )
2500  {
2501  return;
2502  }
2503 
2504  mLayer->setSvgStrokeColor( color );
2505  emit changed();
2506 }
2507 
2508 void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2509 {
2510  if ( mLayer )
2511  {
2512  mLayer->setSvgStrokeWidth( d );
2513  emit changed();
2514  }
2515 }
2516 
2517 void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
2518 {
2519  if ( mLayer )
2520  {
2521  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2522  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2523  emit changed();
2524  }
2525 }
2526 
2527 void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
2528 {
2529  if ( mLayer )
2530  {
2531  mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
2532  mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
2533  emit changed();
2534  }
2535 }
2536 
2538 
2540  QgsSymbolLayerWidget( parent, vl )
2541 {
2542  setupUi( this );
2543  connect( mAngleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
2544  connect( mDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
2545  connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
2546  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
2547  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
2552  mOffsetSpinBox->setClearValue( 0 );
2553  mAngleSpinBox->setClearValue( 0 );
2554 }
2555 
2557 {
2558  if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
2559  {
2560  return;
2561  }
2562 
2563  QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
2564  if ( patternLayer )
2565  {
2566  mLayer = patternLayer;
2567  mAngleSpinBox->blockSignals( true );
2568  mAngleSpinBox->setValue( mLayer->lineAngle() );
2569  mAngleSpinBox->blockSignals( false );
2570  mDistanceSpinBox->blockSignals( true );
2571  mDistanceSpinBox->setValue( mLayer->distance() );
2572  mDistanceSpinBox->blockSignals( false );
2573  mOffsetSpinBox->blockSignals( true );
2574  mOffsetSpinBox->setValue( mLayer->offset() );
2575  mOffsetSpinBox->blockSignals( false );
2576 
2577  //units
2578  mDistanceUnitWidget->blockSignals( true );
2579  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2580  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2581  mDistanceUnitWidget->blockSignals( false );
2582  mOffsetUnitWidget->blockSignals( true );
2583  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2584  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2585  mOffsetUnitWidget->blockSignals( false );
2586  }
2587 
2590 }
2591 
2593 {
2594  return mLayer;
2595 }
2596 
2597 void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
2598 {
2599  if ( mLayer )
2600  {
2601  mLayer->setLineAngle( d );
2602  emit changed();
2603  }
2604 }
2605 
2606 void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
2607 {
2608  if ( mLayer )
2609  {
2610  mLayer->setDistance( d );
2611  emit changed();
2612  }
2613 }
2614 
2615 void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
2616 {
2617  if ( mLayer )
2618  {
2619  mLayer->setOffset( d );
2620  emit changed();
2621  }
2622 }
2623 
2624 void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
2625 {
2626  if ( mLayer )
2627  {
2628  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2629  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2630  emit changed();
2631  }
2632 }
2633 
2634 void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
2635 {
2636  if ( mLayer )
2637  {
2638  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2639  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2640  emit changed();
2641  }
2642 }
2643 
2645 
2647  QgsSymbolLayerWidget( parent, vl )
2648 {
2649  setupUi( this );
2650  connect( mHorizontalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
2651  connect( mVerticalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
2652  connect( mHorizontalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
2653  connect( mVerticalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
2654  connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
2655  connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
2656  connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
2657  connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
2666 }
2667 
2668 
2670 {
2671  if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
2672  {
2673  return;
2674  }
2675 
2676  mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
2677  mHorizontalDistanceSpinBox->blockSignals( true );
2678  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2679  mHorizontalDistanceSpinBox->blockSignals( false );
2680  mVerticalDistanceSpinBox->blockSignals( true );
2681  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2682  mVerticalDistanceSpinBox->blockSignals( false );
2683  mHorizontalDisplacementSpinBox->blockSignals( true );
2684  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2685  mHorizontalDisplacementSpinBox->blockSignals( false );
2686  mVerticalDisplacementSpinBox->blockSignals( true );
2687  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2688  mVerticalDisplacementSpinBox->blockSignals( false );
2689 
2690  mHorizontalDistanceUnitWidget->blockSignals( true );
2691  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2692  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2693  mHorizontalDistanceUnitWidget->blockSignals( false );
2694  mVerticalDistanceUnitWidget->blockSignals( true );
2695  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2696  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2697  mVerticalDistanceUnitWidget->blockSignals( false );
2698  mHorizontalDisplacementUnitWidget->blockSignals( true );
2699  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2700  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2701  mHorizontalDisplacementUnitWidget->blockSignals( false );
2702  mVerticalDisplacementUnitWidget->blockSignals( true );
2703  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2704  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2705  mVerticalDisplacementUnitWidget->blockSignals( false );
2706 
2707  registerDataDefinedButton( mHorizontalDistanceDDBtn, QgsSymbolLayer::PropertyDistanceX );
2709  registerDataDefinedButton( mHorizontalDisplacementDDBtn, QgsSymbolLayer::PropertyDisplacementX );
2711 }
2712 
2714 {
2715  return mLayer;
2716 }
2717 
2718 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
2719 {
2720  if ( mLayer )
2721  {
2722  mLayer->setDistanceX( d );
2723  emit changed();
2724  }
2725 }
2726 
2727 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
2728 {
2729  if ( mLayer )
2730  {
2731  mLayer->setDistanceY( d );
2732  emit changed();
2733  }
2734 }
2735 
2736 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
2737 {
2738  if ( mLayer )
2739  {
2740  mLayer->setDisplacementX( d );
2741  emit changed();
2742  }
2743 }
2744 
2745 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
2746 {
2747  if ( mLayer )
2748  {
2749  mLayer->setDisplacementY( d );
2750  emit changed();
2751  }
2752 }
2753 
2754 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
2755 {
2756  if ( mLayer )
2757  {
2758  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2759  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2760  emit changed();
2761  }
2762 }
2763 
2764 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
2765 {
2766  if ( mLayer )
2767  {
2768  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2769  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2770  emit changed();
2771  }
2772 }
2773 
2774 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
2775 {
2776  if ( mLayer )
2777  {
2778  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2779  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2780  emit changed();
2781  }
2782 }
2783 
2784 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
2785 {
2786  if ( mLayer )
2787  {
2788  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2789  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2790  emit changed();
2791  }
2792 }
2793 
2795 
2797  : QgsSymbolLayerWidget( parent, vl )
2798 {
2799  mLayer = nullptr;
2800 
2801  setupUi( this );
2802  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2803  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2804  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2805  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2806  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2807  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2815  scrollArea->setWidget( widgetChar );
2816 
2817  btnColor->setAllowOpacity( true );
2818  btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
2819  btnColor->setContext( QStringLiteral( "symbology" ) );
2820  btnStrokeColor->setAllowOpacity( true );
2821  btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
2822  btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
2823 
2824  spinOffsetX->setClearValue( 0.0 );
2825  spinOffsetY->setClearValue( 0.0 );
2826  spinAngle->setClearValue( 0.0 );
2827 
2828  //make a temporary symbol for the size assistant preview
2829  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2830 
2831  if ( vectorLayer() )
2832  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
2833 
2834  connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
2835  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
2836  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
2839  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
2840  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
2841  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
2842  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
2844  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
2845 }
2846 
2848 {
2849  if ( layer->layerType() != QLatin1String( "FontMarker" ) )
2850  return;
2851 
2852  // layer type is correct, we can do the cast
2853  mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
2854 
2855  QFont layerFont( mLayer->fontFamily() );
2856  // set values
2857  whileBlocking( cboFont )->setCurrentFont( layerFont );
2858  whileBlocking( spinSize )->setValue( mLayer->size() );
2859  whileBlocking( btnColor )->setColor( mLayer->color() );
2860  whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
2861  whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
2862  whileBlocking( spinAngle )->setValue( mLayer->angle() );
2863 
2864  widgetChar->blockSignals( true );
2865  widgetChar->setFont( layerFont );
2867  widgetChar->blockSignals( false );
2868 
2869  //block
2870  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
2871  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
2872 
2873  mSizeUnitWidget->blockSignals( true );
2874  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2875  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2876  mSizeUnitWidget->blockSignals( false );
2877 
2878  mStrokeWidthUnitWidget->blockSignals( true );
2879  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2880  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2881  mStrokeWidthUnitWidget->blockSignals( false );
2882 
2883  mOffsetUnitWidget->blockSignals( true );
2884  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2885  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2886  mOffsetUnitWidget->blockSignals( false );
2887 
2888  whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
2889 
2890  //anchor points
2891  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2892  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
2893 
2904 
2905  updateAssistantSymbol();
2906 }
2907 
2909 {
2910  return mLayer;
2911 }
2912 
2914 {
2915  mLayer->setFontFamily( font.family() );
2916  widgetChar->setFont( font );
2917  emit changed();
2918 }
2919 
2920 void QgsFontMarkerSymbolLayerWidget::setColor( const QColor &color )
2921 {
2922  mLayer->setColor( color );
2923  emit changed();
2924 }
2925 
2927 {
2928  mLayer->setStrokeColor( color );
2929  emit changed();
2930 }
2931 
2933 {
2934  mLayer->setSize( size );
2935  //widgetChar->updateSize(size);
2936  emit changed();
2937 }
2938 
2940 {
2941  mLayer->setAngle( angle );
2942  emit changed();
2943 }
2944 
2946 {
2947  mLayer->setCharacter( chr );
2948  emit changed();
2949 }
2950 
2951 void QgsFontMarkerSymbolLayerWidget::setOffset()
2952 {
2953  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2954  emit changed();
2955 }
2956 
2957 void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
2958 {
2959  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
2960  emit changed();
2961 }
2962 
2963 void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2964 {
2965  if ( mLayer )
2966  {
2967  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2968  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2969  emit changed();
2970  }
2971 }
2972 
2973 void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2974 {
2975  if ( mLayer )
2976  {
2977  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2978  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2979  emit changed();
2980  }
2981 }
2982 
2983 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2984 {
2985  if ( mLayer )
2986  {
2987  mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
2988  mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2989  emit changed();
2990  }
2991 }
2992 
2993 void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2994 {
2995  if ( mLayer )
2996  {
2998  emit changed();
2999  }
3000 }
3001 
3002 void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3003 {
3004  if ( mLayer )
3005  {
3007  emit changed();
3008  }
3009 }
3010 
3011 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3012 {
3013  if ( mLayer )
3014  {
3015  mLayer->setStrokeWidth( d );
3016  emit changed();
3017  }
3018 }
3019 
3020 void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3021 {
3022  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
3023  {
3024  mAssistantPreviewSymbol->deleteSymbolLayer( i );
3025  }
3026  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3028  if ( ddSize )
3029  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3030 }
3031 
3033 
3034 
3036  : QgsSymbolLayerWidget( parent, vl )
3037 {
3038  mLayer = nullptr;
3039 
3040  setupUi( this );
3041  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3042  connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3043 }
3044 
3046 {
3047  if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3048  return;
3049 
3050  // layer type is correct, we can do the cast
3051  mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3052 
3053  // set values
3054  whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3055  whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3056 }
3057 
3059 {
3060  return mLayer;
3061 }
3062 
3063 void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3064 {
3065  mLayer->setPointOnSurface( state == Qt::Checked );
3066  emit changed();
3067 }
3068 
3069 void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3070 {
3071  mLayer->setPointOnAllParts( state == Qt::Checked );
3072  emit changed();
3073 }
3074 
3076 
3078  : QgsSymbolLayerWidget( parent, vl )
3079 {
3080  mLayer = nullptr;
3081  setupUi( this );
3082  connect( mBrowseToolButton, &QToolButton::clicked, this, &QgsRasterFillSymbolLayerWidget::mBrowseToolButton_clicked );
3083  connect( mImageLineEdit, &QLineEdit::editingFinished, this, &QgsRasterFillSymbolLayerWidget::mImageLineEdit_editingFinished );
3084  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3085  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
3086  connect( mWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed );
3087  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged );
3088 
3093 
3094  mSpinOffsetX->setClearValue( 0.0 );
3095  mSpinOffsetY->setClearValue( 0.0 );
3096  mRotationSpinBox->setClearValue( 0.0 );
3097 
3098  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
3099  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
3100  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
3101  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
3102 }
3103 
3104 
3106 {
3107  if ( !layer )
3108  {
3109  return;
3110  }
3111 
3112  if ( layer->layerType() != QLatin1String( "RasterFill" ) )
3113  {
3114  return;
3115  }
3116 
3117  mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
3118  if ( !mLayer )
3119  {
3120  return;
3121  }
3122 
3123  mImageLineEdit->blockSignals( true );
3124  mImageLineEdit->setText( mLayer->imageFilePath() );
3125  mImageLineEdit->blockSignals( false );
3126 
3127  cboCoordinateMode->blockSignals( true );
3128  switch ( mLayer->coordinateMode() )
3129  {
3131  cboCoordinateMode->setCurrentIndex( 1 );
3132  break;
3134  default:
3135  cboCoordinateMode->setCurrentIndex( 0 );
3136  break;
3137  }
3138  cboCoordinateMode->blockSignals( false );
3139  mOpacityWidget->blockSignals( true );
3140  mOpacityWidget->setOpacity( mLayer->opacity() );
3141  mOpacityWidget->blockSignals( false );
3142  mRotationSpinBox->blockSignals( true );
3143  mRotationSpinBox->setValue( mLayer->angle() );
3144  mRotationSpinBox->blockSignals( false );
3145 
3146  mSpinOffsetX->blockSignals( true );
3147  mSpinOffsetX->setValue( mLayer->offset().x() );
3148  mSpinOffsetX->blockSignals( false );
3149  mSpinOffsetY->blockSignals( true );
3150  mSpinOffsetY->setValue( mLayer->offset().y() );
3151  mSpinOffsetY->blockSignals( false );
3152  mOffsetUnitWidget->blockSignals( true );
3153  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3154  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3155  mOffsetUnitWidget->blockSignals( false );
3156 
3157  mWidthSpinBox->blockSignals( true );
3158  mWidthSpinBox->setValue( mLayer->width() );
3159  mWidthSpinBox->blockSignals( false );
3160  mWidthUnitWidget->blockSignals( true );
3161  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
3162  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
3163  mWidthUnitWidget->blockSignals( false );
3164  updatePreviewImage();
3165 
3170 }
3171 
3173 {
3174  return mLayer;
3175 }
3176 
3177 void QgsRasterFillSymbolLayerWidget::mBrowseToolButton_clicked()
3178 {
3179  QgsSettings s;
3180  QString openDir;
3181  QString lineEditText = mImageLineEdit->text();
3182  if ( !lineEditText.isEmpty() )
3183  {
3184  QFileInfo openDirFileInfo( lineEditText );
3185  openDir = openDirFileInfo.path();
3186  }
3187 
3188  if ( openDir.isEmpty() )
3189  {
3190  openDir = s.value( QStringLiteral( "/UI/lastRasterFillImageDir" ), QDir::homePath() ).toString();
3191  }
3192 
3193  //show file dialog
3194  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select Image File" ), openDir );
3195  if ( !filePath.isNull() )
3196  {
3197  //check if file exists
3198  QFileInfo fileInfo( filePath );
3199  if ( !fileInfo.exists() || !fileInfo.isReadable() )
3200  {
3201  QMessageBox::critical( nullptr, QStringLiteral( "Select Image File" ), QStringLiteral( "Error, file does not exist or is not readable." ) );
3202  return;
3203  }
3204 
3205  s.setValue( QStringLiteral( "/UI/lastRasterFillImageDir" ), fileInfo.absolutePath() );
3206  mImageLineEdit->setText( filePath );
3207  mImageLineEdit_editingFinished();
3208  }
3209 }
3210 
3211 void QgsRasterFillSymbolLayerWidget::mImageLineEdit_editingFinished()
3212 {
3213  if ( !mLayer )
3214  {
3215  return;
3216  }
3217 
3218  QFileInfo fi( mImageLineEdit->text() );
3219  if ( !fi.exists() )
3220  {
3221  QUrl url( mImageLineEdit->text() );
3222  if ( !url.isValid() )
3223  {
3224  return;
3225  }
3226  }
3227 
3228  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3229  mLayer->setImageFilePath( mImageLineEdit->text() );
3230  updatePreviewImage();
3231  QApplication::restoreOverrideCursor();
3232 
3233  emit changed();
3234 }
3235 
3236 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
3237 {
3238  switch ( index )
3239  {
3240  case 0:
3241  //feature coordinate mode
3243  break;
3244  case 1:
3245  //viewport coordinate mode
3247  break;
3248  }
3249 
3250  emit changed();
3251 }
3252 
3253 void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
3254 {
3255  if ( !mLayer )
3256  {
3257  return;
3258  }
3259 
3260  mLayer->setOpacity( value );
3261  emit changed();
3262  updatePreviewImage();
3263 }
3264 
3265 void QgsRasterFillSymbolLayerWidget::offsetChanged()
3266 {
3267  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
3268  emit changed();
3269 }
3270 
3271 void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3272 {
3273  if ( !mLayer )
3274  {
3275  return;
3276  }
3277  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3278  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3279  emit changed();
3280 }
3281 
3282 void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
3283 {
3284  if ( mLayer )
3285  {
3286  mLayer->setAngle( d );
3287  emit changed();
3288  }
3289 }
3290 
3291 void QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed()
3292 {
3293  if ( !mLayer )
3294  {
3295  return;
3296  }
3297  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
3298  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3299  emit changed();
3300 }
3301 
3302 void QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged( double d )
3303 {
3304  if ( !mLayer )
3305  {
3306  return;
3307  }
3308  mLayer->setWidth( d );
3309  emit changed();
3310 }
3311 
3312 
3313 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
3314 {
3315  if ( !mLayer )
3316  {
3317  return;
3318  }
3319 
3320  QImage image( mLayer->imageFilePath() );
3321  if ( image.isNull() )
3322  {
3323  mLabelImagePreview->setPixmap( QPixmap() );
3324  return;
3325  }
3326 
3327  if ( image.height() > 150 || image.width() > 150 )
3328  {
3329  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
3330  }
3331 
3332  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3333  previewImage.fill( Qt::transparent );
3334  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3335  QPainter p;
3336  p.begin( &previewImage );
3337  //draw a checkerboard background
3338  uchar pixDataRGB[] = { 150, 150, 150, 150,
3339  100, 100, 100, 150,
3340  100, 100, 100, 150,
3341  150, 150, 150, 150
3342  };
3343  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3344  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3345  QBrush checkerBrush;
3346  checkerBrush.setTexture( pix );
3347  p.fillRect( imageRect, checkerBrush );
3348 
3349  if ( mLayer->opacity() < 1.0 )
3350  {
3351  p.setOpacity( mLayer->opacity() );
3352  }
3353 
3354  p.drawImage( imageRect.left(), imageRect.top(), image );
3355  p.end();
3356  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3357 }
3358 
3359 
3361  : QgsSymbolLayerWidget( parent, vl )
3362 
3363 {
3364  setupUi( this );
3365  modificationExpressionSelector->setMultiLine( true );
3366  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
3367  modificationExpressionSelector->registerExpressionContextGenerator( this );
3368  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon / MultiPolygon" ), QgsSymbol::Fill );
3369  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "LineString / MultiLineString" ), QgsSymbol::Line );
3370  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point / MultiPoint" ), QgsSymbol::Marker );
3371  connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
3372  connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
3373 }
3374 
3376 {
3377  mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
3378  modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
3379  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
3380 }
3381 
3383 {
3384  return mLayer;
3385 }
3386 
3387 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
3388 {
3389  mLayer->setGeometryExpression( string );
3390 
3391  emit changed();
3392 }
3393 
3394 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
3395 {
3396  mLayer->setSymbolType( static_cast<QgsSymbol::SymbolType>( cbxGeometryType->currentData().toInt() ) );
3397 
3398  emit symbolChanged();
3399 }
void setOffset(QPointF offset)
Sets the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered marker...
const QgsMapUnitScale & intervalMapUnitScale() const
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern&#39;s stroke.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
static QgsSvgCache * svgCache()
Returns the application&#39;s SVG cache, used for caching SVG images and handling parameter replacement w...
double interval() const
Returns the interval between individual markers.
QgsUnitTypes::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
Meters value as Map units.
Definition: qgsunittypes.h:119
void setDistance(double d)
Sets the distance between lines in the fill pattern.
Single variable definition for use within a QgsExpressionContextScope.
RenderRingFilter ringFilter() const
Returns the line symbol layer&#39;s ring filter, which controls which rings are rendered when the line sy...
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
Gradient reference point 1 is centroid.
const QgsMapUnitScale & displacementYMapUnitScale() const
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsMarkerLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsMarkerLineSymbolLayerWidget.
void setColorStroke(const QColor &color)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s offset.
void setMapUnitScale(const QgsMapUnitScale &scale) override
void setSymbolLayer(QgsSymbolLayer *layer) override
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setColorFill(const QColor &color)
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker&#39;s stroke join style (e.g., miter, bevel, etc).
QgsSymbolLayer * symbolLayer() override
QgsGradientFillSymbolLayer * mLayer
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the width of the SVG images in the pattern.
QColor strokeColor() const override
Gets stroke color.
void setSymbolLayer(QgsSymbolLayer *layer) override
Gradient reference point 1 x.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the fill&#39;s offset.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
QgsSymbolLayer * symbolLayer() override
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern&#39;s width.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point...
void setUseCustomDashPattern(bool b)
A model for displaying SVG files with a preview icon.
void setSymbolLayer(QgsSymbolLayer *layer) override
const QgsMapUnitScale & displacementXMapUnitScale() const
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:152
This class is a composition of two QSettings instances:
Definition: qgssettings.h:58
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
QString imageFilePath() const
The path to the raster image used for the fill.
QPointF offset() const
Returns the offset for the shapeburst fill.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker&#39;s stroke.
void setSymbolLayer(QgsSymbolLayer *layer) override
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker&#39;s stroke style (e.g., solid, dashed, etc)
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke...
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
virtual void setWidth(double width)
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
void colorRampChanged()
Emitted whenever a new color ramp is set for the button.
const QgsMapUnitScale & offsetMapUnitScale() const
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
Qt::PenJoinStyle penJoinStyle() const
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern&#39;s offset.
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
A symbol fill consisting of repeated parallel lines.
QgsSimpleFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleFillSymbolLayerWidget.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol&#39;s size.
QString geometryExpression() const
Gets the expression to generate this geometry.
void lockChanged(bool locked)
Emitted whenever the lock state changes.
double angle() const
QgsLinePatternFillSymbolLayer * mLayer
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image&#39;s width.
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
QgsGradientFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGradientFillSymbolLayerWidget.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
Render both exterior and interior rings.
QgsSymbolLayer * symbolLayer() override
void setAngle(double angle)
Abstract base class for color ramps.
Definition: qgscolorramp.h:31
void setRotateMarker(bool rotate)
Shall the marker be rotated.
void setSymbolLayer(QgsSymbolLayer *layer) override
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
A widget for displaying characters available in a preset font, and allowing users to select an indivi...
void setStrokeColor(const QColor &color) override
Sets the marker&#39;s stroke color.
void setCharacter(QChar character)
Sets the currently selected character in the widget.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
void setColor(const QColor &color)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeWidth(double w)
Sets the width of the marker&#39;s stroke.
QgsSymbolLayer * symbolLayer() override
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol&#39;s offset.
void setStrokeWidth(double width)
Set&#39;s the marker&#39;s stroke width.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill&#39;s offset.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol&#39;s offset.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line&#39;s offset.
Line symbol.
Definition: qgssymbol.h:86
QColor strokeColor() const override
Returns the marker&#39;s stroke color.
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for markers...
QgsCentroidFillSymbolLayer * mLayer
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
QgsSVGFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSVGFillSymbolLayerWidget.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern&#39;s stroke.
static QString encodeShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Encodes a shape to its string representation.
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features...
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
Tiling is based on complete map viewport.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:183
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
virtual double width() const
bool rotateMarker() const
Shall the marker be rotated.
Name, eg shape name for simple markers.
void setStrokeWidth(double strokeWidth)
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line&#39;s width.
Gradient reference point 2 y.
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
QgsShapeburstFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsShapeburstFillSymbolLayerWidget.
QString path() const
Returns the marker SVG path.
void setSymbolLayer(QgsSymbolLayer *layer) override
QColor strokeColor() const override
Gets stroke color.
void setGradientType(GradientType gradientType)
void setInterval(double interval)
Sets the interval between individual markers.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
static QIcon symbolLayerPreviewIcon(QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to an icon.
double strokeWidth() const
Returns the width of the marker&#39;s stroke.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern&#39;s line offset.
void setPath(const QString &path)
Set the marker SVG path.
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for lengths used in the custom dash pattern.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern&#39;s offset.
void setCoordinateMode(FillCoordinateMode mode)
Set the coordinate mode for fill.
virtual void setColor(const QColor &color)
The fill color.
void setOffset(QPointF offset)
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void setSymbolLayer(QgsSymbolLayer *layer) override
void setSymbolLayer(QgsSymbolLayer *layer) override
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
A dialog to create a new auxiliary layer.
void setField(const QString &field)
Sets the field name the property references.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
const QgsMapUnitScale & distanceMapUnitScale() const
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
A class for filling symbols with a repeated raster image.
void setPlacement(Placement p)
The placement of the markers.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
A cross platform button subclass used to represent a locked / unlocked ratio state.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
A dialog to enter a custom dash space pattern for lines.
A button for controlling property overrides which may apply to a widget.
void setStrokeColor(const QColor &color) override
Set stroke color.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsSymbolLayer * symbolLayer() override
QgsMarkerLineSymbolLayer * mLayer
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
QgsSimpleLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleLineSymbolLayerWidget.
void setColor(const QColor &color) override
The fill color.
QgsSimpleFillSymbolLayer * mLayer
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line&#39;s width.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker&#39;s stroke.
QVector< qreal > customDashVector() const
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
QgsCentroidFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsCentroidFillSymbolLayerWidget.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
double size() const
Returns the symbol size.
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1...
Render the interior rings only.
virtual QgsSymbolLayer * symbolLayer()=0
void setSymbolLayer(QgsSymbolLayer *layer) override
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker&#39;s stroke.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image&#39;s width.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer&#39;s property collection, used for data defined overrides...
void setSize(double size)
Sets the symbol size.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
points (e.g., for font sizes)
Definition: qgsunittypes.h:117
const QgsMapUnitScale & offsetMapUnitScale() const
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol&#39;s size.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill&#39;s offset.
QgsSvgMarkerSymbolLayer * mLayer
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QgsShapeburstFillSymbolLayer * mLayer
void setStrokeStyle(Qt::PenStyle strokeStyle)
virtual QColor color() const
The fill color.
QgsSymbolLayer * symbolLayer() override
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QColor fillColor() const override
Gets fill color.
Filename, eg for svg files.
QgsFilledMarkerSymbolLayer * mLayer
void setSymbolType(QgsSymbol::SymbolType symbolType)
Set the type of symbol which should be created.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
void setSymbolLayer(QgsSymbolLayer *layer) override
Shapeburst fill from edge distance.
void setCharacter(QChar ch)
Sets the character used when rendering points.
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
QgsUnitTypes::RenderUnit offsetUnit() const
Qt::PenJoinStyle penJoinStyle() const
Character, eg for font marker symbol layers.
double offset() const
Qt::PenJoinStyle penJoinStyle() const
Returns the marker&#39;s stroke join style (e.g., miter, bevel, etc).
QgsPointPatternFillSymbolLayer * mLayer
void setPenJoinStyle(Qt::PenJoinStyle style)
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
Definition: qgsproperty.h:229
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
QgsRasterFillSymbolLayer * mLayer
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for markers...
QgsSymbolLayer * symbolLayer() override
Tiling is based on feature bounding box.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
void setOffset(QPointF offset)
Sets the offset for the fill.
QgsSymbolLayer * symbolLayer() override
void setPenStyle(Qt::PenStyle style)
void setSymbolLayer(QgsSymbolLayer *layer) override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsGeometryGeneratorSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGeometryGeneratorSymbolLayerWidget.
void setColor(const QColor &color)
void setMapUnitScale(const QgsMapUnitScale &scale) override
QgsSvgMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSvgMarkerSymbolLayerWidget.
Qt::PenStyle strokeStyle() const
Returns the marker&#39;s stroke style (e.g., solid, dashed, etc)
Definition for a property.
Definition: qgsproperty.h:46
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the stroke width.
Gradient reference point 1 y.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
void setFont(const QFont &font)
Sets the font to show in the widget.
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for markers.
void setOffset(QPointF offset)
Offset for gradient fill.
VerticalAnchorPoint
Symbol vertical anchor points.
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setPenCapStyle(Qt::PenCapStyle style)
const double DEFAULT_POINT_SIZE
Magic number that determines the default point size for point symbols.
Definition: qgis.h:552
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth) const
Tests if an svg file contains parameters for fill, stroke color, stroke width.
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for markers.
void sourceChanged(const QString &source)
Emitted whenever the SVG source is changed in the widget.
QgsSimpleMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleMarkerSymbolLayerWidget.
Qt::BrushStyle brushStyle() const
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
GradientType gradientType() const
Type of gradient, e.g., linear or radial.
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern&#39;s line distance.
void colorChanged(const QColor &color)
Is emitted whenever a new color is set for the button.
void changed()
Emitted when property definition changes.
A model for displaying SVG search paths.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key)
Registers a data defined override button.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s size.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
Marker symbol.
Definition: qgssymbol.h:85
A class for filling symbols with a repeated SVG file.
void setMapUnitScale(const QgsMapUnitScale &scale) override
Stroke style (eg solid, dashed)
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker&#39;s stroke.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
Fill symbol.
Definition: qgssymbol.h:87
QChar character() const
Returns the character used when rendering points.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:225
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill&#39;s offset.
QgsSimpleLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
QgsPointPatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsPointPatternFillSymbolLayerWidget.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
void setGradientColorType(GradientColorType gradientColorType)
QgsFilledMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFilledMarkerSymbolLayerWidget.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0...
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image&#39;s width.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
void updateParamGui(bool resetValues=true)
Enables or disables svg fill color, stroke color and stroke width based on whether the svg file suppo...
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol&#39;s size.
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
const QgsMapUnitScale & distanceXMapUnitScale() const
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern&#39;s width.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
void setSvgFilePath(const QString &svgPath)
Sets the path to the SVG file to render in the fill.
QgsSymbolLayer * symbolLayer() override
Qt::PenStyle penStyle() const
Qt::PenStyle strokeStyle() const
const QgsMapUnitScale & offsetMapUnitScale() const
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill&#39;s stroke.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
double strokeWidth() const
Returns the marker&#39;s stroke width.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
int propertyKey() const
Returns the property key linked to the button.
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between markers.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line&#39;s offset.
void setRingFilter(QgsLineSymbolLayer::RenderRingFilter filter)
Sets the line symbol layer&#39;s ring filter, which controls which rings are rendered when the line symbo...
void setStrokeColor(const QColor &color)
const QgsMapUnitScale & distanceYMapUnitScale() const
QColor fillColor() const override
Gets fill color.
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFontMarkerSymbolLayerWidget.
void setColorStroke(const QColor &color)
Set stroke color.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image&#39;s width.
QgsLinePatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLinePatternFillSymbolLayerWidget.
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
Secondary color (eg for gradient fills)
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
double maxDistance() const
Returns the maximum distance from the shape&#39;s boundary which is shaded.
void setCustomDashVector(const QVector< qreal > &vector)
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon&#39;s boundary.
QgsRasterFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterFillSymbolLayerWidget.
double opacity() const
Returns the opacity for the raster image used in the fill.
void setColor2(const QColor &color2)
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setAngle(double angle)
Sets the rotation angle for the marker.
const QgsMapUnitScale & widthMapUnitScale() const
QgsSimpleLineSymbolLayer * mLayer
const QgsMapUnitScale & customDashPatternMapUnitScale() const
QgsSymbolLayer * symbolLayer() override
void setMapUnitScale(const QgsMapUnitScale &scale) override
Render the exterior ring only.
void setBrushStyle(Qt::BrushStyle style)
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
void setFillColor(const QColor &color) override
Set fill color.
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
QColor strokeColor() const override
Gets stroke color.
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the marker placement.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
QgsFontMarkerSymbolLayer * mLayer
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
Shapeburst blur radius.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
void setOffset(double offset)
Sets the offset distance for lines within the fill, which is the distance to offset the parallel line...
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill&#39;s stroke.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
void setSvgStrokeColor(const QColor &c)
Sets the stroke color used for rendering the SVG content.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Units for gradient fill offset.
A widget displaying a combobox allowing the user to choose between various display units...
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern&#39;s line offset.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
double distance() const
Returns the distance between lines in the fill pattern.
QPointF offset() const
Returns the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered mar...
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
Placement placement() const
The placement of the markers.
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
Fill style (eg solid, dots)
Represents a vector layer which manages a vector based data sets.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
Qt::PenCapStyle penCapStyle() const
void updateFieldLists()
Updates list of fields.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol&#39;s offset.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
void setSymbolLayer(QgsSymbolLayer *layer) override
void applyColorRamp()
Applies the color ramp passed on by the color ramp button.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout)...
double width() const
Returns the width used for scaling the image used in the fill.
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between markers.
const QgsMapUnitScale & offsetMapUnitScale() const
Gradient reference point 2 is centroid.
void setGradientSpread(GradientSpread gradientSpread)
void setGuiForSvg(const QgsSvgMarkerSymbolLayer *layer)
void characterSelected(QChar character)
Emitted when a character is selected in the widget.
QgsSimpleMarkerSymbolLayer * mLayer
void setCoordinateMode(GradientCoordinateMode coordinateMode)
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
QgsPropertyDefinition propertyDefinition() const
Returns the underlying property definition.
Gradient reference point 2 x.
QgsSVGFillSymbolLayer * mLayer
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern&#39;s line distance.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
Property
Data definable properties.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsSymbolLayer * symbolLayer() override
void setPenJoinStyle(Qt::PenJoinStyle style)
A dialog to create a new auxiliary field.
void setPointOnSurface(bool pointOnSurface)
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
void setOffset(double offset)
Horizontal distance between points.
QPointF offset() const
Returns the offset for the fill.
virtual QString layerType() const =0
Returns a string that represents this layer type.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
Vertical distance between points.