QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
373 QgsDataDefinedSizeLegendWidget *QgsRendererWidget::createDataDefinedSizeLegendWidget( const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend )
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 }
QgsCompoundColorWidget::setAllowOpacity
void setAllowOpacity(bool allowOpacity)
Sets whether opacity modification (transparency) is permitted for the color dialog.
Definition: qgscompoundcolorwidget.cpp:303
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsProperty::isActive
bool isActive() const
Returns whether the property is currently active.
Definition: qgsproperty.cpp:291
QgsDataDefinedSizeDialog::value
double value(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:522
QgsDataDefinedSizeDialog::symbolDataDefined
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:516
QgsRendererWidget::changeSymbolWidth
void changeSymbolWidth()
Change line widths of selected symbols.
Definition: qgsrendererwidget.cpp:214
qgsexpressioncontextutils.h
QgsSymbolWidgetContext::mapCanvas
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
Definition: qgssymbolwidgetcontext.cpp:54
QgsSymbol::color
QColor color() const
Returns the symbol's color.
Definition: qgssymbol.cpp:877
QgsDataDefinedSizeDialog
Definition: qgsrendererwidget.h:283
QgsSymbolLevelsWidget::symbolLevels
QgsLegendSymbolList symbolLevels() const
Returns the current legend symbols with rendering passes set, as defined in the widget.
Definition: qgssymbollevelsdialog.cpp:164
QgsRendererWidget::refreshSymbolView
virtual void refreshSymbolView()
Definition: qgsrendererwidget.h:138
QgsProperty
A store for object properties.
Definition: qgsproperty.h:230
QgsRendererWidget::changeSymbolAngle
void changeSymbolAngle()
Change marker angles of selected symbols.
Definition: qgsrendererwidget.cpp:273
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
Qgis::SymbolType::Line
@ Line
Line symbol.
QgsSymbolLevelsDialog::symbolLevels
QgsLegendSymbolList symbolLevels() const
Returns the current legend symbols with rendering passes set, as defined in the widget.
Definition: qgssymbollevelsdialog.cpp:223
QgsSymbolLevelsWidget::usingLevels
bool usingLevels() const
Returns whether the level ordering is enabled.
Definition: qgssymbollevelsdialog.cpp:159
QgsExpressionContextUtils::globalScope
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Definition: qgsexpressioncontextutils.cpp:40
qgsmapcanvas.h
QgsRendererWidget::mCopyAction
QAction * mCopyAction
Definition: qgsrendererwidget.h:115
QgsPanelWidget::setDockMode
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgspanelwidget.cpp:44
QgsPropertyOverrideButton::changed
void changed()
Emitted when property definition changes.
QgsPanelWidget::findParentPanel
static QgsPanelWidget * findParentPanel(QWidget *widget)
Traces through the parents of a widget to find if it is contained within a QgsPanelWidget widget.
Definition: qgspanelwidget.cpp:54
QgsRendererWidget::mLayer
QgsVectorLayer * mLayer
Definition: qgsrendererwidget.h:112
QgsSymbolLayerUtils::symbolFromMimeData
static QgsSymbol * symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
Definition: qgssymbollayerutils.cpp:3305
QgsMarkerSymbol::dataDefinedSize
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:343
QgsRendererWidget::mPasteSymbolAction
QAction * mPasteSymbolAction
Paste symbol action.
Definition: qgsrendererwidget.h:128
qgssymbollayerutils.h
QgsDataDefinedValueDialog::dataDefinedChanged
void dataDefinedChanged()
Definition: qgsrendererwidget.cpp:487
QgsRendererWidget::context
QgsSymbolWidgetContext context() const
Returns the context in which the renderer widget is shown, e.g., the associated map canvas and expres...
Definition: qgsrendererwidget.cpp:346
QgsDataDefinedValueDialog::vectorLayer
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
Definition: qgsrendererwidget.h:250
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:334
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsDataDefinedWidthDialog::symbolDataDefined
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:563
QgsPanelWidget::openPanel
void openPanel(QgsPanelWidget *panel)
Open a panel or dialog depending on dock mode setting If dock mode is true this method will emit the ...
Definition: qgspanelwidget.cpp:84
QgsDataDefinedWidthDialog::QgsDataDefinedWidthDialog
QgsDataDefinedWidthDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
Definition: qgsrendererwidget.cpp:557
QgsRendererWidget::applyChanges
void applyChanges()
This method should be called whenever the renderer is actually set on the layer.
Definition: qgsrendererwidget.cpp:351
QgsDataDefinedSizeLegend
Object that keeps configuration of appearance of marker symbol's data-defined size in legend.
Definition: qgsdatadefinedsizelegend.h:42
QgsDataDefinedSizeDialog::QgsDataDefinedSizeDialog
QgsDataDefinedSizeDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
Definition: qgsrendererwidget.cpp:505
QgsDataDefinedRotationDialog::QgsDataDefinedRotationDialog
QgsDataDefinedRotationDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer)
Definition: qgsrendererwidget.cpp:534
QgsExpressionContextUtils::mapSettingsScope
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object.
Definition: qgsexpressioncontextutils.cpp:427
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:480
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsFeatureRenderer::legendSymbolItems
virtual QgsLegendSymbolList legendSymbolItems() const
Returns a list of symbology items for the legend.
Definition: qgsrenderer.cpp:377
qgsdatadefinedsizelegendwidget.h
QgsExpressionContextScopeGenerator
Abstract interface for generating an expression context scope.
Definition: qgsexpressioncontextscopegenerator.h:28
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsDataDefinedRotationDialog::symbolDataDefined
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:540
QgsSymbol::outputUnit
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Definition: qgssymbol.cpp:578
qgssymbollevelsdialog.h
Qgis::ScaleMethod::ScaleDiameter
@ ScaleDiameter
Calculate scale by the diameter.
QgsPanelWidget::dockMode
bool dockMode()
Returns the dock mode state.
Definition: qgspanelwidget.h:93
QgsSymbolLevelsWidget
A widget which allows the user to modify the rendering order of symbol layers.
Definition: qgssymbollevelsdialog.h:37
QgsDataDefinedWidthDialog::value
double value(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:569
QgsMarkerSymbol::clone
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
Definition: qgsmarkersymbol.cpp:523
QgsRendererWidget::disableSymbolLevels
virtual void disableSymbolLevels()
Disables symbol level modification on the widget.
Definition: qgsrendererwidget.cpp:369
QgsSymbolLayerUtils::symbolToMimeData
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
Definition: qgssymbollayerutils.cpp:3287
QgsCompoundColorWidget
A custom QGIS widget for selecting a color, including options for selecting colors via hue wheel,...
Definition: qgscompoundcolorwidget.h:33
QgsDataDefinedRotationDialog::value
double value(const QgsSymbol *symbol) const override
Definition: qgsrendererwidget.cpp:546
QgsSymbolLayer::propertyDefinitions
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Definition: qgssymbollayer.cpp:292
QgsCompoundColorWidget::LayoutVertical
@ LayoutVertical
Use a narrower, vertically stacked layout.
Definition: qgscompoundcolorwidget.h:44
qgstemporalcontroller.h
QgsSymbol::opacity
qreal opacity() const
Returns the opacity for the symbol.
Definition: qgssymbol.h:495
QgsCompoundColorWidget::currentColorChanged
void currentColorChanged(const QColor &color)
Emitted when the dialog's color changes.
QgsExpressionContextUtils::projectScope
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
Definition: qgsexpressioncontextutils.cpp:291
QgsPanelWidget
Base class for any widget that can be shown as a inline panel.
Definition: qgspanelwidget.h:29
QgsDataDefinedValueDialog::setContext
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Definition: qgsrendererwidget.cpp:406
QgsRendererWidget::copy
virtual void copy()
Definition: qgsrendererwidget.h:174
QgsDataDefinedValueDialog
Utility classes for "en masse" size definition.
Definition: qgsrendererwidget.h:216
QgsRendererWidget::pasteSymbolToSelection
virtual void pasteSymbolToSelection()
Pastes the clipboard symbol over selected items.
Definition: qgsrendererwidget.cpp:302
QgsRendererWidget::mCopySymbolAction
QAction * mCopySymbolAction
Copy symbol action.
Definition: qgsrendererwidget.h:122
QgsDataDefinedRotationDialog::setDataDefined
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
Definition: qgsrendererwidget.cpp:551
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsSymbolLevelsDialog::usingLevels
bool usingLevels() const
Returns whether the level ordering is enabled.
Definition: qgssymbollevelsdialog.cpp:218
QgsDataDefinedValueDialog::QgsDataDefinedValueDialog
QgsDataDefinedValueDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
Definition: qgsrendererwidget.cpp:396
QgsRendererWidget::mPasteAction
QAction * mPasteAction
Definition: qgsrendererwidget.h:116
QgsDataDefinedRotationDialog
Definition: qgsrendererwidget.h:305
QgsSymbolLayer::PropertySize
@ PropertySize
Symbol size.
Definition: qgssymbollayer.h:144
QgsRendererWidget::setDockMode
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Definition: qgsrendererwidget.cpp:356
QgsPanelWidget::widgetChanged
void widgetChanged()
Emitted when the widget state changes.
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsFeatureRenderer::usingSymbolLevels
bool usingSymbolLevels() const
Definition: qgsrenderer.h:292
QgsLineSymbol::dataDefinedWidth
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
Definition: qgslinesymbol.cpp:178
qgssymbollayer.h
QgsRendererWidget::changeSymbolSize
void changeSymbolSize()
Change marker sizes of selected symbols.
Definition: qgsrendererwidget.cpp:244
QgsRendererWidget::setSymbolLevels
virtual void setSymbolLevels(const QList< QgsLegendSymbolItem > &levels, bool enabled)
Sets the symbol levels for the renderer defined in the widget.
Definition: qgsrendererwidget.cpp:387
QgsDataDefinedValueDialog::init
void init(int propertyKey)
Should be called in the constructor of child classes.
Definition: qgsrendererwidget.cpp:450
QgsSymbolLayer::PropertyStrokeWidth
@ PropertyStrokeWidth
Stroke width.
Definition: qgssymbollayer.h:149
QgsPanelWidget::setPanelTitle
void setPanelTitle(const QString &panelTitle)
Set the title of the panel when shown in the interface.
Definition: qgspanelwidget.h:44
QgsRendererWidget::contextMenu
QMenu * contextMenu
Definition: qgsrendererwidget.h:114
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:113
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:494
qgsvectorlayer.h
qgscolordialog.h
QgsSymbolLevelsDialog
A dialog which allows the user to modify the rendering order of symbol layers.
Definition: qgssymbollevelsdialog.h:105
QgsRendererWidget::selectedSymbols
virtual QList< QgsSymbol * > selectedSymbols()
Subclasses may provide the capability of changing multiple symbols at once by implementing the follow...
Definition: qgsrendererwidget.h:137
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:143
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
QgsRendererWidget::createDataDefinedSizeLegendWidget
QgsDataDefinedSizeLegendWidget * createDataDefinedSizeLegendWidget(const QgsMarkerSymbol *symbol, const QgsDataDefinedSizeLegend *ddsLegend)
Creates widget to setup data-defined size legend.
Definition: qgsrendererwidget.cpp:373
QgsFeatureRenderer
Definition: qgsrenderer.h:101
QgsRendererWidget::paste
virtual void paste()
Definition: qgsrendererwidget.h:175
QgsRendererWidget::contextMenuViewCategories
void contextMenuViewCategories(QPoint p)
Definition: qgsrendererwidget.cpp:80
QgsStyle
Definition: qgsstyle.h:159
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsMarkerSymbol::dataDefinedAngle
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
Definition: qgsmarkersymbol.cpp:106
qgsmarkersymbol.h
QgsRendererWidget::mContext
QgsSymbolWidgetContext mContext
Context in which widget is shown.
Definition: qgsrendererwidget.h:131
QgsDataDefinedValueDialog::context
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
Definition: qgsrendererwidget.cpp:411
QgsSymbolLayer::PropertyAngle
@ PropertyAngle
Symbol angle.
Definition: qgssymbollayer.h:145
qgsrendererwidget.h
QgsExpressionContextUtils::atlasScope
static QgsExpressionContextScope * atlasScope(const QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
Definition: qgsexpressioncontextutils.cpp:660
QgsDataDefinedSizeDialog::setDataDefined
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
Definition: qgsrendererwidget.cpp:527
QgsRendererWidget::QgsRendererWidget
QgsRendererWidget(QgsVectorLayer *layer, QgsStyle *style)
Definition: qgsrendererwidget.cpp:38
qgspanelwidget.h
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88
QgsVectorLayer::geometryType
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
Definition: qgsvectorlayer.cpp:720
QgsRendererWidget::changeSymbolOpacity
void changeSymbolOpacity()
Change opacity of selected symbols.
Definition: qgsrendererwidget.cpp:140
MathUtils::angle
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
QgsRendererWidget::setContext
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the renderer widget is shown, e.g., the associated map canvas and expressio...
Definition: qgsrendererwidget.cpp:341
qgssymbol.h
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
qgsproject.h
Qgis::SymbolType::Marker
@ Marker
Marker symbol.
QgsSymbolWidgetContext::additionalExpressionContextScopes
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer.
Definition: qgssymbolwidgetcontext.cpp:87
QgsColorDialog::getColor
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), bool allowOpacity=false)
Returns a color selection from a color dialog.
Definition: qgscolordialog.cpp:81
QgsRendererWidget::changeSymbolColor
void changeSymbolColor()
Change color of selected symbols.
Definition: qgsrendererwidget.cpp:85
QgsRendererWidget::showSymbolLevelsDialog
void showSymbolLevelsDialog(QgsFeatureRenderer *r)
Show a dialog with renderer's symbol level settings.
Definition: qgsrendererwidget.cpp:318
qgslinesymbol.h
QgsDataDefinedWidthDialog
Definition: qgsrendererwidget.h:323
qgsexpressionbuilderdialog.h
QgsRendererWidget::changeSymbolUnit
void changeSymbolUnit()
Change units mm/map units of selected symbols.
Definition: qgsrendererwidget.cpp:176
QgsDataDefinedWidthDialog::setDataDefined
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
Definition: qgsrendererwidget.cpp:574