QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 <QMessageBox>
26 
27 QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer )
28  : QWidget( parent )
29  , mSymbol( symbol )
30  , mStyle( style )
31  , mAdvancedMenu( menu )
32  , mLayer( layer )
33 {
34  setupUi( this );
35  connect( mSymbolUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSymbolsListWidget::mSymbolUnitWidget_changed );
36  spinAngle->setClearValue( 0 );
37 
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  if ( mSymbol )
55  {
56  updateSymbolInfo();
57  }
58 
59  // select correct page in stacked widget
60  // there's a correspondence between symbol type number and page numbering => exploit it!
61  stackedWidget->setCurrentIndex( symbol->type() );
63  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerAngle );
64  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerSize );
65  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setLineWidth );
66 
67  registerDataDefinedButton( mRotationDDBtn, QgsSymbolLayer::PropertyAngle );
69  registerDataDefinedButton( mSizeDDBtn, QgsSymbolLayer::PropertySize );
71  registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
73 
74  connect( this, &QgsSymbolsListWidget::changed, this, &QgsSymbolsListWidget::updateAssistantSymbol );
75  updateAssistantSymbol();
76 
77  btnColor->setAllowOpacity( true );
78  btnColor->setColorDialogTitle( tr( "Select Color" ) );
79  btnColor->setContext( QStringLiteral( "symbology" ) );
80 
81  connect( mOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsSymbolsListWidget::opacityChanged );
82 
83  connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::selectionChanged, this, &QgsSymbolsListWidget::setSymbolFromStyle );
84  connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::saveEntity, this, &QgsSymbolsListWidget::saveSymbol );
85 }
86 
88 {
89  // This action was added to the menu by this widget, clean it up
90  // The menu can be passed in the constructor, so may live longer than this widget
91  mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
92  mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
93 }
94 
95 void QgsSymbolsListWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key )
96 {
97  button->setProperty( "propertyKey", key );
98  button->registerExpressionContextGenerator( this );
99 
100  connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolsListWidget::createAuxiliaryField );
101 }
102 
103 void QgsSymbolsListWidget::createAuxiliaryField()
104 {
105  // try to create an auxiliary layer if not yet created
106  if ( !mLayer->auxiliaryLayer() )
107  {
108  QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
109  dlg.exec();
110  }
111 
112  // return if still not exists
113  if ( !mLayer->auxiliaryLayer() )
114  return;
115 
116  QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
117  QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
119 
120  // create property in auxiliary storage if necessary
121  if ( !mLayer->auxiliaryLayer()->exists( def ) )
122  mLayer->auxiliaryLayer()->addAuxiliaryField( def );
123 
124  // update property with join field name from auxiliary storage
125  QgsProperty property = button->toProperty();
126  property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
127  property.setActive( true );
128  button->updateFieldLists();
129  button->setToProperty( property );
130 
131  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
132  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
133  switch ( key )
134  {
136  if ( markerSymbol )
137  markerSymbol->setDataDefinedAngle( button->toProperty() );
138  break;
139 
141  if ( markerSymbol )
142  {
143  markerSymbol->setDataDefinedSize( button->toProperty() );
144  markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
145  }
146  break;
147 
149  if ( lineSymbol )
150  lineSymbol->setDataDefinedWidth( button->toProperty() );
151  break;
152 
153  default:
154  break;
155  }
156 
157  emit changed();
158 }
159 
161 {
162  mContext = context;
163  const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
164  for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
165  {
166  unitWidget->setMapCanvas( mContext.mapCanvas() );
167  }
168 #if 0
169  Q_FOREACH ( QgsPropertyOverrideButton *ddButton, findChildren<QgsPropertyOverrideButton *>() )
170  {
171  if ( ddButton->assistant() )
172  ddButton->assistant()->setMapCanvas( mContext.mapCanvas() );
173  }
174 #endif
175 }
176 
178 {
179  return mContext;
180 }
181 
182 void QgsSymbolsListWidget::forceRHRToggled( bool checked )
183 {
184  if ( !mSymbol )
185  return;
186 
187  mSymbol->setForceRHR( checked );
188  emit changed();
189 }
190 
191 void QgsSymbolsListWidget::saveSymbol()
192 {
193  if ( !mStyle )
194  return;
195 
196  QgsStyleSaveDialog saveDlg( this );
197  saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
198  if ( !saveDlg.exec() )
199  return;
200 
201  if ( saveDlg.name().isEmpty() )
202  return;
203 
204  // check if there is no symbol with same name
205  if ( mStyle->symbolNames().contains( saveDlg.name() ) )
206  {
207  int res = QMessageBox::warning( this, tr( "Save Symbol" ),
208  tr( "Symbol with name '%1' already exists. Overwrite?" )
209  .arg( saveDlg.name() ),
210  QMessageBox::Yes | QMessageBox::No );
211  if ( res != QMessageBox::Yes )
212  {
213  return;
214  }
215  mStyle->removeSymbol( saveDlg.name() );
216  }
217 
218  QStringList symbolTags = saveDlg.tags().split( ',' );
219 
220  // add new symbol to style and re-populate the list
221  mStyle->addSymbol( saveDlg.name(), mSymbol->clone() );
222 
223  // make sure the symbol is stored
224  mStyle->saveSymbol( saveDlg.name(), mSymbol->clone(), saveDlg.isFavorite(), symbolTags );
225 }
226 
228 {
229  if ( !mSymbol )
230  return;
231 
232  mSymbol->setClipFeaturesToExtent( checked );
233  emit changed();
234 }
235 
236 void QgsSymbolsListWidget::setSymbolColor( const QColor &color )
237 {
238  mSymbol->setColor( color );
239  emit changed();
240 }
241 
243 {
244  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
245  if ( markerSymbol->angle() == angle )
246  return;
247  markerSymbol->setAngle( angle );
248  emit changed();
249 }
250 
252 {
253  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
254  QgsProperty dd( mRotationDDBtn->toProperty() );
255 
256  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
257 
258  QgsProperty symbolDD( markerSymbol->dataDefinedAngle() );
259 
260  if ( // shall we remove datadefined expressions for layers ?
261  ( !symbolDD && !dd )
262  // shall we set the "en masse" expression for properties ?
263  || dd )
264  {
265  markerSymbol->setDataDefinedAngle( dd );
266  emit changed();
267  }
268 }
269 
271 {
272  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
273  if ( markerSymbol->size() == size )
274  return;
275  markerSymbol->setSize( size );
276  emit changed();
277 }
278 
280 {
281  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
282  QgsProperty dd( mSizeDDBtn->toProperty() );
283 
284  spinSize->setEnabled( !mSizeDDBtn->isActive() );
285 
286  QgsProperty symbolDD( markerSymbol->dataDefinedSize() );
287 
288  if ( // shall we remove datadefined expressions for layers ?
289  ( !symbolDD && !dd )
290  // shall we set the "en masse" expression for properties ?
291  || dd )
292  {
293  markerSymbol->setDataDefinedSize( dd );
294  markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
295  emit changed();
296  }
297 }
298 
300 {
301  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
302  if ( lineSymbol->width() == width )
303  return;
304  lineSymbol->setWidth( width );
305  emit changed();
306 }
307 
309 {
310  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
311  QgsProperty dd( mWidthDDBtn->toProperty() );
312 
313  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
314 
315  QgsProperty symbolDD( lineSymbol->dataDefinedWidth() );
316 
317  if ( // shall we remove datadefined expressions for layers ?
318  ( !symbolDD && !dd )
319  // shall we set the "en masse" expression for properties ?
320  || dd )
321  {
322  lineSymbol->setDataDefinedWidth( dd );
323  emit changed();
324  }
325 }
326 
327 void QgsSymbolsListWidget::updateAssistantSymbol()
328 {
329  mAssistantSymbol.reset( mSymbol->clone() );
330  if ( mSymbol->type() == QgsSymbol::Marker )
331  mSizeDDBtn->setSymbol( mAssistantSymbol );
332  else if ( mSymbol->type() == QgsSymbol::Line && mLayer )
333  mWidthDDBtn->setSymbol( mAssistantSymbol );
334 }
335 
336 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
337 {
338  if ( mSymbol )
339  {
340 
341  mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
342  mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
343 
344  emit changed();
345  }
346 }
347 
348 void QgsSymbolsListWidget::opacityChanged( double opacity )
349 {
350  if ( mSymbol )
351  {
352  mSymbol->setOpacity( opacity );
353  emit changed();
354  }
355 }
356 
357 void QgsSymbolsListWidget::updateSymbolColor()
358 {
359  btnColor->blockSignals( true );
360  btnColor->setColor( mSymbol->color() );
361  btnColor->blockSignals( false );
362 }
363 
364 QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const
365 {
366  if ( mContext.expressionContext() )
367  return QgsExpressionContext( *mContext.expressionContext() );
368 
369  //otherwise create a default symbol context
370  QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) );
371 
372  // additional scopes
373  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
374  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
375  {
376  expContext.appendScope( new QgsExpressionContextScope( scope ) );
377  }
378 
379  expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
383 
384  return expContext;
385 }
386 
387 void QgsSymbolsListWidget::updateSymbolInfo()
388 {
389  updateSymbolColor();
390 
391  const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
392  for ( QgsPropertyOverrideButton *button : overrideButtons )
393  {
394  button->registerExpressionContextGenerator( this );
395  }
396 
397  if ( mSymbol->type() == QgsSymbol::Marker )
398  {
399  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
400  spinSize->setValue( markerSymbol->size() );
401  spinAngle->setValue( markerSymbol->angle() );
402 
403  if ( mLayer )
404  {
405  QgsProperty ddSize( markerSymbol->dataDefinedSize() );
406  mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
407  spinSize->setEnabled( !mSizeDDBtn->isActive() );
408  QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
409  mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
410  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
411  }
412  else
413  {
414  mSizeDDBtn->setEnabled( false );
415  mRotationDDBtn->setEnabled( false );
416  }
417  }
418  else if ( mSymbol->type() == QgsSymbol::Line )
419  {
420  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
421  spinWidth->setValue( lineSymbol->width() );
422 
423  if ( mLayer )
424  {
425  QgsProperty dd( lineSymbol->dataDefinedWidth() );
426  mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
427  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
428  }
429  else
430  {
431  mWidthDDBtn->setEnabled( false );
432  }
433  }
434 
435  mSymbolUnitWidget->blockSignals( true );
436  mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
437  mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
438  mSymbolUnitWidget->blockSignals( false );
439 
440  mOpacityWidget->setOpacity( mSymbol->opacity() );
441 
442  // Clean up previous advanced symbol actions
443  const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
444  for ( const auto &action : actionList )
445  {
446  if ( mClipFeaturesAction->text() == action->text() )
447  {
448  mStyleItemsListWidget->advancedMenu()->removeAction( action );
449  }
450  else if ( mStandardizeRingsAction->text() == action->text() )
451  {
452  mStyleItemsListWidget->advancedMenu()->removeAction( action );
453  }
454  }
455 
456  if ( mSymbol->type() == QgsSymbol::Line || mSymbol->type() == QgsSymbol::Fill )
457  {
458  //add clip features option for line or fill symbols
459  mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
460  }
461  if ( mSymbol->type() == QgsSymbol::Fill )
462  {
463  mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
464  }
465 
466  mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
467 
468  whileBlocking( mClipFeaturesAction )->setChecked( mSymbol->clipFeaturesToExtent() );
469  whileBlocking( mStandardizeRingsAction )->setChecked( mSymbol->forceRHR() );
470 }
471 
472 void QgsSymbolsListWidget::setSymbolFromStyle( const QString &name, QgsStyle::StyleEntity )
473 {
474  // get new instance of symbol from style
475  std::unique_ptr< QgsSymbol > s( mStyle->symbol( name ) );
476  if ( !s )
477  return;
478 
479  // remove all symbol layers from original symbolgroupsCombo
480  while ( mSymbol->symbolLayerCount() )
481  mSymbol->deleteSymbolLayer( 0 );
482  // move all symbol layers to our symbol
483  while ( s->symbolLayerCount() )
484  {
485  QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
486  mSymbol->appendSymbolLayer( sl );
487  }
488  mSymbol->setOpacity( s->opacity() );
489 
490  updateSymbolInfo();
491  emit changed();
492 }
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.
Meters value as Map units.
Definition: qgsunittypes.h:154
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
void setLineWidth(double width)
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
Definition: qgssymbol.cpp:288
Calculate scale by the diameter.
Definition: qgssymbol.h:97
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
Definition: qgssymbol.cpp:380
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
Definition: qgssymbol.cpp:255
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
void setSize(double size)
Sets the size for the whole symbol.
Definition: qgssymbol.cpp:1385
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context&#39;s extent...
Definition: qgssymbol.h:474
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:173
void setMarkerSize(double size)
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
Definition: qgssymbol.cpp:390
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1309
Line symbol.
Definition: qgssymbol.h:86
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
Definition: qgssymbol.cpp:1271
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:218
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
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:860
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1060
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:177
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:234
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:279
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1338
A dialog to create a new auxiliary layer.
void setField(const QString &field)
Sets the field name the property references.
A button for controlling property overrides which may apply to a widget.
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
Definition: qgssymbol.h:496
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.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:440
void setWidth(double width)
Sets the width for the whole line symbol.
Definition: qgssymbol.cpp:1731
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgssymbol.cpp:1758
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setSymbolColor(const QColor &color)
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QColor color() const
Returns the symbol&#39;s color.
Definition: qgssymbol.cpp:484
void setMarkerAngle(double angle)
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Definition: qgssymbol.cpp:1599
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
Definition: qgsproperty.h:229
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1793
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
Definition for a property.
Definition: qgsproperty.h:46
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1543
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
void changed()
Emitted when property definition changes.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
void clipFeaturesToggled(bool checked)
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Marker symbol.
Definition: qgssymbol.h:85
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol&#39;s ownership.
Definition: qgsstyle.cpp:124
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:227
Points (e.g., for font sizes)
Definition: qgsunittypes.h:151
SymbolType type() const
Returns the symbol&#39;s type.
Definition: qgssymbol.h:120
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgssymbol.cpp:1409
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
int propertyKey() const
Returns the property key linked to the button.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:214
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1506
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags.
Definition: qgsstyle.cpp:148
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context&#39;s extent...
Definition: qgssymbol.h:463
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:433
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
Definition: qgsstyle.cpp:181
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Definition: qgssymbol.h:485
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
Represents a vector layer which manages a vector based data sets.
void updateFieldLists()
Updates list of fields.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1829
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1284
QgsSymbolsListWidget(QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer=nullptr)
Constructor for QgsSymbolsListWidget.
Property
Data definable properties.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
void setColor(const QColor &color)
Sets the color for the symbol.
Definition: qgssymbol.cpp:474
QStringList symbolNames() const
Returns a list of names of symbols.
Definition: qgsstyle.cpp:230