QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 
18 #include "qgssymbol.h"
19 #include "qgsvectorlayer.h"
20 #include "qgscolordialog.h"
21 #include "qgssymbollevelsdialog.h"
22 #include "qgssymbollayer.h"
24 #include "qgsmapcanvas.h"
25 #include "qgspanelwidget.h"
26 #include "qgsproject.h"
28 #include "qgssymbollayerutils.h"
29 #include "qgstemporalcontroller.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() == QgsUnitTypes::RenderMillimeters ) ? 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 QgsUnitTypes::RenderUnit unit = ( item.compare( tr( "Millimeter" ) ) == 0 ) ? QgsUnitTypes::RenderMillimeters : QgsUnitTypes::RenderMapUnits;
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 
303 {
304 
305 }
306 
307 void 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 
319 {
321  if ( panel && panel->dockMode() )
322  {
324  widget->setPanelTitle( tr( "Symbol Levels" ) );
325  connect( widget, &QgsPanelWidget::widgetChanged, this, [ = ]()
326  {
327  setSymbolLevels( widget->symbolLevels(), widget->usingLevels() );
328  } );
329  panel->openPanel( widget );
330  }
331  else
332  {
333  QgsSymbolLevelsDialog dlg( r, r->usingSymbolLevels(), panel );
334  if ( dlg.exec() )
335  {
336  setSymbolLevels( dlg.symbolLevels(), dlg.usingLevels() );
337  }
338  }
339 }
340 
342 {
343  mContext = context;
344 }
345 
347 {
348  return mContext;
349 }
350 
352 {
353  apply();
354 }
355 
356 void QgsRendererWidget::setDockMode( bool dockMode )
357 {
358  if ( dockMode )
359  {
360  // when in dock mode, these shortcuts conflict with the main window shortcuts and cannot be used
361  if ( mCopyAction )
362  mCopyAction->setShortcut( QKeySequence() );
363  if ( mPasteAction )
364  mPasteAction->setShortcut( QKeySequence() );
365  }
367 }
368 
370 {
371 }
372 
374 {
375  const QgsProperty ddSize = symbol->dataDefinedSize();
376  if ( !ddSize || !ddSize.isActive() )
377  {
378  QMessageBox::warning( this, tr( "Data-defined Size Legend" ), tr( "Data-defined size is not enabled!" ) );
379  return nullptr;
380  }
381 
382  QgsDataDefinedSizeLegendWidget *panel = new QgsDataDefinedSizeLegendWidget( ddsLegend, ddSize, symbol->clone(), mContext.mapCanvas() );
384  return panel;
385 }
386 
387 void QgsRendererWidget::setSymbolLevels( const QList< QgsLegendSymbolItem > &, bool )
388 {
389 
390 }
391 
392 //
393 // QgsDataDefinedValueDialog
394 //
395 
396 QgsDataDefinedValueDialog::QgsDataDefinedValueDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label )
397  : mSymbolList( symbolList )
398  , mLayer( layer )
399 {
400  setupUi( this );
401  setWindowFlags( Qt::WindowStaysOnTopHint );
402  mLabel->setText( label );
404 }
405 
407 {
408  mContext = context;
409 }
410 
412 {
413  return mContext;
414 }
415 
416 QgsExpressionContext QgsDataDefinedValueDialog::createExpressionContext() const
417 {
418  QgsExpressionContext expContext;
422  if ( auto *lMapCanvas = mContext.mapCanvas() )
423  {
424  expContext << QgsExpressionContextUtils::mapSettingsScope( lMapCanvas->mapSettings() )
425  << new QgsExpressionContextScope( lMapCanvas->expressionContextScope() );
426 
427  if ( const QgsExpressionContextScopeGenerator *generator = dynamic_cast< const QgsExpressionContextScopeGenerator * >( lMapCanvas->temporalController() ) )
428  {
429  expContext << generator->createExpressionContextScope();
430  }
431  }
432  else
433  {
435  }
436 
437  if ( auto *lVectorLayer = vectorLayer() )
438  expContext << QgsExpressionContextUtils::layerScope( lVectorLayer );
439 
440  // additional scopes
441  const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
442  for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
443  {
444  expContext.appendScope( new QgsExpressionContextScope( scope ) );
445  }
446 
447  return expContext;
448 }
449 
450 void QgsDataDefinedValueDialog::init( int propertyKey )
451 {
452  const QgsProperty dd( symbolDataDefined() );
453 
454  mDDBtn->init( propertyKey, dd, QgsSymbolLayer::propertyDefinitions(), mLayer );
455  mDDBtn->registerExpressionContextGenerator( this );
456 
457  QgsSymbol *initialSymbol = nullptr;
458  const auto constMSymbolList = mSymbolList;
459  for ( QgsSymbol *symbol : constMSymbolList )
460  {
461  if ( symbol )
462  {
463  initialSymbol = symbol;
464  }
465  }
466  mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
467  mSpinBox->setEnabled( !mDDBtn->isActive() );
468 }
469 
470 QgsProperty QgsDataDefinedValueDialog::symbolDataDefined() const
471 {
472  if ( mSymbolList.isEmpty() || !mSymbolList.back() )
473  return QgsProperty();
474 
475  // check that all symbols share the same size expression
476  const QgsProperty dd = symbolDataDefined( mSymbolList.back() );
477  const auto constMSymbolList = mSymbolList;
478  for ( QgsSymbol *it : constMSymbolList )
479  {
480  const QgsProperty symbolDD( symbolDataDefined( it ) );
481  if ( !it || !dd || !symbolDD || symbolDD != dd )
482  return QgsProperty();
483  }
484  return dd;
485 }
486 
488 {
489  const QgsProperty dd( mDDBtn->toProperty() );
490  mSpinBox->setEnabled( !dd.isActive() );
491 
492  const QgsProperty symbolDD( symbolDataDefined() );
493 
494  if ( // shall we remove datadefined expressions for layers ?
495  ( symbolDD && symbolDD.isActive() && !dd.isActive() )
496  // shall we set the "en masse" expression for properties ?
497  || dd.isActive() )
498  {
499  const auto constMSymbolList = mSymbolList;
500  for ( QgsSymbol *it : constMSymbolList )
501  setDataDefined( it, dd );
502  }
503 }
504 
505 QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
506  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Size" ) )
507 {
509  if ( !symbolList.isEmpty() && symbolList.at( 0 ) && vectorLayer() )
510  {
511  mAssistantSymbol.reset( static_cast<const QgsMarkerSymbol *>( symbolList.at( 0 ) )->clone() );
512  mDDBtn->setSymbol( mAssistantSymbol );
513  }
514 }
515 
517 {
518  const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
519  return marker->dataDefinedSize();
520 }
521 
522 double QgsDataDefinedSizeDialog::value( const QgsSymbol *symbol ) const
523 {
524  return static_cast<const QgsMarkerSymbol *>( symbol )->size();
525 }
526 
528 {
529  static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedSize( dd );
530  static_cast<QgsMarkerSymbol *>( symbol )->setScaleMethod( Qgis::ScaleMethod::ScaleDiameter );
531 }
532 
533 
534 QgsDataDefinedRotationDialog::QgsDataDefinedRotationDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
535  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Rotation" ) )
536 {
538 }
539 
541 {
542  const QgsMarkerSymbol *marker = static_cast<const QgsMarkerSymbol *>( symbol );
543  return marker->dataDefinedAngle();
544 }
545 
546 double QgsDataDefinedRotationDialog::value( const QgsSymbol *symbol ) const
547 {
548  return static_cast<const QgsMarkerSymbol *>( symbol )->angle();
549 }
550 
552 {
553  static_cast<QgsMarkerSymbol *>( symbol )->setDataDefinedAngle( dd );
554 }
555 
556 
557 QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog( const QList<QgsSymbol *> &symbolList, QgsVectorLayer *layer )
558  : QgsDataDefinedValueDialog( symbolList, layer, tr( "Width" ) )
559 {
561 }
562 
564 {
565  const QgsLineSymbol *line = static_cast<const QgsLineSymbol *>( symbol );
566  return line->dataDefinedWidth();
567 }
568 
569 double QgsDataDefinedWidthDialog::value( const QgsSymbol *symbol ) const
570 {
571  return static_cast<const QgsLineSymbol *>( symbol )->width();
572 }
573 
575 {
576  static_cast<QgsLineSymbol *>( symbol )->setDataDefinedWidth( dd );
577 }
578 
579 void QgsRendererWidget::apply()
580 {
581 
582 }
@ ScaleDiameter
Calculate scale by the diameter.
@ 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 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.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
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)
Abstract interface for generating an expression context scope.
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 appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
bool usingSymbolLevels() const
Definition: qgsrenderer.h:292
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:30
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.
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.
Definition: qgsproject.cpp:470
void changed()
Emitted when property definition changes.
A store for object properties.
Definition: qgsproperty.h:231
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 paste()
virtual void pasteSymbolToSelection()
Pastes the clipboard symbol over selected items.
virtual QList< QgsSymbol * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
QgsRendererWidget(QgsVectorLayer *layer, QgsStyle *style)
virtual void refreshSymbolView()
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...
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)
virtual void setSymbolLevels(const QList< QgsLegendSymbolItem > &levels, bool enabled)
Sets the symbol levels for the renderer defined in the widget.
QgsSymbolWidgetContext context() const
Returns the context in which the renderer widget is shown, e.g., the associated map canvas and expres...
void changeSymbolColor()
Change color of selected symbols.
QAction * mCopySymbolAction
Copy symbol action.
void changeSymbolAngle()
Change marker angles of selected symbols.
virtual void copy()
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.
@ PropertyAngle
Symbol angle.
@ PropertySize
Symbol size.
@ PropertyStrokeWidth
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.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:38
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:275
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:440
QColor color() const
Returns the symbol's color.
Definition: qgssymbol.cpp:551
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:168
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786