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