24 #include <QMessageBox> 25 #include <QInputDialog> 32 , mMapCanvas( nullptr )
107 firstSymbol = symbol;
115 double oldTransparency = ( 1 - firstSymbol->
alpha() ) * 100;
116 double transparency =
QInputDialog::getDouble(
this,
tr(
"Transparency" ),
tr(
"Change symbol transparency [%]" ), oldTransparency, 0.0, 100.0, 0, &ok );
122 symbol->
setAlpha( 1 - transparency / 100 );
141 firstSymbol = symbol;
175 if ( QDialog::Accepted == dlg.
exec() )
177 if ( !dlg.mDDBtn->isActive() )
185 static_cast<QgsLineSymbolV2*>( symbol )->setWidth( dlg.mSpinBox->
value() );
203 if ( QDialog::Accepted == dlg.
exec() )
205 if ( !dlg.mDDBtn->isActive() )
213 static_cast<QgsMarkerSymbolV2*>( symbol )->setSize( dlg.mSpinBox->
value() );
231 if ( QDialog::Accepted == dlg.
exec() )
233 if ( !dlg.mDDBtn->isActive() )
241 static_cast<QgsMarkerSymbolV2*>( symbol )->setAngle( dlg.mSpinBox->
value() );
346 bool hasField =
false;
349 if ( fld.
type() == QVariant::Int || fld.
type() == QVariant::Double )
353 if ( fieldName == fld.
name() )
371 aExpr->
setText(
tr(
"- expression -" ) + fieldName );
386 if ( fldName ==
tr(
"- no field -" ) )
390 else if ( fldName.
startsWith(
tr(
"- expression -" ) ) )
393 expr.
replace( 0,
tr(
"- expression -" ).length(),
"" );
395 if ( !dialog.
exec() )
return;
398 a->
setText(
tr(
"- expression -" ) + fldName );
413 if ( fldName ==
tr(
"- no field -" ) )
417 else if ( fldName.
startsWith(
tr(
"- expression -" ) ) )
420 expr.
replace( 0,
tr(
"- expression -" ).length(),
"" );
422 if ( !dialog.
exec() )
return;
425 a->
setText(
tr(
"- expression -" ) + fldName );
436 if ( a->
text() ==
tr(
"Scale area" ) )
440 else if ( a->
text() ==
tr(
"Scale diameter" ) )
445 #if 0 // MK: is there any reason for this? 446 void QgsRendererV2DataDefinedMenus::updateMenu(
QActionGroup* actionGroup,
QString fieldName )
456 : mSymbolList( symbolList )
458 , mMapCanvas( nullptr )
462 mLabel->setText( label );
518 initialSymbol = symbol;
521 mSpinBox->setValue( initialSymbol ?
value( initialSymbol ) : 0 );
522 mSpinBox->setEnabled( !mDDBtn->isActive() );
543 mSpinBox->setEnabled( !dd.
isActive() );
591 void QgsRendererV2Widget::apply()
QgsDataDefined dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
double value(const QgsSymbolV2 *symbol) const override
void setText(const QString &text)
Class for parsing and evaluation of expressions (formerly called "search strings").
OutputUnit
The unit of the output.
A container class for data source field mapping or expression.
void init(const QString &description)
static QgsExpressionContextScope * atlasScope(const QgsAtlasComposition *atlas)
Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd) override
void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd) override
Calculate scale by the diameter.
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
double value(const QgsSymbolV2 *symbol) const override
QgsFields fields() const
Returns the list of fields of this layer.
The QgsMapSettings class contains configuration for rendering of the map.
void setColor(const QColor &color)
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
Utility classes for "en masse" size definition.
The output shall be in millimeters.
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context...
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
const QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsDataDefinedValueDialog(const QList< QgsSymbolV2 *> &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the dialog.
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
The output shall be in map unitx.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
double value(const QgsSymbolV2 *symbol) const override
bool usingSymbolLevels() const
Encapsulate a field in an attribute table or data source.
Single scope for storing variables and functions for use within a QgsExpressionContext.
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
virtual double value(const QgsSymbolV2 *) const =0
void setShortcut(const QKeySequence &shortcut)
void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd) override
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
QgsSymbolV2::OutputUnit outputUnit() const
void dataDefinedChanged()
void setUsingSymbolLevels(bool usingSymbolLevels)
QString & replace(int position, int n, QChar after)
QList< QgsSymbolV2 * > mSymbolList
QList< QAction * > actions() const
static QColor getColor(const QColor &initialColor, QWidget *parent, const QString &title=QString(), const bool allowAlpha=false)
Return a color selection from a color dialog.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
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.
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
virtual void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd)=0
QgsMapCanvas * mMapCanvas
Calculate scale by the area.
static QgsExpressionContextScope * projectScope()
Creates a new scope which contains variables and functions relating to the current QGIS project...
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QgsDataDefined symbolDataDefined() const
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
int compare(const QString &other) const
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
A generic dialog for building expression strings.