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