QGIS API Documentation
qgssymbollayerv2widget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbollayerv2widget.h - symbol layer widgets
3 
4  ---------------------
5  begin : November 2009
6  copyright : (C) 2009 by Martin Dobias
7  email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #ifndef QGSSYMBOLLAYERV2WIDGET_H
18 #define QGSSYMBOLLAYERV2WIDGET_H
19 
20 #include <qgsdatadefinedbutton.h>
21 
22 #include <QWidget>
23 #include <QStandardItemModel>
24 
25 class QgsSymbolLayerV2;
26 class QgsVectorLayer;
27 class QgsMapCanvas;
28 
29 class GUI_EXPORT QgsSymbolLayerV2Widget : public QWidget
30 {
31  Q_OBJECT
32 
33  public:
34  QgsSymbolLayerV2Widget( QWidget* parent, const QgsVectorLayer* vl = nullptr ) : QWidget( parent ), mVectorLayer( vl ), mPresetExpressionContext( nullptr ), mMapCanvas( nullptr ) {}
36 
37  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) = 0;
38  virtual QgsSymbolLayerV2* symbolLayer() = 0;
39 
46  QgsExpressionContext* expressionContext() const { return mPresetExpressionContext; }
47 
54  virtual void setMapCanvas( QgsMapCanvas* canvas );
55 
60  const QgsMapCanvas* mapCanvas() const;
61 
65  const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
66 
67  public slots:
68 
77  void setExpressionContext( QgsExpressionContext* context ) { mPresetExpressionContext = context; }
78 
79  protected:
81 
84 
86 
87  void registerDataDefinedButton( QgsDataDefinedButton * button, const QString & propertyName, QgsDataDefinedButton::DataType type, const QString & description );
88 
94  Q_DECL_DEPRECATED virtual QString dataDefinedPropertyLabel( const QString &entryName );
95 
96  signals:
101  void changed();
108  void symbolChanged();
109 
110  protected slots:
111  void updateDataDefinedProperty();
112 };
113 
115 
116 #include "ui_widget_simpleline.h"
117 
119 
120 class GUI_EXPORT QgsSimpleLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleLine
121 {
122  Q_OBJECT
123 
124  public:
125  QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
126 
128 
130 
131  // from base class
132  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
133  virtual QgsSymbolLayerV2* symbolLayer() override;
134 
135  public slots:
136  void penWidthChanged();
137  void colorChanged( const QColor& color );
138  void penStyleChanged();
139  void offsetChanged();
140  void on_mCustomCheckBox_stateChanged( int state );
141  void on_mChangePatternButton_clicked();
142  void on_mPenWidthUnitWidget_changed();
143  void on_mOffsetUnitWidget_changed();
144  void on_mDashPatternUnitWidget_changed();
145  void on_mDrawInsideCheckBox_stateChanged( int state );
146 
147  protected:
149 
150  //creates a new icon for the 'change pattern' button
151  void updatePatternIcon();
152 
153  private slots:
154 
155  void updateAssistantSymbol();
156 
157  private:
158 
159  QgsLineSymbolV2* mAssistantPreviewSymbol;
160 
161 };
162 
164 
165 #include "ui_widget_simplemarker.h"
166 
168 
169 class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleMarker
170 {
171  Q_OBJECT
172 
173  public:
174  QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
176 
178 
179  // from base class
180  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
181  virtual QgsSymbolLayerV2* symbolLayer() override;
182 
183  public slots:
184  void setName();
185  void setColorBorder( const QColor& color );
186  void setColorFill( const QColor& color );
187  void setSize();
188  void setAngle();
189  void setOffset();
190  void on_mSizeUnitWidget_changed();
191  void on_mOffsetUnitWidget_changed();
192  void on_mOutlineWidthUnitWidget_changed();
193  void on_mOutlineStyleComboBox_currentIndexChanged( int index );
194  void on_mOutlineWidthSpinBox_valueChanged( double d );
195  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
196  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
197 
198  protected:
200 
201  private slots:
202 
203  void updateAssistantSymbol();
204  void penJoinStyleChanged();
205 
206  private:
207 
208  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
209 };
210 
212 
213 #include "ui_widget_simplefill.h"
214 
216 
217 class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleFill
218 {
219  Q_OBJECT
220 
221  public:
222  QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
223 
225 
226  // from base class
227  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
228  virtual QgsSymbolLayerV2* symbolLayer() override;
229 
230  public slots:
231  void setColor( const QColor& color );
232  void setBorderColor( const QColor& color );
233  void setBrushStyle();
234  void borderWidthChanged();
235  void borderStyleChanged();
236  void offsetChanged();
237  void on_mBorderWidthUnitWidget_changed();
238  void on_mOffsetUnitWidget_changed();
239 
240  protected:
242 };
243 
244 
246 
247 #include "ui_widget_gradientfill.h"
248 
250 
251 class GUI_EXPORT QgsGradientFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetGradientFill
252 {
253  Q_OBJECT
254 
255  public:
256  QgsGradientFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
257 
259 
260  // from base class
261  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
262  virtual QgsSymbolLayerV2* symbolLayer() override;
263 
264  public slots:
265  void setColor( const QColor& color );
266  void setColor2( const QColor& color );
267  void applyColorRamp();
268  void setGradientType( int index );
269  void setCoordinateMode( int index );
270  void setGradientSpread( int index );
271  void offsetChanged();
272  void referencePointChanged();
273  void on_mOffsetUnitWidget_changed();
274  void colorModeChanged();
275  void on_mSpinAngle_valueChanged( double value );
276 
277  protected:
279 };
280 
282 
283 #include "ui_widget_shapeburstfill.h"
284 
286 
287 class GUI_EXPORT QgsShapeburstFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetShapeburstFill
288 {
289  Q_OBJECT
290 
291  public:
292  QgsShapeburstFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
293 
295 
296  // from base class
297  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
298  virtual QgsSymbolLayerV2* symbolLayer() override;
299 
300  public slots:
301  void setColor( const QColor& color );
302  void setColor2( const QColor& color );
303  void colorModeChanged();
304  void on_mSpinBlurRadius_valueChanged( int value );
305  void on_mSpinMaxDistance_valueChanged( double value );
306  void on_mDistanceUnitWidget_changed();
307  void on_mRadioUseWholeShape_toggled( bool value );
308  void applyColorRamp();
309  void offsetChanged();
310  void on_mOffsetUnitWidget_changed();
311  void on_mIgnoreRingsCheckBox_stateChanged( int state );
312 
313  protected:
315 };
316 
318 
319 #include "ui_widget_markerline.h"
320 
322 
323 class GUI_EXPORT QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetMarkerLine
324 {
325  Q_OBJECT
326 
327  public:
328  QgsMarkerLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
329 
331 
332  // from base class
333  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
334  virtual QgsSymbolLayerV2* symbolLayer() override;
335 
336  public slots:
337 
338  void setInterval( double val );
339  void setOffsetAlongLine( double val );
340  void setRotate();
341  void setOffset();
342  void setPlacement();
343  void on_mIntervalUnitWidget_changed();
344  void on_mOffsetUnitWidget_changed();
345  void on_mOffsetAlongLineUnitWidget_changed();
346 
347  protected:
348 
350 };
351 
352 
354 
355 #include "ui_widget_svgmarker.h"
356 
358 
359 class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSvgMarker
360 {
361  Q_OBJECT
362 
363  public:
364  QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
366 
368 
369  // from base class
370  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
371  virtual QgsSymbolLayerV2* symbolLayer() override;
372 
373  public slots:
374  void setName( const QModelIndex& idx );
375  void populateIcons( const QModelIndex& idx );
376  void setSize();
377  void setAngle();
378  void setOffset();
379  void on_mFileToolButton_clicked();
380  void on_mFileLineEdit_textEdited( const QString& text );
381  void on_mFileLineEdit_editingFinished();
382  void on_mChangeColorButton_colorChanged( const QColor& color );
383  void on_mChangeBorderColorButton_colorChanged( const QColor& color );
384  void on_mBorderWidthSpinBox_valueChanged( double d );
385  void on_mSizeUnitWidget_changed();
386  void on_mBorderWidthUnitWidget_changed();
387  void on_mOffsetUnitWidget_changed();
388  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
389  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
390 
391  protected:
392 
393  void populateList();
394  //update gui for svg file (insert new path, update activation of gui elements for svg params)
395  void setGuiForSvg( const QgsSvgMarkerSymbolLayerV2* layer );
396 
398 
399  private slots:
400 
401  void updateAssistantSymbol();
402 
403  private:
404 
405  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
406 
407 };
408 
410 
411 #include "ui_widget_rasterfill.h"
412 
414 
415 class GUI_EXPORT QgsRasterFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetRasterFill
416 {
417  Q_OBJECT
418 
419  public:
420  QgsRasterFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
421 
423 
424  // from base class
425  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
426  virtual QgsSymbolLayerV2* symbolLayer() override;
427 
428  protected:
430 
431  private slots:
432  void on_mBrowseToolButton_clicked();
433  void on_mImageLineEdit_editingFinished();
434  void setCoordinateMode( int index );
435  void on_mSpinTransparency_valueChanged( int value );
436  void offsetChanged();
437  void on_mOffsetUnitWidget_changed();
438  void on_mRotationSpinBox_valueChanged( double d );
439  void on_mWidthUnitWidget_changed();
440  void on_mWidthSpinBox_valueChanged( double d );
441 
442  private:
443  void updatePreviewImage();
444 };
445 
447 
448 #include "ui_widget_svgfill.h"
449 
451 
452 class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetSVGFill
453 {
454  Q_OBJECT
455 
456  public:
457  QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
458 
459  static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSVGFillSymbolLayerWidget( vl ); }
460 
461  // from base class
462  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
463  virtual QgsSymbolLayerV2* symbolLayer() override;
464 
465  protected:
467  void insertIcons();
473  void updateParamGui( bool resetValues = true );
474 
475  private slots:
476  void on_mBrowseToolButton_clicked();
477  void on_mTextureWidthSpinBox_valueChanged( double d );
478  void on_mSVGLineEdit_textEdited( const QString & text );
479  void on_mSVGLineEdit_editingFinished();
480  void setFile( const QModelIndex& item );
481  void populateIcons( const QModelIndex& item );
482  void on_mRotationSpinBox_valueChanged( double d );
483  void on_mChangeColorButton_colorChanged( const QColor& color );
484  void on_mChangeBorderColorButton_colorChanged( const QColor& color );
485  void on_mBorderWidthSpinBox_valueChanged( double d );
486  void on_mTextureWidthUnitWidget_changed();
487  void on_mSvgOutlineWidthUnitWidget_changed();
488 };
489 
491 
492 #include "ui_widget_linepatternfill.h"
493 
495 
496 class GUI_EXPORT QgsLinePatternFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetLinePatternFill
497 {
498  Q_OBJECT
499 
500  public:
501 
502  QgsLinePatternFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
504 
505  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
506  virtual QgsSymbolLayerV2* symbolLayer() override;
507 
508  protected:
510 
511  private slots:
512  void on_mAngleSpinBox_valueChanged( double d );
513  void on_mDistanceSpinBox_valueChanged( double d );
514  void on_mOffsetSpinBox_valueChanged( double d );
515  void on_mDistanceUnitWidget_changed();
516  void on_mOffsetUnitWidget_changed();
517 };
518 
520 
521 #include "ui_widget_pointpatternfill.h"
522 
524 
525 class GUI_EXPORT QgsPointPatternFillSymbolLayerWidget: public QgsSymbolLayerV2Widget, private Ui::WidgetPointPatternFill
526 {
527  Q_OBJECT
528 
529  public:
530  QgsPointPatternFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
532 
533  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
534  virtual QgsSymbolLayerV2* symbolLayer() override;
535 
536  protected:
538 
539  private slots:
540  void on_mHorizontalDistanceSpinBox_valueChanged( double d );
541  void on_mVerticalDistanceSpinBox_valueChanged( double d );
542  void on_mHorizontalDisplacementSpinBox_valueChanged( double d );
543  void on_mVerticalDisplacementSpinBox_valueChanged( double d );
544  void on_mHorizontalDistanceUnitWidget_changed();
545  void on_mVerticalDistanceUnitWidget_changed();
546  void on_mHorizontalDisplacementUnitWidget_changed();
547  void on_mVerticalDisplacementUnitWidget_changed();
548 };
549 
551 
552 #include "ui_widget_fontmarker.h"
553 
555 class CharacterWidget;
556 
557 class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetFontMarker
558 {
559  Q_OBJECT
560 
561  public:
562  QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
563 
565 
567 
568  // from base class
569  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
570  virtual QgsSymbolLayerV2* symbolLayer() override;
571 
572  public slots:
573  void setFontFamily( const QFont& font );
574  void setColor( const QColor& color );
575 
578  void setColorBorder( const QColor& color );
579  void setSize( double size );
580  void setAngle( double angle );
581  void setCharacter( QChar chr );
582  void setOffset();
583  void on_mSizeUnitWidget_changed();
584  void on_mOffsetUnitWidget_changed();
585  void on_mBorderWidthUnitWidget_changed();
586  void on_mBorderWidthSpinBox_valueChanged( double d );
587  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
588  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
589 
590  protected:
593 
594  private slots:
595 
596  void penJoinStyleChanged();
597  void updateAssistantSymbol();
598 
599  private:
600 
601  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
602 
603 };
604 
606 
607 
608 #include "ui_widget_centroidfill.h"
609 
611 
612 class GUI_EXPORT QgsCentroidFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetCentroidFill
613 {
614  Q_OBJECT
615 
616  public:
617  QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
618 
620 
621  // from base class
622  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
623  virtual QgsSymbolLayerV2* symbolLayer() override;
624 
625  protected:
627 
628  private slots:
629  void on_mDrawInsideCheckBox_stateChanged( int state );
630  void on_mDrawAllPartsCheckBox_stateChanged( int state );
631 
632 };
633 
634 
636 
637 class QgsSvgListModel : public QAbstractListModel
638 {
639  Q_OBJECT
640 
641  public:
642  explicit QgsSvgListModel( QObject* parent );
643 
644  // Constructor to create model for icons in a specific path
645  QgsSvgListModel( QObject* parent, const QString& path );
646 
647  int rowCount( const QModelIndex & parent = QModelIndex() ) const override;
648 
649  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
650 
651  protected:
652  QStringList mSvgFiles;
653 };
654 
655 class QgsSvgGroupsModel : public QStandardItemModel
656 {
657  Q_OBJECT
658 
659  public:
660  explicit QgsSvgGroupsModel( QObject* parent );
661 
662  private:
663  void createTree( QStandardItem* &parentGroup );
664 };
665 
667 
668 #include "ui_qgsgeometrygeneratorwidgetbase.h"
669 
671 
672 class GUI_EXPORT QgsGeometryGeneratorSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::GeometryGeneratorWidgetBase
673 {
674  Q_OBJECT
675 
676  public:
677  QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
678 
683 
684  // from base class
685  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
686  virtual QgsSymbolLayerV2* symbolLayer() override;
687 
688  private:
690 
691  private slots:
692  void updateExpression();
693  void updateSymbolType();
694 };
695 
696 #endif
virtual void setSymbolLayer(QgsSymbolLayerV2 *layer)=0
static unsigned index
QgsGradientFillSymbolLayerV2 * mLayer
QgsSimpleLineSymbolLayerV2 * mLayer
QgsLinePatternFillSymbolLayer * mLayer
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
QgsFontMarkerSymbolLayerV2 * mLayer
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:105
const QgsVectorLayer * mVectorLayer
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
A class for filling symbols with a repeated raster image.
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
QgsPointPatternFillSymbolLayer * mLayer
QgsRasterFillSymbolLayer * mLayer
QgsMarkerLineSymbolLayerV2 * mLayer
A button for defining data source field mappings or expressions.
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
void setName(const char *name)
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)
QgsCentroidFillSymbolLayerV2 * mLayer
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
QgsSimpleMarkerSymbolLayerV2 * mLayer
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
A class for svg fill patterns.
QgsExpressionContext * mPresetExpressionContext
Optional preset expression context.
QgsSvgMarkerSymbolLayerV2 * mLayer
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
QgsSymbolLayerV2Widget(QWidget *parent, const QgsVectorLayer *vl=nullptr)
virtual QgsSymbolLayerV2 * symbolLayer()=0
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
Will be registered as factory.
QgsShapeburstFillSymbolLayerV2 * mLayer
Represents a vector layer which manages a vector based data sets.
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
QgsSVGFillSymbolLayer * mLayer
QgsSimpleFillSymbolLayerV2 * mLayer
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.