QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
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 );
383 << QStringLiteral(
"symbol_layer_count" ) << QStringLiteral(
"symbol_layer_index" ) );
388 void QgsSymbolsListWidget::updateSymbolInfo()
392 const auto overrideButtons {findChildren< QgsPropertyOverrideButton * >()};
401 spinSize->setValue( markerSymbol->
size() );
402 spinAngle->setValue( markerSymbol->
angle() );
408 spinSize->setEnabled( !mSizeDDBtn->isActive() );
411 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
415 mSizeDDBtn->setEnabled(
false );
416 mRotationDDBtn->setEnabled(
false );
422 spinWidth->setValue( lineSymbol->
width() );
428 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
432 mWidthDDBtn->setEnabled(
false );
436 mSymbolUnitWidget->blockSignals(
true );
437 mSymbolUnitWidget->setUnit( mSymbol->
outputUnit() );
438 mSymbolUnitWidget->setMapUnitScale( mSymbol->
mapUnitScale() );
439 mSymbolUnitWidget->blockSignals(
false );
441 mOpacityWidget->setOpacity( mSymbol->
opacity() );
444 const QList<QAction *> actionList( mStyleItemsListWidget->advancedMenu()->actions() );
445 for (
const auto &action : actionList )
447 if ( mClipFeaturesAction->text() == action->text() )
449 mStyleItemsListWidget->advancedMenu()->removeAction( action );
451 else if ( mStandardizeRingsAction->text() == action->text() )
453 mStyleItemsListWidget->advancedMenu()->removeAction( action );
460 mStyleItemsListWidget->advancedMenu()->addAction( mClipFeaturesAction );
464 mStyleItemsListWidget->advancedMenu()->addAction( mStandardizeRingsAction );
467 mStyleItemsListWidget->showAdvancedButton( mAdvancedMenu || !mStyleItemsListWidget->advancedMenu()->isEmpty() );
476 std::unique_ptr< QgsSymbol > s( mStyle->
symbol( name ) );
484 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...
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
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.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
@ ScaleDiameter
Calculate scale by the diameter.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
@ RenderMillimeters
Millimeters.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
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.
double angle() const
Returns the marker angle for the whole symbol.
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.
void setWidth(double width)
Sets the width for the whole line symbol.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
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.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within 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.
@ PropertySize
Symbol size.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
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 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....
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.
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
bool removeSymbol(const QString &name)
Removes symbol from style (and delete it)
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
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.
void setColor(const QColor &color)
Sets the color for the symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
@ 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.
SymbolType type() const
Returns the symbol's type.
Property
Data definable properties.
bool saveSymbol(const QString &name, QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
QList< QgsUnitTypes::RenderUnit > RenderUnitList
List of render units.
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)
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.
void setSize(double size)
Sets the size for the whole symbol.
StyleEntity
Enum for Entities involved in a style.