QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
qgsrendererwidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrendererwidget.cpp
3 ---------------------
4 begin : November 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15#include "qgsrendererwidget.h"
16
18#include "qgssymbol.h"
19#include "qgsvectorlayer.h"
20#include "qgscolordialog.h"
22#include "qgssymbollayer.h"
23#include "qgsmapcanvas.h"
24#include "qgspanelwidget.h"
25#include "qgsproject.h"
27#include "qgssymbollayerutils.h"
29#include "qgsmarkersymbol.h"
30#include "qgslinesymbol.h"
31
32#include <QMessageBox>
33#include <QInputDialog>
34#include <QMenu>
35#include <QClipboard>
36
38 : mLayer( layer )
39 , mStyle( style )
40{
41 contextMenu = new QMenu( tr( "Renderer Options" ), this );
42
43 mCopyAction = new QAction( tr( "Copy" ), this );
44 connect( mCopyAction, &QAction::triggered, this, &QgsRendererWidget::copy );
45 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
46 mPasteAction = new QAction( tr( "Paste" ), this );
47 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
48 connect( mPasteAction, &QAction::triggered, this, &QgsRendererWidget::paste );
49
50 mCopySymbolAction = new QAction( tr( "Copy Symbol" ), this );
51 contextMenu->addAction( mCopySymbolAction );
52 connect( mCopySymbolAction, &QAction::triggered, this, &QgsRendererWidget::copySymbol );
53 mPasteSymbolAction = new QAction( tr( "Paste Symbol" ), this );
54 contextMenu->addAction( mPasteSymbolAction );
55 connect( mPasteSymbolAction, &QAction::triggered, this, &QgsRendererWidget::pasteSymbolToSelection );
56
57 contextMenu->addSeparator();
58 contextMenu->addAction( tr( "Change Color…" ), this, SLOT( changeSymbolColor() ) );
59 contextMenu->addAction( tr( "Change Opacity…" ), this, SLOT( changeSymbolOpacity() ) );
60 contextMenu->addAction( tr( "Change Output Unit…" ), this, SLOT( changeSymbolUnit() ) );
61
63 {
64 contextMenu->addAction( tr( "Change Width…" ), this, SLOT( changeSymbolWidth() ) );
65 }
67 {
68 contextMenu->addAction( tr( "Change Size…" ), this, SLOT( changeSymbolSize() ) );
69 contextMenu->addAction( tr( "Change Angle…" ), this, SLOT( changeSymbolAngle() ) );
70 }
71
72 connect( contextMenu, &QMenu::aboutToShow, this, [ = ]
73 {
74 const std::unique_ptr< QgsSymbol > tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
75 mPasteSymbolAction->setEnabled( static_cast< bool >( tempSymbol ) );
76 } );
77}
78
80{
81 contextMenu->exec( QCursor::pos() );
82}
83
85{
86 const QList<QgsSymbol *> symbolList = selectedSymbols();
87 if ( symbolList.isEmpty() )
88 {
89 return;
90 }
91
92 QgsSymbol *firstSymbol = nullptr;
93 for ( QgsSymbol *symbol : symbolList )
94 {
95 if ( symbol )
96 {
97 firstSymbol = symbol;
98 break;
99 }
100 }
101 if ( !firstSymbol )
102 return;
103
104 const QColor currentColor = firstSymbol->color();
105
106 QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( qobject_cast< QWidget * >( parent() ) );
107 if ( panel && panel->dockMode() )
108 {
110 colorWidget->setPanelTitle( tr( "Change Symbol Color" ) );
111 colorWidget->setAllowOpacity( true );
112 connect( colorWidget, &QgsCompoundColorWidget::currentColorChanged, this, [ = ]( const QColor & color )
113 {
114 for ( QgsSymbol *symbol : symbolList )
115 {
116 if ( symbol )
117 symbol->setColor( color );
118 }
120 } );
121 panel->openPanel( colorWidget );
122 }
123 else
124 {
125 // modal dialog version... yuck
126 const QColor color = QgsColorDialog::getColor( firstSymbol->color(), this, QStringLiteral( "Change Symbol Color" ), true );
127 if ( color.isValid() )
128 {
129 for ( QgsSymbol *symbol : symbolList )
130 {
131 if ( symbol )
132 symbol->setColor( color );
133 }
135 }
136 }
137}
138
140{
141 const QList<QgsSymbol *> symbolList = selectedSymbols();
142 if ( symbolList.isEmpty() )
143 {
144 return;
145 }
146
147 QgsSymbol *firstSymbol = nullptr;
148 const auto constSymbolList = symbolList;
149 for ( QgsSymbol *symbol : constSymbolList )
150 {
151 if ( symbol )
152 {
153 firstSymbol = symbol;
154 break;
155 }
156 }
157 if ( !firstSymbol )
158 return;
159
160 bool ok;
161 const double oldOpacity = firstSymbol->opacity() * 100; // convert to %
162 const double opacity = QInputDialog::getDouble( this, tr( "Opacity" ), tr( "Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
163 if ( ok )
164 {
165 const auto constSymbolList = symbolList;
166 for ( QgsSymbol *symbol : constSymbolList )
167 {
168 if ( symbol )
169 symbol->setOpacity( opacity / 100.0 );
170 }
172 }
173}
174
176{
177 const QList<QgsSymbol *> symbolList = selectedSymbols();
178 if ( symbolList.isEmpty() )
179 {
180 return;
181 }
182
183 QgsSymbol *firstSymbol = nullptr;
184 const auto constSymbolList = symbolList;
185 for ( QgsSymbol *symbol : constSymbolList )
186 {
187 if ( symbol )
188 {
189 firstSymbol = symbol;
190 break;
191 }
192 }
193 if ( !firstSymbol )
194 return;
195
196 bool ok;
197 const int currentUnit = ( firstSymbol->outputUnit() == Qgis::RenderUnit::Millimeters ) ? 0 : 1;
198 const QString item = QInputDialog::getItem( this, tr( "Symbol unit" ), tr( "Select symbol unit" ), QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), currentUnit, false, &ok );
199 if ( ok )
200 {
201 const Qgis::RenderUnit unit = ( item.compare( tr( "Millimeter" ) ) == 0 ) ? Qgis::RenderUnit::Millimeters : Qgis::RenderUnit::MapUnits;
202
203 const auto constSymbolList = symbolList;
204 for ( QgsSymbol *symbol : constSymbolList )
205 {
206 if ( symbol )
207 symbol->setOutputUnit( unit );
208 }
210 }
211}
212
214{
215 const QList<QgsSymbol *> symbolList = selectedSymbols();
216 if ( symbolList.isEmpty() )
217 {
218 return;
219 }
220
221 QgsDataDefinedWidthDialog dlg( symbolList, mLayer );
222
223 dlg.setContext( mContext );
224
225 if ( QDialog::Accepted == dlg.exec() )
226 {
227 if ( !dlg.mDDBtn->isActive() )
228 {
229 const auto constSymbolList = symbolList;
230 for ( QgsSymbol *symbol : constSymbolList )
231 {
232 if ( !symbol )
233 continue;
234
235 if ( symbol->type() == Qgis::SymbolType::Line )
236 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->value() );
237 }
238 }
240 }
241}
242
244{
245 const QList<QgsSymbol *> symbolList = selectedSymbols();
246 if ( symbolList.isEmpty() )
247 {
248 return;
249 }
250
251 QgsDataDefinedSizeDialog dlg( symbolList, mLayer );
252 dlg.setContext( mContext );
253
254 if ( QDialog::Accepted == dlg.exec() )
255 {
256 if ( !dlg.mDDBtn->isActive() )
257 {
258 const auto constSymbolList = symbolList;
259 for ( QgsSymbol *symbol : constSymbolList )
260 {
261 if ( !symbol )
262 continue;
263
264 if ( symbol->type() == Qgis::SymbolType::Marker )
265 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->value() );
266 }
267 }
269 }
270}
271
273{
274 const QList<QgsSymbol *> symbolList = selectedSymbols();
275 if ( symbolList.isEmpty() )
276 {
277 return;
278 }
279
280 QgsDataDefinedRotationDialog dlg( symbolList, mLayer );
281 dlg.setContext( mContext );
282
283 if ( QDialog::Accepted == dlg.exec() )
284 {
285 if ( !dlg.mDDBtn->isActive() )
286 {
287 const auto constSymbolList = symbolList;
288 for ( QgsSymbol *symbol : constSymbolList )
289 {
290 if ( !symbol )
291 continue;
292
293 if ( symbol->type() == Qgis::SymbolType::Marker )
294 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->value() );
295 }
296 }
298 }
299}
300
305
306void QgsRendererWidget::copySymbol()
307{
308 const QList<QgsSymbol *> symbolList = selectedSymbols();
309 if ( symbolList.isEmpty() )
310 {
311 return;
312 }
313
314 QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( symbolList.at( 0 ) ) );
315}
316
317void QgsRendererWidget::updateDataDefinedProperty()
318{
319 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
320 const QgsFeatureRenderer::Property key = static_cast< QgsFeatureRenderer::Property >( button->propertyKey() );
321 renderer()->setDataDefinedProperty( key, button->toProperty() );
322 emit widgetChanged();
323}
324
326{
328 if ( panel && panel->dockMode() )
329 {
331 widget->setPanelTitle( tr( "Symbol Levels" ) );
332 connect( widget, &QgsPanelWidget::widgetChanged, this, [ = ]()
333 {
334 setSymbolLevels( widget->symbolLevels(), widget->usingLevels() );
335 } );
336 panel->openPanel( widget );
337 }
338 else
339 {
340 QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), panel );
341 if ( dlg.exec() )
342 {
344 }
345 }
346}
347
352
357
359{
360 apply();
361}
362
364{
365 if ( dockMode )
366 {
367 // when in dock mode, these shortcuts conflict with the main window shortcuts and cannot be used
368 if ( mCopyAction )
369 mCopyAction->setShortcut( QKeySequence() );
370 if ( mPasteAction )
371 mPasteAction->setShortcut( QKeySequence() );
372 }
374}
375
379
381{
382 const QgsProperty ddSize = symbol->dataDefinedSize();
383 if ( !ddSize || !ddSize.isActive() )
384 {
385 QMessageBox::warning( this, tr( "Data-defined Size Legend" ), tr( "Data-defined size is not enabled!" ) );
386 return nullptr;
387 }
388
389 QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
391 return panel;
392}
393
394void QgsRendererWidget::setSymbolLevels( const QList< QgsLegendSymbolItem > &, bool )
395{
396
397}
398
400{
401 // note that we don't specify the layer here -- we don't want to expose a choice of fields for renderer level buttons,
402 // as the settings apply to the WHOLE layer and aren't evaluated on a feature-by-feature basis
403 button->init( static_cast< int >( key ), renderer()->dataDefinedProperties(), QgsFeatureRenderer::propertyDefinitions(), nullptr, true );
404 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRendererWidget::updateDataDefinedProperty );
405
407}
408
410{
411 if ( auto *lExpressionContext = mContext.expressionContext() )
412 return *lExpressionContext;
413
415
416 // additional scopes
417 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
418 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
419 {
420 expContext.appendScope( new QgsExpressionContextScope( scope ) );
421 }
422
423 //TODO - show actual value
424 expContext.setOriginalValueVariable( QVariant() );
425
426 QStringList highlights;
428
429 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
430 {
431 highlights << QStringLiteral( "zoom_level" );
432 }
433 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
434 {
435 highlights << QStringLiteral( "vector_tile_zoom" );
436 }
437
438 expContext.setHighlightedVariables( highlights );
439
440 return expContext;
441}
442
443//
444// QgsDataDefinedValueDialog
445//
446
447QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
448 : mSymbolList( symbolList )
449 , mLayer( layer )
450{
451 setupUi( this );
452 setWindowFlags( Qt::WindowStaysOnTopHint );
453 mLabel->setText( label );
455}
456
458{
459 mContext = context;
460}
461
463{
464 return mContext;
465}
466
467QgsExpressionContext QgsDataDefinedValueDialog::createExpressionContext() const
468{
469 QgsExpressionContext expContext;
473 if ( auto *lMapCanvas = mContext.mapCanvas() )
474 {
475 expContext << QgsExpressionContextUtils::mapSettingsScope( lMapCanvas->mapSettings() )
476 << new QgsExpressionContextScope( lMapCanvas->expressionContextScope() );
477
478 if ( const QgsExpressionContextScopeGenerator *generator = dynamic_cast< const QgsExpressionContextScopeGenerator * >( lMapCanvas->temporalController() ) )
479 {
480 expContext << generator->createExpressionContextScope();
481 }
482 }
483 else
484 {
486 }
487
488 if ( auto *lVectorLayer = vectorLayer() )
489 expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
490
491 // additional scopes
492 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
493 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
494 {
495 expContext.appendScope( new QgsExpressionContextScope( scope ) );
496 }
497
498 return expContext;
499}
500
501void QgsDataDefinedValueDialog::init( int propertyKey )
502{
503 const QgsProperty dd( symbolDataDefined() );
504
505 mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
506 mDDBtn->registerExpressionContextGenerator( this );
507
508 QgsSymbol *initialSymbol = nullptr;
509 const auto constMSymbolList = mSymbolList;
510 for ( QgsSymbol *symbol : constMSymbolList )
511 {
512 if ( symbol )
513 {
514 initialSymbol = symbol;
515 }
516 }
517 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
518 mSpinBox->setEnabled( !mDDBtn->isActive() );
519}
520
521QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
522{
523 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
524 return QgsProperty();
525
526 // check that all symbols share the same size expression
527 const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
528 const auto constMSymbolList = mSymbolList;
529 for ( QgsSymbol *it : constMSymbolList )
530 {
531 const QgsProperty symbolDD( symbolDataDefined( it ) );
532 if ( !it || !dd || !symbolDD || symbolDD != dd )
533 return QgsProperty();
534 }
535 return dd;
536}
537
539{
540 const QgsProperty dd( mDDBtn->toProperty() );
541 mSpinBox->setEnabled( !dd.isActive() );
542
543 const QgsProperty symbolDD( symbolDataDefined() );
544
545 if ( // shall we remove datadefined expressions for layers ?
546 ( symbolDD && symbolDD.isActive() && !dd.isActive() )
547 // shall we set the "en masse" expression for properties ?
548 || dd.isActive() )
549 {
550 const auto constMSymbolList = mSymbolList;
551 for ( QgsSymbol *it : constMSymbolList )
552 setDataDefined( it, dd );
553 }
554}
555
556QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
557 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
558{
559 init( static_cast< int >( QgsSymbolLayer::Property::Size ) );
560 if ( !symbolList.isEmpty() && symbolList.at( 0 ) && vectorLayer() )
561 {
562 mAssistantSymbol.reset( static_cast<const QgsMarkerSymbol *>( symbolList.at( 0 ) )->clone() );
563 mDDBtn->setSymbol( mAssistantSymbol );
564 }
565}
566
568{
569 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
570 return marker->dataDefinedSize();
571}
572
573double QgsDataDefinedSizeDialog::value( const QgsSymbol *symbol ) const
574{
575 return static_cast<const QgsMarkerSymbol *>( symbol )->size();
576}
577
579{
580 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedSize( dd );
581 static_cast<QgsMarkerSymbol *>( symbol )->setScaleMethod( Qgis::ScaleMethod::ScaleDiameter );
582}
583
584
586 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
587{
588 init( static_cast< int >( QgsSymbolLayer::Property::Angle ) );
589}
590
592{
593 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
594 return marker->dataDefinedAngle();
595}
596
598{
599 return static_cast<const QgsMarkerSymbol *>( symbol )->angle();
600}
601
603{
604 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedAngle( dd );
605}
606
607
608QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
609 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
610{
611 init( static_cast< int >( QgsSymbolLayer::Property::StrokeWidth ) );
612}
613
615{
616 const QgsLineSymbol *line = static_cast<const QgsLineSymbol *>( symbol );
617 return line->dataDefinedWidth();
618}
619
620double QgsDataDefinedWidthDialog::value( const QgsSymbol *symbol ) const
621{
622 return static_cast<const QgsLineSymbol *>( symbol )->width();
623}
624
626{
627 static_cast<QgsLineSymbol *>( symbol )->setDataDefinedWidth( dd );
628}
629
630void QgsRendererWidget::apply()
631{
632
633}
@ ScaleDiameter
Calculate scale by the diameter.
RenderUnit
Rendering size units.
Definition qgis.h:4494
@ Millimeters
Millimeters.
@ MapUnits
Map units.
@ Marker
Marker symbol.
@ Line
Line symbol.
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), bool allowOpacity=false)
Returns a color selection from a color dialog.
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel,...
@ LayoutVertical
Use a narrower, vertically stacked layout.
void currentColorChanged(const QColor &color)
Emitted when the dialog's color changes.
void setAllowOpacity(bool allowOpacity)
Sets whether opacity modification (transparency) is permitted for the color dialog.
void setColor(const QColor &color)
Sets the current color for the dialog.
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
QgsDataDefinedRotationDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
double value(const QgsSymbol *symbol) const override
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
double value(const QgsSymbol *symbol) const override
QgsDataDefinedSizeDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
Widget for configuration of appearance of legend for marker symbols with data-defined size.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Utility classes for "en masse" size definition.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
QgsDataDefinedValueDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
void init(int propertyKey)
Should be called in the constructor of child classes.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
double value(const QgsSymbol *symbol) const override
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
QgsDataDefinedWidthDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
Abstract interface for generating an expression context scope.
Single scope for storing variables and functions for use within a QgsExpressionContext.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
bool hasVariable(const QString &name) const
Check whether a variable is specified by any scope within the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
static const QString EXPR_ORIGINAL_VALUE
Inbuilt variable name for value original value variable.
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
Property
Data definable properties for renderers.
bool usingSymbolLevels() const
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol property definitions.
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the renderer.
A line symbol type, for rendering LineString and MultiLineString geometries.
void setWidth(double width) const
Sets the width for the whole line symbol.
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
The QgsMapSettings class contains configuration for rendering of the map.
A marker symbol type, for rendering Point and MultiPoint geometries.
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
void setSize(double size) const
Sets the size for the whole symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Base class for any widget that can be shown as a inline panel.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
void widgetChanged()
Emitted when the widget state changes.
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
bool dockMode()
Returns the dock mode state.
static QgsProject * instance()
Returns the QgsProject singleton instance.
A button for controlling property overrides which may apply to a widget.
QgsProperty toProperty() const
Returns a QgsProperty object encapsulating the current state of the widget.
void changed()
Emitted when property definition changes.
void init(int propertyKey, const QgsProperty &property, const QgsPropertiesDefinition &definitions, const QgsVectorLayer *layer=nullptr, bool auxiliaryStorageEnabled=false)
Initialize a newly constructed property button (useful if button was included in a UI layout).
void registerExpressionContextGenerator(QgsExpressionContextGenerator *generator)
Register an expression context generator class that will be used to retrieve an expression context fo...
int propertyKey() const
Returns the property key linked to the button.
A store for object properties.
bool isActive() const
Returns whether the property is currently active.
QAction * mPasteSymbolAction
Paste symbol action.
void changeSymbolSize()
Change marker sizes of selected symbols.
virtual void pasteSymbolToSelection()
Pastes the clipboard symbol over selected items.
QgsRendererWidget(QgsVectorLayer *layer, QgsStyle *style)
virtual void refreshSymbolView()
virtual QList< QgsSymbol * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
void showSymbolLevelsDialog(QgsFeatureRenderer *r)
Show a dialog with renderer's symbol level settings.
void changeSymbolOpacity()
Change opacity of selected symbols.
void changeSymbolWidth()
Change line widths of selected symbols.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
QgsSymbolWidgetContext mContext
Context in which widget is shown.
void changeSymbolUnit()
Change units mm/map units of selected symbols.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the renderer widget is shown, e.g., the associated map canvas and expressio...
virtual QgsFeatureRenderer * renderer()=0
Returns pointer to the renderer (no transfer of ownership)
QgsDataDefinedSizeLegendWidget * createDataDefinedSizeLegendWidget(const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend)
Creates widget to setup data-defined size legend.
virtual void disableSymbolLevels()
Disables symbol level modification on the widget.
void contextMenuViewCategories(QPoint p)
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
virtual void setSymbolLevels(const QList< QgsLegendSymbolItem > &levels, bool enabled)
Sets the symbol levels for the renderer defined in the widget.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsSymbolWidgetContext context() const
Returns the context in which the renderer widget is shown, e.g., the associated map canvas and expres...
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsFeatureRenderer::Property key)
Registers a data defined override button.
void changeSymbolColor()
Change color of selected symbols.
QAction * mCopySymbolAction
Copy symbol action.
void changeSymbolAngle()
Change marker angles of selected symbols.
void applyChanges()
This method should be called whenever the renderer is actually set on the layer.
QgsVectorLayer * mLayer
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
@ StrokeWidth
Stroke width.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
A dialog which allows the user to modify the rendering order of symbol layers.
QgsLegendSymbolList symbolLevels() const
Returns the current legend symbols with rendering passes set, as defined in the widget.
bool usingLevels() const
Returns whether the level ordering is enabled.
A widget which allows the user to modify the rendering order of symbol layers.
bool usingLevels() const
Returns whether the level ordering is enabled.
QgsLegendSymbolList symbolLevels() const
Returns the current legend symbols with rendering passes set, as defined in the widget.
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.
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.
Definition qgssymbol.h:94
qreal opacity() const
Returns the opacity for the symbol.
Definition qgssymbol.h:495
QColor color() const
Returns the symbol's color.
Qgis::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.