18 #ifndef QGSPALETTEDRENDERERWIDGET_H 19 #define QGSPALETTEDRENDERERWIDGET_H 27 #include "ui_qgspalettedrendererwidgetbase.h" 39 class QgsPalettedRendererClassGatherer:
public QThread
46 , mBandNumber( bandNumber )
48 , mClasses( existingClasses )
49 , mWasCanceled( false )
63 QgsPalettedRasterRenderer::ClassData::iterator classIt = newClasses.begin();
64 for ( ; classIt != newClasses.end(); ++classIt )
69 if ( existingClass.
value == classIt->value )
71 classIt->color = existingClass.
color;
72 classIt->label = existingClass.
label;
77 mClasses = newClasses;
80 mFeedbackMutex.lock();
83 mFeedbackMutex.unlock();
85 emit collectedClasses();
92 mFeedbackMutex.lock();
95 mFeedbackMutex.unlock();
101 bool wasCanceled()
const {
return mWasCanceled; }
110 void collectedClasses();
116 void progressChanged(
double progress );
122 std::unique_ptr< QgsColorRamp > mRamp;
126 QMutex mFeedbackMutex;
130 class QgsPalettedRendererModel :
public QAbstractItemModel
143 QgsPalettedRendererModel( QObject *parent =
nullptr );
149 QModelIndex index(
int row,
int column,
const QModelIndex &parent = QModelIndex() )
const override;
150 QModelIndex parent(
const QModelIndex &index )
const override;
151 int columnCount(
const QModelIndex &parent = QModelIndex() )
const override;
152 int rowCount(
const QModelIndex &parent = QModelIndex() )
const override;
153 QVariant data(
const QModelIndex &index,
int role = Qt::DisplayRole )
const override;
154 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
155 bool setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole )
override;
156 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
157 bool removeRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
158 bool insertRows(
int row,
int count,
const QModelIndex &parent = QModelIndex() )
override;
159 Qt::DropActions supportedDropActions()
const override;
160 QStringList mimeTypes()
const override;
161 QMimeData *mimeData(
const QModelIndexList &indexes )
const override;
162 bool dropMimeData(
const QMimeData *data, Qt::DropAction action,
int row,
int column,
const QModelIndex &parent )
override;
164 QModelIndex addEntry(
const QColor &color );
172 void classesChanged();
203 QMenu *mContextMenu =
nullptr;
204 QMenu *mAdvancedMenu =
nullptr;
205 QAction *mLoadFromLayerAction =
nullptr;
206 QgsPalettedRendererModel *mModel =
nullptr;
210 QgsPalettedRendererClassGatherer *mGatherer =
nullptr;
214 void setSelectionColor(
const QItemSelection &selection,
const QColor &color );
221 void changeOpacity();
223 void applyColorRamp();
224 void loadColorTable();
225 void saveColorTable();
227 void loadFromLayer();
228 void bandChanged(
int band );
230 void gatheredClasses();
231 void gathererThreadFinished();
236 #endif // QGSPALETTEDRENDERERWIDGET_H A rectangle specified with double values.
Base class for all map layer types.
QColor color
Color to render value.
QString label
Label for value.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
Abstract base class for color ramps.
Properties of a single value class.
void progressChanged(double progress)
Emitted when the feedback object reports a progress change.
QList< QgsPalettedRasterRenderer::Class > ClassData
Map of value to class properties.
static QgsPalettedRasterRenderer::ClassData classDataFromRaster(QgsRasterInterface *raster, int bandNumber, QgsColorRamp *ramp=nullptr, QgsRasterBlockFeedback *feedback=nullptr)
Generates class data from a raster, for the specified bandNumber.
Feedback object tailored for raster block reading.
Raster renderer pipe that applies colors to a raster.
A delegate for showing a color swatch in a list.