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() );
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.
bool isActive() const
Returns whether the property is currently active.
double value(const QgsSymbol *symbol) const override
bool usingSymbolLevels() const
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
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
QgsSymbolWidgetContext context() const
Returns the context in which the symbol widget is shown, e.g., the associated map canvas and expressi...
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
qreal opacity() const
Returns the opacity for the symbol.
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.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
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.
QgsDataDefinedValueDialog(const QList< QgsSymbol * > &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
A store for object properties.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
A dialog which allows the user to modify the rendering order of symbol layers.
double value(const QgsSymbol *symbol) const override
void dataDefinedChanged()
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
static QgsExpressionContextScope * atlasScope(QgsLayoutAtlas *atlas)
Creates a new scope which contains variables and functions relating to a QgsLayoutAtlas.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
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.
SymbolType type() const
Returns the symbol's type.
QgsProperty symbolDataDefined(const QgsSymbol *symbol) const override
QList< QgsExpressionContextScope > additionalExpressionContextScopes() const
Returns the list of additional expression context scopes to show as available within the layer...
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
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 ...
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
QColor color() const
Returns the symbol's color.
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...
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
void setDataDefined(QgsSymbol *symbol, const QgsProperty &dd) override
RenderUnit
Rendering size units.
void setColor(const QColor &color)
Sets the color for the symbol.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.