QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsrastertransparencywidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrastertransparencywidget.h
3 ---------------------
4 begin : May 2016
5 copyright : (C) 2016 by Nathan Woodrow
6 email : woodrow dot nathan at gmail dot 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#ifndef QGSRASTERTRANSPARENCYWIDGET_H
16#define QGSRASTERTRANSPARENCYWIDGET_H
17
18#include <QWidget>
19
20#include "ui_qgsrastertransparencywidget.h"
21
23#include "qgsrasterpipe.h"
25
26#include "qgis_gui.h"
27
28class QgsRasterLayer;
30class QgsMapCanvas;
32class QgsPointXY;
33
38class GUI_EXPORT QgsRasterTransparencyWidget : public QgsMapLayerConfigWidget, private QgsExpressionContextGenerator, public Ui::QgsRasterTransparencyWidget
39{
40 Q_OBJECT
41 public:
45 QgsRasterTransparencyWidget( QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr );
46
51 void setContext( const QgsSymbolWidgetContext &context );
52
54
59 QgsMapToolEmitPoint *pixelSelectorTool() const;
60
68 void applyToRasterProvider( QgsRasterDataProvider *provider ) SIP_SKIP;
69
77 void applyToRasterRenderer( QgsRasterRenderer *renderer ) SIP_SKIP;
78
79 public slots:
80
81#ifdef __clang__
82#pragma clang diagnostic push
83#pragma clang diagnostic ignored "-Woverloaded-virtual"
84#endif
85
89 void syncToLayer();
90#ifdef __clang__
91#pragma clang diagnostic pop
92#endif
93
97 void apply() override;
98
99 protected:
100#ifndef SIP_RUN
101
102 // TODO -- consider moving these to a common raster widget base class
103
111 void initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsRasterPipe::Property key );
112
118 void updateDataDefinedButtons();
119
125 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
126
129
130#endif
131
132 private slots:
133
134 void updateProperty();
135
136 void pixelSelected( const QgsPointXY &canvasPoint );
137
139 void transparencyCellTextEdited( const QString &text );
140
142 void pbnAddValuesFromDisplay_clicked();
143
145 void pbnAddValuesManually_clicked();
146
148 void pbnDefaultValues_clicked();
149
151 void pbnExportTransparentPixelValues_clicked();
152
154 void pbnImportTransparentPixelValues_clicked();
156 void pbnRemoveSelectedRow_clicked();
157
158 private:
160 const QString TRSTRING_NOT_SET;
161
162 enum class Mode : int
163 {
164 SingleBand = 0,
165 RgbBands
166 };
167
168 enum class RgbBandTableColumns : int
169 {
170 Red = 0,
171 Green = 1,
172 Blue = 2,
173 Tolerance = 3,
174 Opacity = 4,
175 ColumnCount = Opacity + 1
176 };
177
178 enum class SingleBandTableColumns : int
179 {
180 From = 0,
181 To = 1,
182 Opacity = 2,
183 ColumnCount = Opacity + 1
184 };
185
187 void populateTransparencyTable( QgsRasterRenderer *renderer );
188
189 void setupTransparencyTable( int nBands );
190
191 void setTransparencyCell( int row, int column, double value );
192
193 void adjustTransparencyCellWidth( int row, int column );
194
195 void setTransparencyToEdited( int row );
196
197 double transparencyCellValue( int row, int column );
198
199 Mode mCurrentMode = Mode::RgbBands;
200
201 QgsRasterLayer *mRasterLayer = nullptr;
202
203 QgsMapCanvas *mMapCanvas = nullptr;
204
205 QgsMapToolEmitPoint *mPixelSelectorTool = nullptr;
206
207 QVector<bool> mTransparencyToEdited;
208
210 QgsSymbolWidgetContext mContext;
211};
212#endif // QGSRASTERTRANSPARENCYWIDGET_H
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.
A panel widget that can be shown in the map style dock.
virtual void apply()=0
Called when changes to the layer need to be made.
virtual void syncToLayer(QgsMapLayer *layer)
Reset to original (vector layer) values.
A map tool that simply emits a point when clicking on the map.
A class to represent a 2D point.
Definition qgspointxy.h:60
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.
Base class for raster data providers.
Represents a raster layer.
Property
Data definable properties.
Raster renderer pipe that applies colors to a raster.
Widget to control a layers transparency and related options.
QgsPropertyCollection mPropertyCollection
Temporary property collection.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
#define SIP_SKIP
Definition qgis_sip.h:126