QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
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 "qgsdataitem.h"
20 #include "qgslinesymbollayer.h"
21 #include "qgsmarkersymbollayer.h"
22 #include "qgsfillsymbollayer.h"
24 #include "qgssymbolslistwidget.h"
26 
27 #include "characterwidget.h"
28 #include "qgsdashspacedialog.h"
30 #include "qgssvgcache.h"
31 #include "qgssymbollayerutils.h"
32 #include "qgscolorramp.h"
33 #include "qgscolorrampbutton.h"
34 #include "qgsfontutils.h"
36 #include "qgsproperty.h"
37 #include "qgsstyle.h" //for symbol selector dialog
38 #include "qgsmapcanvas.h"
39 #include "qgsapplication.h"
40 #include "qgsvectorlayer.h"
41 #include "qgssvgselectorwidget.h"
42 #include "qgslogger.h"
43 #include "qgssettings.h"
46 #include "qgsauxiliarystorage.h"
47 #include "qgsimagecache.h"
48 
49 #include <QAbstractButton>
50 #include <QButtonGroup>
51 #include <QColorDialog>
52 #include <QCursor>
53 #include <QDir>
54 #include <QFileDialog>
55 #include <QPainter>
56 #include <QStandardItemModel>
57 #include <QSvgRenderer>
58 #include <QMessageBox>
59 #include <QMenu>
60 #include <QAction>
61 #include <QInputDialog>
62 #include <QBuffer>
63 #include <QRegularExpression>
64 
66 {
67  if ( auto *lExpressionContext = mContext.expressionContext() )
68  return *lExpressionContext;
69 
71 
73  if ( const QgsSymbolLayer *symbolLayer = const_cast< QgsSymbolLayerWidget * >( this )->symbolLayer() )
74  {
75  //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
76  //color, but that's not accessible here). 99% of the time these will be the same anyway
78  }
79  expContext << symbolScope;
84  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_count" ), 1, true ) );
85  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_index" ), 1, true ) );
86  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_row" ), 1, true ) );
87  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_column" ), 1, true ) );
88 
89  // additional scopes
90  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
91  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
92  {
93  expContext.appendScope( new QgsExpressionContextScope( scope ) );
94  }
95 
96  //TODO - show actual value
97  expContext.setOriginalValueVariable( QVariant() );
98 
99  QStringList highlights;
104  << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" );
105 
106 
107  if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
108  {
109  highlights << QStringLiteral( "zoom_level" );
110  }
111  if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
112  {
113  highlights << QStringLiteral( "vector_tile_zoom" );
114  }
115 
116  expContext.setHighlightedVariables( highlights );
117 
118  return expContext;
119 }
120 
122 {
123  mContext = context;
124  const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
125  for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
126  {
127  unitWidget->setMapCanvas( mContext.mapCanvas() );
128  }
129 }
130 
132 {
133  return mContext;
134 }
135 
137 {
138  button->init( key, symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
140  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
141 
142  button->registerExpressionContextGenerator( this );
143 }
144 
145 void QgsSymbolLayerWidget::createAuxiliaryField()
146 {
147  // try to create an auxiliary layer if not yet created
148  if ( !mVectorLayer->auxiliaryLayer() )
149  {
150  QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
151  dlg.exec();
152  }
153 
154  // return if still not exists
155  if ( !mVectorLayer->auxiliaryLayer() )
156  return;
157 
158  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
159  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
161 
162  // create property in auxiliary storage if necessary
163  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
164  {
165  QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer, true, this );
166  if ( dlg.exec() == QDialog::Accepted )
167  def = dlg.propertyDefinition();
168  }
169 
170  // return if still not exist
171  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
172  return;
173 
174  // update property with join field name from auxiliary storage
175  QgsProperty property = button->toProperty();
176  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
177  property.setActive( true );
178  button->updateFieldLists();
179  button->setToProperty( property );
180  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
181 
182  emit changed();
183 }
184 
186 {
187  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
188  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
189  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
190  emit changed();
191 }
192 
194  : QgsSymbolLayerWidget( parent, vl )
195 {
196  mLayer = nullptr;
197 
198  setupUi( this );
199  connect( mCustomCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
200  connect( mChangePatternButton, &QPushButton::clicked, this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
201  connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed );
202  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed );
203  connect( mDashPatternUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed );
204  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
205  connect( mPatternOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged );
206  connect( mCheckAlignDash, &QCheckBox::toggled, this, [ = ]
207  {
208  mCheckDashCorners->setEnabled( mCheckAlignDash->isChecked() );
209  if ( !mCheckAlignDash->isChecked() )
210  mCheckDashCorners->setChecked( false );
211 
212  if ( mLayer )
213  {
214  mLayer->setAlignDashPattern( mCheckAlignDash->isChecked() );
215  emit changed();
216  }
217  } );
218  connect( mCheckDashCorners, &QCheckBox::toggled, this, [ = ]
219  {
220  if ( mLayer )
221  {
222  mLayer->setTweakDashPatternOnCorners( mCheckDashCorners->isChecked() );
223  emit changed();
224  }
225  } );
226 
235 
236  btnChangeColor->setAllowOpacity( true );
237  btnChangeColor->setColorDialogTitle( tr( "Select Line Color" ) );
238  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
239 
240  mColorDDBtn->registerLinkedWidget( btnChangeColor );
241 
242  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
243  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
244  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
245  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
246  {
247  if ( mLayer )
248  {
249  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
250  emit changed();
251  }
252  } );
253 
254  spinOffset->setClearValue( 0.0 );
255  spinPatternOffset->setClearValue( 0.0 );
256 
257  //make a temporary symbol for the size assistant preview
258  mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
259 
260  if ( vectorLayer() )
261  mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
262 
263  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
264  connect( btnChangeColor, &QgsColorButton::colorChanged, this, &QgsSimpleLineSymbolLayerWidget::colorChanged );
265  connect( cboPenStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
266  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
267  connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
268  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
269  connect( spinPatternOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::patternOffsetChanged );
270 
272 
273  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol );
274 }
275 
276 void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
277 {
278  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
279  {
280  mAssistantPreviewSymbol->deleteSymbolLayer( i );
281  }
282  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
284  if ( ddWidth )
285  mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
286 }
287 
288 
290 {
291  if ( !layer || layer->layerType() != QLatin1String( "SimpleLine" ) )
292  return;
293 
294  // layer type is correct, we can do the cast
295  mLayer = static_cast<QgsSimpleLineSymbolLayer *>( layer );
296 
297  // set units
298  mPenWidthUnitWidget->blockSignals( true );
299  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
300  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
301  mPenWidthUnitWidget->blockSignals( false );
302  mOffsetUnitWidget->blockSignals( true );
303  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
304  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
305  mOffsetUnitWidget->blockSignals( false );
306  mDashPatternUnitWidget->blockSignals( true );
307  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
308  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
309  mDashPatternUnitWidget->blockSignals( false );
310 
311  whileBlocking( mPatternOffsetUnitWidget )->setUnit( mLayer->dashPatternOffsetUnit() );
312  whileBlocking( mPatternOffsetUnitWidget )->setMapUnitScale( mLayer->dashPatternOffsetMapUnitScale() );
313 
314  // set values
315  spinWidth->blockSignals( true );
316  spinWidth->setValue( mLayer->width() );
317  spinWidth->blockSignals( false );
318  btnChangeColor->blockSignals( true );
319  btnChangeColor->setColor( mLayer->color() );
320  btnChangeColor->blockSignals( false );
321  spinOffset->blockSignals( true );
322  spinOffset->setValue( mLayer->offset() );
323  spinOffset->blockSignals( false );
324  cboPenStyle->blockSignals( true );
325  cboJoinStyle->blockSignals( true );
326  cboCapStyle->blockSignals( true );
327  cboPenStyle->setPenStyle( mLayer->penStyle() );
328  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
329  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
330  cboPenStyle->blockSignals( false );
331  cboJoinStyle->blockSignals( false );
332  cboCapStyle->blockSignals( false );
333  whileBlocking( spinPatternOffset )->setValue( mLayer->dashPatternOffset() );
334 
335  //use a custom dash pattern?
336  bool useCustomDashPattern = mLayer->useCustomDashPattern();
337  mChangePatternButton->setEnabled( useCustomDashPattern );
338  label_3->setEnabled( !useCustomDashPattern );
339  cboPenStyle->setEnabled( !useCustomDashPattern );
340  mCustomCheckBox->blockSignals( true );
341  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
342  mCustomCheckBox->blockSignals( false );
343 
344  //make sure height of custom dash button looks good under different platforms
345  QSize size = mChangePatternButton->minimumSizeHint();
346  int fontHeight = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.4 );
347  mChangePatternButton->setMinimumSize( QSize( size.width(), std::max( size.height(), fontHeight ) ) );
348 
349  //draw inside polygon?
350  const bool drawInsidePolygon = mLayer->drawInsidePolygon();
351  whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
352 
353  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
354 
355  whileBlocking( mCheckAlignDash )->setChecked( mLayer->alignDashPattern() );
356  mCheckDashCorners->setEnabled( mLayer->alignDashPattern() );
357  whileBlocking( mCheckDashCorners )->setChecked( mLayer->tweakDashPatternOnCorners() && mLayer->alignDashPattern() );
358 
360 
369 
370  updateAssistantSymbol();
371 }
372 
374 {
375  return mLayer;
376 }
377 
379 {
381 
382  switch ( context.symbolType() )
383  {
384  case QgsSymbol::Marker:
385  case QgsSymbol::Line:
386  //these settings only have an effect when the symbol layers is part of a fill symbol
387  mDrawInsideCheckBox->hide();
388  mRingFilterComboBox->hide();
389  mRingsLabel->hide();
390  break;
391 
392  case QgsSymbol::Fill:
393  case QgsSymbol::Hybrid:
394  break;
395  }
396 }
397 
398 void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
399 {
400  mLayer->setWidth( spinWidth->value() );
402  emit changed();
403 }
404 
405 void QgsSimpleLineSymbolLayerWidget::colorChanged( const QColor &color )
406 {
407  mLayer->setColor( color );
408  emit changed();
409 }
410 
411 void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
412 {
413  mLayer->setPenStyle( cboPenStyle->penStyle() );
414  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
415  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
417  emit changed();
418 }
419 
420 void QgsSimpleLineSymbolLayerWidget::offsetChanged()
421 {
422  mLayer->setOffset( spinOffset->value() );
424  emit changed();
425 }
426 
427 void QgsSimpleLineSymbolLayerWidget::patternOffsetChanged()
428 {
429  mLayer->setDashPatternOffset( spinPatternOffset->value() );
431  emit changed();
432 }
433 
434 void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged( int state )
435 {
436  bool checked = ( state == Qt::Checked );
437  mChangePatternButton->setEnabled( checked );
438  label_3->setEnabled( !checked );
439  cboPenStyle->setEnabled( !checked );
440 
441  mLayer->setUseCustomDashPattern( checked );
442  emit changed();
443 }
444 
445 void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
446 {
448  if ( panel && panel->dockMode() )
449  {
451  widget->setPanelTitle( tr( "Custom Dash Pattern" ) );
452  widget->setUnit( mDashPatternUnitWidget->unit() );
453  connect( widget, &QgsPanelWidget::widgetChanged, this, [ this, widget ]()
454  {
457  } );
459  panel->openPanel( widget );
460  return;
461  }
462 
464  d.setUnit( mDashPatternUnitWidget->unit() );
465  if ( d.exec() == QDialog::Accepted )
466  {
467  mLayer->setCustomDashVector( d.dashDotVector() );
469  emit changed();
470  }
471 }
472 
473 void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
474 {
475  if ( mLayer )
476  {
477  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
478  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
480  emit changed();
481  }
482 }
483 
484 void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
485 {
486  if ( mLayer )
487  {
488  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
489  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
490  emit changed();
491  }
492 }
493 
494 void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
495 {
496  if ( mLayer )
497  {
498  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
499  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
501  emit changed();
502  }
503 }
504 
505 void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
506 {
507  bool checked = ( state == Qt::Checked );
508  mLayer->setDrawInsidePolygon( checked );
509  emit changed();
510 }
511 
512 void QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged()
513 {
514  if ( mLayer )
515  {
516  mLayer->setDashPatternOffsetUnit( mPatternOffsetUnitWidget->unit() );
517  mLayer->setDashPatternOffsetMapUnitScale( mPatternOffsetUnitWidget->getMapUnitScale() );
519  emit changed();
520  }
521 }
522 
524 {
525  if ( !mLayer )
526  {
527  return;
528  }
529  std::unique_ptr< QgsSimpleLineSymbolLayer > layerCopy( mLayer->clone() );
530  if ( !layerCopy )
531  {
532  return;
533  }
534  QColor color = qApp->palette().color( QPalette::WindowText );
535  layerCopy->setColor( color );
536  // reset offset, we don't want to show that in the preview
537  layerCopy->setOffset( 0 );
538  layerCopy->setUseCustomDashPattern( true );
539 
540  QSize currentIconSize;
541  //icon size is button size with a small margin
542 #ifdef Q_OS_WIN
543  currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 6 );
544 #else
545  currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 12 );
546 #endif
547 
548  if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
549  {
550  return;
551  }
552 
553  //create an icon pixmap
554  std::unique_ptr< QgsLineSymbol > previewSymbol = qgis::make_unique< QgsLineSymbol >( QgsSymbolLayerList() << layerCopy.release() );
555  const QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize );
556  mChangePatternButton->setIconSize( currentIconSize );
557  mChangePatternButton->setIcon( icon );
558 
559  // set tooltip
560  // create very large preview image
561 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
562  int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 23 );
563 #else
564  int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 23 );
565 #endif
566  int height = static_cast< int >( width / 1.61803398875 ); // golden ratio
567 
568  QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20 );
569  QByteArray data;
570  QBuffer buffer( &data );
571  pm.save( &buffer, "PNG", 100 );
572  mChangePatternButton->setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3'>" ).arg( QString( data.toBase64() ) ) );
573 }
574 
576 {
577  QgsSymbolLayerWidget::resizeEvent( event );
578  // redraw custom dash pattern icon -- the button size has changed
580 }
581 
582 
584 
585 
587  : QgsSymbolLayerWidget( parent, vl )
588 {
589  mLayer = nullptr;
590 
591  setupUi( this );
592  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
593  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
594  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
595  connect( mStrokeStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
596  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
597  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
598  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
605 
606  btnChangeColorFill->setAllowOpacity( true );
607  btnChangeColorFill->setColorDialogTitle( tr( "Select Fill Color" ) );
608  btnChangeColorFill->setContext( QStringLiteral( "symbology" ) );
609  btnChangeColorFill->setShowNoColor( true );
610  btnChangeColorFill->setNoColorString( tr( "Transparent Fill" ) );
611  btnChangeColorStroke->setAllowOpacity( true );
612  btnChangeColorStroke->setColorDialogTitle( tr( "Select Stroke Color" ) );
613  btnChangeColorStroke->setContext( QStringLiteral( "symbology" ) );
614  btnChangeColorStroke->setShowNoColor( true );
615  btnChangeColorStroke->setNoColorString( tr( "Transparent Stroke" ) );
616 
617  mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
618  mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
619 
620  spinOffsetX->setClearValue( 0.0 );
621  spinOffsetY->setClearValue( 0.0 );
622  spinAngle->setClearValue( 0.0 );
623 
624  //make a temporary symbol for the size assistant preview
625  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
626 
627  if ( vectorLayer() )
628  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
629 
630  int size = lstNames->iconSize().width();
631 
632 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
633  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 3 ) ) );
634 #else
635  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
636 #endif
637 
638  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
639  lstNames->setIconSize( QSize( size, size ) );
640 
641  double markerSize = size * 0.8;
643  for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
644  {
645  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
647  lyr->setColor( QColor( 200, 200, 200 ) );
648  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
649  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
650  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
651  item->setData( Qt::UserRole, static_cast< int >( shape ) );
652  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
653  delete lyr;
654  }
655  // show at least 3 rows
656  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
657 
658  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
659  connect( btnChangeColorStroke, &QgsColorButton::colorChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setColorStroke );
661  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
662  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
663  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
664  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
665  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
666  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol );
667 }
668 
670 {
671  if ( layer->layerType() != QLatin1String( "SimpleMarker" ) )
672  return;
673 
674  // layer type is correct, we can do the cast
675  mLayer = static_cast<QgsSimpleMarkerSymbolLayer *>( layer );
676 
677  // set values
679  for ( int i = 0; i < lstNames->count(); ++i )
680  {
681  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
682  {
683  lstNames->setCurrentRow( i );
684  break;
685  }
686  }
687  btnChangeColorStroke->blockSignals( true );
688  btnChangeColorStroke->setColor( mLayer->strokeColor() );
689  btnChangeColorStroke->blockSignals( false );
690  btnChangeColorFill->blockSignals( true );
691  btnChangeColorFill->setColor( mLayer->fillColor() );
692  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
693  btnChangeColorFill->blockSignals( false );
694  spinSize->blockSignals( true );
695  spinSize->setValue( mLayer->size() );
696  spinSize->blockSignals( false );
697  spinAngle->blockSignals( true );
698  spinAngle->setValue( mLayer->angle() );
699  spinAngle->blockSignals( false );
700  mStrokeStyleComboBox->blockSignals( true );
701  mStrokeStyleComboBox->setPenStyle( mLayer->strokeStyle() );
702  mStrokeStyleComboBox->blockSignals( false );
703  mStrokeWidthSpinBox->blockSignals( true );
704  mStrokeWidthSpinBox->setValue( mLayer->strokeWidth() );
705  mStrokeWidthSpinBox->blockSignals( false );
706  cboJoinStyle->blockSignals( true );
707  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
708  cboJoinStyle->blockSignals( false );
709 
710  // without blocking signals the value gets changed because of slot setOffset()
711  spinOffsetX->blockSignals( true );
712  spinOffsetX->setValue( mLayer->offset().x() );
713  spinOffsetX->blockSignals( false );
714  spinOffsetY->blockSignals( true );
715  spinOffsetY->setValue( mLayer->offset().y() );
716  spinOffsetY->blockSignals( false );
717 
718  mSizeUnitWidget->blockSignals( true );
719  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
720  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
721  mSizeUnitWidget->blockSignals( false );
722  mOffsetUnitWidget->blockSignals( true );
723  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
724  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
725  mOffsetUnitWidget->blockSignals( false );
726  mStrokeWidthUnitWidget->blockSignals( true );
727  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
728  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
729  mStrokeWidthUnitWidget->blockSignals( false );
730 
731  //anchor points
732  mHorizontalAnchorComboBox->blockSignals( true );
733  mVerticalAnchorComboBox->blockSignals( true );
734  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
735  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
736  mHorizontalAnchorComboBox->blockSignals( false );
737  mVerticalAnchorComboBox->blockSignals( false );
738 
750 
751  updateAssistantSymbol();
752 }
753 
755 {
756  return mLayer;
757 }
758 
759 void QgsSimpleMarkerSymbolLayerWidget::setShape()
760 {
761  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
762  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
763  emit changed();
764 }
765 
767 {
768  mLayer->setStrokeColor( color );
769  emit changed();
770 }
771 
773 {
774  mLayer->setColor( color );
775  emit changed();
776 }
777 
778 void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
779 {
780  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
781  emit changed();
782 }
783 
784 void QgsSimpleMarkerSymbolLayerWidget::setSize()
785 {
786  mLayer->setSize( spinSize->value() );
787  emit changed();
788 }
789 
790 void QgsSimpleMarkerSymbolLayerWidget::setAngle()
791 {
792  mLayer->setAngle( spinAngle->value() );
793  emit changed();
794 }
795 
796 void QgsSimpleMarkerSymbolLayerWidget::setOffset()
797 {
798  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
799  emit changed();
800 }
801 
802 void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged( int index )
803 {
804  Q_UNUSED( index )
805 
806  if ( mLayer )
807  {
808  mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
809  emit changed();
810  }
811 }
812 
813 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
814 {
815  if ( mLayer )
816  {
817  mLayer->setStrokeWidth( d );
818  emit changed();
819  }
820 }
821 
822 void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
823 {
824  if ( mLayer )
825  {
826  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
827  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
828  emit changed();
829  }
830 }
831 
832 void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
833 {
834  if ( mLayer )
835  {
836  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
837  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
838  emit changed();
839  }
840 }
841 
842 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
843 {
844  if ( mLayer )
845  {
846  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
847  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
848  emit changed();
849  }
850 }
851 
852 void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
853 {
854  if ( mLayer )
855  {
857  emit changed();
858  }
859 }
860 
861 void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
862 {
863  if ( mLayer )
864  {
866  emit changed();
867  }
868 }
869 
870 void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
871 {
872  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
873  {
874  mAssistantPreviewSymbol->deleteSymbolLayer( i );
875  }
876  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
878  if ( ddSize )
879  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
880 }
881 
882 
884 
886  : QgsSymbolLayerWidget( parent, vl )
887 {
888  mLayer = nullptr;
889 
890  setupUi( this );
891  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
892  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed );
897 
898  btnChangeColor->setAllowOpacity( true );
899  btnChangeColor->setColorDialogTitle( tr( "Select Fill Color" ) );
900  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
901  btnChangeColor->setShowNoColor( true );
902  btnChangeColor->setNoColorString( tr( "Transparent Fill" ) );
903  btnChangeStrokeColor->setAllowOpacity( true );
904  btnChangeStrokeColor->setColorDialogTitle( tr( "Select Stroke Color" ) );
905  btnChangeStrokeColor->setContext( QStringLiteral( "symbology" ) );
906  btnChangeStrokeColor->setShowNoColor( true );
907  btnChangeStrokeColor->setNoColorString( tr( "Transparent Stroke" ) );
908 
909  spinOffsetX->setClearValue( 0.0 );
910  spinOffsetY->setClearValue( 0.0 );
911 
913  connect( cboFillStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
914  connect( btnChangeStrokeColor, &QgsColorButton::colorChanged, this, &QgsSimpleFillSymbolLayerWidget::setStrokeColor );
915  connect( spinStrokeWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
916  connect( cboStrokeStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
917  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
918  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
919  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
920 
921  mFillColorDDBtn->registerLinkedWidget( btnChangeColor );
922  mStrokeColorDDBtn->registerLinkedWidget( btnChangeStrokeColor );
923 }
924 
926 {
927  if ( layer->layerType() != QLatin1String( "SimpleFill" ) )
928  return;
929 
930  // layer type is correct, we can do the cast
931  mLayer = static_cast<QgsSimpleFillSymbolLayer *>( layer );
932 
933  // set values
934  btnChangeColor->blockSignals( true );
935  btnChangeColor->setColor( mLayer->color() );
936  btnChangeColor->blockSignals( false );
937  cboFillStyle->blockSignals( true );
938  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
939  cboFillStyle->blockSignals( false );
940  btnChangeStrokeColor->blockSignals( true );
941  btnChangeStrokeColor->setColor( mLayer->strokeColor() );
942  btnChangeStrokeColor->blockSignals( false );
943  cboStrokeStyle->blockSignals( true );
944  cboStrokeStyle->setPenStyle( mLayer->strokeStyle() );
945  cboStrokeStyle->blockSignals( false );
946  spinStrokeWidth->blockSignals( true );
947  spinStrokeWidth->setValue( mLayer->strokeWidth() );
948  spinStrokeWidth->blockSignals( false );
949  cboJoinStyle->blockSignals( true );
950  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
951  cboJoinStyle->blockSignals( false );
952  spinOffsetX->blockSignals( true );
953  spinOffsetX->setValue( mLayer->offset().x() );
954  spinOffsetX->blockSignals( false );
955  spinOffsetY->blockSignals( true );
956  spinOffsetY->setValue( mLayer->offset().y() );
957  spinOffsetY->blockSignals( false );
958 
959  mStrokeWidthUnitWidget->blockSignals( true );
960  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
961  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
962  mStrokeWidthUnitWidget->blockSignals( false );
963  mOffsetUnitWidget->blockSignals( true );
964  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
965  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
966  mOffsetUnitWidget->blockSignals( false );
967 
975 }
976 
978 {
979  return mLayer;
980 }
981 
982 void QgsSimpleFillSymbolLayerWidget::setColor( const QColor &color )
983 {
984  mLayer->setColor( color );
985  emit changed();
986 }
987 
989 {
990  mLayer->setStrokeColor( color );
991  emit changed();
992 }
993 
994 void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
995 {
996  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
997  emit changed();
998 }
999 
1000 void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
1001 {
1002  mLayer->setStrokeWidth( spinStrokeWidth->value() );
1003  emit changed();
1004 }
1005 
1006 void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
1007 {
1008  mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
1009  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
1010  emit changed();
1011 }
1012 
1013 void QgsSimpleFillSymbolLayerWidget::offsetChanged()
1014 {
1015  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1016  emit changed();
1017 }
1018 
1019 void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
1020 {
1021  if ( mLayer )
1022  {
1023  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
1024  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
1025  emit changed();
1026  }
1027 }
1028 
1029 void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1030 {
1031  if ( mLayer )
1032  {
1033  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1034  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1035  emit changed();
1036  }
1037 }
1038 
1040 
1042  : QgsSymbolLayerWidget( parent, vl )
1043 {
1044  mLayer = nullptr;
1045 
1046  setupUi( this );
1047  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
1048  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
1049  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1050  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1055 
1056  spinOffsetX->setClearValue( 0.0 );
1057  spinOffsetY->setClearValue( 0.0 );
1058  spinAngle->setClearValue( 0.0 );
1059 
1060  //make a temporary symbol for the size assistant preview
1061  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1062 
1063  if ( vectorLayer() )
1064  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
1065 
1066  int size = lstNames->iconSize().width();
1067 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
1068  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().width( 'X' ) * 3 ) ) );
1069 #else
1070  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
1071 #endif
1072  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
1073  lstNames->setIconSize( QSize( size, size ) );
1074 
1075  double markerSize = size * 0.8;
1077  for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
1078  {
1079  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
1081  lyr->setColor( QColor( 200, 200, 200 ) );
1082  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
1083  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
1084  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
1085  item->setData( Qt::UserRole, static_cast< int >( shape ) );
1086  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
1087  delete lyr;
1088  }
1089  // show at least 3 rows
1090  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
1091 
1092  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
1093  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
1094  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
1095  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1096  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1097  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
1098 }
1099 
1101 {
1102  if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
1103  return;
1104 
1105  // layer type is correct, we can do the cast
1106  mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
1107 
1108  // set values
1110  for ( int i = 0; i < lstNames->count(); ++i )
1111  {
1112  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
1113  {
1114  lstNames->setCurrentRow( i );
1115  break;
1116  }
1117  }
1118  whileBlocking( spinSize )->setValue( mLayer->size() );
1119  whileBlocking( spinAngle )->setValue( mLayer->angle() );
1120  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
1121  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
1122 
1123  mSizeUnitWidget->blockSignals( true );
1124  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1125  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1126  mSizeUnitWidget->blockSignals( false );
1127  mOffsetUnitWidget->blockSignals( true );
1128  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1129  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1130  mOffsetUnitWidget->blockSignals( false );
1131 
1132  //anchor points
1133  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1134  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
1135 
1142 
1143  updateAssistantSymbol();
1144 }
1145 
1147 {
1148  return mLayer;
1149 }
1150 
1151 void QgsFilledMarkerSymbolLayerWidget::setShape()
1152 {
1153  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
1154  emit changed();
1155 }
1156 
1157 void QgsFilledMarkerSymbolLayerWidget::setSize()
1158 {
1159  mLayer->setSize( spinSize->value() );
1160  emit changed();
1161 }
1162 
1163 void QgsFilledMarkerSymbolLayerWidget::setAngle()
1164 {
1165  mLayer->setAngle( spinAngle->value() );
1166  emit changed();
1167 }
1168 
1169 void QgsFilledMarkerSymbolLayerWidget::setOffset()
1170 {
1171  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1172  emit changed();
1173 }
1174 
1175 void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1176 {
1177  if ( mLayer )
1178  {
1179  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1180  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1181  emit changed();
1182  }
1183 }
1184 
1185 void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1186 {
1187  if ( mLayer )
1188  {
1189  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1190  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1191  emit changed();
1192  }
1193 }
1194 
1195 void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
1196 {
1197  if ( mLayer )
1198  {
1200  emit changed();
1201  }
1202 }
1203 
1204 void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
1205 {
1206  if ( mLayer )
1207  {
1209  emit changed();
1210  }
1211 }
1212 
1213 void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1214 {
1215  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1216  {
1217  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1218  }
1219  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1221  if ( ddSize )
1222  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1223 }
1224 
1225 
1227 
1229  : QgsSymbolLayerWidget( parent, vl )
1230 {
1231  mLayer = nullptr;
1232 
1233  setupUi( this );
1234  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1235  connect( mSpinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1238 
1239  btnColorRamp->setShowGradientOnly( true );
1240 
1241  btnChangeColor->setAllowOpacity( true );
1242  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1243  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1244  btnChangeColor->setShowNoColor( true );
1245  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1246  btnChangeColor2->setAllowOpacity( true );
1247  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1248  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1249  btnChangeColor2->setShowNoColor( true );
1250  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1251 
1252  mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1253  mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1254 
1255  spinOffsetX->setClearValue( 0.0 );
1256  spinOffsetY->setClearValue( 0.0 );
1257  mSpinAngle->setClearValue( 0.0 );
1258 
1262  connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1263  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1264  connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1265  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1266  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1267  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1268  connect( spinRefPoint1X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1269  connect( spinRefPoint1Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1270  connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1271  connect( spinRefPoint2X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1272  connect( spinRefPoint2Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1273  connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1274 }
1275 
1277 {
1278  if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1279  return;
1280 
1281  // layer type is correct, we can do the cast
1282  mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1283 
1284  // set values
1285  btnChangeColor->blockSignals( true );
1286  btnChangeColor->setColor( mLayer->color() );
1287  btnChangeColor->blockSignals( false );
1288  btnChangeColor2->blockSignals( true );
1289  btnChangeColor2->setColor( mLayer->color2() );
1290  btnChangeColor2->blockSignals( false );
1291 
1293  {
1294  radioTwoColor->setChecked( true );
1295  btnColorRamp->setEnabled( false );
1296  }
1297  else
1298  {
1299  radioColorRamp->setChecked( true );
1300  btnChangeColor->setEnabled( false );
1301  btnChangeColor2->setEnabled( false );
1302  }
1303 
1304  // set source color ramp
1305  if ( mLayer->colorRamp() )
1306  {
1307  btnColorRamp->blockSignals( true );
1308  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1309  btnColorRamp->blockSignals( false );
1310  }
1311 
1312  cboGradientType->blockSignals( true );
1313  switch ( mLayer->gradientType() )
1314  {
1316  cboGradientType->setCurrentIndex( 0 );
1317  break;
1319  cboGradientType->setCurrentIndex( 1 );
1320  break;
1322  cboGradientType->setCurrentIndex( 2 );
1323  break;
1324  }
1325  cboGradientType->blockSignals( false );
1326 
1327  cboCoordinateMode->blockSignals( true );
1328  switch ( mLayer->coordinateMode() )
1329  {
1331  cboCoordinateMode->setCurrentIndex( 1 );
1332  checkRefPoint1Centroid->setEnabled( false );
1333  checkRefPoint2Centroid->setEnabled( false );
1334  break;
1336  default:
1337  cboCoordinateMode->setCurrentIndex( 0 );
1338  break;
1339  }
1340  cboCoordinateMode->blockSignals( false );
1341 
1342  cboGradientSpread->blockSignals( true );
1343  switch ( mLayer->gradientSpread() )
1344  {
1346  cboGradientSpread->setCurrentIndex( 0 );
1347  break;
1349  cboGradientSpread->setCurrentIndex( 1 );
1350  break;
1352  cboGradientSpread->setCurrentIndex( 2 );
1353  break;
1354  }
1355  cboGradientSpread->blockSignals( false );
1356 
1357  spinRefPoint1X->blockSignals( true );
1358  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1359  spinRefPoint1X->blockSignals( false );
1360  spinRefPoint1Y->blockSignals( true );
1361  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1362  spinRefPoint1Y->blockSignals( false );
1363  checkRefPoint1Centroid->blockSignals( true );
1364  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1366  {
1367  spinRefPoint1X->setEnabled( false );
1368  spinRefPoint1Y->setEnabled( false );
1369  }
1370  checkRefPoint1Centroid->blockSignals( false );
1371  spinRefPoint2X->blockSignals( true );
1372  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1373  spinRefPoint2X->blockSignals( false );
1374  spinRefPoint2Y->blockSignals( true );
1375  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1376  spinRefPoint2Y->blockSignals( false );
1377  checkRefPoint2Centroid->blockSignals( true );
1378  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1380  {
1381  spinRefPoint2X->setEnabled( false );
1382  spinRefPoint2Y->setEnabled( false );
1383  }
1384  checkRefPoint2Centroid->blockSignals( false );
1385 
1386  spinOffsetX->blockSignals( true );
1387  spinOffsetX->setValue( mLayer->offset().x() );
1388  spinOffsetX->blockSignals( false );
1389  spinOffsetY->blockSignals( true );
1390  spinOffsetY->setValue( mLayer->offset().y() );
1391  spinOffsetY->blockSignals( false );
1392  mSpinAngle->blockSignals( true );
1393  mSpinAngle->setValue( mLayer->angle() );
1394  mSpinAngle->blockSignals( false );
1395 
1396  mOffsetUnitWidget->blockSignals( true );
1397  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1398  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1399  mOffsetUnitWidget->blockSignals( false );
1400 
1414 }
1415 
1417 {
1418  return mLayer;
1419 }
1420 
1422 {
1423  mLayer->setColor( color );
1424  emit changed();
1425 }
1426 
1428 {
1429  mLayer->setColor2( color );
1430  emit changed();
1431 }
1432 
1433 void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1434 {
1435  if ( radioTwoColor->isChecked() )
1436  {
1438  }
1439  else
1440  {
1442  }
1443  emit changed();
1444 }
1445 
1447 {
1448  if ( btnColorRamp->isNull() )
1449  return;
1450 
1451  mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1452  emit changed();
1453 }
1454 
1456 {
1457  switch ( index )
1458  {
1459  case 0:
1461  //set sensible default reference points
1462  spinRefPoint1X->setValue( 0.5 );
1463  spinRefPoint1Y->setValue( 0 );
1464  spinRefPoint2X->setValue( 0.5 );
1465  spinRefPoint2Y->setValue( 1 );
1466  break;
1467  case 1:
1469  //set sensible default reference points
1470  spinRefPoint1X->setValue( 0 );
1471  spinRefPoint1Y->setValue( 0 );
1472  spinRefPoint2X->setValue( 1 );
1473  spinRefPoint2Y->setValue( 1 );
1474  break;
1475  case 2:
1477  spinRefPoint1X->setValue( 0.5 );
1478  spinRefPoint1Y->setValue( 0.5 );
1479  spinRefPoint2X->setValue( 1 );
1480  spinRefPoint2Y->setValue( 1 );
1481  break;
1482  }
1483  emit changed();
1484 }
1485 
1487 {
1488 
1489  switch ( index )
1490  {
1491  case 0:
1492  //feature coordinate mode
1494  //allow choice of centroid reference positions
1495  checkRefPoint1Centroid->setEnabled( true );
1496  checkRefPoint2Centroid->setEnabled( true );
1497  break;
1498  case 1:
1499  //viewport coordinate mode
1501  //disable choice of centroid reference positions
1502  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1503  checkRefPoint1Centroid->setEnabled( false );
1504  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1505  checkRefPoint2Centroid->setEnabled( false );
1506  break;
1507  }
1508 
1509  emit changed();
1510 }
1511 
1513 {
1514  switch ( index )
1515  {
1516  case 0:
1518  break;
1519  case 1:
1521  break;
1522  case 2:
1524  break;
1525  }
1526 
1527  emit changed();
1528 }
1529 
1530 void QgsGradientFillSymbolLayerWidget::offsetChanged()
1531 {
1532  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1533  emit changed();
1534 }
1535 
1536 void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1537 {
1538  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1539  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1540  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1541  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1542  emit changed();
1543 }
1544 
1545 void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1546 {
1547  mLayer->setAngle( value );
1548  emit changed();
1549 }
1550 
1551 void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1552 {
1553  if ( mLayer )
1554  {
1555  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1556  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1557  emit changed();
1558  }
1559 }
1560 
1562 
1564  : QgsSymbolLayerWidget( parent, vl )
1565 {
1566  mLayer = nullptr;
1567 
1568  setupUi( this );
1569  connect( mSpinBlurRadius, qgis::overload< int >::of( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1570  connect( mSpinMaxDistance, qgis::overload< double >::of( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1571  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1572  connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1573  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1574  connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1579 
1580  QButtonGroup *group1 = new QButtonGroup( this );
1581  group1->addButton( radioColorRamp );
1582  group1->addButton( radioTwoColor );
1583  QButtonGroup *group2 = new QButtonGroup( this );
1584  group2->addButton( mRadioUseMaxDistance );
1585  group2->addButton( mRadioUseWholeShape );
1586  btnChangeColor->setAllowOpacity( true );
1587  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1588  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1589  btnChangeColor->setShowNoColor( true );
1590  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1591  btnChangeColor2->setAllowOpacity( true );
1592  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1593  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1594  btnChangeColor2->setShowNoColor( true );
1595  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1596 
1597  mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1598  mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1599 
1600  spinOffsetX->setClearValue( 0.0 );
1601  spinOffsetY->setClearValue( 0.0 );
1602  mSpinMaxDistance->setClearValue( 5.0 );
1603 
1604  btnColorRamp->setShowGradientOnly( true );
1605 
1606  connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1607 
1610  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1611  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1612  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1613 
1614  connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1615  connect( mSpinBlurRadius, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1616 }
1617 
1619 {
1620  if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1621  return;
1622 
1623  // layer type is correct, we can do the cast
1624  mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1625 
1626  // set values
1627  btnChangeColor->blockSignals( true );
1628  btnChangeColor->setColor( mLayer->color() );
1629  btnChangeColor->blockSignals( false );
1630  btnChangeColor2->blockSignals( true );
1631  btnChangeColor2->setColor( mLayer->color2() );
1632  btnChangeColor2->blockSignals( false );
1633 
1635  {
1636  radioTwoColor->setChecked( true );
1637  btnColorRamp->setEnabled( false );
1638  }
1639  else
1640  {
1641  radioColorRamp->setChecked( true );
1642  btnChangeColor->setEnabled( false );
1643  btnChangeColor2->setEnabled( false );
1644  }
1645 
1646  mSpinBlurRadius->blockSignals( true );
1647  mBlurSlider->blockSignals( true );
1648  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1649  mBlurSlider->setValue( mLayer->blurRadius() );
1650  mSpinBlurRadius->blockSignals( false );
1651  mBlurSlider->blockSignals( false );
1652 
1653  mSpinMaxDistance->blockSignals( true );
1654  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1655  mSpinMaxDistance->blockSignals( false );
1656 
1657  mRadioUseWholeShape->blockSignals( true );
1658  mRadioUseMaxDistance->blockSignals( true );
1659  if ( mLayer->useWholeShape() )
1660  {
1661  mRadioUseWholeShape->setChecked( true );
1662  mSpinMaxDistance->setEnabled( false );
1663  mDistanceUnitWidget->setEnabled( false );
1664  }
1665  else
1666  {
1667  mRadioUseMaxDistance->setChecked( true );
1668  mSpinMaxDistance->setEnabled( true );
1669  mDistanceUnitWidget->setEnabled( true );
1670  }
1671  mRadioUseWholeShape->blockSignals( false );
1672  mRadioUseMaxDistance->blockSignals( false );
1673 
1674  mDistanceUnitWidget->blockSignals( true );
1675  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1676  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1677  mDistanceUnitWidget->blockSignals( false );
1678 
1679  mIgnoreRingsCheckBox->blockSignals( true );
1680  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1681  mIgnoreRingsCheckBox->blockSignals( false );
1682 
1683  // set source color ramp
1684  if ( mLayer->colorRamp() )
1685  {
1686  btnColorRamp->blockSignals( true );
1687  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1688  btnColorRamp->blockSignals( false );
1689  }
1690 
1691  spinOffsetX->blockSignals( true );
1692  spinOffsetX->setValue( mLayer->offset().x() );
1693  spinOffsetX->blockSignals( false );
1694  spinOffsetY->blockSignals( true );
1695  spinOffsetY->setValue( mLayer->offset().y() );
1696  spinOffsetY->blockSignals( false );
1697  mOffsetUnitWidget->blockSignals( true );
1698  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1699  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1700  mOffsetUnitWidget->blockSignals( false );
1701 
1709 }
1710 
1712 {
1713  return mLayer;
1714 }
1715 
1717 {
1718  if ( mLayer )
1719  {
1720  mLayer->setColor( color );
1721  emit changed();
1722  }
1723 }
1724 
1726 {
1727  if ( mLayer )
1728  {
1729  mLayer->setColor2( color );
1730  emit changed();
1731  }
1732 }
1733 
1734 void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1735 {
1736  if ( !mLayer )
1737  {
1738  return;
1739  }
1740 
1741  if ( radioTwoColor->isChecked() )
1742  {
1744  }
1745  else
1746  {
1748  }
1749  emit changed();
1750 }
1751 
1752 void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1753 {
1754  if ( mLayer )
1755  {
1756  mLayer->setBlurRadius( value );
1757  emit changed();
1758  }
1759 }
1760 
1761 void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1762 {
1763  if ( mLayer )
1764  {
1765  mLayer->setMaxDistance( value );
1766  emit changed();
1767  }
1768 }
1769 
1770 void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1771 {
1772  if ( mLayer )
1773  {
1774  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1775  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1776  emit changed();
1777  }
1778 }
1779 
1780 void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1781 {
1782  if ( mLayer )
1783  {
1784  mLayer->setUseWholeShape( value );
1785  mDistanceUnitWidget->setEnabled( !value );
1786  emit changed();
1787  }
1788 }
1789 
1790 void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1791 {
1792  QgsColorRamp *ramp = btnColorRamp->colorRamp();
1793  if ( !ramp )
1794  return;
1795 
1796  mLayer->setColorRamp( ramp );
1797  emit changed();
1798 }
1799 
1800 void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1801 {
1802  if ( mLayer )
1803  {
1804  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1805  emit changed();
1806  }
1807 }
1808 
1809 void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1810 {
1811  if ( mLayer )
1812  {
1813  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1814  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1815  emit changed();
1816  }
1817 }
1818 
1819 
1820 void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1821 {
1822  bool checked = ( state == Qt::Checked );
1823  mLayer->setIgnoreRings( checked );
1824  emit changed();
1825 }
1826 
1828 
1830  : QgsSymbolLayerWidget( parent, vl )
1831 {
1832  mLayer = nullptr;
1833 
1834  setupUi( this );
1835  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1836  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1837  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1838  connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged );
1847 
1848  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1849  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1850  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1851  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
1852  {
1853  if ( mLayer )
1854  {
1855  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
1856  emit changed();
1857  }
1858  } );
1859 
1860  spinOffset->setClearValue( 0.0 );
1861 
1862  mSpinAverageAngleLength->setClearValue( 4.0 );
1863 
1864  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1865  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1866  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1867  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1868  connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setAverageAngle );
1869  connect( radInterval, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1870  connect( radVertex, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1871  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1872  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1873  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1874  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1875  connect( radSegmentCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1876 }
1877 
1879 {
1880  if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1881  return;
1882 
1883  // layer type is correct, we can do the cast
1884  mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1885 
1886  // set values
1887  spinInterval->blockSignals( true );
1888  spinInterval->setValue( mLayer->interval() );
1889  spinInterval->blockSignals( false );
1890  mSpinOffsetAlongLine->blockSignals( true );
1891  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1892  mSpinOffsetAlongLine->blockSignals( false );
1893  chkRotateMarker->blockSignals( true );
1894  chkRotateMarker->setChecked( mLayer->rotateSymbols() );
1895  chkRotateMarker->blockSignals( false );
1896  spinOffset->blockSignals( true );
1897  spinOffset->setValue( mLayer->offset() );
1898  spinOffset->blockSignals( false );
1900  radInterval->setChecked( true );
1902  radVertex->setChecked( true );
1904  radVertexLast->setChecked( true );
1906  radCentralPoint->setChecked( true );
1908  radCurvePoint->setChecked( true );
1910  radSegmentCentralPoint->setChecked( true );
1911  else
1912  radVertexFirst->setChecked( true );
1913 
1914  // set units
1915  mIntervalUnitWidget->blockSignals( true );
1916  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1917  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1918  mIntervalUnitWidget->blockSignals( false );
1919  mOffsetUnitWidget->blockSignals( true );
1920  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1921  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1922  mOffsetUnitWidget->blockSignals( false );
1923  mOffsetAlongLineUnitWidget->blockSignals( true );
1924  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1925  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1926  mOffsetAlongLineUnitWidget->blockSignals( false );
1927 
1928  whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
1929  whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
1930  whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
1931 
1932  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1933 
1934  setPlacement(); // update gui
1935 
1941 }
1942 
1944 {
1945  return mLayer;
1946 }
1947 
1949 {
1951 
1952  switch ( context.symbolType() )
1953  {
1954  case QgsSymbol::Marker:
1955  case QgsSymbol::Line:
1956  //these settings only have an effect when the symbol layers is part of a fill symbol
1957  mRingFilterComboBox->hide();
1958  mRingsLabel->hide();
1959  break;
1960 
1961  case QgsSymbol::Fill:
1962  case QgsSymbol::Hybrid:
1963  break;
1964  }
1965 }
1966 
1968 {
1969  mLayer->setInterval( val );
1970  emit changed();
1971 }
1972 
1974 {
1975  mLayer->setOffsetAlongLine( val );
1976  emit changed();
1977 }
1978 
1979 void QgsMarkerLineSymbolLayerWidget::setRotate()
1980 {
1981  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
1982  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
1983 
1984  mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
1985  emit changed();
1986 }
1987 
1988 void QgsMarkerLineSymbolLayerWidget::setOffset()
1989 {
1990  mLayer->setOffset( spinOffset->value() );
1991  emit changed();
1992 }
1993 
1994 void QgsMarkerLineSymbolLayerWidget::setPlacement()
1995 {
1996  bool interval = radInterval->isChecked();
1997  spinInterval->setEnabled( interval );
1998  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
1999  mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2000  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2001  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2002  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
2003  if ( radInterval->isChecked() )
2005  else if ( radVertex->isChecked() )
2007  else if ( radVertexLast->isChecked() )
2009  else if ( radVertexFirst->isChecked() )
2011  else if ( radCurvePoint->isChecked() )
2013  else if ( radSegmentCentralPoint->isChecked() )
2015  else
2017 
2018  emit changed();
2019 }
2020 
2021 void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2022 {
2023  if ( mLayer )
2024  {
2025  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2026  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2027  emit changed();
2028  }
2029 }
2030 
2031 void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2032 {
2033  if ( mLayer )
2034  {
2035  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2036  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2037  emit changed();
2038  }
2039 }
2040 
2041 void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2042 {
2043  if ( mLayer )
2044  {
2045  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2046  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2047  }
2048  emit changed();
2049 }
2050 
2051 void QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged()
2052 {
2053  if ( mLayer )
2054  {
2055  mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2056  mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2057  }
2058  emit changed();
2059 }
2060 
2061 void QgsMarkerLineSymbolLayerWidget::setAverageAngle( double val )
2062 {
2063  if ( mLayer )
2064  {
2065  mLayer->setAverageAngleLength( val );
2066  emit changed();
2067  }
2068 }
2069 
2070 
2072 
2074  : QgsSymbolLayerWidget( parent, vl )
2075 {
2076  mLayer = nullptr;
2077 
2078  setupUi( this );
2079  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed );
2080  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed );
2081  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
2082  connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged );
2083  connect( mHashLengthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged );
2094 
2095  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
2096  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
2097  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
2098  connect( mRingFilterComboBox, qgis::overload< int >::of( &QComboBox::currentIndexChanged ), this, [ = ]( int )
2099  {
2100  if ( mLayer )
2101  {
2102  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
2103  emit changed();
2104  }
2105  } );
2106 
2107  spinOffset->setClearValue( 0.0 );
2108 
2109  mHashRotationSpinBox->setClearValue( 0 );
2110  mSpinAverageAngleLength->setClearValue( 4.0 );
2111 
2112  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setInterval );
2113  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffsetAlongLine );
2114  connect( mSpinHashLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashLength );
2115  connect( mHashRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashAngle );
2116  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setRotate );
2117  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffset );
2118  connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setAverageAngle );
2119  connect( radInterval, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2120  connect( radVertex, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2121  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2122  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2123  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2124  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2125  connect( radSegmentCentralPoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2126 }
2127 
2129 {
2130  if ( layer->layerType() != QLatin1String( "HashLine" ) )
2131  return;
2132 
2133  // layer type is correct, we can do the cast
2134  mLayer = static_cast<QgsHashedLineSymbolLayer *>( layer );
2135 
2136  // set values
2137  spinInterval->blockSignals( true );
2138  spinInterval->setValue( mLayer->interval() );
2139  spinInterval->blockSignals( false );
2140  mSpinOffsetAlongLine->blockSignals( true );
2141  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
2142  mSpinOffsetAlongLine->blockSignals( false );
2143  whileBlocking( mSpinHashLength )->setValue( mLayer->hashLength() );
2144  whileBlocking( mHashRotationSpinBox )->setValue( mLayer->hashAngle() );
2145  chkRotateMarker->blockSignals( true );
2146  chkRotateMarker->setChecked( mLayer->rotateSymbols() );
2147  chkRotateMarker->blockSignals( false );
2148  spinOffset->blockSignals( true );
2149  spinOffset->setValue( mLayer->offset() );
2150  spinOffset->blockSignals( false );
2152  radInterval->setChecked( true );
2153  else if ( mLayer->placement() == QgsTemplatedLineSymbolLayerBase::Vertex )
2154  radVertex->setChecked( true );
2156  radVertexLast->setChecked( true );
2158  radCentralPoint->setChecked( true );
2160  radCurvePoint->setChecked( true );
2162  radSegmentCentralPoint->setChecked( true );
2163  else
2164  radVertexFirst->setChecked( true );
2165 
2166  // set units
2167  mIntervalUnitWidget->blockSignals( true );
2168  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
2169  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
2170  mIntervalUnitWidget->blockSignals( false );
2171  mOffsetUnitWidget->blockSignals( true );
2172  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2173  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2174  mOffsetUnitWidget->blockSignals( false );
2175  mOffsetAlongLineUnitWidget->blockSignals( true );
2176  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
2177  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
2178  mOffsetAlongLineUnitWidget->blockSignals( false );
2179  whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
2180  whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
2181  whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
2182  whileBlocking( mHashLengthUnitWidget )->setUnit( mLayer->hashLengthUnit() );
2183  whileBlocking( mHashLengthUnitWidget )->setMapUnitScale( mLayer->hashLengthMapUnitScale() );
2184 
2185  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
2186 
2187  setPlacement(); // update gui
2188 
2196 }
2197 
2199 {
2200  return mLayer;
2201 }
2202 
2204 {
2206 
2207  switch ( context.symbolType() )
2208  {
2209  case QgsSymbol::Marker:
2210  case QgsSymbol::Line:
2211  //these settings only have an effect when the symbol layers is part of a fill symbol
2212  mRingFilterComboBox->hide();
2213  mRingsLabel->hide();
2214  break;
2215 
2216  case QgsSymbol::Fill:
2217  case QgsSymbol::Hybrid:
2218  break;
2219  }
2220 }
2221 
2222 void QgsHashedLineSymbolLayerWidget::setInterval( double val )
2223 {
2224  mLayer->setInterval( val );
2225  emit changed();
2226 }
2227 
2228 void QgsHashedLineSymbolLayerWidget::setOffsetAlongLine( double val )
2229 {
2230  mLayer->setOffsetAlongLine( val );
2231  emit changed();
2232 }
2233 
2234 void QgsHashedLineSymbolLayerWidget::setHashLength( double val )
2235 {
2236  mLayer->setHashLength( val );
2237  emit changed();
2238 }
2239 
2240 void QgsHashedLineSymbolLayerWidget::setHashAngle( double val )
2241 {
2242  mLayer->setHashAngle( val );
2243  emit changed();
2244 }
2245 
2246 void QgsHashedLineSymbolLayerWidget::setRotate()
2247 {
2248  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2249  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2250 
2251  mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2252  emit changed();
2253 }
2254 
2255 void QgsHashedLineSymbolLayerWidget::setOffset()
2256 {
2257  mLayer->setOffset( spinOffset->value() );
2258  emit changed();
2259 }
2260 
2261 void QgsHashedLineSymbolLayerWidget::setPlacement()
2262 {
2263  bool interval = radInterval->isChecked();
2264  spinInterval->setEnabled( interval );
2265  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
2266  mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2267  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2268  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2269  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
2270  if ( radInterval->isChecked() )
2272  else if ( radVertex->isChecked() )
2274  else if ( radVertexLast->isChecked() )
2276  else if ( radVertexFirst->isChecked() )
2278  else if ( radCurvePoint->isChecked() )
2280  else if ( radSegmentCentralPoint->isChecked() )
2282  else
2284 
2285  emit changed();
2286 }
2287 
2288 void QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2289 {
2290  if ( mLayer )
2291  {
2292  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2293  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2294  emit changed();
2295  }
2296 }
2297 
2298 void QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2299 {
2300  if ( mLayer )
2301  {
2302  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2303  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2304  emit changed();
2305  }
2306 }
2307 
2308 void QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2309 {
2310  if ( mLayer )
2311  {
2312  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2313  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2314  }
2315  emit changed();
2316 }
2317 
2318 void QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged()
2319 {
2320  if ( mLayer )
2321  {
2322  mLayer->setHashLengthUnit( mHashLengthUnitWidget->unit() );
2323  mLayer->setHashLengthMapUnitScale( mHashLengthUnitWidget->getMapUnitScale() );
2324  }
2325  emit changed();
2326 }
2327 
2328 void QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged()
2329 {
2330  if ( mLayer )
2331  {
2332  mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2333  mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2334  }
2335  emit changed();
2336 }
2337 
2338 void QgsHashedLineSymbolLayerWidget::setAverageAngle( double val )
2339 {
2340  if ( mLayer )
2341  {
2342  mLayer->setAverageAngleLength( val );
2343  emit changed();
2344  }
2345 }
2346 
2348 
2349 
2351  : QgsSymbolLayerWidget( parent, vl )
2352 {
2353  mLayer = nullptr;
2354 
2355  setupUi( this );
2356 
2357  mSvgSelectorWidget->setAllowParameters( true );
2358  mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2359  mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
2360  mSvgSelectorWidget->initParametersModel( this, vl );
2361 
2362  connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
2363  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
2364  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2365  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2366  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2367  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2368  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2369  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2370  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2377  mChangeColorButton->setAllowOpacity( true );
2378  mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
2379  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2380  mChangeStrokeColorButton->setAllowOpacity( true );
2381  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2382  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2383 
2384  mFillColorDDBtn->registerLinkedWidget( mChangeColorButton );
2385  mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2386 
2387  spinOffsetX->setClearValue( 0.0 );
2388  spinOffsetY->setClearValue( 0.0 );
2389  spinAngle->setClearValue( 0.0 );
2390 
2391  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
2392  connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
2393  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
2394  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
2395  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2396  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2397  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
2398 
2399  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSvgMarkerSymbolLayerWidget::setSvgPath );
2401 
2402  //make a temporary symbol for the size assistant preview
2403  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2404 
2405  if ( vectorLayer() )
2406  {
2407  mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
2408  mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
2409  }
2410 }
2411 
2412 #include <QTime>
2413 #include <QAbstractListModel>
2414 #include <QPixmapCache>
2415 #include <QStyle>
2416 
2417 
2418 
2419 
2420 void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors )
2421 {
2422  if ( !layer )
2423  {
2424  return;
2425  }
2426 
2427  //activate gui for svg parameters only if supported by the svg file
2428  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2429  QColor defaultFill, defaultStroke;
2430  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2431  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2432  QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
2433  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2434  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2435  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2436  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2437  mChangeColorButton->setEnabled( hasFillParam );
2438  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2439  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2440  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2441  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2442 
2443  if ( hasFillParam )
2444  {
2445  QColor fill = layer->fillColor();
2446  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2447  if ( hasDefaultFillColor && !skipDefaultColors )
2448  {
2449  fill = defaultFill;
2450  }
2451  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
2452  mChangeColorButton->setColor( fill );
2453  }
2454  if ( hasStrokeParam )
2455  {
2456  QColor stroke = layer->strokeColor();
2457  double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2458  if ( hasDefaultStrokeColor && !skipDefaultColors )
2459  {
2460  stroke = defaultStroke;
2461  }
2462  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
2463  mChangeStrokeColorButton->setColor( stroke );
2464  }
2465 
2466  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( layer->path() );
2467 
2468  mStrokeWidthSpinBox->blockSignals( true );
2469  mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
2470  mStrokeWidthSpinBox->blockSignals( false );
2471 
2472  bool preservedAspectRatio = layer->preservedAspectRatio();
2473  spinHeight->blockSignals( true );
2474  if ( preservedAspectRatio )
2475  {
2476  spinHeight->setValue( layer->size() * layer->defaultAspectRatio() );
2477  }
2478  else
2479  {
2480  spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2481  }
2482  spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2483  spinHeight->blockSignals( false );
2484  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2485 }
2486 
2487 void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2488 {
2489  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2490  {
2491  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2492  }
2493  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2495  if ( ddSize )
2496  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2497 }
2498 
2499 
2501 {
2502  if ( !layer )
2503  {
2504  return;
2505  }
2506 
2507  if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2508  return;
2509 
2510  // layer type is correct, we can do the cast
2511  mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2512 
2513  // set values
2514  mSvgSelectorWidget->setSvgPath( mLayer->path() );
2515  mSvgSelectorWidget->setSvgParameters( mLayer->parameters() );
2516 
2517  spinWidth->blockSignals( true );
2518  spinWidth->setValue( mLayer->size() );
2519  spinWidth->blockSignals( false );
2520  spinAngle->blockSignals( true );
2521  spinAngle->setValue( mLayer->angle() );
2522  spinAngle->blockSignals( false );
2523 
2524  // without blocking signals the value gets changed because of slot setOffset()
2525  spinOffsetX->blockSignals( true );
2526  spinOffsetX->setValue( mLayer->offset().x() );
2527  spinOffsetX->blockSignals( false );
2528  spinOffsetY->blockSignals( true );
2529  spinOffsetY->setValue( mLayer->offset().y() );
2530  spinOffsetY->blockSignals( false );
2531 
2532  mSizeUnitWidget->blockSignals( true );
2533  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2534  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2535  mSizeUnitWidget->blockSignals( false );
2536  mStrokeWidthUnitWidget->blockSignals( true );
2537  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2538  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2539  mStrokeWidthUnitWidget->blockSignals( false );
2540  mOffsetUnitWidget->blockSignals( true );
2541  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2542  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2543  mOffsetUnitWidget->blockSignals( false );
2544 
2545  //anchor points
2546  mHorizontalAnchorComboBox->blockSignals( true );
2547  mVerticalAnchorComboBox->blockSignals( true );
2548  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2549  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2550  mHorizontalAnchorComboBox->blockSignals( false );
2551  mVerticalAnchorComboBox->blockSignals( false );
2552 
2553  setGuiForSvg( mLayer, true );
2554 
2564 
2565  registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::PropertyName );
2566 
2567  updateAssistantSymbol();
2568 }
2569 
2571 {
2572  return mLayer;
2573 }
2574 
2576 {
2578  mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2579 }
2580 
2582 {
2583  mLayer->setPath( name );
2584  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2585 
2586  setGuiForSvg( mLayer );
2587  emit changed();
2588 }
2589 
2590 void QgsSvgMarkerSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2591 {
2592  mLayer->setParameters( parameters );
2593  whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2594 
2595  setGuiForSvg( mLayer );
2596  emit changed();
2597 }
2598 
2599 void QgsSvgMarkerSymbolLayerWidget::setWidth()
2600 {
2601  double defaultAspectRatio = mLayer->defaultAspectRatio();
2602  double fixedAspectRatio = 0.0;
2603  spinHeight->blockSignals( true );
2604  if ( defaultAspectRatio <= 0.0 )
2605  {
2606  spinHeight->setValue( spinWidth->value() );
2607  }
2608  else if ( mLockAspectRatio->locked() )
2609  {
2610  spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2611  }
2612  else
2613  {
2614  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2615  }
2616  spinHeight->blockSignals( false );
2617  mLayer->setSize( spinWidth->value() );
2618  mLayer->setFixedAspectRatio( fixedAspectRatio );
2619  emit changed();
2620 }
2621 
2622 void QgsSvgMarkerSymbolLayerWidget::setHeight()
2623 {
2624  double defaultAspectRatio = mLayer->defaultAspectRatio();
2625  double fixedAspectRatio = 0.0;
2626  spinWidth->blockSignals( true );
2627  if ( defaultAspectRatio <= 0.0 )
2628  {
2629  spinWidth->setValue( spinHeight->value() );
2630  }
2631  else if ( mLockAspectRatio->locked() )
2632  {
2633  spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2634  }
2635  else
2636  {
2637  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2638  }
2639  spinWidth->blockSignals( false );
2640  mLayer->setSize( spinWidth->value() );
2641  mLayer->setFixedAspectRatio( fixedAspectRatio );
2642  emit changed();
2643 }
2644 
2645 void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2646 {
2647  //spinHeight->setEnabled( !locked );
2648  double defaultAspectRatio = mLayer->defaultAspectRatio();
2649  if ( defaultAspectRatio <= 0.0 )
2650  {
2651  whileBlocking( mLockAspectRatio )->setLocked( true );
2652  }
2653  else if ( locked )
2654  {
2655  mLayer->setFixedAspectRatio( 0.0 );
2656  setWidth();
2657  }
2658  else
2659  {
2660  mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2661  }
2662  //emit changed();
2663 }
2664 
2665 void QgsSvgMarkerSymbolLayerWidget::setAngle()
2666 {
2667  mLayer->setAngle( spinAngle->value() );
2668  emit changed();
2669 }
2670 
2671 void QgsSvgMarkerSymbolLayerWidget::setOffset()
2672 {
2673  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2674  emit changed();
2675 }
2676 
2677 void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2678 {
2679  mLayer->setPath( text );
2680  setGuiForSvg( mLayer );
2681  emit changed();
2682 }
2683 
2684 void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2685 {
2686  if ( !mLayer )
2687  {
2688  return;
2689  }
2690 
2691  mLayer->setFillColor( color );
2692  emit changed();
2693 }
2694 
2695 void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2696 {
2697  if ( !mLayer )
2698  {
2699  return;
2700  }
2701 
2702  mLayer->setStrokeColor( color );
2703  emit changed();
2704 }
2705 
2706 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2707 {
2708  if ( mLayer )
2709  {
2710  mLayer->setStrokeWidth( d );
2711  emit changed();
2712  }
2713 }
2714 
2715 void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2716 {
2717  if ( mLayer )
2718  {
2719  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2720  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2721  emit changed();
2722  }
2723 }
2724 
2725 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2726 {
2727  if ( mLayer )
2728  {
2729  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2730  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2731  emit changed();
2732  }
2733 }
2734 
2735 void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2736 {
2737  if ( mLayer )
2738  {
2739  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2740  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2741  emit changed();
2742  }
2743 }
2744 
2745 void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2746 {
2747  if ( mLayer )
2748  {
2750  emit changed();
2751  }
2752 }
2753 
2754 void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
2755 {
2756  if ( mLayer )
2757  {
2759  emit changed();
2760  }
2761 }
2762 
2764 
2766 {
2767  mLayer = nullptr;
2768  setupUi( this );
2769 
2770  mSvgSelectorWidget->setAllowParameters( true );
2771  mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2772 
2773  connect( mTextureWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2774  connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2775  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2776  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2777  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2778  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2779  connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2780  connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2785 
2786  mRotationSpinBox->setClearValue( 0.0 );
2787 
2788  mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2789  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2790  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2791  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2792 
2793  mFilColorDDBtn->registerLinkedWidget( mChangeColorButton );
2794  mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2795 
2796  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSVGFillSymbolLayerWidget::setFile );
2797  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsSVGFillSymbolLayerWidget::setSvgParameters );
2798 }
2799 
2801 {
2802  if ( !layer )
2803  {
2804  return;
2805  }
2806 
2807  if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2808  {
2809  return;
2810  }
2811 
2812  mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2813  if ( mLayer )
2814  {
2815  double width = mLayer->patternWidth();
2816  mTextureWidthSpinBox->blockSignals( true );
2817  mTextureWidthSpinBox->setValue( width );
2818  mTextureWidthSpinBox->blockSignals( false );
2819  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( mLayer->svgFilePath() );
2820  mRotationSpinBox->blockSignals( true );
2821  mRotationSpinBox->setValue( mLayer->angle() );
2822  mRotationSpinBox->blockSignals( false );
2823  mTextureWidthUnitWidget->blockSignals( true );
2824  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2825  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2826  mTextureWidthUnitWidget->blockSignals( false );
2827  mSvgStrokeWidthUnitWidget->blockSignals( true );
2828  mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2829  mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2830  mSvgStrokeWidthUnitWidget->blockSignals( false );
2831  mChangeColorButton->blockSignals( true );
2832  mChangeColorButton->setColor( mLayer->svgFillColor() );
2833  mChangeColorButton->blockSignals( false );
2834  mChangeStrokeColorButton->blockSignals( true );
2835  mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2836  mChangeStrokeColorButton->blockSignals( false );
2837  mStrokeWidthSpinBox->blockSignals( true );
2838  mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2839  mStrokeWidthSpinBox->blockSignals( false );
2840  }
2841  updateParamGui( false );
2842 
2848 
2849  registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::PropertyFile );
2850 }
2851 
2853 {
2854  return mLayer;
2855 }
2856 
2858 {
2860  mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2861 }
2862 
2863 void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2864 {
2865  if ( mLayer )
2866  {
2867  mLayer->setPatternWidth( d );
2868  emit changed();
2869  }
2870 }
2871 
2872 void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2873 {
2874  if ( !mLayer )
2875  {
2876  return;
2877  }
2878 
2879  mLayer->setSvgFilePath( text );
2880  updateParamGui();
2881  emit changed();
2882 }
2883 
2884 void QgsSVGFillSymbolLayerWidget::setFile( const QString &name )
2885 {
2886  mLayer->setSvgFilePath( name );
2887  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2888 
2889  updateParamGui();
2890  emit changed();
2891 }
2892 
2893 void QgsSVGFillSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2894 {
2895  mLayer->setParameters( parameters );
2896  whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2897 
2898  updateParamGui();
2899  emit changed();
2900 }
2901 
2902 
2903 void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2904 {
2905  if ( mLayer )
2906  {
2907  mLayer->setAngle( d );
2908  emit changed();
2909  }
2910 }
2911 
2913 {
2914  //activate gui for svg parameters only if supported by the svg file
2915  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2916  QColor defaultFill, defaultStroke;
2917  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2918  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2919  QgsApplication::svgCache()->containsParams( mSvgSelectorWidget->sourceLineEdit()->source(), hasFillParam, hasDefaultFillColor, defaultFill,
2920  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2921  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2922  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2923  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2924  if ( resetValues )
2925  {
2926  QColor fill = mChangeColorButton->color();
2927  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2928  if ( hasDefaultFillColor )
2929  {
2930  fill = defaultFill;
2931  }
2932  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2933  mChangeColorButton->setColor( fill );
2934  }
2935  mChangeColorButton->setEnabled( hasFillParam );
2936  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2937  if ( resetValues )
2938  {
2939  QColor stroke = mChangeStrokeColorButton->color();
2940  double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2941  if ( hasDefaultStrokeColor )
2942  {
2943  stroke = defaultStroke;
2944  }
2945  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
2946  mChangeStrokeColorButton->setColor( stroke );
2947  }
2948  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2949  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2950  if ( hasDefaultStrokeWidth && resetValues )
2951  {
2952  mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
2953  }
2954  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2955 }
2956 
2957 void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2958 {
2959  if ( !mLayer )
2960  {
2961  return;
2962  }
2963 
2964  mLayer->setSvgFillColor( color );
2965  emit changed();
2966 }
2967 
2968 void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2969 {
2970  if ( !mLayer )
2971  {
2972  return;
2973  }
2974 
2975  mLayer->setSvgStrokeColor( color );
2976  emit changed();
2977 }
2978 
2979 void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2980 {
2981  if ( mLayer )
2982  {
2983  mLayer->setSvgStrokeWidth( d );
2984  emit changed();
2985  }
2986 }
2987 
2988 void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
2989 {
2990  if ( mLayer )
2991  {
2992  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
2993  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
2994  emit changed();
2995  }
2996 }
2997 
2998 void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
2999 {
3000  if ( mLayer )
3001  {
3002  mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
3003  mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
3004  emit changed();
3005  }
3006 }
3007 
3009 
3011  QgsSymbolLayerWidget( parent, vl )
3012 {
3013  setupUi( this );
3014  connect( mAngleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
3015  connect( mDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
3016  connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
3017  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
3018  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3023  mOffsetSpinBox->setClearValue( 0 );
3024  mAngleSpinBox->setClearValue( 0 );
3025 }
3026 
3028 {
3029  if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
3030  {
3031  return;
3032  }
3033 
3034  QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
3035  if ( patternLayer )
3036  {
3037  mLayer = patternLayer;
3038  mAngleSpinBox->blockSignals( true );
3039  mAngleSpinBox->setValue( mLayer->lineAngle() );
3040  mAngleSpinBox->blockSignals( false );
3041  mDistanceSpinBox->blockSignals( true );
3042  mDistanceSpinBox->setValue( mLayer->distance() );
3043  mDistanceSpinBox->blockSignals( false );
3044  mOffsetSpinBox->blockSignals( true );
3045  mOffsetSpinBox->setValue( mLayer->offset() );
3046  mOffsetSpinBox->blockSignals( false );
3047 
3048  //units
3049  mDistanceUnitWidget->blockSignals( true );
3050  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
3051  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
3052  mDistanceUnitWidget->blockSignals( false );
3053  mOffsetUnitWidget->blockSignals( true );
3054  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3055  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3056  mOffsetUnitWidget->blockSignals( false );
3057  }
3058 
3061 }
3062 
3064 {
3065  return mLayer;
3066 }
3067 
3068 void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
3069 {
3070  if ( mLayer )
3071  {
3072  mLayer->setLineAngle( d );
3073  emit changed();
3074  }
3075 }
3076 
3077 void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
3078 {
3079  if ( mLayer )
3080  {
3081  mLayer->setDistance( d );
3082  emit changed();
3083  }
3084 }
3085 
3086 void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
3087 {
3088  if ( mLayer )
3089  {
3090  mLayer->setOffset( d );
3091  emit changed();
3092  }
3093 }
3094 
3095 void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
3096 {
3097  if ( mLayer )
3098  {
3099  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
3100  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
3101  emit changed();
3102  }
3103 }
3104 
3105 void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3106 {
3107  if ( mLayer )
3108  {
3109  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3110  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3111  emit changed();
3112  }
3113 }
3114 
3116 
3118  QgsSymbolLayerWidget( parent, vl )
3119 {
3120  setupUi( this );
3121  connect( mHorizontalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
3122  connect( mVerticalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
3123  connect( mHorizontalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
3124  connect( mVerticalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
3125  connect( mHorizontalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged );
3126  connect( mVerticalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged );
3127  connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
3128  connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
3129  connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
3130  connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
3131  connect( mHorizontalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed );
3132  connect( mVerticalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed );
3145 }
3146 
3147 
3149 {
3150  if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
3151  {
3152  return;
3153  }
3154 
3155  mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
3156  whileBlocking( mHorizontalDistanceSpinBox )->setValue( mLayer->distanceX() );
3157  whileBlocking( mVerticalDistanceSpinBox )->setValue( mLayer->distanceY() );
3158  whileBlocking( mHorizontalDisplacementSpinBox )->setValue( mLayer->displacementX() );
3159  whileBlocking( mVerticalDisplacementSpinBox )->setValue( mLayer->displacementY() );
3160  whileBlocking( mHorizontalOffsetSpinBox )->setValue( mLayer->offsetX() );
3161  whileBlocking( mVerticalOffsetSpinBox )->setValue( mLayer->offsetY() );
3162 
3163  mHorizontalDistanceUnitWidget->blockSignals( true );
3164  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
3165  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
3166  mHorizontalDistanceUnitWidget->blockSignals( false );
3167  mVerticalDistanceUnitWidget->blockSignals( true );
3168  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
3169  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
3170  mVerticalDistanceUnitWidget->blockSignals( false );
3171  mHorizontalDisplacementUnitWidget->blockSignals( true );
3172  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
3173  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
3174  mHorizontalDisplacementUnitWidget->blockSignals( false );
3175  mVerticalDisplacementUnitWidget->blockSignals( true );
3176  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
3177  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
3178  mVerticalDisplacementUnitWidget->blockSignals( false );
3179  mHorizontalOffsetUnitWidget->blockSignals( true );
3180  mHorizontalOffsetUnitWidget->setUnit( mLayer->offsetXUnit() );
3181  mHorizontalOffsetUnitWidget->setMapUnitScale( mLayer->offsetXMapUnitScale() );
3182  mHorizontalOffsetUnitWidget->blockSignals( false );
3183  mVerticalOffsetUnitWidget->blockSignals( true );
3184  mVerticalOffsetUnitWidget->setUnit( mLayer->offsetYUnit() );
3185  mVerticalOffsetUnitWidget->setMapUnitScale( mLayer->offsetYMapUnitScale() );
3186  mVerticalOffsetUnitWidget->blockSignals( false );
3187 
3188  registerDataDefinedButton( mHorizontalDistanceDDBtn, QgsSymbolLayer::PropertyDistanceX );
3190  registerDataDefinedButton( mHorizontalDisplacementDDBtn, QgsSymbolLayer::PropertyDisplacementX );
3194 }
3195 
3197 {
3198  return mLayer;
3199 }
3200 
3201 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
3202 {
3203  if ( mLayer )
3204  {
3205  mLayer->setDistanceX( d );
3206  emit changed();
3207  }
3208 }
3209 
3210 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
3211 {
3212  if ( mLayer )
3213  {
3214  mLayer->setDistanceY( d );
3215  emit changed();
3216  }
3217 }
3218 
3219 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
3220 {
3221  if ( mLayer )
3222  {
3223  mLayer->setDisplacementX( d );
3224  emit changed();
3225  }
3226 }
3227 
3228 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
3229 {
3230  if ( mLayer )
3231  {
3232  mLayer->setDisplacementY( d );
3233  emit changed();
3234  }
3235 }
3236 
3237 void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged( double d )
3238 {
3239  if ( mLayer )
3240  {
3241  mLayer->setOffsetX( d );
3242  emit changed();
3243  }
3244 }
3245 
3246 void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged( double d )
3247 {
3248  if ( mLayer )
3249  {
3250  mLayer->setOffsetY( d );
3251  emit changed();
3252  }
3253 }
3254 
3255 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
3256 {
3257  if ( mLayer )
3258  {
3259  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
3260  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
3261  emit changed();
3262  }
3263 }
3264 
3265 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
3266 {
3267  if ( mLayer )
3268  {
3269  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
3270  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
3271  emit changed();
3272  }
3273 }
3274 
3275 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
3276 {
3277  if ( mLayer )
3278  {
3279  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
3280  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
3281  emit changed();
3282  }
3283 }
3284 
3285 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
3286 {
3287  if ( mLayer )
3288  {
3289  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
3290  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
3291  emit changed();
3292  }
3293 }
3294 
3295 void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed()
3296 {
3297  if ( mLayer )
3298  {
3299  mLayer->setOffsetXUnit( mHorizontalOffsetUnitWidget->unit() );
3300  mLayer->setOffsetXMapUnitScale( mHorizontalOffsetUnitWidget->getMapUnitScale() );
3301  emit changed();
3302  }
3303 }
3304 
3305 void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed()
3306 {
3307  if ( mLayer )
3308  {
3309  mLayer->setOffsetYUnit( mVerticalOffsetUnitWidget->unit() );
3310  mLayer->setOffsetYMapUnitScale( mVerticalOffsetUnitWidget->getMapUnitScale() );
3311  emit changed();
3312  }
3313 }
3314 
3316 
3318  : QgsSymbolLayerWidget( parent, vl )
3319 {
3320  mLayer = nullptr;
3321 
3322  setupUi( this );
3323  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3324  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3325  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
3326  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
3327  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3328  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3335 
3336  widgetChar = new CharacterWidget();
3337  scrollArea->setWidget( widgetChar );
3338  scrollArea->setVerticalOnly( true );
3339 
3340  btnColor->setAllowOpacity( true );
3341  btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
3342  btnColor->setContext( QStringLiteral( "symbology" ) );
3343  btnStrokeColor->setAllowOpacity( true );
3344  btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
3345  btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
3346 
3347  mColorDDBtn->registerLinkedWidget( btnColor );
3348  mStrokeColorDDBtn->registerLinkedWidget( btnStrokeColor );
3349 
3350  spinOffsetX->setClearValue( 0.0 );
3351  spinOffsetY->setClearValue( 0.0 );
3352  spinAngle->setClearValue( 0.0 );
3353 
3354  //make a temporary symbol for the size assistant preview
3355  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
3356 
3357  if ( vectorLayer() )
3358  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
3359 
3360  connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
3361  connect( mFontStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged );
3362  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
3363  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3366  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3367  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
3368  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3369  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3371  connect( mCharLineEdit, &QLineEdit::textChanged, this, &QgsFontMarkerSymbolLayerWidget::setCharacterFromText );
3372 
3373  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
3374 }
3375 
3377 {
3378  if ( layer->layerType() != QLatin1String( "FontMarker" ) )
3379  return;
3380 
3381  // layer type is correct, we can do the cast
3382  mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
3383 
3384  mRefFont.setFamily( mLayer->fontFamily() );
3385  mRefFont.setStyleName( QgsFontUtils::translateNamedStyle( mLayer->fontStyle() ) );
3386 
3387  mFontStyleComboBox->blockSignals( true );
3388  populateFontStyleComboBox();
3389  mFontStyleComboBox->blockSignals( false );
3390 
3391  // set values
3392  whileBlocking( cboFont )->setCurrentFont( mRefFont );
3393  whileBlocking( spinSize )->setValue( mLayer->size() );
3394  whileBlocking( btnColor )->setColor( mLayer->color() );
3395  whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
3396  whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
3397  whileBlocking( spinAngle )->setValue( mLayer->angle() );
3398 
3399  widgetChar->blockSignals( true );
3400  widgetChar->setFont( mRefFont );
3401  if ( mLayer->character().length() == 1 )
3402  {
3403  widgetChar->setCharacter( mLayer->character().at( 0 ) );
3404  }
3405  widgetChar->blockSignals( false );
3406  whileBlocking( mCharLineEdit )->setText( mLayer->character() );
3407  mCharPreview->setFont( mRefFont );
3408 
3409  //block
3410  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
3411  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
3412 
3413  mSizeUnitWidget->blockSignals( true );
3414  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3415  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3416  mSizeUnitWidget->blockSignals( false );
3417 
3418  mStrokeWidthUnitWidget->blockSignals( true );
3419  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
3420  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
3421  mStrokeWidthUnitWidget->blockSignals( false );
3422 
3423  mOffsetUnitWidget->blockSignals( true );
3424  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3425  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3426  mOffsetUnitWidget->blockSignals( false );
3427 
3428  whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
3429 
3430  //anchor points
3431  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
3432  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
3433 
3446 
3447  updateAssistantSymbol();
3448 }
3449 
3451 {
3452  return mLayer;
3453 }
3454 
3456 {
3457  if ( mLayer )
3458  {
3459  mLayer->setFontFamily( font.family() );
3460  mRefFont.setFamily( font.family() );
3461  widgetChar->setFont( mRefFont );
3462  mCharPreview->setFont( mRefFont );
3463  populateFontStyleComboBox();
3464  emit changed();
3465  }
3466 }
3467 
3468 void QgsFontMarkerSymbolLayerWidget::setFontStyle( const QString &style )
3469 {
3470  if ( mLayer )
3471  {
3472  QgsFontUtils::updateFontViaStyle( mRefFont, style );
3474  widgetChar->setFont( mRefFont );
3475  mCharPreview->setFont( mRefFont );
3476  emit changed();
3477  }
3478 }
3479 
3480 void QgsFontMarkerSymbolLayerWidget::setColor( const QColor &color )
3481 {
3482  mLayer->setColor( color );
3483  emit changed();
3484 }
3485 
3487 {
3488  mLayer->setStrokeColor( color );
3489  emit changed();
3490 }
3491 
3493 {
3494  mLayer->setSize( size );
3495  //widgetChar->updateSize(size);
3496  emit changed();
3497 }
3498 
3500 {
3501  mLayer->setAngle( angle );
3502  emit changed();
3503 }
3504 
3506 {
3507  mCharPreview->setText( text );
3508 
3509  if ( text.isEmpty() )
3510  return;
3511 
3512  // take the last character of a string for a better experience when users cycle through several characters on their keyboard
3513  QString character = text;
3514  if ( text.contains( QRegularExpression( QStringLiteral( "^0x[0-9a-fA-F]{1,4}$" ) ) ) )
3515  {
3516  bool ok = false;
3517  unsigned int value = text.toUInt( &ok, 0 );
3518  if ( ok )
3519  {
3520  character = QChar( value );
3521  mCharPreview->setText( character );
3522  }
3523  }
3524 
3525  if ( character != mLayer->character() )
3526  {
3527  mLayer->setCharacter( character );
3528  if ( mLayer->character().length() == 1 )
3529  {
3530  whileBlocking( widgetChar )->setCharacter( mLayer->character().at( 0 ) );
3531  }
3532  else
3533  {
3535  }
3536  emit changed();
3537  }
3538 }
3539 
3541 {
3542  if ( mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
3543  {
3544  mCharLineEdit->insert( chr );
3545  return;
3546  }
3547 
3548  mLayer->setCharacter( chr );
3549  whileBlocking( mCharLineEdit )->setText( chr );
3550  mCharPreview->setText( chr );
3551  emit changed();
3552 }
3553 
3554 void QgsFontMarkerSymbolLayerWidget::setOffset()
3555 {
3556  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
3557  emit changed();
3558 }
3559 
3560 void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
3561 {
3562  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
3563  emit changed();
3564 }
3565 
3566 void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3567 {
3568  if ( mLayer )
3569  {
3570  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3571  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3572  emit changed();
3573  }
3574 }
3575 
3576 void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3577 {
3578  if ( mLayer )
3579  {
3580  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3581  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3582  emit changed();
3583  }
3584 }
3585 
3586 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
3587 {
3588  if ( mLayer )
3589  {
3590  mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
3591  mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3592  emit changed();
3593  }
3594 }
3595 
3596 void QgsFontMarkerSymbolLayerWidget::populateFontStyleComboBox()
3597 {
3598  mFontStyleComboBox->clear();
3599  QStringList styles = mFontDB.styles( mRefFont.family() );
3600  const auto constStyles = styles;
3601  for ( const QString &style : constStyles )
3602  {
3603  mFontStyleComboBox->addItem( style );
3604  }
3605 
3606  QString targetStyle = mFontDB.styleString( mRefFont );
3607  if ( !styles.contains( targetStyle ) )
3608  {
3609  QFont f = QFont( mRefFont.family() );
3610  targetStyle = QFontInfo( f ).styleName();
3611  mRefFont.setStyleName( targetStyle );
3612  }
3613  int curIndx = 0;
3614  int stylIndx = mFontStyleComboBox->findText( targetStyle );
3615  if ( stylIndx > -1 )
3616  {
3617  curIndx = stylIndx;
3618  }
3619 
3620  mFontStyleComboBox->setCurrentIndex( curIndx );
3621 }
3622 
3623 void QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged( int index )
3624 {
3625  Q_UNUSED( index );
3626  setFontStyle( mFontStyleComboBox->currentText() );
3627 }
3628 
3629 void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
3630 {
3631  if ( mLayer )
3632  {
3634  emit changed();
3635  }
3636 }
3637 
3638 void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3639 {
3640  if ( mLayer )
3641  {
3643  emit changed();
3644  }
3645 }
3646 
3647 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3648 {
3649  if ( mLayer )
3650  {
3651  mLayer->setStrokeWidth( d );
3652  emit changed();
3653  }
3654 }
3655 
3656 void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3657 {
3658  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
3659  {
3660  mAssistantPreviewSymbol->deleteSymbolLayer( i );
3661  }
3662  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3664  if ( ddSize )
3665  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3666 }
3667 
3669 
3670 
3672  : QgsSymbolLayerWidget( parent, vl )
3673 {
3674  mLayer = nullptr;
3675 
3676  setupUi( this );
3677  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3678  connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3679  connect( mClipPointsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged );
3680  connect( mClipOnCurrentPartOnlyCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged );
3681 }
3682 
3684 {
3685  if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3686  return;
3687 
3688  // layer type is correct, we can do the cast
3689  mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3690 
3691  // set values
3692  whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3693  whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3694  whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
3695  whileBlocking( mClipOnCurrentPartOnlyCheckBox )->setChecked( mLayer->clipOnCurrentPartOnly() );
3696 }
3697 
3699 {
3700  return mLayer;
3701 }
3702 
3703 void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3704 {
3705  mLayer->setPointOnSurface( state == Qt::Checked );
3706  emit changed();
3707 }
3708 
3709 void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3710 {
3711  mLayer->setPointOnAllParts( state == Qt::Checked );
3712  emit changed();
3713 }
3714 
3715 void QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged( int state )
3716 {
3717  mLayer->setClipPoints( state == Qt::Checked );
3718  emit changed();
3719 }
3720 
3721 void QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged( int state )
3722 {
3723  mLayer->setClipOnCurrentPartOnly( state == Qt::Checked );
3724  emit changed();
3725 }
3726 
3728 
3730  : QgsSymbolLayerWidget( parent, vl )
3731 {
3732  mLayer = nullptr;
3733 
3734  setupUi( this );
3735 
3736  mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
3737 
3738  connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterMarkerSymbolLayerWidget::imageSourceChanged );
3739  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3740  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setAngle );
3741  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3742  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setWidth );
3743  connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setHeight );
3744  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio );
3745 
3750 
3751  mSpinOffsetX->setClearValue( 0.0 );
3752  mSpinOffsetY->setClearValue( 0.0 );
3753  mRotationSpinBox->setClearValue( 0.0 );
3754 
3755  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3756  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3757  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterMarkerSymbolLayerWidget::setOpacity );
3758 
3759  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3760  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3761 }
3762 
3764 {
3765  if ( !layer )
3766  {
3767  return;
3768  }
3769 
3770  if ( layer->layerType() != QLatin1String( "RasterMarker" ) )
3771  return;
3772 
3773  // layer type is correct, we can do the cast
3774  mLayer = static_cast<QgsRasterMarkerSymbolLayer *>( layer );
3775 
3776  // set values
3777  whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
3778 
3779  whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
3780  bool preservedAspectRatio = mLayer->preservedAspectRatio();
3781  mHeightSpinBox->blockSignals( true );
3782  if ( preservedAspectRatio )
3783  {
3784  mHeightSpinBox->setValue( mLayer->size() );
3785  }
3786  else
3787  {
3788  mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
3789  }
3790  mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
3791  mHeightSpinBox->blockSignals( false );
3792  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
3793 
3794  whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
3795  whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
3796 
3797  whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
3798  whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
3799 
3800  mSizeUnitWidget->blockSignals( true );
3801  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3802  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3803  mSizeUnitWidget->blockSignals( false );
3804  mOffsetUnitWidget->blockSignals( true );
3805  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3806  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3807  mOffsetUnitWidget->blockSignals( false );
3808 
3809  //anchor points
3810  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
3811  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
3812 
3821 
3822  updatePreviewImage();
3823 }
3824 
3826 {
3827  return mLayer;
3828 }
3829 
3831 {
3833  mImageSourceLineEdit->setMessageBar( context.messageBar() );
3834 }
3835 
3836 void QgsRasterMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
3837 {
3838  mLayer->setPath( text );
3839  updatePreviewImage();
3840  emit changed();
3841 }
3842 
3843 void QgsRasterMarkerSymbolLayerWidget::updatePreviewImage()
3844 {
3845  bool fitsInCache = false;
3846  QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
3847  if ( image.isNull() )
3848  {
3849  mLabelImagePreview->setPixmap( QPixmap() );
3850  return;
3851  }
3852 
3853  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3854  previewImage.fill( Qt::transparent );
3855  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3856  QPainter p;
3857  p.begin( &previewImage );
3858  //draw a checkerboard background
3859  uchar pixDataRGB[] = { 150, 150, 150, 150,
3860  100, 100, 100, 150,
3861  100, 100, 100, 150,
3862  150, 150, 150, 150
3863  };
3864  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3865  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3866  QBrush checkerBrush;
3867  checkerBrush.setTexture( pix );
3868  p.fillRect( imageRect, checkerBrush );
3869 
3870  if ( mLayer->opacity() < 1.0 )
3871  {
3872  p.setOpacity( mLayer->opacity() );
3873  }
3874 
3875  p.drawImage( imageRect.left(), imageRect.top(), image );
3876  p.end();
3877  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3878 }
3879 
3880 void QgsRasterMarkerSymbolLayerWidget::setWidth()
3881 {
3882  double defaultAspectRatio = mLayer->defaultAspectRatio();
3883  double fixedAspectRatio = 0.0;
3884  mHeightSpinBox->blockSignals( true );
3885  if ( defaultAspectRatio <= 0.0 )
3886  {
3887  mHeightSpinBox->setValue( mWidthSpinBox->value() );
3888  }
3889  else if ( mLockAspectRatio->locked() )
3890  {
3891  mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
3892  }
3893  else
3894  {
3895  fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3896  }
3897  mHeightSpinBox->blockSignals( false );
3898  mLayer->setSize( mWidthSpinBox->value() );
3899  mLayer->setFixedAspectRatio( fixedAspectRatio );
3900  emit changed();
3901 }
3902 
3903 void QgsRasterMarkerSymbolLayerWidget::setHeight()
3904 {
3905  double defaultAspectRatio = mLayer->defaultAspectRatio();
3906  double fixedAspectRatio = 0.0;
3907  mWidthSpinBox->blockSignals( true );
3908  if ( defaultAspectRatio <= 0.0 )
3909  {
3910  mWidthSpinBox->setValue( mHeightSpinBox->value() );
3911  }
3912  else if ( mLockAspectRatio->locked() )
3913  {
3914  mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
3915  }
3916  else
3917  {
3918  fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3919  }
3920  mWidthSpinBox->blockSignals( false );
3921  mLayer->setSize( mWidthSpinBox->value() );
3922  mLayer->setFixedAspectRatio( fixedAspectRatio );
3923  emit changed();
3924 }
3925 
3926 void QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
3927 {
3928  double defaultAspectRatio = mLayer->defaultAspectRatio();
3929  if ( defaultAspectRatio <= 0.0 )
3930  {
3931  whileBlocking( mLockAspectRatio )->setLocked( true );
3932  }
3933  else if ( locked )
3934  {
3935  mLayer->setFixedAspectRatio( 0.0 );
3936  setWidth();
3937  }
3938  else
3939  {
3940  mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
3941  }
3942 }
3943 
3944 void QgsRasterMarkerSymbolLayerWidget::setAngle()
3945 {
3946  mLayer->setAngle( mRotationSpinBox->value() );
3947  emit changed();
3948 }
3949 
3950 void QgsRasterMarkerSymbolLayerWidget::setOpacity( double value )
3951 {
3952  mLayer->setOpacity( value );
3953  emit changed();
3954  updatePreviewImage();
3955 }
3956 
3957 void QgsRasterMarkerSymbolLayerWidget::setOffset()
3958 {
3959  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
3960  emit changed();
3961 }
3962 
3963 void QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3964 {
3965  if ( mLayer )
3966  {
3967  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3968  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3969  emit changed();
3970  }
3971 }
3972 
3973 void QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3974 {
3975  if ( mLayer )
3976  {
3977  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3978  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3979  emit changed();
3980  }
3981 }
3982 
3983 void QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
3984 {
3985  if ( mLayer )
3986  {
3988  emit changed();
3989  }
3990 }
3991 
3992 void QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3993 {
3994  if ( mLayer )
3995  {
3997  emit changed();
3998  }
3999 }
4000 
4002 
4004  : QgsSymbolLayerWidget( parent, vl )
4005 {
4006  mLayer = nullptr;
4007  setupUi( this );
4008 
4009  mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4010  connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterFillSymbolLayerWidget::imageSourceChanged );
4011 
4012  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
4013  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
4014  connect( mWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed );
4015  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged );
4016 
4021 
4022  mSpinOffsetX->setClearValue( 0.0 );
4023  mSpinOffsetY->setClearValue( 0.0 );
4024  mRotationSpinBox->setClearValue( 0.0 );
4025 
4026  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
4027  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4028  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4029  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
4030 }
4031 
4032 
4034 {
4035  if ( !layer )
4036  {
4037  return;
4038  }
4039 
4040  if ( layer->layerType() != QLatin1String( "RasterFill" ) )
4041  {
4042  return;
4043  }
4044 
4045  mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
4046  if ( !mLayer )
4047  {
4048  return;
4049  }
4050 
4051  whileBlocking( mImageSourceLineEdit )->setSource( mLayer->imageFilePath() );
4052 
4053  cboCoordinateMode->blockSignals( true );
4054  switch ( mLayer->coordinateMode() )
4055  {
4057  cboCoordinateMode->setCurrentIndex( 1 );
4058  break;
4060  default:
4061  cboCoordinateMode->setCurrentIndex( 0 );
4062  break;
4063  }
4064  cboCoordinateMode->blockSignals( false );
4065  whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4066  whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4067 
4068  whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4069  whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4070  mOffsetUnitWidget->blockSignals( true );
4071  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4072  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4073  mOffsetUnitWidget->blockSignals( false );
4074 
4075  whileBlocking( mWidthSpinBox )->setValue( mLayer->width() );
4076  mWidthUnitWidget->blockSignals( true );
4077  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
4078  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
4079  mWidthUnitWidget->blockSignals( false );
4080 
4081  updatePreviewImage();
4082 
4088 }
4089 
4091 {
4092  return mLayer;
4093 }
4094 
4095 void QgsRasterFillSymbolLayerWidget::imageSourceChanged( const QString &text )
4096 {
4097  mLayer->setImageFilePath( text );
4098  updatePreviewImage();
4099  emit changed();
4100 }
4101 
4102 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
4103 {
4104  switch ( index )
4105  {
4106  case 0:
4107  //feature coordinate mode
4109  break;
4110  case 1:
4111  //viewport coordinate mode
4113  break;
4114  }
4115 
4116  emit changed();
4117 }
4118 
4119 void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
4120 {
4121  if ( !mLayer )
4122  {
4123  return;
4124  }
4125 
4126  mLayer->setOpacity( value );
4127  emit changed();
4128  updatePreviewImage();
4129 }
4130 
4131 void QgsRasterFillSymbolLayerWidget::offsetChanged()
4132 {
4133  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4134  emit changed();
4135 }
4136 
4137 void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
4138 {
4139  if ( !mLayer )
4140  {
4141  return;
4142  }
4143  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4144  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4145  emit changed();
4146 }
4147 
4148 void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
4149 {
4150  if ( mLayer )
4151  {
4152  mLayer->setAngle( d );
4153  emit changed();
4154  }
4155 }
4156 
4157 void QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed()
4158 {
4159  if ( !mLayer )
4160  {
4161  return;
4162  }
4163  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
4164  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4165  emit changed();
4166 }
4167 
4168 void QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged( double d )
4169 {
4170  if ( !mLayer )
4171  {
4172  return;
4173  }
4174  mLayer->setWidth( d );
4175  emit changed();
4176 }
4177 
4178 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
4179 {
4180  bool fitsInCache = false;
4181  QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->imageFilePath(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4182  if ( image.isNull() )
4183  {
4184  mLabelImagePreview->setPixmap( QPixmap() );
4185  return;
4186  }
4187 
4188  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4189  previewImage.fill( Qt::transparent );
4190  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4191  QPainter p;
4192  p.begin( &previewImage );
4193  //draw a checkerboard background
4194  uchar pixDataRGB[] = { 150, 150, 150, 150,
4195  100, 100, 100, 150,
4196  100, 100, 100, 150,
4197  150, 150, 150, 150
4198  };
4199  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4200  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4201  QBrush checkerBrush;
4202  checkerBrush.setTexture( pix );
4203  p.fillRect( imageRect, checkerBrush );
4204 
4205  if ( mLayer->opacity() < 1.0 )
4206  {
4207  p.setOpacity( mLayer->opacity() );
4208  }
4209 
4210  p.drawImage( imageRect.left(), imageRect.top(), image );
4211  p.end();
4212  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4213 }
4214 
4215 
4217  : QgsSymbolLayerWidget( parent, vl )
4218 
4219 {
4220  setupUi( this );
4221  modificationExpressionSelector->setMultiLine( true );
4222  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
4223  modificationExpressionSelector->registerExpressionContextGenerator( this );
4224  cbxGeometryType->addItem( QgsLayerItem::iconPolygon(), tr( "Polygon / MultiPolygon" ), QgsSymbol::Fill );
4225  cbxGeometryType->addItem( QgsLayerItem::iconLine(), tr( "LineString / MultiLineString" ), QgsSymbol::Line );
4226  cbxGeometryType->addItem( QgsLayerItem::iconPoint(), tr( "Point / MultiPoint" ), QgsSymbol::Marker );
4227  connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
4228  connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
4229 }
4230 
4232 {
4233  mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
4234  modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
4235  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( mLayer->symbolType() ) );
4236 }
4237 
4239 {
4240  return mLayer;
4241 }
4242 
4243 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
4244 {
4245  mLayer->setGeometryExpression( string );
4246 
4247  emit changed();
4248 }
4249 
4250 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
4251 {
4252  mLayer->setSymbolType( static_cast<QgsSymbol::SymbolType>( cbxGeometryType->currentData().toInt() ) );
4253 
4254  emit symbolChanged();
4255 }
4256 
4257 //
4258 // QgsRandomMarkerFillSymbolLayerWidget
4259 //
4260 
4261 
4263  QgsSymbolLayerWidget( parent, vl )
4264 {
4265  setupUi( this );
4266 
4267  mCountMethodComboBox->addItem( tr( "Absolute Count" ), QgsRandomMarkerFillSymbolLayer::AbsoluteCount );
4268  mCountMethodComboBox->addItem( tr( "Density-based Count" ), QgsRandomMarkerFillSymbolLayer::DensityBasedCount );
4269 
4270  mPointCountSpinBox->setShowClearButton( true );
4271  mPointCountSpinBox->setClearValue( 100 );
4272  mSeedSpinBox->setShowClearButton( true );
4273  mSeedSpinBox->setClearValue( 0 );
4274 
4275  connect( mCountMethodComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged );
4276  connect( mPointCountSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countChanged );
4277  connect( mDensityAreaSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged );
4278  connect( mSeedSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::seedChanged );
4279  connect( mClipPointsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
4280  {
4281  if ( mLayer )
4282  {
4283  mLayer->setClipPoints( checked );
4284  emit changed();
4285  }
4286  } );
4287 
4290 
4291  connect( mDensityAreaUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged );
4292 }
4293 
4295 {
4296  if ( !layer || layer->layerType() != QLatin1String( "RandomMarkerFill" ) )
4297  {
4298  return;
4299  }
4300 
4301  mLayer = static_cast<QgsRandomMarkerFillSymbolLayer *>( layer );
4302  whileBlocking( mPointCountSpinBox )->setValue( mLayer->pointCount() );
4303  whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
4304  whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
4305 
4306  bool showDensityBasedCountWidgets = false;
4307  switch ( mLayer->countMethod() )
4308  {
4310  showDensityBasedCountWidgets = true;
4311  break;
4313  break;
4314  }
4315  mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4316  mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4317  mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4318  mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4319 
4320  whileBlocking( mCountMethodComboBox )->setCurrentIndex( mCountMethodComboBox->findData( mLayer->countMethod() ) );
4321  whileBlocking( mDensityAreaSpinBox )->setValue( mLayer->densityArea() );
4322  mDensityAreaUnitWidget->blockSignals( true );
4323  mDensityAreaUnitWidget->setUnit( mLayer->densityAreaUnit() );
4324  mDensityAreaUnitWidget->setMapUnitScale( mLayer->densityAreaUnitScale() );
4325  mDensityAreaUnitWidget->blockSignals( false );
4326 
4331 }
4332 
4334 {
4335  return mLayer;
4336 }
4337 
4338 void QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged( int )
4339 {
4340 
4341  bool showDensityBasedCountWidgets = false;
4342  switch ( static_cast< QgsRandomMarkerFillSymbolLayer::CountMethod >( mCountMethodComboBox->currentData().toInt() ) )
4343  {
4345  showDensityBasedCountWidgets = true;
4346  break;
4348  break;
4349  }
4350  mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4351  mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4352  mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4353  mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4354 
4355  if ( mLayer )
4356  {
4357  mLayer->setCountMethod( static_cast< QgsRandomMarkerFillSymbolLayer::CountMethod >( mCountMethodComboBox->currentData().toInt() ) );
4358  emit changed();
4359  }
4360 }
4361 
4362 void QgsRandomMarkerFillSymbolLayerWidget::countChanged( int d )
4363 {
4364  if ( mLayer )
4365  {
4366  mLayer->setPointCount( d );
4367  emit changed();
4368  }
4369 }
4370 
4371 void QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged( double d )
4372 {
4373  if ( mLayer )
4374  {
4375  mLayer->setDensityArea( d );
4376  emit changed();
4377  }
4378 }
4379 
4380 void QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged()
4381 {
4382  if ( mLayer )
4383  {
4384  mLayer->setDensityAreaUnit( mDensityAreaUnitWidget->unit() );
4385  mLayer->setDensityAreaUnitScale( mDensityAreaUnitWidget->getMapUnitScale() );
4386  emit changed();
4387  }
4388 }
4389 
4390 void QgsRandomMarkerFillSymbolLayerWidget::seedChanged( int d )
4391 {
4392  if ( mLayer )
4393  {
4394  mLayer->setSeed( d );
4395  emit changed();
4396  }
4397 }
A widget for displaying characters available in a preset font, and allowing users to select an indivi...
void characterSelected(QChar character)
Emitted when a character is selected in the widget.
void setCharacter(QChar character)
Sets the currently selected character in the widget.
void setFont(const QFont &font)
Sets the font to show in the widget.
void clearCharacter()
Clears the currently selected character in the widget.
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:183
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
static QgsSvgCache * svgCache()
Returns the application's SVG cache, used for caching SVG images and handling parameter replacement w...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsCentroidFillSymbolLayer * mLayer
QgsCentroidFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsCentroidFillSymbolLayerWidget.
void setPointOnAllParts(bool pointOnAllParts)
Sets whether a point is drawn for all parts or only on the biggest part of multi-part features.
void setClipOnCurrentPartOnly(bool clipOnCurrentPartOnly)
Sets whether point markers should be clipped to the current part boundary only.
void setClipPoints(bool clipPoints)
Sets whether point markers should be clipped to the polygon boundary.
bool pointOnAllParts() const
Returns whether a point is drawn for all parts or only on the biggest part of multi-part features.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
bool clipOnCurrentPartOnly() const
Returns true if point markers should be clipped to the current part boundary only.
void setPointOnSurface(bool pointOnSurface)
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
void colorRampChanged()
Emitted whenever a new color ramp is set for the button.
Abstract base class for color ramps.
Definition: qgscolorramp.h:32
A dialog to enter a custom dash space pattern for lines.
A widget to enter a custom dash space pattern for lines.
QVector< qreal > dashDotVector() const
Returns the dash pattern as a list of numbers.
void setUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit type used for the dash space pattern (used to update interface labels)
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
void expressionChanged(const QString &expression)
Emitted when the expression is changed.
double angle() const
void setAngle(double angle)
QgsFilledMarkerSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
QgsFilledMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFilledMarkerSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbol.
QgsFilledMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QgsFontMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsFontMarkerSymbolLayerWidget.
void setCharacter(QChar chr)
Set the font marker character from char.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsFontMarkerSymbolLayer * mLayer
void setCharacterFromText(const QString &text)
Set the font marker character from a text string.
void setColor(const QColor &color)
void setColorStroke(const QColor &color)
Set stroke color.
void setStrokeColor(const QColor &color) override
Set stroke color.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the stroke width map unit scale.
double strokeWidth() const
Returns the marker's stroke width.
void setFontStyle(const QString &style)
Sets the font style for the font which will be used to render the point.
QString fontStyle() const
Returns the font style for the associated font which will be used to render the point.
QColor strokeColor() const override
Gets stroke color.
QString fontFamily() const
Returns the font family name for the associated font which will be used to render the point.
void setCharacter(QString chr)
Sets the character(s) used when rendering points.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the stroke width unit.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the stroke width unit.
void setFontFamily(const QString &family)
Sets the font family for the font which will be used to render the point.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the stroke width map unit scale.
void setStrokeWidth(double width)
Set's the marker's stroke width.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the stroke join style.
QgsFontMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
Qt::PenJoinStyle penJoinStyle() const
Returns the stroke join style.
QString character() const
Returns the character(s) used when rendering points.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
static QString untranslateNamedStyle(const QString &namedStyle)
Returns the english named style of a font, if possible.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsGeometryGeneratorSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGeometryGeneratorSymbolLayerWidget.
QString geometryExpression() const
Gets the expression to generate this geometry.
void setGeometryExpression(const QString &exp)
Set the expression to generate this geometry.
QgsSymbol::SymbolType symbolType() const
Access the symbol type.
void setSymbolType(QgsSymbol::SymbolType symbolType)
Set the type of symbol which should be created.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsGradientFillSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
void applyColorRamp()
Applies the color ramp passed on by the color ramp button.
QgsGradientFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsGradientFillSymbolLayerWidget.
QgsColorRamp * colorRamp()
Returns the color ramp used for the gradient fill.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used for the gradient fill.
GradientCoordinateMode coordinateMode() const
Coordinate mode for gradient. Controls how the gradient stops are positioned.
QColor color2() const
Color for endpoint of gradient, only used if the gradient color type is set to SimpleTwoColor.
void setGradientType(GradientType gradientType)
void setCoordinateMode(GradientCoordinateMode coordinateMode)
GradientSpread gradientSpread() const
Gradient spread mode. Controls how the gradient behaves outside of the predefined stops.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the fill's offset.
void setReferencePoint2(QPointF referencePoint)
End point of gradient fill, in the range [0,0] - [1,1].
void setGradientColorType(GradientColorType gradientColorType)
GradientColorType gradientColorType() const
Gradient color mode, controls how gradient color stops are created.
void setGradientSpread(GradientSpread gradientSpread)
void setReferencePoint2IsCentroid(bool isCentroid)
Sets the end point of the gradient to be the feature centroid.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
void setReferencePoint1IsCentroid(bool isCentroid)
Sets the starting point of the gradient to be the feature centroid.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setReferencePoint1(QPointF referencePoint)
Starting point of gradient fill, in the range [0,0] - [1,1].
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QPointF offset() const
Returns the offset by which polygons will be translated during rendering.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
GradientType gradientType() const
Type of gradient, e.g., linear or radial.
void setColor2(const QColor &color2)
QgsHashedLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsHashedLineSymbolLayerWidget.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Line symbol layer type which draws repeating line sections along a line feature.
void setHashLength(double length)
Sets the length of hash symbols.
double hashAngle() const
Returns the angle to use when drawing the hashed lines sections, in degrees clockwise.
QgsUnitTypes::RenderUnit hashLengthUnit() const
Returns the units for the length of hash symbols.
const QgsMapUnitScale & hashLengthMapUnitScale() const
Returns the map unit scale for the hash length.
void setHashLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length of hash symbols.
void setHashLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the hash length.
double hashLength() const
Returns the length of hash symbols.
void setHashAngle(double angle)
Sets the angle to use when drawing the hashed lines sections, in degrees clockwise.
QImage pathAsImage(const QString &path, const QSize size, const bool keepAspectRatio, const double opacity, bool &fitsInCache, bool blocking=false, bool *isMissing=nullptr)
Returns the specified path rendered as an image.
static QIcon iconPoint()
Definition: qgsdataitem.cpp:76
static QIcon iconLine()
Definition: qgsdataitem.cpp:81
static QIcon iconPolygon()
Definition: qgsdataitem.cpp:86
QgsLinePatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLinePatternFillSymbolLayerWidget.
QgsLinePatternFillSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
A symbol fill consisting of repeated parallel lines.
void setMapUnitScale(const QgsMapUnitScale &scale) override
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the pattern's line offset.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line distance.
double lineAngle() const
Returns the angle for the parallel lines used to fill the symbol.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line pattern's offset.
void setDistance(double d)
Sets the distance between lines in the fill pattern.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the distance between lines in the fill pattern.
void setLineAngle(double a)
Sets the angle for the parallel lines used to fill the symbol.
double offset() const
Returns the offset distance for lines within the fill, which is the distance to offset the parallel l...
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line pattern's offset.
double distance() const
Returns the distance between lines in the fill pattern.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the units for the distance between lines in the fill pattern.
void setOffset(double offset)
Sets the offset distance for lines within the fill, which is the distance to offset the parallel line...
const QgsMapUnitScale & distanceMapUnitScale() const
Returns the map unit scale for the pattern's line distance.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's line offset.
RenderRingFilter
Options for filtering rings when the line symbol layer is being used to render a polygon's rings.
@ ExteriorRingOnly
Render the exterior ring only.
@ InteriorRingsOnly
Render the interior rings only.
@ AllRings
Render both exterior and interior rings.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the line's offset.
virtual void setWidth(double width)
Sets the width of the line symbol layer.
RenderRingFilter ringFilter() const
Returns the line symbol layer's ring filter, which controls which rings are rendered when the line sy...
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the line's offset.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
void setWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the line's width.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the line's offset.
void setOffset(double offset)
Sets the line's offset.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the line's width.
virtual double width() const
Returns the estimated width for the line symbol layer.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the line's offset.
void setRingFilter(QgsLineSymbolLayer::RenderRingFilter filter)
Sets the line symbol layer's ring filter, which controls which rings are rendered when the line symbo...
double offset() const
Returns the line's offset.
const QgsMapUnitScale & widthMapUnitScale() const
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1204
QgsMarkerLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsMarkerLineSymbolLayerWidget.
QgsMarkerLineSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
Line symbol layer type which draws repeating marker symbols along a line feature.
virtual void setSize(double size)
Sets the symbol size.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
HorizontalAnchorPoint
Symbol horizontal anchor points.
void setAngle(double angle)
Sets the rotation angle for the marker.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
void setVerticalAnchorPoint(VerticalAnchorPoint v)
Sets the vertical anchor point for positioning the symbol.
void setHorizontalAnchorPoint(HorizontalAnchorPoint h)
Sets the horizontal anchor point for positioning the symbol.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the symbol's offset.
double size() const
Returns the symbol size.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the symbol's offset.
VerticalAnchorPoint verticalAnchorPoint() const
Returns the vertical anchor point for positioning the symbol.
HorizontalAnchorPoint horizontalAnchorPoint() const
Returns the horizontal anchor point for positioning the symbol.
VerticalAnchorPoint
Symbol vertical anchor points.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's offset.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's offset.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:1004
A dialog to create a new auxiliary field.
A dialog to create a new auxiliary layer.
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1....
Base class for any widget that can be shown as a inline panel.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
bool dockMode()
Returns the dock mode state.
QgsPointPatternFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsPointPatternFillSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsPointPatternFillSymbolLayer * mLayer
const QgsMapUnitScale & displacementYMapUnitScale() const
void setOffsetYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical offset for rows in the pattern.
void setOffsetX(double offset)
Sets the horizontal offset values for points in the pattern.
QgsUnitTypes::RenderUnit offsetYUnit() const
Returns the units for the vertical offset for rows in the pattern.
const QgsMapUnitScale & offsetYMapUnitScale() const
Returns the unit scale for the vertical offset between rows in the pattern.
QgsUnitTypes::RenderUnit displacementYUnit() const
Returns the units for the vertical displacement between rows in the pattern.
QgsUnitTypes::RenderUnit distanceYUnit() const
Returns the units for the vertical distance between points in the pattern.
double offsetY() const
Returns the vertical offset values for points in the pattern.
const QgsMapUnitScale & distanceYMapUnitScale() const
void setDisplacementYMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetY(double offset)
Sets the vertical offset values for points in the pattern.
QgsUnitTypes::RenderUnit offsetXUnit() const
Returns the units for the horizontal offset for rows in the pattern.
void setDistanceXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal distance between points in the pattern.
void setDistanceXMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & offsetXMapUnitScale() const
Returns the unit scale for the horizontal offset for rows in the pattern.
void setOffsetYMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the vertical offset for rows in the pattern.
void setDisplacementYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical displacement between rows in the pattern.
double offsetX() const
Returns the horizontal offset values for points in the pattern.
void setDisplacementXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal displacement between rows in the pattern.
void setDisplacementXMapUnitScale(const QgsMapUnitScale &scale)
void setDistanceYMapUnitScale(const QgsMapUnitScale &scale)
QgsUnitTypes::RenderUnit displacementXUnit() const
Returns the units for the horizontal displacement between rows in the pattern.
void setOffsetXMapUnitScale(const QgsMapUnitScale &scale)
Sets the unit scale for the horizontal offset for rows in the pattern.
void setOffsetXUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the horizontal offset between rows in the pattern.
const QgsMapUnitScale & distanceXMapUnitScale() const
QgsUnitTypes::RenderUnit distanceXUnit() const
Returns the units for the horizontal distance between points in the pattern.
void setDistanceYUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the vertical distance between points in the pattern.
const QgsMapUnitScale & displacementXMapUnitScale() const
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
Definition for a property.
Definition: qgsproperty.h:48
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void updateFieldLists()
Updates list of fields.
void changed()
Emitted when property definition changes.
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).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
A store for object properties.
Definition: qgsproperty.h:232
void setField(const QString &field)
Sets the field name the property references.
QgsRandomMarkerFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRandomMarkerFillSymbolLayerWidget.
void setSymbolLayer(QgsSymbolLayer *layer) override
A fill symbol layer which places markers at random locations within polygons.
QgsUnitTypes::RenderUnit densityAreaUnit() const
Returns the units for the density area.
int pointCount() const
Returns the count of random points to render in the fill.
unsigned long seed() const
Returns the random number seed to use when generating points, or 0 if a truly random sequence will be...
void setCountMethod(CountMethod method)
Sets the count method used to randomly fill the polygon.
void setDensityAreaUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the density area.
void setDensityAreaUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the density area.
bool clipPoints() const
Returns true if point markers should be clipped to the polygon boundary.
void setClipPoints(bool clipped)
Sets whether point markers should be clipped to the polygon boundary.
void setSeed(unsigned long seed)
Sets the random number seed to use when generating points, or 0 if a truly random sequence will be us...
const QgsMapUnitScale & densityAreaUnitScale() const
Returns the map scale for the density area.
void setPointCount(int count)
Sets the count of random points to render in the fill.
CountMethod
Methods to define the number of points randomly filling the polygon.
@ AbsoluteCount
The point count is used as an absolute count of markers.
@ DensityBasedCount
The point count is part of a marker density count.
double densityArea() const
Returns the density area used to count the number of points to randomly fill the polygon.
void setDensityArea(double area)
Sets the density area used to count the number of points to randomly fill the polygon.
CountMethod countMethod() const
Returns the count method used to randomly fill the polygon.
QgsRasterFillSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsRasterFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterFillSymbolLayerWidget.
A class for filling symbols with a repeated raster image.
double width() const
Returns the width used for scaling the image used in the fill.
void setWidthUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the image's width.
@ Feature
Tiling is based on feature bounding box.
@ Viewport
Tiling is based on complete map viewport.
void setOffsetUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units for the fill's offset.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
QgsUnitTypes::RenderUnit widthUnit() const
Returns the units for the image's width.
void setWidth(const double width)
Sets the width for scaling the image used in the fill.
double opacity() const
Returns the opacity for the raster image used in the fill.
const QgsMapUnitScale & widthMapUnitScale() const
Returns the map unit scale for the image's width.
void setOpacity(double opacity)
Sets the opacity for the raster image used in the fill.
void setWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the image's width.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QString imageFilePath() const
The path to the raster image used for the fill.
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setImageFilePath(const QString &imagePath)
Sets the path to the raster image used for the fill.
void setCoordinateMode(FillCoordinateMode mode)
Set the coordinate mode for fill.
QPointF offset() const
Returns the offset for the fill.
void setOffset(QPointF offset)
Sets the offset for the fill.
FillCoordinateMode coordinateMode() const
Coordinate mode for fill.
QgsRasterMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsRasterMarkerSymbolLayerWidget.
QgsRasterMarkerSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
Raster marker symbol layer class.
void setOpacity(double opacity)
Set the marker opacity.
QString path() const
Returns the marker raster image path.
void setPath(const QString &path)
Set the marker raster image path.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is low...
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
double opacity() const
Returns the marker opacity.
A cross platform button subclass used to represent a locked / unlocked ratio state.
void lockChanged(bool locked)
Emitted whenever the lock state changes.
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSVGFillSymbolLayer * mLayer
void updateParamGui(bool resetValues=true)
Enables or disables svg fill color, stroke color and stroke width based on whether the svg file suppo...
QgsSVGFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSVGFillSymbolLayerWidget.
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
A class for filling symbols with a repeated SVG file.
void setParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
QString svgFilePath() const
Returns the path to the SVG file used to render the fill.
void setSvgStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's stroke.
void setPatternWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the width of the SVG images in the pattern.
QColor svgStrokeColor() const
Returns the stroke color used for rendering the SVG content.
const QgsMapUnitScale & svgStrokeWidthMapUnitScale() const
Returns the map unit scale for the pattern's stroke.
void setSvgFillColor(const QColor &c)
Sets the fill color used for rendering the SVG content.
QgsUnitTypes::RenderUnit svgStrokeWidthUnit() const
Returns the units for the stroke width.
double svgStrokeWidth() const
Returns the stroke width used for rendering the SVG content.
void setSvgStrokeWidth(double w)
Sets the stroke width used for rendering the SVG content.
void setSvgFilePath(const QString &svgPath)
Sets the path to the SVG file to render in the fill.
QColor svgFillColor() const
Returns the fill color used for rendering the SVG content.
const QgsMapUnitScale & patternWidthMapUnitScale() const
Returns the map unit scale for the pattern's width.
void setSvgStrokeColor(const QColor &c)
Sets the stroke color used for rendering the SVG content.
void setSvgStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the stroke width.
void setPatternWidth(double width)
Sets the width to render the SVG content as within the fill (i.e.
double patternWidth() const
Returns the width of the rendered SVG content within the fill (i.e.
QgsUnitTypes::RenderUnit patternWidthUnit() const
Returns the units for the width of the SVG images in the pattern.
void setPatternWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the pattern's width.
QgsShapeburstFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsShapeburstFillSymbolLayerWidget.
QgsShapeburstFillSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
int blurRadius() const
Returns the blur radius, which controls the amount of blurring applied to the fill.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
QgsColorRamp * colorRamp()
Returns the color ramp used for the shapeburst fill.
void setOffset(QPointF offset)
Sets the offset for the shapeburst fill.
const QgsMapUnitScale & distanceMapUnitScale() const
void setBlurRadius(int blurRadius)
Sets the blur radius, which controls the amount of blurring applied to the fill.
void setUseWholeShape(bool useWholeShape)
Sets whether the shapeburst fill should be drawn using the entire shape.
QColor color2() const
Returns the color used for the endpoint of the shapeburst fill.
void setDistanceUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
QgsUnitTypes::RenderUnit distanceUnit() const
Returns the unit for the maximum distance to shade inside of the shape from the polygon's boundary.
void setIgnoreRings(bool ignoreRings)
Sets whether the shapeburst fill should ignore polygon rings when calculating the buffered shading.
void setMaxDistance(double maxDistance)
Sets the maximum distance to shape inside of the shape from the polygon's boundary.
void setColor2(const QColor &color2)
Sets the color for the endpoint of the shapeburst fill.
const QgsMapUnitScale & offsetMapUnitScale() const
void setColorType(ShapeburstColorType colorType)
Sets the color mode to use for the shapeburst fill.
QPointF offset() const
Returns the offset for the shapeburst fill.
bool useWholeShape() const
Returns whether the shapeburst fill is set to cover the entire shape.
ShapeburstColorType colorType() const
Returns the color mode used for the shapeburst fill.
bool ignoreRings() const
Returns whether the shapeburst fill is set to ignore polygon interior rings.
double maxDistance() const
Returns the maximum distance from the shape's boundary which is shaded.
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units used for the offset of the shapeburst fill.
void setDistanceMapUnitScale(const QgsMapUnitScale &scale)
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the offset for the shapeburst fill.
void setColorRamp(QgsColorRamp *ramp)
Sets the color ramp used to draw the shapeburst fill.
void setColor(const QColor &color)
QgsSimpleFillSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleFillSymbolLayerWidget.
void setStrokeColor(const QColor &color)
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSimpleFillSymbolLayer * mLayer
QgsSymbolLayer * symbolLayer() override
Qt::PenJoinStyle penJoinStyle() const
QColor strokeColor() const override
Gets stroke color.
void setBrushStyle(Qt::BrushStyle style)
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
const QgsMapUnitScale & offsetMapUnitScale() const
Returns the map unit scale for the fill's offset.
void setOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the fill's offset.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the width of the fill's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
Qt::PenStyle strokeStyle() const
void setStrokeWidth(double strokeWidth)
void setStrokeStyle(Qt::PenStyle strokeStyle)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
QgsUnitTypes::RenderUnit offsetUnit() const
Returns the units for the fill's offset.
QPointF offset()
Returns the offset by which polygons will be translated during rendering.
void setOffset(QPointF offset)
Sets an offset by which polygons will be translated during rendering.
void setStrokeColor(const QColor &strokeColor) override
Set stroke color.
void setOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the fill's offset.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the width of the fill's stroke.
Qt::BrushStyle brushStyle() const
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSimpleLineSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
QgsSymbolLayer * symbolLayer() override
QgsSimpleLineSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleLineSymbolLayerWidget.
void resizeEvent(QResizeEvent *event) override
A simple line symbol layer, which renders lines using a line in a variety of styles (e....
QgsUnitTypes::RenderUnit dashPatternOffsetUnit() const
Returns the units for the dash pattern offset.
void setDrawInsidePolygon(bool drawInsidePolygon)
Sets whether the line should only be drawn inside polygons, and any portion of the line which falls o...
bool tweakDashPatternOnCorners() const
Returns true if dash patterns tweaks should be applied on sharp corners, to ensure that a double-leng...
void setPenCapStyle(Qt::PenCapStyle style)
Sets the pen cap style used to render the line (e.g.
Qt::PenJoinStyle penJoinStyle() const
Returns the pen join style used to render the line (e.g.
void setDashPatternOffsetUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the dash pattern offset.
void setCustomDashPatternMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for lengths used in the custom dash pattern.
QgsUnitTypes::RenderUnit customDashPatternUnit() const
Returns the units for lengths used in the custom dash pattern.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
void setUseCustomDashPattern(bool b)
Sets whether the line uses a custom dash pattern.
void setTweakDashPatternOnCorners(bool enabled)
Sets whether dash patterns tweaks should be applied on sharp corners, to ensure that a double-length ...
void setCustomDashVector(const QVector< qreal > &vector)
Sets the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ren...
bool useCustomDashPattern() const
Returns true if the line uses a custom dash pattern.
void setDashPatternOffset(double offset)
Sets the dash pattern offset, which dictates how far along the dash pattern the pattern should start ...
const QgsMapUnitScale & dashPatternOffsetMapUnitScale() const
Returns the map unit scale the dash pattern offset value.
void setDashPatternOffsetMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the dash pattern offset.
QgsSimpleLineSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setPenStyle(Qt::PenStyle style)
Sets the pen style used to render the line (e.g.
Qt::PenStyle penStyle() const
Returns the pen style used to render the line (e.g.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the pen join style used to render the line (e.g.
double dashPatternOffset() const
Returns the dash pattern offset, which dictates how far along the dash pattern the pattern should sta...
void setAlignDashPattern(bool enabled)
Sets whether dash patterns should be aligned to the start and end of lines, by applying subtle tweaks...
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
const QgsMapUnitScale & customDashPatternMapUnitScale() const
Returns the map unit scale for lengths used in the custom dash pattern.
bool drawInsidePolygon() const
Returns true if the line should only be drawn inside polygons, and any portion of the line which fall...
void setMapUnitScale(const QgsMapUnitScale &scale) override
bool alignDashPattern() const
Returns true if dash patterns should be aligned to the start and end of lines, by applying subtle twe...
static bool shapeIsFilled(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Returns true if a symbol shape has a fill.
static QList< QgsSimpleMarkerSymbolLayerBase::Shape > availableShapes()
Returns a list of all available shape types.
QgsSimpleMarkerSymbolLayerBase::Shape shape() const
Returns the shape for the rendered marker symbol.
void setShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Sets the rendered marker shape.
static QString encodeShape(QgsSimpleMarkerSymbolLayerBase::Shape shape)
Encodes a shape to its string representation.
QgsSymbolLayer * symbolLayer() override
void setColorStroke(const QColor &color)
void setColorFill(const QColor &color)
QgsSimpleMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSimpleMarkerSymbolLayerWidget.
QgsSimpleMarkerSymbolLayer * mLayer
void setSymbolLayer(QgsSymbolLayer *layer) override
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit u)
Sets the unit for the width of the marker's stroke.
void setColor(const QColor &color) override
The fill color.
Qt::PenJoinStyle penJoinStyle() const
Returns the marker's stroke join style (e.g., miter, bevel, etc).
QgsSimpleMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map scale for the width of the marker's stroke.
void setStrokeStyle(Qt::PenStyle strokeStyle)
Sets the marker's stroke style (e.g., solid, dashed, etc)
const QgsMapUnitScale & strokeWidthMapUnitScale() const
Returns the map scale for the width of the marker's stroke.
QColor fillColor() const override
Gets fill color.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the unit for the width of the marker's stroke.
void setPenJoinStyle(Qt::PenJoinStyle style)
Sets the marker's stroke join style (e.g., miter, bevel, etc).
QColor strokeColor() const override
Returns the marker's stroke color.
void setStrokeWidth(double w)
Sets the width of the marker's stroke.
void setStrokeColor(const QColor &color) override
Sets the marker's stroke color.
Qt::PenStyle strokeStyle() const
Returns the marker's stroke style (e.g., solid, dashed, etc)
double strokeWidth() const
Returns the width of the marker's stroke.
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
void setContext(const QgsSymbolWidgetContext &context) override
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolLayer * symbolLayer() override
void setSymbolLayer(QgsSymbolLayer *layer) override
void setGuiForSvg(const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors=false)
Updates the GUI to reflect the SVG marker symbol layer.
void setSvgPath(const QString &name)
Sets the SVG path.
QgsSvgMarkerSymbolLayer * mLayer
QgsSvgMarkerSymbolLayerWidget(QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsSvgMarkerSymbolLayerWidget.
void setSvgParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
QgsSvgMarkerSymbolLayer * clone() const override
Shall be reimplemented by subclasses to create a deep copy of the instance.
QColor fillColor() const override
Gets fill color.
void setStrokeWidthMapUnitScale(const QgsMapUnitScale &scale)
QString path() const
Returns the marker SVG path.
bool preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
QgsUnitTypes::RenderUnit strokeWidthUnit() const
Returns the units for the stroke width.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the stroke width.
const QgsMapUnitScale & strokeWidthMapUnitScale() const
double fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is...
void setStrokeColor(const QColor &c) override
Set stroke color.
void setMapUnitScale(const QgsMapUnitScale &scale) override
QColor strokeColor() const override
Gets stroke color.
void setFillColor(const QColor &color) override
Set fill color.
QMap< QString, QgsProperty > parameters() const
Returns the dynamic SVG parameters.
void setParameters(const QMap< QString, QgsProperty > &parameters)
Sets the dynamic SVG parameters.
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 setPath(const QString &path)
Set the marker SVG path.
double defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
void svgParametersChanged(const QMap< QString, QgsProperty > &parameters)
Emitted when the parameters have changed.
void svgSelected(const QString &path)
void sourceChanged(const QString &source)
Emitted whenever the SVG source is changed in the widget.
static QPixmap symbolPreviewPixmap(const QgsSymbol *symbol, QSize size, int padding=0, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *shape=nullptr)
Returns a pixmap preview for a color ramp.
static QIcon symbolPreviewIcon(const QgsSymbol *symbol, QSize size, int padding=0, QgsLegendPatchShape *shape=nullptr)
Returns an icon preview for a color ramp.
static QIcon symbolLayerPreviewIcon(const QgsSymbolLayer *layer, QgsUnitTypes::RenderUnit u, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale())
Draws a symbol layer preview to an icon.
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key)
Registers a data defined override button.
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
virtual QgsSymbolLayer * symbolLayer()=0
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
Property
Data definable properties.
@ PropertyGradientReference1X
Gradient reference point 1 x.
@ PropertyShapeburstIgnoreRings
Shapeburst ignore rings.
@ PropertyGradientReference2X
Gradient reference point 2 x.
@ PropertyStrokeStyle
Stroke style (eg solid, dashed)
@ PropertyPlacement
Line marker placement.
@ PropertyHorizontalAnchor
Horizontal anchor point.
@ PropertyDistanceX
Horizontal distance between points.
@ PropertyFile
Filename, eg for svg files.
@ PropertyGradientType
Gradient fill type.
@ PropertyCapStyle
Line cap style.
@ PropertyAngle
Symbol angle.
@ PropertyDistanceY
Vertical distance between points.
@ PropertyDisplacementX
Horizontal displacement.
@ PropertyVerticalAnchor
Vertical anchor point.
@ PropertyGradientSpread
Gradient spread mode.
@ PropertyOffsetY
Vertical offset.
@ PropertyGradientReference1Y
Gradient reference point 1 y.
@ PropertyLineDistance
Distance between lines, or length of lines for hash line symbols.
@ PropertyOffsetAlongLine
Offset along line.
@ PropertyBlurRadius
Shapeburst blur radius.
@ PropertyGradientReference2Y
Gradient reference point 2 y.
@ PropertyDensityArea
Density area.
@ PropertyGradientReference1IsCentroid
Gradient reference point 1 is centroid.
@ PropertyCustomDash
Custom dash pattern.
@ PropertyShapeburstUseWholeShape
Shapeburst use whole shape.
@ PropertySize
Symbol size.
@ PropertyOffsetX
Horizontal offset.
@ PropertyJoinStyle
Line join style.
@ PropertyOpacity
Opacity.
@ PropertySecondaryColor
Secondary color (eg for gradient fills)
@ PropertyCharacter
Character, eg for font marker symbol layers.
@ PropertyCoordinateMode
Gradient coordinate mode.
@ PropertyLineAngle
Line angle, or angle of hash lines for hash line symbols.
@ PropertyShapeburstMaxDistance
Shapeburst fill from edge distance.
@ PropertyOffset
Symbol offset.
@ PropertyStrokeWidth
Stroke width.
@ PropertyDashPatternOffset
Dash pattern offset.
@ PropertyFillColor
Fill color.
@ PropertyFontStyle
Font style.
@ PropertyHeight
Symbol height.
@ PropertyClipPoints
Whether markers should be clipped to polygon boundaries.
@ PropertyFontFamily
Font family.
@ PropertyPointCount
Point count.
@ PropertyRandomSeed
Random number seed.
@ PropertyName
Name, eg shape name for simple markers.
@ PropertyAverageAngleLength
Length to average symbol angles over.
@ PropertyInterval
Line marker interval.
@ PropertyFillStyle
Fill style (eg solid, dots)
@ PropertyDisplacementY
Vertical displacement.
@ PropertyStrokeColor
Stroke color.
@ PropertyGradientReference2IsCentroid
Gradient reference point 2 is centroid.
@ PropertyWidth
Symbol width.
virtual QColor color() const
The fill color.
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
virtual void setColor(const QColor &color)
The fill color.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
QgsSymbol::SymbolType symbolType() const
Returns the associated symbol type, if the widget is being shown as a subcomponent of a parent symbol...
SymbolType
Type of the symbol.
Definition: qgssymbol.h:87
@ Line
Line symbol.
Definition: qgssymbol.h:89
@ Hybrid
Hybrid symbol.
Definition: qgssymbol.h:91
@ Fill
Fill symbol.
Definition: qgssymbol.h:90
@ Marker
Marker symbol.
Definition: qgssymbol.h:88
bool rotateSymbols() const
Returns true if the repeating symbols be rotated to match their line segment orientation.
double averageAngleLength() const
Returns the length of line over which the line's direction is averaged when calculating individual sy...
const QgsMapUnitScale & intervalMapUnitScale() const
Returns the map unit scale for the interval between symbols.
void setMapUnitScale(const QgsMapUnitScale &scale) FINAL
void setRotateSymbols(bool rotate)
Sets whether the repeating symbols should be rotated to match their line segment orientation.
Placement placement() const
Returns the placement of the symbols.
@ Vertex
Place symbols on every vertex in the line.
@ LastVertex
Place symbols on the last vertex in the line.
@ CentralPoint
Place symbols at the mid point of the line.
@ FirstVertex
Place symbols on the first vertex in the line.
@ SegmentCenter
Place symbols at the center of every line segment.
@ Interval
Place symbols at regular intervals.
@ CurvePoint
Place symbols at every virtual curve point in the line (used when rendering curved geometry types onl...
const QgsMapUnitScale & averageAngleMapUnitScale() const
Returns the map unit scale for the length over which the line's direction is averaged when calculatin...
double interval() const
Returns the interval between individual symbols.
void setAverageAngleMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the length over which the line's direction is averaged when calculating i...
double offsetAlongLine() const
Returns the offset along the line for the symbol placement.
void setOffsetAlongLine(double offsetAlongLine)
Sets the the offset along the line for the symbol placement.
void setPlacement(Placement placement)
Sets the placement of the symbols.
void setOffsetAlongLineUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit used for calculating the offset along line for symbols.
void setInterval(double interval)
Sets the interval between individual symbols.
const QgsMapUnitScale & offsetAlongLineMapUnitScale() const
Returns the map unit scale used for calculating the offset in map units along line for symbols.
QgsUnitTypes::RenderUnit averageAngleUnit() const
Returns the unit for the length over which the line's direction is averaged when calculating individu...
QgsUnitTypes::RenderUnit offsetAlongLineUnit() const
Returns the unit used for calculating the offset along line for symbols.
QgsUnitTypes::RenderUnit intervalUnit() const
Returns the units for the interval between symbols.
void setAverageAngleUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the length over which the line's direction is averaged when calculating individual ...
void setIntervalUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the interval between symbols.
void setIntervalMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the interval between symbols.
void setOffsetAlongLineMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for calculating the offset in map units along line for symbols.
void setAverageAngleLength(double length)
Sets the length of line over which the line's direction is averaged when calculating individual symbo...
A widget displaying a combobox allowing the user to choose between various display units,...
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:239
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:175
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:171
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
@ RenderInches
Inches.
Definition: qgsunittypes.h:173
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:169
Represents a vector layer which manages a vector based data sets.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
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
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:263
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition: qgssymbol.h:54
Single variable definition for use within a QgsExpressionContextScope.