QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgslayerpropertieswidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayerpropertieswidget.cpp
3 ----------------------------
4 begin : June 2012
5 copyright : (C) 2012 by Arunmozhi
6 email : aruntheguy at gmail.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
17
18#include "qgsapplication.h"
22#include "qgsfillsymbol.h"
25#include "qgslinesymbol.h"
26#include "qgslogger.h"
27#include "qgsmapcanvas.h"
28#include "qgsmarkersymbol.h"
31#include "qgspainteffect.h"
33#include "qgspanelwidget.h"
34#include "qgsproject.h"
35#include "qgssymbol.h"
36#include "qgssymbollayer.h"
38#include "qgssymbollayerutils.h"
42#include "qgsvectorlayer.h"
43
44#include <QFile>
45#include <QKeyEvent>
46#include <QMessageBox>
47#include <QPicture>
48#include <QStandardItem>
49#include <QString>
50
51#include "moc_qgslayerpropertieswidget.cpp"
52
53using namespace Qt::StringLiterals;
54
55static bool _initWidgetFunction( const QString &name, QgsSymbolLayerWidgetFunc f )
56{
58
59 QgsSymbolLayerAbstractMetadata *abstractMetadata = reg->symbolLayerMetadata( name );
60 if ( !abstractMetadata )
61 {
62 QgsDebugError( "Failed to find symbol layer's entry in registry: " + name );
63 return false;
64 }
65 QgsSymbolLayerMetadata *metadata = dynamic_cast<QgsSymbolLayerMetadata *>( abstractMetadata );
66 if ( !metadata )
67 {
68 QgsDebugError( "Failed to cast symbol layer's metadata: " + name );
69 return false;
70 }
71 metadata->setWidgetFunction( f );
72 return true;
73}
74
75static void _initWidgetFunctions()
76{
77 static bool sInitialized = false;
78 if ( sInitialized )
79 return;
80
81 _initWidgetFunction( u"SimpleLine"_s, QgsSimpleLineSymbolLayerWidget::create );
82 _initWidgetFunction( u"MarkerLine"_s, QgsMarkerLineSymbolLayerWidget::create );
83 _initWidgetFunction( u"HashLine"_s, QgsHashedLineSymbolLayerWidget::create );
84 _initWidgetFunction( u"ArrowLine"_s, QgsArrowSymbolLayerWidget::create );
85 _initWidgetFunction( u"InterpolatedLine"_s, QgsInterpolatedLineSymbolLayerWidget::create );
86 _initWidgetFunction( u"RasterLine"_s, QgsRasterLineSymbolLayerWidget::create );
87 _initWidgetFunction( u"Lineburst"_s, QgsLineburstSymbolLayerWidget::create );
88 _initWidgetFunction( u"FilledLine"_s, QgsFilledLineSymbolLayerWidget::create );
89 _initWidgetFunction( u"LinearReferencing"_s, QgsLinearReferencingSymbolLayerWidget::create );
90
91 _initWidgetFunction( u"SimpleMarker"_s, QgsSimpleMarkerSymbolLayerWidget::create );
92 _initWidgetFunction( u"FilledMarker"_s, QgsFilledMarkerSymbolLayerWidget::create );
93 _initWidgetFunction( u"SvgMarker"_s, QgsSvgMarkerSymbolLayerWidget::create );
94 _initWidgetFunction( u"RasterMarker"_s, QgsRasterMarkerSymbolLayerWidget::create );
95 _initWidgetFunction( u"AnimatedMarker"_s, QgsAnimatedMarkerSymbolLayerWidget::create );
96 _initWidgetFunction( u"FontMarker"_s, QgsFontMarkerSymbolLayerWidget::create );
97 _initWidgetFunction( u"EllipseMarker"_s, QgsEllipseSymbolLayerWidget::create );
98 _initWidgetFunction( u"VectorField"_s, QgsVectorFieldSymbolLayerWidget::create );
99 _initWidgetFunction( u"MaskMarker"_s, QgsMaskMarkerSymbolLayerWidget::create );
100
101 _initWidgetFunction( u"SimpleFill"_s, QgsSimpleFillSymbolLayerWidget::create );
102 _initWidgetFunction( u"GradientFill"_s, QgsGradientFillSymbolLayerWidget::create );
103 _initWidgetFunction( u"ShapeburstFill"_s, QgsShapeburstFillSymbolLayerWidget::create );
104 _initWidgetFunction( u"RasterFill"_s, QgsRasterFillSymbolLayerWidget::create );
105 _initWidgetFunction( u"SVGFill"_s, QgsSVGFillSymbolLayerWidget::create );
106 _initWidgetFunction( u"CentroidFill"_s, QgsCentroidFillSymbolLayerWidget::create );
107 _initWidgetFunction( u"LinePatternFill"_s, QgsLinePatternFillSymbolLayerWidget::create );
108 _initWidgetFunction( u"PointPatternFill"_s, QgsPointPatternFillSymbolLayerWidget::create );
109 _initWidgetFunction( u"RandomMarkerFill"_s, QgsRandomMarkerFillSymbolLayerWidget::create );
110
111 _initWidgetFunction( u"GeometryGenerator"_s, QgsGeometryGeneratorSymbolLayerWidget::create );
112
113 sInitialized = true;
114}
115
116
118 : QgsPanelWidget( parent )
119 , mLayer( layer )
120 , mSymbol( symbol )
121 , mVectorLayer( vl )
122{
123 setupUi( this );
124 connect( mEnabledCheckBox, &QCheckBox::toggled, this, &QgsLayerPropertiesWidget::mEnabledCheckBox_toggled );
125 // initialize the sub-widgets
126 // XXX Should this thing be here this way? Initialize all the widgets just for the sake of one layer?
127 // TODO Make this on demand creation
128 _initWidgetFunctions();
129
130 // TODO Algorithm
131 //
132 // 3. populate the combo box with the supported layer type
133 // 4. set the present layer type
134 // 5. create the widget for the present layer type and set in stacked widget
135 // 6. connect comboBox type changed to two things
136 // 1. emit signal that type has beed changed
137 // 2. remove the widget and place the new widget corresponding to the changed layer type
138 //
140 // update layer type combo box
141 const int idx = cboLayerType->findData( mLayer->layerType() );
142 cboLayerType->setCurrentIndex( idx );
143
144 connect( mEnabledCheckBox, &QAbstractButton::toggled, mEnabledDDBtn, &QWidget::setEnabled );
145 mEnabledCheckBox->setChecked( mLayer->enabled() );
146
147 // set the corresponding widget
149 connect( cboLayerType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayerPropertiesWidget::layerTypeChanged );
150
152
153 this->connectChildPanel( mEffectWidget );
154
155 if ( !mLayer->paintEffect() )
156 {
157 mLayer->setPaintEffect( QgsPaintEffectRegistry::defaultStack() );
158 mLayer->paintEffect()->setEnabled( false );
159 }
160 mEffectWidget->setPaintEffect( mLayer->paintEffect() );
161
163}
164
166{
167 mContext = context;
168 if ( mSymbol )
169 mContext.setSymbolType( mSymbol->type() );
170
171 QgsSymbolLayerWidget *w = dynamic_cast<QgsSymbolLayerWidget *>( stackedWidget->currentWidget() );
172 if ( w )
173 w->setContext( mContext );
174}
175
177{
178 return mContext;
179}
180
182{
184 mEffectWidget->setDockMode( this->dockMode() );
185}
186
188{
189 const QStringList symbolLayerIds = QgsApplication::symbolLayerRegistry()->symbolLayersForType( mSymbol->type() );
190
191 const auto constSymbolLayerIds = symbolLayerIds;
192 for ( const QString &symbolLayerId : constSymbolLayerIds )
193 cboLayerType->addItem( QgsApplication::symbolLayerRegistry()->symbolLayerMetadata( symbolLayerId )->visibleName(), symbolLayerId );
194
195 if ( mSymbol->type() == Qgis::SymbolType::Fill )
196 {
198 const auto constLineLayerIds = lineLayerIds;
199 for ( const QString &lineLayerId : constLineLayerIds )
200 {
202 if ( layerInfo->type() != Qgis::SymbolType::Hybrid )
203 {
204 const QString visibleName = layerInfo->visibleName();
205 const QString name = tr( "Outline: %1" ).arg( visibleName );
206 cboLayerType->addItem( name, lineLayerId );
207 }
208 }
209 }
210}
211
213{
214 if ( stackedWidget->currentWidget() != pageDummy )
215 {
216 // stop updating from the original widget
217 if ( QgsSymbolLayerWidget *w = qobject_cast<QgsSymbolLayerWidget *>( stackedWidget->currentWidget() ) )
219 stackedWidget->removeWidget( stackedWidget->currentWidget() );
220 }
221
223
224 const QString layerType = layer->layerType();
226 if ( am )
227 {
229 if ( w )
230 {
231 w->setContext( mContext );
232 w->setSymbolLayer( layer );
233 stackedWidget->addWidget( w );
234 stackedWidget->setCurrentWidget( w );
235 // start receiving updates from widget
237 connect( w, &QgsSymbolLayerWidget::symbolChanged, this, &QgsLayerPropertiesWidget::reloadLayer );
238 return;
239 }
240 }
241 // When anything is not right
242 stackedWidget->setCurrentWidget( pageDummy );
243}
244
246{
247 if ( auto *lExpressionContext = mContext.expressionContext() )
248 return *lExpressionContext;
249
250 QgsExpressionContext expContext;
251 if ( auto *lMapCanvas = mContext.mapCanvas() )
252 {
253 expContext = lMapCanvas->createExpressionContext();
254 }
255 else
256 {
261 }
262
264
266 if ( mLayer )
267 {
268 //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
269 //color, but that's not accessible here). 99% of the time these will be the same anyway
271 }
272 expContext << symbolScope;
278 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( u"symbol_layer_count"_s, 1, true ) );
279 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( u"symbol_layer_index"_s, 1, true ) );
280 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( u"symbol_marker_row"_s, 1, true ) );
281 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( u"symbol_marker_column"_s, 1, true ) );
282 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( u"symbol_frame"_s, 1, true ) );
283
284 // additional scopes
285 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
286 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
287 {
288 expContext.appendScope( new QgsExpressionContextScope( scope ) );
289 }
290
291 //TODO - show actual value
292 expContext.setOriginalValueVariable( QVariant() );
293
295
296 return expContext;
297}
298
300{
301 button->init( static_cast<int>( key ), mLayer->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer );
302 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLayerPropertiesWidget::updateProperty );
304}
305
306void QgsLayerPropertiesWidget::updateProperty()
307{
308 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
309 const QgsSymbolLayer::Property key = static_cast<QgsSymbolLayer::Property>( button->propertyKey() );
310 mLayer->setDataDefinedProperty( key, button->toProperty() );
311 emit changed();
312}
313
315{
316 QgsSymbolLayer *layer = mLayer;
317 if ( !layer )
318 return;
319 const QString newLayerType = cboLayerType->currentData().toString();
320 if ( layer->layerType() == newLayerType )
321 return;
322
323 // get creation function for new layer from registry
325 QgsSymbolLayerAbstractMetadata *am = pReg->symbolLayerMetadata( newLayerType );
326 if ( !am ) // check whether the metadata is assigned
327 return;
328
329 // change layer to a new (with different type)
330 // base new layer on existing layer's properties
331 QVariantMap properties = layer->properties();
332
333 // if the old symbol layer was a "geometry generator" layer then
334 // we instead get the properties from the generator
335 if ( QgsGeometryGeneratorSymbolLayer *generator = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( layer ) )
336 {
337 if ( generator->subSymbol() && generator->subSymbol()->symbolLayerCount() > 0 )
338 properties = generator->subSymbol()->symbolLayer( 0 )->properties();
339 }
340
341 QgsSymbolLayer *newLayer = am->createSymbolLayer( properties );
342 if ( !newLayer )
343 return;
344
345 // if a symbol layer is changed to a "geometry generator" layer, then we move the old symbol layer into the
346 // geometry generator's subsymbol.
347 if ( QgsGeometryGeneratorSymbolLayer *generator = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( newLayer ) )
348 {
349 if ( mSymbol )
350 {
351 switch ( mSymbol->type() )
352 {
354 {
355 auto markerSymbol = std::make_unique<QgsMarkerSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
356 generator->setSymbolType( Qgis::SymbolType::Marker );
357 generator->setSubSymbol( markerSymbol.release() );
358 break;
359 }
361 {
362 auto lineSymbol = std::make_unique<QgsLineSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
363 generator->setSymbolType( Qgis::SymbolType::Line );
364 generator->setSubSymbol( lineSymbol.release() );
365 break;
366 }
368 {
369 auto fillSymbol = std::make_unique<QgsFillSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
370 generator->setSymbolType( Qgis::SymbolType::Fill );
371 generator->setSubSymbol( fillSymbol.release() );
372 break;
373 }
375 break;
376 }
377 }
378 }
379 else
380 {
381 // try to copy the subsymbol, if its the same type as the new symbol layer's subsymbol
382 if ( newLayer->subSymbol() && layer->subSymbol() && newLayer->subSymbol()->type() == layer->subSymbol()->type() )
383 {
384 newLayer->setSubSymbol( layer->subSymbol()->clone() );
385 }
386 }
387
388 // special logic for when NEW symbol layers are created from GUI only...
389 // TODO: find a nicer generic way to handle this!
390 if ( QgsFontMarkerSymbolLayer *fontMarker = dynamic_cast<QgsFontMarkerSymbolLayer *>( newLayer ) )
391 {
392 const QString defaultFont = fontMarker->fontFamily();
393 const QFontDatabase fontDb;
394 if ( !fontDb.hasFamily( defaultFont ) )
395 {
396 // default font marker font choice doesn't exist on system, so just use first available symbol font
397 const QStringList candidates = fontDb.families( QFontDatabase::WritingSystem::Symbol );
398 bool foundGoodCandidate = false;
399 for ( const QString &candidate : candidates )
400 {
401 if ( fontDb.writingSystems( candidate ).size() == 1 )
402 {
403 // family ONLY offers symbol writing systems, so it's a good candidate!
404 fontMarker->setFontFamily( candidate );
405 foundGoodCandidate = true;
406 break;
407 }
408 }
409 if ( !foundGoodCandidate && !candidates.empty() )
410 {
411 // fallback to first available family which advertises symbol writing system
412 QString candidate = candidates.at( 0 );
413 fontMarker->setFontFamily( candidate );
414 }
415 }
416
417 // search (briefly!!) for a unicode character which actually exists in the font
418 const QFontMetrics fontMetrics( fontMarker->fontFamily() );
419 ushort character = fontMarker->character().at( 0 ).unicode();
420 for ( ; character < 1000; ++character )
421 {
422 if ( fontMetrics.inFont( QChar( character ) ) )
423 {
424 fontMarker->setCharacter( QChar( character ) );
425 break;
426 }
427 }
428 }
429
430 updateSymbolLayerWidget( newLayer );
431 emit changeLayer( newLayer );
432}
433
435{
436 emit changed();
437
438 // also update paint effect preview
439 bool paintEffectToggled = false;
440 if ( mLayer->paintEffect() && mLayer->paintEffect()->enabled() )
441 {
442 mLayer->paintEffect()->setEnabled( false );
443 paintEffectToggled = true;
444 }
446 if ( paintEffectToggled )
447 {
448 mLayer->paintEffect()->setEnabled( true );
449 }
450 emit widgetChanged();
451}
452
453void QgsLayerPropertiesWidget::reloadLayer()
454{
455 emit changeLayer( mLayer );
456}
457
458void QgsLayerPropertiesWidget::mEnabledCheckBox_toggled( bool enabled )
459{
460 mLayer->setEnabled( enabled );
462}
@ Millimeters
Millimeters.
Definition qgis.h:5256
@ Marker
Marker symbol.
Definition qgis.h:630
@ Line
Line symbol.
Definition qgis.h:631
@ Fill
Fill symbol.
Definition qgis.h:632
@ Hybrid
Hybrid symbol.
Definition qgis.h:633
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsAnimatedMarkerSymbolLayerWidget.
static QgsSymbolLayerRegistry * symbolLayerRegistry()
Returns the application's symbol layer registry, used for managing symbol layers.
static QgsSymbolLayerWidget * create(QgsVectorLayer *layer)
Static creation method.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsCentroidFillSymbolLayerWidget.
void changed()
Emitted when the paint effect properties change.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSymbolLayerWidget.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
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...
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static const QString EXPR_GEOMETRY_POINT_COUNT
Inbuilt variable name for point count variable.
static const QString EXPR_CLUSTER_SIZE
Inbuilt variable name for cluster size variable.
static const QString EXPR_GEOMETRY_POINT_NUM
Inbuilt variable name for point number variable.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
static const QString EXPR_GEOMETRY_RING_NUM
Inbuilt variable name for geometry ring number variable.
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
static const QString EXPR_SYMBOL_COLOR
Inbuilt variable name for symbol color variable.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of 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.
static const QString EXPR_CLUSTER_COLOR
Inbuilt variable name for cluster color variable.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsFilledLineSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsFilledMarkerSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsFontMarkerSymbolLayerWidget.
A marker symbol layer which displays characters rendered using a font.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Will be registered as factory.
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsGradientFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsHashedLineSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *layer)
Static creation method.
QgsLayerPropertiesWidget(QgsSymbolLayer *layer, const QgsSymbol *symbol, QgsVectorLayer *vl, QWidget *parent=nullptr)
Constructor for QgsLayerPropertiesWidget.
void setDockMode(bool dockMode) override
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
void changeLayer(QgsSymbolLayer *layer)
Emitted when the symbol layer is changed in the widget.
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
void changed()
Emitted when the symbol layer configuration is changed in the widget.
void updateSymbolLayerWidget(QgsSymbolLayer *layer)
void registerDataDefinedButton(QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key)
Registers a data defined override button.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsLinePatternFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsLinearReferencingSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsLineburstSymbolLayerWidget.
Contains configuration for rendering maps.
Struct for storing maximum and minimum scales for measurements in map units.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsMarkerLineSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *layer)
Static creation method.
static QgsPaintEffect * defaultStack()
Returns a new effect stack consisting of a sensible selection of default effects.
bool dockMode() const
Returns the dock mode state.
void connectChildPanel(QgsPanelWidget *panel)
Connect the given sub panel widgets showPanel signals to this current panels main showPanel event to ...
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.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsPointPatternFillSymbolLayerWidget.
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.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsRandomMarkerFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsRasterFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsRasterLineSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsRasterMarkerSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSVGFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsShapeburstFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSimpleFillSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSimpleLineSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSimpleMarkerSymbolLayerWidget.
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsSvgMarkerSymbolLayerWidget.
Stores metadata about one symbol layer class.
virtual QgsSymbolLayer * createSymbolLayer(const QVariantMap &map)=0
Create a symbol layer of this type given the map of properties.
virtual QgsSymbolLayerWidget * createSymbolLayerWidget(QgsVectorLayer *)
Create widget for symbol layer of this type. Can return nullptr if there's no GUI.
Convenience metadata class that uses static functions to create symbol layer and its widget.
void setWidgetFunction(QgsSymbolLayerWidgetFunc f)
Registry of available symbol layer classes.
QStringList symbolLayersForType(Qgis::SymbolType type)
Returns a list of available symbol layers for a specified symbol type.
QgsSymbolLayerAbstractMetadata * symbolLayerMetadata(const QString &name) const
Returns metadata for specified symbol layer. Returns nullptr if not found.
static QPicture symbolLayerPreviewPicture(const QgsSymbolLayer *layer, Qgis::RenderUnit units, QSize size, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::SymbolType parentSymbolType=Qgis::SymbolType::Hybrid)
Draws a symbol layer preview to a QPicture.
Abstract base class for widgets used to configure QgsSymbolLayer classes.
virtual void setSymbolLayer(QgsSymbolLayer *layer)=0
void changed()
Should be emitted whenever configuration changes happened on this symbol layer configuration.
void symbolChanged()
Should be emitted whenever the sub symbol changed on this symbol layer configuration.
virtual void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Abstract base class for symbol layers.
virtual QgsSymbolLayer * clone() const =0
Shall be reimplemented by subclasses to create a deep copy of the instance.
virtual bool setSubSymbol(QgsSymbol *symbol)
Sets layer's subsymbol. takes ownership of the passed symbol.
Property
Data definable properties.
@ LayerEnabled
Whether symbol layer is enabled.
virtual QVariantMap properties() const =0
Should be reimplemented by subclasses to return a string map that contains the configuration informat...
virtual QString layerType() const =0
Returns a string that represents this layer type.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
virtual QgsSymbol * subSymbol()
Returns the symbol's sub symbol, if present.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
virtual QgsSymbol * clone() const =0
Returns a deep copy of this symbol.
Qgis::SymbolType type() const
Returns the symbol's type.
Definition qgssymbol.h:294
static QgsSymbolLayerWidget * create(QgsVectorLayer *vl)
Creates a new QgsVectorFieldSymbolLayerWidget.
Represents a vector layer which manages a vector based dataset.
#define QgsDebugError(str)
Definition qgslogger.h:59
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30
QgsSymbolLayerWidget *(* QgsSymbolLayerWidgetFunc)(QgsVectorLayer *)
Single variable definition for use within a QgsExpressionContextScope.