QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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  QgsSymbol *newSymbol = mSymbol->clone();
222  mStyle->addSymbol( saveDlg.name(), newSymbol );
223 
224  // make sure the symbol is stored
225  mStyle->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
226 }
227 
229 {
230  if ( !mSymbol )
231  return;
232 
233  mSymbol->setClipFeaturesToExtent( checked );
234  emit changed();
235 }
236 
237 void QgsSymbolsListWidget::setSymbolColor( const QColor &color )
238 {
239  mSymbol->setColor( color );
240  emit changed();
241 }
242 
244 {
245  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
246  if ( markerSymbol->angle() == angle )
247  return;
248  markerSymbol->setAngle( angle );
249  emit changed();
250 }
251 
253 {
254  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
255  QgsProperty dd( mRotationDDBtn->toProperty() );
256 
257  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
258 
259  QgsProperty symbolDD( markerSymbol->dataDefinedAngle() );
260 
261  if ( // shall we remove datadefined expressions for layers ?
262  ( !symbolDD && !dd )
263  // shall we set the "en masse" expression for properties ?
264  || dd )
265  {
266  markerSymbol->setDataDefinedAngle( dd );
267  emit changed();
268  }
269 }
270 
272 {
273  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
274  if ( markerSymbol->size() == size )
275  return;
276  markerSymbol->setSize( size );
277  emit changed();
278 }
279 
281 {
282  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
283  QgsProperty dd( mSizeDDBtn->toProperty() );
284 
285  spinSize->setEnabled( !mSizeDDBtn->isActive() );
286 
287  QgsProperty symbolDD( markerSymbol->dataDefinedSize() );
288 
289  if ( // shall we remove datadefined expressions for layers ?
290  ( !symbolDD && !dd )
291  // shall we set the "en masse" expression for properties ?
292  || dd )
293  {
294  markerSymbol->setDataDefinedSize( dd );
295  markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
296  emit changed();
297  }
298 }
299 
301 {
302  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
303  if ( lineSymbol->width() == width )
304  return;
305  lineSymbol->setWidth( width );
306  emit changed();
307 }
308 
310 {
311  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
312  QgsProperty dd( mWidthDDBtn->toProperty() );
313 
314  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
315 
316  QgsProperty symbolDD( lineSymbol->dataDefinedWidth() );
317 
318  if ( // shall we remove datadefined expressions for layers ?
319  ( !symbolDD && !dd )
320  // shall we set the "en masse" expression for properties ?
321  || dd )
322  {
323  lineSymbol->setDataDefinedWidth( dd );
324  emit changed();
325  }
326 }
327 
328 void QgsSymbolsListWidget::updateAssistantSymbol()
329 {
330  mAssistantSymbol.reset( mSymbol->clone() );
331  if ( mSymbol->type() == QgsSymbol::Marker )
332  mSizeDDBtn->setSymbol( mAssistantSymbol );
333  else if ( mSymbol->type() == QgsSymbol::Line && mLayer )
334  mWidthDDBtn->setSymbol( mAssistantSymbol );
335 }
336 
337 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
338 {
339  if ( mSymbol )
340  {
341 
342  mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
343  mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
344 
345  emit changed();
346  }
347 }
348 
349 void QgsSymbolsListWidget::opacityChanged( double opacity )
350 {
351  if ( mSymbol )
352  {
353  mSymbol->setOpacity( opacity );
354  emit changed();
355  }
356 }
357 
358 void QgsSymbolsListWidget::updateSymbolColor()
359 {
360  btnColor->blockSignals( true );
361  btnColor->setColor( mSymbol->color() );
362  btnColor->blockSignals( false );
363 }
364 
365 QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const
366 {
367  if ( auto *lExpressionContext = mContext.expressionContext() )
368  return QgsExpressionContext( *lExpressionContext );
369 
370  //otherwise create a default symbol context
371  QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) );
372 
373  // additional scopes
374  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
375  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
376  {
377  expContext.appendScope( new QgsExpressionContextScope( scope ) );
378  }
379 
380  expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
384  << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" ) );
385 
386  return expContext;
387 }
388 
389 void QgsSymbolsListWidget::updateSymbolInfo()
390 {
391  updateSymbolColor();
392 
393  const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
394  for ( QgsPropertyOverrideButton *button : overrideButtons )
395  {
396  button->registerExpressionContextGenerator( this );
397  }
398 
399  if ( mSymbol->type() == QgsSymbol::Marker )
400  {
401  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
402  spinSize->setValue( markerSymbol->size() );
403  spinAngle->setValue( markerSymbol->angle() );
404 
405  if ( mLayer )
406  {
407  QgsProperty ddSize( markerSymbol->dataDefinedSize() );
408  mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
409  spinSize->setEnabled( !mSizeDDBtn->isActive() );
410  QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
411  mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
412  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
413  }
414  else
415  {
416  mSizeDDBtn->setEnabled( false );
417  mRotationDDBtn->setEnabled( false );
418  }
419  }
420  else if ( mSymbol->type() == QgsSymbol::Line )
421  {
422  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
423  spinWidth->setValue( lineSymbol->width() );
424 
425  if ( mLayer )
426  {
427  QgsProperty dd( lineSymbol->dataDefinedWidth() );
428  mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
429  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
430  }
431  else
432  {
433  mWidthDDBtn->setEnabled( false );
434  }
435  }
436 
437  mSymbolUnitWidget->blockSignals( true );
438  mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
439  mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
440  mSymbolUnitWidget->blockSignals( false );
441 
442  mOpacityWidget->setOpacity( mSymbol->opacity() );
443 
444  // Clean up previous advanced symbol actions
445  const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
446  for ( const auto &action : actionList )
447  {
448  if ( mClipFeaturesAction->text() == action->text() )
449  {
450  mStyleItemsListWidget->advancedMenu()->removeAction( action );
451  }
452  else if ( mStandardizeRingsAction->text() == action->text() )
453  {
454  mStyleItemsListWidget->advancedMenu()->removeAction( action );
455  }
456  }
457 
458  if ( mSymbol->type() == QgsSymbol::Line || mSymbol->type() == QgsSymbol::Fill )
459  {
460  //add clip features option for line or fill symbols
461  mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
462  }
463  if ( mSymbol->type() == QgsSymbol::Fill )
464  {
465  mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
466  }
467 
468  mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
469 
470  whileBlocking( mClipFeaturesAction )->setChecked( mSymbol->clipFeaturesToExtent() );
471  whileBlocking( mStandardizeRingsAction )->setChecked( mSymbol->forceRHR() );
472 }
473 
474 void QgsSymbolsListWidget::setSymbolFromStyle( const QString &name, QgsStyle::StyleEntity )
475 {
476  // get new instance of symbol from style
477  std::unique_ptr< QgsSymbol > s( mStyle->symbol( name ) );
478  if ( !s )
479  return;
480 
481  // remove all symbol layers from original symbolgroupsCombo
482  while ( mSymbol->symbolLayerCount() )
483  mSymbol->deleteSymbolLayer( 0 );
484  // move all symbol layers to our symbol
485  while ( s->symbolLayerCount() )
486  {
487  QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
488  mSymbol->appendSymbolLayer( sl );
489  }
490  mSymbol->setOpacity( s->opacity() );
491 
492  updateSymbolInfo();
493  emit changed();
494 }
QgsSymbolWidgetContext::globalProjectAtlasMapLayerScopes
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
Definition: qgssymbolwidgetcontext.cpp:92
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:370
QgsOpacityWidget::opacityChanged
void opacityChanged(double opacity)
Emitted when the opacity is changed in the widget, where opacity ranges from 0.0 (transparent) to 1....
QgsMarkerSymbol::setAngle
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
Definition: qgssymbol.cpp:1501
QgsSymbolWidgetContext::mapCanvas
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:54
QgsSymbol::color
QColor color() const
Returns the symbol's color.
Definition: qgssymbol.cpp:514
QgsSymbolsListWidget::setLineWidth
void setLineWidth(double width)
Definition: qgssymbolslistwidget.cpp:300
QgsUnitTypes::RenderInches
@ RenderInches
Inches.
Definition: qgsunittypes.h:173
QgsStyleItemsListWidget::saveEntity
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
qgsstyleitemslistwidget.h
QgsMarkerSymbol::setDataDefinedAngle
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1538
QgsProperty
A store for object properties.
Definition: qgsproperty.h:232
QgsSymbolsListWidget::QgsSymbolsListWidget
QgsSymbolsListWidget(QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer=nullptr)
Constructor for QgsSymbolsListWidget.
Definition: qgssymbolslistwidget.cpp:27
QgsExpressionContext::EXPR_ORIGINAL_VALUE
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
Definition: qgsexpressioncontext.h:721
QgsMarkerSymbol::size
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
Definition: qgssymbol.cpp:1638
QgsPropertyOverrideButton::changed
void changed()
Emitted when property definition changes.
qgsstylemanagerdialog.h
QgsExpressionContext::EXPR_CLUSTER_COLOR
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
Definition: qgsexpressioncontext.h:737
QgsExpressionContext::EXPR_GEOMETRY_POINT_COUNT
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
Definition: qgsexpressioncontext.h:731
QgsMarkerSymbol::dataDefinedSize
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1772
QgsLineSymbol::width
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
Definition: qgssymbol.cpp:2000
QgsAuxiliaryLayer::exists
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
Definition: qgsauxiliarystorage.cpp:135
QgsUnitTypes::RenderPoints
@ RenderPoints
Points (e.g., for font sizes)
Definition: qgsunittypes.h:172
QgsExpressionContext::EXPR_GEOMETRY_POINT_NUM
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
Definition: qgsexpressioncontext.h:733
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:36
QgsSymbolSelectorDialog::context
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
Definition: qgssymbolselectordialog.cpp:815
QgsSymbol::ScaleDiameter
@ ScaleDiameter
Calculate scale by the diameter.
Definition: qgssymbol.h:99
QgsVectorLayer::auxiliaryLayer
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Definition: qgsvectorlayer.cpp:5293
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
QgsPropertyOverrideButton::createAuxiliaryField
void createAuxiliaryField()
Emitted when creating a new auxiliary field.
QgsMarkerSymbol::setDataDefinedSize
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1735
QgsPropertyOverrideButton::propertyKey
int propertyKey() const
Returns the property key linked to the button.
Definition: qgspropertyoverridebutton.h:123
QgsSymbolsListWidget::setMarkerSize
void setMarkerSize(double size)
Definition: qgssymbolslistwidget.cpp:271
QgsSymbol::mapUnitScale
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
Definition: qgssymbol.cpp:278
QgsExpressionContext::EXPR_GEOMETRY_PART_NUM
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
Definition: qgsexpressioncontext.h:729
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:64
QgsMarkerSymbol::angle
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1514
QgsSymbol::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:257
QgsExpressionContext::EXPR_SYMBOL_COLOR
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
Definition: qgsexpressioncontext.h:723
QgsLineSymbol::setWidth
void setWidth(double width)
Sets the width for the whole line symbol.
Definition: qgssymbol.cpp:1960
qgsstylesavedialog.h
QgsStyle::symbol
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:269
QgsStyle::SymbolEntity
@ SymbolEntity
Symbols.
Definition: qgsstyle.h:180
QgsPropertyOverrideButton::setToProperty
void setToProperty(const QgsProperty &property)
Sets the widget to reflect the current state of a QgsProperty.
Definition: qgspropertyoverridebutton.cpp:286
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:51
QgsSymbolWidgetContext::setMapCanvas
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:49
QgsColorButton::colorChanged
void colorChanged(const QColor &color)
Emitted whenever a new color is set for the button.
qgsauxiliarystorage.h
QgsSymbolsListWidget::changed
void changed()
QgsSymbol::setMapUnitScale
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
Definition: qgssymbol.cpp:311
qgsnewauxiliarylayerdialog.h
QgsSymbolLayer::propertyDefinitions
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Definition: qgssymbollayer.cpp:221
QgsSymbol::setOpacity
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:465
QgsSymbol::setClipFeaturesToExtent
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
Definition: qgssymbol.h:488
QgsSymbol::opacity
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:458
QgsSymbolLayer
Definition: qgssymbollayer.h:53
QgsStyle::addSymbol
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
Definition: qgsstyle.cpp:177
QgsSymbol::setOutputUnit
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:302
QgsSymbol::appendSymbolLayer
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
Definition: qgssymbol.cpp:408
QgsProperty::setField
void setField(const QString &field)
Sets the field name the property references.
Definition: qgsproperty.cpp:292
whileBlocking
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Definition: qgis.h:262
QgsPropertyOverrideButton::updateFieldLists
void updateFieldLists()
Updates list of fields.
Definition: qgspropertyoverridebutton.cpp:152
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:931
QgsStyleItemsListWidget::selectionChanged
void selectionChanged(const QString &name, QgsStyle::StyleEntity type)
Emitted when the selected item is changed in the widget.
QgsSymbolLayer::PropertySize
@ PropertySize
Symbol size.
Definition: qgssymbollayer.h:132
QgsSymbolsListWidget::setMarkerAngle
void setMarkerAngle(double angle)
Definition: qgssymbolslistwidget.cpp:243
QgsSymbolsListWidget::setSymbolColor
void setSymbolColor(const QColor &color)
Definition: qgssymbolslistwidget.cpp:237
QgsMarkerSymbol::setScaleMethod
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Definition: qgssymbol.cpp:1828
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1131
QgsPropertyOverrideButton::toProperty
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
Definition: qgspropertyoverridebutton.cpp:210
QgsPropertyDefinition
Definition for a property.
Definition: qgsproperty.h:48
qgssymbolslistwidget.h
QgsLineSymbol::dataDefinedWidth
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:2071
QgsSymbolsListWidget::~QgsSymbolsListWidget
~QgsSymbolsListWidget() override
Definition: qgssymbolslistwidget.cpp:87
QgsUnitSelectionWidget::changed
void changed()
QgsSymbol::Fill
@ Fill
Fill symbol.
Definition: qgssymbol.h:89
QgsSymbolWidgetContext::expressionContext
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
Definition: qgssymbolwidgetcontext.cpp:77
QgsSymbolLayer::PropertyStrokeWidth
@ PropertyStrokeWidth
Stroke width.
Definition: qgssymbollayer.h:137
QgsSymbol::setForceRHR
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Definition: qgssymbol.h:510
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext.
Definition: qgsexpressioncontext.h:112
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:170
QgsStyle::symbolNames
QStringList symbolNames() const
Returns a list of names of symbols.
Definition: qgsstyle.cpp:285
qgsvectorlayer.h
QgsExpressionContext::EXPR_CLUSTER_SIZE
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
Definition: qgsexpressioncontext.h:735
QgsSymbolsListWidget::updateDataDefinedMarkerSize
void updateDataDefinedMarkerSize()
Definition: qgssymbolslistwidget.cpp:280
QgsExpressionContext::EXPR_GEOMETRY_PART_COUNT
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
Definition: qgsexpressioncontext.h:727
QgsSymbol::clone
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
QgsStyle::removeSymbol
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
Definition: qgsstyle.cpp:235
QgsSymbolsListWidget::clipFeaturesToggled
void clipFeaturesToggled(bool checked)
Definition: qgssymbolslistwidget.cpp:228
QgsSymbolsListWidget::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Definition: qgssymbolslistwidget.cpp:160
QgsLineSymbol::setDataDefinedWidth
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:2035
QgsSymbolSelectorDialog::symbol
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
Definition: qgssymbolselectordialog.cpp:820
QgsSymbolsListWidget::layer
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
Definition: qgssymbolslistwidget.h:74
QgsSymbol::clipFeaturesToExtent
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
Definition: qgssymbol.h:499
QgsSymbol::setColor
void setColor(const QColor &color)
Sets the color for the symbol.
Definition: qgssymbol.cpp:504
QgsStyle
Definition: qgsstyle.h:160
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
QgsPropertyOverrideButton::registerExpressionContextGenerator
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
Definition: qgspropertyoverridebutton.cpp:954
QgsMarkerSymbol::dataDefinedAngle
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1567
QgsSymbol::deleteSymbolLayer
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
Definition: qgssymbol.cpp:418
QgsSymbolLayer::PropertyAngle
@ PropertyAngle
Symbol angle.
Definition: qgssymbollayer.h:133
QgsUnitTypes::RenderMetersInMapUnits
@ RenderMetersInMapUnits
Meters value as Map units.
Definition: qgsunittypes.h:175
QgsSymbol::Line
@ Line
Line symbol.
Definition: qgssymbol.h:88
QgsAuxiliaryLayer::nameFromProperty
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
Definition: qgsauxiliarystorage.cpp:366
QgsSymbol::type
SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:122
QgsSymbol::Marker
@ Marker
Marker symbol.
Definition: qgssymbol.h:87
QgsSymbolLayer::Property
Property
Data definable properties.
Definition: qgssymbollayer.h:131
QgsStyle::saveSymbol
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
Definition: qgsstyle.cpp:201
QgsUnitTypes::RenderUnitList
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:239
QgsAuxiliaryLayer::addAuxiliaryField
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
Definition: qgsauxiliarystorage.cpp:140
MathUtils::angle
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
QgsSymbolsListWidget::context
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
Definition: qgssymbolslistwidget.cpp:177
QgsSymbol::forceRHR
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
Definition: qgssymbol.h:521
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:169
QgsNewAuxiliaryLayerDialog
A dialog to create a new auxiliary layer.
Definition: qgsnewauxiliarylayerdialog.h:35
QgsSymbolWidgetContext::additionalExpressionContextScopes
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
Definition: qgssymbolwidgetcontext.cpp:87
QgsSymbolsListWidget::updateDataDefinedLineWidth
void updateDataDefinedLineWidth()
Definition: qgssymbolslistwidget.cpp:309
QgsSymbol::symbolLayerCount
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:183
QgsMarkerSymbol::setSize
void setSize(double size)
Sets the size for the whole symbol.
Definition: qgssymbol.cpp:1614
QgsStyle::StyleEntity
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
QgsSymbolsListWidget::updateDataDefinedMarkerAngle
void updateDataDefinedMarkerAngle()
Definition: qgssymbolslistwidget.cpp:252