QGIS API Documentation 3.41.0-Master (cea29feecf2)
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#include "moc_qgsrendererwidget.cpp"
17
19#include "qgssymbol.h"
20#include "qgsvectorlayer.h"
21#include "qgscolordialog.h"
23#include "qgssymbollayer.h"
24#include "qgsmapcanvas.h"
25#include "qgspanelwidget.h"
26#include "qgsproject.h"
28#include "qgssymbollayerutils.h"
30#include "qgsmarkersymbol.h"
31#include "qgslinesymbol.h"
32
33#include <QMessageBox>
34#include <QInputDialog>
35#include <QMenu>
36#include <QClipboard>
37
39 : mLayer( layer )
40 , mStyle( style )
41{
42 contextMenu = new QMenu( tr( "Renderer Options" ), this );
43
44 mCopyAction = new QAction( tr( "Copy" ), this );
45 connect( mCopyAction, &QAction::triggered, this, &QgsRendererWidget::copy );
46 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
47 mPasteAction = new QAction( tr( "Paste" ), this );
48 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
49 connect( mPasteAction, &QAction::triggered, this, &QgsRendererWidget::paste );
50
51 mCopySymbolAction = new QAction( tr( "Copy Symbol" ), this );
52 contextMenu->addAction( mCopySymbolAction );
53 connect( mCopySymbolAction, &QAction::triggered, this, &QgsRendererWidget::copySymbol );
54 mPasteSymbolAction = new QAction( tr( "Paste Symbol" ), this );
55 contextMenu->addAction( mPasteSymbolAction );
56 connect( mPasteSymbolAction, &QAction::triggered, this, &QgsRendererWidget::pasteSymbolToSelection );
57
58 contextMenu->addSeparator();
59 contextMenu->addAction( tr( "Change Color…" ), this, SLOT( changeSymbolColor() ) );
60 contextMenu->addAction( tr( "Change Opacity…" ), this, SLOT( changeSymbolOpacity() ) );
61 contextMenu->addAction( tr( "Change Output Unit…" ), this, SLOT( changeSymbolUnit() ) );
62
64 {
65 contextMenu->addAction( tr( "Change Width…" ), this, SLOT( changeSymbolWidth() ) );
66 }
68 {
69 contextMenu->addAction( tr( "Change Size…" ), this, SLOT( changeSymbolSize() ) );
70 contextMenu->addAction( tr( "Change Angle…" ), this, SLOT( changeSymbolAngle() ) );
71 }
72
73 connect( contextMenu, &QMenu::aboutToShow, this, [=] {
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 for ( QgsSymbol *symbol : symbolList )
114 {
115 if ( symbol )
116 symbol->setColor( color );
117 }
119 } );
120 panel->openPanel( colorWidget );
121 }
122 else
123 {
124 // modal dialog version... yuck
125 const QColor color = QgsColorDialog::getColor( firstSymbol->color(), this, QStringLiteral( "Change Symbol Color" ), true );
126 if ( color.isValid() )
127 {
128 for ( QgsSymbol *symbol : symbolList )
129 {
130 if ( symbol )
131 symbol->setColor( color );
132 }
134 }
135 }
136}
137
139{
140 const QList<QgsSymbol *> symbolList = selectedSymbols();
141 if ( symbolList.isEmpty() )
142 {
143 return;
144 }
145
146 QgsSymbol *firstSymbol = nullptr;
147 const auto constSymbolList = symbolList;
148 for ( QgsSymbol *symbol : constSymbolList )
149 {
150 if ( symbol )
151 {
152 firstSymbol = symbol;
153 break;
154 }
155 }
156 if ( !firstSymbol )
157 return;
158
159 bool ok;
160 const double oldOpacity = firstSymbol->opacity() * 100; // convert to %
161 const double opacity = QInputDialog::getDouble( this, tr( "Opacity" ), tr( "Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
162 if ( ok )
163 {
164 const auto constSymbolList = symbolList;
165 for ( QgsSymbol *symbol : constSymbolList )
166 {
167 if ( symbol )
168 symbol->setOpacity( opacity / 100.0 );
169 }
171 }
172}
173
175{
176 const QList<QgsSymbol *> symbolList = selectedSymbols();
177 if ( symbolList.isEmpty() )
178 {
179 return;
180 }
181
182 QgsSymbol *firstSymbol = nullptr;
183 const auto constSymbolList = symbolList;
184 for ( QgsSymbol *symbol : constSymbolList )
185 {
186 if ( symbol )
187 {
188 firstSymbol = symbol;
189 break;
190 }
191 }
192 if ( !firstSymbol )
193 return;
194
195 bool ok;
196 const int currentUnit = ( firstSymbol->outputUnit() == Qgis::RenderUnit::Millimeters ) ? 0 : 1;
197 const QString item = QInputDialog::getItem( this, tr( "Symbol unit" ), tr( "Select symbol unit" ), QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), currentUnit, false, &ok );
198 if ( ok )
199 {
200 const Qgis::RenderUnit unit = ( item.compare( tr( "Millimeter" ) ) == 0 ) ? Qgis::RenderUnit::Millimeters : Qgis::RenderUnit::MapUnits;
201
202 const auto constSymbolList = symbolList;
203 for ( QgsSymbol *symbol : constSymbolList )
204 {
205 if ( symbol )
206 symbol->setOutputUnit( unit );
207 }
209 }
210}
211
213{
214 const QList<QgsSymbol *> symbolList = selectedSymbols();
215 if ( symbolList.isEmpty() )
216 {
217 return;
218 }
219
220 QgsDataDefinedWidthDialog dlg( symbolList, mLayer );
221
222 dlg.setContext( mContext );
223
224 if ( QDialog::Accepted == dlg.exec() )
225 {
226 if ( !dlg.mDDBtn->isActive() )
227 {
228 const auto constSymbolList = symbolList;
229 for ( QgsSymbol *symbol : constSymbolList )
230 {
231 if ( !symbol )
232 continue;
233
234 if ( symbol->type() == Qgis::SymbolType::Line )
235 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->value() );
236 }
237 }
239 }
240}
241
243{
244 const QList<QgsSymbol *> symbolList = selectedSymbols();
245 if ( symbolList.isEmpty() )
246 {
247 return;
248 }
249
250 QgsDataDefinedSizeDialog dlg( symbolList, mLayer );
251 dlg.setContext( mContext );
252
253 if ( QDialog::Accepted == dlg.exec() )
254 {
255 if ( !dlg.mDDBtn->isActive() )
256 {
257 const auto constSymbolList = symbolList;
258 for ( QgsSymbol *symbol : constSymbolList )
259 {
260 if ( !symbol )
261 continue;
262
263 if ( symbol->type() == Qgis::SymbolType::Marker )
264 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->value() );
265 }
266 }
268 }
269}
270
272{
273 const QList<QgsSymbol *> symbolList = selectedSymbols();
274 if ( symbolList.isEmpty() )
275 {
276 return;
277 }
278
279 QgsDataDefinedRotationDialog dlg( symbolList, mLayer );
280 dlg.setContext( mContext );
281
282 if ( QDialog::Accepted == dlg.exec() )
283 {
284 if ( !dlg.mDDBtn->isActive() )
285 {
286 const auto constSymbolList = symbolList;
287 for ( QgsSymbol *symbol : constSymbolList )
288 {
289 if ( !symbol )
290 continue;
291
292 if ( symbol->type() == Qgis::SymbolType::Marker )
293 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->value() );
294 }
295 }
297 }
298}
299
303
304void QgsRendererWidget::copySymbol()
305{
306 const QList<QgsSymbol *> symbolList = selectedSymbols();
307 if ( symbolList.isEmpty() )
308 {
309 return;
310 }
311
312 QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( symbolList.at( 0 ) ) );
313}
314
315void QgsRendererWidget::updateDataDefinedProperty()
316{
317 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
318 const QgsFeatureRenderer::Property key = static_cast<QgsFeatureRenderer::Property>( button->propertyKey() );
319 renderer()->setDataDefinedProperty( key, button->toProperty() );
320 emit widgetChanged();
321}
322
324{
326 if ( panel && panel->dockMode() )
327 {
329 widget->setPanelTitle( tr( "Symbol Levels" ) );
330 connect( widget, &QgsPanelWidget::widgetChanged, this, [=]() {
331 setSymbolLevels( widget->symbolLevels(), widget->usingLevels() );
332 } );
333 panel->openPanel( widget );
334 }
335 else
336 {
337 QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), panel );
338 if ( dlg.exec() )
339 {
341 }
342 }
343}
344
349
354
356{
357 apply();
358}
359
361{
362 if ( dockMode )
363 {
364 // when in dock mode, these shortcuts conflict with the main window shortcuts and cannot be used
365 if ( mCopyAction )
366 mCopyAction->setShortcut( QKeySequence() );
367 if ( mPasteAction )
368 mPasteAction->setShortcut( QKeySequence() );
369 }
371}
372
376
378{
379 const QgsProperty ddSize = symbol->dataDefinedSize();
380 if ( !ddSize || !ddSize.isActive() )
381 {
382 QMessageBox::warning( this, tr( "Data-defined Size Legend" ), tr( "Data-defined size is not enabled!" ) );
383 return nullptr;
384 }
385
386 QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
388 return panel;
389}
390
391void QgsRendererWidget::setSymbolLevels( const QList<QgsLegendSymbolItem> &, bool )
392{
393}
394
396{
397 // note that we don't specify the layer here -- we don't want to expose a choice of fields for renderer level buttons,
398 // as the settings apply to the WHOLE layer and aren't evaluated on a feature-by-feature basis
399 button->init( static_cast<int>( key ), renderer()->dataDefinedProperties(), QgsFeatureRenderer::propertyDefinitions(), nullptr, true );
400 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRendererWidget::updateDataDefinedProperty );
401
403}
404
406{
407 if ( auto *lExpressionContext = mContext.expressionContext() )
408 return *lExpressionContext;
409
411
412 // additional scopes
413 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
414 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
415 {
416 expContext.appendScope( new QgsExpressionContextScope( scope ) );
417 }
418
419 //TODO - show actual value
420 expContext.setOriginalValueVariable( QVariant() );
421
422 QStringList highlights;
424
425 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
426 {
427 highlights << QStringLiteral( "zoom_level" );
428 }
429 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
430 {
431 highlights << QStringLiteral( "vector_tile_zoom" );
432 }
433
434 expContext.setHighlightedVariables( highlights );
435
436 return expContext;
437}
438
439//
440// QgsDataDefinedValueDialog
441//
442
443QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
444 : mSymbolList( symbolList )
445 , mLayer( layer )
446{
447 setupUi( this );
448 setWindowFlags( Qt::WindowStaysOnTopHint );
449 mLabel->setText( label );
451}
452
454{
455 mContext = context;
456}
457
459{
460 return mContext;
461}
462
463QgsExpressionContext QgsDataDefinedValueDialog::createExpressionContext() const
464{
465 QgsExpressionContext expContext;
466 if ( auto *lMapCanvas = mContext.mapCanvas() )
467 {
468 expContext = lMapCanvas->createExpressionContext();
469 }
470 else
471 {
476 }
477
478 if ( auto *lVectorLayer = vectorLayer() )
479 expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
480
481 // additional scopes
482 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
483 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
484 {
485 expContext.appendScope( new QgsExpressionContextScope( scope ) );
486 }
487
488 return expContext;
489}
490
491void QgsDataDefinedValueDialog::init( int propertyKey )
492{
493 const QgsProperty dd( symbolDataDefined() );
494
495 mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
496 mDDBtn->registerExpressionContextGenerator( this );
497
498 QgsSymbol *initialSymbol = nullptr;
499 const auto constMSymbolList = mSymbolList;
500 for ( QgsSymbol *symbol : constMSymbolList )
501 {
502 if ( symbol )
503 {
504 initialSymbol = symbol;
505 }
506 }
507 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
508 mSpinBox->setEnabled( !mDDBtn->isActive() );
509}
510
511QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
512{
513 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
514 return QgsProperty();
515
516 // check that all symbols share the same size expression
517 const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
518 const auto constMSymbolList = mSymbolList;
519 for ( QgsSymbol *it : constMSymbolList )
520 {
521 const QgsProperty symbolDD( symbolDataDefined( it ) );
522 if ( !it || !dd || !symbolDD || symbolDD != dd )
523 return QgsProperty();
524 }
525 return dd;
526}
527
529{
530 const QgsProperty dd( mDDBtn->toProperty() );
531 mSpinBox->setEnabled( !dd.isActive() );
532
533 const QgsProperty symbolDD( symbolDataDefined() );
534
535 if ( // shall we remove datadefined expressions for layers ?
536 ( symbolDD && symbolDD.isActive() && !dd.isActive() )
537 // shall we set the "en masse" expression for properties ?
538 || dd.isActive()
539 )
540 {
541 const auto constMSymbolList = mSymbolList;
542 for ( QgsSymbol *it : constMSymbolList )
543 setDataDefined( it, dd );
544 }
545}
546
547QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
548 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
549{
550 init( static_cast<int>( QgsSymbolLayer::Property::Size ) );
551 if ( !symbolList.isEmpty() && symbolList.at( 0 ) && vectorLayer() )
552 {
553 mAssistantSymbol.reset( static_cast<const QgsMarkerSymbol *>( symbolList.at( 0 ) )->clone() );
554 mDDBtn->setSymbol( mAssistantSymbol );
555 }
556}
557
559{
560 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
561 return marker->dataDefinedSize();
562}
563
564double QgsDataDefinedSizeDialog::value( const QgsSymbol *symbol ) const
565{
566 return static_cast<const QgsMarkerSymbol *>( symbol )->size();
567}
568
570{
571 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedSize( dd );
572 static_cast<QgsMarkerSymbol *>( symbol )->setScaleMethod( Qgis::ScaleMethod::ScaleDiameter );
573}
574
575
577 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
578{
579 init( static_cast<int>( QgsSymbolLayer::Property::Angle ) );
580}
581
583{
584 const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
585 return marker->dataDefinedAngle();
586}
587
589{
590 return static_cast<const QgsMarkerSymbol *>( symbol )->angle();
591}
592
594{
595 static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedAngle( dd );
596}
597
598
599QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
600 : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
601{
602 init( static_cast<int>( QgsSymbolLayer::Property::StrokeWidth ) );
603}
604
606{
607 const QgsLineSymbol *line = static_cast<const QgsLineSymbol *>( symbol );
608 return line->dataDefinedWidth();
609}
610
611double QgsDataDefinedWidthDialog::value( const QgsSymbol *symbol ) const
612{
613 return static_cast<const QgsLineSymbol *>( symbol )->width();
614}
615
617{
618 static_cast<QgsLineSymbol *>( symbol )->setDataDefinedWidth( dd );
619}
620
621void QgsRendererWidget::apply()
622{
623}
@ ScaleDiameter
Calculate scale by the diameter.
RenderUnit
Rendering size units.
Definition qgis.h:4892
@ 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)
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.
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:231
qreal opacity() const
Returns the opacity for the symbol.
Definition qgssymbol.h:633
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.