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();
193 for (
int i = 0; i < names.
count(); i++ )
202 item->
setData( names[i], Qt::UserRole );
205 item->
setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
256 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
284 spinSize->setEnabled( !mSizeDDBtn->isActive() );
313 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
338 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
346 tr(
"Symbol with name '%1' already exists. Overwrite?" )
348 QMessageBox::Yes | QMessageBox::No );
349 if ( res != QMessageBox::Yes )
367 tr(
"Please enter name for the symbol:" ), QLineEdit::Normal,
tr(
"New symbol" ), &ok );
375 tr(
"Symbol with name '%1' already exists. Overwrite?" )
377 QMessageBox::Yes | QMessageBox::No );
378 if ( res != QMessageBox::Yes )
407 double alpha = 1 - ( value / 255.0 );
409 displayTransparency( alpha );
414 void QgsSymbolsListWidget::displayTransparency(
double alpha )
416 double transparencyPercent = ( 1 - alpha ) * 100;
417 mTransparencyLabel->setText(
tr(
"Transparency %1%" ).arg((
int ) transparencyPercent ) );
422 btnColor->blockSignals(
true );
424 btnColor->blockSignals(
false );
469 spinSize->setValue( markerSymbol->
size() );
470 spinAngle->setValue( markerSymbol->
angle() );
476 spinSize->setEnabled( !mSizeDDBtn->isActive() );
479 spinAngle->setEnabled( !mRotationDDBtn->isActive() );
483 mSizeDDBtn->setEnabled(
false );
484 mRotationDDBtn->setEnabled(
false );
490 spinWidth->setValue( lineSymbol->
width() );
496 spinWidth->setEnabled( !mWidthDDBtn->isActive() );
500 mWidthDDBtn->setEnabled(
false );
504 mSymbolUnitWidget->blockSignals(
true );
507 mSymbolUnitWidget->blockSignals(
false );
509 mTransparencySlider->blockSignals(
true );
511 mTransparencySlider->setValue( transparency * 255 );
513 mTransparencySlider->blockSignals(
false );
534 lblSymbolName->setText( symbolName );
559 QString text = groupsCombo->itemText( index );
568 if ( groupsCombo->itemData( index ).toString() ==
"smart" )
575 groupid = groupsCombo->itemData( index ).toInt();
QgsDataDefined dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
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...
double angle() const
Returns the marker angle for the whole symbol.
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
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
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
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)
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
QgsDataDefined dataDefinedWidth() const
Returns data defined size for whole symbol (including all symbol layers).
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
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)
Sets the angle for the whole symbol.
int symbolLayerCount()
Returns total number of symbol layers contained in the symbol.
void setSize(double size)
Sets the size for the whole symbol.
QStringList symbolsOfSmartgroup(StyleEntity type, int id)
returns the symbols for the smartgroup
Single scope for storing variables and functions for use within a QgsExpressionContext.
QgsMapUnitScale mapUnitScale() const
QStringList symbolNames()
return a list of names of symbols
qreal alpha() const
Get alpha transparency 1 for opaque, 0 for invisible.
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)
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
void setText(const QString &text)
QgsSymbolV2::OutputUnit outputUnit() const
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.
QVariant data(int role) const
QgsDataDefined dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
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.
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 hasDefaultValues() const
Returns whether the data defined container is set to all the default values, ie, disabled, with empty expression and no assigned field.
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)
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 ...