QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
24 #include "qgssymbolwidgetcontext.h"
25 
26 #include "qgis_gui.h"
27 
28 class QgsRasterLayer;
29 class QgsRasterRenderer;
30 class QgsMapCanvas;
32 class QgsPointXY;
33 
38 class 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 
62  public slots:
63 
64 #ifdef __clang__
65 #pragma clang diagnostic push
66 #pragma clang diagnostic ignored "-Woverloaded-virtual"
67 #endif
68 
72  void syncToLayer();
73 #ifdef __clang__
74 #pragma clang diagnostic pop
75 #endif
76 
80  void apply() override;
81 
82  protected:
83 
84 #ifndef SIP_RUN
85 
86  // TODO -- consider moving these to a common raster widget base class
87 
95  void initializeDataDefinedButton( QgsPropertyOverrideButton *button, QgsRasterPipe::Property key );
96 
102  void updateDataDefinedButtons();
103 
109  void updateDataDefinedButton( QgsPropertyOverrideButton *button );
110 
113 
114 #endif
115 
116  private slots:
117 
118  void updateProperty();
119 
120  void pixelSelected( const QgsPointXY &canvasPoint );
121 
123  void transparencyCellTextEdited( const QString &text );
124 
126  void pbnAddValuesFromDisplay_clicked();
127 
129  void pbnAddValuesManually_clicked();
130 
132  void pbnDefaultValues_clicked();
133 
135  void pbnExportTransparentPixelValues_clicked();
136 
138  void pbnImportTransparentPixelValues_clicked();
140  void pbnRemoveSelectedRow_clicked();
141 
142  private:
144  const QString TRSTRING_NOT_SET;
145 
146  bool rasterIsMultiBandColor();
147 
149  void populateTransparencyTable( QgsRasterRenderer *renderer );
150 
151  void setupTransparencyTable( int nBands );
152 
153  void setTransparencyCell( int row, int column, double value );
154 
155  void adjustTransparencyCellWidth( int row, int column );
156 
157  void setTransparencyToEdited( int row );
158 
159  double transparencyCellValue( int row, int column );
160 
161  QgsRasterLayer *mRasterLayer = nullptr;
162 
163  QgsMapCanvas *mMapCanvas = nullptr;
164 
165  QgsMapToolEmitPoint *mPixelSelectorTool = nullptr;
166 
167  QVector<bool> mTransparencyToEdited;
168 
170  QgsSymbolWidgetContext mContext;
171 };
172 #endif // QGSRASTERTRANSPARENCYWIDGET_H
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
qgsrasterpipe.h
QgsSymbolWidgetContext
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
Definition: qgssymbolwidgetcontext.h:35
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:89
QgsMapLayerConfigWidget::apply
virtual void apply()=0
Called when changes to the layer need to be made.
qgssymbolwidgetcontext.h
QgsMapLayerConfigWidget
A panel widget that can be shown in the map style dock.
Definition: qgsmaplayerconfigwidget.h:115
QgsPropertyOverrideButton
A button for controlling property overrides which may apply to a widget.
Definition: qgspropertyoverridebutton.h:50
QgsRasterRenderer
Raster renderer pipe that applies colors to a raster.
Definition: qgsrasterrenderer.h:40
QgsExpressionContextGenerator::createExpressionContext
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsRasterLayer
Represents a raster layer.
Definition: qgsrasterlayer.h:76
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsMapToolEmitPoint
A map tool that simply emits a point when clicking on the map. Connecting a slot to its canvasClicked...
Definition: qgsmaptoolemitpoint.h:30
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsRasterTransparencyWidget::mPropertyCollection
QgsPropertyCollection mPropertyCollection
Temporary property collection.
Definition: qgsrastertransparencywidget.h:112
qgsmaplayerconfigwidget.h
QgsMapLayerConfigWidget::syncToLayer
virtual void syncToLayer(QgsMapLayer *layer)
Reset to original (vector layer) values.
Definition: qgsmaplayerconfigwidget.h:142
QgsRasterPipe::Property
Property
Data definable properties.
Definition: qgsrasterpipe.h:57
QgsExpressionContextGenerator
Abstract interface for generating an expression context.
Definition: qgsexpressioncontextgenerator.h:36