25 #include <QMessageBox> 31 , mAdvancedMenu( menu )
36 spinAngle->setClearValue( 0 );
41 mStyleItemsListWidget->setStyle( mStyle );
44 mStyleItemsListWidget->setSymbolType( mSymbol->
type() );
45 mStyleItemsListWidget->setAdvancedMenu( menu );
47 mClipFeaturesAction =
new QAction( tr(
"Clip Features to Canvas Extent" ),
this );
48 mClipFeaturesAction->setCheckable(
true );
50 mStandardizeRingsAction =
new QAction( tr(
"Force Right-Hand-Rule Orientation" ),
this );
51 mStandardizeRingsAction->setCheckable(
true );
52 connect( mStandardizeRingsAction, &QAction::toggled,
this, &QgsSymbolsListWidget::forceRHRToggled );
61 stackedWidget->setCurrentIndex( symbol->
type() );
75 updateAssistantSymbol();
77 btnColor->setAllowOpacity(
true );
78 btnColor->setColorDialogTitle( tr(
"Select Color" ) );
79 btnColor->setContext( QStringLiteral(
"symbology" ) );
91 mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
92 mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
97 button->setProperty(
"propertyKey", key );
103 void QgsSymbolsListWidget::createAuxiliaryField()
127 property.setActive(
true );
163 const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
164 for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
171 if ( ddButton->assistant() )
172 ddButton->assistant()->setMapCanvas( mContext.
mapCanvas() );
182 void QgsSymbolsListWidget::forceRHRToggled(
bool checked )
191 void QgsSymbolsListWidget::saveSymbol()
196 QgsStyleSaveDialog saveDlg(
this );
197 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
198 if ( !saveDlg.exec() )
201 if ( saveDlg.name().isEmpty() )
205 if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
207 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ),
208 tr(
"Symbol with name '%1' already exists. Overwrite?" )
209 .arg( saveDlg.name() ),
210 QMessageBox::Yes | QMessageBox::No );
211 if ( res != QMessageBox::Yes )
218 QStringList symbolTags = saveDlg.tags().split(
',' );
224 mStyle->
saveSymbol( saveDlg.name(), mSymbol->
clone(), saveDlg.isFavorite(), symbolTags );
256 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
273 if ( markerSymbol->
size() == size )
284 spinSize->setEnabled( !mSizeDDBtn->isActive() );
302 if ( lineSymbol->
width() == width )
313 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
327 void QgsSymbolsListWidget::updateAssistantSymbol()
329 mAssistantSymbol.reset( mSymbol->
clone() );
331 mSizeDDBtn->setSymbol( mAssistantSymbol );
333 mWidthDDBtn->setSymbol( mAssistantSymbol );
336 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
348 void QgsSymbolsListWidget::opacityChanged(
double opacity )
357 void QgsSymbolsListWidget::updateSymbolColor()
359 btnColor->blockSignals(
true );
360 btnColor->setColor( mSymbol->
color() );
361 btnColor->blockSignals(
false );
387 void QgsSymbolsListWidget::updateSymbolInfo()
391 const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
400 spinSize->setValue( markerSymbol->
size() );
401 spinAngle->setValue( markerSymbol->
angle() );
407 spinSize->setEnabled( !mSizeDDBtn->isActive() );
410 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
414 mSizeDDBtn->setEnabled(
false );
415 mRotationDDBtn->setEnabled(
false );
421 spinWidth->setValue( lineSymbol->
width() );
427 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
431 mWidthDDBtn->setEnabled(
false );
435 mSymbolUnitWidget->blockSignals(
true );
436 mSymbolUnitWidget->setUnit( mSymbol->
outputUnit() );
437 mSymbolUnitWidget->setMapUnitScale( mSymbol->
mapUnitScale() );
438 mSymbolUnitWidget->blockSignals(
false );
440 mOpacityWidget->setOpacity( mSymbol->
opacity() );
443 const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
444 for (
const auto &action : actionList )
446 if ( mClipFeaturesAction->text() == action->text() )
448 mStyleItemsListWidget->advancedMenu()->removeAction( action );
450 else if ( mStandardizeRingsAction->text() == action->text() )
452 mStyleItemsListWidget->advancedMenu()->removeAction( action );
459 mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
463 mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
466 mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
475 std::unique_ptr< QgsSymbol > s( mStyle->
symbol( name ) );
483 while ( s->symbolLayerCount() )
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.
Meters value as Map units.
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
Calculate scale by the diameter.
Abstract base class for all rendered symbols.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
void setSize(double size)
Sets the size for the whole symbol.
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
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)
A marker symbol type, for rendering Point and MultiPoint geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
StyleEntity
Enum for Entities involved in a style.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
A dialog to create a new auxiliary layer.
void setField(const QString &field)
Sets the field name the property references.
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
void setWidth(double width)
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...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QColor color() const
Returns the symbol's color.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
Definition for a property.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
Points (e.g., for font sizes)
SymbolType type() const
Returns the symbol's type.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
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.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the DB with the tags.
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
qreal opacity() const
Returns the opacity for the symbol.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
Represents a vector layer which manages a vector based data sets.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
double angle() const
Returns the marker angle for the whole symbol.
Property
Data definable properties.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
void setColor(const QColor &color)
Sets the color for the symbol.
QStringList symbolNames() const
Returns a list of names of symbols.