QGIS API Documentation 3.41.0-Master (25ec5511245)
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 {
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, [ = ]( const QColor & color )
114 {
115 for ( QgsSymbol *symbol : symbolList )
116 {
117 if ( symbol )
118 symbol->setColor( color );
119 }
121 } );
122 panel->openPanel( colorWidget );
123 }
124 else
125 {
126 // modal dialog version... yuck
127 const QColor color = QgsColorDialog::getColor( firstSymbol->color(), this, QStringLiteral( "Change Symbol Color" ), true );
128 if ( color.isValid() )
129 {
130 for ( QgsSymbol *symbol : symbolList )
131 {
132 if ( symbol )
133 symbol->setColor( color );
134 }
136 }
137 }
138}
139
141{
142 const QList<QgsSymbol *> symbolList = selectedSymbols();
143 if ( symbolList.isEmpty() )
144 {
145 return;
146 }
147
148 QgsSymbol *firstSymbol = nullptr;
149 const auto constSymbolList = symbolList;
150 for ( QgsSymbol *symbol : constSymbolList )
151 {
152 if ( symbol )
153 {
154 firstSymbol = symbol;
155 break;
156 }
157 }
158 if ( !firstSymbol )
159 return;
160
161 bool ok;
162 const double oldOpacity = firstSymbol->opacity() * 100; // convert to %
163 const double opacity = QInputDialog::getDouble( this, tr( "Opacity" ), tr( "Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
164 if ( ok )
165 {
166 const auto constSymbolList = symbolList;
167 for ( QgsSymbol *symbol : constSymbolList )
168 {
169 if ( symbol )
170 symbol->setOpacity( opacity / 100.0 );
171 }
173 }
174}
175
177{
178 const QList<QgsSymbol *> symbolList = selectedSymbols();
179 if ( symbolList.isEmpty() )
180 {
181 return;
182 }
183
184 QgsSymbol *firstSymbol = nullptr;
185 const auto constSymbolList = symbolList;
186 for ( QgsSymbol *symbol : constSymbolList )
187 {
188 if ( symbol )
189 {
190 firstSymbol = symbol;
191 break;
192 }
193 }
194 if ( !firstSymbol )
195 return;
196
197 bool ok;
198 const int currentUnit = ( firstSymbol->outputUnit() == Qgis::RenderUnit::Millimeters ) ? 0 : 1;
199 const QString item = QInputDialog::getItem( this, tr( "Symbol unit" ), tr( "Select symbol unit" ), QStringList() << tr( "Millimeter" ) << tr( "Map unit" ), currentUnit, false, &ok );
200 if ( ok )
201 {
202 const Qgis::RenderUnit unit = ( item.compare( tr( "Millimeter" ) ) == 0 ) ? Qgis::RenderUnit::Millimeters : Qgis::RenderUnit::MapUnits;
203
204 const auto constSymbolList = symbolList;
205 for ( QgsSymbol *symbol : constSymbolList )
206 {
207 if ( symbol )
208 symbol->setOutputUnit( unit );
209 }
211 }
212}
213
215{
216 const QList<QgsSymbol *> symbolList = selectedSymbols();
217 if ( symbolList.isEmpty() )
218 {
219 return;
220 }
221
222 QgsDataDefinedWidthDialog dlg( symbolList, mLayer );
223
224 dlg.setContext( mContext );
225
226 if ( QDialog::Accepted == dlg.exec() )
227 {
228 if ( !dlg.mDDBtn->isActive() )
229 {
230 const auto constSymbolList = symbolList;
231 for ( QgsSymbol *symbol : constSymbolList )
232 {
233 if ( !symbol )
234 continue;
235
236 if ( symbol->type() == Qgis::SymbolType::Line )
237 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->value() );
238 }
239 }
241 }
242}
243
245{
246 const QList<QgsSymbol *> symbolList = selectedSymbols();
247 if ( symbolList.isEmpty() )
248 {
249 return;
250 }
251
252 QgsDataDefinedSizeDialog dlg( symbolList, mLayer );
253 dlg.setContext( mContext );
254
255 if ( QDialog::Accepted == dlg.exec() )
256 {
257 if ( !dlg.mDDBtn->isActive() )
258 {
259 const auto constSymbolList = symbolList;
260 for ( QgsSymbol *symbol : constSymbolList )
261 {
262 if ( !symbol )
263 continue;
264
265 if ( symbol->type() == Qgis::SymbolType::Marker )
266 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->value() );
267 }
268 }
270 }
271}
272
274{
275 const QList<QgsSymbol *> symbolList = selectedSymbols();
276 if ( symbolList.isEmpty() )
277 {
278 return;
279 }
280
281 QgsDataDefinedRotationDialog dlg( symbolList, mLayer );
282 dlg.setContext( mContext );
283
284 if ( QDialog::Accepted == dlg.exec() )
285 {
286 if ( !dlg.mDDBtn->isActive() )
287 {
288 const auto constSymbolList = symbolList;
289 for ( QgsSymbol *symbol : constSymbolList )
290 {
291 if ( !symbol )
292 continue;
293
294 if ( symbol->type() == Qgis::SymbolType::Marker )
295 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->value() );
296 }
297 }
299 }
300}
301
306
307void QgsRendererWidget::copySymbol()
308{
309 const QList<QgsSymbol *> symbolList = selectedSymbols();
310 if ( symbolList.isEmpty() )
311 {
312 return;
313 }
314
315 QApplication::clipboard()->setMimeData( QgsSymbolLayerUtils::symbolToMimeData( symbolList.at( 0 ) ) );
316}
317
318void QgsRendererWidget::updateDataDefinedProperty()
319{
320 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
321 const QgsFeatureRenderer::Property key = static_cast< QgsFeatureRenderer::Property >( button->propertyKey() );
322 renderer()->setDataDefinedProperty( key, button->toProperty() );
323 emit widgetChanged();
324}
325
327{
329 if ( panel && panel->dockMode() )
330 {
332 widget->setPanelTitle( tr( "Symbol Levels" ) );
333 connect( widget, &QgsPanelWidget::widgetChanged, this, [ = ]()
334 {
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}
399
401{
402 // note that we don't specify the layer here -- we don't want to expose a choice of fields for renderer level buttons,
403 // as the settings apply to the WHOLE layer and aren't evaluated on a feature-by-feature basis
404 button->init( static_cast< int >( key ), renderer()->dataDefinedProperties(), QgsFeatureRenderer::propertyDefinitions(), nullptr, true );
405 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRendererWidget::updateDataDefinedProperty );
406
408}
409
411{
412 if ( auto *lExpressionContext = mContext.expressionContext() )
413 return *lExpressionContext;
414
416
417 // additional scopes
418 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
419 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
420 {
421 expContext.appendScope( new QgsExpressionContextScope( scope ) );
422 }
423
424 //TODO - show actual value
425 expContext.setOriginalValueVariable( QVariant() );
426
427 QStringList highlights;
429
430 if ( expContext.hasVariable( QStringLiteral( "zoom_level" ) ) )
431 {
432 highlights << QStringLiteral( "zoom_level" );
433 }
434 if ( expContext.hasVariable( QStringLiteral( "vector_tile_zoom" ) ) )
435 {
436 highlights << QStringLiteral( "vector_tile_zoom" );
437 }
438
439 expContext.setHighlightedVariables( highlights );
440
441 return expContext;
442}
443
444//
445// QgsDataDefinedValueDialog
446//
447
448QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
449 : mSymbolList( symbolList )
450 , mLayer( layer )
451{
452 setupUi( this );
453 setWindowFlags( Qt::WindowStaysOnTopHint );
454 mLabel->setText( label );
456}
457
459{
460 mContext = context;
461}
462
464{
465 return mContext;
466}
467
468QgsExpressionContext QgsDataDefinedValueDialog::createExpressionContext() const
469{
470 QgsExpressionContext expContext;
471 if ( auto *lMapCanvas = mContext.mapCanvas() )
472 {
473 expContext = lMapCanvas->createExpressionContext();
474 }
475 else
476 {
481 }
482
483 if ( auto *lVectorLayer = vectorLayer() )
484 expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
485
486 // additional scopes
487 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
488 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
489 {
490 expContext.appendScope( new QgsExpressionContextScope( scope ) );
491 }
492
493 return expContext;
494}
495
496void QgsDataDefinedValueDialog::init( int propertyKey )
497{
498 const QgsProperty dd( symbolDataDefined() );
499
500 mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
501 mDDBtn->registerExpressionContextGenerator( this );
502
503 QgsSymbol *initialSymbol = nullptr;
504 const auto constMSymbolList = mSymbolList;
505 for ( QgsSymbol *symbol : constMSymbolList )
506 {
507 if ( symbol )
508 {
509 initialSymbol = symbol;
510 }
511 }
512 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
513 mSpinBox->setEnabled( !mDDBtn->isActive() );
514}
515
516QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
517{
518 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
519 return QgsProperty();
520
521 // check that all symbols share the same size expression
522 const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
523 const auto constMSymbolList = mSymbolList;
524 for ( QgsSymbol *it : constMSymbolList )
525 {
526 const QgsProperty symbolDD( symbolDataDefined( it ) );
527 if ( !it || !dd || !symbolDD || symbolDD != dd )
528 return QgsProperty();
529 }
530 return dd;
531}
532
534{
535 const QgsProperty dd( mDDBtn->toProperty() );
536 mSpinBox->setEnabled( !dd.isActive() );
537
538 const QgsProperty symbolDD( symbolDataDefined() );
539
540 if ( // shall we remove datadefined expressions for layers ?
541 ( symbolDD && symbolDD.isActive() && !dd.isActive() )
542 // shall we set the "en masse" expression for properties ?
543 || dd.isActive() )
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
628}
@ ScaleDiameter
Calculate scale by the diameter.
RenderUnit
Rendering size units.
Definition qgis.h:4839
@ 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:632
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.