QGIS API Documentation 3.29.0-Master (ade4f0cf0f)
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
18
20#include "qgsstylesavedialog.h"
22#include "qgsvectorlayer.h"
24#include "qgsauxiliarystorage.h"
25#include "qgsmarkersymbol.h"
26#include "qgslinesymbol.h"
27#include "qgsfillsymbol.h"
30
31#include <QMessageBox>
32
33QgsSymbolsListWidget::QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent, QgsVectorLayer *layer )
34 : QWidget( parent )
35 , mSymbol( symbol )
36 , mStyle( style )
37 , mAdvancedMenu( menu )
38 , mLayer( layer )
39{
40 setupUi( this );
41 spinAngle->setClearValue( 0 );
42
43 mStyleItemsListWidget->setStyle( mStyle );
44 mStyleItemsListWidget->setEntityType( QgsStyle::SymbolEntity );
45 if ( mSymbol )
46 mStyleItemsListWidget->setSymbolType( mSymbol->type() );
47 mStyleItemsListWidget->setAdvancedMenu( menu );
48
49 mClipFeaturesAction = new QAction( tr( "Clip Features to Canvas Extent" ), this );
50 mClipFeaturesAction->setCheckable( true );
51 connect( mClipFeaturesAction, &QAction::toggled, this, &QgsSymbolsListWidget::clipFeaturesToggled );
52 mStandardizeRingsAction = new QAction( tr( "Force Right-Hand-Rule Orientation" ), this );
53 mStandardizeRingsAction->setCheckable( true );
54 connect( mStandardizeRingsAction, &QAction::toggled, this, &QgsSymbolsListWidget::forceRHRToggled );
55 mAnimationSettingsAction = new QAction( tr( "Animation Settingsā€¦" ), this );
56 connect( mAnimationSettingsAction, &QAction::triggered, this, &QgsSymbolsListWidget::showAnimationSettings );
57
58 // select correct page in stacked widget
59 QgsPropertyOverrideButton *opacityDDBtn = nullptr;
60 switch ( symbol->type() )
61 {
63 {
64 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
65 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
66 mSymbolColorButton = btnMarkerColor;
67 opacityDDBtn = mMarkerOpacityDDBtn;
68 mSymbolOpacityWidget = mMarkerOpacityWidget;
69 mSymbolUnitWidget = mMarkerUnitWidget;
70 connect( spinAngle, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerAngle );
71 connect( spinSize, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setMarkerSize );
72 registerDataDefinedButton( mSizeDDBtn, QgsSymbolLayer::PropertySize );
74 registerDataDefinedButton( mRotationDDBtn, QgsSymbolLayer::PropertyAngle );
76 break;
77 }
78
80 {
81 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
82 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
83 mSymbolColorButton = btnLineColor;
84 opacityDDBtn = mLineOpacityDDBtn;
85 mSymbolOpacityWidget = mLineOpacityWidget;
86 mSymbolUnitWidget = mLineUnitWidget;
87 connect( spinWidth, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ), this, &QgsSymbolsListWidget::setLineWidth );
88 registerDataDefinedButton( mWidthDDBtn, QgsSymbolLayer::PropertyStrokeWidth );
90 break;
91 }
92
94 {
95 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
96 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
97 mSymbolColorButton = btnFillColor;
98 opacityDDBtn = mFillOpacityDDBtn;
99 mSymbolOpacityWidget = mFillOpacityWidget;
100 mSymbolUnitWidget = mFillUnitWidget;
101 break;
102 }
103
105 break;
106 }
107
108 stackedWidget->setCurrentIndex( 0 );
109
112
113 if ( mSymbol )
114 {
115 updateSymbolInfo();
116 }
117
118 connect( mSymbolUnitWidget, &QgsUnitSelectionWidget::changed, this, &QgsSymbolsListWidget::mSymbolUnitWidget_changed );
119 connect( mSymbolColorButton, &QgsColorButton::colorChanged, this, &QgsSymbolsListWidget::setSymbolColor );
120
121 registerSymbolDataDefinedButton( opacityDDBtn, QgsSymbol::PropertyOpacity );
122
123 connect( this, &QgsSymbolsListWidget::changed, this, &QgsSymbolsListWidget::updateAssistantSymbol );
124 updateAssistantSymbol();
125
126 mSymbolColorButton->setAllowOpacity( true );
127 mSymbolColorButton->setColorDialogTitle( tr( "Select Color" ) );
128 mSymbolColorButton->setContext( QStringLiteral( "symbology" ) );
129
130 connect( mSymbolOpacityWidget, &QgsOpacityWidget::opacityChanged, this, &QgsSymbolsListWidget::opacityChanged );
131
132 connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::selectionChangedWithStylePath, this, &QgsSymbolsListWidget::setSymbolFromStyle );
133 connect( mStyleItemsListWidget, &QgsStyleItemsListWidget::saveEntity, this, &QgsSymbolsListWidget::saveSymbol );
134}
135
137{
138 // This action was added to the menu by this widget, clean it up
139 // The menu can be passed in the constructor, so may live longer than this widget
140 mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
141 mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
142 mStyleItemsListWidget->advancedMenu()->removeAction( mAnimationSettingsAction );
143}
144
145void QgsSymbolsListWidget::registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key )
146{
147 button->setProperty( "propertyKey", key );
149
150 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolsListWidget::createAuxiliaryField );
151}
152
153void QgsSymbolsListWidget::createAuxiliaryField()
154{
155 // try to create an auxiliary layer if not yet created
156 if ( !mLayer->auxiliaryLayer() )
157 {
158 QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
159 dlg.exec();
160 }
161
162 // return if still not exists
163 if ( !mLayer->auxiliaryLayer() )
164 return;
165
166 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
167 const QgsSymbolLayer::Property key = static_cast< QgsSymbolLayer::Property >( button->propertyKey() );
169
170 // create property in auxiliary storage if necessary
171 if ( !mLayer->auxiliaryLayer()->exists( def ) )
172 mLayer->auxiliaryLayer()->addAuxiliaryField( def );
173
174 // update property with join field name from auxiliary storage
175 QgsProperty property = button->toProperty();
176 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
177 property.setActive( true );
178 button->updateFieldLists();
179 button->setToProperty( property );
180
181 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
182 QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
183 switch ( key )
184 {
186 if ( markerSymbol )
187 markerSymbol->setDataDefinedAngle( button->toProperty() );
188 break;
189
191 if ( markerSymbol )
192 {
193 markerSymbol->setDataDefinedSize( button->toProperty() );
195 }
196 break;
197
199 if ( lineSymbol )
200 lineSymbol->setDataDefinedWidth( button->toProperty() );
201 break;
202
203 default:
204 break;
205 }
206
207 emit changed();
208}
209
210void QgsSymbolsListWidget::createSymbolAuxiliaryField()
211{
212 // try to create an auxiliary layer if not yet created
213 if ( !mLayer->auxiliaryLayer() )
214 {
215 QgsNewAuxiliaryLayerDialog dlg( mLayer, this );
216 dlg.exec();
217 }
218
219 // return if still not exists
220 if ( !mLayer->auxiliaryLayer() )
221 return;
222
223 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
224 const QgsSymbol::Property key = static_cast< QgsSymbol::Property >( button->propertyKey() );
226
227 // create property in auxiliary storage if necessary
228 if ( !mLayer->auxiliaryLayer()->exists( def ) )
229 mLayer->auxiliaryLayer()->addAuxiliaryField( def );
230
231 // update property with join field name from auxiliary storage
232 QgsProperty property = button->toProperty();
233 property.setField( QgsAuxiliaryLayer::nameFromProperty( def, true ) );
234 property.setActive( true );
235 button->updateFieldLists();
236 button->setToProperty( property );
237
238 mSymbol->setDataDefinedProperty( key, button->toProperty() );
239
240 emit changed();
241}
242
244{
245 mContext = context;
246 const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
247 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
248 {
249 unitWidget->setMapCanvas( mContext.mapCanvas() );
250 }
251}
252
254{
255 return mContext;
256}
257
258void QgsSymbolsListWidget::forceRHRToggled( bool checked )
259{
260 if ( !mSymbol )
261 return;
262
263 mSymbol->setForceRHR( checked );
264 emit changed();
265}
266
267void QgsSymbolsListWidget::showAnimationSettings()
268{
270 if ( panel && panel->dockMode() )
271 {
273 widget->setPanelTitle( tr( "Animation Settings" ) );
274 widget->setAnimationSettings( mSymbol->animationSettings() );
275 connect( widget, &QgsPanelWidget::widgetChanged, this, [ this, widget ]()
276 {
277 mSymbol->setAnimationSettings( widget->animationSettings() );
278 emit changed();
279 } );
280 panel->openPanel( widget );
281 return;
282 }
283
285 d.setAnimationSettings( mSymbol->animationSettings() );
286 if ( d.exec() == QDialog::Accepted )
287 {
288 mSymbol->setAnimationSettings( d.animationSettings() );
289 emit changed();
290 }
291}
292
293void QgsSymbolsListWidget::saveSymbol()
294{
295 QgsStyleSaveDialog saveDlg( this );
296 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
297 if ( !saveDlg.exec() )
298 return;
299
300 if ( saveDlg.name().isEmpty() )
301 return;
302
303 QgsStyle *style = saveDlg.destinationStyle();
304 if ( !style )
305 return;
306
307 // check if there is no symbol with same name
308 if ( style->symbolNames().contains( saveDlg.name() ) )
309 {
310 const int res = QMessageBox::warning( this, tr( "Save Symbol" ),
311 tr( "Symbol with name '%1' already exists. Overwrite?" )
312 .arg( saveDlg.name() ),
313 QMessageBox::Yes | QMessageBox::No );
314 if ( res != QMessageBox::Yes )
315 {
316 return;
317 }
318 style->removeSymbol( saveDlg.name() );
319 }
320
321 const QStringList symbolTags = saveDlg.tags().split( ',' );
322
323 // add new symbol to style and re-populate the list
324 QgsSymbol *newSymbol = mSymbol->clone();
325 style->addSymbol( saveDlg.name(), newSymbol );
326
327 // make sure the symbol is stored
328 style->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
329}
330
331void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
332{
333 if ( !mSymbol )
334 return;
335
336 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
337 const QgsSymbol::Property key = static_cast< QgsSymbol::Property >( button->propertyKey() );
338 mSymbol->setDataDefinedProperty( key, button->toProperty() );
339 emit changed();
340}
341
342void QgsSymbolsListWidget::registerSymbolDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbol::Property key )
343{
344 button->init( key, mSymbol ? mSymbol->dataDefinedProperties() : QgsPropertyCollection(), QgsSymbol::propertyDefinitions(), mLayer, true );
345 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsSymbolsListWidget::updateSymbolDataDefinedProperty );
346 connect( button, &QgsPropertyOverrideButton::createAuxiliaryField, this, &QgsSymbolsListWidget::createSymbolAuxiliaryField );
347
349}
350
352{
353 if ( !mSymbol )
354 return;
355
356 mSymbol->setClipFeaturesToExtent( checked );
357 emit changed();
358}
359
360void QgsSymbolsListWidget::setSymbolColor( const QColor &color )
361{
362 mSymbol->setColor( color );
363 emit changed();
364}
365
367{
368 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
369 if ( markerSymbol->angle() == angle )
370 return;
371 markerSymbol->setAngle( angle );
372 emit changed();
373}
374
376{
377 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
378 const QgsProperty dd( mRotationDDBtn->toProperty() );
379
380 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
381
382 const QgsProperty symbolDD( markerSymbol->dataDefinedAngle() );
383
384 if ( // shall we remove datadefined expressions for layers ?
385 ( !symbolDD && !dd )
386 // shall we set the "en masse" expression for properties ?
387 || dd )
388 {
389 markerSymbol->setDataDefinedAngle( dd );
390 emit changed();
391 }
392}
393
395{
396 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
397 if ( markerSymbol->size() == size )
398 return;
399 markerSymbol->setSize( size );
400 emit changed();
401}
402
404{
405 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
406 const QgsProperty dd( mSizeDDBtn->toProperty() );
407
408 spinSize->setEnabled( !mSizeDDBtn->isActive() );
409
410 const QgsProperty symbolDD( markerSymbol->dataDefinedSize() );
411
412 if ( // shall we remove datadefined expressions for layers ?
413 ( !symbolDD && !dd )
414 // shall we set the "en masse" expression for properties ?
415 || dd )
416 {
417 markerSymbol->setDataDefinedSize( dd );
419 emit changed();
420 }
421}
422
424{
425 QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
426 if ( lineSymbol->width() == width )
427 return;
428 lineSymbol->setWidth( width );
429 emit changed();
430}
431
433{
434 QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
435 const QgsProperty dd( mWidthDDBtn->toProperty() );
436
437 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
438
439 const QgsProperty symbolDD( lineSymbol->dataDefinedWidth() );
440
441 if ( // shall we remove datadefined expressions for layers ?
442 ( !symbolDD && !dd )
443 // shall we set the "en masse" expression for properties ?
444 || dd )
445 {
446 lineSymbol->setDataDefinedWidth( dd );
447 emit changed();
448 }
449}
450
451void QgsSymbolsListWidget::updateAssistantSymbol()
452{
453 mAssistantSymbol.reset( mSymbol->clone() );
454 if ( mSymbol->type() == Qgis::SymbolType::Marker )
455 mSizeDDBtn->setSymbol( mAssistantSymbol );
456 else if ( mSymbol->type() == Qgis::SymbolType::Line && mLayer )
457 mWidthDDBtn->setSymbol( mAssistantSymbol );
458}
459
460void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
461{
462 if ( mSymbol )
463 {
464
465 mSymbol->setOutputUnit( mSymbolUnitWidget->unit() );
466 mSymbol->setMapUnitScale( mSymbolUnitWidget->getMapUnitScale() );
467
468 emit changed();
469 }
470}
471
472void QgsSymbolsListWidget::opacityChanged( double opacity )
473{
474 if ( mSymbol )
475 {
476 mSymbol->setOpacity( opacity );
477 emit changed();
478 }
479}
480
481void QgsSymbolsListWidget::updateSymbolColor()
482{
483 mSymbolColorButton->blockSignals( true );
484 mSymbolColorButton->setColor( mSymbol->color() );
485 mSymbolColorButton->blockSignals( false );
486}
487
488QgsExpressionContext QgsSymbolsListWidget::createExpressionContext() const
489{
490 if ( auto *lExpressionContext = mContext.expressionContext() )
491 return QgsExpressionContext( *lExpressionContext );
492
493 //otherwise create a default symbol context
495
496 // additional scopes
497 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
498 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
499 {
500 expContext.appendScope( new QgsExpressionContextScope( scope ) );
501 }
502
503 expContext.setHighlightedVariables( QStringList() << QgsExpressionContext::EXPR_ORIGINAL_VALUE << QgsExpressionContext::EXPR_SYMBOL_COLOR
508 << QStringLiteral( "symbol_layer_count" ) << QStringLiteral( "symbol_layer_index" )
509 << QStringLiteral( "symbol_frame" ) );
510
511 return expContext;
512}
513
514void QgsSymbolsListWidget::updateSymbolInfo()
515{
516 updateSymbolColor();
517
518 const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
519 for ( QgsPropertyOverrideButton *button : overrideButtons )
520 {
522 }
523
524 if ( mSymbol->type() == Qgis::SymbolType::Marker )
525 {
526 QgsMarkerSymbol *markerSymbol = static_cast<QgsMarkerSymbol *>( mSymbol );
527 spinSize->setValue( markerSymbol->size() );
528 spinAngle->setValue( markerSymbol->angle() );
529
530 if ( mLayer )
531 {
532 const QgsProperty ddSize( markerSymbol->dataDefinedSize() );
533 mSizeDDBtn->init( QgsSymbolLayer::PropertySize, ddSize, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
534 spinSize->setEnabled( !mSizeDDBtn->isActive() );
535 const QgsProperty ddAngle( markerSymbol->dataDefinedAngle() );
536 mRotationDDBtn->init( QgsSymbolLayer::PropertyAngle, ddAngle, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
537 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
538 }
539 else
540 {
541 mSizeDDBtn->setEnabled( false );
542 mRotationDDBtn->setEnabled( false );
543 }
544 }
545 else if ( mSymbol->type() == Qgis::SymbolType::Line )
546 {
547 QgsLineSymbol *lineSymbol = static_cast<QgsLineSymbol *>( mSymbol );
548 spinWidth->setValue( lineSymbol->width() );
549
550 if ( mLayer )
551 {
552 const QgsProperty dd( lineSymbol->dataDefinedWidth() );
553 mWidthDDBtn->init( QgsSymbolLayer::PropertyStrokeWidth, dd, QgsSymbolLayer::propertyDefinitions(), mLayer, true );
554 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
555 }
556 else
557 {
558 mWidthDDBtn->setEnabled( false );
559 }
560 }
561
562 mSymbolUnitWidget->blockSignals( true );
563 mSymbolUnitWidget->setUnit( mSymbol->outputUnit() );
564 mSymbolUnitWidget->setMapUnitScale( mSymbol->mapUnitScale() );
565 mSymbolUnitWidget->blockSignals( false );
566
567 mSymbolOpacityWidget->setOpacity( mSymbol->opacity() );
568
569 // Clean up previous advanced symbol actions
570 const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
571 for ( const auto &action : actionList )
572 {
573 if ( mClipFeaturesAction->text() == action->text() )
574 {
575 mStyleItemsListWidget->advancedMenu()->removeAction( action );
576 }
577 else if ( mStandardizeRingsAction->text() == action->text() )
578 {
579 mStyleItemsListWidget->advancedMenu()->removeAction( action );
580 }
581 else if ( mAnimationSettingsAction->text() == action->text() )
582 {
583 mStyleItemsListWidget->advancedMenu()->removeAction( action );
584 }
585 }
586
587 if ( mSymbol->type() == Qgis::SymbolType::Line || mSymbol->type() == Qgis::SymbolType::Fill )
588 {
589 //add clip features option for line or fill symbols
590 mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
591 }
592 if ( mSymbol->type() == Qgis::SymbolType::Fill )
593 {
594 mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
595 }
596 mStyleItemsListWidget->advancedMenu()->addAction( mAnimationSettingsAction );
597
598 mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
599
600 whileBlocking( mClipFeaturesAction )->setChecked( mSymbol->clipFeaturesToExtent() );
601 whileBlocking( mStandardizeRingsAction )->setChecked( mSymbol->forceRHR() );
602}
603
604void QgsSymbolsListWidget::setSymbolFromStyle( const QString &name, QgsStyle::StyleEntity, const QString &stylePath )
605{
606 if ( name.isEmpty() )
607 return;
608
609 QgsStyle *style = nullptr;
610 if ( mStyle != QgsStyle::defaultStyle() )
611 {
612 // get new instance of symbol from style
613 style = mStyle;
614 }
615 else
616 {
617 style = QgsProject::instance()->styleSettings()->styleAtPath( stylePath );
618 }
619
620 if ( !style )
621 return;
622
623 // get new instance of symbol from style
624 std::unique_ptr< QgsSymbol > s( style->symbol( name ) );
625 if ( !s )
626 return;
627
628 // remove all symbol layers from original symbolgroupsCombo
629 while ( mSymbol->symbolLayerCount() )
630 mSymbol->deleteSymbolLayer( 0 );
631 // move all symbol layers to our symbol
632 while ( s->symbolLayerCount() )
633 {
634 QgsSymbolLayer *sl = s->takeSymbolLayer( 0 );
635 mSymbol->appendSymbolLayer( sl );
636 }
637 mSymbol->setOpacity( s->opacity() );
638 mSymbol->setFlags( s->flags() );
639
640 updateSymbolInfo();
641 emit changed();
642}
@ ScaleDiameter
Calculate scale by the diameter.
@ Marker
Marker symbol.
@ Line
Line symbol.
@ Fill
Fill symbol.
@ Hybrid
Hybrid symbol.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
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
void setDataDefinedWidth(const QgsProperty &property) const
Set data defined width for whole symbol (including all symbol layers).
void setWidth(double width) const
Sets the width for the whole line symbol.
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
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) const
Sets the method to use for scaling the marker's size.
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
void setSize(double size) const
Sets the size for the whole symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
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.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
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....
Base class for any widget that can be shown as a inline panel.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
bool dockMode()
Returns the dock mode state.
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:476
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition for a property.
Definition: qgsproperty.h:46
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:230
void setField(const QString &field)
Sets the field name the property references.
void saveEntity()
Emitted when the user has opted to save a new entity to the style database, by clicking the "Save" bu...
void selectionChangedWithStylePath(const QString &name, QgsStyle::StyleEntity type, const QString &stylePath)
Emitted when the selected item is changed in the widget.
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:257
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
Definition: qgsstyle.cpp:291
StyleEntity
Enum for Entities involved in a style.
Definition: qgsstyle.h:179
@ SymbolEntity
Symbols.
Definition: qgsstyle.h:180
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:145
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
Definition: qgsstyle.cpp:221
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
Definition: qgsstyle.cpp:197
QStringList symbolNames() const
Returns a list of names of symbols.
Definition: qgsstyle.cpp:307
A dialog for customising animation settings for a symbol.
A widget for customising animation settings for a symbol.
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets the animation settings to show in the widget.
QgsSymbolAnimationSettings animationSettings() const
Returns the animation settings as defined in the widget.
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:93
Property
Data definable properties.
Definition: qgssymbol.h:130
@ PropertyOpacity
Opacity.
Definition: qgssymbol.h:131
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
Definition: qgssymbol.cpp:1199
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
Definition: qgssymbol.h:622
void setOutputUnit(QgsUnitTypes::RenderUnit unit) const
Sets the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:671
QgsSymbolAnimationSettings & animationSettings()
Returns a reference to the symbol animation settings.
Definition: qgssymbol.cpp:689
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol property definitions.
Definition: qgssymbol.cpp:597
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
Definition: qgssymbol.cpp:779
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:609
void setColor(const QColor &color) const
Sets the color for the symbol.
Definition: qgssymbol.cpp:898
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
Definition: qgssymbol.cpp:647
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:495
void setMapUnitScale(const QgsMapUnitScale &scale) const
Sets the map unit scale for the symbol.
Definition: qgssymbol.cpp:680
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
Definition: qgssymbol.h:552
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
Definition: qgssymbol.h:522
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
Definition: qgssymbol.cpp:789
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Definition: qgssymbol.h:502
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
Definition: qgssymbol.h:215
QColor color() const
Returns the symbol's color.
Definition: qgssymbol.cpp:908
Qgis::SymbolType type() const
Returns the symbol's type.
Definition: qgssymbol.h:152
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
Definition: qgssymbol.cpp:699
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
Definition: qgssymbol.h:574
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
Definition: qgssymbol.h:541
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Definition: qgssymbol.h:563
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.
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
void clipFeaturesToggled(bool checked)
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:2708