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