17#include "moc_qgssymbolslistwidget.cpp"
38 , mAdvancedMenu( menu )
42 spinAngle->setClearValue( 0 );
44 mStyleItemsListWidget->setStyle( mStyle );
47 mStyleItemsListWidget->setSymbolType( mSymbol->
type() );
48 mStyleItemsListWidget->setAdvancedMenu( menu );
50 mClipFeaturesAction =
new QAction( tr(
"Clip Features to Canvas Extent" ),
this );
51 mClipFeaturesAction->setCheckable(
true );
53 mStandardizeRingsAction =
new QAction( tr(
"Force Right-Hand-Rule Orientation" ),
this );
54 mStandardizeRingsAction->setCheckable(
true );
55 connect( mStandardizeRingsAction, &QAction::toggled,
this, &QgsSymbolsListWidget::forceRHRToggled );
57 mBufferSettingsAction =
new QAction( tr(
"Buffer Settings…" ),
this );
58 connect( mBufferSettingsAction, &QAction::triggered,
this, &QgsSymbolsListWidget::showBufferSettings );
60 mAnimationSettingsAction =
new QAction( tr(
"Animation Settings…" ),
this );
61 connect( mAnimationSettingsAction, &QAction::triggered,
this, &QgsSymbolsListWidget::showAnimationSettings );
63 mExtentBufferAction =
new QAction( tr(
"Extent Buffer…" ),
this );
64 connect( mExtentBufferAction, &QAction::triggered,
this, &QgsSymbolsListWidget::showExtentBufferSettings );
68 switch ( symbol->
type() )
72 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
73 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
74 mSymbolColorButton = btnMarkerColor;
75 opacityDDBtn = mMarkerOpacityDDBtn;
76 mSymbolOpacityWidget = mMarkerOpacityWidget;
77 mSymbolUnitWidget = mMarkerUnitWidget;
89 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
90 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
91 mSymbolColorButton = btnLineColor;
92 opacityDDBtn = mLineOpacityDDBtn;
93 mSymbolOpacityWidget = mLineOpacityWidget;
94 mSymbolUnitWidget = mLineUnitWidget;
103 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
104 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
105 mSymbolColorButton = btnFillColor;
106 opacityDDBtn = mFillOpacityDDBtn;
107 mSymbolOpacityWidget = mFillOpacityWidget;
108 mSymbolUnitWidget = mFillUnitWidget;
116 stackedWidget->setCurrentIndex( 0 );
131 updateAssistantSymbol();
135 mSymbolColorButton->
setContext( QStringLiteral(
"symbology" ) );
147 mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
148 mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
149 mStyleItemsListWidget->advancedMenu()->removeAction( mAnimationSettingsAction );
150 mStyleItemsListWidget->advancedMenu()->removeAction( mExtentBufferAction );
151 mStyleItemsListWidget->advancedMenu()->removeAction( mBufferSettingsAction );
156 button->setProperty(
"propertyKey",
static_cast<int>( key ) );
162void QgsSymbolsListWidget::createAuxiliaryField()
186 property.setActive(
true );
219void QgsSymbolsListWidget::createSymbolAuxiliaryField()
243 property.setActive(
true );
255 const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
267void QgsSymbolsListWidget::forceRHRToggled(
bool checked )
276void QgsSymbolsListWidget::showAnimationSettings()
294 if ( d.exec() == QDialog::Accepted )
301void QgsSymbolsListWidget::showExtentBufferSettings()
326 dlg.setContext( mContext );
329 if ( dlg.exec() == QDialog::Accepted )
340void QgsSymbolsListWidget::showBufferSettings()
360 d.setBufferSettings( *settings );
361 if ( d.exec() == QDialog::Accepted )
368void QgsSymbolsListWidget::saveSymbol()
371 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
372 if ( !saveDlg.exec() )
375 if ( saveDlg.name().isEmpty() )
378 QgsStyle *style = saveDlg.destinationStyle();
383 if ( style->
symbolNames().contains( saveDlg.name() ) )
385 const int res = QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Symbol with name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
386 if ( res != QMessageBox::Yes )
393 const QStringList symbolTags = saveDlg.tags().split(
',' );
397 style->
addSymbol( saveDlg.name(), newSymbol );
400 style->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
403void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
441 if ( markerSymbol->
angle() == angle )
450 const QgsProperty dd( mRotationDDBtn->toProperty() );
452 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
470 if ( markerSymbol->
size() == size )
481 spinSize->setEnabled( !mSizeDDBtn->isActive() );
500 if ( lineSymbol->
width() == width )
511 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
526void QgsSymbolsListWidget::updateAssistantSymbol()
528 mAssistantSymbol.reset( mSymbol->
clone() );
530 mSizeDDBtn->setSymbol( mAssistantSymbol );
532 mWidthDDBtn->setSymbol( mAssistantSymbol );
535void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
546void QgsSymbolsListWidget::opacityChanged(
double opacity )
555void QgsSymbolsListWidget::updateSymbolColor()
557 mSymbolColorButton->blockSignals(
true );
559 mSymbolColorButton->blockSignals(
false );
582void QgsSymbolsListWidget::updateSymbolInfo()
586 const auto overrideButtons { findChildren<QgsPropertyOverrideButton *>() };
595 spinSize->setValue( markerSymbol->
size() );
596 spinAngle->setValue( markerSymbol->
angle() );
602 spinSize->setEnabled( !mSizeDDBtn->isActive() );
605 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
609 mSizeDDBtn->setEnabled(
false );
610 mRotationDDBtn->setEnabled(
false );
616 spinWidth->setValue( lineSymbol->
width() );
622 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
626 mWidthDDBtn->setEnabled(
false );
630 mSymbolUnitWidget->blockSignals(
true );
633 mSymbolUnitWidget->blockSignals(
false );
638 const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
639 for ( QAction *action : actionList )
641 for ( QAction *actionsToRemove :
644 mStandardizeRingsAction,
645 mAnimationSettingsAction,
647 mBufferSettingsAction
650 if ( actionsToRemove->text() == action->text() )
652 mStyleItemsListWidget->advancedMenu()->removeAction( action );
661 mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
665 mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
669 mStyleItemsListWidget->advancedMenu()->addAction( mBufferSettingsAction );
671 mStyleItemsListWidget->advancedMenu()->addAction( mAnimationSettingsAction );
672 mStyleItemsListWidget->advancedMenu()->addAction( mExtentBufferAction );
674 mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
680void QgsSymbolsListWidget::setSymbolFromStyle(
const QString &name,
QgsStyle::StyleEntity,
const QString &stylePath )
682 if ( name.isEmpty() )
700 std::unique_ptr<QgsSymbol> s( style->
symbol( name ) );
708 while ( s->symbolLayerCount() )
@ ScaleDiameter
Calculate scale by the diameter.
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
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.
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 dialog which allows the user to modify the extent buffer of a symbol.
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.
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.
A store for object properties.
void setField(const QString &field)
Sets the field name the property references.
a dialog for setting properties of a newly saved style.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
StyleEntity
Enum for Entities involved in a style.
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QStringList symbolNames() const
Returns a list of names of symbols.
A dialog for customising animation settings for a symbol.
A dialog for customising buffer settings for a symbol.
Contains settings relating to symbol buffers, which draw a "halo" effect around the symbol.
Property
Data definable properties.
@ StrokeWidth
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.
void setOutputUnit(Qgis::RenderUnit unit) const
Sets the units to use for sizes and widths within the symbol.
Property
Data definable properties.
@ ExtentBuffer
Extent buffer.
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.
void setExtentBuffer(double extentBuffer)
Sets the symbol's extent buffer.
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.
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.
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
void setExtentBufferSizeUnit(Qgis::RenderUnit unit)
Sets the unit used for the extent buffer.
QgsSymbolBufferSettings * bufferSettings()
Returns the symbol buffer settings, which control an optional "halo" effect around the symbol.
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
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.
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.
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
void setBufferSettings(QgsSymbolBufferSettings *settings)
Sets a the symbol buffer settings, which control an optional "halo" effect around the symbol.
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent.
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
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.