QGIS API Documentation  2.99.0-Master (d55fa22)
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"
21 
22 #include "qgssymbol.h"
23 #include "qgsstyle.h"
24 #include "qgssymbollayerutils.h"
25 #include "qgsmarkersymbollayer.h"
26 #include "qgsmapcanvas.h"
27 #include "qgsapplication.h"
28 #include "qgsvectorlayer.h"
29 #include "qgssettings.h"
30 
31 #include <QAction>
32 #include <QString>
33 #include <QStringList>
34 #include <QPainter>
35 #include <QIcon>
36 #include <QStandardItemModel>
37 #include <QColorDialog>
38 #include <QInputDialog>
39 #include <QMessageBox>
40 #include <QMenu>
41 #include <QPushButton>
42 
43 
44 QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, const QgsVectorLayer *layer )
45  : QWidget( parent )
46  , mSymbol( symbol )
47  , mStyle( style )
48  , mAdvancedMenu( nullptr )
49  , mClipFeaturesAction( nullptr )
50  , mLayer( layer )
51  , mMapCanvas( nullptr )
52 {
53  setupUi( this );
54 
57 
58  btnAdvanced->hide(); // advanced button is hidden by default
59  if ( menu ) // show it if there is a menu pointer
60  {
61  mAdvancedMenu = menu;
62  btnAdvanced->show();
63  btnAdvanced->setMenu( mAdvancedMenu );
64  }
65  else
66  {
67  btnAdvanced->setMenu( new QMenu( this ) );
68  }
69  mClipFeaturesAction = new QAction( tr( "Clip features to canvas extent" ), this );
70  mClipFeaturesAction->setCheckable( true );
71  connect( mClipFeaturesAction, &QAction::toggled, this, &QgsSymbolsListWidget::clipFeaturesToggled );
72 
73  QStandardItemModel *model = new QStandardItemModel( viewSymbols );
74  viewSymbols->setModel( model );
75  connect( viewSymbols->selectionModel(), &QItemSelectionModel::currentChanged, this, &QgsSymbolsListWidget::setSymbolFromStyle );
76 
79 
80  connect( openStyleManagerButton, &QPushButton::pressed, this, &QgsSymbolsListWidget::openStyleManager );
81 
82  lblSymbolName->setText( QLatin1String( "" ) );
83 
85 
86  if ( mSymbol )
87  {
88  updateSymbolInfo();
89  }
90 
91  // select correct page in stacked widget
92  // there's a correspondence between symbol type number and page numbering => exploit it!
93  stackedWidget->setCurrentIndex( symbol->type() );
95  connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerAngle );
96  connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerSize );
97  connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setLineWidth );
98 
99  registerDataDefinedButton( mRotationDDBtn, QgsSymbolLayer::PropertyAngle );
101  registerDataDefinedButton( mSizeDDBtn, QgsSymbolLayer::PropertySize );
103  registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
105 
106  connect( this, &QgsSymbolsListWidget::changed, this, &QgsSymbolsListWidget::updateAssistantSymbol );
107  updateAssistantSymbol();
108 
109  // Live color updates are not undoable to child symbol layers
110  btnColor->setAcceptLiveUpdates( false );
111  btnColor->setAllowAlpha( true );
112  btnColor->setColorDialogTitle( tr( "Select color" ) );
113  btnColor->setContext( QStringLiteral( "symbology" ) );
114 
115  connect( btnSaveSymbol, &QPushButton::clicked, this, &QgsSymbolsListWidget::saveSymbol );
116 }
117 
119 {
120  // This action was added to the menu by this widget, clean it up
121  // The menu can be passed in the constructor, so may live longer than this widget
122  btnAdvanced->menu()->removeAction( mClipFeaturesAction );
123 }
124 
125 void QgsSymbolsListWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key )
126 {
127  button->setProperty( "propertyKey", key );
128  button->registerExpressionContextGenerator( this );
129 }
130 
132 {
133  mContext = context;
134  Q_FOREACH ( QgsUnitSelectionWidget *unitWidget, findChildren<QgsUnitSelectionWidget *>() )
135  {
136  unitWidget->setMapCanvas( mContext.mapCanvas() );
137  }
138 #if 0
139  Q_FOREACH ( QgsPropertyOverrideButton *ddButton, findChildren<QgsPropertyOverrideButton *>() )
140  {
141  if ( ddButton->assistant() )
142  ddButton->assistant()->setMapCanvas( mContext.mapCanvas() );
143  }
144 #endif
145 }
146 
148 {
149  return mContext;
150 }
151 
153 {
154  groupsCombo->blockSignals( true );
155  groupsCombo->clear();
156 
157  groupsCombo->addItem( tr( "Favorites" ), QVariant( "favorite" ) );
158  groupsCombo->addItem( tr( "All Symbols" ), QVariant( "all" ) );
159 
160  int index = 2;
161  QStringList tags = mStyle->tags();
162  if ( tags.count() > 0 )
163  {
164  tags.sort();
165  groupsCombo->insertSeparator( index );
166  Q_FOREACH ( const QString &tag, tags )
167  {
168  groupsCombo->addItem( tag, QVariant( "tag" ) );
169  index++;
170  }
171  }
172 
173  QStringList groups = mStyle->smartgroupNames();
174  if ( groups.count() > 0 )
175  {
176  groups.sort();
177  groupsCombo->insertSeparator( index + 1 );
178  Q_FOREACH ( const QString &group, groups )
179  {
180  groupsCombo->addItem( group, QVariant( "smartgroup" ) );
181  }
182  }
183  groupsCombo->blockSignals( false );
184 
185  QgsSettings settings;
186  index = settings.value( "qgis/symbolsListGroupsIndex", 0 ).toInt();
187  groupsCombo->setCurrentIndex( index );
188 
189  populateSymbolView();
190 }
191 
192 void QgsSymbolsListWidget::populateSymbolView()
193 {
194  QStringList symbols;
195  QString text = groupsCombo->currentText();
196  int id;
197 
198  if ( groupsCombo->currentData().toString() == QLatin1String( "favorite" ) )
199  {
200  symbols = mStyle->symbolsOfFavorite( QgsStyle::SymbolEntity );
201  }
202  else if ( groupsCombo->currentData().toString() == QLatin1String( "all" ) )
203  {
204  symbols = mStyle->symbolNames();
205  }
206  else if ( groupsCombo->currentData().toString() == QLatin1String( "smartgroup" ) )
207  {
208  id = mStyle->smartgroupId( text );
209  symbols = mStyle->symbolsOfSmartgroup( QgsStyle::SymbolEntity, id );
210  }
211  else
212  {
213  id = mStyle->tagId( text );
214  symbols = mStyle->symbolsWithTag( QgsStyle::SymbolEntity, id );
215  }
216 
217  symbols.sort();
218  populateSymbols( symbols );
219 }
220 
221 void QgsSymbolsListWidget::populateSymbols( const QStringList &names )
222 {
223  QSize previewSize = viewSymbols->iconSize();
224 
225  QStandardItemModel *model = qobject_cast<QStandardItemModel *>( viewSymbols->model() );
226  if ( !model )
227  {
228  return;
229  }
230  model->clear();
231 
232  for ( int i = 0; i < names.count(); i++ )
233  {
234  QgsSymbol *s = mStyle->symbol( names[i] );
235  if ( s->type() != mSymbol->type() )
236  {
237  delete s;
238  continue;
239  }
240  QStringList tags = mStyle->tagsOfSymbol( QgsStyle::SymbolEntity, names[i] );
241  QStandardItem *item = new QStandardItem( names[i] );
242  item->setData( names[i], Qt::UserRole ); //so we can load symbol with that name
243  item->setText( names[i] );
244  item->setToolTip( QString( "<b>%1</b><br><i>%2</i>" ).arg( names[i] ).arg( tags.count() > 0 ? tags.join( ", " ) : tr( "Not tagged" ) ) );
245  item->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
246  // Set font to 10points to show reasonable text
247  QFont itemFont = item->font();
248  itemFont.setPointSize( 10 );
249  item->setFont( itemFont );
250  // create preview icon
251  QIcon icon = QgsSymbolLayerUtils::symbolPreviewIcon( s, previewSize, 15 );
252  item->setIcon( icon );
253  // add to model
254  model->appendRow( item );
255  delete s;
256  }
257 }
258 
260 {
261  QgsStyleManagerDialog dlg( mStyle, this );
262  dlg.exec();
263 
264  populateSymbolView();
265 }
266 
268 {
269  if ( !mSymbol )
270  return;
271 
272  mSymbol->setClipFeaturesToExtent( checked );
273  emit changed();
274 }
275 
276 void QgsSymbolsListWidget::setSymbolColor( const QColor &color )
277 {
278  mSymbol->setColor( color );
279  emit changed();
280 }
281 
283 {
284  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
285  if ( markerSymbol->angle() == angle )
286  return;
287  markerSymbol->setAngle( angle );
288  emit changed();
289 }
290 
292 {
293  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
294  QgsProperty dd( mRotationDDBtn->toProperty() );
295 
296  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
297 
298  QgsProperty symbolDD( markerSymbol->dataDefinedAngle() );
299 
300  if ( // shall we remove datadefined expressions for layers ?
301  ( !symbolDD && !dd )
302  // shall we set the "en masse" expression for properties ?
303  || dd )
304  {
305  markerSymbol->setDataDefinedAngle( dd );
306  emit changed();
307  }
308 }
309 
311 {
312  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
313  if ( markerSymbol->size() == size )
314  return;
315  markerSymbol->setSize( size );
316  emit changed();
317 }
318 
320 {
321  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
322  QgsProperty dd( mSizeDDBtn->toProperty() );
323 
324  spinSize->setEnabled( !mSizeDDBtn->isActive() );
325 
326  QgsProperty symbolDD( markerSymbol->dataDefinedSize() );
327 
328  if ( // shall we remove datadefined expressions for layers ?
329  ( !symbolDD && !dd )
330  // shall we set the "en masse" expression for properties ?
331  || dd )
332  {
333  markerSymbol->setDataDefinedSize( dd );
334  markerSymbol->setScaleMethod( QgsSymbol::ScaleDiameter );
335  emit changed();
336  }
337 }
338 
340 {
341  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
342  if ( lineSymbol->width() == width )
343  return;
344  lineSymbol->setWidth( width );
345  emit changed();
346 }
347 
349 {
350  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
351  QgsProperty dd( mWidthDDBtn->toProperty() );
352 
353  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
354 
355  QgsProperty symbolDD( lineSymbol->dataDefinedWidth() );
356 
357  if ( // shall we remove datadefined expressions for layers ?
358  ( !symbolDD && !dd )
359  // shall we set the "en masse" expression for properties ?
360  || dd )
361  {
362  lineSymbol->setDataDefinedWidth( dd );
363  emit changed();
364  }
365 }
366 
367 void QgsSymbolsListWidget::updateAssistantSymbol()
368 {
369  mAssistantSymbol.reset( mSymbol->clone() );
370  if ( mSymbol->type() == QgsSymbol::Marker )
371  mSizeDDBtn->setSymbol( mAssistantSymbol );
372  else if ( mSymbol->type() == QgsSymbol::Line && mLayer )
373  mWidthDDBtn->setSymbol( mAssistantSymbol );
374 }
375 
376 void QgsSymbolsListWidget::symbolAddedToStyle( const QString &name, QgsSymbol *symbol )
377 {
378  Q_UNUSED( name );
379  Q_UNUSED( symbol );
380  populateSymbolView();
381 }
382 
384 {
385  bool ok;
386  QString name = QInputDialog::getText( this, tr( "Symbol name" ),
387  tr( "Please enter name for the symbol:" ), QLineEdit::Normal, tr( "New symbol" ), &ok );
388  if ( !ok || name.isEmpty() )
389  return;
390 
391  // check if there is no symbol with same name
392  if ( mStyle->symbolNames().contains( name ) )
393  {
394  int res = QMessageBox::warning( this, tr( "Save symbol" ),
395  tr( "Symbol with name '%1' already exists. Overwrite?" )
396  .arg( name ),
397  QMessageBox::Yes | QMessageBox::No );
398  if ( res != QMessageBox::Yes )
399  {
400  return;
401  }
402  }
403 
404  // add new symbol to style and re-populate the list
405  mStyle->addSymbol( name, mSymbol->clone() );
406 
407  // make sure the symbol is stored
408  mStyle->saveSymbol( name, mSymbol->clone(), false, QStringList() );
409  populateSymbolView();
410 }
411 
413 {
414  QgsStyleSaveDialog saveDlg( this );
415  if ( !saveDlg.exec() )
416  return;
417 
418  if ( saveDlg.name().isEmpty() )
419  return;
420 
421  // check if there is no symbol with same name
422  if ( mStyle->symbolNames().contains( saveDlg.name() ) )
423  {
424  int res = QMessageBox::warning( this, tr( "Save symbol" ),
425  tr( "Symbol with name '%1' already exists. Overwrite?" )
426  .arg( saveDlg.name() ),
427  QMessageBox::Yes | QMessageBox::No );
428  if ( res != QMessageBox::Yes )
429  {
430  return;
431  }
432  mStyle->removeSymbol( saveDlg.name() );
433  }
434 
435  QStringList symbolTags = saveDlg.tags().split( ',' );
436 
437  // add new symbol to style and re-populate the list
438  mStyle->addSymbol( saveDlg.name(), mSymbol->clone() );
439 
440  // make sure the symbol is stored
441  mStyle->saveSymbol( saveDlg.name(), mSymbol->clone(), saveDlg.isFavorite(), symbolTags );
442 }
443 
445 {
446  if ( mSymbol )
447  {
448 
449  mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
450  mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
451 
452  emit changed();
453  }
454 }
455 
457 {
458  if ( mSymbol )
459  {
460  double alpha = 1 - ( value / 255.0 );
461  mSymbol->setAlpha( alpha );
462  displayTransparency( alpha );
463  emit changed();
464  }
465 }
466 
467 void QgsSymbolsListWidget::displayTransparency( double alpha )
468 {
469  double transparencyPercent = ( 1 - alpha ) * 100;
470  mTransparencyLabel->setText( tr( "Transparency %1%" ).arg( ( int ) transparencyPercent ) );
471 }
472 
473 void QgsSymbolsListWidget::updateSymbolColor()
474 {
475  btnColor->blockSignals( true );
476  btnColor->setColor( mSymbol->color() );
477  btnColor->blockSignals( false );
478 }
479 
480 QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const
481 {
482  if ( mContext.expressionContext() )
483  return QgsExpressionContext( *mContext.expressionContext() );
484 
485  //otherwise create a default symbol context
486  QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( layer() ) );
487 
488  // additional scopes
489  Q_FOREACH ( const QgsExpressionContextScope &scope, mContext.additionalExpressionContextScopes() )
490  {
491  expContext.appendScope( new QgsExpressionContextScope( scope ) );
492  }
493 
494  expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
498 
499  return expContext;
500 }
501 
502 void QgsSymbolsListWidget::updateSymbolInfo()
503 {
504  updateSymbolColor();
505 
506  Q_FOREACH ( QgsPropertyOverrideButton *button, findChildren< QgsPropertyOverrideButton * >() )
507  {
508  button->registerExpressionContextGenerator( this );
509  }
510 
511  if ( mSymbol->type() == QgsSymbol::Marker )
512  {
513  QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
514  spinSize->setValue( markerSymbol->size() );
515  spinAngle->setValue( markerSymbol->angle() );
516 
517  if ( mLayer )
518  {
519  QgsProperty ddSize( markerSymbol->dataDefinedSize() );
520  mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer );
521  spinSize->setEnabled( !mSizeDDBtn->isActive() );
522  QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
523  mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer );
524  spinAngle->setEnabled( !mRotationDDBtn->isActive() );
525  }
526  else
527  {
528  mSizeDDBtn->setEnabled( false );
529  mRotationDDBtn->setEnabled( false );
530  }
531  }
532  else if ( mSymbol->type() == QgsSymbol::Line )
533  {
534  QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
535  spinWidth->setValue( lineSymbol->width() );
536 
537  if ( mLayer )
538  {
539  QgsProperty dd( lineSymbol->dataDefinedWidth() );
541  spinWidth->setEnabled( !mWidthDDBtn->isActive() );
542  }
543  else
544  {
545  mWidthDDBtn->setEnabled( false );
546  }
547  }
548 
549  mSymbolUnitWidget->blockSignals( true );
550  mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
551  mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
552  mSymbolUnitWidget->blockSignals( false );
553 
554  mTransparencySlider->blockSignals( true );
555  double transparency = 1 - mSymbol->alpha();
556  mTransparencySlider->setValue( transparency * 255 );
557  displayTransparency( mSymbol->alpha() );
558  mTransparencySlider->blockSignals( false );
559 
560  if ( mSymbol->type() == QgsSymbol::Line || mSymbol->type() == QgsSymbol::Fill )
561  {
562  //add clip features option for line or fill symbols
563  btnAdvanced->menu()->addAction( mClipFeaturesAction );
564  }
565  else
566  {
567  btnAdvanced->menu()->removeAction( mClipFeaturesAction );
568  }
569  btnAdvanced->setVisible( mAdvancedMenu || !btnAdvanced->menu()->isEmpty() );
570 
571  mClipFeaturesAction->blockSignals( true );
572  mClipFeaturesAction->setChecked( mSymbol->clipFeaturesToExtent() );
573  mClipFeaturesAction->blockSignals( false );
574 }
575 
576 void QgsSymbolsListWidget::setSymbolFromStyle( const QModelIndex &index )
577 {
578  QString symbolName = index.data( Qt::UserRole ).toString();
579  lblSymbolName->setText( symbolName );
580  // get new instance of symbol from style
581  QgsSymbol *s = mStyle->symbol( symbolName );
582  // remove all symbol layers from original symbolgroupsCombo
583  while ( mSymbol->symbolLayerCount() )
584  mSymbol->deleteSymbolLayer( 0 );
585  // move all symbol layers to our symbol
586  while ( s->symbolLayerCount() )
587  {
588  QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
589  mSymbol->appendSymbolLayer( sl );
590  }
591  mSymbol->setAlpha( s->alpha() );
592 
593  // delete the temporary symbol
594  delete s;
595 
596  updateSymbolInfo();
597  emit changed();
598 }
599 
601 {
602  QgsSettings settings;
603  settings.setValue( QStringLiteral( "qgis/symbolsListGroupsIndex" ), index );
604 
605  populateSymbolView();
606 }
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.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
void on_mTransparencySlider_valueChanged(int value)
void setLineWidth(double width)
QString tags() const
returns the text value of the tags element
void symbolSaved(const QString &name, QgsSymbol *symbol)
Is emitted every time a new symbol has been added to the database.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
void setSymbolFromStyle(const QModelIndex &index)
void setMapUnitScale(const QgsMapUnitScale &scale)
Definition: qgssymbol.cpp:247
Calculate scale by the diameter.
Definition: qgssymbol.h:83
a dialog for setting properties of a newly saved style.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:54
QStringList symbolsWithTag(StyleEntity type, int tagid) const
Returns the symbol names with which have the given tag.
Definition: qgsstyle.cpp:565
bool appendSymbolLayer(QgsSymbolLayer *layer)
Append symbol layer at the end of the list Ownership will be transferred.
Definition: qgssymbol.cpp:330
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbol.h:231
QgsMapUnitScale mapUnitScale() const
Definition: qgssymbol.cpp:215
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
Definition: qgsstyle.cpp:1027
QString name() const
returns the text value of the name element
void setSize(double size)
Sets the size for the whole symbol.
Definition: qgssymbol.cpp:1196
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context&#39;s extent...
Definition: qgssymbol.h:261
void setMarkerSize(double size)
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
Definition: qgssymbol.cpp:340
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1122
Line symbol.
Definition: qgssymbol.h:72
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
Definition: qgssymbol.cpp:1087
QList< RenderUnit > RenderUnitList
List of render units.
Definition: qgsunittypes.h:145
void populateGroups()
Pupulates the groups combo box with available tags and smartgroups.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:194
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:239
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1150
void setValue(const QString &key, const QVariant &value, const QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
QgsSymbolsListWidget(QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, const QgsVectorLayer *layer=nullptr)
A button for controlling property overrides which may apply to a widget.
static QIcon symbolPreviewIcon(QgsSymbol *symbol, QSize size, int padding=0)
Returns an icon preview for a color ramp.
QStringList symbolNames()
Returns a list of names of symbols.
Definition: qgsstyle.cpp:187
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setWidth(double width)
Definition: qgssymbol.cpp:1509
double width() const
Definition: qgssymbol.cpp:1535
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void groupsModified()
Is emitted every time a tag or smartgroup has been added, removed, or renamed.
points (e.g., for font sizes)
Definition: qgsunittypes.h:102
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:126
void setSymbolColor(const QColor &color)
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QColor color() const
Definition: qgssymbol.cpp:423
void setMarkerAngle(double angle)
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Definition: qgssymbol.cpp:1387
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
Definition: qgsproperty.h:189
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
Definition: qgssymbol.h:229
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1554
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
void on_groupsCombo_currentIndexChanged(int index)
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
Returns the symbols for the smartgroup.
Definition: qgsstyle.cpp:1268
int smartgroupId(const QString &smartgroup)
Returns the DB id for the given smartgroup name.
Definition: qgsstyle.cpp:1168
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1332
QStringList smartgroupNames()
Returns the smart groups list.
Definition: qgsstyle.cpp:1243
int tagId(const QString &tag)
Returns the DB id for the given tag name.
Definition: qgsstyle.cpp:1163
void colorChanged(const QColor &color)
Is 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:71
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol&#39;s ownership.
Definition: qgsstyle.cpp:88
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QStringList tags() const
Returns a list of all tags in the style database.
Definition: qgsstyle.cpp:634
Fill symbol.
Definition: qgssymbol.h:73
void symbolAddedToStyle(const QString &name, QgsSymbol *symbol)
SymbolType type() const
Definition: qgssymbol.h:99
virtual QgsSymbol * clone() const =0
Get a deep copy of this symbol.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
Definition: qgssymbol.cpp:1219
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
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...
bool isFavorite() const
returns whether the favorite element is checked
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
QgsSymbolLayer * takeSymbolLayer(int index)
Remove symbol layer from the list and return pointer to it.
Definition: qgssymbol.cpp:351
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:171
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1296
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags.
Definition: qgsstyle.cpp:112
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context&#39;s extent...
Definition: qgssymbol.h:251
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
Definition: qgsstyle.cpp:143
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
A widget displaying a combobox allowing the user to choose between various display units...
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.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cc:857
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
Definition: qgssymbol.cpp:1589
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
Definition: qgsstyle.cpp:528
double angle() const
Returns the marker angle for the whole symbol.
Definition: qgssymbol.cpp:1099
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)
Definition: qgssymbol.cpp:414