QGIS API Documentation 3.99.0-Master (26c88405ac0)
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
37#include "moc_qgsrendererwidget.cpp"
38
40 : mLayer( layer )
41 , mStyle( style )
42{
43 contextMenu = new QMenu( tr( "Renderer Options" ), this );
44
45 mCopyAction = new QAction( tr( "Copy" ), this );
46 connect( mCopyAction, &QAction::triggered, this, &QgsRendererWidget::copy );
47 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
48 mPasteAction = new QAction( tr( "Paste" ), this );
49 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
50 connect( mPasteAction, &QAction::triggered, this, &QgsRendererWidget::paste );
51
52 mCopySymbolAction = new QAction( tr( "Copy Symbol" ), this );
53 contextMenu->addAction( mCopySymbolAction );
54 connect( mCopySymbolAction, &QAction::triggered, this, &QgsRendererWidget::copySymbol );
55 mPasteSymbolAction = new QAction( tr( "Paste Symbol" ), this );
56 contextMenu->addAction( mPasteSymbolAction );
57 connect( mPasteSymbolAction, &QAction::triggered, this, &QgsRendererWidget::pasteSymbolToSelection );
58
59 contextMenu->addSeparator();
60 contextMenu->addAction( tr( "Change Color…" ), this, &QgsRendererWidget::changeSymbolColor );
61 contextMenu->addAction( tr( "Change Opacity…" ), this, &QgsRendererWidget::changeSymbolOpacity );
62 contextMenu->addAction( tr( "Change Output Unit…" ), this, &QgsRendererWidget::changeSymbolUnit );
63
64 if ( mLayer && mLayer->geometryType() == Qgis::GeometryType::Line )
65 {
66 contextMenu->addAction( tr( "Change Width…" ), this, &QgsRendererWidget::changeSymbolWidth );
67 }
68 else if ( mLayer && mLayer->geometryType() == Qgis::GeometryType::Point )
69 {
70 contextMenu->addAction( tr( "Change Size…" ), this, &QgsRendererWidget::changeSymbolSize );
71 contextMenu->addAction( tr( "Change Angle…" ), this, &QgsRendererWidget::changeSymbolAngle );
72 }
73
74 connect( contextMenu, &QMenu::aboutToShow, this, [this] {
75 const std::unique_ptr<QgsSymbol> tempSymbol( QgsSymbolLayerUtils::symbolFromMimeData( QApplication::clipboard()->mimeData() ) );
76 mPasteSymbolAction->setEnabled( static_cast<bool>( tempSymbol ) );
77 } );
78}
79
81{
82 contextMenu->exec( QCursor::pos() );
83}
84
86{
87 const QList<QgsSymbol *> symbolList = selectedSymbols();
88 if ( symbolList.isEmpty() )
89 {
90 return;
91 }
92
93 QgsSymbol *firstSymbol = nullptr;
94 for ( QgsSymbol *symbol : symbolList )
95 {
96 if ( symbol )
97 {
98 firstSymbol = symbol;
99 break;
100 }
101 }
102 if ( !firstSymbol )
103 return;
104
105 const QColor currentColor = firstSymbol->color();
106
107 QgsPanelWidget *panel = QgsPanelWidget::findParentPanel( qobject_cast<QWidget *>( parent() ) );
108 if ( panel && panel->dockMode() )
109 {
111 colorWidget->setPanelTitle( tr( "Change Symbol Color" ) );
112 colorWidget->setAllowOpacity( true );
113 connect( colorWidget, &QgsCompoundColorWidget::currentColorChanged, this, [this, symbolList]( const QColor &color ) {
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
304
305void QgsRendererWidget::copySymbol()
306{
307 const QList<QgsSymbol *> symbolList = selectedSymbols();
308 if ( symbolList.isEmpty() )
309 {
310 return;
311 }
312
313 QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( symbolList.at( 0 ) ) );
314}
315
316void QgsRendererWidget::updateDataDefinedProperty()
317{
318 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
319 const QgsFeatureRenderer::Property key = static_cast<QgsFeatureRenderer::Property>( button->propertyKey() );
320 renderer()->setDataDefinedProperty( key, button->toProperty() );
321 emit widgetChanged();
322}
323
325{
327 if ( panel && panel->dockMode() )
328 {
330 widget->setPanelTitle( tr( "Symbol Levels" ) );
331 connect( widget, &QgsPanelWidget::widgetChanged, this, [this, widget]() {
332 setSymbolLevels( widget->symbolLevels(), widget->usingLevels() );
333 } );
334 panel->openPanel( widget );
335 }
336 else
337 {
338 QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), panel );
339 if ( dlg.exec() )
340 {
342 }
343 }
344}
345
350
355
357{
358 apply();
359}
360
362{
363 if ( dockMode )
364 {
365 // when in dock mode, these shortcuts conflict with the main window shortcuts and cannot be used
366 if ( mCopyAction )
367 mCopyAction->setShortcut( QKeySequence() );
368 if ( mPasteAction )
369 mPasteAction->setShortcut( QKeySequence() );
370 }
372}
373
377
379{
380 const QgsProperty ddSize = symbol->dataDefinedSize();
381 if ( !ddSize || !ddSize.isActive() )
382 {
383 QMessageBox::warning( this, tr( "Data-defined Size Legend" ), tr( "Data-defined size is not enabled!" ) );
384 return nullptr;
385 }
386
387 QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
389 return panel;
390}
391
392void QgsRendererWidget::setSymbolLevels( const QList<QgsLegendSymbolItem> &, bool )
393{
394}
395
397{
398 // note that we don't specify the layer here -- we don't want to expose a choice of fields for renderer level buttons,
399 // as the settings apply to the WHOLE layer and aren't evaluated on a feature-by-feature basis
400 button->init( static_cast<int>( key ), renderer()->dataDefinedProperties(), QgsFeatureRenderer::propertyDefinitions(), nullptr, true );
401 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRendererWidget::updateDataDefinedProperty );
402
404}
405
407{
408 if ( auto *lExpressionContext = mContext.expressionContext() )
409 return *lExpressionContext;
410
411 QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( vectorLayer() ) );
412
413 // additional scopes
414 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
415 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
416 {
417 expContext.appendScope( new QgsExpressionContextScope( scope ) );
418 }
419
420 //TODO - show actual value
421 expContext.setOriginalValueVariable( QVariant() );
422
423 QStringList highlights;
425
426 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
427 {
428 highlights << QStringLiteral( "zoom_level" );
429 }
430 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
431 {
432 highlights << QStringLiteral( "vector_tile_zoom" );
433 }
434
435 expContext.setHighlightedVariables( highlights );
436
437 return expContext;
438}
439
440//
441// QgsDataDefinedValueDialog
442//
443
444QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
445 : mSymbolList( symbolList )
446 , mLayer( layer )
447{
448 setupUi( this );
449 setWindowFlags( Qt::WindowStaysOnTopHint );
450 mLabel->setText( label );
452}
453
458
460{
461 return mContext;
462}
463
465{
466 QgsExpressionContext expContext;
467 if ( auto *lMapCanvas = mContext.mapCanvas() )
468 {
469 expContext = lMapCanvas->createExpressionContext();
470 }
471 else
472 {
476 << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() );
477 }
478
479 if ( auto *lVectorLayer = vectorLayer() )
480 expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
481
482 // additional scopes
483 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
484 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
485 {
486 expContext.appendScope( new QgsExpressionContextScope( scope ) );
487 }
488
489 return expContext;
490}
491
492void QgsDataDefinedValueDialog::init( int propertyKey )
493{
494 const QgsProperty dd( symbolDataDefined() );
495
496 mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
497 mDDBtn->registerExpressionContextGenerator( this );
498
499 QgsSymbol *initialSymbol = nullptr;
500 const auto constMSymbolList = mSymbolList;
501 for ( QgsSymbol *symbol : constMSymbolList )
502 {
503 if ( symbol )
504 {
505 initialSymbol = symbol;
506 }
507 }
508 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
509 mSpinBox->setEnabled( !mDDBtn->isActive() );
510}
511
512QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
513{
514 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
515 return QgsProperty();
516
517 // check that all symbols share the same size expression
518 const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
519 const auto constMSymbolList = mSymbolList;
520 for ( QgsSymbol *it : constMSymbolList )
521 {
522 const QgsProperty symbolDD( symbolDataDefined( it ) );
523 if ( !it || !dd || !symbolDD || symbolDD != dd )
524 return QgsProperty();
525 }
526 return dd;
527}
528
530{
531 const QgsProperty dd( mDDBtn->toProperty() );
532 mSpinBox->setEnabled( !dd.isActive() );
533
534 const QgsProperty symbolDD( symbolDataDefined() );
535
536 if ( // shall we remove datadefined expressions for layers ?
537 ( symbolDD && symbolDD.isActive() && !dd.isActive() )
538 // shall we set the "en masse" expression for properties ?
539 || dd.isActive()
540 )
541 {
542 const auto constMSymbolList = mSymbolList;
543 for ( QgsSymbol *it : constMSymbolList )
544 setDataDefined( it, dd );
545 }
546}
547
548QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
549 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
550{
551 init( static_cast<int>( QgsSymbolLayer::Property::Size ) );
552 if ( !symbolList.isEmpty() && symbolList.at( 0 ) && vectorLayer() )
553 {
554 mAssistantSymbol.reset( static_cast<const QgsMarkerSymbol *>( symbolList.at( 0 ) )->clone() );
555 mDDBtn->setSymbol( mAssistantSymbol );
556 }
557}
558
560{
561 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
562 return marker->dataDefinedSize();
563}
564
565double QgsDataDefinedSizeDialog::value( const QgsSymbol *symbol ) const
566{
567 return static_cast<const QgsMarkerSymbol *>( symbol )->size();
568}
569
571{
572 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedSize( dd );
573 static_cast<QgsMarkerSymbol *>( symbol )->setScaleMethod( Qgis::ScaleMethod::ScaleDiameter );
574}
575
576
578 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
579{
580 init( static_cast<int>( QgsSymbolLayer::Property::Angle ) );
581}
582
584{
585 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
586 return marker->dataDefinedAngle();
587}
588
590{
591 return static_cast<const QgsMarkerSymbol *>( symbol )->angle();
592}
593
595{
596 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedAngle( dd );
597}
598
599
600QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
601 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
602{
603 init( static_cast<int>( QgsSymbolLayer::Property::StrokeWidth ) );
604}
605
607{
608 const QgsLineSymbol *line = static_cast<const QgsLineSymbol *>( symbol );
609 return line->dataDefinedWidth();
610}
611
612double QgsDataDefinedWidthDialog::value( const QgsSymbol *symbol ) const
613{
614 return static_cast<const QgsLineSymbol *>( symbol )->width();
615}
616
618{
619 static_cast<QgsLineSymbol *>( symbol )->setDataDefinedWidth( dd );
620}
621
622void QgsRendererWidget::apply()
623{
624}
@ ScaleDiameter
Calculate scale by the diameter.
Definition qgis.h:626
@ Point
Points.
Definition qgis.h:359
@ Line
Lines.
Definition qgis.h:360
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ Millimeters
Millimeters.
Definition qgis.h:5184
@ MapUnits
Map units.
Definition qgis.h:5185
@ Marker
Marker symbol.
Definition qgis.h:611
@ Line
Line symbol.
Definition qgis.h:612
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:88
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.