QGIS API Documentation 3.99.0-Master (d270888f95f)
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
17#include "qgscolordialog.h"
20#include "qgslinesymbol.h"
21#include "qgsmapcanvas.h"
22#include "qgsmarkersymbol.h"
23#include "qgspanelwidget.h"
24#include "qgsproject.h"
25#include "qgssymbol.h"
26#include "qgssymbollayer.h"
27#include "qgssymbollayerutils.h"
30#include "qgsvectorlayer.h"
31
32#include <QClipboard>
33#include <QInputDialog>
34#include <QMenu>
35#include <QMessageBox>
36#include <QString>
37
38#include "moc_qgsrendererwidget.cpp"
39
40using namespace Qt::StringLiterals;
41
43 : mLayer( layer )
44 , mStyle( style )
45{
46 contextMenu = new QMenu( tr( "Renderer Options" ), this );
47
48 mCopyAction = new QAction( tr( "Copy" ), this );
49 connect( mCopyAction, &QAction::triggered, this, &QgsRendererWidget::copy );
50 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
51 mPasteAction = new QAction( tr( "Paste" ), this );
52 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
53 connect( mPasteAction, &QAction::triggered, this, &QgsRendererWidget::paste );
54
55 mCopySymbolAction = new QAction( tr( "Copy Symbol" ), this );
56 contextMenu->addAction( mCopySymbolAction );
57 connect( mCopySymbolAction, &QAction::triggered, this, &QgsRendererWidget::copySymbol );
58 mPasteSymbolAction = new QAction( tr( "Paste Symbol" ), this );
59 contextMenu->addAction( mPasteSymbolAction );
60 connect( mPasteSymbolAction, &QAction::triggered, this, &QgsRendererWidget::pasteSymbolToSelection );
61
62 contextMenu->addSeparator();
63 contextMenu->addAction( tr( "Change Color…" ), this, &QgsRendererWidget::changeSymbolColor );
64 contextMenu->addAction( tr( "Change Opacity…" ), this, &QgsRendererWidget::changeSymbolOpacity );
65 contextMenu->addAction( tr( "Change Output Unit…" ), this, &QgsRendererWidget::changeSymbolUnit );
66
67 if ( mLayer && mLayer->geometryType() == Qgis::GeometryType::Line )
68 {
69 contextMenu->addAction( tr( "Change Width…" ), this, &QgsRendererWidget::changeSymbolWidth );
70 }
71 else if ( mLayer && mLayer->geometryType() == Qgis::GeometryType::Point )
72 {
73 contextMenu->addAction( tr( "Change Size…" ), this, &QgsRendererWidget::changeSymbolSize );
74 contextMenu->addAction( tr( "Change Angle…" ), this, &QgsRendererWidget::changeSymbolAngle );
75 }
76
77 connect( contextMenu, &QMenu::aboutToShow, this, [this] {
78 const std::unique_ptr<QgsSymbol> tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
79 mPasteSymbolAction->setEnabled( static_cast<bool>( tempSymbol ) );
80 } );
81}
82
84{
85 contextMenu->exec( QCursor::pos() );
86}
87
89{
90 const QList<QgsSymbol *> symbolList = selectedSymbols();
91 if ( symbolList.isEmpty() )
92 {
93 return;
94 }
95
96 QgsSymbol *firstSymbol = nullptr;
97 for ( QgsSymbol *symbol : symbolList )
98 {
99 if ( symbol )
100 {
101 firstSymbol = symbol;
102 break;
103 }
104 }
105 if ( !firstSymbol )
106 return;
107
108 const QColor currentColor = firstSymbol->color();
109
110 QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( qobject_cast<QWidget *>( parent() ) );
111 if ( panel && panel->dockMode() )
112 {
114 colorWidget->setPanelTitle( tr( "Change Symbol Color" ) );
115 colorWidget->setAllowOpacity( true );
116 connect( colorWidget, &QgsCompoundColorWidget::currentColorChanged, this, [this, symbolList]( const QColor &color ) {
117 for ( QgsSymbol *symbol : symbolList )
118 {
119 if ( symbol )
120 symbol->setColor( color );
121 }
123 } );
124 panel->openPanel( colorWidget );
125 }
126 else
127 {
128 // modal dialog version... yuck
129 const QColor color = QgsColorDialog::getColor( firstSymbol->color(), this, u"Change Symbol Color"_s, true );
130 if ( color.isValid() )
131 {
132 for ( QgsSymbol *symbol : symbolList )
133 {
134 if ( symbol )
135 symbol->setColor( color );
136 }
138 }
139 }
140}
141
143{
144 const QList<QgsSymbol *> symbolList = selectedSymbols();
145 if ( symbolList.isEmpty() )
146 {
147 return;
148 }
149
150 QgsSymbol *firstSymbol = nullptr;
151 const auto constSymbolList = symbolList;
152 for ( QgsSymbol *symbol : constSymbolList )
153 {
154 if ( symbol )
155 {
156 firstSymbol = symbol;
157 break;
158 }
159 }
160 if ( !firstSymbol )
161 return;
162
163 bool ok;
164 const double oldOpacity = firstSymbol->opacity() * 100; // convert to %
165 const double opacity = QInputDialog::getDouble( this, tr( "Opacity" ), tr( "Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
166 if ( ok )
167 {
168 const auto constSymbolList = symbolList;
169 for ( QgsSymbol *symbol : constSymbolList )
170 {
171 if ( symbol )
172 symbol->setOpacity( opacity / 100.0 );
173 }
175 }
176}
177
179{
180 const QList<QgsSymbol *> symbolList = selectedSymbols();
181 if ( symbolList.isEmpty() )
182 {
183 return;
184 }
185
186 QgsSymbol *firstSymbol = nullptr;
187 const auto constSymbolList = symbolList;
188 for ( QgsSymbol *symbol : constSymbolList )
189 {
190 if ( symbol )
191 {
192 firstSymbol = symbol;
193 break;
194 }
195 }
196 if ( !firstSymbol )
197 return;
198
199 bool ok;
200 const int currentUnit = ( firstSymbol->outputUnit() == Qgis::RenderUnit::Millimeters ) ? 0 : 1;
201 const QString item = QInputDialog::getItem( this, tr( "Symbol unit" ), tr( "Select symbol unit" ), QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), currentUnit, false, &ok );
202 if ( ok )
203 {
204 const Qgis::RenderUnit unit = ( item.compare( tr( "Millimeter" ) ) == 0 ) ? Qgis::RenderUnit::Millimeters : Qgis::RenderUnit::MapUnits;
205
206 const auto constSymbolList = symbolList;
207 for ( QgsSymbol *symbol : constSymbolList )
208 {
209 if ( symbol )
210 symbol->setOutputUnit( unit );
211 }
213 }
214}
215
217{
218 const QList<QgsSymbol *> symbolList = selectedSymbols();
219 if ( symbolList.isEmpty() )
220 {
221 return;
222 }
223
224 QgsDataDefinedWidthDialog dlg( symbolList, mLayer );
225
226 dlg.setContext( mContext );
227
228 if ( QDialog::Accepted == dlg.exec() )
229 {
230 if ( !dlg.mDDBtn->isActive() )
231 {
232 const auto constSymbolList = symbolList;
233 for ( QgsSymbol *symbol : constSymbolList )
234 {
235 if ( !symbol )
236 continue;
237
238 if ( symbol->type() == Qgis::SymbolType::Line )
239 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->value() );
240 }
241 }
243 }
244}
245
247{
248 const QList<QgsSymbol *> symbolList = selectedSymbols();
249 if ( symbolList.isEmpty() )
250 {
251 return;
252 }
253
254 QgsDataDefinedSizeDialog dlg( symbolList, mLayer );
255 dlg.setContext( mContext );
256
257 if ( QDialog::Accepted == dlg.exec() )
258 {
259 if ( !dlg.mDDBtn->isActive() )
260 {
261 const auto constSymbolList = symbolList;
262 for ( QgsSymbol *symbol : constSymbolList )
263 {
264 if ( !symbol )
265 continue;
266
267 if ( symbol->type() == Qgis::SymbolType::Marker )
268 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->value() );
269 }
270 }
272 }
273}
274
276{
277 const QList<QgsSymbol *> symbolList = selectedSymbols();
278 if ( symbolList.isEmpty() )
279 {
280 return;
281 }
282
283 QgsDataDefinedRotationDialog dlg( symbolList, mLayer );
284 dlg.setContext( mContext );
285
286 if ( QDialog::Accepted == dlg.exec() )
287 {
288 if ( !dlg.mDDBtn->isActive() )
289 {
290 const auto constSymbolList = symbolList;
291 for ( QgsSymbol *symbol : constSymbolList )
292 {
293 if ( !symbol )
294 continue;
295
296 if ( symbol->type() == Qgis::SymbolType::Marker )
297 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->value() );
298 }
299 }
301 }
302}
303
307
308void QgsRendererWidget::copySymbol()
309{
310 const QList<QgsSymbol *> symbolList = selectedSymbols();
311 if ( symbolList.isEmpty() )
312 {
313 return;
314 }
315
316 QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( symbolList.at( 0 ) ) );
317}
318
319void QgsRendererWidget::updateDataDefinedProperty()
320{
321 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
322 const QgsFeatureRenderer::Property key = static_cast<QgsFeatureRenderer::Property>( button->propertyKey() );
323 renderer()->setDataDefinedProperty( key, button->toProperty() );
324 emit widgetChanged();
325}
326
328{
330 if ( panel && panel->dockMode() )
331 {
333 widget->setPanelTitle( tr( "Symbol Levels" ) );
334 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
335 setSymbolLevels( widget->symbolLevels(), widget->usingLevels() );
336 } );
337 panel->openPanel( widget );
338 }
339 else
340 {
341 QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), panel );
342 if ( dlg.exec() )
343 {
345 }
346 }
347}
348
353
358
360{
361 apply();
362}
363
365{
366 if ( dockMode )
367 {
368 // when in dock mode, these shortcuts conflict with the main window shortcuts and cannot be used
369 if ( mCopyAction )
370 mCopyAction->setShortcut( QKeySequence() );
371 if ( mPasteAction )
372 mPasteAction->setShortcut( QKeySequence() );
373 }
375}
376
380
382{
383 const QgsProperty ddSize = symbol->dataDefinedSize();
384 if ( !ddSize || !ddSize.isActive() )
385 {
386 QMessageBox::warning( this, tr( "Data-defined Size Legend" ), tr( "Data-defined size is not enabled!" ) );
387 return nullptr;
388 }
389
390 QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
392 return panel;
393}
394
395void QgsRendererWidget::setSymbolLevels( const QList<QgsLegendSymbolItem> &, bool )
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
414 QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( vectorLayer() ) );
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( u"zoom_level"_s ) )
430 {
431 highlights << u"zoom_level"_s;
432 }
433 if ( expContext.hasVariable( u"vector_tile_zoom"_s ) )
434 {
435 highlights << u"vector_tile_zoom"_s;
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
461
463{
464 return mContext;
465}
466
468{
469 QgsExpressionContext expContext;
470 if ( auto *lMapCanvas = mContext.mapCanvas() )
471 {
472 expContext = lMapCanvas->createExpressionContext();
473 }
474 else
475 {
479 << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() );
480 }
481
482 if ( auto *lVectorLayer = vectorLayer() )
483 expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
484
485 // additional scopes
486 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
487 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
488 {
489 expContext.appendScope( new QgsExpressionContextScope( scope ) );
490 }
491
492 return expContext;
493}
494
495void QgsDataDefinedValueDialog::init( int propertyKey )
496{
497 const QgsProperty dd( symbolDataDefined() );
498
499 mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
500 mDDBtn->registerExpressionContextGenerator( this );
501
502 QgsSymbol *initialSymbol = nullptr;
503 const auto constMSymbolList = mSymbolList;
504 for ( QgsSymbol *symbol : constMSymbolList )
505 {
506 if ( symbol )
507 {
508 initialSymbol = symbol;
509 }
510 }
511 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
512 mSpinBox->setEnabled( !mDDBtn->isActive() );
513}
514
515QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
516{
517 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
518 return QgsProperty();
519
520 // check that all symbols share the same size expression
521 const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
522 const auto constMSymbolList = mSymbolList;
523 for ( QgsSymbol *it : constMSymbolList )
524 {
525 const QgsProperty symbolDD( symbolDataDefined( it ) );
526 if ( !it || !dd || !symbolDD || symbolDD != dd )
527 return QgsProperty();
528 }
529 return dd;
530}
531
533{
534 const QgsProperty dd( mDDBtn->toProperty() );
535 mSpinBox->setEnabled( !dd.isActive() );
536
537 const QgsProperty symbolDD( symbolDataDefined() );
538
539 if ( // shall we remove datadefined expressions for layers ?
540 ( symbolDD && symbolDD.isActive() && !dd.isActive() )
541 // shall we set the "en masse" expression for properties ?
542 || dd.isActive()
543 )
544 {
545 const auto constMSymbolList = mSymbolList;
546 for ( QgsSymbol *it : constMSymbolList )
547 setDataDefined( it, dd );
548 }
549}
550
551QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
552 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
553{
554 init( static_cast<int>( QgsSymbolLayer::Property::Size ) );
555 if ( !symbolList.isEmpty() && symbolList.at( 0 ) && vectorLayer() )
556 {
557 mAssistantSymbol.reset( static_cast<const QgsMarkerSymbol *>( symbolList.at( 0 ) )->clone() );
558 mDDBtn->setSymbol( mAssistantSymbol );
559 }
560}
561
563{
564 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
565 return marker->dataDefinedSize();
566}
567
568double QgsDataDefinedSizeDialog::value( const QgsSymbol *symbol ) const
569{
570 return static_cast<const QgsMarkerSymbol *>( symbol )->size();
571}
572
574{
575 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedSize( dd );
576 static_cast<QgsMarkerSymbol *>( symbol )->setScaleMethod( Qgis::ScaleMethod::ScaleDiameter );
577}
578
579
581 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
582{
583 init( static_cast<int>( QgsSymbolLayer::Property::Angle ) );
584}
585
587{
588 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
589 return marker->dataDefinedAngle();
590}
591
593{
594 return static_cast<const QgsMarkerSymbol *>( symbol )->angle();
595}
596
598{
599 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedAngle( dd );
600}
601
602
603QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
604 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
605{
606 init( static_cast<int>( QgsSymbolLayer::Property::StrokeWidth ) );
607}
608
610{
611 const QgsLineSymbol *line = static_cast<const QgsLineSymbol *>( symbol );
612 return line->dataDefinedWidth();
613}
614
615double QgsDataDefinedWidthDialog::value( const QgsSymbol *symbol ) const
616{
617 return static_cast<const QgsLineSymbol *>( symbol )->width();
618}
619
621{
622 static_cast<QgsLineSymbol *>( symbol )->setDataDefinedWidth( dd );
623}
624
625void QgsRendererWidget::apply()
626{
627}
@ ScaleDiameter
Calculate scale by the diameter.
Definition qgis.h:645
@ Point
Points.
Definition qgis.h:366
@ Line
Lines.
Definition qgis.h:367
RenderUnit
Rendering size units.
Definition qgis.h:5255
@ Millimeters
Millimeters.
Definition qgis.h:5256
@ MapUnits
Map units.
Definition qgis.h:5257
@ Marker
Marker symbol.
Definition qgis.h:630
@ Line
Line symbol.
Definition qgis.h:631
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.
A dialog for configuring symbol-level data defined rotation.
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
A dialog for configuring symbol-level data defined size.
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.
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.
A dialog for configuring symbol-level data defined width.
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)
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
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.
Abstract base class for all 2D vector feature renderers.
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.
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
A marker symbol type, for rendering Point and MultiPoint geometries.
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.
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
bool dockMode() const
Returns the dock mode state.
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
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.
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
A database of saved style entities, including symbols, color ramps, text formats and others.
Definition qgsstyle.h:89
static std::unique_ptr< 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.
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,...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
qreal opacity() const
Returns the opacity for the symbol.
Definition qgssymbol.h:659
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 dataset.