QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
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, [this, widget]() { setSymbolLevels( widget->symbolLevels(), widget->usingLevels() ); } );
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
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
395{
396 // note that we don't specify the layer here -- we don't want to expose a choice of fields for renderer level buttons,
397 // as the settings apply to the WHOLE layer and aren't evaluated on a feature-by-feature basis
398 button->init( static_cast<int>( key ), renderer()->dataDefinedProperties(), QgsFeatureRenderer::propertyDefinitions(), nullptr, true );
399 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsRendererWidget::updateDataDefinedProperty );
400
402}
403
405{
406 if ( auto *lExpressionContext = mContext.expressionContext() )
407 return *lExpressionContext;
408
409 QgsExpressionContext expContext( mContext.globalProjectAtlasMapLayerScopes( vectorLayer() ) );
410
411 // additional scopes
412 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
413 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
414 {
415 expContext.appendScope( new QgsExpressionContextScope( scope ) );
416 }
417
418 //TODO - show actual value
419 expContext.setOriginalValueVariable( QVariant() );
420
421 QStringList highlights;
423
424 if ( expContext.hasVariable( u"zoom_level"_s ) )
425 {
426 highlights << u"zoom_level"_s;
427 }
428 if ( expContext.hasVariable( u"vector_tile_zoom"_s ) )
429 {
430 highlights << u"vector_tile_zoom"_s;
431 }
432
433 expContext.setHighlightedVariables( highlights );
434
435 return expContext;
436}
437
438//
439// QgsDataDefinedValueDialog
440//
441
442QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
443 : mSymbolList( symbolList )
444 , mLayer( layer )
445{
446 setupUi( this );
447 setWindowFlags( Qt::WindowStaysOnTopHint );
448 mLabel->setText( label );
450}
451
456
458{
459 return mContext;
460}
461
463{
464 QgsExpressionContext expContext;
465 if ( auto *lMapCanvas = mContext.mapCanvas() )
466 {
467 expContext = lMapCanvas->createExpressionContext();
468 }
469 else
470 {
471 expContext
475 << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() );
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{}
@ ScaleDiameter
Calculate scale by the diameter.
Definition qgis.h:652
@ Point
Points.
Definition qgis.h:380
@ Line
Lines.
Definition qgis.h:381
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
@ MapUnits
Map units.
Definition qgis.h:5342
@ Marker
Marker symbol.
Definition qgis.h:637
@ Line
Line symbol.
Definition qgis.h:638
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:227
qreal opacity() const
Returns the opacity for the symbol.
Definition qgssymbol.h:677
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.