QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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:
42
46 QgsRasterTransparencyWidget( QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr );
47
52 void setContext( const QgsSymbolWidgetContext &context );
53
55
60 QgsMapToolEmitPoint *pixelSelectorTool() const;
61
69 void applyToRasterProvider( QgsRasterDataProvider *provider ) SIP_SKIP;
70
78 void applyToRasterRenderer( QgsRasterRenderer *renderer ) SIP_SKIP;
79
80 public slots:
81
82#ifdef __clang__
83#pragma clang diagnostic push
84#pragma clang diagnostic ignored "-Woverloaded-virtual"
85#endif
86
90 void syncToLayer();
91#ifdef __clang__
92#pragma clang diagnostic pop
93#endif
94
98 void apply() override;
99
100 protected:
101
102#ifndef SIP_RUN
103
104 // TODO -- consider moving these to a common raster widget base class
105
113 void initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsRasterPipe::Property key );
114
120 void updateDataDefinedButtons();
121
127 void updateDataDefinedButton( QgsPropertyOverrideButton *button );
128
131
132#endif
133
134 private slots:
135
136 void updateProperty();
137
138 void pixelSelected( const QgsPointXY &canvasPoint );
139
141 void transparencyCellTextEdited( const QString &text );
142
144 void pbnAddValuesFromDisplay_clicked();
145
147 void pbnAddValuesManually_clicked();
148
150 void pbnDefaultValues_clicked();
151
153 void pbnExportTransparentPixelValues_clicked();
154
156 void pbnImportTransparentPixelValues_clicked();
158 void pbnRemoveSelectedRow_clicked();
159
160 private:
162 const QString TRSTRING_NOT_SET;
163
164 enum class Mode : int
165 {
166 SingleBand = 0,
167 RgbBands
168 };
169
170 enum class RgbBandTableColumns : int
171 {
172 Red = 0,
173 Green = 1,
174 Blue = 2,
175 Tolerance = 3,
176 Opacity = 4,
177 ColumnCount = Opacity + 1
178 };
179
180 enum class SingleBandTableColumns : int
181 {
182 From = 0,
183 To = 1,
184 Opacity = 2,
185 ColumnCount = Opacity + 1
186 };
187
189 void populateTransparencyTable( QgsRasterRenderer *renderer );
190
191 void setupTransparencyTable( int nBands );
192
193 void setTransparencyCell( int row, int column, double value );
194
195 void adjustTransparencyCellWidth( int row, int column );
196
197 void setTransparencyToEdited( int row );
198
199 double transparencyCellValue( int row, int column );
200
201 Mode mCurrentMode = Mode::RgbBands;
202
203 QgsRasterLayer *mRasterLayer = nullptr;
204
205 QgsMapCanvas *mMapCanvas = nullptr;
206
207 QgsMapToolEmitPoint *mPixelSelectorTool = nullptr;
208
209 QVector<bool> mTransparencyToEdited;
210
212 QgsSymbolWidgetContext mContext;
213};
214#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