29 #include <QMessageBox> 
   35   , mAdvancedMenu( menu )
 
   39   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 );
 
   57   switch ( symbol->
type() )
 
   61       stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
 
   62       stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
 
   63       mSymbolColorButton = btnMarkerColor;
 
   64       opacityDDBtn = mMarkerOpacityDDBtn;
 
   65       mSymbolOpacityWidget = mMarkerOpacityWidget;
 
   66       mSymbolUnitWidget = mMarkerUnitWidget;
 
   78       stackedWidget->removeWidget( stackedWidget->widget( 2 ) );
 
   79       stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
 
   80       mSymbolColorButton = btnLineColor;
 
   81       opacityDDBtn = mLineOpacityDDBtn;
 
   82       mSymbolOpacityWidget = mLineOpacityWidget;
 
   83       mSymbolUnitWidget = mLineUnitWidget;
 
   92       stackedWidget->removeWidget( stackedWidget->widget( 1 ) );
 
   93       stackedWidget->removeWidget( stackedWidget->widget( 0 ) );
 
   94       mSymbolColorButton = btnFillColor;
 
   95       opacityDDBtn = mFillOpacityDDBtn;
 
   96       mSymbolOpacityWidget = mFillOpacityWidget;
 
   97       mSymbolUnitWidget = mFillUnitWidget;
 
  105   stackedWidget->setCurrentIndex( 0 );
 
  121   updateAssistantSymbol();
 
  125   mSymbolColorButton->
setContext( QStringLiteral( 
"symbology" ) );
 
  137   mStyleItemsListWidget->advancedMenu()->removeAction( mClipFeaturesAction );
 
  138   mStyleItemsListWidget->advancedMenu()->removeAction( mStandardizeRingsAction );
 
  143   button->setProperty( 
"propertyKey", key );
 
  149 void QgsSymbolsListWidget::createAuxiliaryField()
 
  173   property.setActive( 
true );
 
  206 void QgsSymbolsListWidget::createSymbolAuxiliaryField()
 
  230   property.setActive( 
true );
 
  242   const auto unitSelectionWidgets { findChildren<QgsUnitSelectionWidget *>() };
 
  254 void QgsSymbolsListWidget::forceRHRToggled( 
bool checked )
 
  263 void QgsSymbolsListWidget::saveSymbol()
 
  269   saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
 
  270   if ( !saveDlg.exec() )
 
  273   if ( saveDlg.name().isEmpty() )
 
  277   if ( mStyle->
symbolNames().contains( saveDlg.name() ) )
 
  279     int res = QMessageBox::warning( 
this, tr( 
"Save Symbol" ),
 
  280                                     tr( 
"Symbol with name '%1' already exists. Overwrite?" )
 
  281                                     .arg( saveDlg.name() ),
 
  282                                     QMessageBox::Yes | QMessageBox::No );
 
  283     if ( res != QMessageBox::Yes )
 
  290   QStringList symbolTags = saveDlg.tags().split( 
',' );
 
  294   mStyle->
addSymbol( saveDlg.name(), newSymbol );
 
  297   mStyle->
saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
 
  300 void QgsSymbolsListWidget::updateSymbolDataDefinedProperty()
 
  349   spinAngle->setEnabled( !mRotationDDBtn->isActive() );
 
  366   if ( markerSymbol->
size() == size )
 
  377   spinSize->setEnabled( !mSizeDDBtn->isActive() );
 
  395   if ( lineSymbol->
width() == width )
 
  406   spinWidth->setEnabled( !mWidthDDBtn->isActive() );
 
  420 void QgsSymbolsListWidget::updateAssistantSymbol()
 
  422   mAssistantSymbol.reset( mSymbol->
clone() );
 
  424     mSizeDDBtn->setSymbol( mAssistantSymbol );
 
  426     mWidthDDBtn->setSymbol( mAssistantSymbol );
 
  429 void QgsSymbolsListWidget::mSymbolUnitWidget_changed()
 
  441 void QgsSymbolsListWidget::opacityChanged( 
double opacity )
 
  450 void QgsSymbolsListWidget::updateSymbolColor()
 
  452   mSymbolColorButton->blockSignals( 
true );
 
  454   mSymbolColorButton->blockSignals( 
false );
 
  477                                       << QStringLiteral( 
"symbol_layer_count" ) << QStringLiteral( 
"symbol_layer_index" ) );
 
  482 void QgsSymbolsListWidget::updateSymbolInfo()
 
  486   const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
 
  495     spinSize->setValue( markerSymbol->
size() );
 
  496     spinAngle->setValue( markerSymbol->
angle() );
 
  502       spinSize->setEnabled( !mSizeDDBtn->isActive() );
 
  505       spinAngle->setEnabled( !mRotationDDBtn->isActive() );
 
  509       mSizeDDBtn->setEnabled( 
false );
 
  510       mRotationDDBtn->setEnabled( 
false );
 
  516     spinWidth->setValue( lineSymbol->
width() );
 
  522       spinWidth->setEnabled( !mWidthDDBtn->isActive() );
 
  526       mWidthDDBtn->setEnabled( 
false );
 
  530   mSymbolUnitWidget->blockSignals( 
true );
 
  533   mSymbolUnitWidget->blockSignals( 
false );
 
  538   const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
 
  539   for ( 
const auto &action : actionList )
 
  541     if ( mClipFeaturesAction->text() == action->text() )
 
  543       mStyleItemsListWidget->advancedMenu()->removeAction( action );
 
  545     else if ( mStandardizeRingsAction->text() == action->text() )
 
  547       mStyleItemsListWidget->advancedMenu()->removeAction( action );
 
  554     mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
 
  558     mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
 
  561   mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
 
  570   std::unique_ptr< QgsSymbol > s( mStyle->
symbol( name ) );
 
  578   while ( s->symbolLayerCount() )
 
@ ScaleDiameter
Calculate scale by the diameter.
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_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.
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.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
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.
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.
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.
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.
void setFlags(Qgis::SymbolFlags flags)
Sets flags for the symbol.
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.
Qgis::SymbolType type() const
Returns the symbol's type.
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.