QGIS API Documentation  3.23.0-Master (dd0cd13a00)
qgssymbolslistwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolslist.cpp
3  ---------------------
4  begin : June 2012
5  copyright : (C) 2012 by Arunmozhi
6  email : aruntheguy at gmail.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 
17 #include "qgssymbolslistwidget.h"
18 
19 #include "qgsstylemanagerdialog.h"
20 #include "qgsstylesavedialog.h"
22 #include "qgsvectorlayer.h"
24 #include "qgsauxiliarystorage.h"
25 #include "qgsmarkersymbol.h"
26 #include "qgslinesymbol.h"
27 #include "qgsfillsymbol.h"
28 
29 #include <QMessageBox>
30 
31 QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer )
32  : QWidget( parent )
33  , mSymbol( symbol )
34  , mStyle( style )
35  , mAdvancedMenu( menu )
36  , mLayer( layer )
37 {
38  setupUi( this );
39  spinAngle->setClearValue( 0 );
40 
41  mStyleItemsListWidget->setStyle( mStyle );
42  mStyleItemsListWidget->setEntityType( QgsStyle::SymbolEntity );
43  if ( mSymbol )
44  mStyleItemsListWidget->setSymbolType( mSymbol->type() );
45  mStyleItemsListWidget->setAdvancedMenu( menu );
46 
47  mClipFeaturesAction = new QAction( tr( "Clip Features to Canvas Extent" ), this );
48  mClipFeaturesAction->setCheckable( true );
49  connect( mClipFeaturesAction, &QAction::toggled, this, &QgsSymbolsListWidget::clipFeaturesToggled );
50  mStandardizeRingsAction = new QAction( tr( "Force Right-Hand-Rule Orientation" ), this );
51  mStandardizeRingsAction->setCheckable( true );
52  connect( mStandardizeRingsAction, &QAction::toggled, this, &QgsSymbolsListWidget::forceRHRToggled );
53 
54 
55  // select correct page in stacked widget
56  QgsPropertyOverrideButton *opacityDDBtn = nullptr;
57  switch ( symbol->type() )
58  {
60  {
61  stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
62  stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
63  mSymbolColorButton = btnMarkerColor;
64  opacityDDBtn = mMarkerOpacityDDBtn;
65  mSymbolOpacityWidget = mMarkerOpacityWidget;
66  mSymbolUnitWidget = mMarkerUnitWidget;
67  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerAngle );
68  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerSize );
69  registerDataDefinedButton( mSizeDDBtn, QgsSymbolLayer::PropertySize );
71  registerDataDefinedButton( mRotationDDBtn, QgsSymbolLayer::PropertyAngle );
73  break;
74  }
75 
77  {
78  stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
79  stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
80  mSymbolColorButton = btnLineColor;
81  opacityDDBtn = mLineOpacityDDBtn;
82  mSymbolOpacityWidget = mLineOpacityWidget;
83  mSymbolUnitWidget = mLineUnitWidget;
84  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setLineWidth );
85  registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
87  break;
88  }
89 
91  {
92  stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
93  stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
94  mSymbolColorButton = btnFillColor;
95  opacityDDBtn = mFillOpacityDDBtn;
96  mSymbolOpacityWidget = mFillOpacityWidget;
97  mSymbolUnitWidget = mFillUnitWidget;
98  break;
99  }
100 
102  break;
103  }
104 
105  stackedWidget->setCurrentIndex( 0 );
106 
109 
110  if ( mSymbol )
111  {
112  updateSymbolInfo();
113  }
114 
115  connect( mSymbolUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSymbolsListWidget::mSymbolUnitWidget_changed );
116  connect( mSymbolColorButton, &QgsColorButton::colorChanged, this, &QgsSymbolsListWidget::setSymbolColor );
117 
118  registerSymbolDataDefinedButton( opacityDDBtn, QgsSymbol::PropertyOpacity );
119 
120  connect( this, &QgsSymbolsListWidget::changed, this, &QgsSymbolsListWidget::updateAssistantSymbol );
121  updateAssistantSymbol();
122 
123  mSymbolColorButton->setAllowOpacity( true );
124  mSymbolColorButton->setColorDialogTitle( tr( "Select Color" ) );
125  mSymbolColorButton->setContext( QStringLiteral( "symbology" ) );
126 
127  connect( mSymbolOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsSymbolsListWidget::opacityChanged );
128 
129  connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::selectionChanged, this, &QgsSymbolsListWidget::setSymbolFromStyle );
130  connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::saveEntity, this, &QgsSymbolsListWidget::saveSymbol );
131 }
132 
134 {
135  // This action was added to the menu by this widget, clean it up
136  // The menu can be passed in the constructor, so may live longer than this widget
137  mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
138  mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
139 }
140 
141 void QgsSymbolsListWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key )
142 {
143  button->setProperty( "propertyKey", key );
144  button->registerExpressionContextGenerator( this );
145 
146  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolsListWidget::createAuxiliaryField );
147 }
148 
149 void QgsSymbolsListWidget::createAuxiliaryField()
150 {
151  // try to create an auxiliary layer if not yet created
152  if ( !mLayer->auxiliaryLayer() )
153  {
154  QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
155  dlg.exec();
156  }
157 
158  // return if still not exists
159  if ( !mLayer->auxiliaryLayer() )
160  return;
161 
162  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
163  const QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
165 
166  // create property in auxiliary storage if necessary
167  if ( !mLayer->auxiliaryLayer()->exists( def ) )
168  mLayer->auxiliaryLayer()->addAuxiliaryField( def );
169 
170  // update property with join field name from auxiliary storage
171  QgsProperty property = button->toProperty();
172  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
173  property.setActive( true );
174  button->updateFieldLists();
175  button->setToProperty( property );
176 
177  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
178  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
179  switch ( key )
180  {
182  if ( markerSymbol )
183  markerSymbol->setDataDefinedAngle( button->toProperty() );
184  break;
185 
187  if ( markerSymbol )
188  {
189  markerSymbol->setDataDefinedSize( button->toProperty() );
191  }
192  break;
193 
195  if ( lineSymbol )
196  lineSymbol->setDataDefinedWidth( button->toProperty() );
197  break;
198 
199  default:
200  break;
201  }
202 
203  emit changed();
204 }
205 
206 void QgsSymbolsListWidget::createSymbolAuxiliaryField()
207 {
208  // try to create an auxiliary layer if not yet created
209  if ( !mLayer->auxiliaryLayer() )
210  {
211  QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
212  dlg.exec();
213  }
214 
215  // return if still not exists
216  if ( !mLayer->auxiliaryLayer() )
217  return;
218 
219  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
220  const QgsSymbol::Property key = static_cast< QgsSymbol::Property >( button->propertyKey() );
222 
223  // create property in auxiliary storage if necessary
224  if ( !mLayer->auxiliaryLayer()->exists( def ) )
225  mLayer->auxiliaryLayer()->addAuxiliaryField( def );
226 
227  // update property with join field name from auxiliary storage
228  QgsProperty property = button->toProperty();
229  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
230  property.setActive( true );
231  button->updateFieldLists();
232  button->setToProperty( property );
233 
234  mSymbol->setDataDefinedProperty( key, button->toProperty() );
235 
236  emit changed();
237 }
238 
240 {
241  mContext = context;
242  const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
243  for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
244  {
245  unitWidget->setMapCanvas( mContext.mapCanvas() );
246  }
247 }
248 
250 {
251  return mContext;
252 }
253 
254 void QgsSymbolsListWidget::forceRHRToggled( bool checked )
255 {
256  if ( !mSymbol )
257  return;
258 
259  mSymbol->setForceRHR( checked );
260  emit changed();
261 }
262 
263 void QgsSymbolsListWidget::saveSymbol()
264 {
265  if ( !mStyle )
266  return;
267 
268  QgsStyleSaveDialog saveDlg( this );
269  saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
270  if ( !saveDlg.exec() )
271  return;
272 
273  if ( saveDlg.name().isEmpty() )
274  return;
275 
276  // check if there is no symbol with same name
277  if ( mStyle->symbolNames().contains( saveDlg.name() ) )
278  {
279  const int res = QMessageBox::warning( this, tr( "Save Symbol" ),
280  tr( "Symbol with name '%1' already exists. Overwrite?" )
281  .arg( saveDlg.name() ),
282  QMessageBox::Yes | QMessageBox::No );
283  if ( res != QMessageBox::Yes )
284  {
285  return;
286  }
287  mStyle->removeSymbol( saveDlg.name() );
288  }
289 
290  const QStringList symbolTags = saveDlg.tags().split( ',' );
291 
292  // add new symbol to style and re-populate the list
293  QgsSymbol *newSymbol = mSymbol->clone();
294  mStyle->addSymbol( saveDlg.name(), newSymbol );
295 
296  // make sure the symbol is stored
297  mStyle->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
298 }
299 
300 void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
301 {
302  if ( !mSymbol )
303  return;
304 
305  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
306  const QgsSymbol::Property key = static_cast< QgsSymbol::Property >( button->propertyKey() );
307  mSymbol->setDataDefinedProperty( key, button->toProperty() );
308  emit changed();
309 }
310 
311 void QgsSymbolsListWidget::registerSymbolDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbol::Property key )
312 {
313  button->init( key, mSymbol ? mSymbol->dataDefinedProperties() : QgsPropertyCollection(), QgsSymbol::propertyDefinitions(), mLayer, true );
314  connect( button, &QgsPropertyOverrideButton::changed, this, &QgsSymbolsListWidget::updateSymbolDataDefinedProperty );
315  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolsListWidget::createSymbolAuxiliaryField );
316 
317  button->registerExpressionContextGenerator( this );
318 }
319 
321 {
322  if ( !mSymbol )
323  return;
324 
325  mSymbol->setClipFeaturesToExtent( checked );
326  emit changed();
327 }
328 
329 void QgsSymbolsListWidget::setSymbolColor( const QColor &color )
330 {
331  mSymbol->setColor( color );
332  emit changed();
333 }
334 
336 {
337  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
338  if ( markerSymbol->angle() == angle )
339  return;
340  markerSymbol->setAngle( angle );
341  emit changed();
342 }
343 
345 {
346  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
347  const QgsProperty dd( mRotationDDBtn->toProperty() );
348 
349  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
350 
351  const QgsProperty symbolDD( markerSymbol->dataDefinedAngle() );
352 
353  if ( // shall we remove datadefined expressions for layers ?
354  ( !symbolDD && !dd )
355  // shall we set the "en masse" expression for properties ?
356  || dd )
357  {
358  markerSymbol->setDataDefinedAngle( dd );
359  emit changed();
360  }
361 }
362 
364 {
365  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
366  if ( markerSymbol->size() == size )
367  return;
368  markerSymbol->setSize( size );
369  emit changed();
370 }
371 
373 {
374  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
375  const QgsProperty dd( mSizeDDBtn->toProperty() );
376 
377  spinSize->setEnabled( !mSizeDDBtn->isActive() );
378 
379  const QgsProperty symbolDD( markerSymbol->dataDefinedSize() );
380 
381  if ( // shall we remove datadefined expressions for layers ?
382  ( !symbolDD && !dd )
383  // shall we set the "en masse" expression for properties ?
384  || dd )
385  {
386  markerSymbol->setDataDefinedSize( dd );
388  emit changed();
389  }
390 }
391 
393 {
394  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
395  if ( lineSymbol->width() == width )
396  return;
397  lineSymbol->setWidth( width );
398  emit changed();
399 }
400 
402 {
403  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
404  const QgsProperty dd( mWidthDDBtn->toProperty() );
405 
406  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
407 
408  const QgsProperty symbolDD( lineSymbol->dataDefinedWidth() );
409 
410  if ( // shall we remove datadefined expressions for layers ?
411  ( !symbolDD && !dd )
412  // shall we set the "en masse" expression for properties ?
413  || dd )
414  {
415  lineSymbol->setDataDefinedWidth( dd );
416  emit changed();
417  }
418 }
419 
420 void QgsSymbolsListWidget::updateAssistantSymbol()
421 {
422  mAssistantSymbol.reset( mSymbol->clone() );
423  if ( mSymbol->type() == Qgis::SymbolType::Marker )
424  mSizeDDBtn->setSymbol( mAssistantSymbol );
425  else if ( mSymbol->type() == Qgis::SymbolType::Line && mLayer )
426  mWidthDDBtn->setSymbol( mAssistantSymbol );
427 }
428 
429 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
430 {
431  if ( mSymbol )
432  {
433 
434  mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
435  mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
436 
437  emit changed();
438  }
439 }
440 
441 void QgsSymbolsListWidget::opacityChanged( double opacity )
442 {
443  if ( mSymbol )
444  {
445  mSymbol->setOpacity( opacity );
446  emit changed();
447  }
448 }
449 
450 void QgsSymbolsListWidget::updateSymbolColor()
451 {
452  mSymbolColorButton->blockSignals( true );
453  mSymbolColorButton->setColor( mSymbol->color() );
454  mSymbolColorButton->blockSignals( false );
455 }
456 
457 QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const
458 {
459  if ( auto *lExpressionContext = mContext.expressionContext() )
460  return QgsExpressionContext( *lExpressionContext );
461 
462  //otherwise create a default symbol context
463  QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) );
464 
465  // additional scopes
466  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
467  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
468  {
469  expContext.appendScope( new QgsExpressionContextScope( scope ) );
470  }
471 
472  expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
477  << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" ) );
478 
479  return expContext;
480 }
481 
482 void QgsSymbolsListWidget::updateSymbolInfo()
483 {
484  updateSymbolColor();
485 
486  const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
487  for ( QgsPropertyOverrideButton *button : overrideButtons )
488  {
489  button->registerExpressionContextGenerator( this );
490  }
491 
492  if ( mSymbol->type() == Qgis::SymbolType::Marker )
493  {
494  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
495  spinSize->setValue( markerSymbol->size() );
496  spinAngle->setValue( markerSymbol->angle() );
497 
498  if ( mLayer )
499  {
500  const QgsProperty ddSize( markerSymbol->dataDefinedSize() );
501  mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
502  spinSize->setEnabled( !mSizeDDBtn->isActive() );
503  const QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
504  mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
505  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
506  }
507  else
508  {
509  mSizeDDBtn->setEnabled( false );
510  mRotationDDBtn->setEnabled( false );
511  }
512  }
513  else if ( mSymbol->type() == Qgis::SymbolType::Line )
514  {
515  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
516  spinWidth->setValue( lineSymbol->width() );
517 
518  if ( mLayer )
519  {
520  const QgsProperty dd( lineSymbol->dataDefinedWidth() );
521  mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
522  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
523  }
524  else
525  {
526  mWidthDDBtn->setEnabled( false );
527  }
528  }
529 
530  mSymbolUnitWidget->blockSignals( true );
531  mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
532  mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
533  mSymbolUnitWidget->blockSignals( false );
534 
535  mSymbolOpacityWidget->setOpacity( mSymbol->opacity() );
536 
537  // Clean up previous advanced symbol actions
538  const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
539  for ( const auto &action : actionList )
540  {
541  if ( mClipFeaturesAction->text() == action->text() )
542  {
543  mStyleItemsListWidget->advancedMenu()->removeAction( action );
544  }
545  else if ( mStandardizeRingsAction->text() == action->text() )
546  {
547  mStyleItemsListWidget->advancedMenu()->removeAction( action );
548  }
549  }
550 
551  if ( mSymbol->type() == Qgis::SymbolType::Line || mSymbol->type() == Qgis::SymbolType::Fill )
552  {
553  //add clip features option for line or fill symbols
554  mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
555  }
556  if ( mSymbol->type() == Qgis::SymbolType::Fill )
557  {
558  mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
559  }
560 
561  mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
562 
563  whileBlocking( mClipFeaturesAction )->setChecked( mSymbol->clipFeaturesToExtent() );
564  whileBlocking( mStandardizeRingsAction )->setChecked( mSymbol->forceRHR() );
565 }
566 
567 void QgsSymbolsListWidget::setSymbolFromStyle( const QString &name, QgsStyle::StyleEntity )
568 {
569  // get new instance of symbol from style
570  std::unique_ptr< QgsSymbol > s( mStyle->symbol( name ) );
571  if ( !s )
572  return;
573 
574  // remove all symbol layers from original symbolgroupsCombo
575  while ( mSymbol->symbolLayerCount() )
576  mSymbol->deleteSymbolLayer( 0 );
577  // move all symbol layers to our symbol
578  while ( s->symbolLayerCount() )
579  {
580  QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
581  mSymbol->appendSymbolLayer( sl );
582  }
583  mSymbol->setOpacity( s->opacity() );
584  mSymbol->setFlags( s->flags() );
585 
586  updateSymbolInfo();
587  emit changed();
588 }
@ ScaleDiameter
Calculate scale by the diameter.
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
void setColorDialogTitle(const QString &title)
Set the title for the color chooser dialog window.
void setAllowOpacity(bool allowOpacity)
Sets whether opacity modification (transparency) is permitted for the color.
void setContext(const QString &context)
Sets the context string for the color button.
void setColor(const QColor &color)
Sets the current color for the button.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
static const QString EXPR_GEOMETRY_RING_NUM
Inbuilt variable name for geometry ring number variable.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
void setWidth(double width)
Sets the width for the whole line symbol.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
A marker symbol type, for rendering Point and MultiPoint geometries.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
void setSize(double size)
Sets the size for the whole symbol.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
double angle() const
Returns the marker angle for the whole symbol.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
A dialog to create a new auxiliary layer.
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1....
void setOpacity(double opacity)
Sets the current opacity to show in the widget, where opacity ranges from 0.0 (transparent) to 1....
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition for a property.
Definition: qgsproperty.h:47
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void updateFieldLists()
Updates list of fields.
void changed()
Emitted when property definition changes.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
A store for object properties.
Definition: qgsproperty.h:231
void setField(const QString &field)
Sets the field name the property references.
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
a dialog for setting properties of a newly saved style.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
Definition: qgsstyle.cpp:241
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:275
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
@ SymbolEntity
Symbols.
Definition: qgsstyle.h:180
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
Definition: qgsstyle.cpp:205
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
Definition: qgsstyle.cpp:181
QStringList symbolNames() const
Returns a list of names of symbols.
Definition: qgsstyle.cpp:291
Property
Data definable properties.
@ PropertyAngle
Symbol angle.
@ PropertySize
Symbol size.
@ PropertyStrokeWidth
Stroke width.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
Property
Data definable properties.
Definition: qgssymbol.h:75
@ PropertyOpacity
Opacity.
Definition: qgssymbol.h:76
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
Definition: qgssymbol.cpp:838
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:337
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol property definitions.
Definition: qgssymbol.cpp:263
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
Definition: qgssymbol.cpp:443
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:275
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
Definition: qgssymbol.cpp:313
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:440
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
Definition: qgssymbol.h:497
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
Definition: qgssymbol.h:467
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
Definition: qgssymbol.cpp:453
void setColor(const QColor &color)
Sets the color for the symbol.
Definition: qgssymbol.cpp:541
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:543
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:447
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
Definition: qgssymbol.cpp:346
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:160
QColor color() const
Returns the symbol's color.
Definition: qgssymbol.cpp:551
Qgis::SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:97
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
Definition: qgssymbol.h:519
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
Definition: qgssymbol.h:486
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Definition: qgssymbol.h:508
void setLineWidth(double width)
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
void setSymbolColor(const QColor &color)
void setMarkerAngle(double angle)
QgsSymbolsListWidget(QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer=nullptr)
Constructor for QgsSymbolsListWidget.
void clipFeaturesToggled(bool checked)
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
void setMarkerSize(double size)
A widget displaying a combobox allowing the user to choose between various display units,...
QgsMapUnitScale getMapUnitScale() const
Returns the map unit scale.
void setUnits(const QStringList &units, int mapUnitIdx)
Sets the units which the user can choose from in the combobox.
void setUnit(int unitIndex)
Sets the selected unit index.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale.
QgsUnitTypes::RenderUnit unit() const
Returns the current predefined selected unit (if applicable).
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:240
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:176
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:173
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
@ RenderInches
Inches.
Definition: qgsunittypes.h:174
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
Represents a vector layer which manages a vector based data sets.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:1443