QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgsdiagramproperties.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsdiagramproperties.h
3 Properties for diagram layers
4 -------------------
5 begin : August 2012
6 copyright : (C) Matthias Kuhn
7 email : matthias at opengis dot ch
8
9 ***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSDIAGRAMPROPERTIES_H
19#define QGSDIAGRAMPROPERTIES_H
20
21// We don't want to expose this in the public API
22#define SIP_NO_FILE
23
24#include "ui_qgsdiagrampropertiesbase.h"
25
26#include "qgis_gui.h"
27#include "qgsdiagramrenderer.h"
28#include "qgscolorschemelist.h"
29
30#include <QDialog>
31#include <QStyledItemDelegate>
32
33class QgsVectorLayer;
34class QgsMapCanvas;
35
42class GUI_EXPORT QgsDiagramProperties : public QgsPanelWidget, private Ui::QgsDiagramPropertiesBase, private QgsExpressionContextGenerator
43{
44 Q_OBJECT
45
46 public:
47 QgsDiagramProperties( QgsVectorLayer *layer, QWidget *parent, QgsMapCanvas *canvas );
48 ~QgsDiagramProperties() override;
49
55 void syncToLayer();
56
63 void syncToRenderer( const QgsDiagramRenderer *dr );
64
71 void syncToSettings( const QgsDiagramLayerSettings *dls );
72
74 void addAttribute( QTreeWidgetItem *item );
75
80 void setDockMode( bool dockMode ) override;
81
87 void setDiagramType( const QString diagramType );
88
97 void setAllowedToEditDiagramLayerSettings( bool allowed );
98
102 bool isAllowedToEditDiagramLayerSettings() const;
103
104 signals:
105
107
108 public slots:
109 void apply();
110 void mDiagramTypeComboBox_currentIndexChanged( int index );
111 void mAddCategoryPushButton_clicked();
112 void mAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
113 void mFindMaximumValueButton_clicked();
114 void mRemoveCategoryPushButton_clicked();
115 void mDiagramAttributesTreeWidget_itemDoubleClicked( QTreeWidgetItem *item, int column );
116 void showAddAttributeExpressionDialog();
117 void mDiagramStackedWidget_currentChanged( int index );
118 void updatePlacementWidgets();
119 void scalingTypeChanged();
120 void showSizeLegendDialog();
121
122 private slots:
123
124 void updateProperty();
125 void showHelp();
126
127 void createAuxiliaryField();
128
129 private:
130 QgsVectorLayer *mLayer = nullptr;
132 QButtonGroup *mPlacePointBtnGrp = nullptr;
134 QButtonGroup *mPlaceLineBtnGrp = nullptr;
136 QButtonGroup *mPlacePolygonBtnGrp = nullptr;
137
138 std::unique_ptr<QgsPaintEffect> mPaintEffect;
139
140 enum Columns
141 {
142 ColumnAttributeExpression = 0,
143 ColumnColor,
144 ColumnLegendText,
145 };
146
147 enum Roles
148 {
149 RoleAttributeExpression = Qt::UserRole,
150 };
151
152 QString showExpressionBuilder( const QString &initialExpression );
153
154 QgsPropertyCollection mDataDefinedProperties;
155
156 // Keeps track of the diagram type to properly save / restore settings when the diagram type combo box is set to no diagram.
157 QString mDiagramType;
158 std::unique_ptr<QgsDataDefinedSizeLegend> mSizeLegend;
159
160 QString guessLegendText( const QString &expression );
161 QgsMapCanvas *mMapCanvas = nullptr;
162
164
165 bool mAllowedToEditDls = true;
166
167 void registerDataDefinedButton( QgsPropertyOverrideButton *button, QgsDiagramLayerSettings::Property key );
168
174 void connectValueChanged( const QList<QWidget *> &widgets );
175
181 std::unique_ptr<QgsDiagram> createDiagramObject();
182
188 std::unique_ptr<QgsDiagramSettings> createDiagramSettings();
189
195 std::unique_ptr<QgsDiagramRenderer> createRenderer();
196
202 QgsDiagramLayerSettings createDiagramLayerSettings();
203
207 void insertDefaults();
208
217 void setDiagramEnabled( const bool enabled );
218
227 bool isDiagramEnabled() const;
228
231};
232
233
238class EditBlockerDelegate : public QStyledItemDelegate
239{
240 Q_OBJECT
241 public:
242 EditBlockerDelegate( QObject *parent = nullptr )
243 : QStyledItemDelegate( parent )
244 {}
245
246 QWidget *createEditor( QWidget *, const QStyleOptionViewItem &, const QModelIndex & ) const override
247 {
248 return nullptr;
249 }
250};
251
252
253#endif // QGSDIAGRAMPROPERTIES_H
EditBlockerDelegate(QObject *parent=nullptr)
QWidget * createEditor(QWidget *, const QStyleOptionViewItem &, const QModelIndex &) const override
Stores the settings for rendering of all diagrams for a layer.
Property
Data definable properties.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Abstract interface for generating an expression context.
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for any widget that can be shown as a inline panel.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
A button for controlling property overrides which may apply to a widget.
Represents a vector layer which manages a vector based data sets.