QGIS API Documentation  2.13.0-Master
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 
205  private:
206 
207  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
208 };
209 
211 
212 #include "ui_widget_simplefill.h"
213 
215 
216 class GUI_EXPORT QgsSimpleFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSimpleFill
217 {
218  Q_OBJECT
219 
220  public:
221  QgsSimpleFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
222 
224 
225  // from base class
226  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
227  virtual QgsSymbolLayerV2* symbolLayer() override;
228 
229  public slots:
230  void setColor( const QColor& color );
231  void setBorderColor( const QColor& color );
232  void setBrushStyle();
233  void borderWidthChanged();
234  void borderStyleChanged();
235  void offsetChanged();
236  void on_mBorderWidthUnitWidget_changed();
237  void on_mOffsetUnitWidget_changed();
238 
239  protected:
241 };
242 
243 
245 
246 #include "ui_widget_gradientfill.h"
247 
249 
250 class GUI_EXPORT QgsGradientFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetGradientFill
251 {
252  Q_OBJECT
253 
254  public:
255  QgsGradientFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
256 
258 
259  // from base class
260  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
261  virtual QgsSymbolLayerV2* symbolLayer() override;
262 
263  public slots:
264  void setColor( const QColor& color );
265  void setColor2( const QColor& color );
266  void applyColorRamp();
267  void setGradientType( int index );
268  void setCoordinateMode( int index );
269  void setGradientSpread( int index );
270  void offsetChanged();
271  void referencePointChanged();
272  void on_mOffsetUnitWidget_changed();
273  void colorModeChanged();
274  void on_mSpinAngle_valueChanged( double value );
275 
276  protected:
278 };
279 
281 
282 #include "ui_widget_shapeburstfill.h"
283 
285 
286 class GUI_EXPORT QgsShapeburstFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetShapeburstFill
287 {
288  Q_OBJECT
289 
290  public:
291  QgsShapeburstFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
292 
294 
295  // from base class
296  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
297  virtual QgsSymbolLayerV2* symbolLayer() override;
298 
299  public slots:
300  void setColor( const QColor& color );
301  void setColor2( const QColor& color );
302  void colorModeChanged();
303  void on_mSpinBlurRadius_valueChanged( int value );
304  void on_mSpinMaxDistance_valueChanged( double value );
305  void on_mDistanceUnitWidget_changed();
306  void on_mRadioUseWholeShape_toggled( bool value );
307  void applyColorRamp();
308  void offsetChanged();
309  void on_mOffsetUnitWidget_changed();
310  void on_mIgnoreRingsCheckBox_stateChanged( int state );
311 
312  protected:
314 };
315 
317 
318 #include "ui_widget_markerline.h"
319 
321 
322 class GUI_EXPORT QgsMarkerLineSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetMarkerLine
323 {
324  Q_OBJECT
325 
326  public:
327  QgsMarkerLineSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
328 
330 
331  // from base class
332  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
333  virtual QgsSymbolLayerV2* symbolLayer() override;
334 
335  public slots:
336 
337  void setInterval( double val );
338  void setOffsetAlongLine( double val );
339  void setRotate();
340  void setOffset();
341  void setPlacement();
342  void on_mIntervalUnitWidget_changed();
343  void on_mOffsetUnitWidget_changed();
344  void on_mOffsetAlongLineUnitWidget_changed();
345 
346  protected:
347 
349 };
350 
351 
353 
354 #include "ui_widget_svgmarker.h"
355 
357 
358 class GUI_EXPORT QgsSvgMarkerSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetSvgMarker
359 {
360  Q_OBJECT
361 
362  public:
363  QgsSvgMarkerSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
365 
367 
368  // from base class
369  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
370  virtual QgsSymbolLayerV2* symbolLayer() override;
371 
372  public slots:
373  void setName( const QModelIndex& idx );
374  void populateIcons( const QModelIndex& idx );
375  void setSize();
376  void setAngle();
377  void setOffset();
378  void on_mFileToolButton_clicked();
379  void on_mFileLineEdit_textEdited( const QString& text );
380  void on_mFileLineEdit_editingFinished();
381  void on_mChangeColorButton_colorChanged( const QColor& color );
382  void on_mChangeBorderColorButton_colorChanged( const QColor& color );
383  void on_mBorderWidthSpinBox_valueChanged( double d );
384  void on_mSizeUnitWidget_changed();
385  void on_mBorderWidthUnitWidget_changed();
386  void on_mOffsetUnitWidget_changed();
387  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
388  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
389 
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  void setSize( double size );
576  void setAngle( double angle );
577  void setCharacter( QChar chr );
578  void setOffset();
579  void on_mSizeUnitWidget_changed();
580  void on_mOffsetUnitWidget_changed();
581  void on_mHorizontalAnchorComboBox_currentIndexChanged( int index );
582  void on_mVerticalAnchorComboBox_currentIndexChanged( int index );
583 
584  protected:
587 
588  private slots:
589 
590  void updateAssistantSymbol();
591 
592  private:
593 
594  QgsMarkerSymbolV2* mAssistantPreviewSymbol;
595 
596 };
597 
599 
600 
601 #include "ui_widget_centroidfill.h"
602 
604 
605 class GUI_EXPORT QgsCentroidFillSymbolLayerV2Widget : public QgsSymbolLayerV2Widget, private Ui::WidgetCentroidFill
606 {
607  Q_OBJECT
608 
609  public:
610  QgsCentroidFillSymbolLayerV2Widget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
611 
613 
614  // from base class
615  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
616  virtual QgsSymbolLayerV2* symbolLayer() override;
617 
618  protected:
620 
621  private slots:
622  void on_mDrawInsideCheckBox_stateChanged( int state );
623 
624 };
625 
626 
628 
629 class QgsSvgListModel : public QAbstractListModel
630 {
631  Q_OBJECT
632 
633  public:
634  explicit QgsSvgListModel( QObject* parent );
635 
636  // Constructor to create model for icons in a specific path
637  QgsSvgListModel( QObject* parent, const QString& path );
638 
639  int rowCount( const QModelIndex & parent = QModelIndex() ) const override;
640 
641  QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const override;
642 
643  protected:
644  QStringList mSvgFiles;
645 };
646 
647 class QgsSvgGroupsModel : public QStandardItemModel
648 {
649  Q_OBJECT
650 
651  public:
652  explicit QgsSvgGroupsModel( QObject* parent );
653 
654  private:
655  void createTree( QStandardItem* &parentGroup );
656 };
657 
659 
660 #include "ui_qgsgeometrygeneratorwidgetbase.h"
661 
663 
664 class GUI_EXPORT QgsGeometryGeneratorSymbolLayerWidget : public QgsSymbolLayerV2Widget, private Ui::GeometryGeneratorWidgetBase
665 {
666  Q_OBJECT
667 
668  public:
669  QgsGeometryGeneratorSymbolLayerWidget( const QgsVectorLayer* vl, QWidget* parent = nullptr );
670 
675 
676  // from base class
677  virtual void setSymbolLayer( QgsSymbolLayerV2* layer ) override;
678  virtual QgsSymbolLayerV2* symbolLayer() override;
679 
680  private:
682 
683  private slots:
684  void updateExpression();
685  void updateSymbolType();
686 };
687 
688 #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.