29 #include <QMessageBox> 30 #include <QInputDialog> 37 contextMenu =
new QMenu( tr(
"Renderer Options" ),
this );
40 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
42 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
68 if ( symbolList.isEmpty() )
74 Q_FOREACH (
QgsSymbol *symbol, symbolList )
86 if ( color.isValid() )
88 Q_FOREACH (
QgsSymbol *symbol, symbolList )
100 if ( symbolList.isEmpty() )
106 Q_FOREACH (
QgsSymbol *symbol, symbolList )
110 firstSymbol = symbol;
118 double oldOpacity = firstSymbol->
opacity() * 100;
119 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
122 Q_FOREACH (
QgsSymbol *symbol, symbolList )
134 if ( symbolList.isEmpty() )
140 Q_FOREACH (
QgsSymbol *symbol, symbolList )
144 firstSymbol = symbol;
153 QString item = QInputDialog::getItem(
this, tr(
"Symbol unit" ), tr(
"Select symbol unit" ), QStringList() << tr(
"Millimeter" ) << tr(
"Map unit" ), currentUnit,
false, &ok );
158 Q_FOREACH (
QgsSymbol *symbol, symbolList )
170 if ( symbolList.isEmpty() )
179 if ( QDialog::Accepted == dlg.exec() )
181 if ( !dlg.mDDBtn->isActive() )
183 Q_FOREACH (
QgsSymbol *symbol, symbolList )
189 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->
value() );
199 if ( symbolList.isEmpty() )
207 if ( QDialog::Accepted == dlg.exec() )
209 if ( !dlg.mDDBtn->isActive() )
211 Q_FOREACH (
QgsSymbol *symbol, symbolList )
217 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->
value() );
227 if ( symbolList.isEmpty() )
235 if ( QDialog::Accepted == dlg.exec() )
237 if ( !dlg.mDDBtn->isActive() )
239 Q_FOREACH (
QgsSymbol *symbol, symbolList )
245 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->
value() );
290 if ( !ddSize || !ddSize.
isActive() )
292 QMessageBox::warning(
this, tr(
"Data-defined Size Legend" ), tr(
"Data-defined size is not enabled!" ) );
307 : mSymbolList( symbolList )
311 setWindowFlags( Qt::WindowStaysOnTopHint );
312 mLabel->setText( label );
359 mDDBtn->registerExpressionContextGenerator(
this );
362 Q_FOREACH (
QgsSymbol *symbol, mSymbolList )
366 initialSymbol = symbol;
369 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
370 mSpinBox->setEnabled( !mDDBtn->isActive() );
373 QgsProperty QgsDataDefinedValueDialog::symbolDataDefined()
const 375 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
379 QgsProperty dd = symbolDataDefined( mSymbolList.back() );
383 if ( !it || !dd || !symbolDD || symbolDD != dd )
392 mSpinBox->setEnabled( !dd.isActive() );
397 ( symbolDD && symbolDD.
isActive() && !dd.isActive() )
402 setDataDefined( it, dd );
439 static_cast<QgsLineSymbol *
>( symbol )->setDataDefinedWidth( dd );
442 void QgsRendererWidget::apply()
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), bool allowOpacity=false)
Returns a color selection from a color dialog.
Calculate scale by the diameter.
double value(const QgsSymbol *symbol) const override
Abstract base class for all rendered symbols.
double value(const QgsSymbol *symbol) const override
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
A marker symbol type, for rendering Point and MultiPoint geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
The QgsMapSettings class contains configuration for rendering of the map.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QColor color() const
Returns the symbol's color.
Single scope for storing variables and functions for use within a QgsExpressionContext.
A store for object properties.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
A dialog which allows the user to modify the rendering order of symbol layers.
double value(const QgsSymbol *symbol) const override
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
void dataDefinedChanged()
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
bool usingSymbolLevels() const
static QgsExpressionContextScope * mapSettingsScope(const QgsMapSettings &mapSettings)
Creates a new scope which contains variables and functions relating to a QgsMapSettings object...
QgsExpressionContextScope & expressionContextScope()
Returns a reference to the expression context scope for the map canvas.
SymbolType type() const
Returns the symbol's type.
void init(int propertyKey)
Should be called in the constructor of child classes.
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
QgsDataDefinedValueDialog(const QList< QgsSymbol *> &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
qreal opacity() const
Returns the opacity for the symbol.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the symbol widget is shown, e.g., the associated map canvas and expression ...
Represents a vector layer which manages a vector based data sets.
Object that keeps configuration of appearance of marker symbol's data-defined size in legend...
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
bool isActive() const
Returns whether the property is currently active.
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
RenderUnit
Rendering size units.
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
void setColor(const QColor &color)
Sets the color for the symbol.