QGIS API Documentation  3.6.0-Noosa (5873452)
qgssymbolslistwidget.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssymbolslistwidget.h
3  ---------------------
4  begin : June 2012
5  copyright : (C) 2012 by Arunmozhi
6  email : aruntheguy at gmail.com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSSYMBOLSLISTWIDGET_H
17 #define QGSSYMBOLSLISTWIDGET_H
18 
19 #include "ui_widget_symbolslist.h"
20 
21 #include "qgssymbolwidgetcontext.h"
22 #include "qgssymbollayer.h"
23 #include "qgsstylemodel.h"
24 #include <QWidget>
25 #include "qgis_gui.h"
26 
27 class QgsSymbol;
28 class QgsStyle;
29 
30 class QMenu;
31 
32 #ifndef SIP_RUN
33 class QgsReadOnlyStyleModel : public QgsStyleProxyModel
35 {
36  Q_OBJECT
37  public:
38 
39  explicit QgsReadOnlyStyleModel( QgsStyle *style, QObject *parent = nullptr );
40  Qt::ItemFlags flags( const QModelIndex &index ) const override;
41  QVariant data( const QModelIndex &index, int role ) const override;
42 
43 };
44 #endif
45 
51 class GUI_EXPORT QgsSymbolsListWidget : public QWidget, private Ui::SymbolsListWidget, private QgsExpressionContextGenerator
52 {
53  Q_OBJECT
54 
55  public:
56 
65  QgsSymbolsListWidget( QgsSymbol *symbol, QgsStyle *style, QMenu *menu, QWidget *parent SIP_TRANSFERTHIS, QgsVectorLayer *layer = nullptr );
66 
67 
68  ~QgsSymbolsListWidget() override;
69 
76  void setContext( const QgsSymbolWidgetContext &context );
77 
83  QgsSymbolWidgetContext context() const;
84 
89  const QgsVectorLayer *layer() const { return mLayer; }
90 
91  public slots:
92 
93  void setSymbolFromStyle( const QModelIndex &index );
94  void setSymbolColor( const QColor &color );
95  void setMarkerAngle( double angle );
96  void setMarkerSize( double size );
97  void setLineWidth( double width );
98  void addSymbolToStyle();
99  void saveSymbol();
100 
102  void populateGroups();
103 
104  void openStyleManager();
105  void clipFeaturesToggled( bool checked );
106 
107  void updateDataDefinedMarkerSize();
108  void updateDataDefinedMarkerAngle();
109  void updateDataDefinedLineWidth();
110 
111  signals:
112  void changed();
113 
114  private slots:
115  void mSymbolUnitWidget_changed();
116  void groupsCombo_currentIndexChanged( int index );
117  void updateAssistantSymbol();
118  void opacityChanged( double value );
119  void createAuxiliaryField();
120  void updateModelFilters();
121  void forceRHRToggled( bool checked );
122 
123  private:
124  QgsSymbol *mSymbol = nullptr;
125  std::shared_ptr< QgsSymbol > mAssistantSymbol;
126  QgsStyle *mStyle = nullptr;
127  QMenu *mAdvancedMenu = nullptr;
128  QAction *mClipFeaturesAction = nullptr;
129  QAction *mStandardizeRingsAction = nullptr;
130  QgsVectorLayer *mLayer = nullptr;
131  QgsMapCanvas *mMapCanvas = nullptr;
132  QgsStyleProxyModel *mModel = nullptr;
133  bool mUpdatingGroups = false;
134 
135  void updateSymbolColor();
136  void updateSymbolInfo();
137  QgsSymbolWidgetContext mContext;
138 
139  QgsExpressionContext createExpressionContext() const override;
140  void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsSymbolLayer::Property key );
141 };
142 
143 #endif //QGSSYMBOLSLISTWIDGET_H
144 
145 
146 
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:73
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
A button for controlling property overrides which may apply to a widget.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
const QgsVectorLayer * layer() const
Returns the vector layer associated with the widget.
Abstract interface for generating an expression context.
Represents a vector layer which manages a vector based data sets.
Property
Data definable properties.