QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
32 class GUI_EXPORT QgsSymbolLayerV2Widget : public QWidget
33 {
34  Q_OBJECT
35 
36  public:
37  QgsSymbolLayerV2Widget( QWidget* parent, const QgsVectorLayer* vl = nullptr )
38  : QWidget( parent )
39  , mVectorLayer( vl )
40  , mPresetExpressionContext( nullptr )
41  , mMapCanvas( nullptr )
42  {}
44 
45  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) = 0;
46  virtual QgsSymbolLayerV2* symbolLayer() = 0;
47 
54  QgsExpressionContext* expressionContext() const { return mPresetExpressionContext; }
55 
62  virtual void setMapCanvas( QgsMapCanvas* canvas );
63 
68  const QgsMapCanvas* mapCanvas() const;
69 
73  const QgsVectorLayer* vectorLayer() const { return mVectorLayer; }
74 
75  public slots:
76 
85  void setExpressionContext( QgsExpressionContext* context ) { mPresetExpressionContext = context; }
86 
87  protected:
89 
92 
94 
95  void registerDataDefinedButton( QgsDataDefinedButton * button, const QString & propertyName, QgsDataDefinedButton::DataType type, const QString & description );
96 
102  Q_DECL_DEPRECATED virtual QString dataDefinedPropertyLabel( const QString &entryName );
103 
104  signals:
109  void changed();
116  void symbolChanged();
117 
118  protected slots:
119  void updateDataDefinedProperty();
120 };
121 
123 
124 #include "ui_widget_simpleline.h"
125 
127 
131 class GUI_EXPORT QgsSimpleLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleLine
132 {
133  Q_OBJECT
134 
135  public:
136  QgsSimpleLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
137 
139 
141 
142  // from base class
143  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
144  virtual QgsSymbolLayerV2* symbolLayer() override;
145 
146  public slots:
147  void penWidthChanged();
148  void colorChanged( const QColor& color );
149  void penStyleChanged();
150  void offsetChanged();
151  void on_mCustomCheckBox_stateChanged( int state );
152  void on_mChangePatternButton_clicked();
153  void on_mPenWidthUnitWidget_changed();
154  void on_mOffsetUnitWidget_changed();
155  void on_mDashPatternUnitWidget_changed();
156  void on_mDrawInsideCheckBox_stateChanged( int state );
157 
158  protected:
160 
161  //creates a new icon for the 'change pattern' button
162  void updatePatternIcon();
163 
164  private slots:
165 
166  void updateAssistantSymbol();
167 
168  private:
169 
170  QgsLineSymbolV2* mAssistantPreviewSymbol;
171 
172 };
173 
175 
176 #include "ui_widget_simplemarker.h"
177 
179 
183 class GUI_EXPORT QgsSimpleMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleMarker
184 {
185  Q_OBJECT
186 
187  public:
188  QgsSimpleMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
190 
192 
193  // from base class
194  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
195  virtual QgsSymbolLayerV2* symbolLayer() override;
196 
197  public slots:
198  //TODO QGIS 3.0 - rename to setShape
199  void setName();
200  void setColorBorder( const QColor& color );
201  void setColorFill( const QColor& color );
202  void setSize();
203  void setAngle();
204  void setOffset();
205  void on_mSizeUnitWidget_changed();
206  void on_mOffsetUnitWidget_changed();
207  void on_mOutlineWidthUnitWidget_changed();
208  void on_mOutlineStyleComboBox_currentIndexChanged( int index );
209  void on_mOutlineWidthSpinBox_valueChanged( double d );
210  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
211  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
212 
213  protected:
215 
216  private slots:
217 
218  void updateAssistantSymbol();
219  void penJoinStyleChanged();
220 
221  private:
222 
223  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
224 };
225 
227 
228 #include "ui_widget_simplefill.h"
229 
231 
235 class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleFill
236 {
237  Q_OBJECT
238 
239  public:
240  QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
241 
243 
244  // from base class
245  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
246  virtual QgsSymbolLayerV2* symbolLayer() override;
247 
248  public slots:
249  void setColor( const QColor& color );
250  void setBorderColor( const QColor& color );
251  void setBrushStyle();
252  void borderWidthChanged();
253  void borderStyleChanged();
254  void offsetChanged();
255  void on_mBorderWidthUnitWidget_changed();
256  void on_mOffsetUnitWidget_changed();
257 
258  protected:
260 };
261 
262 
264 
265 #include "ui_widget_filledmarker.h"
266 
268 
274 class GUI_EXPORT QgsFilledMarkerSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetFilledMarker
275 {
276  Q_OBJECT
277 
278  public:
279 
284  QgsFilledMarkerSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
285 
287 
292 
293  // from base class
294  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
295  virtual QgsSymbolLayerV2* symbolLayer() override;
296 
297  protected:
299 
300  private slots:
301 
302  void updateAssistantSymbol();
303  void setShape();
304  void setSize();
305  void setAngle();
306  void setOffset();
307  void on_mSizeUnitWidget_changed();
308  void on_mOffsetUnitWidget_changed();
309  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
310  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
311 
312  private:
313 
314  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
315 };
316 
318 
319 #include "ui_widget_gradientfill.h"
320 
322 
326 class GUI_EXPORT QgsGradientFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetGradientFill
327 {
328  Q_OBJECT
329 
330  public:
331  QgsGradientFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
332 
334 
335  // from base class
336  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
337  virtual QgsSymbolLayerV2* symbolLayer() override;
338 
339  public slots:
340  void setColor( const QColor& color );
341  void setColor2( const QColor& color );
342  void applyColorRamp();
343  void setGradientType( int index );
344  void setCoordinateMode( int index );
345  void setGradientSpread( int index );
346  void offsetChanged();
347  void referencePointChanged();
348  void on_mOffsetUnitWidget_changed();
349  void colorModeChanged();
350  void on_mSpinAngle_valueChanged( double value );
351 
352  protected:
354 };
355 
357 
358 #include "ui_widget_shapeburstfill.h"
359 
361 
365 class GUI_EXPORT QgsShapeburstFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetShapeburstFill
366 {
367  Q_OBJECT
368 
369  public:
370  QgsShapeburstFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
371 
373 
374  // from base class
375  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
376  virtual QgsSymbolLayerV2* symbolLayer() override;
377 
378  public slots:
379  void setColor( const QColor& color );
380  void setColor2( const QColor& color );
381  void colorModeChanged();
382  void on_mSpinBlurRadius_valueChanged( int value );
383  void on_mSpinMaxDistance_valueChanged( double value );
384  void on_mDistanceUnitWidget_changed();
385  void on_mRadioUseWholeShape_toggled( bool value );
386  void applyColorRamp();
387  void offsetChanged();
388  void on_mOffsetUnitWidget_changed();
389  void on_mIgnoreRingsCheckBox_stateChanged( int state );
390 
391  protected:
393 };
394 
396 
397 #include "ui_widget_markerline.h"
398 
400 
404 class GUI_EXPORT QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetMarkerLine
405 {
406  Q_OBJECT
407 
408  public:
409  QgsMarkerLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
410 
412 
413  // from base class
414  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
415  virtual QgsSymbolLayerV2* symbolLayer() override;
416 
417  public slots:
418 
419  void setInterval( double val );
420  void setOffsetAlongLine( double val );
421  void setRotate();
422  void setOffset();
423  void setPlacement();
424  void on_mIntervalUnitWidget_changed();
425  void on_mOffsetUnitWidget_changed();
426  void on_mOffsetAlongLineUnitWidget_changed();
427 
428  protected:
429 
431 };
432 
433 
435 
436 #include "ui_widget_svgmarker.h"
437 
439 
443 class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSvgMarker
444 {
445  Q_OBJECT
446 
447  public:
448  QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
450 
452 
453  // from base class
454  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
455  virtual QgsSymbolLayerV2* symbolLayer() override;
456 
457  public slots:
458  void setName( const QModelIndex& idx );
459  void populateIcons( const QModelIndex& idx );
460  void setSize();
461  void setAngle();
462  void setOffset();
463  void on_mFileToolButton_clicked();
464  void on_mFileLineEdit_textEdited( const QString& text );
465  void on_mFileLineEdit_editingFinished();
466  void on_mChangeColorButton_colorChanged( const QColor& color );
467  void on_mChangeBorderColorButton_colorChanged( const QColor& color );
468  void on_mBorderWidthSpinBox_valueChanged( double d );
469  void on_mSizeUnitWidget_changed();
470  void on_mBorderWidthUnitWidget_changed();
471  void on_mOffsetUnitWidget_changed();
472  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
473  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
474 
475  protected:
476 
477  void populateList();
478  //update gui for svg file (insert new path, update activation of gui elements for svg params)
479  void setGuiForSvg( const QgsSvgMarkerSymbolLayerV2* layer );
480 
482 
483  private slots:
484 
485  void updateAssistantSymbol();
486 
487  private:
488 
489  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
490 
491 };
492 
494 
495 #include "ui_widget_rasterfill.h"
496 
498 
502 class GUI_EXPORT QgsRasterFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetRasterFill
503 {
504  Q_OBJECT
505 
506  public:
507  QgsRasterFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
508 
510 
511  // from base class
512  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
513  virtual QgsSymbolLayerV2* symbolLayer() override;
514 
515  protected:
517 
518  private slots:
519  void on_mBrowseToolButton_clicked();
520  void on_mImageLineEdit_editingFinished();
521  void setCoordinateMode( int index );
522  void on_mSpinTransparency_valueChanged( int value );
523  void offsetChanged();
524  void on_mOffsetUnitWidget_changed();
525  void on_mRotationSpinBox_valueChanged( double d );
526  void on_mWidthUnitWidget_changed();
527  void on_mWidthSpinBox_valueChanged( double d );
528 
529  private:
530  void updatePreviewImage();
531 };
532 
534 
535 #include "ui_widget_svgfill.h"
536 
538 
542 class GUI_EXPORT QgsSVGFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetSVGFill
543 {
544  Q_OBJECT
545 
546  public:
547  QgsSVGFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
548 
549  static QgsSymbolLayerV2Widget* create( const QgsVectorLayer* vl ) { return new QgsSVGFillSymbolLayerWidget( vl ); }
550 
551  // from base class
552  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
553  virtual QgsSymbolLayerV2* symbolLayer() override;
554 
555  protected:
557  void insertIcons();
563  void updateParamGui( bool resetValues = true );
564 
565  private slots:
566  void on_mBrowseToolButton_clicked();
567  void on_mTextureWidthSpinBox_valueChanged( double d );
568  void on_mSVGLineEdit_textEdited( const QString & text );
569  void on_mSVGLineEdit_editingFinished();
570  void setFile( const QModelIndex& item );
571  void populateIcons( const QModelIndex& item );
572  void on_mRotationSpinBox_valueChanged( double d );
573  void on_mChangeColorButton_colorChanged( const QColor& color );
574  void on_mChangeBorderColorButton_colorChanged( const QColor& color );
575  void on_mBorderWidthSpinBox_valueChanged( double d );
576  void on_mTextureWidthUnitWidget_changed();
577  void on_mSvgOutlineWidthUnitWidget_changed();
578 };
579 
581 
582 #include "ui_widget_linepatternfill.h"
583 
585 
589 class GUI_EXPORT QgsLinePatternFillSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::WidgetLinePatternFill
590 {
591  Q_OBJECT
592 
593  public:
594 
595  QgsLinePatternFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
597 
598  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
599  virtual QgsSymbolLayerV2* symbolLayer() override;
600 
601  protected:
603 
604  private slots:
605  void on_mAngleSpinBox_valueChanged( double d );
606  void on_mDistanceSpinBox_valueChanged( double d );
607  void on_mOffsetSpinBox_valueChanged( double d );
608  void on_mDistanceUnitWidget_changed();
609  void on_mOffsetUnitWidget_changed();
610 };
611 
613 
614 #include "ui_widget_pointpatternfill.h"
615 
617 
621 class GUI_EXPORT QgsPointPatternFillSymbolLayerWidget: public QgsSymbolLayerV2Widget, private Ui::WidgetPointPatternFill
622 {
623  Q_OBJECT
624 
625  public:
626  QgsPointPatternFillSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
628 
629  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
630  virtual QgsSymbolLayerV2* symbolLayer() override;
631 
632  protected:
634 
635  private slots:
636  void on_mHorizontalDistanceSpinBox_valueChanged( double d );
637  void on_mVerticalDistanceSpinBox_valueChanged( double d );
638  void on_mHorizontalDisplacementSpinBox_valueChanged( double d );
639  void on_mVerticalDisplacementSpinBox_valueChanged( double d );
640  void on_mHorizontalDistanceUnitWidget_changed();
641  void on_mVerticalDistanceUnitWidget_changed();
642  void on_mHorizontalDisplacementUnitWidget_changed();
643  void on_mVerticalDisplacementUnitWidget_changed();
644 };
645 
647 
648 #include "ui_widget_fontmarker.h"
649 
651 class CharacterWidget;
652 
656 class GUI_EXPORT QgsFontMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetFontMarker
657 {
658  Q_OBJECT
659 
660  public:
661  QgsFontMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
662 
664 
666 
667  // from base class
668  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
669  virtual QgsSymbolLayerV2* symbolLayer() override;
670 
671  public slots:
672  void setFontFamily( const QFont& font );
673  void setColor( const QColor& color );
674 
677  void setColorBorder( const QColor& color );
678  void setSize( double size );
679  void setAngle( double angle );
680  void setCharacter( QChar chr );
681  void setOffset();
682  void on_mSizeUnitWidget_changed();
683  void on_mOffsetUnitWidget_changed();
684  void on_mBorderWidthUnitWidget_changed();
685  void on_mBorderWidthSpinBox_valueChanged( double d );
686  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
687  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
688 
689  protected:
692 
693  private slots:
694 
695  void penJoinStyleChanged();
696  void updateAssistantSymbol();
697 
698  private:
699 
700  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
701 
702 };
703 
705 
706 
707 #include "ui_widget_centroidfill.h"
708 
710 
714 class GUI_EXPORT QgsCentroidFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetCentroidFill
715 {
716  Q_OBJECT
717 
718  public:
719  QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
720 
722 
723  // from base class
724  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
725  virtual QgsSymbolLayerV2* symbolLayer() override;
726 
727  protected:
729 
730  private slots:
731  void on_mDrawInsideCheckBox_stateChanged( int state );
732  void on_mDrawAllPartsCheckBox_stateChanged( int state );
733 
734 };
735 
736 
737 #include "ui_qgsgeometrygeneratorwidgetbase.h"
738 
740 
744 class GUI_EXPORT QgsGeometryGeneratorSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::GeometryGeneratorWidgetBase
745 {
746  Q_OBJECT
747 
748  public:
749  QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
750 
755 
756  // from base class
757  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
758  virtual QgsSymbolLayerV2* symbolLayer() override;
759 
760  private:
762 
763  private slots:
764  void updateExpression();
765  void updateSymbolType();
766 };
767 
768 #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)
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
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.
QgsExpressionContext * expressionContext() const
Returns the expression context used for the widget, if set.
Widget for configuring QgsFilledMarkerSymbolLayer symbol layers.
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)
QgsFilledMarkerSymbolLayer * mLayer
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
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
Filled marker symbol layer, consisting of a shape which is rendered using a QgsFillSymbolV2.
Represents a vector layer which manages a vector based data sets.
const QgsVectorLayer * vectorLayer() const
Returns the vector layer associated with the widget.
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
Creates a new QgsFilledMarkerSymbolLayerWidget.
static QgsSymbolLayerV2Widget * create(const QgsVectorLayer *vl)
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an outline...
QgsSVGFillSymbolLayer * mLayer
QgsSimpleFillSymbolLayerV2 * mLayer
void setExpressionContext(QgsExpressionContext *context)
Sets the optional expression context used for the widget.