25 #include <QMessageBox>
31 , mAdvancedMenu( menu )
35 spinAngle->setClearValue( 0 );
37 mStyleItemsListWidget->setStyle( mStyle );
40 mStyleItemsListWidget->setSymbolType( mSymbol->
type() );
41 mStyleItemsListWidget->setAdvancedMenu( menu );
43 mClipFeaturesAction =
new QAction( tr(
"Clip Features to Canvas Extent" ),
this );
44 mClipFeaturesAction->setCheckable(
true );
46 mStandardizeRingsAction =
new QAction( tr(
"Force Right-Hand-Rule Orientation" ),
this );
47 mStandardizeRingsAction->setCheckable(
true );
48 connect( mStandardizeRingsAction, &QAction::toggled,
this, &QgsSymbolsListWidget::forceRHRToggled );
53 switch ( symbol->
type() )
57 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
58 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
59 mSymbolColorButton = btnMarkerColor;
60 opacityDDBtn = mMarkerOpacityDDBtn;
61 mSymbolOpacityWidget = mMarkerOpacityWidget;
62 mSymbolUnitWidget = mMarkerUnitWidget;
74 stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
75 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
76 mSymbolColorButton = btnLineColor;
77 opacityDDBtn = mLineOpacityDDBtn;
78 mSymbolOpacityWidget = mLineOpacityWidget;
79 mSymbolUnitWidget = mLineUnitWidget;
88 stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
89 stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
90 mSymbolColorButton = btnFillColor;
91 opacityDDBtn = mFillOpacityDDBtn;
92 mSymbolOpacityWidget = mFillOpacityWidget;
93 mSymbolUnitWidget = mFillUnitWidget;
101 stackedWidget->setCurrentIndex( 0 );
117 updateAssistantSymbol();
121 mSymbolColorButton->
setContext( QStringLiteral(
"symbology" ) );
133 mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
134 mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
139 button->setProperty(
"propertyKey", key );
145 void QgsSymbolsListWidget::createAuxiliaryField()
169 property.setActive(
true );
202 void QgsSymbolsListWidget::createSymbolAuxiliaryField()
226 property.setActive(
true );
238 const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
246 if ( ddButton->assistant() )
247 ddButton->assistant()->setMapCanvas( mContext.
mapCanvas() );
257 void QgsSymbolsListWidget::forceRHRToggled(
bool checked )
266 void QgsSymbolsListWidget::saveSymbol()
272 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
273 if ( !saveDlg.exec() )
276 if ( saveDlg.name().isEmpty() )
280 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
282 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
283 tr(
"Symbol with name '%1' already exists. Overwrite?" )
284 .arg( saveDlg.name() ),
285 QMessageBox::Yes | QMessageBox::No );
286 if ( res != QMessageBox::Yes )
293 QStringList symbolTags = saveDlg.tags().split(
',' );
297 mStyle->
addSymbol( saveDlg.name(), newSymbol );
300 mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
303 void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
352 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
369 if ( markerSymbol->
size() == size )
380 spinSize->setEnabled( !mSizeDDBtn->isActive() );
398 if ( lineSymbol->
width() == width )
409 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
423 void QgsSymbolsListWidget::updateAssistantSymbol()
425 mAssistantSymbol.reset( mSymbol->
clone() );
427 mSizeDDBtn->setSymbol( mAssistantSymbol );
429 mWidthDDBtn->setSymbol( mAssistantSymbol );
432 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
444 void QgsSymbolsListWidget::opacityChanged(
double opacity )
453 void QgsSymbolsListWidget::updateSymbolColor()
455 mSymbolColorButton->blockSignals(
true );
457 mSymbolColorButton->blockSignals(
false );
479 << QStringLiteral(
"symbol_layer_count" ) << QStringLiteral(
"symbol_layer_index" ) );
484 void QgsSymbolsListWidget::updateSymbolInfo()
488 const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
497 spinSize->setValue( markerSymbol->
size() );
498 spinAngle->setValue( markerSymbol->
angle() );
504 spinSize->setEnabled( !mSizeDDBtn->isActive() );
507 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
511 mSizeDDBtn->setEnabled(
false );
512 mRotationDDBtn->setEnabled(
false );
518 spinWidth->setValue( lineSymbol->
width() );
524 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
528 mWidthDDBtn->setEnabled(
false );
532 mSymbolUnitWidget->blockSignals(
true );
535 mSymbolUnitWidget->blockSignals(
false );
540 const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
541 for (
const auto &action : actionList )
543 if ( mClipFeaturesAction->text() == action->text() )
545 mStyleItemsListWidget->advancedMenu()->removeAction( action );
547 else if ( mStandardizeRingsAction->text() == action->text() )
549 mStyleItemsListWidget->advancedMenu()->removeAction( action );
556 mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
560 mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
563 mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
572 std::unique_ptr< QgsSymbol > s( mStyle->
symbol( name ) );
580 while ( s->symbolLayerCount() )
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
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_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.
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
void setWidth(double width)
Sets the width for the whole line symbol.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
void setSize(double size)
Sets the size for the whole symbol.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
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.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
A dialog to create a new auxiliary layer.
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.
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.
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.
Property
Data definable properties.
@ PropertyOpacity
Opacity.
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
@ ScaleDiameter
Calculate scale by the diameter.
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.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
SymbolType type() const
Returns the symbol's type.
qreal opacity() const
Returns the opacity for the symbol.
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
void setColor(const QColor &color)
Sets the color for the symbol.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
QColor color() const
Returns the symbol's color.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this 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...
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
@ RenderMetersInMapUnits
Meters value as Map units.
@ RenderPoints
Points (e.g., for font sizes)
@ RenderMillimeters
Millimeters.
@ RenderMapUnits
Map units.
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)
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.