32 #include <QStringList> 35 #include <QStandardItemModel> 36 #include <QColorDialog> 37 #include <QInputDialog> 38 #include <QMessageBox> 40 #include <QScopedPointer> 47 , mAdvancedMenu( nullptr )
48 , mClipFeaturesAction( nullptr )
50 , mMapCanvas( nullptr )
51 , mPresetExpressionContext( nullptr )
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 ) ) );
117 btnColor->setAcceptLiveUpdates(
false );
118 btnColor->setAllowAlpha(
true );
119 btnColor->setColorDialogTitle(
tr(
"Select color" ) );
120 btnColor->setContext(
"symbology" );
153 mPresetExpressionContext = context;
165 text = prepend +
'/' + i.
value();
172 populateGroups( i.
value(), text );
184 QSize previewSize = viewSymbols->iconSize();
195 for (
int i = 0; i < names.
count(); i++ )
204 item->
setData( names[i], Qt::UserRole );
207 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
258 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
286 spinSize->setEnabled( !mSizeDDBtn->isActive() );
315 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
340 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
348 tr(
"Symbol with name '%1' already exists. Overwrite?" )
350 QMessageBox::Yes | QMessageBox::No );
351 if ( res != QMessageBox::Yes )
369 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
377 tr(
"Symbol with name '%1' already exists. Overwrite?" )
379 QMessageBox::Yes | QMessageBox::No );
380 if ( res != QMessageBox::Yes )
409 double alpha = 1 - ( value / 255.0 );
411 displayTransparency( alpha );
416 void QgsSymbolsListWidget::displayTransparency(
double alpha )
418 double transparencyPercent = ( 1 - alpha ) * 100;
419 mTransparencyLabel->setText(
tr(
"Transparency %1%" ).arg((
int ) transparencyPercent ) );
424 btnColor->blockSignals(
true );
426 btnColor->blockSignals(
false );
471 spinSize->setValue( markerSymbol->
size() );
472 spinAngle->setValue( markerSymbol->
angle() );
478 spinSize->setEnabled( !mSizeDDBtn->isActive() );
481 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
485 mSizeDDBtn->setEnabled(
false );
486 mRotationDDBtn->setEnabled(
false );
492 spinWidth->setValue( lineSymbol->
width() );
498 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
502 mWidthDDBtn->setEnabled(
false );
506 mSymbolUnitWidget->blockSignals(
true );
509 mSymbolUnitWidget->blockSignals(
false );
511 mTransparencySlider->blockSignals(
true );
513 mTransparencySlider->setValue( transparency * 255 );
515 mTransparencySlider->blockSignals(
false );
536 lblSymbolName->setText( symbolName );
561 QString text = groupsCombo->itemText( index );
570 if ( groupsCombo->itemData( index ).toString() ==
"smart" )
577 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.
Calculate scale by the diameter.
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.
void setScaleMethod(QgsSymbolV2::ScaleMethod scaleMethod)
QStringList findSymbols(StyleEntity type, const QString &qword)
return the names of the symbols which have a matching 'substring' in its defintion ...