QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
50#include "moc_qgslayerpropertieswidget.cpp"
51
52static bool _initWidgetFunction( const QString &name, QgsSymbolLayerWidgetFunc f )
53{
55
56 QgsSymbolLayerAbstractMetadata *abstractMetadata = reg->symbolLayerMetadata( name );
57 if ( !abstractMetadata )
58 {
59 QgsDebugError( "Failed to find symbol layer's entry in registry: " + name );
60 return false;
61 }
62 QgsSymbolLayerMetadata *metadata = dynamic_cast<QgsSymbolLayerMetadata *>( abstractMetadata );
63 if ( !metadata )
64 {
65 QgsDebugError( "Failed to cast symbol layer's metadata: " + name );
66 return false;
67 }
68 metadata->setWidgetFunction( f );
69 return true;
70}
71
72static void _initWidgetFunctions()
73{
74 static bool sInitialized = false;
75 if ( sInitialized )
76 return;
77
78 _initWidgetFunction( QStringLiteral( "SimpleLine" ), QgsSimpleLineSymbolLayerWidget::create );
79 _initWidgetFunction( QStringLiteral( "MarkerLine" ), QgsMarkerLineSymbolLayerWidget::create );
80 _initWidgetFunction( QStringLiteral( "HashLine" ), QgsHashedLineSymbolLayerWidget::create );
81 _initWidgetFunction( QStringLiteral( "ArrowLine" ), QgsArrowSymbolLayerWidget::create );
82 _initWidgetFunction( QStringLiteral( "InterpolatedLine" ), QgsInterpolatedLineSymbolLayerWidget::create );
83 _initWidgetFunction( QStringLiteral( "RasterLine" ), QgsRasterLineSymbolLayerWidget::create );
84 _initWidgetFunction( QStringLiteral( "Lineburst" ), QgsLineburstSymbolLayerWidget::create );
85 _initWidgetFunction( QStringLiteral( "FilledLine" ), QgsFilledLineSymbolLayerWidget::create );
86 _initWidgetFunction( QStringLiteral( "LinearReferencing" ), QgsLinearReferencingSymbolLayerWidget::create );
87
88 _initWidgetFunction( QStringLiteral( "SimpleMarker" ), QgsSimpleMarkerSymbolLayerWidget::create );
89 _initWidgetFunction( QStringLiteral( "FilledMarker" ), QgsFilledMarkerSymbolLayerWidget::create );
90 _initWidgetFunction( QStringLiteral( "SvgMarker" ), QgsSvgMarkerSymbolLayerWidget::create );
91 _initWidgetFunction( QStringLiteral( "RasterMarker" ), QgsRasterMarkerSymbolLayerWidget::create );
92 _initWidgetFunction( QStringLiteral( "AnimatedMarker" ), QgsAnimatedMarkerSymbolLayerWidget::create );
93 _initWidgetFunction( QStringLiteral( "FontMarker" ), QgsFontMarkerSymbolLayerWidget::create );
94 _initWidgetFunction( QStringLiteral( "EllipseMarker" ), QgsEllipseSymbolLayerWidget::create );
95 _initWidgetFunction( QStringLiteral( "VectorField" ), QgsVectorFieldSymbolLayerWidget::create );
96 _initWidgetFunction( QStringLiteral( "MaskMarker" ), QgsMaskMarkerSymbolLayerWidget::create );
97
98 _initWidgetFunction( QStringLiteral( "SimpleFill" ), QgsSimpleFillSymbolLayerWidget::create );
99 _initWidgetFunction( QStringLiteral( "GradientFill" ), QgsGradientFillSymbolLayerWidget::create );
100 _initWidgetFunction( QStringLiteral( "ShapeburstFill" ), QgsShapeburstFillSymbolLayerWidget::create );
101 _initWidgetFunction( QStringLiteral( "RasterFill" ), QgsRasterFillSymbolLayerWidget::create );
102 _initWidgetFunction( QStringLiteral( "SVGFill" ), QgsSVGFillSymbolLayerWidget::create );
103 _initWidgetFunction( QStringLiteral( "CentroidFill" ), QgsCentroidFillSymbolLayerWidget::create );
104 _initWidgetFunction( QStringLiteral( "LinePatternFill" ), QgsLinePatternFillSymbolLayerWidget::create );
105 _initWidgetFunction( QStringLiteral( "PointPatternFill" ), QgsPointPatternFillSymbolLayerWidget::create );
106 _initWidgetFunction( QStringLiteral( "RandomMarkerFill" ), QgsRandomMarkerFillSymbolLayerWidget::create );
107
108 _initWidgetFunction( QStringLiteral( "GeometryGenerator" ), QgsGeometryGeneratorSymbolLayerWidget::create );
109
110 sInitialized = true;
111}
112
113
115 : QgsPanelWidget( parent )
116 , mLayer( layer )
117 , mSymbol( symbol )
118 , mVectorLayer( vl )
119{
120 setupUi( this );
121 connect( mEnabledCheckBox, &QCheckBox::toggled, this, &QgsLayerPropertiesWidget::mEnabledCheckBox_toggled );
122 // initialize the sub-widgets
123 // XXX Should this thing be here this way? Initialize all the widgets just for the sake of one layer?
124 // TODO Make this on demand creation
125 _initWidgetFunctions();
126
127 // TODO Algorithm
128 //
129 // 3. populate the combo box with the supported layer type
130 // 4. set the present layer type
131 // 5. create the widget for the present layer type and set in stacked widget
132 // 6. connect comboBox type changed to two things
133 // 1. emit signal that type has beed changed
134 // 2. remove the widget and place the new widget corresponding to the changed layer type
135 //
137 // update layer type combo box
138 const int idx = cboLayerType->findData( mLayer->layerType() );
139 cboLayerType->setCurrentIndex( idx );
140
141 connect( mEnabledCheckBox, &QAbstractButton::toggled, mEnabledDDBtn, &QWidget::setEnabled );
142 mEnabledCheckBox->setChecked( mLayer->enabled() );
143
144 // set the corresponding widget
146 connect( cboLayerType, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsLayerPropertiesWidget::layerTypeChanged );
147
149
150 this->connectChildPanel( mEffectWidget );
151
152 if ( !mLayer->paintEffect() )
153 {
154 mLayer->setPaintEffect( QgsPaintEffectRegistry::defaultStack() );
155 mLayer->paintEffect()->setEnabled( false );
156 }
157 mEffectWidget->setPaintEffect( mLayer->paintEffect() );
158
160}
161
163{
164 mContext = context;
165 if ( mSymbol )
166 mContext.setSymbolType( mSymbol->type() );
167
168 QgsSymbolLayerWidget *w = dynamic_cast<QgsSymbolLayerWidget *>( stackedWidget->currentWidget() );
169 if ( w )
170 w->setContext( mContext );
171}
172
174{
175 return mContext;
176}
177
179{
181 mEffectWidget->setDockMode( this->dockMode() );
182}
183
185{
186 const QStringList symbolLayerIds = QgsApplication::symbolLayerRegistry()->symbolLayersForType( mSymbol->type() );
187
188 const auto constSymbolLayerIds = symbolLayerIds;
189 for ( const QString &symbolLayerId : constSymbolLayerIds )
190 cboLayerType->addItem( QgsApplication::symbolLayerRegistry()->symbolLayerMetadata( symbolLayerId )->visibleName(), symbolLayerId );
191
192 if ( mSymbol->type() == Qgis::SymbolType::Fill )
193 {
195 const auto constLineLayerIds = lineLayerIds;
196 for ( const QString &lineLayerId : constLineLayerIds )
197 {
199 if ( layerInfo->type() != Qgis::SymbolType::Hybrid )
200 {
201 const QString visibleName = layerInfo->visibleName();
202 const QString name = tr( "Outline: %1" ).arg( visibleName );
203 cboLayerType->addItem( name, lineLayerId );
204 }
205 }
206 }
207}
208
210{
211 if ( stackedWidget->currentWidget() != pageDummy )
212 {
213 // stop updating from the original widget
214 if ( QgsSymbolLayerWidget *w = qobject_cast<QgsSymbolLayerWidget *>( stackedWidget->currentWidget() ) )
216 stackedWidget->removeWidget( stackedWidget->currentWidget() );
217 }
218
220
221 const QString layerType = layer->layerType();
223 if ( am )
224 {
226 if ( w )
227 {
228 w->setContext( mContext );
229 w->setSymbolLayer( layer );
230 stackedWidget->addWidget( w );
231 stackedWidget->setCurrentWidget( w );
232 // start receiving updates from widget
234 connect( w, &QgsSymbolLayerWidget::symbolChanged, this, &QgsLayerPropertiesWidget::reloadLayer );
235 return;
236 }
237 }
238 // When anything is not right
239 stackedWidget->setCurrentWidget( pageDummy );
240}
241
243{
244 if ( auto *lExpressionContext = mContext.expressionContext() )
245 return *lExpressionContext;
246
247 QgsExpressionContext expContext;
248 if ( auto *lMapCanvas = mContext.mapCanvas() )
249 {
250 expContext = lMapCanvas->createExpressionContext();
251 }
252 else
253 {
258 }
259
261
263 if ( mLayer )
264 {
265 //cheat a bit - set the symbol color variable to match the symbol layer's color (when we should really be using the *symbols*
266 //color, but that's not accessible here). 99% of the time these will be the same anyway
268 }
269 expContext << symbolScope;
275 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_count" ), 1, true ) );
276 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_layer_index" ), 1, true ) );
277 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_row" ), 1, true ) );
278 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_marker_column" ), 1, true ) );
279 expContext.lastScope()->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "symbol_frame" ), 1, true ) );
280
281 // additional scopes
282 const auto constAdditionalExpressionContextScopes = mContext.additionalExpressionContextScopes();
283 for ( const QgsExpressionContextScope &scope : constAdditionalExpressionContextScopes )
284 {
285 expContext.appendScope( new QgsExpressionContextScope( scope ) );
286 }
287
288 //TODO - show actual value
289 expContext.setOriginalValueVariable( QVariant() );
290
292
293 return expContext;
294}
295
297{
298 button->init( static_cast<int>( key ), mLayer->dataDefinedProperties(), QgsSymbolLayer::propertyDefinitions(), mVectorLayer );
299 connect( button, &QgsPropertyOverrideButton::changed, this, &QgsLayerPropertiesWidget::updateProperty );
301}
302
303void QgsLayerPropertiesWidget::updateProperty()
304{
305 QgsPropertyOverrideButton *button = qobject_cast<QgsPropertyOverrideButton *>( sender() );
306 const QgsSymbolLayer::Property key = static_cast<QgsSymbolLayer::Property>( button->propertyKey() );
307 mLayer->setDataDefinedProperty( key, button->toProperty() );
308 emit changed();
309}
310
312{
313 QgsSymbolLayer *layer = mLayer;
314 if ( !layer )
315 return;
316 const QString newLayerType = cboLayerType->currentData().toString();
317 if ( layer->layerType() == newLayerType )
318 return;
319
320 // get creation function for new layer from registry
322 QgsSymbolLayerAbstractMetadata *am = pReg->symbolLayerMetadata( newLayerType );
323 if ( !am ) // check whether the metadata is assigned
324 return;
325
326 // change layer to a new (with different type)
327 // base new layer on existing layer's properties
328 QVariantMap properties = layer->properties();
329
330 // if the old symbol layer was a "geometry generator" layer then
331 // we instead get the properties from the generator
332 if ( QgsGeometryGeneratorSymbolLayer *generator = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( layer ) )
333 {
334 if ( generator->subSymbol() && generator->subSymbol()->symbolLayerCount() > 0 )
335 properties = generator->subSymbol()->symbolLayer( 0 )->properties();
336 }
337
338 QgsSymbolLayer *newLayer = am->createSymbolLayer( properties );
339 if ( !newLayer )
340 return;
341
342 // if a symbol layer is changed to a "geometry generator" layer, then we move the old symbol layer into the
343 // geometry generator's subsymbol.
344 if ( QgsGeometryGeneratorSymbolLayer *generator = dynamic_cast<QgsGeometryGeneratorSymbolLayer *>( newLayer ) )
345 {
346 if ( mSymbol )
347 {
348 switch ( mSymbol->type() )
349 {
351 {
352 auto markerSymbol = std::make_unique<QgsMarkerSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
353 generator->setSymbolType( Qgis::SymbolType::Marker );
354 generator->setSubSymbol( markerSymbol.release() );
355 break;
356 }
358 {
359 auto lineSymbol = std::make_unique<QgsLineSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
360 generator->setSymbolType( Qgis::SymbolType::Line );
361 generator->setSubSymbol( lineSymbol.release() );
362 break;
363 }
365 {
366 auto fillSymbol = std::make_unique<QgsFillSymbol>( QgsSymbolLayerList( { layer->clone() } ) );
367 generator->setSymbolType( Qgis::SymbolType::Fill );
368 generator->setSubSymbol( fillSymbol.release() );
369 break;
370 }
372 break;
373 }
374 }
375 }
376 else
377 {
378 // try to copy the subsymbol, if its the same type as the new symbol layer's subsymbol
379 if ( newLayer->subSymbol() && layer->subSymbol() && newLayer->subSymbol()->type() == layer->subSymbol()->type() )
380 {
381 newLayer->setSubSymbol( layer->subSymbol()->clone() );
382 }
383 }
384
385 // special logic for when NEW symbol layers are created from GUI only...
386 // TODO: find a nicer generic way to handle this!
387 if ( QgsFontMarkerSymbolLayer *fontMarker = dynamic_cast<QgsFontMarkerSymbolLayer *>( newLayer ) )
388 {
389 const QString defaultFont = fontMarker->fontFamily();
390 const QFontDatabase fontDb;
391 if ( !fontDb.hasFamily( defaultFont ) )
392 {
393 // default font marker font choice doesn't exist on system, so just use first available symbol font
394 const QStringList candidates = fontDb.families( QFontDatabase::WritingSystem::Symbol );
395 bool foundGoodCandidate = false;
396 for ( const QString &candidate : candidates )
397 {
398 if ( fontDb.writingSystems( candidate ).size() == 1 )
399 {
400 // family ONLY offers symbol writing systems, so it's a good candidate!
401 fontMarker->setFontFamily( candidate );
402 foundGoodCandidate = true;
403 break;
404 }
405 }
406 if ( !foundGoodCandidate && !candidates.empty() )
407 {
408 // fallback to first available family which advertises symbol writing system
409 QString candidate = candidates.at( 0 );
410 fontMarker->setFontFamily( candidate );
411 }
412 }
413
414 // search (briefly!!) for a unicode character which actually exists in the font
415 const QFontMetrics fontMetrics( fontMarker->fontFamily() );
416 ushort character = fontMarker->character().at( 0 ).unicode();
417 for ( ; character < 1000; ++character )
418 {
419 if ( fontMetrics.inFont( QChar( character ) ) )
420 {
421 fontMarker->setCharacter( QChar( character ) );
422 break;
423 }
424 }
425 }
426
427 updateSymbolLayerWidget( newLayer );
428 emit changeLayer( newLayer );
429}
430
432{
433 emit changed();
434
435 // also update paint effect preview
436 bool paintEffectToggled = false;
437 if ( mLayer->paintEffect() && mLayer->paintEffect()->enabled() )
438 {
439 mLayer->paintEffect()->setEnabled( false );
440 paintEffectToggled = true;
441 }
443 if ( paintEffectToggled )
444 {
445 mLayer->paintEffect()->setEnabled( true );
446 }
447 emit widgetChanged();
448}
449
450void QgsLayerPropertiesWidget::reloadLayer()
451{
452 emit changeLayer( mLayer );
453}
454
455void QgsLayerPropertiesWidget::mEnabledCheckBox_toggled( bool enabled )
456{
457 mLayer->setEnabled( enabled );
459}
@ Millimeters
Millimeters.
Definition qgis.h:5184
@ Marker
Marker symbol.
Definition qgis.h:611
@ Line
Line symbol.
Definition qgis.h:612
@ Fill
Fill symbol.
Definition qgis.h:613
@ Hybrid
Hybrid symbol.
Definition qgis.h:614
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:57
QList< QgsSymbolLayer * > QgsSymbolLayerList
Definition qgssymbol.h:30
QgsSymbolLayerWidget *(* QgsSymbolLayerWidgetFunc)(QgsVectorLayer *)
Single variable definition for use within a QgsExpressionContextScope.