QGIS API Documentation 3.99.0-Master (752b475928d)
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 "ui_qgsrastertransparencywidget.h"
19
20#include "qgis_gui.h"
22#include "qgsrasterpipe.h"
24
25#include <QWidget>
26
27class QgsRasterLayer;
29class QgsMapCanvas;
31class QgsPointXY;
32
37class GUI_EXPORT QgsRasterTransparencyWidget : public QgsMapLayerConfigWidget, private QgsExpressionContextGenerator, public Ui::QgsRasterTransparencyWidget
38{
39 Q_OBJECT
40 public:
44 QgsRasterTransparencyWidget( QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent = nullptr );
45
50 void setContext( const QgsSymbolWidgetContext &context );
51
53
59
68
77
78 public slots:
79
80#ifdef __clang__
81#pragma clang diagnostic push
82#pragma clang diagnostic ignored "-Woverloaded-virtual"
83#endif
84
88 void syncToLayer();
89#ifdef __clang__
90#pragma clang diagnostic pop
91#endif
92
96 void apply() override;
97
98 protected:
99#ifndef SIP_RUN
100
101 // TODO -- consider moving these to a common raster widget base class
102
111
118
125
128
129#endif
130
131 private slots:
132
133 void updateProperty();
134
135 void pixelSelected( const QgsPointXY &canvasPoint );
136
138 void transparencyCellTextEdited( const QString &text );
139
141 void pbnAddValuesFromDisplay_clicked();
142
144 void pbnAddValuesManually_clicked();
145
147 void pbnDefaultValues_clicked();
148
150 void pbnExportTransparentPixelValues_clicked();
151
153 void pbnImportTransparentPixelValues_clicked();
155 void pbnRemoveSelectedRow_clicked();
156
157 private:
159 const QString TRSTRING_NOT_SET;
160
161 enum class Mode : int
162 {
163 SingleBand = 0,
164 RgbBands
165 };
166
167 enum class RgbBandTableColumns : int
168 {
169 Red = 0,
170 Green = 1,
171 Blue = 2,
172 Tolerance = 3,
173 Opacity = 4,
174 ColumnCount = Opacity + 1
175 };
176
177 enum class SingleBandTableColumns : int
178 {
179 From = 0,
180 To = 1,
181 Opacity = 2,
182 ColumnCount = Opacity + 1
183 };
184
186 void populateTransparencyTable( QgsRasterRenderer *renderer );
187
188 void setupTransparencyTable( int nBands );
189
190 void setTransparencyCell( int row, int column, double value );
191
192 void adjustTransparencyCellWidth( int row, int column );
193
194 void setTransparencyToEdited( int row );
195
196 double transparencyCellValue( int row, int column );
197
198 Mode mCurrentMode = Mode::RgbBands;
199
200 QgsRasterLayer *mRasterLayer = nullptr;
201
202 QgsMapCanvas *mMapCanvas = nullptr;
203
204 QgsMapToolEmitPoint *mPixelSelectorTool = nullptr;
205
206 QVector<bool> mTransparencyToEdited;
207
209 QgsSymbolWidgetContext mContext;
210};
211#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.
QgsMapLayerConfigWidget(QgsMapLayer *layer, QgsMapCanvas *canvas, QWidget *parent=nullptr)
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.
Represents a 2D point.
Definition qgspointxy.h:60
A grouped map of multiple QgsProperty objects, each referenced by an 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.
void updateDataDefinedButtons()
Updates all property override buttons to reflect the widgets's current properties.
QgsPropertyCollection mPropertyCollection
Temporary property collection.
void applyToRasterRenderer(QgsRasterRenderer *renderer) SIP_SKIP
Applies widget settings to a raster renderer.
QgsMapToolEmitPoint * pixelSelectorTool() const
Returns the (possibly nullptr) map pixel selector tool.
void initializeDataDefinedButton(QgsPropertyOverrideButton *button, QgsRasterPipe::Property key)
Registers a property override button, setting up its initial value, connections and description.
QgsRasterTransparencyWidget(QgsRasterLayer *layer, QgsMapCanvas *canvas, QWidget *parent=nullptr)
Widget to control a layers transparency and related options.
void updateDataDefinedButton(QgsPropertyOverrideButton *button)
Updates a specific property override button to reflect the widgets's current properties.
void setContext(const QgsSymbolWidgetContext &context)
Sets the context in which the dialog is shown, e.g., the associated map canvas and expression context...
void applyToRasterProvider(QgsRasterDataProvider *provider) SIP_SKIP
Applies widget settings to a raster provider.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
#define SIP_SKIP
Definition qgis_sip.h:134