32 #include <QStringList>
35 #include <QStandardItemModel>
36 #include <QColorDialog>
37 #include <QInputDialog>
38 #include <QMessageBox>
40 #include <QScopedPointer>
48 , mClipFeaturesAction( 0 )
51 , mPresetExpressionContext( 0 )
66 btnAdvanced->setMenu(
new QMenu(
this ) );
73 groupsCombo->addItem(
"" );
76 Q_FOREACH (
const QString& group, groups )
78 groupsCombo->addItem( group,
QVariant(
"smart" ) );
82 viewSymbols->setModel( model );
88 lblSymbolName->setText(
"" );
98 stackedWidget->setCurrentIndex( symbol->
type() );
102 connect( spinWidth, SIGNAL( valueChanged(
double ) ),
this, SLOT(
setLineWidth(
double ) ) );
115 btnColor->setAcceptLiveUpdates(
false );
116 btnColor->setAllowAlpha(
true );
117 btnColor->setColorDialogTitle(
tr(
"Select color" ) );
118 btnColor->setContext(
"symbology" );
149 mPresetExpressionContext = context;
152 void QgsSymbolsListWidget::populateGroups(
const QString& parent,
const QString& prepend )
161 text = prepend +
"/" + i.
value();
168 populateGroups( i.
value(), text );
180 QSize previewSize = viewSymbols->iconSize();
191 for (
int i = 0; i < names.
count(); i++ )
200 item->
setData( names[i], Qt::UserRole );
203 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
254 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
282 spinSize->setEnabled( !mSizeDDBtn->isActive() );
310 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
335 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
343 tr(
"Symbol with name '%1' already exists. Overwrite?" )
345 QMessageBox::Yes | QMessageBox::No );
346 if ( res != QMessageBox::Yes )
376 double alpha = 1 - ( value / 255.0 );
378 displayTransparency( alpha );
383 void QgsSymbolsListWidget::displayTransparency(
double alpha )
385 double transparencyPercent = ( 1 - alpha ) * 100;
386 mTransparencyLabel->setText(
tr(
"Transparency %1%" ).arg((
int ) transparencyPercent ) );
391 btnColor->blockSignals(
true );
393 btnColor->blockSignals(
false );
438 spinSize->setValue( markerSymbol->
size() );
439 spinAngle->setValue( markerSymbol->
angle() );
445 spinSize->setEnabled( !mSizeDDBtn->isActive() );
448 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
452 mSizeDDBtn->setEnabled(
false );
453 mRotationDDBtn->setEnabled(
false );
459 spinWidth->setValue( lineSymbol->
width() );
465 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
469 mWidthDDBtn->setEnabled(
false );
473 mSymbolUnitWidget->blockSignals(
true );
476 mSymbolUnitWidget->blockSignals(
false );
478 mTransparencySlider->blockSignals(
true );
480 mTransparencySlider->setValue( transparency * 255 );
482 mTransparencySlider->blockSignals(
false );
503 lblSymbolName->setText( symbolName );
528 QString text = groupsCombo->itemText( index );
537 if ( groupsCombo->itemData( index ).toString() ==
"smart" )
544 groupid = groupsCombo->itemData( index ).toInt();
bool deleteSymbolLayer(int index)
delete symbol layer at specified index
void setPointSize(int pointSize)
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
OutputUnit
The unit of the output.
void setIcon(const QIcon &icon)
void setDataDefinedAngle(const QgsDataDefined &dd)
Set data defined angle for whole symbol (including all symbol layers).
A container class for data source field mapping or expression.
bool addSymbol(const QString &name, QgsSymbolV2 *symbol, bool update=false)
add symbol to style. takes symbol's ownership
static QgsExpressionContextScope * atlasScope(const QgsAtlasComposition *atlas)
Creates a new scope which contains variables and functions relating to a QgsAtlasComposition.
void setDataDefinedSize(const QgsDataDefined &dd)
Set data defined size for whole symbol (including all symbol layers).
virtual QgsSymbolV2 * clone() const =0
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
const_iterator constBegin() const
The output shall be in pixels.
QStringList symbolsOfGroup(StyleEntity type, int groupid)
returns the symbolnames of a given groupid
bool contains(const QString &str, Qt::CaseSensitivity cs) const
QgsMapUnitScale mapUnitScale() const
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
void setWidth(double width)
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
virtual void setData(const QVariant &value, int role)
void setMapUnitScale(const QgsMapUnitScale &scale)
The QgsMapSettings class contains configuration for rendering of the map.
void setColor(const QColor &color)
const char * name() const
The output shall be in millimeters.
static QIcon symbolPreviewIcon(QgsSymbolV2 *symbol, QSize size)
QgsSymbolGroupMap childGroupNames(const QString &parent="")
return a map of groupid and names for the given parent group
int count(const T &value) const
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.
bool appendSymbolLayer(QgsSymbolLayerV2 *layer)
Append symbol layer at the end of the list Ownership will be transferred.
bool saveSymbol(const QString &name, QgsSymbolV2 *symbol, int groupid, const QStringList &tags)
add the symbol to the DB with the tags
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
void setFlags(QFlags< Qt::ItemFlag > flags)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
const_iterator constEnd() const
The output shall be in map unitx.
void setAngle(double angle)
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setSize(double size)
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
Single scope for storing variables and functions for use within a QgsExpressionContext.
QStringList symbolNames()
return a list of names of symbols
void setFont(const QFont &font)
QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode, const QString &text, bool *ok, QFlags< Qt::WindowType > flags, QFlags< Qt::InputMethodHint > inputMethodHints)
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
QgsSymbolV2 * symbol(const QString &name)
return a NEW copy of symbol
bool blockSignals(bool block)
void setText(const QString &text)
void setDataDefinedWidth(const QgsDataDefined &dd)
Set data defined width for whole symbol (including all symbol layers).
QStringList smartgroupNames()
returns the smart groups list
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).
QVariant data(int role) const
QgsSymbolV2::OutputUnit outputUnit() const
StandardButton warning(QWidget *parent, const QString &title, const QString &text, QFlags< QMessageBox::StandardButton > buttons, StandardButton defaultButton)
QgsSymbolLayerV2 * takeSymbolLayer(int index)
Remove symbol layer from the list and return pointer to it.
bool hasDefaultValues() const
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field.
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.
int smartgroupId(const QString &smartgroup)
return the DB id for the given smartgroup name
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
Represents a vector layer which manages a vector based data sets.
void setOutputUnit(QgsSymbolV2::OutputUnit u)
void appendRow(const QList< QStandardItem * > &items)
void setAlpha(qreal alpha)
Set alpha transparency 1 for opaque, 0 for invisible.
QStringList findSymbols(StyleEntity type, const QString &qword)
return the names of the symbols which have a matching 'substring' in its defintion ...