/
qgslayerstylingwidget.h
162 lines (141 loc) · 5.53 KB
/
qgslayerstylingwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/***************************************************************************
qgslayerstylingwidget.h
---------------------
begin : April 2016
copyright : (C) 2016 by Nathan Woodrow
email : woodrow dot nathan at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSLAYERSTYLESDOCK_H
#define QGSLAYERSTYLESDOCK_H
#include <QToolButton>
#include <QWidget>
#include <QLabel>
#include <QTabWidget>
#include <QStackedWidget>
#include <QDialogButtonBox>
#include <QCheckBox>
#include <QUndoCommand>
#include <QDomNode>
#include <QTime>
#include <QTimer>
#include "ui_qgsmapstylingwidgetbase.h"
#include "qgsmaplayerconfigwidgetfactory.h"
#include "qgis_app.h"
class QgsLabelingWidget;
class QgsMaskingWidget;
class QgsMapLayer;
class QgsMapCanvas;
class QgsRendererPropertiesDialog;
class QgsRendererRasterPropertiesWidget;
class QgsRendererMeshPropertiesWidget;
class QgsUndoWidget;
class QgsRasterHistogramWidget;
class QgsMapLayerStyleManagerWidget;
class QgsVectorLayer3DRendererWidget;
class QgsMeshLayer3DRendererWidget;
class QgsPointCloudLayer3DRendererWidget;
class QgsMessageBar;
class QgsVectorTileBasicRendererWidget;
class QgsVectorTileBasicLabelingWidget;
class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory
{
public:
QgsLayerStyleManagerWidgetFactory();
bool supportsStyleDock() const override { return true; }
QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const override;
bool supportsLayer( QgsMapLayer *layer ) const override;
};
class APP_EXPORT QgsMapLayerStyleCommand : public QUndoCommand
{
public:
QgsMapLayerStyleCommand( QgsMapLayer *layer, const QString &text, const QDomNode ¤t, const QDomNode &last, bool triggerRepaint = true );
/**
* Returns unique ID for this kind of undo command.
* Currently we do not have a central registry of undo command IDs, so it is a random magic number.
*/
int id() const override { return 0xbeef; }
void undo() override;
void redo() override;
//! Try to merge with other commands of this type when they are created in small time interval
bool mergeWith( const QUndoCommand *other ) override;
private:
QgsMapLayer *mLayer = nullptr;
QDomNode mXml;
QDomNode mLastState;
QTime mTime;
bool mTriggerRepaint = true;
};
class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerStylingWidgetBase
{
Q_OBJECT
public:
enum Page
{
Symbology = 1,
VectorLabeling,
RasterTransparency,
RasterHistogram,
History,
Symbology3D,
};
QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBar *messageBar, const QList<const QgsMapLayerConfigWidgetFactory *> &pages, QWidget *parent = nullptr );
~QgsLayerStylingWidget() override;
QgsMapLayer *layer() { return mCurrentLayer; }
void setPageFactories( const QList<const QgsMapLayerConfigWidgetFactory *> &factories );
/**
* Sets whether updates of the styling widget are blocked. This can be called to prevent
* the widget being refreshed multiple times when a batch of layer style changes are
* about to be applied
* \param blocked set to TRUE to block updates, or FALSE to re-allow updates
*/
void blockUpdates( bool blocked );
signals:
void styleChanged( QgsMapLayer *layer );
public slots:
void setLayer( QgsMapLayer *layer );
void apply();
void autoApply();
void undo();
void redo();
void updateCurrentWidgetLayer();
/**
* Sets the current visible page in the widget.
* \param page standard page to display
*/
void setCurrentPage( QgsLayerStylingWidget::Page page );
private slots:
void layerAboutToBeRemoved( QgsMapLayer *layer );
void liveApplyToggled( bool value );
private:
void pushUndoItem( const QString &name, bool triggerRepaint = true );
int mNotSupportedPage;
int mLayerPage;
QTimer *mAutoApplyTimer = nullptr;
QDomNode mLastStyleXml;
QgsMapCanvas *mMapCanvas = nullptr;
QgsMessageBar *mMessageBar = nullptr;
bool mBlockAutoApply;
QgsUndoWidget *mUndoWidget = nullptr;
QgsMapLayer *mCurrentLayer = nullptr;
QgsLabelingWidget *mLabelingWidget = nullptr;
QgsMaskingWidget *mMaskingWidget = nullptr;
#ifdef HAVE_3D
QgsVectorLayer3DRendererWidget *mVector3DWidget = nullptr;
QgsMeshLayer3DRendererWidget *mMesh3DWidget = nullptr;
#endif
QgsRendererRasterPropertiesWidget *mRasterStyleWidget = nullptr;
QgsRendererMeshPropertiesWidget *mMeshStyleWidget = nullptr;
QgsVectorTileBasicRendererWidget *mVectorTileStyleWidget = nullptr;
QgsVectorTileBasicLabelingWidget *mVectorTileLabelingWidget = nullptr;
QList<const QgsMapLayerConfigWidgetFactory *> mPageFactories;
QMap<int, const QgsMapLayerConfigWidgetFactory *> mUserPages;
QgsLayerStyleManagerWidgetFactory *mStyleManagerFactory = nullptr;
};
#endif // QGSLAYERSTYLESDOCK_H