23 #include <QMessageBox> 24 #include <QInputDialog> 31 , mMapCanvas( nullptr )
106 firstSymbol = symbol;
114 double oldTransparency = ( 1 - firstSymbol->
alpha() ) * 100;
115 double transparency =
QInputDialog::getDouble(
this,
tr(
"Transparency" ),
tr(
"Change symbol transparency [%]" ), oldTransparency, 0.0, 100.0, 0, &ok );
121 symbol->
setAlpha( 1 - transparency / 100 );
140 firstSymbol = symbol;
174 if ( QDialog::Accepted == dlg.
exec() )
176 if ( !dlg.mDDBtn->isActive() )
184 static_cast<QgsLineSymbolV2*>( symbol )->setWidth( dlg.mSpinBox->
value() );
202 if ( QDialog::Accepted == dlg.
exec() )
204 if ( !dlg.mDDBtn->isActive() )
212 static_cast<QgsMarkerSymbolV2*>( symbol )->setSize( dlg.mSpinBox->
value() );
230 if ( QDialog::Accepted == dlg.
exec() )
232 if ( !dlg.mDDBtn->isActive() )
240 static_cast<QgsMarkerSymbolV2*>( symbol )->setAngle( dlg.mSpinBox->
value() );
342 bool hasField =
false;
344 for (
int idx = 0; idx < flds.
count(); ++idx )
347 if ( fld.
type() == QVariant::Int || fld.
type() == QVariant::Double )
351 if ( fieldName == fld.
name() )
369 aExpr->
setText(
tr(
"- expression -" ) + fieldName );
384 if ( fldName ==
tr(
"- no field -" ) )
388 else if ( fldName.
startsWith(
tr(
"- expression -" ) ) )
391 expr.
replace( 0,
tr(
"- expression -" ).length(),
"" );
393 if ( !dialog.
exec() )
return;
396 a->
setText(
tr(
"- expression -" ) + fldName );
411 if ( fldName ==
tr(
"- no field -" ) )
415 else if ( fldName.
startsWith(
tr(
"- expression -" ) ) )
418 expr.
replace( 0,
tr(
"- expression -" ).length(),
"" );
420 if ( !dialog.
exec() )
return;
423 a->
setText(
tr(
"- expression -" ) + fldName );
434 if ( a->
text() ==
tr(
"Scale area" ) )
438 else if ( a->
text() ==
tr(
"Scale diameter" ) )
443 #if 0 // MK: is there any reason for this? 444 void QgsRendererV2DataDefinedMenus::updateMenu(
QActionGroup* actionGroup,
QString fieldName )
454 : mSymbolList( symbolList )
456 , mMapCanvas( nullptr )
460 mLabel->setText( label );
516 initialSymbol = symbol;
519 mSpinBox->setValue( initialSymbol ?
value( initialSymbol ) : 0 );
520 mSpinBox->setEnabled( !mDDBtn->isActive() );
541 mSpinBox->setEnabled( !dd.
isActive() );
589 void QgsRendererV2Widget::apply()
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
QgsFields fields() const
Returns the list of fields of this layer.
void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd) override
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
Calculate scale by the diameter.
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
Container of fields for a vector layer.
const QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
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
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
The QgsMapSettings class contains configuration for rendering of the map.
QgsDataDefined symbolDataDefined() const
void setColor(const QColor &color)
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.
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
virtual QgsLegendSymbolList legendSymbolItems(double scaleDenominator=-1, const QString &rule="")
return a list of item text / symbol
QString name() const
Gets the name of the field.
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.
int count() const
Return number of items.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
double value(const QgsSymbolV2 *symbol) const override
Encapsulate a field in an attribute table or data source.
Single scope for storing variables and functions for use within a QgsExpressionContext.
virtual double value(const QgsSymbolV2 *) const =0
void setShortcut(const QKeySequence &shortcut)
void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd) override
void dataDefinedChanged()
void setUsingSymbolLevels(bool usingSymbolLevels)
QString & replace(int position, int n, QChar after)
QList< QgsSymbolV2 * > mSymbolList
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
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.
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 dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
virtual void setDataDefined(QgsSymbolV2 *symbol, const QgsDataDefined &dd)=0
bool usingSymbolLevels() const
QgsSymbolV2::OutputUnit outputUnit() const
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.
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.
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.
QgsDataDefinedValueDialog(const QList< QgsSymbolV2 * > &symbolList, QgsVectorLayer *layer, const QString &label)
Constructor.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.