QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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  int size = lstNames->iconSize().width();
904  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXX" ) ) ) ) );
905  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
906  lstNames->setIconSize( QSize( size, size ) );
907 
908  double markerSize = size * 0.8;
910  for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
911  {
912  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
914  lyr->setColor( QColor( 200, 200, 200 ) );
915  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
916  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
917  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
918  item->setData( Qt::UserRole, static_cast< int >( shape ) );
919  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
920  delete lyr;
921  }
922  // show at least 3 rows
923  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
924 
925  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
926  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
927  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
928  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
929  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
930  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
931 }
932 
934 {
935  if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
936  return;
937 
938  // layer type is correct, we can do the cast
939  mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
940 
941  // set values
943  for ( int i = 0; i < lstNames->count(); ++i )
944  {
945  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
946  {
947  lstNames->setCurrentRow( i );
948  break;
949  }
950  }
951  whileBlocking( spinSize )->setValue( mLayer->size() );
952  whileBlocking( spinAngle )->setValue( mLayer->angle() );
953  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
954  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
955 
956  mSizeUnitWidget->blockSignals( true );
957  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
958  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
959  mSizeUnitWidget->blockSignals( false );
960  mOffsetUnitWidget->blockSignals( true );
961  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
962  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
963  mOffsetUnitWidget->blockSignals( false );
964 
965  //anchor points
966  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
967  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
968 
975 
976  updateAssistantSymbol();
977 }
978 
980 {
981  return mLayer;
982 }
983 
984 void QgsFilledMarkerSymbolLayerWidget::setShape()
985 {
986  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
987  emit changed();
988 }
989 
990 void QgsFilledMarkerSymbolLayerWidget::setSize()
991 {
992  mLayer->setSize( spinSize->value() );
993  emit changed();
994 }
995 
996 void QgsFilledMarkerSymbolLayerWidget::setAngle()
997 {
998  mLayer->setAngle( spinAngle->value() );
999  emit changed();
1000 }
1001 
1002 void QgsFilledMarkerSymbolLayerWidget::setOffset()
1003 {
1004  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1005  emit changed();
1006 }
1007 
1008 void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1009 {
1010  if ( mLayer )
1011  {
1012  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1013  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1014  emit changed();
1015  }
1016 }
1017 
1018 void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1019 {
1020  if ( mLayer )
1021  {
1022  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1023  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1024  emit changed();
1025  }
1026 }
1027 
1028 void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
1029 {
1030  if ( mLayer )
1031  {
1033  emit changed();
1034  }
1035 }
1036 
1037 void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
1038 {
1039  if ( mLayer )
1040  {
1042  emit changed();
1043  }
1044 }
1045 
1046 void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1047 {
1048  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1049  {
1050  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1051  }
1052  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1054  if ( ddSize )
1055  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1056 }
1057 
1058 
1060 
1062  : QgsSymbolLayerWidget( parent, vl )
1063 {
1064  mLayer = nullptr;
1065 
1066  setupUi( this );
1067  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1068  connect( mSpinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1071 
1072  btnColorRamp->setShowGradientOnly( true );
1073 
1074  btnChangeColor->setAllowOpacity( true );
1075  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1076  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1077  btnChangeColor->setShowNoColor( true );
1078  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1079  btnChangeColor2->setAllowOpacity( true );
1080  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1081  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1082  btnChangeColor2->setShowNoColor( true );
1083  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1084 
1085  spinOffsetX->setClearValue( 0.0 );
1086  spinOffsetY->setClearValue( 0.0 );
1087  mSpinAngle->setClearValue( 0.0 );
1088 
1092  connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1093  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1094  connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1095  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1096  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1097  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1098  connect( spinRefPoint1X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1099  connect( spinRefPoint1Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1100  connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1101  connect( spinRefPoint2X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1102  connect( spinRefPoint2Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1103  connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1104 }
1105 
1107 {
1108  if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1109  return;
1110 
1111  // layer type is correct, we can do the cast
1112  mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1113 
1114  // set values
1115  btnChangeColor->blockSignals( true );
1116  btnChangeColor->setColor( mLayer->color() );
1117  btnChangeColor->blockSignals( false );
1118  btnChangeColor2->blockSignals( true );
1119  btnChangeColor2->setColor( mLayer->color2() );
1120  btnChangeColor2->blockSignals( false );
1121 
1123  {
1124  radioTwoColor->setChecked( true );
1125  btnColorRamp->setEnabled( false );
1126  }
1127  else
1128  {
1129  radioColorRamp->setChecked( true );
1130  btnChangeColor->setEnabled( false );
1131  btnChangeColor2->setEnabled( false );
1132  }
1133 
1134  // set source color ramp
1135  if ( mLayer->colorRamp() )
1136  {
1137  btnColorRamp->blockSignals( true );
1138  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1139  btnColorRamp->blockSignals( false );
1140  }
1141 
1142  cboGradientType->blockSignals( true );
1143  switch ( mLayer->gradientType() )
1144  {
1146  cboGradientType->setCurrentIndex( 0 );
1147  break;
1149  cboGradientType->setCurrentIndex( 1 );
1150  break;
1152  cboGradientType->setCurrentIndex( 2 );
1153  break;
1154  }
1155  cboGradientType->blockSignals( false );
1156 
1157  cboCoordinateMode->blockSignals( true );
1158  switch ( mLayer->coordinateMode() )
1159  {
1161  cboCoordinateMode->setCurrentIndex( 1 );
1162  checkRefPoint1Centroid->setEnabled( false );
1163  checkRefPoint2Centroid->setEnabled( false );
1164  break;
1166  default:
1167  cboCoordinateMode->setCurrentIndex( 0 );
1168  break;
1169  }
1170  cboCoordinateMode->blockSignals( false );
1171 
1172  cboGradientSpread->blockSignals( true );
1173  switch ( mLayer->gradientSpread() )
1174  {
1176  cboGradientSpread->setCurrentIndex( 0 );
1177  break;
1179  cboGradientSpread->setCurrentIndex( 1 );
1180  break;
1182  cboGradientSpread->setCurrentIndex( 2 );
1183  break;
1184  }
1185  cboGradientSpread->blockSignals( false );
1186 
1187  spinRefPoint1X->blockSignals( true );
1188  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1189  spinRefPoint1X->blockSignals( false );
1190  spinRefPoint1Y->blockSignals( true );
1191  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1192  spinRefPoint1Y->blockSignals( false );
1193  checkRefPoint1Centroid->blockSignals( true );
1194  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1196  {
1197  spinRefPoint1X->setEnabled( false );
1198  spinRefPoint1Y->setEnabled( false );
1199  }
1200  checkRefPoint1Centroid->blockSignals( false );
1201  spinRefPoint2X->blockSignals( true );
1202  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1203  spinRefPoint2X->blockSignals( false );
1204  spinRefPoint2Y->blockSignals( true );
1205  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1206  spinRefPoint2Y->blockSignals( false );
1207  checkRefPoint2Centroid->blockSignals( true );
1208  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1210  {
1211  spinRefPoint2X->setEnabled( false );
1212  spinRefPoint2Y->setEnabled( false );
1213  }
1214  checkRefPoint2Centroid->blockSignals( false );
1215 
1216  spinOffsetX->blockSignals( true );
1217  spinOffsetX->setValue( mLayer->offset().x() );
1218  spinOffsetX->blockSignals( false );
1219  spinOffsetY->blockSignals( true );
1220  spinOffsetY->setValue( mLayer->offset().y() );
1221  spinOffsetY->blockSignals( false );
1222  mSpinAngle->blockSignals( true );
1223  mSpinAngle->setValue( mLayer->angle() );
1224  mSpinAngle->blockSignals( false );
1225 
1226  mOffsetUnitWidget->blockSignals( true );
1227  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1228  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1229  mOffsetUnitWidget->blockSignals( false );
1230 
1243 }
1244 
1246 {
1247  return mLayer;
1248 }
1249 
1251 {
1252  mLayer->setColor( color );
1253  emit changed();
1254 }
1255 
1257 {
1258  mLayer->setColor2( color );
1259  emit changed();
1260 }
1261 
1262 void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1263 {
1264  if ( radioTwoColor->isChecked() )
1265  {
1267  }
1268  else
1269  {
1271  }
1272  emit changed();
1273 }
1274 
1276 {
1277  if ( btnColorRamp->isNull() )
1278  return;
1279 
1280  mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1281  emit changed();
1282 }
1283 
1285 {
1286  switch ( index )
1287  {
1288  case 0:
1290  //set sensible default reference points
1291  spinRefPoint1X->setValue( 0.5 );
1292  spinRefPoint1Y->setValue( 0 );
1293  spinRefPoint2X->setValue( 0.5 );
1294  spinRefPoint2Y->setValue( 1 );
1295  break;
1296  case 1:
1298  //set sensible default reference points
1299  spinRefPoint1X->setValue( 0 );
1300  spinRefPoint1Y->setValue( 0 );
1301  spinRefPoint2X->setValue( 1 );
1302  spinRefPoint2Y->setValue( 1 );
1303  break;
1304  case 2:
1306  spinRefPoint1X->setValue( 0.5 );
1307  spinRefPoint1Y->setValue( 0.5 );
1308  spinRefPoint2X->setValue( 1 );
1309  spinRefPoint2Y->setValue( 1 );
1310  break;
1311  }
1312  emit changed();
1313 }
1314 
1316 {
1317 
1318  switch ( index )
1319  {
1320  case 0:
1321  //feature coordinate mode
1323  //allow choice of centroid reference positions
1324  checkRefPoint1Centroid->setEnabled( true );
1325  checkRefPoint2Centroid->setEnabled( true );
1326  break;
1327  case 1:
1328  //viewport coordinate mode
1330  //disable choice of centroid reference positions
1331  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1332  checkRefPoint1Centroid->setEnabled( false );
1333  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1334  checkRefPoint2Centroid->setEnabled( false );
1335  break;
1336  }
1337 
1338  emit changed();
1339 }
1340 
1342 {
1343  switch ( index )
1344  {
1345  case 0:
1347  break;
1348  case 1:
1350  break;
1351  case 2:
1353  break;
1354  }
1355 
1356  emit changed();
1357 }
1358 
1359 void QgsGradientFillSymbolLayerWidget::offsetChanged()
1360 {
1361  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1362  emit changed();
1363 }
1364 
1365 void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1366 {
1367  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1368  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1369  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1370  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1371  emit changed();
1372 }
1373 
1374 void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1375 {
1376  mLayer->setAngle( value );
1377  emit changed();
1378 }
1379 
1380 void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1381 {
1382  if ( mLayer )
1383  {
1384  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1385  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1386  emit changed();
1387  }
1388 }
1389 
1391 
1393  : QgsSymbolLayerWidget( parent, vl )
1394 {
1395  mLayer = nullptr;
1396 
1397  setupUi( this );
1398  connect( mSpinBlurRadius, qgis::overload< int >::of( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1399  connect( mSpinMaxDistance, qgis::overload< double >::of( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1400  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1401  connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1402  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1403  connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1408 
1409  QButtonGroup *group1 = new QButtonGroup( this );
1410  group1->addButton( radioColorRamp );
1411  group1->addButton( radioTwoColor );
1412  QButtonGroup *group2 = new QButtonGroup( this );
1413  group2->addButton( mRadioUseMaxDistance );
1414  group2->addButton( mRadioUseWholeShape );
1415  btnChangeColor->setAllowOpacity( true );
1416  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1417  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1418  btnChangeColor->setShowNoColor( true );
1419  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1420  btnChangeColor2->setAllowOpacity( true );
1421  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1422  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1423  btnChangeColor2->setShowNoColor( true );
1424  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1425 
1426  spinOffsetX->setClearValue( 0.0 );
1427  spinOffsetY->setClearValue( 0.0 );
1428 
1429  btnColorRamp->setShowGradientOnly( true );
1430 
1431  connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1432 
1435  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1436  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1437  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1438 
1439  connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1440  connect( mSpinBlurRadius, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1441 }
1442 
1444 {
1445  if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1446  return;
1447 
1448  // layer type is correct, we can do the cast
1449  mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1450 
1451  // set values
1452  btnChangeColor->blockSignals( true );
1453  btnChangeColor->setColor( mLayer->color() );
1454  btnChangeColor->blockSignals( false );
1455  btnChangeColor2->blockSignals( true );
1456  btnChangeColor2->setColor( mLayer->color2() );
1457  btnChangeColor2->blockSignals( false );
1458 
1460  {
1461  radioTwoColor->setChecked( true );
1462  btnColorRamp->setEnabled( false );
1463  }
1464  else
1465  {
1466  radioColorRamp->setChecked( true );
1467  btnChangeColor->setEnabled( false );
1468  btnChangeColor2->setEnabled( false );
1469  }
1470 
1471  mSpinBlurRadius->blockSignals( true );
1472  mBlurSlider->blockSignals( true );
1473  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1474  mBlurSlider->setValue( mLayer->blurRadius() );
1475  mSpinBlurRadius->blockSignals( false );
1476  mBlurSlider->blockSignals( false );
1477 
1478  mSpinMaxDistance->blockSignals( true );
1479  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1480  mSpinMaxDistance->blockSignals( false );
1481 
1482  mRadioUseWholeShape->blockSignals( true );
1483  mRadioUseMaxDistance->blockSignals( true );
1484  if ( mLayer->useWholeShape() )
1485  {
1486  mRadioUseWholeShape->setChecked( true );
1487  mSpinMaxDistance->setEnabled( false );
1488  mDistanceUnitWidget->setEnabled( false );
1489  }
1490  else
1491  {
1492  mRadioUseMaxDistance->setChecked( true );
1493  mSpinMaxDistance->setEnabled( true );
1494  mDistanceUnitWidget->setEnabled( true );
1495  }
1496  mRadioUseWholeShape->blockSignals( false );
1497  mRadioUseMaxDistance->blockSignals( false );
1498 
1499  mDistanceUnitWidget->blockSignals( true );
1500  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1501  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1502  mDistanceUnitWidget->blockSignals( false );
1503 
1504  mIgnoreRingsCheckBox->blockSignals( true );
1505  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1506  mIgnoreRingsCheckBox->blockSignals( false );
1507 
1508  // set source color ramp
1509  if ( mLayer->colorRamp() )
1510  {
1511  btnColorRamp->blockSignals( true );
1512  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1513  btnColorRamp->blockSignals( false );
1514  }
1515 
1516  spinOffsetX->blockSignals( true );
1517  spinOffsetX->setValue( mLayer->offset().x() );
1518  spinOffsetX->blockSignals( false );
1519  spinOffsetY->blockSignals( true );
1520  spinOffsetY->setValue( mLayer->offset().y() );
1521  spinOffsetY->blockSignals( false );
1522  mOffsetUnitWidget->blockSignals( true );
1523  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1524  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1525  mOffsetUnitWidget->blockSignals( false );
1526 
1533 }
1534 
1536 {
1537  return mLayer;
1538 }
1539 
1541 {
1542  if ( mLayer )
1543  {
1544  mLayer->setColor( color );
1545  emit changed();
1546  }
1547 }
1548 
1550 {
1551  if ( mLayer )
1552  {
1553  mLayer->setColor2( color );
1554  emit changed();
1555  }
1556 }
1557 
1558 void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1559 {
1560  if ( !mLayer )
1561  {
1562  return;
1563  }
1564 
1565  if ( radioTwoColor->isChecked() )
1566  {
1568  }
1569  else
1570  {
1572  }
1573  emit changed();
1574 }
1575 
1576 void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1577 {
1578  if ( mLayer )
1579  {
1580  mLayer->setBlurRadius( value );
1581  emit changed();
1582  }
1583 }
1584 
1585 void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1586 {
1587  if ( mLayer )
1588  {
1589  mLayer->setMaxDistance( value );
1590  emit changed();
1591  }
1592 }
1593 
1594 void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1595 {
1596  if ( mLayer )
1597  {
1598  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1599  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1600  emit changed();
1601  }
1602 }
1603 
1604 void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1605 {
1606  if ( mLayer )
1607  {
1608  mLayer->setUseWholeShape( value );
1609  mDistanceUnitWidget->setEnabled( !value );
1610  emit changed();
1611  }
1612 }
1613 
1614 void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1615 {
1616  QgsColorRamp *ramp = btnColorRamp->colorRamp();
1617  if ( !ramp )
1618  return;
1619 
1620  mLayer->setColorRamp( ramp );
1621  emit changed();
1622 }
1623 
1624 void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1625 {
1626  if ( mLayer )
1627  {
1628  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1629  emit changed();
1630  }
1631 }
1632 
1633 void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1634 {
1635  if ( mLayer )
1636  {
1637  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1638  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1639  emit changed();
1640  }
1641 }
1642 
1643 
1644 void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1645 {
1646  bool checked = ( state == Qt::Checked );
1647  mLayer->setIgnoreRings( checked );
1648  emit changed();
1649 }
1650 
1652 
1654  : QgsSymbolLayerWidget( parent, vl )
1655 {
1656  mLayer = nullptr;
1657 
1658  setupUi( this );
1659  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1660  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1661  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1668 
1669  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1670  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1671  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1672  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
1673  {
1674  if ( mLayer )
1675  {
1676  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
1677  emit changed();
1678  }
1679  } );
1680 
1681  spinOffset->setClearValue( 0.0 );
1682 
1683 
1684  if ( vl && vl->geometryType() != QgsWkbTypes::PolygonGeometry )
1685  {
1686  mRingFilterComboBox->hide();
1687  mRingsLabel->hide();
1688  }
1689 
1690  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1691  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1692  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1693  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1694  connect( radInterval, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1695  connect( radVertex, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1696  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1697  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1698  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1699  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1700 }
1701 
1703 {
1704  if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1705  return;
1706 
1707  // layer type is correct, we can do the cast
1708  mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1709 
1710  // set values
1711  spinInterval->blockSignals( true );
1712  spinInterval->setValue( mLayer->interval() );
1713  spinInterval->blockSignals( false );
1714  mSpinOffsetAlongLine->blockSignals( true );
1715  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1716  mSpinOffsetAlongLine->blockSignals( false );
1717  chkRotateMarker->blockSignals( true );
1718  chkRotateMarker->setChecked( mLayer->rotateMarker() );
1719  chkRotateMarker->blockSignals( false );
1720  spinOffset->blockSignals( true );
1721  spinOffset->setValue( mLayer->offset() );
1722  spinOffset->blockSignals( false );
1724  radInterval->setChecked( true );
1726  radVertex->setChecked( true );
1728  radVertexLast->setChecked( true );
1730  radCentralPoint->setChecked( true );
1732  radCurvePoint->setChecked( true );
1733  else
1734  radVertexFirst->setChecked( true );
1735 
1736  // set units
1737  mIntervalUnitWidget->blockSignals( true );
1738  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1739  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1740  mIntervalUnitWidget->blockSignals( false );
1741  mOffsetUnitWidget->blockSignals( true );
1742  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1743  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1744  mOffsetUnitWidget->blockSignals( false );
1745  mOffsetAlongLineUnitWidget->blockSignals( true );
1746  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1747  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1748  mOffsetAlongLineUnitWidget->blockSignals( false );
1749 
1750  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1751 
1752  setPlacement(); // update gui
1753 
1758 }
1759 
1761 {
1762  return mLayer;
1763 }
1764 
1766 {
1767  mLayer->setInterval( val );
1768  emit changed();
1769 }
1770 
1772 {
1773  mLayer->setOffsetAlongLine( val );
1774  emit changed();
1775 }
1776 
1777 void QgsMarkerLineSymbolLayerWidget::setRotate()
1778 {
1779  mLayer->setRotateMarker( chkRotateMarker->isChecked() );
1780  emit changed();
1781 }
1782 
1783 void QgsMarkerLineSymbolLayerWidget::setOffset()
1784 {
1785  mLayer->setOffset( spinOffset->value() );
1786  emit changed();
1787 }
1788 
1789 void QgsMarkerLineSymbolLayerWidget::setPlacement()
1790 {
1791  bool interval = radInterval->isChecked();
1792  spinInterval->setEnabled( interval );
1793  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1794  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
1795  if ( radInterval->isChecked() )
1797  else if ( radVertex->isChecked() )
1799  else if ( radVertexLast->isChecked() )
1801  else if ( radVertexFirst->isChecked() )
1803  else if ( radCurvePoint->isChecked() )
1805  else
1807 
1808  emit changed();
1809 }
1810 
1811 void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
1812 {
1813  if ( mLayer )
1814  {
1815  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
1816  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
1817  emit changed();
1818  }
1819 }
1820 
1821 void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
1822 {
1823  if ( mLayer )
1824  {
1825  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1826  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1827  emit changed();
1828  }
1829 }
1830 
1831 void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
1832 {
1833  if ( mLayer )
1834  {
1835  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
1836  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
1837  }
1838  emit changed();
1839 }
1840 
1842 
1843 
1845  : QgsSymbolLayerWidget( parent, vl )
1846 {
1847  mLayer = nullptr;
1848 
1849  setupUi( this );
1850 
1851  mSvgSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
1852 
1853  connect( mSvgSourceLineEdit, &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
1854  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
1855  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
1856  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
1857  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
1858  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
1859  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
1860  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1861  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1868  viewGroups->setHeaderHidden( true );
1869  mChangeColorButton->setAllowOpacity( true );
1870  mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
1871  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
1872  mChangeStrokeColorButton->setAllowOpacity( true );
1873  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
1874  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
1875 
1876  spinOffsetX->setClearValue( 0.0 );
1877  spinOffsetY->setClearValue( 0.0 );
1878  spinAngle->setClearValue( 0.0 );
1879 
1880  mIconSize = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( QStringLiteral( "XXXX" ) ) ) ) );
1881  viewImages->setGridSize( QSize( mIconSize * 1.2, mIconSize * 1.2 ) );
1882 
1883  populateList();
1884 
1885  connect( viewImages->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::setName );
1886  connect( viewGroups->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::populateIcons );
1887  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
1888  connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
1889  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
1890  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
1891  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
1892  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
1893  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
1894 
1895 
1896  //make a temporary symbol for the size assistant preview
1897  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1898 
1899  if ( vectorLayer() )
1900  {
1901  mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
1902  mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
1903  }
1904 }
1905 
1906 #include <QTime>
1907 #include <QAbstractListModel>
1908 #include <QPixmapCache>
1909 #include <QStyle>
1910 
1911 
1913 {
1914  QAbstractItemModel *oldModel = viewGroups->model();
1916  viewGroups->setModel( g );
1917  delete oldModel;
1918 
1919  // Set the tree expanded at the first level
1920  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
1921  for ( int i = 0; i < rows; i++ )
1922  {
1923  viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true );
1924  }
1925 
1926  // Initially load the icons in the List view without any grouping
1927  oldModel = viewImages->model();
1928  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, mIconSize );
1929  viewImages->setModel( m );
1930  delete oldModel;
1931 }
1932 
1933 void QgsSvgMarkerSymbolLayerWidget::populateIcons( const QModelIndex &idx )
1934 {
1935  QString path = idx.data( Qt::UserRole + 1 ).toString();
1936 
1937  QAbstractItemModel *oldModel = viewImages->model();
1938  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( viewImages, path );
1939  viewImages->setModel( m );
1940  delete oldModel;
1941 
1942  connect( viewImages->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSvgMarkerSymbolLayerWidget::setName );
1943 }
1944 
1946 {
1947  if ( !layer )
1948  {
1949  return;
1950  }
1951 
1952  //activate gui for svg parameters only if supported by the svg file
1953  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
1954  QColor defaultFill, defaultStroke;
1955  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
1956  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
1957  QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
1958  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
1959  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
1960  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
1961  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
1962  mChangeColorButton->setEnabled( hasFillParam );
1963  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
1964  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
1965  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
1966  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
1967 
1968  if ( hasFillParam )
1969  {
1970  QColor fill = layer->fillColor();
1971  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
1972  if ( hasDefaultFillColor )
1973  {
1974  fill = defaultFill;
1975  }
1976  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
1977  mChangeColorButton->setColor( fill );
1978  }
1979  if ( hasStrokeParam )
1980  {
1981  QColor stroke = layer->strokeColor();
1982  double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
1983  if ( hasDefaultStrokeColor )
1984  {
1985  stroke = defaultStroke;
1986  }
1987  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
1988  mChangeStrokeColorButton->setColor( stroke );
1989  }
1990 
1991  whileBlocking( mSvgSourceLineEdit )->setSource( layer->path() );
1992 
1993  mStrokeWidthSpinBox->blockSignals( true );
1994  mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
1995  mStrokeWidthSpinBox->blockSignals( false );
1996 
1997  bool preservedAspectRatio = layer->preservedAspectRatio();
1998  spinHeight->blockSignals( true );
1999  if ( preservedAspectRatio )
2000  {
2001  spinHeight->setValue( layer->size() );
2002  }
2003  else
2004  {
2005  spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2006  }
2007  spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2008  spinHeight->blockSignals( false );
2009  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2010 }
2011 
2012 void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2013 {
2014  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2015  {
2016  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2017  }
2018  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2020  if ( ddSize )
2021  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2022 }
2023 
2024 
2026 {
2027  if ( !layer )
2028  {
2029  return;
2030  }
2031 
2032  if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2033  return;
2034 
2035  // layer type is correct, we can do the cast
2036  mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2037 
2038  // set values
2039 
2040  QAbstractItemModel *m = viewImages->model();
2041  QItemSelectionModel *selModel = viewImages->selectionModel();
2042  for ( int i = 0; i < m->rowCount(); i++ )
2043  {
2044  QModelIndex idx( m->index( i, 0 ) );
2045  if ( m->data( idx ).toString() == mLayer->path() )
2046  {
2047  selModel->select( idx, QItemSelectionModel::SelectCurrent );
2048  selModel->setCurrentIndex( idx, QItemSelectionModel::SelectCurrent );
2049  setName( idx );
2050  break;
2051  }
2052  }
2053 
2054  spinWidth->blockSignals( true );
2055  spinWidth->setValue( mLayer->size() );
2056  spinWidth->blockSignals( false );
2057  spinAngle->blockSignals( true );
2058  spinAngle->setValue( mLayer->angle() );
2059  spinAngle->blockSignals( false );
2060 
2061  // without blocking signals the value gets changed because of slot setOffset()
2062  spinOffsetX->blockSignals( true );
2063  spinOffsetX->setValue( mLayer->offset().x() );
2064  spinOffsetX->blockSignals( false );
2065  spinOffsetY->blockSignals( true );
2066  spinOffsetY->setValue( mLayer->offset().y() );
2067  spinOffsetY->blockSignals( false );
2068 
2069  mSizeUnitWidget->blockSignals( true );
2070  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2071  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2072  mSizeUnitWidget->blockSignals( false );
2073  mStrokeWidthUnitWidget->blockSignals( true );
2074  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2075  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2076  mStrokeWidthUnitWidget->blockSignals( false );
2077  mOffsetUnitWidget->blockSignals( true );
2078  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2079  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2080  mOffsetUnitWidget->blockSignals( false );
2081 
2082  //anchor points
2083  mHorizontalAnchorComboBox->blockSignals( true );
2084  mVerticalAnchorComboBox->blockSignals( true );
2085  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2086  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2087  mHorizontalAnchorComboBox->blockSignals( false );
2088  mVerticalAnchorComboBox->blockSignals( false );
2089 
2090  setGuiForSvg( mLayer );
2091 
2102 
2103  updateAssistantSymbol();
2104 }
2105 
2107 {
2108  return mLayer;
2109 }
2110 
2111 void QgsSvgMarkerSymbolLayerWidget::setName( const QModelIndex &idx )
2112 {
2113  QString name = idx.data( Qt::UserRole ).toString();
2114  mLayer->setPath( name );
2115  whileBlocking( mSvgSourceLineEdit )->setSource( name );
2116 
2117  setGuiForSvg( mLayer );
2118  emit changed();
2119 }
2120 
2121 void QgsSvgMarkerSymbolLayerWidget::setWidth()
2122 {
2123  double defaultAspectRatio = mLayer->defaultAspectRatio();
2124  double fixedAspectRatio = 0.0;
2125  spinHeight->blockSignals( true );
2126  if ( defaultAspectRatio <= 0.0 )
2127  {
2128  spinHeight->setValue( spinWidth->value() );
2129  }
2130  else if ( mLockAspectRatio->locked() )
2131  {
2132  spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2133  }
2134  else
2135  {
2136  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2137  }
2138  spinHeight->blockSignals( false );
2139  mLayer->setSize( spinWidth->value() );
2140  mLayer->setFixedAspectRatio( fixedAspectRatio );
2141  emit changed();
2142 }
2143 
2144 void QgsSvgMarkerSymbolLayerWidget::setHeight()
2145 {
2146  double defaultAspectRatio = mLayer->defaultAspectRatio();
2147  double fixedAspectRatio = 0.0;
2148  spinWidth->blockSignals( true );
2149  if ( defaultAspectRatio <= 0.0 )
2150  {
2151  spinWidth->setValue( spinHeight->value() );
2152  }
2153  else if ( mLockAspectRatio->locked() )
2154  {
2155  spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2156  }
2157  else
2158  {
2159  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2160  }
2161  spinWidth->blockSignals( false );
2162  mLayer->setSize( spinWidth->value() );
2163  mLayer->setFixedAspectRatio( fixedAspectRatio );
2164  emit changed();
2165 }
2166 
2167 void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2168 {
2169  //spinHeight->setEnabled( !locked );
2170  double defaultAspectRatio = mLayer->defaultAspectRatio();
2171  if ( defaultAspectRatio <= 0.0 )
2172  {
2173  whileBlocking( mLockAspectRatio )->setLocked( true );
2174  }
2175  else if ( locked )
2176  {
2177  mLayer->setFixedAspectRatio( 0.0 );
2178  setWidth();
2179  }
2180  else
2181  {
2182  mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2183  }
2184  //emit changed();
2185 }
2186 
2187 void QgsSvgMarkerSymbolLayerWidget::setAngle()
2188 {
2189  mLayer->setAngle( spinAngle->value() );
2190  emit changed();
2191 }
2192 
2193 void QgsSvgMarkerSymbolLayerWidget::setOffset()
2194 {
2195  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2196  emit changed();
2197 }
2198 
2199 void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2200 {
2201  mLayer->setPath( text );
2202  setGuiForSvg( mLayer );
2203  emit changed();
2204 }
2205 
2206 void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2207 {
2208  if ( !mLayer )
2209  {
2210  return;
2211  }
2212 
2213  mLayer->setFillColor( color );
2214  emit changed();
2215 }
2216 
2217 void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2218 {
2219  if ( !mLayer )
2220  {
2221  return;
2222  }
2223 
2224  mLayer->setStrokeColor( color );
2225  emit changed();
2226 }
2227 
2228 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2229 {
2230  if ( mLayer )
2231  {
2232  mLayer->setStrokeWidth( d );
2233  emit changed();
2234  }
2235 }
2236 
2237 void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2238 {
2239  if ( mLayer )
2240  {
2241  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2242  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2243  emit changed();
2244  }
2245 }
2246 
2247 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2248 {
2249  if ( mLayer )
2250  {
2251  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2252  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2253  emit changed();
2254  }
2255 }
2256 
2257 void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2258 {
2259  if ( mLayer )
2260  {
2261  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2262  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2263  emit changed();
2264  }
2265 }
2266 
2267 void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2268 {
2269  if ( mLayer )
2270  {
2272  emit changed();
2273  }
2274 }
2275 
2276 void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
2277 {
2278  if ( mLayer )
2279  {
2281  emit changed();
2282  }
2283 }
2284 
2286 
2288 {
2289  mLayer = nullptr;
2290  setupUi( this );
2291  connect( mTextureWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2292  connect( mSvgSourceLineEdit, &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2293  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2294  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2295  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2296  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2297  connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2298  connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2303  mSvgTreeView->setHeaderHidden( true );
2304  insertIcons();
2305 
2306  mRotationSpinBox->setClearValue( 0.0 );
2307 
2308  mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2309  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2310  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2311  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2312 
2313  connect( mSvgListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::setFile );
2314  connect( mSvgTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::populateIcons );
2315 }
2316 
2318 {
2319  if ( !layer )
2320  {
2321  return;
2322  }
2323 
2324  if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2325  {
2326  return;
2327  }
2328 
2329  mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2330  if ( mLayer )
2331  {
2332  double width = mLayer->patternWidth();
2333  mTextureWidthSpinBox->blockSignals( true );
2334  mTextureWidthSpinBox->setValue( width );
2335  mTextureWidthSpinBox->blockSignals( false );
2336  whileBlocking( mSvgSourceLineEdit )->setSource( mLayer->svgFilePath() );
2337  mRotationSpinBox->blockSignals( true );
2338  mRotationSpinBox->setValue( mLayer->angle() );
2339  mRotationSpinBox->blockSignals( false );
2340  mTextureWidthUnitWidget->blockSignals( true );
2341  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2342  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2343  mTextureWidthUnitWidget->blockSignals( false );
2344  mSvgStrokeWidthUnitWidget->blockSignals( true );
2345  mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2346  mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2347  mSvgStrokeWidthUnitWidget->blockSignals( false );
2348  mChangeColorButton->blockSignals( true );
2349  mChangeColorButton->setColor( mLayer->svgFillColor() );
2350  mChangeColorButton->blockSignals( false );
2351  mChangeStrokeColorButton->blockSignals( true );
2352  mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2353  mChangeStrokeColorButton->blockSignals( false );
2354  mStrokeWidthSpinBox->blockSignals( true );
2355  mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2356  mStrokeWidthSpinBox->blockSignals( false );
2357  }
2358  updateParamGui( false );
2359 
2366 }
2367 
2369 {
2370  return mLayer;
2371 }
2372 
2373 void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2374 {
2375  if ( mLayer )
2376  {
2377  mLayer->setPatternWidth( d );
2378  emit changed();
2379  }
2380 }
2381 
2382 void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2383 {
2384  if ( !mLayer )
2385  {
2386  return;
2387  }
2388 
2389  mLayer->setSvgFilePath( text );
2390  updateParamGui();
2391  emit changed();
2392 }
2393 
2394 void QgsSVGFillSymbolLayerWidget::setFile( const QModelIndex &item )
2395 {
2396  QString file = item.data( Qt::UserRole ).toString();
2397  mLayer->setSvgFilePath( file );
2398  whileBlocking( mSvgSourceLineEdit )->setSource( file );
2399 
2400  updateParamGui();
2401  emit changed();
2402 }
2403 
2405 {
2406  QAbstractItemModel *oldModel = mSvgTreeView->model();
2407  QgsSvgSelectorGroupsModel *g = new QgsSvgSelectorGroupsModel( mSvgTreeView );
2408  mSvgTreeView->setModel( g );
2409  delete oldModel;
2410 
2411  // Set the tree expanded at the first level
2412  int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) );
2413  for ( int i = 0; i < rows; i++ )
2414  {
2415  mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true );
2416  }
2417 
2418  oldModel = mSvgListView->model();
2419  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView );
2420  mSvgListView->setModel( m );
2421  delete oldModel;
2422 }
2423 
2424 void QgsSVGFillSymbolLayerWidget::populateIcons( const QModelIndex &idx )
2425 {
2426  QString path = idx.data( Qt::UserRole + 1 ).toString();
2427 
2428  QAbstractItemModel *oldModel = mSvgListView->model();
2429  QgsSvgSelectorListModel *m = new QgsSvgSelectorListModel( mSvgListView, path );
2430  mSvgListView->setModel( m );
2431  delete oldModel;
2432 
2433  connect( mSvgListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSVGFillSymbolLayerWidget::setFile );
2434 }
2435 
2436 
2437 void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2438 {
2439  if ( mLayer )
2440  {
2441  mLayer->setAngle( d );
2442  emit changed();
2443  }
2444 }
2445 
2447 {
2448  //activate gui for svg parameters only if supported by the svg file
2449  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2450  QColor defaultFill, defaultStroke;
2451  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2452  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2453  QgsApplication::svgCache()->containsParams( mSvgSourceLineEdit->source(), hasFillParam, hasDefaultFillColor, defaultFill,
2454  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2455  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2456  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2457  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2458  if ( resetValues )
2459  {
2460  QColor fill = mChangeColorButton->color();
2461  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2462  if ( hasDefaultFillColor )
2463  {
2464  fill = defaultFill;
2465  }
2466  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2467  mChangeColorButton->setColor( fill );
2468  }
2469  mChangeColorButton->setEnabled( hasFillParam );
2470  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2471  if ( resetValues )
2472  {
2473  QColor stroke = mChangeStrokeColorButton->color();
2474  double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2475  if ( hasDefaultStrokeColor )
2476  {
2477  stroke = defaultStroke;
2478  }
2479  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
2480  mChangeStrokeColorButton->setColor( stroke );
2481  }
2482  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2483  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2484  if ( hasDefaultStrokeWidth && resetValues )
2485  {
2486  mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
2487  }
2488  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2489 }
2490 
2491 void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2492 {
2493  if ( !mLayer )
2494  {
2495  return;
2496  }
2497 
2498  mLayer->setSvgFillColor( color );
2499  emit changed();
2500 }
2501 
2502 void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2503 {
2504  if ( !mLayer )
2505  {
2506  return;
2507  }
2508 
2509  mLayer->setSvgStrokeColor( color );
2510  emit changed();
2511 }
2512 
2513 void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2514 {
2515  if ( mLayer )
2516  {
2517  mLayer->setSvgStrokeWidth( d );
2518  emit changed();
2519  }
2520 }
2521 
2522 void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
2523 {
2524  if ( mLayer )
2525  {
2526  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2527  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2528  emit changed();
2529  }
2530 }
2531 
2532 void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
2533 {
2534  if ( mLayer )
2535  {
2536  mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
2537  mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
2538  emit changed();
2539  }
2540 }
2541 
2543 
2545  QgsSymbolLayerWidget( parent, vl )
2546 {
2547  setupUi( this );
2548  connect( mAngleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
2549  connect( mDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
2550  connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
2551  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
2552  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
2557  mOffsetSpinBox->setClearValue( 0 );
2558  mAngleSpinBox->setClearValue( 0 );
2559 }
2560 
2562 {
2563  if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
2564  {
2565  return;
2566  }
2567 
2568  QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
2569  if ( patternLayer )
2570  {
2571  mLayer = patternLayer;
2572  mAngleSpinBox->blockSignals( true );
2573  mAngleSpinBox->setValue( mLayer->lineAngle() );
2574  mAngleSpinBox->blockSignals( false );
2575  mDistanceSpinBox->blockSignals( true );
2576  mDistanceSpinBox->setValue( mLayer->distance() );
2577  mDistanceSpinBox->blockSignals( false );
2578  mOffsetSpinBox->blockSignals( true );
2579  mOffsetSpinBox->setValue( mLayer->offset() );
2580  mOffsetSpinBox->blockSignals( false );
2581 
2582  //units
2583  mDistanceUnitWidget->blockSignals( true );
2584  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
2585  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
2586  mDistanceUnitWidget->blockSignals( false );
2587  mOffsetUnitWidget->blockSignals( true );
2588  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2589  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2590  mOffsetUnitWidget->blockSignals( false );
2591  }
2592 
2595 }
2596 
2598 {
2599  return mLayer;
2600 }
2601 
2602 void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
2603 {
2604  if ( mLayer )
2605  {
2606  mLayer->setLineAngle( d );
2607  emit changed();
2608  }
2609 }
2610 
2611 void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
2612 {
2613  if ( mLayer )
2614  {
2615  mLayer->setDistance( d );
2616  emit changed();
2617  }
2618 }
2619 
2620 void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
2621 {
2622  if ( mLayer )
2623  {
2624  mLayer->setOffset( d );
2625  emit changed();
2626  }
2627 }
2628 
2629 void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
2630 {
2631  if ( mLayer )
2632  {
2633  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
2634  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
2635  emit changed();
2636  }
2637 }
2638 
2639 void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
2640 {
2641  if ( mLayer )
2642  {
2643  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2644  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2645  emit changed();
2646  }
2647 }
2648 
2650 
2652  QgsSymbolLayerWidget( parent, vl )
2653 {
2654  setupUi( this );
2655  connect( mHorizontalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
2656  connect( mVerticalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
2657  connect( mHorizontalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
2658  connect( mVerticalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
2659  connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
2660  connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
2661  connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
2662  connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
2671 }
2672 
2673 
2675 {
2676  if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
2677  {
2678  return;
2679  }
2680 
2681  mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
2682  mHorizontalDistanceSpinBox->blockSignals( true );
2683  mHorizontalDistanceSpinBox->setValue( mLayer->distanceX() );
2684  mHorizontalDistanceSpinBox->blockSignals( false );
2685  mVerticalDistanceSpinBox->blockSignals( true );
2686  mVerticalDistanceSpinBox->setValue( mLayer->distanceY() );
2687  mVerticalDistanceSpinBox->blockSignals( false );
2688  mHorizontalDisplacementSpinBox->blockSignals( true );
2689  mHorizontalDisplacementSpinBox->setValue( mLayer->displacementX() );
2690  mHorizontalDisplacementSpinBox->blockSignals( false );
2691  mVerticalDisplacementSpinBox->blockSignals( true );
2692  mVerticalDisplacementSpinBox->setValue( mLayer->displacementY() );
2693  mVerticalDisplacementSpinBox->blockSignals( false );
2694 
2695  mHorizontalDistanceUnitWidget->blockSignals( true );
2696  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
2697  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
2698  mHorizontalDistanceUnitWidget->blockSignals( false );
2699  mVerticalDistanceUnitWidget->blockSignals( true );
2700  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
2701  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
2702  mVerticalDistanceUnitWidget->blockSignals( false );
2703  mHorizontalDisplacementUnitWidget->blockSignals( true );
2704  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
2705  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
2706  mHorizontalDisplacementUnitWidget->blockSignals( false );
2707  mVerticalDisplacementUnitWidget->blockSignals( true );
2708  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
2709  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
2710  mVerticalDisplacementUnitWidget->blockSignals( false );
2711 
2712  registerDataDefinedButton( mHorizontalDistanceDDBtn, QgsSymbolLayer::PropertyDistanceX );
2714  registerDataDefinedButton( mHorizontalDisplacementDDBtn, QgsSymbolLayer::PropertyDisplacementX );
2716 }
2717 
2719 {
2720  return mLayer;
2721 }
2722 
2723 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
2724 {
2725  if ( mLayer )
2726  {
2727  mLayer->setDistanceX( d );
2728  emit changed();
2729  }
2730 }
2731 
2732 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
2733 {
2734  if ( mLayer )
2735  {
2736  mLayer->setDistanceY( d );
2737  emit changed();
2738  }
2739 }
2740 
2741 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
2742 {
2743  if ( mLayer )
2744  {
2745  mLayer->setDisplacementX( d );
2746  emit changed();
2747  }
2748 }
2749 
2750 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
2751 {
2752  if ( mLayer )
2753  {
2754  mLayer->setDisplacementY( d );
2755  emit changed();
2756  }
2757 }
2758 
2759 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
2760 {
2761  if ( mLayer )
2762  {
2763  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
2764  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
2765  emit changed();
2766  }
2767 }
2768 
2769 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
2770 {
2771  if ( mLayer )
2772  {
2773  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
2774  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
2775  emit changed();
2776  }
2777 }
2778 
2779 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
2780 {
2781  if ( mLayer )
2782  {
2783  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
2784  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
2785  emit changed();
2786  }
2787 }
2788 
2789 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
2790 {
2791  if ( mLayer )
2792  {
2793  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
2794  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
2795  emit changed();
2796  }
2797 }
2798 
2800 
2802  : QgsSymbolLayerWidget( parent, vl )
2803 {
2804  mLayer = nullptr;
2805 
2806  setupUi( this );
2807  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2808  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2809  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2810  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2811  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2812  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2820  scrollArea->setWidget( widgetChar );
2821 
2822  btnColor->setAllowOpacity( true );
2823  btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
2824  btnColor->setContext( QStringLiteral( "symbology" ) );
2825  btnStrokeColor->setAllowOpacity( true );
2826  btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
2827  btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
2828 
2829  spinOffsetX->setClearValue( 0.0 );
2830  spinOffsetY->setClearValue( 0.0 );
2831  spinAngle->setClearValue( 0.0 );
2832 
2833  //make a temporary symbol for the size assistant preview
2834  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2835 
2836  if ( vectorLayer() )
2837  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
2838 
2839  connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
2840  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
2841  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
2844  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
2845  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
2846  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
2847  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
2849  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
2850 }
2851 
2853 {
2854  if ( layer->layerType() != QLatin1String( "FontMarker" ) )
2855  return;
2856 
2857  // layer type is correct, we can do the cast
2858  mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
2859 
2860  QFont layerFont( mLayer->fontFamily() );
2861  // set values
2862  whileBlocking( cboFont )->setCurrentFont( layerFont );
2863  whileBlocking( spinSize )->setValue( mLayer->size() );
2864  whileBlocking( btnColor )->setColor( mLayer->color() );
2865  whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
2866  whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
2867  whileBlocking( spinAngle )->setValue( mLayer->angle() );
2868 
2869  widgetChar->blockSignals( true );
2870  widgetChar->setFont( layerFont );
2872  widgetChar->blockSignals( false );
2873 
2874  //block
2875  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
2876  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
2877 
2878  mSizeUnitWidget->blockSignals( true );
2879  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2880  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2881  mSizeUnitWidget->blockSignals( false );
2882 
2883  mStrokeWidthUnitWidget->blockSignals( true );
2884  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2885  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2886  mStrokeWidthUnitWidget->blockSignals( false );
2887 
2888  mOffsetUnitWidget->blockSignals( true );
2889  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2890  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2891  mOffsetUnitWidget->blockSignals( false );
2892 
2893  whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
2894 
2895  //anchor points
2896  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2897  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
2898 
2909 
2910  updateAssistantSymbol();
2911 }
2912 
2914 {
2915  return mLayer;
2916 }
2917 
2919 {
2920  mLayer->setFontFamily( font.family() );
2921  widgetChar->setFont( font );
2922  emit changed();
2923 }
2924 
2925 void QgsFontMarkerSymbolLayerWidget::setColor( const QColor &color )
2926 {
2927  mLayer->setColor( color );
2928  emit changed();
2929 }
2930 
2932 {
2933  mLayer->setStrokeColor( color );
2934  emit changed();
2935 }
2936 
2938 {
2939  mLayer->setSize( size );
2940  //widgetChar->updateSize(size);
2941  emit changed();
2942 }
2943 
2945 {
2946  mLayer->setAngle( angle );
2947  emit changed();
2948 }
2949 
2951 {
2952  mLayer->setCharacter( chr );
2953  emit changed();
2954 }
2955 
2956 void QgsFontMarkerSymbolLayerWidget::setOffset()
2957 {
2958  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2959  emit changed();
2960 }
2961 
2962 void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
2963 {
2964  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
2965  emit changed();
2966 }
2967 
2968 void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2969 {
2970  if ( mLayer )
2971  {
2972  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2973  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2974  emit changed();
2975  }
2976 }
2977 
2978 void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2979 {
2980  if ( mLayer )
2981  {
2982  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2983  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2984  emit changed();
2985  }
2986 }
2987 
2988 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2989 {
2990  if ( mLayer )
2991  {
2992  mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
2993  mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2994  emit changed();
2995  }
2996 }
2997 
2998 void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2999 {
3000  if ( mLayer )
3001  {
3003  emit changed();
3004  }
3005 }
3006 
3007 void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3008 {
3009  if ( mLayer )
3010  {
3012  emit changed();
3013  }
3014 }
3015 
3016 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3017 {
3018  if ( mLayer )
3019  {
3020  mLayer->setStrokeWidth( d );
3021  emit changed();
3022  }
3023 }
3024 
3025 void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3026 {
3027  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
3028  {
3029  mAssistantPreviewSymbol->deleteSymbolLayer( i );
3030  }
3031  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3033  if ( ddSize )
3034  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3035 }
3036 
3038 
3039 
3041  : QgsSymbolLayerWidget( parent, vl )
3042 {
3043  mLayer = nullptr;
3044 
3045  setupUi( this );
3046  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3047  connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3048 }
3049 
3051 {
3052  if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3053  return;
3054 
3055  // layer type is correct, we can do the cast
3056  mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3057 
3058  // set values
3059  whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3060  whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3061 }
3062 
3064 {
3065  return mLayer;
3066 }
3067 
3068 void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3069 {
3070  mLayer->setPointOnSurface( state == Qt::Checked );
3071  emit changed();
3072 }
3073 
3074 void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3075 {
3076  mLayer->setPointOnAllParts( state == Qt::Checked );
3077  emit changed();
3078 }
3079 
3081 
3083  : QgsSymbolLayerWidget( parent, vl )
3084 {
3085  mLayer = nullptr;
3086  setupUi( this );
3087  connect( mBrowseToolButton, &QToolButton::clicked, this, &QgsRasterFillSymbolLayerWidget::mBrowseToolButton_clicked );
3088  connect( mImageLineEdit, &QLineEdit::editingFinished, this, &QgsRasterFillSymbolLayerWidget::mImageLineEdit_editingFinished );
3089  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3090  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
3091  connect( mWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed );
3092  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged );
3093 
3098 
3099  mSpinOffsetX->setClearValue( 0.0 );
3100  mSpinOffsetY->setClearValue( 0.0 );
3101  mRotationSpinBox->setClearValue( 0.0 );
3102 
3103  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
3104  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
3105  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
3106  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
3107 }
3108 
3109 
3111 {
3112  if ( !layer )
3113  {
3114  return;
3115  }
3116 
3117  if ( layer->layerType() != QLatin1String( "RasterFill" ) )
3118  {
3119  return;
3120  }
3121 
3122  mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
3123  if ( !mLayer )
3124  {
3125  return;
3126  }
3127 
3128  mImageLineEdit->blockSignals( true );
3129  mImageLineEdit->setText( mLayer->imageFilePath() );
3130  mImageLineEdit->blockSignals( false );
3131 
3132  cboCoordinateMode->blockSignals( true );
3133  switch ( mLayer->coordinateMode() )
3134  {
3136  cboCoordinateMode->setCurrentIndex( 1 );
3137  break;
3139  default:
3140  cboCoordinateMode->setCurrentIndex( 0 );
3141  break;
3142  }
3143  cboCoordinateMode->blockSignals( false );
3144  mOpacityWidget->blockSignals( true );
3145  mOpacityWidget->setOpacity( mLayer->opacity() );
3146  mOpacityWidget->blockSignals( false );
3147  mRotationSpinBox->blockSignals( true );
3148  mRotationSpinBox->setValue( mLayer->angle() );
3149  mRotationSpinBox->blockSignals( false );
3150 
3151  mSpinOffsetX->blockSignals( true );
3152  mSpinOffsetX->setValue( mLayer->offset().x() );
3153  mSpinOffsetX->blockSignals( false );
3154  mSpinOffsetY->blockSignals( true );
3155  mSpinOffsetY->setValue( mLayer->offset().y() );
3156  mSpinOffsetY->blockSignals( false );
3157  mOffsetUnitWidget->blockSignals( true );
3158  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3159  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3160  mOffsetUnitWidget->blockSignals( false );
3161 
3162  mWidthSpinBox->blockSignals( true );
3163  mWidthSpinBox->setValue( mLayer->width() );
3164  mWidthSpinBox->blockSignals( false );
3165  mWidthUnitWidget->blockSignals( true );
3166  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
3167  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
3168  mWidthUnitWidget->blockSignals( false );
3169  updatePreviewImage();
3170 
3175 }
3176 
3178 {
3179  return mLayer;
3180 }
3181 
3182 void QgsRasterFillSymbolLayerWidget::mBrowseToolButton_clicked()
3183 {
3184  QgsSettings s;
3185  QString openDir;
3186  QString lineEditText = mImageLineEdit->text();
3187  if ( !lineEditText.isEmpty() )
3188  {
3189  QFileInfo openDirFileInfo( lineEditText );
3190  openDir = openDirFileInfo.path();
3191  }
3192 
3193  if ( openDir.isEmpty() )
3194  {
3195  openDir = s.value( QStringLiteral( "/UI/lastRasterFillImageDir" ), QDir::homePath() ).toString();
3196  }
3197 
3198  //show file dialog
3199  QString filePath = QFileDialog::getOpenFileName( nullptr, tr( "Select Image File" ), openDir );
3200  if ( !filePath.isNull() )
3201  {
3202  //check if file exists
3203  QFileInfo fileInfo( filePath );
3204  if ( !fileInfo.exists() || !fileInfo.isReadable() )
3205  {
3206  QMessageBox::critical( nullptr, QStringLiteral( "Select Image File" ), QStringLiteral( "Error, file does not exist or is not readable." ) );
3207  return;
3208  }
3209 
3210  s.setValue( QStringLiteral( "/UI/lastRasterFillImageDir" ), fileInfo.absolutePath() );
3211  mImageLineEdit->setText( filePath );
3212  mImageLineEdit_editingFinished();
3213  }
3214 }
3215 
3216 void QgsRasterFillSymbolLayerWidget::mImageLineEdit_editingFinished()
3217 {
3218  if ( !mLayer )
3219  {
3220  return;
3221  }
3222 
3223  QFileInfo fi( mImageLineEdit->text() );
3224  if ( !fi.exists() )
3225  {
3226  QUrl url( mImageLineEdit->text() );
3227  if ( !url.isValid() )
3228  {
3229  return;
3230  }
3231  }
3232 
3233  QApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) );
3234  mLayer->setImageFilePath( mImageLineEdit->text() );
3235  updatePreviewImage();
3236  QApplication::restoreOverrideCursor();
3237 
3238  emit changed();
3239 }
3240 
3241 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
3242 {
3243  switch ( index )
3244  {
3245  case 0:
3246  //feature coordinate mode
3248  break;
3249  case 1:
3250  //viewport coordinate mode
3252  break;
3253  }
3254 
3255  emit changed();
3256 }
3257 
3258 void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
3259 {
3260  if ( !mLayer )
3261  {
3262  return;
3263  }
3264 
3265  mLayer->setOpacity( value );
3266  emit changed();
3267  updatePreviewImage();
3268 }
3269 
3270 void QgsRasterFillSymbolLayerWidget::offsetChanged()
3271 {
3272  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
3273  emit changed();
3274 }
3275 
3276 void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3277 {
3278  if ( !mLayer )
3279  {
3280  return;
3281  }
3282  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3283  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3284  emit changed();
3285 }
3286 
3287 void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
3288 {
3289  if ( mLayer )
3290  {
3291  mLayer->setAngle( d );
3292  emit changed();
3293  }
3294 }
3295 
3296 void QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed()
3297 {
3298  if ( !mLayer )
3299  {
3300  return;
3301  }
3302  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
3303  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3304  emit changed();
3305 }
3306 
3307 void QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged( double d )
3308 {
3309  if ( !mLayer )
3310  {
3311  return;
3312  }
3313  mLayer->setWidth( d );
3314  emit changed();
3315 }
3316 
3317 
3318 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
3319 {
3320  if ( !mLayer )
3321  {
3322  return;
3323  }
3324 
3325  QImage image( mLayer->imageFilePath() );
3326  if ( image.isNull() )
3327  {
3328  mLabelImagePreview->setPixmap( QPixmap() );
3329  return;
3330  }
3331 
3332  if ( image.height() > 150 || image.width() > 150 )
3333  {
3334  image = image.scaled( 150, 150, Qt::KeepAspectRatio, Qt::SmoothTransformation );
3335  }
3336 
3337  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3338  previewImage.fill( Qt::transparent );
3339  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3340  QPainter p;
3341  p.begin( &previewImage );
3342  //draw a checkerboard background
3343  uchar pixDataRGB[] = { 150, 150, 150, 150,
3344  100, 100, 100, 150,
3345  100, 100, 100, 150,
3346  150, 150, 150, 150
3347  };
3348  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3349  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3350  QBrush checkerBrush;
3351  checkerBrush.setTexture( pix );
3352  p.fillRect( imageRect, checkerBrush );
3353 
3354  if ( mLayer->opacity() < 1.0 )
3355  {
3356  p.setOpacity( mLayer->opacity() );
3357  }
3358 
3359  p.drawImage( imageRect.left(), imageRect.top(), image );
3360  p.end();
3361  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3362 }
3363 
3364 
3366  : QgsSymbolLayerWidget( parent, vl )
3367 
3368 {
3369  setupUi( this );
3370  modificationExpressionSelector->setMultiLine( true );
3371  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
3372  modificationExpressionSelector->registerExpressionContextGenerator( this );
3373  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPolygonLayer.svg" ) ), tr( "Polygon / MultiPolygon" ), QgsSymbol::Fill );
3374  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconLineLayer.svg" ) ), tr( "LineString / MultiLineString" ), QgsSymbol::Line );
3375  cbxGeometryType->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconPointLayer.svg" ) ), tr( "Point / MultiPoint" ), QgsSymbol::Marker );
3376  connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
3377  connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
3378 }
3379 
3381 {
3382  mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
3383  modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
3384  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
3385 }
3386 
3388 {
3389  return mLayer;
3390 }
3391 
3392 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
3393 {
3394  mLayer->setGeometryExpression( string );
3395 
3396  emit changed();
3397 }
3398 
3399 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
3400 {
3401  mLayer->setSymbolType( static_cast<QgsSymbol::SymbolType>( cbxGeometryType->currentData().toInt() ) );
3402 
3403  emit symbolChanged();
3404 }
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line&#39;s width.
void setOffset(QPointF offset)
Sets the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered marker...
bool rotateMarker() const
Shall the marker be rotated.
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...
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern&#39;s width.
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.
Qt::PenJoinStyle penJoinStyle() const
Placement placement() const
The placement of the markers.
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
Gradient reference point 1 is centroid.
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
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
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
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
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.
const QgsMapUnitScale & displacementXMapUnitScale() const
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
Qt::PenStyle strokeStyle() const
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
QString geometryExpression() const
Gets the expression to generate this geometry.
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
Gradient reference point 1 x.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
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.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker&#39;s stroke.
QgsSymbolLayer * symbolLayer() override
Qt::BrushStyle brushStyle() const
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
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.
void setUseCustomDashPattern(bool b)
A model for displaying SVG files with a preview icon.
void setSymbolLayer(QgsSymbolLayer *layer) override
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
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
int propertyKey() const
Returns the property key linked to the button.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker&#39;s stroke.
void setSymbolLayer(QgsSymbolLayer *layer) override
double maxDistance() const
Returns the maximum distance from the shape&#39;s boundary which is shaded.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
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...
RenderRingFilter ringFilter() const
Returns the line symbol layer&#39;s ring filter, which controls which rings are rendered when the line sy...
virtual void setWidth(double width)
void colorRampChanged()
Emitted whenever a new color ramp is set for the button.
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.
A symbol fill consisting of repeated parallel lines.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
QgsSimpleFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleFillSymbolLayerWidget.
void lockChanged(bool locked)
Emitted whenever the lock state changes.
double interval() const
Returns the interval between individual markers.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern&#39;s stroke.
QgsLinePatternFillSymbolLayer * mLayer
const QgsMapUnitScale & distanceMapUnitScale() const
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
QPointF offset() const
Returns the marker&#39;s offset, which is the horizontal and vertical displacement which the rendered mar...
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill&#39;s offset.
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)
const QgsMapUnitScale & intervalMapUnitScale() const
Render both exterior and interior rings.
QgsSymbolLayer * symbolLayer() override
void setAngle(double angle)
double size() const
Returns the symbol size.
Abstract base class for color ramps.
Definition: qgscolorramp.h:31
void setRotateMarker(bool rotate)
Shall the marker be rotated.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
void setSymbolLayer(QgsSymbolLayer *layer) override
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image&#39;s width.
const QgsMapUnitScale & offsetMapUnitScale() const
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)
void setSymbolLayer(QgsSymbolLayer *layer) override
void setStrokeColor(const QColor &c) override
Set stroke color.
void setStrokeWidth(double w)
Sets the width of the marker&#39;s stroke.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
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.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon&#39;s boundary...
void setStrokeWidth(double width)
Set&#39;s the marker&#39;s stroke width.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0...
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill&#39;s offset.
QgsUnitTypes::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
Qt::PenStyle penStyle() const
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
Line symbol.
Definition: qgssymbol.h:86
QColor strokeColor() const override
Returns the marker&#39;s stroke color.
QgsCentroidFillSymbolLayer * mLayer
const QgsMapUnitScale & strokeWidthMapUnitScale() const
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
const QgsMapUnitScale & widthMapUnitScale() const
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.
double opacity() const
Returns the opacity for the raster image used in the fill.
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...
Tiling is based on complete map viewport.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
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
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:732
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.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:920
Gradient reference point 2 y.
const QgsMapUnitScale & offsetMapUnitScale() const
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
QgsShapeburstFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsShapeburstFillSymbolLayerWidget.
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setSymbolLayer(QgsSymbolLayer *layer) override
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
QColor strokeColor() const override
Gets stroke color.
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
void setGradientType(GradientType gradientType)
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern&#39;s offset.
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 angle() const
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill&#39;s stroke.
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.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features...
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern&#39;s offset.
QChar character() const
Returns the character used when rendering points.
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.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setSymbolLayer(QgsSymbolLayer *layer) override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading...
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
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.
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.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image&#39;s width.
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
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
QgsSimpleLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleLineSymbolLayerWidget.
const QgsMapUnitScale & offsetMapUnitScale() const
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.
double strokeWidth() const
Returns the marker&#39;s stroke width.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill&#39;s offset.
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for markers.
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.
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.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker&#39;s stroke.
QgsCentroidFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsCentroidFillSymbolLayerWidget.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
const QgsMapUnitScale & customDashPatternMapUnitScale() const
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1...
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
Render the interior rings only.
virtual QgsSymbolLayer * symbolLayer()=0
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern&#39;s line offset.
void setSymbolLayer(QgsSymbolLayer *layer) override
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for markers...
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 setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
const QgsMapUnitScale & distanceXMapUnitScale() const
points (e.g., for font sizes)
Definition: qgsunittypes.h:117
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol&#39;s size.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol&#39;s size.
QgsSvgMarkerSymbolLayer * mLayer
QVector< qreal > customDashVector() const
QgsShapeburstFillSymbolLayer * mLayer
QString imageFilePath() const
The path to the raster image used for the fill.
void setStrokeStyle(Qt::PenStyle strokeStyle)
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.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
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.
bool useCustomDashPattern() const
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
void setSymbolLayer(QgsSymbolLayer *layer) override
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
Shapeburst fill from edge distance.
void setCharacter(QChar ch)
Sets the character used when rendering points.
Character, eg for font marker symbol layers.
QgsPointPatternFillSymbolLayer * mLayer
void setPenJoinStyle(Qt::PenJoinStyle style)
Single scope for storing variables and functions for use within a QgsExpressionContext.
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
A store for object properties.
Definition: qgsproperty.h:229
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
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.
QgsUnitTypes::RenderUnit offsetUnit() const
double strokeWidth() const
Returns the width of the marker&#39;s stroke.
QgsSymbolLayer * symbolLayer() override
void setPenStyle(Qt::PenStyle style)
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
const QgsMapUnitScale & displacementYMapUnitScale() const
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.
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.
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops...
Qt::PenJoinStyle penJoinStyle() const
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)
void sourceChanged(const QString &source)
Emitted whenever the SVG source is changed in the widget.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol&#39;s offset.
QString path() const
Returns the marker SVG path.
QgsSimpleMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleMarkerSymbolLayerWidget.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
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.
virtual double width() const
Returns the estimated width for the line symbol layer.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
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.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key)
Registers a data defined override button.
Qt::PenStyle strokeStyle() const
Returns the marker&#39;s stroke style (e.g., solid, dashed, etc)
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol&#39;s size.
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)
Fill symbol.
Definition: qgssymbol.h:87
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.
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern&#39;s line distance.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
QgsPointPatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsPointPatternFillSymbolLayerWidget.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
void setGradientColorType(GradientColorType gradientColorType)
QgsFilledMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFilledMarkerSymbolLayerWidget.
QPointF offset() const
Returns the offset for the fill.
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image&#39;s width.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
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.
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.
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol&#39;s offset.
const QgsMapUnitScale & distanceYMapUnitScale() const
const QgsMapUnitScale & strokeWidthMapUnitScale() const
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
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
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
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
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between markers.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line&#39;s offset.
virtual void setSize(double size)
Sets the symbol size.
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)
QColor fillColor() const override
Gets fill color.
QgsPropertyDefinition propertyDefinition() const
Returns the underlying property definition.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QgsFontMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFontMarkerSymbolLayerWidget.
void setColorStroke(const QColor &color)
Set stroke color.
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.
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...
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between markers.
void setCustomDashVector(const QVector< qreal > &vector)
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
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.
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.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol&#39;s size.
void setColor2(const QColor &color2)
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point...
void setAngle(double angle)
Sets the rotation angle for the marker.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
QgsSimpleLineSymbolLayer * mLayer
Qt::PenJoinStyle penJoinStyle() const
Returns the marker&#39;s stroke join style (e.g., miter, bevel, etc).
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
QgsSymbolLayer * symbolLayer() override
void setMapUnitScale(const QgsMapUnitScale &scale) override
double distance() const
Returns the distance between lines in the fill pattern.
Render the exterior ring only.
void setBrushStyle(Qt::BrushStyle style)
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
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 line&#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.
double offset() const
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QgsFontMarkerSymbolLayer * mLayer
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
Shapeburst blur radius.
Qt::PenCapStyle penCapStyle() const
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...
double width() const
Returns the width used for scaling the image used in the fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
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.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
Fill style (eg solid, dots)
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
Represents a vector layer which manages a vector based data sets.
GradientType gradientType() const
Type of gradient, e.g., linear or radial.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
void updateFieldLists()
Updates list of fields.
virtual QColor color() const
The fill color.
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)...
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.
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].
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.
Property
Data definable properties.
QPointF offset() const
Returns the offset for the shapeburst fill.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsSymbolLayer * symbolLayer() override
const QgsMapUnitScale & offsetMapUnitScale() const
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.
void setOffset(double offset)
Horizontal distance between points.
virtual QString layerType() const =0
Returns a string that represents this layer type.
double offsetAlongLine() const
Returns the offset along the line for the marker placement.
Vertical distance between points.