| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   31 #include <QMessageBox> 
   37   , mAdvancedMenu( menu )
 
   41   spinAngle->setClearValue( 0 );
 
   43   mStyleItemsListWidget->setStyle( mStyle );
 
   46     mStyleItemsListWidget->setSymbolType( mSymbol->
type() );
 
   47   mStyleItemsListWidget->setAdvancedMenu( menu );
 
   49   mClipFeaturesAction = 
new QAction( tr( 
"Clip Features to Canvas Extent" ), 
this );
 
   50   mClipFeaturesAction->setCheckable( 
true );
 
   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 );
 
   64       stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
 
   65       stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
 
   66       mSymbolColorButton = btnMarkerColor;
 
   67       opacityDDBtn = mMarkerOpacityDDBtn;
 
   68       mSymbolOpacityWidget = mMarkerOpacityWidget;
 
   69       mSymbolUnitWidget = mMarkerUnitWidget;
 
   81       stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
 
   82       stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
 
   83       mSymbolColorButton = btnLineColor;
 
   84       opacityDDBtn = mLineOpacityDDBtn;
 
   85       mSymbolOpacityWidget = mLineOpacityWidget;
 
   86       mSymbolUnitWidget = mLineUnitWidget;
 
   95       stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
 
   96       stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
 
   97       mSymbolColorButton = btnFillColor;
 
   98       opacityDDBtn = mFillOpacityDDBtn;
 
   99       mSymbolOpacityWidget = mFillOpacityWidget;
 
  100       mSymbolUnitWidget = mFillUnitWidget;
 
  108   stackedWidget->setCurrentIndex( 0 );
 
  124   updateAssistantSymbol();
 
  128   mSymbolColorButton->
setContext( QStringLiteral( 
"symbology" ) );
 
  140   mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
 
  141   mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
 
  142   mStyleItemsListWidget->advancedMenu()->removeAction( mAnimationSettingsAction );
 
  147   button->setProperty( 
"propertyKey", key );
 
  153 void QgsSymbolsListWidget::createAuxiliaryField()
 
  177   property.setActive( 
true );
 
  210 void QgsSymbolsListWidget::createSymbolAuxiliaryField()
 
  234   property.setActive( 
true );
 
  246   const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
 
  247   for ( QgsUnitSelectionWidget *unitWidget : unitSelectionWidgets )
 
  258 void QgsSymbolsListWidget::forceRHRToggled( 
bool checked )
 
  267 void QgsSymbolsListWidget::showAnimationSettings()
 
  286   if ( d.exec() == QDialog::Accepted )
 
  293 void QgsSymbolsListWidget::saveSymbol()
 
  295   QgsStyleSaveDialog saveDlg( 
this );
 
  296   saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
 
  297   if ( !saveDlg.exec() )
 
  300   if ( saveDlg.name().isEmpty() )
 
  303   QgsStyle *style = saveDlg.destinationStyle();
 
  308   if ( style->
symbolNames().contains( saveDlg.name() ) )
 
  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 )
 
  321   const QStringList symbolTags = saveDlg.tags().split( 
',' );
 
  325   style->
addSymbol( saveDlg.name(), newSymbol );
 
  328   style->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
 
  331 void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
 
  378   const QgsProperty dd( mRotationDDBtn->toProperty() );
 
  380   spinAngle->setEnabled( !mRotationDDBtn->isActive() );
 
  397   if ( markerSymbol->
size() == size )
 
  408   spinSize->setEnabled( !mSizeDDBtn->isActive() );
 
  426   if ( lineSymbol->
width() == width )
 
  437   spinWidth->setEnabled( !mWidthDDBtn->isActive() );
 
  451 void QgsSymbolsListWidget::updateAssistantSymbol()
 
  453   mAssistantSymbol.reset( mSymbol->
clone() );
 
  455     mSizeDDBtn->setSymbol( mAssistantSymbol );
 
  457     mWidthDDBtn->setSymbol( mAssistantSymbol );
 
  460 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
 
  472 void QgsSymbolsListWidget::opacityChanged( 
double opacity )
 
  481 void QgsSymbolsListWidget::updateSymbolColor()
 
  483   mSymbolColorButton->blockSignals( 
true );
 
  485   mSymbolColorButton->blockSignals( 
false );
 
  508                                       << QStringLiteral( 
"symbol_layer_count" ) << QStringLiteral( 
"symbol_layer_index" )
 
  509                                       << QStringLiteral( 
"symbol_frame" ) );
 
  514 void QgsSymbolsListWidget::updateSymbolInfo()
 
  518   const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
 
  527     spinSize->setValue( markerSymbol->
size() );
 
  528     spinAngle->setValue( markerSymbol->
angle() );
 
  534       spinSize->setEnabled( !mSizeDDBtn->isActive() );
 
  537       spinAngle->setEnabled( !mRotationDDBtn->isActive() );
 
  541       mSizeDDBtn->setEnabled( 
false );
 
  542       mRotationDDBtn->setEnabled( 
false );
 
  548     spinWidth->setValue( lineSymbol->
width() );
 
  554       spinWidth->setEnabled( !mWidthDDBtn->isActive() );
 
  558       mWidthDDBtn->setEnabled( 
false );
 
  562   mSymbolUnitWidget->blockSignals( 
true );
 
  563   mSymbolUnitWidget->setUnit( mSymbol->
outputUnit() );
 
  564   mSymbolUnitWidget->setMapUnitScale( mSymbol->
mapUnitScale() );
 
  565   mSymbolUnitWidget->blockSignals( 
false );
 
  570   const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
 
  571   for ( 
const auto &action : actionList )
 
  573     if ( mClipFeaturesAction->text() == action->text() )
 
  575       mStyleItemsListWidget->advancedMenu()->removeAction( action );
 
  577     else if ( mStandardizeRingsAction->text() == action->text() )
 
  579       mStyleItemsListWidget->advancedMenu()->removeAction( action );
 
  581     else if ( mAnimationSettingsAction->text() == action->text() )
 
  583       mStyleItemsListWidget->advancedMenu()->removeAction( action );
 
  590     mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
 
  594     mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
 
  596   mStyleItemsListWidget->advancedMenu()->addAction( mAnimationSettingsAction );
 
  598   mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
 
  604 void QgsSymbolsListWidget::setSymbolFromStyle( 
const QString &name, 
QgsStyle::StyleEntity, 
const QString &stylePath )
 
  606   if ( name.isEmpty() )
 
  610 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) 
  629   std::unique_ptr< QgsSymbol > s( style->
symbol( name ) );
 
  637   while ( s->symbolLayerCount() )
 
  
QList< QgsExpressionContextScope * > globalProjectAtlasMapLayerScopes(const QgsMapLayer *layer) const
Returns list of scopes: global, project, atlas, map, layer.
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
 
QColor color() const
Returns the symbol's color.
 
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
 
A store for object properties.
 
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
 
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
 
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
 
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
 
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
 
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
 
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
 
@ RenderPoints
Points (e.g., for font sizes)
 
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
 
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
 
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
 
@ RenderMillimeters
Millimeters.
 
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
 
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
 
Abstract base class for all rendered symbols.
 
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
 
double angle() const
Returns the marker angle for the whole symbol.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
 
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
 
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
 
@ ScaleDiameter
Calculate scale by the diameter.
 
void setOutputUnit(QgsUnitTypes::RenderUnit unit) const
Sets the units to use for sizes and widths within the symbol.
 
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
 
@ PropertyOpacity
Opacity.
 
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
 
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
 
static QgsStyle * defaultStyle()
Returns default application-wide style.
 
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
 
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
 
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.
 
void setMapUnitScale(const QgsMapUnitScale &scale) const
Sets the map unit scale for the symbol.
 
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol property definitions.
 
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
 
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
 
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
 
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
 
void setField(const QString &field)
Sets the field name the property references.
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
 
Qgis::SymbolType type() const
Returns the symbol's type.
 
A marker symbol type, for rendering Point and MultiPoint geometries.
 
@ PropertySize
Symbol size.
 
A line symbol type, for rendering LineString and MultiLineString geometries.
 
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
 
Definition for a property.
 
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
 
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
 
@ PropertyStrokeWidth
Stroke width.
 
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
 
static const QString EXPR_GEOMETRY_RING_NUM
Inbuilt variable name for geometry ring number variable.
 
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
 
Single scope for storing variables and functions for use within a QgsExpressionContext....
 
A dialog for customising animation settings for a symbol.
 
QStringList symbolNames() const
Returns a list of names of symbols.
 
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
 
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
 
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
 
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
 
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
 
QgsSymbol * symbol()
Returns the symbol that is currently active in the widget.
 
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
 
Property
Data definable properties.
 
Represents a vector layer which manages a vector based data sets.
 
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
 
void setWidth(double width) const
Sets the width for the whole line symbol.
 
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
 
void setSize(double size) const
Sets the size for the whole symbol.
 
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
 
@ PropertyAngle
Symbol angle.
 
@ RenderMetersInMapUnits
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.
 
QgsSymbolAnimationSettings & animationSettings()
Returns a reference to the symbol animation settings.
 
Property
Data definable properties.
 
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
 
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
 
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
 
void setDataDefinedWidth(const QgsProperty &property) const
Set data defined width for whole symbol (including all symbol layers).
 
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
 
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)
 
void setColor(const QColor &color) const
Sets the color for the symbol.
 
bool forceRHR() const
Returns true if polygon features drawn by the symbol will be reoriented to follow the standard right-...
 
@ RenderMapUnits
Map units.
 
A dialog to create a new auxiliary layer.
 
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
 
int symbolLayerCount() const
Returns the total number of symbol layers contained in the symbol.
 
StyleEntity
Enum for Entities involved in a style.