28 #include <QMessageBox> 29 #include <QInputDialog> 36 contextMenu =
new QMenu( tr(
"Renderer Options" ),
this );
39 mCopyAction->setShortcut( QKeySequence( QKeySequence::Copy ) );
41 mPasteAction->setShortcut( QKeySequence( QKeySequence::Paste ) );
67 if ( symbolList.isEmpty() )
73 Q_FOREACH (
QgsSymbol *symbol, symbolList )
85 if ( color.isValid() )
87 Q_FOREACH (
QgsSymbol *symbol, symbolList )
99 if ( symbolList.isEmpty() )
105 Q_FOREACH (
QgsSymbol *symbol, symbolList )
109 firstSymbol = symbol;
117 double oldOpacity = firstSymbol->
opacity() * 100;
118 double opacity = QInputDialog::getDouble(
this, tr(
"Opacity" ), tr(
"Change symbol opacity [%]" ), oldOpacity, 0.0, 100.0, 1, &ok );
121 Q_FOREACH (
QgsSymbol *symbol, symbolList )
133 if ( symbolList.isEmpty() )
139 Q_FOREACH (
QgsSymbol *symbol, symbolList )
143 firstSymbol = symbol;
152 QString item = QInputDialog::getItem(
this, tr(
"Symbol unit" ), tr(
"Select symbol unit" ), QStringList() << tr(
"Millimeter" ) << tr(
"Map unit" ), currentUnit,
false, &ok );
157 Q_FOREACH (
QgsSymbol *symbol, symbolList )
169 if ( symbolList.isEmpty() )
178 if ( QDialog::Accepted == dlg.exec() )
180 if ( !dlg.mDDBtn->isActive() )
182 Q_FOREACH (
QgsSymbol *symbol, symbolList )
188 static_cast<QgsLineSymbol *>( symbol )->setWidth( dlg.mSpinBox->
value() );
198 if ( symbolList.isEmpty() )
206 if ( QDialog::Accepted == dlg.exec() )
208 if ( !dlg.mDDBtn->isActive() )
210 Q_FOREACH (
QgsSymbol *symbol, symbolList )
216 static_cast<QgsMarkerSymbol *>( symbol )->setSize( dlg.mSpinBox->
value() );
226 if ( symbolList.isEmpty() )
234 if ( QDialog::Accepted == dlg.exec() )
236 if ( !dlg.mDDBtn->isActive() )
238 Q_FOREACH (
QgsSymbol *symbol, symbolList )
244 static_cast<QgsMarkerSymbol *>( symbol )->setAngle( dlg.mSpinBox->
value() );
289 if ( !ddSize || !ddSize.
isActive() )
291 QMessageBox::warning(
this, tr(
"Data-defined Size Legend" ), tr(
"Data-defined size is not enabled!" ) );
306 : mSymbolList( symbolList )
310 setWindowFlags( Qt::WindowStaysOnTopHint );
311 mLabel->setText( label );
358 mDDBtn->registerExpressionContextGenerator(
this );
361 Q_FOREACH (
QgsSymbol *symbol, mSymbolList )
365 initialSymbol = symbol;
368 mSpinBox->setValue( initialSymbol ? value( initialSymbol ) : 0 );
369 mSpinBox->setEnabled( !mDDBtn->isActive() );
372 QgsProperty QgsDataDefinedValueDialog::symbolDataDefined()
const 374 if ( mSymbolList.isEmpty() || !mSymbolList.back() )
378 QgsProperty dd = symbolDataDefined( mSymbolList.back() );
382 if ( !it || !dd || !symbolDD || symbolDD != dd )
391 mSpinBox->setEnabled( !dd.isActive() );
396 ( symbolDD && symbolDD.
isActive() && !dd.isActive() )
401 setDataDefined( it, dd );
438 static_cast<QgsLineSymbol *
>( symbol )->setDataDefinedWidth( dd );
441 void QgsRendererWidget::apply()
Calculate scale by the diameter.
double value(const QgsSymbol *symbol) const override
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
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...
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
Get 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 QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), const bool allowOpacity=false)
Return a color selection from a color dialog.
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.
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
Get 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)