QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgssymbollayerwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerwidget.cpp - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgssymbollayerwidget.h"
18 
19 #include "qgslinesymbollayer.h"
20 #include "qgsmarkersymbollayer.h"
21 #include "qgsfillsymbollayer.h"
23 #include "qgssymbolslistwidget.h"
25 
26 #include "characterwidget.h"
27 #include "qgsdashspacedialog.h"
29 #include "qgssvgcache.h"
30 #include "qgssymbollayerutils.h"
31 #include "qgscolorramp.h"
32 #include "qgscolorrampbutton.h"
33 #include "qgsfontutils.h"
35 #include "qgsproperty.h"
36 #include "qgsstyle.h" //for symbol selector dialog
37 #include "qgsmapcanvas.h"
38 #include "qgsapplication.h"
39 #include "qgsvectorlayer.h"
40 #include "qgssvgselectorwidget.h"
41 #include "qgslogger.h"
42 #include "qgssettings.h"
45 #include "qgsauxiliarystorage.h"
46 #include "qgsimagecache.h"
47 #include "qgslinesymbol.h"
48 #include "qgsmarkersymbol.h"
49 #include "qgsiconutils.h"
50 
51 #include <QAbstractButton>
52 #include <QButtonGroup>
53 #include <QColorDialog>
54 #include <QCursor>
55 #include <QDir>
56 #include <QFileDialog>
57 #include <QPainter>
58 #include <QStandardItemModel>
59 #include <QSvgRenderer>
60 #include <QMessageBox>
61 #include <QMenu>
62 #include <QAction>
63 #include <QInputDialog>
64 #include <QBuffer>
65 #include <QRegularExpression>
66 
68 {
69  if ( auto *lExpressionContext = mContext.expressionContext() )
70  return *lExpressionContext;
71 
73 
75  if ( const QgsSymbolLayer *symbolLayer = const_cast< QgsSymbolLayerWidget * >( this )->symbolLayer() )
76  {
77  //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
78  //color, but that's not accessible here). 99% of the time these will be the same anyway
80  }
81  expContext << symbolScope;
87  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_count" ), 1, true ) );
88  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_index" ), 1, true ) );
89  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_row" ), 1, true ) );
90  expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_column" ), 1, true ) );
91 
92  // additional scopes
93  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
94  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
95  {
96  expContext.appendScope( new QgsExpressionContextScope( scope ) );
97  }
98 
99  //TODO - show actual value
100  expContext.setOriginalValueVariable( QVariant() );
101 
102  QStringList highlights;
108  << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" );
109 
110 
111  if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
112  {
113  highlights << QStringLiteral( "zoom_level" );
114  }
115  if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
116  {
117  highlights << QStringLiteral( "vector_tile_zoom" );
118  }
119 
120  expContext.setHighlightedVariables( highlights );
121 
122  return expContext;
123 }
124 
126 {
127  mContext = context;
128  const auto unitSelectionWidgets = findChildren<QgsUnitSelectionWidget *>();
129  for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
130  {
131  unitWidget->setMapCanvas( mContext.mapCanvas() );
132  }
133 }
134 
136 {
137  return mContext;
138 }
139 
141 {
142  button->init( key, symbolLayer()->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer, true );
144  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolLayerWidget::createAuxiliaryField );
145 
146  button->registerExpressionContextGenerator( this );
147 }
148 
149 void QgsSymbolLayerWidget::createAuxiliaryField()
150 {
151  // try to create an auxiliary layer if not yet created
152  if ( !mVectorLayer->auxiliaryLayer() )
153  {
154  QgsNewAuxiliaryLayerDialog dlg( mVectorLayer, this );
155  dlg.exec();
156  }
157 
158  // return if still not exists
159  if ( !mVectorLayer->auxiliaryLayer() )
160  return;
161 
162  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
163  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
165 
166  // create property in auxiliary storage if necessary
167  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
168  {
169  QgsNewAuxiliaryFieldDialog dlg( def, mVectorLayer, true, this );
170  if ( dlg.exec() == QDialog::Accepted )
171  def = dlg.propertyDefinition();
172  }
173 
174  // return if still not exist
175  if ( !mVectorLayer->auxiliaryLayer()->exists( def ) )
176  return;
177 
178  // update property with join field name from auxiliary storage
179  QgsProperty property = button->toProperty();
180  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
181  property.setActive( true );
182  button->updateFieldLists();
183  button->setToProperty( property );
184  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
185 
186  emit changed();
187 }
188 
190 {
191  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
192  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
193  symbolLayer()->setDataDefinedProperty( key, button->toProperty() );
194  emit changed();
195 }
196 
198  : QgsSymbolLayerWidget( parent, vl )
199 {
200  mLayer = nullptr;
201 
202  setupUi( this );
203  connect( mCustomCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged );
204  connect( mChangePatternButton, &QPushButton::clicked, this, &QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked );
205  connect( mPenWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed );
206  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed );
207  connect( mDashPatternUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed );
208  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
209  connect( mPatternOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged );
210  connect( mCheckAlignDash, &QCheckBox::toggled, this, [ = ]
211  {
212  mCheckDashCorners->setEnabled( mCheckAlignDash->isChecked() );
213  if ( !mCheckAlignDash->isChecked() )
214  mCheckDashCorners->setChecked( false );
215 
216  if ( mLayer )
217  {
218  mLayer->setAlignDashPattern( mCheckAlignDash->isChecked() );
219  emit changed();
220  }
221  } );
222  connect( mCheckDashCorners, &QCheckBox::toggled, this, [ = ]
223  {
224  if ( mLayer )
225  {
226  mLayer->setTweakDashPatternOnCorners( mCheckDashCorners->isChecked() );
227  emit changed();
228  }
229  } );
230 
243 
244  btnChangeColor->setAllowOpacity( true );
245  btnChangeColor->setColorDialogTitle( tr( "Select Line Color" ) );
246  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
247 
248  mColorDDBtn->registerLinkedWidget( btnChangeColor );
249 
250  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
251  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
252  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
253  connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
254  {
255  if ( mLayer )
256  {
257  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
258  emit changed();
259  }
260  } );
261 
262  spinOffset->setClearValue( 0.0 );
263  spinPatternOffset->setClearValue( 0.0 );
264 
265  mTrimStartDistanceSpin->setClearValue( 0.0 );
266  mTrimDistanceEndSpin->setClearValue( 0.0 );
267 
268  //make a temporary symbol for the size assistant preview
269  mAssistantPreviewSymbol.reset( new QgsLineSymbol() );
270 
271  if ( vectorLayer() )
272  mPenWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
273 
274  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::penWidthChanged );
275  connect( btnChangeColor, &QgsColorButton::colorChanged, this, &QgsSimpleLineSymbolLayerWidget::colorChanged );
276  connect( cboPenStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
277  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::offsetChanged );
278  connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
279  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleLineSymbolLayerWidget::penStyleChanged );
280  connect( spinPatternOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleLineSymbolLayerWidget::patternOffsetChanged );
281 
282  connect( mTrimStartDistanceSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
283  {
284  if ( !mLayer )
285  return;
286 
287  mLayer->setTrimDistanceStart( value );
288  emit changed();
289  } );
290  connect( mTrimDistanceStartUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
291  {
292  if ( !mLayer )
293  return;
294 
295  mLayer->setTrimDistanceStartUnit( mTrimDistanceStartUnitWidget->unit() );
296  mLayer->setTrimDistanceStartMapUnitScale( mTrimDistanceStartUnitWidget->getMapUnitScale() );
297  emit changed();
298  } );
299  connect( mTrimDistanceEndSpin, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, [ = ]( double value )
300  {
301  if ( !mLayer )
302  return;
303 
304  mLayer->setTrimDistanceEnd( value );
305  emit changed();
306  } );
307  connect( mTrimDistanceEndUnitWidget, &QgsUnitSelectionWidget::changed, this, [ = ]
308  {
309  if ( !mLayer )
310  return;
311 
312  mLayer->setTrimDistanceEndUnit( mTrimDistanceEndUnitWidget->unit() );
313  mLayer->setTrimDistanceEndMapUnitScale( mTrimDistanceEndUnitWidget->getMapUnitScale() );
314  emit changed();
315  } );
316 
317 
319 
320  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol );
321 }
322 
324 
325 void QgsSimpleLineSymbolLayerWidget::updateAssistantSymbol()
326 {
327  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
328  {
329  mAssistantPreviewSymbol->deleteSymbolLayer( i );
330  }
331  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
333  if ( ddWidth )
334  mAssistantPreviewSymbol->setDataDefinedWidth( ddWidth );
335 }
336 
337 
339 {
340  if ( !layer || layer->layerType() != QLatin1String( "SimpleLine" ) )
341  return;
342 
343  // layer type is correct, we can do the cast
344  mLayer = static_cast<QgsSimpleLineSymbolLayer *>( layer );
345 
346  // set units
347  mPenWidthUnitWidget->blockSignals( true );
348  mPenWidthUnitWidget->setUnit( mLayer->widthUnit() );
349  mPenWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
350  mPenWidthUnitWidget->blockSignals( false );
351  mOffsetUnitWidget->blockSignals( true );
352  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
353  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
354  mOffsetUnitWidget->blockSignals( false );
355  mDashPatternUnitWidget->blockSignals( true );
356  mDashPatternUnitWidget->setUnit( mLayer->customDashPatternUnit() );
357  mDashPatternUnitWidget->setMapUnitScale( mLayer->customDashPatternMapUnitScale() );
358  mDashPatternUnitWidget->blockSignals( false );
359 
360  whileBlocking( mPatternOffsetUnitWidget )->setUnit( mLayer->dashPatternOffsetUnit() );
361  whileBlocking( mPatternOffsetUnitWidget )->setMapUnitScale( mLayer->dashPatternOffsetMapUnitScale() );
362  whileBlocking( mTrimDistanceStartUnitWidget )->setUnit( mLayer->trimDistanceStartUnit() );
363  whileBlocking( mTrimDistanceStartUnitWidget )->setMapUnitScale( mLayer->trimDistanceStartMapUnitScale() );
364  whileBlocking( mTrimDistanceEndUnitWidget )->setUnit( mLayer->trimDistanceEndUnit() );
365  whileBlocking( mTrimDistanceEndUnitWidget )->setMapUnitScale( mLayer->trimDistanceEndMapUnitScale() );
366 
367  // set values
368  spinWidth->blockSignals( true );
369  spinWidth->setValue( mLayer->width() );
370  spinWidth->blockSignals( false );
371  btnChangeColor->blockSignals( true );
372  btnChangeColor->setColor( mLayer->color() );
373  btnChangeColor->blockSignals( false );
374  spinOffset->blockSignals( true );
375  spinOffset->setValue( mLayer->offset() );
376  spinOffset->blockSignals( false );
377  cboPenStyle->blockSignals( true );
378  cboJoinStyle->blockSignals( true );
379  cboCapStyle->blockSignals( true );
380  cboPenStyle->setPenStyle( mLayer->penStyle() );
381  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
382  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
383  cboPenStyle->blockSignals( false );
384  cboJoinStyle->blockSignals( false );
385  cboCapStyle->blockSignals( false );
386  whileBlocking( spinPatternOffset )->setValue( mLayer->dashPatternOffset() );
387  whileBlocking( mTrimStartDistanceSpin )->setValue( mLayer->trimDistanceStart() );
388  whileBlocking( mTrimDistanceEndSpin )->setValue( mLayer->trimDistanceEnd() );
389 
390  //use a custom dash pattern?
391  bool useCustomDashPattern = mLayer->useCustomDashPattern();
392  mChangePatternButton->setEnabled( useCustomDashPattern );
393  label_3->setEnabled( !useCustomDashPattern );
394  cboPenStyle->setEnabled( !useCustomDashPattern );
395  mCustomCheckBox->blockSignals( true );
396  mCustomCheckBox->setCheckState( useCustomDashPattern ? Qt::Checked : Qt::Unchecked );
397  mCustomCheckBox->blockSignals( false );
398 
399  //make sure height of custom dash button looks good under different platforms
400  QSize size = mChangePatternButton->minimumSizeHint();
401  int fontHeight = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().height() * 1.4 );
402  mChangePatternButton->setMinimumSize( QSize( size.width(), std::max( size.height(), fontHeight ) ) );
403 
404  //draw inside polygon?
405  const bool drawInsidePolygon = mLayer->drawInsidePolygon();
406  whileBlocking( mDrawInsideCheckBox )->setCheckState( drawInsidePolygon ? Qt::Checked : Qt::Unchecked );
407 
408  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
409 
410  whileBlocking( mCheckAlignDash )->setChecked( mLayer->alignDashPattern() );
411  mCheckDashCorners->setEnabled( mLayer->alignDashPattern() );
412  whileBlocking( mCheckDashCorners )->setChecked( mLayer->tweakDashPatternOnCorners() && mLayer->alignDashPattern() );
413 
415 
426 
427  updateAssistantSymbol();
428 }
429 
431 {
432  return mLayer;
433 }
434 
436 {
438 
439  switch ( context.symbolType() )
440  {
443  //these settings only have an effect when the symbol layers is part of a fill symbol
444  mDrawInsideCheckBox->hide();
445  mRingFilterComboBox->hide();
446  mRingsLabel->hide();
447  break;
448 
451  break;
452  }
453 }
454 
455 void QgsSimpleLineSymbolLayerWidget::penWidthChanged()
456 {
457  mLayer->setWidth( spinWidth->value() );
459  emit changed();
460 }
461 
462 void QgsSimpleLineSymbolLayerWidget::colorChanged( const QColor &color )
463 {
464  mLayer->setColor( color );
465  emit changed();
466 }
467 
468 void QgsSimpleLineSymbolLayerWidget::penStyleChanged()
469 {
470  mLayer->setPenStyle( cboPenStyle->penStyle() );
471  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
472  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
474  emit changed();
475 }
476 
477 void QgsSimpleLineSymbolLayerWidget::offsetChanged()
478 {
479  mLayer->setOffset( spinOffset->value() );
481  emit changed();
482 }
483 
484 void QgsSimpleLineSymbolLayerWidget::patternOffsetChanged()
485 {
486  mLayer->setDashPatternOffset( spinPatternOffset->value() );
488  emit changed();
489 }
490 
491 void QgsSimpleLineSymbolLayerWidget::mCustomCheckBox_stateChanged( int state )
492 {
493  bool checked = ( state == Qt::Checked );
494  mChangePatternButton->setEnabled( checked );
495  label_3->setEnabled( !checked );
496  cboPenStyle->setEnabled( !checked );
497 
498  mLayer->setUseCustomDashPattern( checked );
499  emit changed();
500 }
501 
502 void QgsSimpleLineSymbolLayerWidget::mChangePatternButton_clicked()
503 {
505  if ( panel && panel->dockMode() )
506  {
508  widget->setPanelTitle( tr( "Custom Dash Pattern" ) );
509  widget->setUnit( mDashPatternUnitWidget->unit() );
510  connect( widget, &QgsPanelWidget::widgetChanged, this, [ this, widget ]()
511  {
514  } );
516  panel->openPanel( widget );
517  return;
518  }
519 
521  d.setUnit( mDashPatternUnitWidget->unit() );
522  if ( d.exec() == QDialog::Accepted )
523  {
524  mLayer->setCustomDashVector( d.dashDotVector() );
526  emit changed();
527  }
528 }
529 
530 void QgsSimpleLineSymbolLayerWidget::mPenWidthUnitWidget_changed()
531 {
532  if ( mLayer )
533  {
534  mLayer->setWidthUnit( mPenWidthUnitWidget->unit() );
535  mLayer->setWidthMapUnitScale( mPenWidthUnitWidget->getMapUnitScale() );
537  emit changed();
538  }
539 }
540 
541 void QgsSimpleLineSymbolLayerWidget::mOffsetUnitWidget_changed()
542 {
543  if ( mLayer )
544  {
545  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
546  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
547  emit changed();
548  }
549 }
550 
551 void QgsSimpleLineSymbolLayerWidget::mDashPatternUnitWidget_changed()
552 {
553  if ( mLayer )
554  {
555  mLayer->setCustomDashPatternUnit( mDashPatternUnitWidget->unit() );
556  mLayer->setCustomDashPatternMapUnitScale( mDashPatternUnitWidget->getMapUnitScale() );
558  emit changed();
559  }
560 }
561 
562 void QgsSimpleLineSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
563 {
564  bool checked = ( state == Qt::Checked );
565  mLayer->setDrawInsidePolygon( checked );
566  emit changed();
567 }
568 
569 void QgsSimpleLineSymbolLayerWidget::patternOffsetUnitChanged()
570 {
571  if ( mLayer )
572  {
573  mLayer->setDashPatternOffsetUnit( mPatternOffsetUnitWidget->unit() );
574  mLayer->setDashPatternOffsetMapUnitScale( mPatternOffsetUnitWidget->getMapUnitScale() );
576  emit changed();
577  }
578 }
579 
581 {
582  if ( !mLayer )
583  {
584  return;
585  }
586  std::unique_ptr< QgsSimpleLineSymbolLayer > layerCopy( mLayer->clone() );
587  if ( !layerCopy )
588  {
589  return;
590  }
591  QColor color = qApp->palette().color( QPalette::WindowText );
592  layerCopy->setColor( color );
593  // reset offset, we don't want to show that in the preview
594  layerCopy->setOffset( 0 );
595  layerCopy->setUseCustomDashPattern( true );
596 
597  QSize currentIconSize;
598  //icon size is button size with a small margin
599 #ifdef Q_OS_WIN
600  currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 6 );
601 #else
602  currentIconSize = QSize( mChangePatternButton->width() - 10, mChangePatternButton->height() - 12 );
603 #endif
604 
605  if ( !currentIconSize.isValid() || currentIconSize.width() <= 0 || currentIconSize.height() <= 0 )
606  {
607  return;
608  }
609 
610  //create an icon pixmap
611  std::unique_ptr< QgsLineSymbol > previewSymbol = std::make_unique< QgsLineSymbol >( QgsSymbolLayerList() << layerCopy.release() );
612  const QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( previewSymbol.get(), currentIconSize );
613  mChangePatternButton->setIconSize( currentIconSize );
614  mChangePatternButton->setIcon( icon );
615 
616  // set tooltip
617  // create very large preview image
618  int width = static_cast< int >( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 23 );
619  int height = static_cast< int >( width / 1.61803398875 ); // golden ratio
620 
621  QPixmap pm = QgsSymbolLayerUtils::symbolPreviewPixmap( previewSymbol.get(), QSize( width, height ), height / 20 );
622  QByteArray data;
623  QBuffer buffer( &data );
624  pm.save( &buffer, "PNG", 100 );
625  mChangePatternButton->setToolTip( QStringLiteral( "<img src='data:image/png;base64, %3'>" ).arg( QString( data.toBase64() ) ) );
626 }
627 
629 {
630  QgsSymbolLayerWidget::resizeEvent( event );
631  // redraw custom dash pattern icon -- the button size has changed
633 }
634 
635 
637 
638 
640  : QgsSymbolLayerWidget( parent, vl )
641 {
642  mLayer = nullptr;
643 
644  setupUi( this );
645  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
646  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
647  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
648  connect( mStrokeStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged );
649  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
650  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
651  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
658 
659  btnChangeColorFill->setAllowOpacity( true );
660  btnChangeColorFill->setColorDialogTitle( tr( "Select Fill Color" ) );
661  btnChangeColorFill->setContext( QStringLiteral( "symbology" ) );
662  btnChangeColorFill->setShowNoColor( true );
663  btnChangeColorFill->setNoColorString( tr( "Transparent Fill" ) );
664  btnChangeColorStroke->setAllowOpacity( true );
665  btnChangeColorStroke->setColorDialogTitle( tr( "Select Stroke Color" ) );
666  btnChangeColorStroke->setContext( QStringLiteral( "symbology" ) );
667  btnChangeColorStroke->setShowNoColor( true );
668  btnChangeColorStroke->setNoColorString( tr( "Transparent Stroke" ) );
669 
670  mFillColorDDBtn->registerLinkedWidget( btnChangeColorFill );
671  mStrokeColorDDBtn->registerLinkedWidget( btnChangeColorStroke );
672 
673  spinOffsetX->setClearValue( 0.0 );
674  spinOffsetY->setClearValue( 0.0 );
675  spinAngle->setClearValue( 0.0 );
676 
677  //make a temporary symbol for the size assistant preview
678  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
679 
680  if ( vectorLayer() )
681  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
682 
683  int size = lstNames->iconSize().width();
684 
685  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
686 
687  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
688  lstNames->setIconSize( QSize( size, size ) );
689 
690  double markerSize = size * 0.8;
692  for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
693  {
694  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
696  lyr->setColor( QColor( 200, 200, 200 ) );
697  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
698  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
699  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
700  item->setData( Qt::UserRole, static_cast< int >( shape ) );
701  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
702  delete lyr;
703  }
704  // show at least 3 rows
705  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
706 
707  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setShape );
708  connect( btnChangeColorStroke, &QgsColorButton::colorChanged, this, &QgsSimpleMarkerSymbolLayerWidget::setColorStroke );
710  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged );
711  connect( cboCapStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged );
712  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setSize );
713  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setAngle );
714  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
715  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleMarkerSymbolLayerWidget::setOffset );
716  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol );
717 }
718 
720 
722 {
723  if ( layer->layerType() != QLatin1String( "SimpleMarker" ) )
724  return;
725 
726  // layer type is correct, we can do the cast
727  mLayer = static_cast<QgsSimpleMarkerSymbolLayer *>( layer );
728 
729  // set values
731  for ( int i = 0; i < lstNames->count(); ++i )
732  {
733  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
734  {
735  lstNames->setCurrentRow( i );
736  break;
737  }
738  }
739  btnChangeColorStroke->blockSignals( true );
740  btnChangeColorStroke->setColor( mLayer->strokeColor() );
741  btnChangeColorStroke->blockSignals( false );
742  btnChangeColorFill->blockSignals( true );
743  btnChangeColorFill->setColor( mLayer->fillColor() );
744  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
745  btnChangeColorFill->blockSignals( false );
746  spinSize->blockSignals( true );
747  spinSize->setValue( mLayer->size() );
748  spinSize->blockSignals( false );
749  spinAngle->blockSignals( true );
750  spinAngle->setValue( mLayer->angle() );
751  spinAngle->blockSignals( false );
752  mStrokeStyleComboBox->blockSignals( true );
753  mStrokeStyleComboBox->setPenStyle( mLayer->strokeStyle() );
754  mStrokeStyleComboBox->blockSignals( false );
755  mStrokeWidthSpinBox->blockSignals( true );
756  mStrokeWidthSpinBox->setValue( mLayer->strokeWidth() );
757  mStrokeWidthSpinBox->blockSignals( false );
758  cboJoinStyle->blockSignals( true );
759  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
760  cboJoinStyle->blockSignals( false );
761  cboCapStyle->blockSignals( true );
762  cboCapStyle->setPenCapStyle( mLayer->penCapStyle() );
763  cboCapStyle->blockSignals( false );
764 
765  // without blocking signals the value gets changed because of slot setOffset()
766  spinOffsetX->blockSignals( true );
767  spinOffsetX->setValue( mLayer->offset().x() );
768  spinOffsetX->blockSignals( false );
769  spinOffsetY->blockSignals( true );
770  spinOffsetY->setValue( mLayer->offset().y() );
771  spinOffsetY->blockSignals( false );
772 
773  mSizeUnitWidget->blockSignals( true );
774  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
775  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
776  mSizeUnitWidget->blockSignals( false );
777  mOffsetUnitWidget->blockSignals( true );
778  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
779  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
780  mOffsetUnitWidget->blockSignals( false );
781  mStrokeWidthUnitWidget->blockSignals( true );
782  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
783  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
784  mStrokeWidthUnitWidget->blockSignals( false );
785 
786  //anchor points
787  mHorizontalAnchorComboBox->blockSignals( true );
788  mVerticalAnchorComboBox->blockSignals( true );
789  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
790  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
791  mHorizontalAnchorComboBox->blockSignals( false );
792  mVerticalAnchorComboBox->blockSignals( false );
793 
806 
807  updateAssistantSymbol();
808 }
809 
811 {
812  return mLayer;
813 }
814 
815 void QgsSimpleMarkerSymbolLayerWidget::setShape()
816 {
817  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
818  btnChangeColorFill->setEnabled( QgsSimpleMarkerSymbolLayerBase::shapeIsFilled( mLayer->shape() ) );
819  emit changed();
820 }
821 
823 {
824  mLayer->setStrokeColor( color );
825  emit changed();
826 }
827 
829 {
830  mLayer->setColor( color );
831  emit changed();
832 }
833 
834 void QgsSimpleMarkerSymbolLayerWidget::penJoinStyleChanged()
835 {
836  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
837  emit changed();
838 }
839 
840 void QgsSimpleMarkerSymbolLayerWidget::penCapStyleChanged()
841 {
842  mLayer->setPenCapStyle( cboCapStyle->penCapStyle() );
843  emit changed();
844 }
845 
846 void QgsSimpleMarkerSymbolLayerWidget::setSize()
847 {
848  mLayer->setSize( spinSize->value() );
849  emit changed();
850 }
851 
852 void QgsSimpleMarkerSymbolLayerWidget::setAngle()
853 {
854  mLayer->setAngle( spinAngle->value() );
855  emit changed();
856 }
857 
858 void QgsSimpleMarkerSymbolLayerWidget::setOffset()
859 {
860  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
861  emit changed();
862 }
863 
864 void QgsSimpleMarkerSymbolLayerWidget::mStrokeStyleComboBox_currentIndexChanged( int index )
865 {
866  Q_UNUSED( index )
867 
868  if ( mLayer )
869  {
870  mLayer->setStrokeStyle( mStrokeStyleComboBox->penStyle() );
871  emit changed();
872  }
873 }
874 
875 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
876 {
877  if ( mLayer )
878  {
879  mLayer->setStrokeWidth( d );
880  emit changed();
881  }
882 }
883 
884 void QgsSimpleMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
885 {
886  if ( mLayer )
887  {
888  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
889  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
890  emit changed();
891  }
892 }
893 
894 void QgsSimpleMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
895 {
896  if ( mLayer )
897  {
898  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
899  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
900  emit changed();
901  }
902 }
903 
904 void QgsSimpleMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
905 {
906  if ( mLayer )
907  {
908  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
909  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
910  emit changed();
911  }
912 }
913 
914 void QgsSimpleMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
915 {
916  if ( mLayer )
917  {
919  emit changed();
920  }
921 }
922 
923 void QgsSimpleMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
924 {
925  if ( mLayer )
926  {
928  emit changed();
929  }
930 }
931 
932 void QgsSimpleMarkerSymbolLayerWidget::updateAssistantSymbol()
933 {
934  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
935  {
936  mAssistantPreviewSymbol->deleteSymbolLayer( i );
937  }
938  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
940  if ( ddSize )
941  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
942 }
943 
944 
946 
948  : QgsSymbolLayerWidget( parent, vl )
949 {
950  mLayer = nullptr;
951 
952  setupUi( this );
953  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
954  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed );
959 
960  btnChangeColor->setAllowOpacity( true );
961  btnChangeColor->setColorDialogTitle( tr( "Select Fill Color" ) );
962  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
963  btnChangeColor->setShowNoColor( true );
964  btnChangeColor->setNoColorString( tr( "Transparent Fill" ) );
965  btnChangeStrokeColor->setAllowOpacity( true );
966  btnChangeStrokeColor->setColorDialogTitle( tr( "Select Stroke Color" ) );
967  btnChangeStrokeColor->setContext( QStringLiteral( "symbology" ) );
968  btnChangeStrokeColor->setShowNoColor( true );
969  btnChangeStrokeColor->setNoColorString( tr( "Transparent Stroke" ) );
970 
971  spinOffsetX->setClearValue( 0.0 );
972  spinOffsetY->setClearValue( 0.0 );
973 
975  connect( cboFillStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::setBrushStyle );
976  connect( btnChangeStrokeColor, &QgsColorButton::colorChanged, this, &QgsSimpleFillSymbolLayerWidget::setStrokeColor );
977  connect( spinStrokeWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeWidthChanged );
978  connect( cboStrokeStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
979  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSimpleFillSymbolLayerWidget::strokeStyleChanged );
980  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
981  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSimpleFillSymbolLayerWidget::offsetChanged );
982 
983  mFillColorDDBtn->registerLinkedWidget( btnChangeColor );
984  mStrokeColorDDBtn->registerLinkedWidget( btnChangeStrokeColor );
985 }
986 
988 {
989  if ( layer->layerType() != QLatin1String( "SimpleFill" ) )
990  return;
991 
992  // layer type is correct, we can do the cast
993  mLayer = static_cast<QgsSimpleFillSymbolLayer *>( layer );
994 
995  // set values
996  btnChangeColor->blockSignals( true );
997  btnChangeColor->setColor( mLayer->color() );
998  btnChangeColor->blockSignals( false );
999  cboFillStyle->blockSignals( true );
1000  cboFillStyle->setBrushStyle( mLayer->brushStyle() );
1001  cboFillStyle->blockSignals( false );
1002  btnChangeStrokeColor->blockSignals( true );
1003  btnChangeStrokeColor->setColor( mLayer->strokeColor() );
1004  btnChangeStrokeColor->blockSignals( false );
1005  cboStrokeStyle->blockSignals( true );
1006  cboStrokeStyle->setPenStyle( mLayer->strokeStyle() );
1007  cboStrokeStyle->blockSignals( false );
1008  spinStrokeWidth->blockSignals( true );
1009  spinStrokeWidth->setValue( mLayer->strokeWidth() );
1010  spinStrokeWidth->blockSignals( false );
1011  cboJoinStyle->blockSignals( true );
1012  cboJoinStyle->setPenJoinStyle( mLayer->penJoinStyle() );
1013  cboJoinStyle->blockSignals( false );
1014  spinOffsetX->blockSignals( true );
1015  spinOffsetX->setValue( mLayer->offset().x() );
1016  spinOffsetX->blockSignals( false );
1017  spinOffsetY->blockSignals( true );
1018  spinOffsetY->setValue( mLayer->offset().y() );
1019  spinOffsetY->blockSignals( false );
1020 
1021  mStrokeWidthUnitWidget->blockSignals( true );
1022  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
1023  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
1024  mStrokeWidthUnitWidget->blockSignals( false );
1025  mOffsetUnitWidget->blockSignals( true );
1026  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1027  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1028  mOffsetUnitWidget->blockSignals( false );
1029 
1037 }
1038 
1040 {
1041  return mLayer;
1042 }
1043 
1044 void QgsSimpleFillSymbolLayerWidget::setColor( const QColor &color )
1045 {
1046  mLayer->setColor( color );
1047  emit changed();
1048 }
1049 
1051 {
1052  mLayer->setStrokeColor( color );
1053  emit changed();
1054 }
1055 
1056 void QgsSimpleFillSymbolLayerWidget::setBrushStyle()
1057 {
1058  mLayer->setBrushStyle( cboFillStyle->brushStyle() );
1059  emit changed();
1060 }
1061 
1062 void QgsSimpleFillSymbolLayerWidget::strokeWidthChanged()
1063 {
1064  mLayer->setStrokeWidth( spinStrokeWidth->value() );
1065  emit changed();
1066 }
1067 
1068 void QgsSimpleFillSymbolLayerWidget::strokeStyleChanged()
1069 {
1070  mLayer->setStrokeStyle( cboStrokeStyle->penStyle() );
1071  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
1072  emit changed();
1073 }
1074 
1075 void QgsSimpleFillSymbolLayerWidget::offsetChanged()
1076 {
1077  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1078  emit changed();
1079 }
1080 
1081 void QgsSimpleFillSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
1082 {
1083  if ( mLayer )
1084  {
1085  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
1086  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
1087  emit changed();
1088  }
1089 }
1090 
1091 void QgsSimpleFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1092 {
1093  if ( mLayer )
1094  {
1095  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1096  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1097  emit changed();
1098  }
1099 }
1100 
1102 
1104  : QgsSymbolLayerWidget( parent, vl )
1105 {
1106  mLayer = nullptr;
1107 
1108  setupUi( this );
1109  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
1110  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
1111  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
1112  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
1117 
1118  spinOffsetX->setClearValue( 0.0 );
1119  spinOffsetY->setClearValue( 0.0 );
1120  spinAngle->setClearValue( 0.0 );
1121 
1122  //make a temporary symbol for the size assistant preview
1123  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
1124 
1125  if ( vectorLayer() )
1126  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
1127 
1128  int size = lstNames->iconSize().width();
1129  size = std::max( 30, static_cast< int >( std::round( Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance( 'X' ) * 3 ) ) );
1130  lstNames->setGridSize( QSize( size * 1.2, size * 1.2 ) );
1131  lstNames->setIconSize( QSize( size, size ) );
1132 
1133  double markerSize = size * 0.8;
1135  for ( QgsSimpleMarkerSymbolLayerBase::Shape shape : shapes )
1136  {
1137  QgsSimpleMarkerSymbolLayer *lyr = new QgsSimpleMarkerSymbolLayer( shape, markerSize );
1139  lyr->setColor( QColor( 200, 200, 200 ) );
1140  lyr->setStrokeColor( QColor( 0, 0, 0 ) );
1141  QIcon icon = QgsSymbolLayerUtils::symbolLayerPreviewIcon( lyr, QgsUnitTypes::RenderPixels, QSize( size, size ) );
1142  QListWidgetItem *item = new QListWidgetItem( icon, QString(), lstNames );
1143  item->setData( Qt::UserRole, static_cast< int >( shape ) );
1144  item->setToolTip( QgsSimpleMarkerSymbolLayerBase::encodeShape( shape ) );
1145  delete lyr;
1146  }
1147  // show at least 3 rows
1148  lstNames->setMinimumHeight( lstNames->gridSize().height() * 3.1 );
1149 
1150  connect( lstNames, &QListWidget::currentRowChanged, this, &QgsFilledMarkerSymbolLayerWidget::setShape );
1151  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setSize );
1152  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setAngle );
1153  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1154  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFilledMarkerSymbolLayerWidget::setOffset );
1155  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol );
1156 }
1157 
1159 
1161 {
1162  if ( layer->layerType() != QLatin1String( "FilledMarker" ) )
1163  return;
1164 
1165  // layer type is correct, we can do the cast
1166  mLayer = static_cast<QgsFilledMarkerSymbolLayer *>( layer );
1167 
1168  // set values
1170  for ( int i = 0; i < lstNames->count(); ++i )
1171  {
1172  if ( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape >( lstNames->item( i )->data( Qt::UserRole ).toInt() ) == shape )
1173  {
1174  lstNames->setCurrentRow( i );
1175  break;
1176  }
1177  }
1178  whileBlocking( spinSize )->setValue( mLayer->size() );
1179  whileBlocking( spinAngle )->setValue( mLayer->angle() );
1180  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
1181  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
1182 
1183  mSizeUnitWidget->blockSignals( true );
1184  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
1185  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
1186  mSizeUnitWidget->blockSignals( false );
1187  mOffsetUnitWidget->blockSignals( true );
1188  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1189  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1190  mOffsetUnitWidget->blockSignals( false );
1191 
1192  //anchor points
1193  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
1194  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
1195 
1202 
1203  updateAssistantSymbol();
1204 }
1205 
1207 {
1208  return mLayer;
1209 }
1210 
1211 void QgsFilledMarkerSymbolLayerWidget::setShape()
1212 {
1213  mLayer->setShape( static_cast< QgsSimpleMarkerSymbolLayerBase::Shape>( lstNames->currentItem()->data( Qt::UserRole ).toInt() ) );
1214  emit changed();
1215 }
1216 
1217 void QgsFilledMarkerSymbolLayerWidget::setSize()
1218 {
1219  mLayer->setSize( spinSize->value() );
1220  emit changed();
1221 }
1222 
1223 void QgsFilledMarkerSymbolLayerWidget::setAngle()
1224 {
1225  mLayer->setAngle( spinAngle->value() );
1226  emit changed();
1227 }
1228 
1229 void QgsFilledMarkerSymbolLayerWidget::setOffset()
1230 {
1231  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1232  emit changed();
1233 }
1234 
1235 void QgsFilledMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
1236 {
1237  if ( mLayer )
1238  {
1239  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
1240  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
1241  emit changed();
1242  }
1243 }
1244 
1245 void QgsFilledMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
1246 {
1247  if ( mLayer )
1248  {
1249  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1250  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1251  emit changed();
1252  }
1253 }
1254 
1255 void QgsFilledMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
1256 {
1257  if ( mLayer )
1258  {
1260  emit changed();
1261  }
1262 }
1263 
1264 void QgsFilledMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
1265 {
1266  if ( mLayer )
1267  {
1269  emit changed();
1270  }
1271 }
1272 
1273 void QgsFilledMarkerSymbolLayerWidget::updateAssistantSymbol()
1274 {
1275  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
1276  {
1277  mAssistantPreviewSymbol->deleteSymbolLayer( i );
1278  }
1279  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
1281  if ( ddSize )
1282  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
1283 }
1284 
1285 
1287 
1289  : QgsSymbolLayerWidget( parent, vl )
1290 {
1291  mLayer = nullptr;
1292 
1293  setupUi( this );
1294  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1295  connect( mSpinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged );
1298 
1299  btnColorRamp->setShowGradientOnly( true );
1300 
1301  btnChangeColor->setAllowOpacity( true );
1302  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1303  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1304  btnChangeColor->setShowNoColor( true );
1305  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1306  btnChangeColor2->setAllowOpacity( true );
1307  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1308  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1309  btnChangeColor2->setShowNoColor( true );
1310  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1311 
1312  mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1313  mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1314 
1315  spinOffsetX->setClearValue( 0.0 );
1316  spinOffsetY->setClearValue( 0.0 );
1317  mSpinAngle->setClearValue( 0.0 );
1318 
1322  connect( cboGradientType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientType );
1323  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setCoordinateMode );
1324  connect( cboGradientSpread, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGradientFillSymbolLayerWidget::setGradientSpread );
1325  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::colorModeChanged );
1326  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1327  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::offsetChanged );
1328  connect( spinRefPoint1X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1329  connect( spinRefPoint1Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1330  connect( checkRefPoint1Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1331  connect( spinRefPoint2X, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1332  connect( spinRefPoint2Y, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1333  connect( checkRefPoint2Centroid, &QAbstractButton::toggled, this, &QgsGradientFillSymbolLayerWidget::referencePointChanged );
1334 }
1335 
1337 {
1338  if ( layer->layerType() != QLatin1String( "GradientFill" ) )
1339  return;
1340 
1341  // layer type is correct, we can do the cast
1342  mLayer = static_cast<QgsGradientFillSymbolLayer *>( layer );
1343 
1344  // set values
1345  btnChangeColor->blockSignals( true );
1346  btnChangeColor->setColor( mLayer->color() );
1347  btnChangeColor->blockSignals( false );
1348  btnChangeColor2->blockSignals( true );
1349  btnChangeColor2->setColor( mLayer->color2() );
1350  btnChangeColor2->blockSignals( false );
1351 
1353  {
1354  radioTwoColor->setChecked( true );
1355  btnColorRamp->setEnabled( false );
1356  }
1357  else
1358  {
1359  radioColorRamp->setChecked( true );
1360  btnChangeColor->setEnabled( false );
1361  btnChangeColor2->setEnabled( false );
1362  }
1363 
1364  // set source color ramp
1365  if ( mLayer->colorRamp() )
1366  {
1367  btnColorRamp->blockSignals( true );
1368  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1369  btnColorRamp->blockSignals( false );
1370  }
1371 
1372  cboGradientType->blockSignals( true );
1373  switch ( mLayer->gradientType() )
1374  {
1376  cboGradientType->setCurrentIndex( 0 );
1377  break;
1379  cboGradientType->setCurrentIndex( 1 );
1380  break;
1382  cboGradientType->setCurrentIndex( 2 );
1383  break;
1384  }
1385  cboGradientType->blockSignals( false );
1386 
1387  cboCoordinateMode->blockSignals( true );
1388  switch ( mLayer->coordinateMode() )
1389  {
1391  cboCoordinateMode->setCurrentIndex( 1 );
1392  checkRefPoint1Centroid->setEnabled( false );
1393  checkRefPoint2Centroid->setEnabled( false );
1394  break;
1396  default:
1397  cboCoordinateMode->setCurrentIndex( 0 );
1398  break;
1399  }
1400  cboCoordinateMode->blockSignals( false );
1401 
1402  cboGradientSpread->blockSignals( true );
1403  switch ( mLayer->gradientSpread() )
1404  {
1406  cboGradientSpread->setCurrentIndex( 0 );
1407  break;
1409  cboGradientSpread->setCurrentIndex( 1 );
1410  break;
1412  cboGradientSpread->setCurrentIndex( 2 );
1413  break;
1414  }
1415  cboGradientSpread->blockSignals( false );
1416 
1417  spinRefPoint1X->blockSignals( true );
1418  spinRefPoint1X->setValue( mLayer->referencePoint1().x() );
1419  spinRefPoint1X->blockSignals( false );
1420  spinRefPoint1Y->blockSignals( true );
1421  spinRefPoint1Y->setValue( mLayer->referencePoint1().y() );
1422  spinRefPoint1Y->blockSignals( false );
1423  checkRefPoint1Centroid->blockSignals( true );
1424  checkRefPoint1Centroid->setChecked( mLayer->referencePoint1IsCentroid() );
1426  {
1427  spinRefPoint1X->setEnabled( false );
1428  spinRefPoint1Y->setEnabled( false );
1429  }
1430  checkRefPoint1Centroid->blockSignals( false );
1431  spinRefPoint2X->blockSignals( true );
1432  spinRefPoint2X->setValue( mLayer->referencePoint2().x() );
1433  spinRefPoint2X->blockSignals( false );
1434  spinRefPoint2Y->blockSignals( true );
1435  spinRefPoint2Y->setValue( mLayer->referencePoint2().y() );
1436  spinRefPoint2Y->blockSignals( false );
1437  checkRefPoint2Centroid->blockSignals( true );
1438  checkRefPoint2Centroid->setChecked( mLayer->referencePoint2IsCentroid() );
1440  {
1441  spinRefPoint2X->setEnabled( false );
1442  spinRefPoint2Y->setEnabled( false );
1443  }
1444  checkRefPoint2Centroid->blockSignals( false );
1445 
1446  spinOffsetX->blockSignals( true );
1447  spinOffsetX->setValue( mLayer->offset().x() );
1448  spinOffsetX->blockSignals( false );
1449  spinOffsetY->blockSignals( true );
1450  spinOffsetY->setValue( mLayer->offset().y() );
1451  spinOffsetY->blockSignals( false );
1452  mSpinAngle->blockSignals( true );
1453  mSpinAngle->setValue( mLayer->angle() );
1454  mSpinAngle->blockSignals( false );
1455 
1456  mOffsetUnitWidget->blockSignals( true );
1457  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1458  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1459  mOffsetUnitWidget->blockSignals( false );
1460 
1474 }
1475 
1477 {
1478  return mLayer;
1479 }
1480 
1482 {
1483  mLayer->setColor( color );
1484  emit changed();
1485 }
1486 
1488 {
1489  mLayer->setColor2( color );
1490  emit changed();
1491 }
1492 
1493 void QgsGradientFillSymbolLayerWidget::colorModeChanged()
1494 {
1495  if ( radioTwoColor->isChecked() )
1496  {
1498  }
1499  else
1500  {
1502  }
1503  emit changed();
1504 }
1505 
1507 {
1508  if ( btnColorRamp->isNull() )
1509  return;
1510 
1511  mLayer->setColorRamp( btnColorRamp->colorRamp()->clone() );
1512  emit changed();
1513 }
1514 
1516 {
1517  switch ( index )
1518  {
1519  case 0:
1521  //set sensible default reference points
1522  spinRefPoint1X->setValue( 0.5 );
1523  spinRefPoint1Y->setValue( 0 );
1524  spinRefPoint2X->setValue( 0.5 );
1525  spinRefPoint2Y->setValue( 1 );
1526  break;
1527  case 1:
1529  //set sensible default reference points
1530  spinRefPoint1X->setValue( 0 );
1531  spinRefPoint1Y->setValue( 0 );
1532  spinRefPoint2X->setValue( 1 );
1533  spinRefPoint2Y->setValue( 1 );
1534  break;
1535  case 2:
1537  spinRefPoint1X->setValue( 0.5 );
1538  spinRefPoint1Y->setValue( 0.5 );
1539  spinRefPoint2X->setValue( 1 );
1540  spinRefPoint2Y->setValue( 1 );
1541  break;
1542  }
1543  emit changed();
1544 }
1545 
1547 {
1548 
1549  switch ( index )
1550  {
1551  case 0:
1552  //feature coordinate mode
1554  //allow choice of centroid reference positions
1555  checkRefPoint1Centroid->setEnabled( true );
1556  checkRefPoint2Centroid->setEnabled( true );
1557  break;
1558  case 1:
1559  //viewport coordinate mode
1561  //disable choice of centroid reference positions
1562  checkRefPoint1Centroid->setChecked( Qt::Unchecked );
1563  checkRefPoint1Centroid->setEnabled( false );
1564  checkRefPoint2Centroid->setChecked( Qt::Unchecked );
1565  checkRefPoint2Centroid->setEnabled( false );
1566  break;
1567  }
1568 
1569  emit changed();
1570 }
1571 
1573 {
1574  switch ( index )
1575  {
1576  case 0:
1578  break;
1579  case 1:
1581  break;
1582  case 2:
1584  break;
1585  }
1586 
1587  emit changed();
1588 }
1589 
1590 void QgsGradientFillSymbolLayerWidget::offsetChanged()
1591 {
1592  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1593  emit changed();
1594 }
1595 
1596 void QgsGradientFillSymbolLayerWidget::referencePointChanged()
1597 {
1598  mLayer->setReferencePoint1( QPointF( spinRefPoint1X->value(), spinRefPoint1Y->value() ) );
1599  mLayer->setReferencePoint1IsCentroid( checkRefPoint1Centroid->isChecked() );
1600  mLayer->setReferencePoint2( QPointF( spinRefPoint2X->value(), spinRefPoint2Y->value() ) );
1601  mLayer->setReferencePoint2IsCentroid( checkRefPoint2Centroid->isChecked() );
1602  emit changed();
1603 }
1604 
1605 void QgsGradientFillSymbolLayerWidget::mSpinAngle_valueChanged( double value )
1606 {
1607  mLayer->setAngle( value );
1608  emit changed();
1609 }
1610 
1611 void QgsGradientFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1612 {
1613  if ( mLayer )
1614  {
1615  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1616  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1617  emit changed();
1618  }
1619 }
1620 
1622 
1624  : QgsSymbolLayerWidget( parent, vl )
1625 {
1626  mLayer = nullptr;
1627 
1628  setupUi( this );
1629  connect( mSpinBlurRadius, qOverload< int >( &QSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged );
1630  connect( mSpinMaxDistance, qOverload< double >( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged );
1631  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed );
1632  connect( mRadioUseWholeShape, &QRadioButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled );
1633  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed );
1634  connect( mIgnoreRingsCheckBox, &QCheckBox::stateChanged, this, &QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged );
1639 
1640  QButtonGroup *group1 = new QButtonGroup( this );
1641  group1->addButton( radioColorRamp );
1642  group1->addButton( radioTwoColor );
1643  QButtonGroup *group2 = new QButtonGroup( this );
1644  group2->addButton( mRadioUseMaxDistance );
1645  group2->addButton( mRadioUseWholeShape );
1646  btnChangeColor->setAllowOpacity( true );
1647  btnChangeColor->setColorDialogTitle( tr( "Select Gradient Color" ) );
1648  btnChangeColor->setContext( QStringLiteral( "symbology" ) );
1649  btnChangeColor->setShowNoColor( true );
1650  btnChangeColor->setNoColorString( tr( "Transparent" ) );
1651  btnChangeColor2->setAllowOpacity( true );
1652  btnChangeColor2->setColorDialogTitle( tr( "Select Gradient Color" ) );
1653  btnChangeColor2->setContext( QStringLiteral( "symbology" ) );
1654  btnChangeColor2->setShowNoColor( true );
1655  btnChangeColor2->setNoColorString( tr( "Transparent" ) );
1656 
1657  mStartColorDDBtn->registerLinkedWidget( btnChangeColor );
1658  mEndColorDDBtn->registerLinkedWidget( btnChangeColor2 );
1659 
1660  spinOffsetX->setClearValue( 0.0 );
1661  spinOffsetY->setClearValue( 0.0 );
1662  mSpinMaxDistance->setClearValue( 5.0 );
1663 
1664  btnColorRamp->setShowGradientOnly( true );
1665 
1666  connect( btnColorRamp, &QgsColorRampButton::colorRampChanged, this, &QgsShapeburstFillSymbolLayerWidget::applyColorRamp );
1667 
1670  connect( radioTwoColor, &QAbstractButton::toggled, this, &QgsShapeburstFillSymbolLayerWidget::colorModeChanged );
1671  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1672  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsShapeburstFillSymbolLayerWidget::offsetChanged );
1673 
1674  connect( mBlurSlider, &QAbstractSlider::valueChanged, mSpinBlurRadius, &QSpinBox::setValue );
1675  connect( mSpinBlurRadius, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mBlurSlider, &QAbstractSlider::setValue );
1676 }
1677 
1679 {
1680  if ( layer->layerType() != QLatin1String( "ShapeburstFill" ) )
1681  return;
1682 
1683  // layer type is correct, we can do the cast
1684  mLayer = static_cast<QgsShapeburstFillSymbolLayer *>( layer );
1685 
1686  // set values
1687  btnChangeColor->blockSignals( true );
1688  btnChangeColor->setColor( mLayer->color() );
1689  btnChangeColor->blockSignals( false );
1690  btnChangeColor2->blockSignals( true );
1691  btnChangeColor2->setColor( mLayer->color2() );
1692  btnChangeColor2->blockSignals( false );
1693 
1695  {
1696  radioTwoColor->setChecked( true );
1697  btnColorRamp->setEnabled( false );
1698  }
1699  else
1700  {
1701  radioColorRamp->setChecked( true );
1702  btnChangeColor->setEnabled( false );
1703  btnChangeColor2->setEnabled( false );
1704  }
1705 
1706  mSpinBlurRadius->blockSignals( true );
1707  mBlurSlider->blockSignals( true );
1708  mSpinBlurRadius->setValue( mLayer->blurRadius() );
1709  mBlurSlider->setValue( mLayer->blurRadius() );
1710  mSpinBlurRadius->blockSignals( false );
1711  mBlurSlider->blockSignals( false );
1712 
1713  mSpinMaxDistance->blockSignals( true );
1714  mSpinMaxDistance->setValue( mLayer->maxDistance() );
1715  mSpinMaxDistance->blockSignals( false );
1716 
1717  mRadioUseWholeShape->blockSignals( true );
1718  mRadioUseMaxDistance->blockSignals( true );
1719  if ( mLayer->useWholeShape() )
1720  {
1721  mRadioUseWholeShape->setChecked( true );
1722  mSpinMaxDistance->setEnabled( false );
1723  mDistanceUnitWidget->setEnabled( false );
1724  }
1725  else
1726  {
1727  mRadioUseMaxDistance->setChecked( true );
1728  mSpinMaxDistance->setEnabled( true );
1729  mDistanceUnitWidget->setEnabled( true );
1730  }
1731  mRadioUseWholeShape->blockSignals( false );
1732  mRadioUseMaxDistance->blockSignals( false );
1733 
1734  mDistanceUnitWidget->blockSignals( true );
1735  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
1736  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
1737  mDistanceUnitWidget->blockSignals( false );
1738 
1739  mIgnoreRingsCheckBox->blockSignals( true );
1740  mIgnoreRingsCheckBox->setCheckState( mLayer->ignoreRings() ? Qt::Checked : Qt::Unchecked );
1741  mIgnoreRingsCheckBox->blockSignals( false );
1742 
1743  // set source color ramp
1744  if ( mLayer->colorRamp() )
1745  {
1746  btnColorRamp->blockSignals( true );
1747  btnColorRamp->setColorRamp( mLayer->colorRamp() );
1748  btnColorRamp->blockSignals( false );
1749  }
1750 
1751  spinOffsetX->blockSignals( true );
1752  spinOffsetX->setValue( mLayer->offset().x() );
1753  spinOffsetX->blockSignals( false );
1754  spinOffsetY->blockSignals( true );
1755  spinOffsetY->setValue( mLayer->offset().y() );
1756  spinOffsetY->blockSignals( false );
1757  mOffsetUnitWidget->blockSignals( true );
1758  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1759  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1760  mOffsetUnitWidget->blockSignals( false );
1761 
1769 }
1770 
1772 {
1773  return mLayer;
1774 }
1775 
1777 {
1778  if ( mLayer )
1779  {
1780  mLayer->setColor( color );
1781  emit changed();
1782  }
1783 }
1784 
1786 {
1787  if ( mLayer )
1788  {
1789  mLayer->setColor2( color );
1790  emit changed();
1791  }
1792 }
1793 
1794 void QgsShapeburstFillSymbolLayerWidget::colorModeChanged()
1795 {
1796  if ( !mLayer )
1797  {
1798  return;
1799  }
1800 
1801  if ( radioTwoColor->isChecked() )
1802  {
1804  }
1805  else
1806  {
1808  }
1809  emit changed();
1810 }
1811 
1812 void QgsShapeburstFillSymbolLayerWidget::mSpinBlurRadius_valueChanged( int value )
1813 {
1814  if ( mLayer )
1815  {
1816  mLayer->setBlurRadius( value );
1817  emit changed();
1818  }
1819 }
1820 
1821 void QgsShapeburstFillSymbolLayerWidget::mSpinMaxDistance_valueChanged( double value )
1822 {
1823  if ( mLayer )
1824  {
1825  mLayer->setMaxDistance( value );
1826  emit changed();
1827  }
1828 }
1829 
1830 void QgsShapeburstFillSymbolLayerWidget::mDistanceUnitWidget_changed()
1831 {
1832  if ( mLayer )
1833  {
1834  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
1835  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
1836  emit changed();
1837  }
1838 }
1839 
1840 void QgsShapeburstFillSymbolLayerWidget::mRadioUseWholeShape_toggled( bool value )
1841 {
1842  if ( mLayer )
1843  {
1844  mLayer->setUseWholeShape( value );
1845  mDistanceUnitWidget->setEnabled( !value );
1846  emit changed();
1847  }
1848 }
1849 
1850 void QgsShapeburstFillSymbolLayerWidget::applyColorRamp()
1851 {
1852  QgsColorRamp *ramp = btnColorRamp->colorRamp();
1853  if ( !ramp )
1854  return;
1855 
1856  mLayer->setColorRamp( ramp );
1857  emit changed();
1858 }
1859 
1860 void QgsShapeburstFillSymbolLayerWidget::offsetChanged()
1861 {
1862  if ( mLayer )
1863  {
1864  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
1865  emit changed();
1866  }
1867 }
1868 
1869 void QgsShapeburstFillSymbolLayerWidget::mOffsetUnitWidget_changed()
1870 {
1871  if ( mLayer )
1872  {
1873  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
1874  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
1875  emit changed();
1876  }
1877 }
1878 
1879 
1880 void QgsShapeburstFillSymbolLayerWidget::mIgnoreRingsCheckBox_stateChanged( int state )
1881 {
1882  bool checked = ( state == Qt::Checked );
1883  mLayer->setIgnoreRings( checked );
1884  emit changed();
1885 }
1886 
1888 
1890  : QgsSymbolLayerWidget( parent, vl )
1891 {
1892  mLayer = nullptr;
1893 
1894  setupUi( this );
1895  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed );
1896  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed );
1897  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
1898  connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged );
1907 
1908  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
1909  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
1910  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
1911  connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
1912  {
1913  if ( mLayer )
1914  {
1915  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
1916  emit changed();
1917  }
1918  } );
1919 
1920  spinOffset->setClearValue( 0.0 );
1921 
1922  mSpinAverageAngleLength->setClearValue( 4.0 );
1923 
1924  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setInterval );
1925  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffsetAlongLine );
1926  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setRotate );
1927  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setOffset );
1928  connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsMarkerLineSymbolLayerWidget::setAverageAngle );
1929  connect( radInterval, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1930  connect( radVertex, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1931  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1932  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1933  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1934  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1935  connect( radSegmentCentralPoint, &QAbstractButton::clicked, this, &QgsMarkerLineSymbolLayerWidget::setPlacement );
1936 }
1937 
1939 {
1940  if ( layer->layerType() != QLatin1String( "MarkerLine" ) )
1941  return;
1942 
1943  // layer type is correct, we can do the cast
1944  mLayer = static_cast<QgsMarkerLineSymbolLayer *>( layer );
1945 
1946  // set values
1947  spinInterval->blockSignals( true );
1948  spinInterval->setValue( mLayer->interval() );
1949  spinInterval->blockSignals( false );
1950  mSpinOffsetAlongLine->blockSignals( true );
1951  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
1952  mSpinOffsetAlongLine->blockSignals( false );
1953  chkRotateMarker->blockSignals( true );
1954  chkRotateMarker->setChecked( mLayer->rotateSymbols() );
1955  chkRotateMarker->blockSignals( false );
1956  spinOffset->blockSignals( true );
1957  spinOffset->setValue( mLayer->offset() );
1958  spinOffset->blockSignals( false );
1960  radInterval->setChecked( true );
1962  radVertex->setChecked( true );
1964  radVertexLast->setChecked( true );
1966  radCentralPoint->setChecked( true );
1968  radCurvePoint->setChecked( true );
1970  radSegmentCentralPoint->setChecked( true );
1971  else
1972  radVertexFirst->setChecked( true );
1973 
1974  // set units
1975  mIntervalUnitWidget->blockSignals( true );
1976  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
1977  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
1978  mIntervalUnitWidget->blockSignals( false );
1979  mOffsetUnitWidget->blockSignals( true );
1980  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
1981  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
1982  mOffsetUnitWidget->blockSignals( false );
1983  mOffsetAlongLineUnitWidget->blockSignals( true );
1984  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
1985  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
1986  mOffsetAlongLineUnitWidget->blockSignals( false );
1987 
1988  whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
1989  whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
1990  whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
1991 
1992  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
1993 
1994  setPlacement(); // update gui
1995 
2001 }
2002 
2004 {
2005  return mLayer;
2006 }
2007 
2009 {
2011 
2012  switch ( context.symbolType() )
2013  {
2016  //these settings only have an effect when the symbol layers is part of a fill symbol
2017  mRingFilterComboBox->hide();
2018  mRingsLabel->hide();
2019  break;
2020 
2023  break;
2024  }
2025 }
2026 
2028 {
2029  mLayer->setInterval( val );
2030  emit changed();
2031 }
2032 
2034 {
2035  mLayer->setOffsetAlongLine( val );
2036  emit changed();
2037 }
2038 
2039 void QgsMarkerLineSymbolLayerWidget::setRotate()
2040 {
2041  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2042  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2043 
2044  mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2045  emit changed();
2046 }
2047 
2048 void QgsMarkerLineSymbolLayerWidget::setOffset()
2049 {
2050  mLayer->setOffset( spinOffset->value() );
2051  emit changed();
2052 }
2053 
2054 void QgsMarkerLineSymbolLayerWidget::setPlacement()
2055 {
2056  bool interval = radInterval->isChecked();
2057  spinInterval->setEnabled( interval );
2058  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
2059  mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2060  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2061  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2062  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
2063  if ( radInterval->isChecked() )
2065  else if ( radVertex->isChecked() )
2067  else if ( radVertexLast->isChecked() )
2069  else if ( radVertexFirst->isChecked() )
2071  else if ( radCurvePoint->isChecked() )
2073  else if ( radSegmentCentralPoint->isChecked() )
2075  else
2077 
2078  emit changed();
2079 }
2080 
2081 void QgsMarkerLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2082 {
2083  if ( mLayer )
2084  {
2085  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2086  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2087  emit changed();
2088  }
2089 }
2090 
2091 void QgsMarkerLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2092 {
2093  if ( mLayer )
2094  {
2095  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2096  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2097  emit changed();
2098  }
2099 }
2100 
2101 void QgsMarkerLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2102 {
2103  if ( mLayer )
2104  {
2105  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2106  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2107  }
2108  emit changed();
2109 }
2110 
2111 void QgsMarkerLineSymbolLayerWidget::averageAngleUnitChanged()
2112 {
2113  if ( mLayer )
2114  {
2115  mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2116  mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2117  }
2118  emit changed();
2119 }
2120 
2121 void QgsMarkerLineSymbolLayerWidget::setAverageAngle( double val )
2122 {
2123  if ( mLayer )
2124  {
2125  mLayer->setAverageAngleLength( val );
2126  emit changed();
2127  }
2128 }
2129 
2130 
2132 
2134  : QgsSymbolLayerWidget( parent, vl )
2135 {
2136  mLayer = nullptr;
2137 
2138  setupUi( this );
2139  connect( mIntervalUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed );
2140  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed );
2141  connect( mOffsetAlongLineUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed );
2142  connect( mAverageAngleUnit, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged );
2143  connect( mHashLengthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged );
2154 
2155  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconAllRings.svg" ) ), tr( "All Rings" ), QgsLineSymbolLayer::AllRings );
2156  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconExteriorRing.svg" ) ), tr( "Exterior Ring Only" ), QgsLineSymbolLayer::ExteriorRingOnly );
2157  mRingFilterComboBox->addItem( QgsApplication::getThemeIcon( QStringLiteral( "mIconInteriorRings.svg" ) ), tr( "Interior Rings Only" ), QgsLineSymbolLayer::InteriorRingsOnly );
2158  connect( mRingFilterComboBox, qOverload< int >( &QComboBox::currentIndexChanged ), this, [ = ]( int )
2159  {
2160  if ( mLayer )
2161  {
2162  mLayer->setRingFilter( static_cast< QgsLineSymbolLayer::RenderRingFilter >( mRingFilterComboBox->currentData().toInt() ) );
2163  emit changed();
2164  }
2165  } );
2166 
2167  spinOffset->setClearValue( 0.0 );
2168 
2169  mHashRotationSpinBox->setClearValue( 0 );
2170  mSpinAverageAngleLength->setClearValue( 4.0 );
2171 
2172  connect( spinInterval, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setInterval );
2173  connect( mSpinOffsetAlongLine, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffsetAlongLine );
2174  connect( mSpinHashLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashLength );
2175  connect( mHashRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setHashAngle );
2176  connect( chkRotateMarker, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setRotate );
2177  connect( spinOffset, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setOffset );
2178  connect( mSpinAverageAngleLength, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsHashedLineSymbolLayerWidget::setAverageAngle );
2179  connect( radInterval, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2180  connect( radVertex, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2181  connect( radVertexLast, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2182  connect( radVertexFirst, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2183  connect( radCentralPoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2184  connect( radCurvePoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2185  connect( radSegmentCentralPoint, &QAbstractButton::clicked, this, &QgsHashedLineSymbolLayerWidget::setPlacement );
2186 }
2187 
2189 {
2190  if ( layer->layerType() != QLatin1String( "HashLine" ) )
2191  return;
2192 
2193  // layer type is correct, we can do the cast
2194  mLayer = static_cast<QgsHashedLineSymbolLayer *>( layer );
2195 
2196  // set values
2197  spinInterval->blockSignals( true );
2198  spinInterval->setValue( mLayer->interval() );
2199  spinInterval->blockSignals( false );
2200  mSpinOffsetAlongLine->blockSignals( true );
2201  mSpinOffsetAlongLine->setValue( mLayer->offsetAlongLine() );
2202  mSpinOffsetAlongLine->blockSignals( false );
2203  whileBlocking( mSpinHashLength )->setValue( mLayer->hashLength() );
2204  whileBlocking( mHashRotationSpinBox )->setValue( mLayer->hashAngle() );
2205  chkRotateMarker->blockSignals( true );
2206  chkRotateMarker->setChecked( mLayer->rotateSymbols() );
2207  chkRotateMarker->blockSignals( false );
2208  spinOffset->blockSignals( true );
2209  spinOffset->setValue( mLayer->offset() );
2210  spinOffset->blockSignals( false );
2212  radInterval->setChecked( true );
2213  else if ( mLayer->placement() == QgsTemplatedLineSymbolLayerBase::Vertex )
2214  radVertex->setChecked( true );
2216  radVertexLast->setChecked( true );
2218  radCentralPoint->setChecked( true );
2220  radCurvePoint->setChecked( true );
2222  radSegmentCentralPoint->setChecked( true );
2223  else
2224  radVertexFirst->setChecked( true );
2225 
2226  // set units
2227  mIntervalUnitWidget->blockSignals( true );
2228  mIntervalUnitWidget->setUnit( mLayer->intervalUnit() );
2229  mIntervalUnitWidget->setMapUnitScale( mLayer->intervalMapUnitScale() );
2230  mIntervalUnitWidget->blockSignals( false );
2231  mOffsetUnitWidget->blockSignals( true );
2232  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2233  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2234  mOffsetUnitWidget->blockSignals( false );
2235  mOffsetAlongLineUnitWidget->blockSignals( true );
2236  mOffsetAlongLineUnitWidget->setUnit( mLayer->offsetAlongLineUnit() );
2237  mOffsetAlongLineUnitWidget->setMapUnitScale( mLayer->offsetAlongLineMapUnitScale() );
2238  mOffsetAlongLineUnitWidget->blockSignals( false );
2239  whileBlocking( mAverageAngleUnit )->setUnit( mLayer->averageAngleUnit() );
2240  whileBlocking( mAverageAngleUnit )->setMapUnitScale( mLayer->averageAngleMapUnitScale() );
2241  whileBlocking( mSpinAverageAngleLength )->setValue( mLayer->averageAngleLength() );
2242  whileBlocking( mHashLengthUnitWidget )->setUnit( mLayer->hashLengthUnit() );
2243  whileBlocking( mHashLengthUnitWidget )->setMapUnitScale( mLayer->hashLengthMapUnitScale() );
2244 
2245  whileBlocking( mRingFilterComboBox )->setCurrentIndex( mRingFilterComboBox->findData( mLayer->ringFilter() ) );
2246 
2247  setPlacement(); // update gui
2248 
2256 }
2257 
2259 {
2260  return mLayer;
2261 }
2262 
2264 {
2266 
2267  switch ( context.symbolType() )
2268  {
2271  //these settings only have an effect when the symbol layers is part of a fill symbol
2272  mRingFilterComboBox->hide();
2273  mRingsLabel->hide();
2274  break;
2275 
2278  break;
2279  }
2280 }
2281 
2282 void QgsHashedLineSymbolLayerWidget::setInterval( double val )
2283 {
2284  mLayer->setInterval( val );
2285  emit changed();
2286 }
2287 
2288 void QgsHashedLineSymbolLayerWidget::setOffsetAlongLine( double val )
2289 {
2290  mLayer->setOffsetAlongLine( val );
2291  emit changed();
2292 }
2293 
2294 void QgsHashedLineSymbolLayerWidget::setHashLength( double val )
2295 {
2296  mLayer->setHashLength( val );
2297  emit changed();
2298 }
2299 
2300 void QgsHashedLineSymbolLayerWidget::setHashAngle( double val )
2301 {
2302  mLayer->setHashAngle( val );
2303  emit changed();
2304 }
2305 
2306 void QgsHashedLineSymbolLayerWidget::setRotate()
2307 {
2308  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2309  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2310 
2311  mLayer->setRotateSymbols( chkRotateMarker->isChecked() );
2312  emit changed();
2313 }
2314 
2315 void QgsHashedLineSymbolLayerWidget::setOffset()
2316 {
2317  mLayer->setOffset( spinOffset->value() );
2318  emit changed();
2319 }
2320 
2321 void QgsHashedLineSymbolLayerWidget::setPlacement()
2322 {
2323  bool interval = radInterval->isChecked();
2324  spinInterval->setEnabled( interval );
2325  mSpinOffsetAlongLine->setEnabled( radInterval->isChecked() || radVertexLast->isChecked() || radVertexFirst->isChecked() );
2326  mOffsetAlongLineUnitWidget->setEnabled( mSpinOffsetAlongLine->isEnabled() );
2327  mSpinAverageAngleLength->setEnabled( chkRotateMarker->isChecked() && ( radInterval->isChecked() || radCentralPoint->isChecked() ) );
2328  mAverageAngleUnit->setEnabled( mSpinAverageAngleLength->isEnabled() );
2329  //mLayer->setPlacement( interval ? QgsMarkerLineSymbolLayer::Interval : QgsMarkerLineSymbolLayer::Vertex );
2330  if ( radInterval->isChecked() )
2332  else if ( radVertex->isChecked() )
2334  else if ( radVertexLast->isChecked() )
2336  else if ( radVertexFirst->isChecked() )
2338  else if ( radCurvePoint->isChecked() )
2340  else if ( radSegmentCentralPoint->isChecked() )
2342  else
2344 
2345  emit changed();
2346 }
2347 
2348 void QgsHashedLineSymbolLayerWidget::mIntervalUnitWidget_changed()
2349 {
2350  if ( mLayer )
2351  {
2352  mLayer->setIntervalUnit( mIntervalUnitWidget->unit() );
2353  mLayer->setIntervalMapUnitScale( mIntervalUnitWidget->getMapUnitScale() );
2354  emit changed();
2355  }
2356 }
2357 
2358 void QgsHashedLineSymbolLayerWidget::mOffsetUnitWidget_changed()
2359 {
2360  if ( mLayer )
2361  {
2362  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2363  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2364  emit changed();
2365  }
2366 }
2367 
2368 void QgsHashedLineSymbolLayerWidget::mOffsetAlongLineUnitWidget_changed()
2369 {
2370  if ( mLayer )
2371  {
2372  mLayer->setOffsetAlongLineUnit( mOffsetAlongLineUnitWidget->unit() );
2373  mLayer->setOffsetAlongLineMapUnitScale( mOffsetAlongLineUnitWidget->getMapUnitScale() );
2374  }
2375  emit changed();
2376 }
2377 
2378 void QgsHashedLineSymbolLayerWidget::hashLengthUnitWidgetChanged()
2379 {
2380  if ( mLayer )
2381  {
2382  mLayer->setHashLengthUnit( mHashLengthUnitWidget->unit() );
2383  mLayer->setHashLengthMapUnitScale( mHashLengthUnitWidget->getMapUnitScale() );
2384  }
2385  emit changed();
2386 }
2387 
2388 void QgsHashedLineSymbolLayerWidget::averageAngleUnitChanged()
2389 {
2390  if ( mLayer )
2391  {
2392  mLayer->setAverageAngleUnit( mAverageAngleUnit->unit() );
2393  mLayer->setAverageAngleMapUnitScale( mAverageAngleUnit->getMapUnitScale() );
2394  }
2395  emit changed();
2396 }
2397 
2398 void QgsHashedLineSymbolLayerWidget::setAverageAngle( double val )
2399 {
2400  if ( mLayer )
2401  {
2402  mLayer->setAverageAngleLength( val );
2403  emit changed();
2404  }
2405 }
2406 
2408 
2409 
2411  : QgsSymbolLayerWidget( parent, vl )
2412 {
2413  mLayer = nullptr;
2414 
2415  setupUi( this );
2416 
2417  mSvgSelectorWidget->setAllowParameters( true );
2418  mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2419  mSvgSelectorWidget->sourceLineEdit()->setLastPathSettingsKey( QStringLiteral( "/UI/lastSVGMarkerDir" ) );
2420  mSvgSelectorWidget->initParametersModel( this, vl );
2421 
2422  connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSvgMarkerSymbolLayerWidget::svgSourceChanged );
2423  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged );
2424  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2425  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2426  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
2427  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
2428  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
2429  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
2430  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
2437  mChangeColorButton->setAllowOpacity( true );
2438  mChangeColorButton->setColorDialogTitle( tr( "Select Fill color" ) );
2439  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2440  mChangeStrokeColorButton->setAllowOpacity( true );
2441  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2442  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2443 
2444  mFillColorDDBtn->registerLinkedWidget( mChangeColorButton );
2445  mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2446 
2447  spinOffsetX->setClearValue( 0.0 );
2448  spinOffsetY->setClearValue( 0.0 );
2449  spinAngle->setClearValue( 0.0 );
2450 
2451  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setWidth );
2452  connect( spinHeight, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setHeight );
2453  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged );
2454  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setAngle );
2455  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2456  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSvgMarkerSymbolLayerWidget::setOffset );
2457  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol );
2458 
2459  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSvgMarkerSymbolLayerWidget::setSvgPath );
2461 
2462  //make a temporary symbol for the size assistant preview
2463  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
2464 
2465  if ( vectorLayer() )
2466  {
2467  mWidthDDBtn->setSymbol( mAssistantPreviewSymbol );
2468  mHeightDDBtn->setSymbol( mAssistantPreviewSymbol );
2469  }
2470 }
2471 
2473 
2474 #include <QTime>
2475 #include <QAbstractListModel>
2476 #include <QPixmapCache>
2477 #include <QStyle>
2478 
2479 
2480 
2481 
2482 void QgsSvgMarkerSymbolLayerWidget::setGuiForSvg( const QgsSvgMarkerSymbolLayer *layer, bool skipDefaultColors )
2483 {
2484  if ( !layer )
2485  {
2486  return;
2487  }
2488 
2489  //activate gui for svg parameters only if supported by the svg file
2490  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2491  QColor defaultFill, defaultStroke;
2492  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2493  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2494  QgsApplication::svgCache()->containsParams( layer->path(), hasFillParam, hasDefaultFillColor, defaultFill,
2495  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2496  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2497  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2498  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2499  mChangeColorButton->setEnabled( hasFillParam );
2500  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2501  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
2502  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
2503  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
2504 
2505  if ( hasFillParam )
2506  {
2507  QColor fill = layer->fillColor();
2508  double existingOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2509  if ( hasDefaultFillColor && !skipDefaultColors )
2510  {
2511  fill = defaultFill;
2512  }
2513  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : existingOpacity );
2514  mChangeColorButton->setColor( fill );
2515  }
2516  if ( hasStrokeParam )
2517  {
2518  QColor stroke = layer->strokeColor();
2519  double existingOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
2520  if ( hasDefaultStrokeColor && !skipDefaultColors )
2521  {
2522  stroke = defaultStroke;
2523  }
2524  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : existingOpacity );
2525  mChangeStrokeColorButton->setColor( stroke );
2526  }
2527 
2528  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( layer->path() );
2529 
2530  mStrokeWidthSpinBox->blockSignals( true );
2531  mStrokeWidthSpinBox->setValue( hasDefaultStrokeWidth ? defaultStrokeWidth : layer->strokeWidth() );
2532  mStrokeWidthSpinBox->blockSignals( false );
2533 
2534  bool preservedAspectRatio = layer->preservedAspectRatio();
2535  spinHeight->blockSignals( true );
2536  if ( preservedAspectRatio )
2537  {
2538  spinHeight->setValue( layer->size() * layer->defaultAspectRatio() );
2539  }
2540  else
2541  {
2542  spinHeight->setValue( layer->size() * layer->fixedAspectRatio() );
2543  }
2544  spinHeight->setEnabled( layer->defaultAspectRatio() > 0.0 );
2545  spinHeight->blockSignals( false );
2546  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
2547 }
2548 
2549 void QgsSvgMarkerSymbolLayerWidget::updateAssistantSymbol()
2550 {
2551  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
2552  {
2553  mAssistantPreviewSymbol->deleteSymbolLayer( i );
2554  }
2555  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
2557  if ( ddSize )
2558  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
2559 }
2560 
2561 
2563 {
2564  if ( !layer )
2565  {
2566  return;
2567  }
2568 
2569  if ( layer->layerType() != QLatin1String( "SvgMarker" ) )
2570  return;
2571 
2572  // layer type is correct, we can do the cast
2573  mLayer = static_cast<QgsSvgMarkerSymbolLayer *>( layer );
2574 
2575  // set values
2576  mSvgSelectorWidget->setSvgPath( mLayer->path() );
2577  mSvgSelectorWidget->setSvgParameters( mLayer->parameters() );
2578 
2579  spinWidth->blockSignals( true );
2580  spinWidth->setValue( mLayer->size() );
2581  spinWidth->blockSignals( false );
2582  spinAngle->blockSignals( true );
2583  spinAngle->setValue( mLayer->angle() );
2584  spinAngle->blockSignals( false );
2585 
2586  // without blocking signals the value gets changed because of slot setOffset()
2587  spinOffsetX->blockSignals( true );
2588  spinOffsetX->setValue( mLayer->offset().x() );
2589  spinOffsetX->blockSignals( false );
2590  spinOffsetY->blockSignals( true );
2591  spinOffsetY->setValue( mLayer->offset().y() );
2592  spinOffsetY->blockSignals( false );
2593 
2594  mSizeUnitWidget->blockSignals( true );
2595  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
2596  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
2597  mSizeUnitWidget->blockSignals( false );
2598  mStrokeWidthUnitWidget->blockSignals( true );
2599  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
2600  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
2601  mStrokeWidthUnitWidget->blockSignals( false );
2602  mOffsetUnitWidget->blockSignals( true );
2603  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
2604  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
2605  mOffsetUnitWidget->blockSignals( false );
2606 
2607  //anchor points
2608  mHorizontalAnchorComboBox->blockSignals( true );
2609  mVerticalAnchorComboBox->blockSignals( true );
2610  mHorizontalAnchorComboBox->setCurrentIndex( mLayer->horizontalAnchorPoint() );
2611  mVerticalAnchorComboBox->setCurrentIndex( mLayer->verticalAnchorPoint() );
2612  mHorizontalAnchorComboBox->blockSignals( false );
2613  mVerticalAnchorComboBox->blockSignals( false );
2614 
2615  setGuiForSvg( mLayer, true );
2616 
2626 
2627  registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::PropertyName );
2628 
2629  updateAssistantSymbol();
2630 }
2631 
2633 {
2634  return mLayer;
2635 }
2636 
2638 {
2640  mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2641 }
2642 
2644 {
2645  mLayer->setPath( name );
2646  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2647 
2648  setGuiForSvg( mLayer );
2649  emit changed();
2650 }
2651 
2652 void QgsSvgMarkerSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2653 {
2654  mLayer->setParameters( parameters );
2655  whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2656 
2657  setGuiForSvg( mLayer );
2658  emit changed();
2659 }
2660 
2661 void QgsSvgMarkerSymbolLayerWidget::setWidth()
2662 {
2663  double defaultAspectRatio = mLayer->defaultAspectRatio();
2664  double fixedAspectRatio = 0.0;
2665  spinHeight->blockSignals( true );
2666  if ( defaultAspectRatio <= 0.0 )
2667  {
2668  spinHeight->setValue( spinWidth->value() );
2669  }
2670  else if ( mLockAspectRatio->locked() )
2671  {
2672  spinHeight->setValue( spinWidth->value() * defaultAspectRatio );
2673  }
2674  else
2675  {
2676  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2677  }
2678  spinHeight->blockSignals( false );
2679  mLayer->setSize( spinWidth->value() );
2680  mLayer->setFixedAspectRatio( fixedAspectRatio );
2681  emit changed();
2682 }
2683 
2684 void QgsSvgMarkerSymbolLayerWidget::setHeight()
2685 {
2686  double defaultAspectRatio = mLayer->defaultAspectRatio();
2687  double fixedAspectRatio = 0.0;
2688  spinWidth->blockSignals( true );
2689  if ( defaultAspectRatio <= 0.0 )
2690  {
2691  spinWidth->setValue( spinHeight->value() );
2692  }
2693  else if ( mLockAspectRatio->locked() )
2694  {
2695  spinWidth->setValue( spinHeight->value() / defaultAspectRatio );
2696  }
2697  else
2698  {
2699  fixedAspectRatio = spinHeight->value() / spinWidth->value();
2700  }
2701  spinWidth->blockSignals( false );
2702  mLayer->setSize( spinWidth->value() );
2703  mLayer->setFixedAspectRatio( fixedAspectRatio );
2704  emit changed();
2705 }
2706 
2707 void QgsSvgMarkerSymbolLayerWidget::lockAspectRatioChanged( const bool locked )
2708 {
2709  //spinHeight->setEnabled( !locked );
2710  double defaultAspectRatio = mLayer->defaultAspectRatio();
2711  if ( defaultAspectRatio <= 0.0 )
2712  {
2713  whileBlocking( mLockAspectRatio )->setLocked( true );
2714  }
2715  else if ( locked )
2716  {
2717  mLayer->setFixedAspectRatio( 0.0 );
2718  setWidth();
2719  }
2720  else
2721  {
2722  mLayer->setFixedAspectRatio( spinHeight->value() / spinWidth->value() );
2723  }
2724  //emit changed();
2725 }
2726 
2727 void QgsSvgMarkerSymbolLayerWidget::setAngle()
2728 {
2729  mLayer->setAngle( spinAngle->value() );
2730  emit changed();
2731 }
2732 
2733 void QgsSvgMarkerSymbolLayerWidget::setOffset()
2734 {
2735  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
2736  emit changed();
2737 }
2738 
2739 void QgsSvgMarkerSymbolLayerWidget::svgSourceChanged( const QString &text )
2740 {
2741  mLayer->setPath( text );
2742  setGuiForSvg( mLayer );
2743  emit changed();
2744 }
2745 
2746 void QgsSvgMarkerSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
2747 {
2748  if ( !mLayer )
2749  {
2750  return;
2751  }
2752 
2753  mLayer->setFillColor( color );
2754  emit changed();
2755 }
2756 
2757 void QgsSvgMarkerSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
2758 {
2759  if ( !mLayer )
2760  {
2761  return;
2762  }
2763 
2764  mLayer->setStrokeColor( color );
2765  emit changed();
2766 }
2767 
2768 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
2769 {
2770  if ( mLayer )
2771  {
2772  mLayer->setStrokeWidth( d );
2773  emit changed();
2774  }
2775 }
2776 
2777 void QgsSvgMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
2778 {
2779  if ( mLayer )
2780  {
2781  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
2782  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
2783  emit changed();
2784  }
2785 }
2786 
2787 void QgsSvgMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
2788 {
2789  if ( mLayer )
2790  {
2791  mLayer->setStrokeWidthUnit( mStrokeWidthUnitWidget->unit() );
2792  mLayer->setStrokeWidthMapUnitScale( mStrokeWidthUnitWidget->getMapUnitScale() );
2793  emit changed();
2794  }
2795 }
2796 
2797 void QgsSvgMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
2798 {
2799  if ( mLayer )
2800  {
2801  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
2802  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
2803  emit changed();
2804  }
2805 }
2806 
2807 void QgsSvgMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
2808 {
2809  if ( mLayer )
2810  {
2812  emit changed();
2813  }
2814 }
2815 
2816 void QgsSvgMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
2817 {
2818  if ( mLayer )
2819  {
2821  emit changed();
2822  }
2823 }
2824 
2826 
2828 {
2829  mLayer = nullptr;
2830  setupUi( this );
2831 
2832  mSvgSelectorWidget->setAllowParameters( true );
2833  mSvgSelectorWidget->sourceLineEdit()->setPropertyOverrideToolButtonVisible( true );
2834 
2835  connect( mTextureWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged );
2836  connect( mSvgSelectorWidget->sourceLineEdit(), &QgsSvgSourceLineEdit::sourceChanged, this, &QgsSVGFillSymbolLayerWidget::svgSourceChanged );
2837  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
2838  connect( mChangeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged );
2839  connect( mChangeStrokeColorButton, &QgsColorButton::colorChanged, this, &QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged );
2840  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
2841  connect( mTextureWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed );
2842  connect( mSvgStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed );
2847 
2848  mRotationSpinBox->setClearValue( 0.0 );
2849 
2850  mChangeColorButton->setColorDialogTitle( tr( "Select Fill Color" ) );
2851  mChangeColorButton->setContext( QStringLiteral( "symbology" ) );
2852  mChangeStrokeColorButton->setColorDialogTitle( tr( "Select Stroke Color" ) );
2853  mChangeStrokeColorButton->setContext( QStringLiteral( "symbology" ) );
2854 
2855  mFilColorDDBtn->registerLinkedWidget( mChangeColorButton );
2856  mStrokeColorDDBtn->registerLinkedWidget( mChangeStrokeColorButton );
2857 
2858  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgSelected, this, &QgsSVGFillSymbolLayerWidget::setFile );
2859  connect( mSvgSelectorWidget, &QgsSvgSelectorWidget::svgParametersChanged, this, &QgsSVGFillSymbolLayerWidget::setSvgParameters );
2860 }
2861 
2863 {
2864  if ( !layer )
2865  {
2866  return;
2867  }
2868 
2869  if ( layer->layerType() != QLatin1String( "SVGFill" ) )
2870  {
2871  return;
2872  }
2873 
2874  mLayer = dynamic_cast<QgsSVGFillSymbolLayer *>( layer );
2875  if ( mLayer )
2876  {
2877  double width = mLayer->patternWidth();
2878  mTextureWidthSpinBox->blockSignals( true );
2879  mTextureWidthSpinBox->setValue( width );
2880  mTextureWidthSpinBox->blockSignals( false );
2881  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( mLayer->svgFilePath() );
2882  mRotationSpinBox->blockSignals( true );
2883  mRotationSpinBox->setValue( mLayer->angle() );
2884  mRotationSpinBox->blockSignals( false );
2885  mTextureWidthUnitWidget->blockSignals( true );
2886  mTextureWidthUnitWidget->setUnit( mLayer->patternWidthUnit() );
2887  mTextureWidthUnitWidget->setMapUnitScale( mLayer->patternWidthMapUnitScale() );
2888  mTextureWidthUnitWidget->blockSignals( false );
2889  mSvgStrokeWidthUnitWidget->blockSignals( true );
2890  mSvgStrokeWidthUnitWidget->setUnit( mLayer->svgStrokeWidthUnit() );
2891  mSvgStrokeWidthUnitWidget->setMapUnitScale( mLayer->svgStrokeWidthMapUnitScale() );
2892  mSvgStrokeWidthUnitWidget->blockSignals( false );
2893  mChangeColorButton->blockSignals( true );
2894  mChangeColorButton->setColor( mLayer->svgFillColor() );
2895  mChangeColorButton->blockSignals( false );
2896  mChangeStrokeColorButton->blockSignals( true );
2897  mChangeStrokeColorButton->setColor( mLayer->svgStrokeColor() );
2898  mChangeStrokeColorButton->blockSignals( false );
2899  mStrokeWidthSpinBox->blockSignals( true );
2900  mStrokeWidthSpinBox->setValue( mLayer->svgStrokeWidth() );
2901  mStrokeWidthSpinBox->blockSignals( false );
2902  }
2903  updateParamGui( false );
2904 
2910 
2911  registerDataDefinedButton( mSvgSelectorWidget->sourceLineEdit()->propertyOverrideToolButton(), QgsSymbolLayer::PropertyFile );
2912 }
2913 
2915 {
2916  return mLayer;
2917 }
2918 
2920 {
2922  mSvgSelectorWidget->sourceLineEdit()->setMessageBar( context.messageBar() );
2923 }
2924 
2925 void QgsSVGFillSymbolLayerWidget::mTextureWidthSpinBox_valueChanged( double d )
2926 {
2927  if ( mLayer )
2928  {
2929  mLayer->setPatternWidth( d );
2930  emit changed();
2931  }
2932 }
2933 
2934 void QgsSVGFillSymbolLayerWidget::svgSourceChanged( const QString &text )
2935 {
2936  if ( !mLayer )
2937  {
2938  return;
2939  }
2940 
2941  mLayer->setSvgFilePath( text );
2942  updateParamGui();
2943  emit changed();
2944 }
2945 
2946 void QgsSVGFillSymbolLayerWidget::setFile( const QString &name )
2947 {
2948  mLayer->setSvgFilePath( name );
2949  whileBlocking( mSvgSelectorWidget->sourceLineEdit() )->setSource( name );
2950 
2951  updateParamGui();
2952  emit changed();
2953 }
2954 
2955 void QgsSVGFillSymbolLayerWidget::setSvgParameters( const QMap<QString, QgsProperty> &parameters )
2956 {
2957  mLayer->setParameters( parameters );
2958  whileBlocking( mSvgSelectorWidget )->setSvgParameters( parameters );
2959 
2960  updateParamGui();
2961  emit changed();
2962 }
2963 
2964 
2965 void QgsSVGFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
2966 {
2967  if ( mLayer )
2968  {
2969  mLayer->setAngle( d );
2970  emit changed();
2971  }
2972 }
2973 
2975 {
2976  //activate gui for svg parameters only if supported by the svg file
2977  bool hasFillParam, hasFillOpacityParam, hasStrokeParam, hasStrokeWidthParam, hasStrokeOpacityParam;
2978  QColor defaultFill, defaultStroke;
2979  double defaultStrokeWidth, defaultFillOpacity, defaultStrokeOpacity;
2980  bool hasDefaultFillColor, hasDefaultFillOpacity, hasDefaultStrokeColor, hasDefaultStrokeWidth, hasDefaultStrokeOpacity;
2981  QgsApplication::svgCache()->containsParams( mSvgSelectorWidget->sourceLineEdit()->source(), hasFillParam, hasDefaultFillColor, defaultFill,
2982  hasFillOpacityParam, hasDefaultFillOpacity, defaultFillOpacity,
2983  hasStrokeParam, hasDefaultStrokeColor, defaultStroke,
2984  hasStrokeWidthParam, hasDefaultStrokeWidth, defaultStrokeWidth,
2985  hasStrokeOpacityParam, hasDefaultStrokeOpacity, defaultStrokeOpacity );
2986  if ( resetValues )
2987  {
2988  QColor fill = mChangeColorButton->color();
2989  double newOpacity = hasFillOpacityParam ? fill.alphaF() : 1.0;
2990  if ( hasDefaultFillColor )
2991  {
2992  fill = defaultFill;
2993  }
2994  fill.setAlphaF( hasDefaultFillOpacity ? defaultFillOpacity : newOpacity );
2995  mChangeColorButton->setColor( fill );
2996  }
2997  mChangeColorButton->setEnabled( hasFillParam );
2998  mChangeColorButton->setAllowOpacity( hasFillOpacityParam );
2999  if ( resetValues )
3000  {
3001  QColor stroke = mChangeStrokeColorButton->color();
3002  double newOpacity = hasStrokeOpacityParam ? stroke.alphaF() : 1.0;
3003  if ( hasDefaultStrokeColor )
3004  {
3005  stroke = defaultStroke;
3006  }
3007  stroke.setAlphaF( hasDefaultStrokeOpacity ? defaultStrokeOpacity : newOpacity );
3008  mChangeStrokeColorButton->setColor( stroke );
3009  }
3010  mChangeStrokeColorButton->setEnabled( hasStrokeParam );
3011  mChangeStrokeColorButton->setAllowOpacity( hasStrokeOpacityParam );
3012  if ( hasDefaultStrokeWidth && resetValues )
3013  {
3014  mStrokeWidthSpinBox->setValue( defaultStrokeWidth );
3015  }
3016  mStrokeWidthSpinBox->setEnabled( hasStrokeWidthParam );
3017 }
3018 
3019 void QgsSVGFillSymbolLayerWidget::mChangeColorButton_colorChanged( const QColor &color )
3020 {
3021  if ( !mLayer )
3022  {
3023  return;
3024  }
3025 
3026  mLayer->setSvgFillColor( color );
3027  emit changed();
3028 }
3029 
3030 void QgsSVGFillSymbolLayerWidget::mChangeStrokeColorButton_colorChanged( const QColor &color )
3031 {
3032  if ( !mLayer )
3033  {
3034  return;
3035  }
3036 
3037  mLayer->setSvgStrokeColor( color );
3038  emit changed();
3039 }
3040 
3041 void QgsSVGFillSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3042 {
3043  if ( mLayer )
3044  {
3045  mLayer->setSvgStrokeWidth( d );
3046  emit changed();
3047  }
3048 }
3049 
3050 void QgsSVGFillSymbolLayerWidget::mTextureWidthUnitWidget_changed()
3051 {
3052  if ( mLayer )
3053  {
3054  mLayer->setPatternWidthUnit( mTextureWidthUnitWidget->unit() );
3055  mLayer->setPatternWidthMapUnitScale( mTextureWidthUnitWidget->getMapUnitScale() );
3056  emit changed();
3057  }
3058 }
3059 
3060 void QgsSVGFillSymbolLayerWidget::mSvgStrokeWidthUnitWidget_changed()
3061 {
3062  if ( mLayer )
3063  {
3064  mLayer->setSvgStrokeWidthUnit( mSvgStrokeWidthUnitWidget->unit() );
3065  mLayer->setSvgStrokeWidthMapUnitScale( mSvgStrokeWidthUnitWidget->getMapUnitScale() );
3066  emit changed();
3067  }
3068 }
3069 
3071 
3073  QgsSymbolLayerWidget( parent, vl )
3074 {
3075  setupUi( this );
3076  connect( mAngleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged );
3077  connect( mDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged );
3078  connect( mOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged );
3079  connect( mDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed );
3080  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed );
3085  mOffsetSpinBox->setClearValue( 0 );
3086  mAngleSpinBox->setClearValue( 0 );
3087 }
3088 
3090 {
3091  if ( layer->layerType() != QLatin1String( "LinePatternFill" ) )
3092  {
3093  return;
3094  }
3095 
3096  QgsLinePatternFillSymbolLayer *patternLayer = static_cast<QgsLinePatternFillSymbolLayer *>( layer );
3097  if ( patternLayer )
3098  {
3099  mLayer = patternLayer;
3100  mAngleSpinBox->blockSignals( true );
3101  mAngleSpinBox->setValue( mLayer->lineAngle() );
3102  mAngleSpinBox->blockSignals( false );
3103  mDistanceSpinBox->blockSignals( true );
3104  mDistanceSpinBox->setValue( mLayer->distance() );
3105  mDistanceSpinBox->blockSignals( false );
3106  mOffsetSpinBox->blockSignals( true );
3107  mOffsetSpinBox->setValue( mLayer->offset() );
3108  mOffsetSpinBox->blockSignals( false );
3109 
3110  //units
3111  mDistanceUnitWidget->blockSignals( true );
3112  mDistanceUnitWidget->setUnit( mLayer->distanceUnit() );
3113  mDistanceUnitWidget->setMapUnitScale( mLayer->distanceMapUnitScale() );
3114  mDistanceUnitWidget->blockSignals( false );
3115  mOffsetUnitWidget->blockSignals( true );
3116  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3117  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3118  mOffsetUnitWidget->blockSignals( false );
3119  }
3120 
3123 }
3124 
3126 {
3127  return mLayer;
3128 }
3129 
3130 void QgsLinePatternFillSymbolLayerWidget::mAngleSpinBox_valueChanged( double d )
3131 {
3132  if ( mLayer )
3133  {
3134  mLayer->setLineAngle( d );
3135  emit changed();
3136  }
3137 }
3138 
3139 void QgsLinePatternFillSymbolLayerWidget::mDistanceSpinBox_valueChanged( double d )
3140 {
3141  if ( mLayer )
3142  {
3143  mLayer->setDistance( d );
3144  emit changed();
3145  }
3146 }
3147 
3148 void QgsLinePatternFillSymbolLayerWidget::mOffsetSpinBox_valueChanged( double d )
3149 {
3150  if ( mLayer )
3151  {
3152  mLayer->setOffset( d );
3153  emit changed();
3154  }
3155 }
3156 
3157 void QgsLinePatternFillSymbolLayerWidget::mDistanceUnitWidget_changed()
3158 {
3159  if ( mLayer )
3160  {
3161  mLayer->setDistanceUnit( mDistanceUnitWidget->unit() );
3162  mLayer->setDistanceMapUnitScale( mDistanceUnitWidget->getMapUnitScale() );
3163  emit changed();
3164  }
3165 }
3166 
3167 void QgsLinePatternFillSymbolLayerWidget::mOffsetUnitWidget_changed()
3168 {
3169  if ( mLayer )
3170  {
3171  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3172  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3173  emit changed();
3174  }
3175 }
3176 
3178 
3180  QgsSymbolLayerWidget( parent, vl )
3181 {
3182  setupUi( this );
3183  connect( mHorizontalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged );
3184  connect( mVerticalDistanceSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged );
3185  connect( mHorizontalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged );
3186  connect( mVerticalDisplacementSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged );
3187  connect( mHorizontalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged );
3188  connect( mVerticalOffsetSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged );
3189  connect( mHorizontalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed );
3190  connect( mVerticalDistanceUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed );
3191  connect( mHorizontalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed );
3192  connect( mVerticalDisplacementUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed );
3193  connect( mHorizontalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed );
3194  connect( mVerticalOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed );
3207 }
3208 
3209 
3211 {
3212  if ( !layer || layer->layerType() != QLatin1String( "PointPatternFill" ) )
3213  {
3214  return;
3215  }
3216 
3217  mLayer = static_cast<QgsPointPatternFillSymbolLayer *>( layer );
3218  whileBlocking( mHorizontalDistanceSpinBox )->setValue( mLayer->distanceX() );
3219  whileBlocking( mVerticalDistanceSpinBox )->setValue( mLayer->distanceY() );
3220  whileBlocking( mHorizontalDisplacementSpinBox )->setValue( mLayer->displacementX() );
3221  whileBlocking( mVerticalDisplacementSpinBox )->setValue( mLayer->displacementY() );
3222  whileBlocking( mHorizontalOffsetSpinBox )->setValue( mLayer->offsetX() );
3223  whileBlocking( mVerticalOffsetSpinBox )->setValue( mLayer->offsetY() );
3224 
3225  mHorizontalDistanceUnitWidget->blockSignals( true );
3226  mHorizontalDistanceUnitWidget->setUnit( mLayer->distanceXUnit() );
3227  mHorizontalDistanceUnitWidget->setMapUnitScale( mLayer->distanceXMapUnitScale() );
3228  mHorizontalDistanceUnitWidget->blockSignals( false );
3229  mVerticalDistanceUnitWidget->blockSignals( true );
3230  mVerticalDistanceUnitWidget->setUnit( mLayer->distanceYUnit() );
3231  mVerticalDistanceUnitWidget->setMapUnitScale( mLayer->distanceYMapUnitScale() );
3232  mVerticalDistanceUnitWidget->blockSignals( false );
3233  mHorizontalDisplacementUnitWidget->blockSignals( true );
3234  mHorizontalDisplacementUnitWidget->setUnit( mLayer->displacementXUnit() );
3235  mHorizontalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementXMapUnitScale() );
3236  mHorizontalDisplacementUnitWidget->blockSignals( false );
3237  mVerticalDisplacementUnitWidget->blockSignals( true );
3238  mVerticalDisplacementUnitWidget->setUnit( mLayer->displacementYUnit() );
3239  mVerticalDisplacementUnitWidget->setMapUnitScale( mLayer->displacementYMapUnitScale() );
3240  mVerticalDisplacementUnitWidget->blockSignals( false );
3241  mHorizontalOffsetUnitWidget->blockSignals( true );
3242  mHorizontalOffsetUnitWidget->setUnit( mLayer->offsetXUnit() );
3243  mHorizontalOffsetUnitWidget->setMapUnitScale( mLayer->offsetXMapUnitScale() );
3244  mHorizontalOffsetUnitWidget->blockSignals( false );
3245  mVerticalOffsetUnitWidget->blockSignals( true );
3246  mVerticalOffsetUnitWidget->setUnit( mLayer->offsetYUnit() );
3247  mVerticalOffsetUnitWidget->setMapUnitScale( mLayer->offsetYMapUnitScale() );
3248  mVerticalOffsetUnitWidget->blockSignals( false );
3249 
3250  registerDataDefinedButton( mHorizontalDistanceDDBtn, QgsSymbolLayer::PropertyDistanceX );
3252  registerDataDefinedButton( mHorizontalDisplacementDDBtn, QgsSymbolLayer::PropertyDisplacementX );
3256 }
3257 
3259 {
3260  return mLayer;
3261 }
3262 
3263 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceSpinBox_valueChanged( double d )
3264 {
3265  if ( mLayer )
3266  {
3267  mLayer->setDistanceX( d );
3268  emit changed();
3269  }
3270 }
3271 
3272 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceSpinBox_valueChanged( double d )
3273 {
3274  if ( mLayer )
3275  {
3276  mLayer->setDistanceY( d );
3277  emit changed();
3278  }
3279 }
3280 
3281 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementSpinBox_valueChanged( double d )
3282 {
3283  if ( mLayer )
3284  {
3285  mLayer->setDisplacementX( d );
3286  emit changed();
3287  }
3288 }
3289 
3290 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementSpinBox_valueChanged( double d )
3291 {
3292  if ( mLayer )
3293  {
3294  mLayer->setDisplacementY( d );
3295  emit changed();
3296  }
3297 }
3298 
3299 void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetSpinBox_valueChanged( double d )
3300 {
3301  if ( mLayer )
3302  {
3303  mLayer->setOffsetX( d );
3304  emit changed();
3305  }
3306 }
3307 
3308 void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetSpinBox_valueChanged( double d )
3309 {
3310  if ( mLayer )
3311  {
3312  mLayer->setOffsetY( d );
3313  emit changed();
3314  }
3315 }
3316 
3317 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDistanceUnitWidget_changed()
3318 {
3319  if ( mLayer )
3320  {
3321  mLayer->setDistanceXUnit( mHorizontalDistanceUnitWidget->unit() );
3322  mLayer->setDistanceXMapUnitScale( mHorizontalDistanceUnitWidget->getMapUnitScale() );
3323  emit changed();
3324  }
3325 }
3326 
3327 void QgsPointPatternFillSymbolLayerWidget::mVerticalDistanceUnitWidget_changed()
3328 {
3329  if ( mLayer )
3330  {
3331  mLayer->setDistanceYUnit( mVerticalDistanceUnitWidget->unit() );
3332  mLayer->setDistanceYMapUnitScale( mVerticalDistanceUnitWidget->getMapUnitScale() );
3333  emit changed();
3334  }
3335 }
3336 
3337 void QgsPointPatternFillSymbolLayerWidget::mHorizontalDisplacementUnitWidget_changed()
3338 {
3339  if ( mLayer )
3340  {
3341  mLayer->setDisplacementXUnit( mHorizontalDisplacementUnitWidget->unit() );
3342  mLayer->setDisplacementXMapUnitScale( mHorizontalDisplacementUnitWidget->getMapUnitScale() );
3343  emit changed();
3344  }
3345 }
3346 
3347 void QgsPointPatternFillSymbolLayerWidget::mVerticalDisplacementUnitWidget_changed()
3348 {
3349  if ( mLayer )
3350  {
3351  mLayer->setDisplacementYUnit( mVerticalDisplacementUnitWidget->unit() );
3352  mLayer->setDisplacementYMapUnitScale( mVerticalDisplacementUnitWidget->getMapUnitScale() );
3353  emit changed();
3354  }
3355 }
3356 
3357 void QgsPointPatternFillSymbolLayerWidget::mHorizontalOffsetUnitWidget_changed()
3358 {
3359  if ( mLayer )
3360  {
3361  mLayer->setOffsetXUnit( mHorizontalOffsetUnitWidget->unit() );
3362  mLayer->setOffsetXMapUnitScale( mHorizontalOffsetUnitWidget->getMapUnitScale() );
3363  emit changed();
3364  }
3365 }
3366 
3367 void QgsPointPatternFillSymbolLayerWidget::mVerticalOffsetUnitWidget_changed()
3368 {
3369  if ( mLayer )
3370  {
3371  mLayer->setOffsetYUnit( mVerticalOffsetUnitWidget->unit() );
3372  mLayer->setOffsetYMapUnitScale( mVerticalOffsetUnitWidget->getMapUnitScale() );
3373  emit changed();
3374  }
3375 }
3376 
3378 
3380  : QgsSymbolLayerWidget( parent, vl )
3381 {
3382  mLayer = nullptr;
3383 
3384  setupUi( this );
3385  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3386  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3387  connect( mStrokeWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed );
3388  connect( mStrokeWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged );
3389  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3390  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3397 
3398  widgetChar = new CharacterWidget();
3399  scrollArea->setWidget( widgetChar );
3400  scrollArea->setVerticalOnly( true );
3401 
3402  btnColor->setAllowOpacity( true );
3403  btnColor->setColorDialogTitle( tr( "Select Symbol Fill Color" ) );
3404  btnColor->setContext( QStringLiteral( "symbology" ) );
3405  btnStrokeColor->setAllowOpacity( true );
3406  btnStrokeColor->setColorDialogTitle( tr( "Select Symbol Stroke Color" ) );
3407  btnStrokeColor->setContext( QStringLiteral( "symbology" ) );
3408 
3409  mColorDDBtn->registerLinkedWidget( btnColor );
3410  mStrokeColorDDBtn->registerLinkedWidget( btnStrokeColor );
3411 
3412  spinOffsetX->setClearValue( 0.0 );
3413  spinOffsetY->setClearValue( 0.0 );
3414  spinAngle->setClearValue( 0.0 );
3415 
3416  //make a temporary symbol for the size assistant preview
3417  mAssistantPreviewSymbol.reset( new QgsMarkerSymbol() );
3418 
3419  if ( vectorLayer() )
3420  mSizeDDBtn->setSymbol( mAssistantPreviewSymbol );
3421 
3422  connect( cboFont, &QFontComboBox::currentFontChanged, this, &QgsFontMarkerSymbolLayerWidget::setFontFamily );
3423  connect( mFontStyleComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged );
3424  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setSize );
3425  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3428  connect( cboJoinStyle, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged );
3429  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setAngle );
3430  connect( spinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3431  connect( spinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsFontMarkerSymbolLayerWidget::setOffset );
3433  connect( mCharLineEdit, &QLineEdit::textChanged, this, &QgsFontMarkerSymbolLayerWidget::setCharacterFromText );
3434 
3435  connect( this, &QgsSymbolLayerWidget::changed, this, &QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol );
3436 }
3437 
3439 
3441 {
3442  if ( layer->layerType() != QLatin1String( "FontMarker" ) )
3443  return;
3444 
3445  // layer type is correct, we can do the cast
3446  mLayer = static_cast<QgsFontMarkerSymbolLayer *>( layer );
3447 
3448  mRefFont.setFamily( mLayer->fontFamily() );
3449  mRefFont.setStyleName( QgsFontUtils::translateNamedStyle( mLayer->fontStyle() ) );
3450 
3451  mFontStyleComboBox->blockSignals( true );
3452  populateFontStyleComboBox();
3453  mFontStyleComboBox->blockSignals( false );
3454 
3455  // set values
3456  whileBlocking( cboFont )->setCurrentFont( mRefFont );
3457  whileBlocking( spinSize )->setValue( mLayer->size() );
3458  whileBlocking( btnColor )->setColor( mLayer->color() );
3459  whileBlocking( btnStrokeColor )->setColor( mLayer->strokeColor() );
3460  whileBlocking( mStrokeWidthSpinBox )->setValue( mLayer->strokeWidth() );
3461  whileBlocking( spinAngle )->setValue( mLayer->angle() );
3462 
3463  widgetChar->blockSignals( true );
3464  widgetChar->setFont( mRefFont );
3465  if ( mLayer->character().length() == 1 )
3466  {
3467  widgetChar->setCharacter( mLayer->character().at( 0 ) );
3468  }
3469  widgetChar->blockSignals( false );
3470  whileBlocking( mCharLineEdit )->setText( mLayer->character() );
3471  mCharPreview->setFont( mRefFont );
3472 
3473  //block
3474  whileBlocking( spinOffsetX )->setValue( mLayer->offset().x() );
3475  whileBlocking( spinOffsetY )->setValue( mLayer->offset().y() );
3476 
3477  mSizeUnitWidget->blockSignals( true );
3478  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3479  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3480  mSizeUnitWidget->blockSignals( false );
3481 
3482  mStrokeWidthUnitWidget->blockSignals( true );
3483  mStrokeWidthUnitWidget->setUnit( mLayer->strokeWidthUnit() );
3484  mStrokeWidthUnitWidget->setMapUnitScale( mLayer->strokeWidthMapUnitScale() );
3485  mStrokeWidthUnitWidget->blockSignals( false );
3486 
3487  mOffsetUnitWidget->blockSignals( true );
3488  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3489  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3490  mOffsetUnitWidget->blockSignals( false );
3491 
3492  whileBlocking( cboJoinStyle )->setPenJoinStyle( mLayer->penJoinStyle() );
3493 
3494  //anchor points
3495  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
3496  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
3497 
3510 
3511  updateAssistantSymbol();
3512 }
3513 
3515 {
3516  return mLayer;
3517 }
3518 
3520 {
3521  if ( mLayer )
3522  {
3523  mLayer->setFontFamily( font.family() );
3524  mRefFont.setFamily( font.family() );
3525  widgetChar->setFont( mRefFont );
3526  mCharPreview->setFont( mRefFont );
3527  populateFontStyleComboBox();
3528  emit changed();
3529  }
3530 }
3531 
3532 void QgsFontMarkerSymbolLayerWidget::setFontStyle( const QString &style )
3533 {
3534  if ( mLayer )
3535  {
3536  QgsFontUtils::updateFontViaStyle( mRefFont, style );
3538  widgetChar->setFont( mRefFont );
3539  mCharPreview->setFont( mRefFont );
3540  emit changed();
3541  }
3542 }
3543 
3544 void QgsFontMarkerSymbolLayerWidget::setColor( const QColor &color )
3545 {
3546  mLayer->setColor( color );
3547  emit changed();
3548 }
3549 
3551 {
3552  mLayer->setStrokeColor( color );
3553  emit changed();
3554 }
3555 
3557 {
3558  mLayer->setSize( size );
3559  //widgetChar->updateSize(size);
3560  emit changed();
3561 }
3562 
3564 {
3565  mLayer->setAngle( angle );
3566  emit changed();
3567 }
3568 
3570 {
3571  mCharPreview->setText( text );
3572 
3573  if ( text.isEmpty() )
3574  return;
3575 
3576  // take the last character of a string for a better experience when users cycle through several characters on their keyboard
3577  QString character = text;
3578  if ( text.contains( QRegularExpression( QStringLiteral( "^0x[0-9a-fA-F]{1,4}$" ) ) ) )
3579  {
3580  bool ok = false;
3581  unsigned int value = text.toUInt( &ok, 0 );
3582  if ( ok )
3583  {
3584  character = QChar( value );
3585  mCharPreview->setText( character );
3586  }
3587  }
3588 
3589  if ( character != mLayer->character() )
3590  {
3591  mLayer->setCharacter( character );
3592  if ( mLayer->character().length() == 1 )
3593  {
3594  whileBlocking( widgetChar )->setCharacter( mLayer->character().at( 0 ) );
3595  }
3596  else
3597  {
3599  }
3600  emit changed();
3601  }
3602 }
3603 
3605 {
3606  if ( mLayer->character().length() > 1 || QGuiApplication::keyboardModifiers() & Qt::ControlModifier )
3607  {
3608  mCharLineEdit->insert( chr );
3609  return;
3610  }
3611 
3612  mLayer->setCharacter( chr );
3613  whileBlocking( mCharLineEdit )->setText( chr );
3614  mCharPreview->setText( chr );
3615  emit changed();
3616 }
3617 
3618 void QgsFontMarkerSymbolLayerWidget::setOffset()
3619 {
3620  mLayer->setOffset( QPointF( spinOffsetX->value(), spinOffsetY->value() ) );
3621  emit changed();
3622 }
3623 
3624 void QgsFontMarkerSymbolLayerWidget::penJoinStyleChanged()
3625 {
3626  mLayer->setPenJoinStyle( cboJoinStyle->penJoinStyle() );
3627  emit changed();
3628 }
3629 
3630 void QgsFontMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
3631 {
3632  if ( mLayer )
3633  {
3634  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
3635  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3636  emit changed();
3637  }
3638 }
3639 
3640 void QgsFontMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
3641 {
3642  if ( mLayer )
3643  {
3644  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
3645  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
3646  emit changed();
3647  }
3648 }
3649 
3650 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthUnitWidget_changed()
3651 {
3652  if ( mLayer )
3653  {
3654  mLayer->setStrokeWidthUnit( mSizeUnitWidget->unit() );
3655  mLayer->setStrokeWidthMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
3656  emit changed();
3657  }
3658 }
3659 
3660 void QgsFontMarkerSymbolLayerWidget::populateFontStyleComboBox()
3661 {
3662  mFontStyleComboBox->clear();
3663  QStringList styles = mFontDB.styles( mRefFont.family() );
3664  const auto constStyles = styles;
3665  for ( const QString &style : constStyles )
3666  {
3667  mFontStyleComboBox->addItem( style );
3668  }
3669 
3670  QString targetStyle = mFontDB.styleString( mRefFont );
3671  if ( !styles.contains( targetStyle ) )
3672  {
3673  QFont f = QFont( mRefFont.family() );
3674  targetStyle = QFontInfo( f ).styleName();
3675  mRefFont.setStyleName( targetStyle );
3676  }
3677  int curIndx = 0;
3678  int stylIndx = mFontStyleComboBox->findText( targetStyle );
3679  if ( stylIndx > -1 )
3680  {
3681  curIndx = stylIndx;
3682  }
3683 
3684  mFontStyleComboBox->setCurrentIndex( curIndx );
3685 }
3686 
3687 void QgsFontMarkerSymbolLayerWidget::mFontStyleComboBox_currentIndexChanged( int index )
3688 {
3689  Q_UNUSED( index );
3690  setFontStyle( mFontStyleComboBox->currentText() );
3691 }
3692 
3693 void QgsFontMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
3694 {
3695  if ( mLayer )
3696  {
3698  emit changed();
3699  }
3700 }
3701 
3702 void QgsFontMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
3703 {
3704  if ( mLayer )
3705  {
3707  emit changed();
3708  }
3709 }
3710 
3711 void QgsFontMarkerSymbolLayerWidget::mStrokeWidthSpinBox_valueChanged( double d )
3712 {
3713  if ( mLayer )
3714  {
3715  mLayer->setStrokeWidth( d );
3716  emit changed();
3717  }
3718 }
3719 
3720 void QgsFontMarkerSymbolLayerWidget::updateAssistantSymbol()
3721 {
3722  for ( int i = mAssistantPreviewSymbol->symbolLayerCount() - 1 ; i >= 0; --i )
3723  {
3724  mAssistantPreviewSymbol->deleteSymbolLayer( i );
3725  }
3726  mAssistantPreviewSymbol->appendSymbolLayer( mLayer->clone() );
3728  if ( ddSize )
3729  mAssistantPreviewSymbol->setDataDefinedSize( ddSize );
3730 }
3731 
3733 
3734 
3736  : QgsSymbolLayerWidget( parent, vl )
3737 {
3738  mLayer = nullptr;
3739 
3740  setupUi( this );
3741  connect( mDrawInsideCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged );
3742  connect( mDrawAllPartsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged );
3743  connect( mClipPointsCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged );
3744  connect( mClipOnCurrentPartOnlyCheckBox, &QCheckBox::stateChanged, this, &QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged );
3745 }
3746 
3748 {
3749  if ( layer->layerType() != QLatin1String( "CentroidFill" ) )
3750  return;
3751 
3752  // layer type is correct, we can do the cast
3753  mLayer = static_cast<QgsCentroidFillSymbolLayer *>( layer );
3754 
3755  // set values
3756  whileBlocking( mDrawInsideCheckBox )->setChecked( mLayer->pointOnSurface() );
3757  whileBlocking( mDrawAllPartsCheckBox )->setChecked( mLayer->pointOnAllParts() );
3758  whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
3759  whileBlocking( mClipOnCurrentPartOnlyCheckBox )->setChecked( mLayer->clipOnCurrentPartOnly() );
3760 }
3761 
3763 {
3764  return mLayer;
3765 }
3766 
3767 void QgsCentroidFillSymbolLayerWidget::mDrawInsideCheckBox_stateChanged( int state )
3768 {
3769  mLayer->setPointOnSurface( state == Qt::Checked );
3770  emit changed();
3771 }
3772 
3773 void QgsCentroidFillSymbolLayerWidget::mDrawAllPartsCheckBox_stateChanged( int state )
3774 {
3775  mLayer->setPointOnAllParts( state == Qt::Checked );
3776  emit changed();
3777 }
3778 
3779 void QgsCentroidFillSymbolLayerWidget::mClipPointsCheckBox_stateChanged( int state )
3780 {
3781  mLayer->setClipPoints( state == Qt::Checked );
3782  emit changed();
3783 }
3784 
3785 void QgsCentroidFillSymbolLayerWidget::mClipOnCurrentPartOnlyCheckBox_stateChanged( int state )
3786 {
3787  mLayer->setClipOnCurrentPartOnly( state == Qt::Checked );
3788  emit changed();
3789 }
3790 
3792 
3794  : QgsSymbolLayerWidget( parent, vl )
3795 {
3796  mLayer = nullptr;
3797 
3798  setupUi( this );
3799 
3800  mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
3801 
3802  connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterMarkerSymbolLayerWidget::imageSourceChanged );
3803  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed );
3804  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setAngle );
3805  connect( mSizeUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed );
3806  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setWidth );
3807  connect( mHeightSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setHeight );
3808  connect( mLockAspectRatio, static_cast < void ( QgsRatioLockButton::* )( bool ) > ( &QgsRatioLockButton::lockChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio );
3809 
3814 
3815  mSpinOffsetX->setClearValue( 0.0 );
3816  mSpinOffsetY->setClearValue( 0.0 );
3817  mRotationSpinBox->setClearValue( 0.0 );
3818 
3819  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3820  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterMarkerSymbolLayerWidget::setOffset );
3821  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterMarkerSymbolLayerWidget::setOpacity );
3822 
3823  connect( mHorizontalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged );
3824  connect( mVerticalAnchorComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged );
3825 }
3826 
3828 {
3829  if ( !layer )
3830  {
3831  return;
3832  }
3833 
3834  if ( layer->layerType() != QLatin1String( "RasterMarker" ) )
3835  return;
3836 
3837  // layer type is correct, we can do the cast
3838  mLayer = static_cast<QgsRasterMarkerSymbolLayer *>( layer );
3839 
3840  // set values
3841  whileBlocking( mImageSourceLineEdit )->setSource( mLayer->path() );
3842 
3843  whileBlocking( mWidthSpinBox )->setValue( mLayer->size() );
3844  bool preservedAspectRatio = mLayer->preservedAspectRatio();
3845  mHeightSpinBox->blockSignals( true );
3846  if ( preservedAspectRatio )
3847  {
3848  mHeightSpinBox->setValue( mLayer->size() );
3849  }
3850  else
3851  {
3852  mHeightSpinBox->setValue( mLayer->size() * mLayer->fixedAspectRatio() );
3853  }
3854  mHeightSpinBox->setEnabled( mLayer->defaultAspectRatio() > 0.0 );
3855  mHeightSpinBox->blockSignals( false );
3856  whileBlocking( mLockAspectRatio )->setLocked( preservedAspectRatio );
3857 
3858  whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
3859  whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
3860 
3861  whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
3862  whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
3863 
3864  mSizeUnitWidget->blockSignals( true );
3865  mSizeUnitWidget->setUnit( mLayer->sizeUnit() );
3866  mSizeUnitWidget->setMapUnitScale( mLayer->sizeMapUnitScale() );
3867  mSizeUnitWidget->blockSignals( false );
3868  mOffsetUnitWidget->blockSignals( true );
3869  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
3870  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
3871  mOffsetUnitWidget->blockSignals( false );
3872 
3873  //anchor points
3874  whileBlocking( mHorizontalAnchorComboBox )->setCurrentIndex( mLayer->horizontalAnchorPoint() );
3875  whileBlocking( mVerticalAnchorComboBox )->setCurrentIndex( mLayer->verticalAnchorPoint() );
3876 
3885 
3886  updatePreviewImage();
3887 }
3888 
3890 {
3891  return mLayer;
3892 }
3893 
3895 {
3897  mImageSourceLineEdit->setMessageBar( context.messageBar() );
3898 }
3899 
3900 void QgsRasterMarkerSymbolLayerWidget::imageSourceChanged( const QString &text )
3901 {
3902  mLayer->setPath( text );
3903  updatePreviewImage();
3904  emit changed();
3905 }
3906 
3907 void QgsRasterMarkerSymbolLayerWidget::updatePreviewImage()
3908 {
3909  bool fitsInCache = false;
3910  QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->path(), QSize( 150, 150 ), true, 1.0, fitsInCache );
3911  if ( image.isNull() )
3912  {
3913  mLabelImagePreview->setPixmap( QPixmap() );
3914  return;
3915  }
3916 
3917  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
3918  previewImage.fill( Qt::transparent );
3919  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
3920  QPainter p;
3921  p.begin( &previewImage );
3922  //draw a checkerboard background
3923  uchar pixDataRGB[] = { 150, 150, 150, 150,
3924  100, 100, 100, 150,
3925  100, 100, 100, 150,
3926  150, 150, 150, 150
3927  };
3928  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
3929  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
3930  QBrush checkerBrush;
3931  checkerBrush.setTexture( pix );
3932  p.fillRect( imageRect, checkerBrush );
3933 
3934  if ( mLayer->opacity() < 1.0 )
3935  {
3936  p.setOpacity( mLayer->opacity() );
3937  }
3938 
3939  p.drawImage( imageRect.left(), imageRect.top(), image );
3940  p.end();
3941  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
3942 }
3943 
3944 void QgsRasterMarkerSymbolLayerWidget::setWidth()
3945 {
3946  double defaultAspectRatio = mLayer->defaultAspectRatio();
3947  double fixedAspectRatio = 0.0;
3948  mHeightSpinBox->blockSignals( true );
3949  if ( defaultAspectRatio <= 0.0 )
3950  {
3951  mHeightSpinBox->setValue( mWidthSpinBox->value() );
3952  }
3953  else if ( mLockAspectRatio->locked() )
3954  {
3955  mHeightSpinBox->setValue( mWidthSpinBox->value() * defaultAspectRatio );
3956  }
3957  else
3958  {
3959  fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3960  }
3961  mHeightSpinBox->blockSignals( false );
3962  mLayer->setSize( mWidthSpinBox->value() );
3963  mLayer->setFixedAspectRatio( fixedAspectRatio );
3964  emit changed();
3965 }
3966 
3967 void QgsRasterMarkerSymbolLayerWidget::setHeight()
3968 {
3969  double defaultAspectRatio = mLayer->defaultAspectRatio();
3970  double fixedAspectRatio = 0.0;
3971  mWidthSpinBox->blockSignals( true );
3972  if ( defaultAspectRatio <= 0.0 )
3973  {
3974  mWidthSpinBox->setValue( mHeightSpinBox->value() );
3975  }
3976  else if ( mLockAspectRatio->locked() )
3977  {
3978  mWidthSpinBox->setValue( mHeightSpinBox->value() / defaultAspectRatio );
3979  }
3980  else
3981  {
3982  fixedAspectRatio = mHeightSpinBox->value() / mWidthSpinBox->value();
3983  }
3984  mWidthSpinBox->blockSignals( false );
3985  mLayer->setSize( mWidthSpinBox->value() );
3986  mLayer->setFixedAspectRatio( fixedAspectRatio );
3987  emit changed();
3988 }
3989 
3990 void QgsRasterMarkerSymbolLayerWidget::setLockAspectRatio( const bool locked )
3991 {
3992  double defaultAspectRatio = mLayer->defaultAspectRatio();
3993  if ( defaultAspectRatio <= 0.0 )
3994  {
3995  whileBlocking( mLockAspectRatio )->setLocked( true );
3996  }
3997  else if ( locked )
3998  {
3999  mLayer->setFixedAspectRatio( 0.0 );
4000  setWidth();
4001  }
4002  else
4003  {
4004  mLayer->setFixedAspectRatio( mHeightSpinBox->value() / mWidthSpinBox->value() );
4005  }
4006 }
4007 
4008 void QgsRasterMarkerSymbolLayerWidget::setAngle()
4009 {
4010  mLayer->setAngle( mRotationSpinBox->value() );
4011  emit changed();
4012 }
4013 
4014 void QgsRasterMarkerSymbolLayerWidget::setOpacity( double value )
4015 {
4016  mLayer->setOpacity( value );
4017  emit changed();
4018  updatePreviewImage();
4019 }
4020 
4021 void QgsRasterMarkerSymbolLayerWidget::setOffset()
4022 {
4023  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4024  emit changed();
4025 }
4026 
4027 void QgsRasterMarkerSymbolLayerWidget::mSizeUnitWidget_changed()
4028 {
4029  if ( mLayer )
4030  {
4031  mLayer->setSizeUnit( mSizeUnitWidget->unit() );
4032  mLayer->setSizeMapUnitScale( mSizeUnitWidget->getMapUnitScale() );
4033  emit changed();
4034  }
4035 }
4036 
4037 void QgsRasterMarkerSymbolLayerWidget::mOffsetUnitWidget_changed()
4038 {
4039  if ( mLayer )
4040  {
4041  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4042  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4043  emit changed();
4044  }
4045 }
4046 
4047 void QgsRasterMarkerSymbolLayerWidget::mHorizontalAnchorComboBox_currentIndexChanged( int index )
4048 {
4049  if ( mLayer )
4050  {
4052  emit changed();
4053  }
4054 }
4055 
4056 void QgsRasterMarkerSymbolLayerWidget::mVerticalAnchorComboBox_currentIndexChanged( int index )
4057 {
4058  if ( mLayer )
4059  {
4061  emit changed();
4062  }
4063 }
4064 
4066 
4068  : QgsSymbolLayerWidget( parent, vl )
4069 {
4070  mLayer = nullptr;
4071  setupUi( this );
4072 
4073  mImageSourceLineEdit->setLastPathSettingsKey( QStringLiteral( "/UI/lastRasterMarkerImageDir" ) );
4074  connect( mImageSourceLineEdit, &QgsImageSourceLineEdit::sourceChanged, this, &QgsRasterFillSymbolLayerWidget::imageSourceChanged );
4075 
4076  connect( mOffsetUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed );
4077  connect( mRotationSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged );
4078  connect( mWidthUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed );
4079  connect( mWidthSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged );
4080 
4085 
4086  mSpinOffsetX->setClearValue( 0.0 );
4087  mSpinOffsetY->setClearValue( 0.0 );
4088  mRotationSpinBox->setClearValue( 0.0 );
4089 
4090  connect( cboCoordinateMode, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRasterFillSymbolLayerWidget::setCoordinateMode );
4091  connect( mSpinOffsetX, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4092  connect( mSpinOffsetY, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRasterFillSymbolLayerWidget::offsetChanged );
4093  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsRasterFillSymbolLayerWidget::opacityChanged );
4094 }
4095 
4096 
4098 {
4099  if ( !layer )
4100  {
4101  return;
4102  }
4103 
4104  if ( layer->layerType() != QLatin1String( "RasterFill" ) )
4105  {
4106  return;
4107  }
4108 
4109  mLayer = dynamic_cast<QgsRasterFillSymbolLayer *>( layer );
4110  if ( !mLayer )
4111  {
4112  return;
4113  }
4114 
4115  whileBlocking( mImageSourceLineEdit )->setSource( mLayer->imageFilePath() );
4116 
4117  cboCoordinateMode->blockSignals( true );
4118  switch ( mLayer->coordinateMode() )
4119  {
4121  cboCoordinateMode->setCurrentIndex( 1 );
4122  break;
4124  default:
4125  cboCoordinateMode->setCurrentIndex( 0 );
4126  break;
4127  }
4128  cboCoordinateMode->blockSignals( false );
4129  whileBlocking( mOpacityWidget )->setOpacity( mLayer->opacity() );
4130  whileBlocking( mRotationSpinBox )->setValue( mLayer->angle() );
4131 
4132  whileBlocking( mSpinOffsetX )->setValue( mLayer->offset().x() );
4133  whileBlocking( mSpinOffsetY )->setValue( mLayer->offset().y() );
4134  mOffsetUnitWidget->blockSignals( true );
4135  mOffsetUnitWidget->setUnit( mLayer->offsetUnit() );
4136  mOffsetUnitWidget->setMapUnitScale( mLayer->offsetMapUnitScale() );
4137  mOffsetUnitWidget->blockSignals( false );
4138 
4139  whileBlocking( mWidthSpinBox )->setValue( mLayer->width() );
4140  mWidthUnitWidget->blockSignals( true );
4141  mWidthUnitWidget->setUnit( mLayer->widthUnit() );
4142  mWidthUnitWidget->setMapUnitScale( mLayer->widthMapUnitScale() );
4143  mWidthUnitWidget->blockSignals( false );
4144 
4145  updatePreviewImage();
4146 
4152 }
4153 
4155 {
4156  return mLayer;
4157 }
4158 
4159 void QgsRasterFillSymbolLayerWidget::imageSourceChanged( const QString &text )
4160 {
4161  mLayer->setImageFilePath( text );
4162  updatePreviewImage();
4163  emit changed();
4164 }
4165 
4166 void QgsRasterFillSymbolLayerWidget::setCoordinateMode( int index )
4167 {
4168  switch ( index )
4169  {
4170  case 0:
4171  //feature coordinate mode
4173  break;
4174  case 1:
4175  //viewport coordinate mode
4177  break;
4178  }
4179 
4180  emit changed();
4181 }
4182 
4183 void QgsRasterFillSymbolLayerWidget::opacityChanged( double value )
4184 {
4185  if ( !mLayer )
4186  {
4187  return;
4188  }
4189 
4190  mLayer->setOpacity( value );
4191  emit changed();
4192  updatePreviewImage();
4193 }
4194 
4195 void QgsRasterFillSymbolLayerWidget::offsetChanged()
4196 {
4197  mLayer->setOffset( QPointF( mSpinOffsetX->value(), mSpinOffsetY->value() ) );
4198  emit changed();
4199 }
4200 
4201 void QgsRasterFillSymbolLayerWidget::mOffsetUnitWidget_changed()
4202 {
4203  if ( !mLayer )
4204  {
4205  return;
4206  }
4207  mLayer->setOffsetUnit( mOffsetUnitWidget->unit() );
4208  mLayer->setOffsetMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4209  emit changed();
4210 }
4211 
4212 void QgsRasterFillSymbolLayerWidget::mRotationSpinBox_valueChanged( double d )
4213 {
4214  if ( mLayer )
4215  {
4216  mLayer->setAngle( d );
4217  emit changed();
4218  }
4219 }
4220 
4221 void QgsRasterFillSymbolLayerWidget::mWidthUnitWidget_changed()
4222 {
4223  if ( !mLayer )
4224  {
4225  return;
4226  }
4227  mLayer->setWidthUnit( mWidthUnitWidget->unit() );
4228  mLayer->setWidthMapUnitScale( mOffsetUnitWidget->getMapUnitScale() );
4229  emit changed();
4230 }
4231 
4232 void QgsRasterFillSymbolLayerWidget::mWidthSpinBox_valueChanged( double d )
4233 {
4234  if ( !mLayer )
4235  {
4236  return;
4237  }
4238  mLayer->setWidth( d );
4239  emit changed();
4240 }
4241 
4242 void QgsRasterFillSymbolLayerWidget::updatePreviewImage()
4243 {
4244  bool fitsInCache = false;
4245  QImage image = QgsApplication::imageCache()->pathAsImage( mLayer->imageFilePath(), QSize( 150, 150 ), true, 1.0, fitsInCache );
4246  if ( image.isNull() )
4247  {
4248  mLabelImagePreview->setPixmap( QPixmap() );
4249  return;
4250  }
4251 
4252  QImage previewImage( 150, 150, QImage::Format_ARGB32 );
4253  previewImage.fill( Qt::transparent );
4254  QRect imageRect( ( 150 - image.width() ) / 2.0, ( 150 - image.height() ) / 2.0, image.width(), image.height() );
4255  QPainter p;
4256  p.begin( &previewImage );
4257  //draw a checkerboard background
4258  uchar pixDataRGB[] = { 150, 150, 150, 150,
4259  100, 100, 100, 150,
4260  100, 100, 100, 150,
4261  150, 150, 150, 150
4262  };
4263  QImage img( pixDataRGB, 2, 2, 8, QImage::Format_ARGB32 );
4264  QPixmap pix = QPixmap::fromImage( img.scaled( 8, 8 ) );
4265  QBrush checkerBrush;
4266  checkerBrush.setTexture( pix );
4267  p.fillRect( imageRect, checkerBrush );
4268 
4269  if ( mLayer->opacity() < 1.0 )
4270  {
4271  p.setOpacity( mLayer->opacity() );
4272  }
4273 
4274  p.drawImage( imageRect.left(), imageRect.top(), image );
4275  p.end();
4276  mLabelImagePreview->setPixmap( QPixmap::fromImage( previewImage ) );
4277 }
4278 
4279 
4281  : QgsSymbolLayerWidget( parent, vl )
4282 
4283 {
4284  setupUi( this );
4285  modificationExpressionSelector->setMultiLine( true );
4286  modificationExpressionSelector->setLayer( const_cast<QgsVectorLayer *>( vl ) );
4287  modificationExpressionSelector->registerExpressionContextGenerator( this );
4288  cbxGeometryType->addItem( QgsIconUtils::iconPolygon(), tr( "Polygon / MultiPolygon" ), static_cast< int >( Qgis::SymbolType::Fill ) );
4289  cbxGeometryType->addItem( QgsIconUtils::iconLine(), tr( "LineString / MultiLineString" ), static_cast< int >( Qgis::SymbolType::Line ) );
4290  cbxGeometryType->addItem( QgsIconUtils::iconPoint(), tr( "Point / MultiPoint" ), static_cast< int >( Qgis::SymbolType::Marker ) );
4291  connect( modificationExpressionSelector, &QgsExpressionLineEdit::expressionChanged, this, &QgsGeometryGeneratorSymbolLayerWidget::updateExpression );
4292  connect( cbxGeometryType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType );
4293 }
4294 
4296 {
4297  mLayer = static_cast<QgsGeometryGeneratorSymbolLayer *>( l );
4298  modificationExpressionSelector->setExpression( mLayer->geometryExpression() );
4299  cbxGeometryType->setCurrentIndex( cbxGeometryType->findData( static_cast< int >( mLayer->symbolType() ) ) );
4300 }
4301 
4303 {
4304  return mLayer;
4305 }
4306 
4307 void QgsGeometryGeneratorSymbolLayerWidget::updateExpression( const QString &string )
4308 {
4309  mLayer->setGeometryExpression( string );
4310 
4311  emit changed();
4312 }
4313 
4314 void QgsGeometryGeneratorSymbolLayerWidget::updateSymbolType()
4315 {
4316  mLayer->setSymbolType( static_cast<Qgis::SymbolType>( cbxGeometryType->currentData().toInt() ) );
4317 
4318  emit symbolChanged();
4319 }
4320 
4321 //
4322 // QgsRandomMarkerFillSymbolLayerWidget
4323 //
4324 
4325 
4327  QgsSymbolLayerWidget( parent, vl )
4328 {
4329  setupUi( this );
4330 
4331  mCountMethodComboBox->addItem( tr( "Absolute Count" ), QgsRandomMarkerFillSymbolLayer::AbsoluteCount );
4332  mCountMethodComboBox->addItem( tr( "Density-based Count" ), QgsRandomMarkerFillSymbolLayer::DensityBasedCount );
4333 
4334  mPointCountSpinBox->setShowClearButton( true );
4335  mPointCountSpinBox->setClearValue( 100 );
4336  mSeedSpinBox->setShowClearButton( true );
4337  mSeedSpinBox->setClearValue( 0 );
4338 
4339  connect( mCountMethodComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged );
4340  connect( mPointCountSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::countChanged );
4341  connect( mDensityAreaSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged );
4342  connect( mSeedSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), this, &QgsRandomMarkerFillSymbolLayerWidget::seedChanged );
4343  connect( mClipPointsCheckBox, &QCheckBox::toggled, this, [ = ]( bool checked )
4344  {
4345  if ( mLayer )
4346  {
4347  mLayer->setClipPoints( checked );
4348  emit changed();
4349  }
4350  } );
4351 
4354 
4355  connect( mDensityAreaUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged );
4356 }
4357 
4359 {
4360  if ( !layer || layer->layerType() != QLatin1String( "RandomMarkerFill" ) )
4361  {
4362  return;
4363  }
4364 
4365  mLayer = static_cast<QgsRandomMarkerFillSymbolLayer *>( layer );
4366  whileBlocking( mPointCountSpinBox )->setValue( mLayer->pointCount() );
4367  whileBlocking( mSeedSpinBox )->setValue( mLayer->seed() );
4368  whileBlocking( mClipPointsCheckBox )->setChecked( mLayer->clipPoints() );
4369 
4370  bool showDensityBasedCountWidgets = false;
4371  switch ( mLayer->countMethod() )
4372  {
4374  showDensityBasedCountWidgets = true;
4375  break;
4377  break;
4378  }
4379  mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4380  mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4381  mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4382  mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4383 
4384  whileBlocking( mCountMethodComboBox )->setCurrentIndex( mCountMethodComboBox->findData( mLayer->countMethod() ) );
4385  whileBlocking( mDensityAreaSpinBox )->setValue( mLayer->densityArea() );
4386  mDensityAreaUnitWidget->blockSignals( true );
4387  mDensityAreaUnitWidget->setUnit( mLayer->densityAreaUnit() );
4388  mDensityAreaUnitWidget->setMapUnitScale( mLayer->densityAreaUnitScale() );
4389  mDensityAreaUnitWidget->blockSignals( false );
4390 
4395 }
4396 
4398 {
4399  return mLayer;
4400 }
4401 
4402 void QgsRandomMarkerFillSymbolLayerWidget::countMethodChanged( int )
4403 {
4404 
4405  bool showDensityBasedCountWidgets = false;
4406  switch ( static_cast< QgsRandomMarkerFillSymbolLayer::CountMethod >( mCountMethodComboBox->currentData().toInt() ) )
4407  {
4409  showDensityBasedCountWidgets = true;
4410  break;
4412  break;
4413  }
4414  mDensityAreaLabel->setVisible( showDensityBasedCountWidgets );
4415  mDensityAreaSpinBox->setVisible( showDensityBasedCountWidgets );
4416  mDensityAreaUnitWidget->setVisible( showDensityBasedCountWidgets );
4417  mDensityAreaDdbtn->setVisible( showDensityBasedCountWidgets );
4418 
4419  if ( mLayer )
4420  {
4421  mLayer->setCountMethod( static_cast< QgsRandomMarkerFillSymbolLayer::CountMethod >( mCountMethodComboBox->currentData().toInt() ) );
4422  emit changed();
4423  }
4424 }
4425 
4426 void QgsRandomMarkerFillSymbolLayerWidget::countChanged( int d )
4427 {
4428  if ( mLayer )
4429  {
4430  mLayer->setPointCount( d );
4431  emit changed();
4432  }
4433 }
4434 
4435 void QgsRandomMarkerFillSymbolLayerWidget::densityAreaChanged( double d )
4436 {
4437  if ( mLayer )
4438  {
4439  mLayer->setDensityArea( d );
4440  emit changed();
4441  }
4442 }
4443 
4444 void QgsRandomMarkerFillSymbolLayerWidget::densityAreaUnitChanged()
4445 {
4446  if ( mLayer )
4447  {
4448  mLayer->setDensityAreaUnit( mDensityAreaUnitWidget->unit() );
4449  mLayer->setDensityAreaUnitScale( mDensityAreaUnitWidget->getMapUnitScale() );
4450  emit changed();
4451  }
4452 }
4453 
4454 void QgsRandomMarkerFillSymbolLayerWidget::seedChanged( int d )
4455 {
4456  if ( mLayer )
4457  {
4458  mLayer->setSeed( d );
4459  emit changed();
4460  }
4461 }
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.
SymbolType
Symbol types.
Definition: qgis.h:168
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
static const double UI_SCALE_FACTOR
UI scaling factor.
Definition: qgis.h:416
void sourceChanged(const QString &source)
Emitted whenever the file source is changed in the widget.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
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 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_RING_NUM
Inbuilt variable name for geometry ring number variable.
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
~QgsFontMarkerSymbolLayerWidget() 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.
void setSymbolType(Qgis::SymbolType symbolType)
Set the type of symbol which should be created.
Qgis::SymbolType symbolType() const
Access the symbol type.
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.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconPoint()
Returns an icon representing point geometries.
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.
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: qgslinesymbol.h:30
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.
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 ...
~QgsSimpleLineSymbolLayerWidget() override
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.
const QgsMapUnitScale & trimDistanceStartMapUnitScale() const
Returns the map unit scale for the trim distance for the start of the line.
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.
QgsUnitTypes::RenderUnit trimDistanceStartUnit() const
Returns the unit for the trim distance for the start of the line.
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.
void setTrimDistanceEndMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the end of the line.
QVector< qreal > customDashVector() const
Returns the custom dash vector, which is the pattern of alternating drawn/skipped lengths used while ...
void setTrimDistanceEnd(double distance)
Sets the trim distance for the end of the line, which dictates a length from the end of the line at w...
void setCustomDashPatternUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for lengths used in the custom dash pattern.
double trimDistanceStart() const
Returns the trim distance for the start of the line, which dictates a length from the start of the li...
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 ...
double trimDistanceEnd() const
Returns the trim distance for the end of the line, which dictates a length from the end of the line a...
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.
QgsUnitTypes::RenderUnit trimDistanceEndUnit() const
Returns the unit for the trim distance for the end of the line.
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 for 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...
void setTrimDistanceStartUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the start of the line.
void setTrimDistanceStartMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the trim distance for the start of the line.
void setTrimDistanceEndUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the trim distance for the end of the line.
Qt::PenCapStyle penCapStyle() const
Returns the pen cap style used to render the line (e.g.
const QgsMapUnitScale & trimDistanceEndMapUnitScale() const
Returns the map unit scale for the trim distance for the end of the line.
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
void setTrimDistanceStart(double distance)
Sets the trim distance for the start of the line, which dictates a length from the start of the line ...
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.
Qt::PenCapStyle penCapStyle() const
Returns the marker's stroke cap style (e.g., flat, round, etc).
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)
void setPenCapStyle(Qt::PenCapStyle style)
Sets the marker's stroke cap style (e.g., flat, round, 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.
~QgsSvgMarkerSymbolLayerWidget() override
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.
@ PropertyTrimEnd
Trim distance from end of line (since QGIS 3.20)
@ 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.
@ PropertyTrimStart
Trim distance from start of line (since QGIS 3.20)
@ 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.
Qgis::SymbolType symbolType() const
Returns the associated symbol type, if the widget is being shown as a subcomponent of a parent symbol...
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
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:240
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
@ RenderPercentage
Percentage of another measurement (e.g., canvas size, feature size)
Definition: qgsunittypes.h:172
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
@ RenderInches
Inches.
Definition: qgsunittypes.h:174
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
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:537
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition: qgssymbol.h:27
Single variable definition for use within a QgsExpressionContextScope.