16#ifndef QGSCURVEEDITORWIDGET_H
17#define QGSCURVEEDITORWIDGET_H
30#include <qwt_global.h>
35class QwtPlotHistogram;
37class QgsCurveEditorPlotEventFilter;
52class QgsHistogramValuesGatherer :
public QThread
57 QgsHistogramValuesGatherer() =
default;
62 if ( mExpression.isEmpty() || !mLayer )
64 mHistogram.setValues( QList<double>() );
71 mHistogram.setValues( mLayer, mExpression, mFeedback );
74 mFeedbackMutex.lock();
77 mFeedbackMutex.unlock();
79 emit calculatedHistogram();
86 mFeedbackMutex.lock();
89 mFeedbackMutex.unlock();
95 bool wasCanceled()
const {
return mWasCanceled; }
97 const QgsHistogram &histogram()
const {
return mHistogram; }
108 QString expression()
const
112 void setExpression(
const QString &expression )
114 mExpression = expression;
122 void calculatedHistogram();
125 QPointer<const QgsVectorLayer> mLayer =
nullptr;
129 QMutex mFeedbackMutex;
130 bool mWasCanceled =
false;
173 void setHistogramSource(
const QgsVectorLayer *layer,
const QString &expression );
196 void setMinHistogramValueRange(
double minValueRange );
203 void setMaxHistogramValueRange(
double maxValueRange );
215 void plotMousePress( QPointF point );
216 void plotMouseRelease( QPointF point );
217 void plotMouseMove( QPointF point );
222 QwtPlot *mPlot =
nullptr;
224 QwtPlotCurve *mPlotCurve =
nullptr;
226 QList<QwtPlotMarker *> mMarkers;
227 QgsCurveEditorPlotEventFilter *mPlotFilter =
nullptr;
228 int mCurrentPlotMarkerIndex = -1;
230 std::unique_ptr<QgsHistogramValuesGatherer> mGatherer;
231 std::unique_ptr<QgsHistogram> mHistogram;
232 double mMinValueRange = 0.0;
233 double mMaxValueRange = 1.0;
235 QwtPlotHistogram *mPlotHistogram =
nullptr;
238 void addPlotMarker(
double x,
double y,
bool isSelected =
false );
239 void updateHistogram();
241 int findNearestControlPoint( QPointF point )
const;
243 QwtPlotHistogram *createPlotHistogram(
const QBrush &brush,
const QPen &pen = Qt::NoPen )
const;
253class GUI_EXPORT QgsCurveEditorPlotEventFilter :
public QObject
258 QgsCurveEditorPlotEventFilter( QwtPlot *plot );
260 bool eventFilter( QObject *
object, QEvent *event )
override;
264 void mousePress( QPointF );
265 void mouseRelease( QPointF );
266 void mouseMove( QPointF );
269 QwtPlot *mPlot =
nullptr;
270 QPointF mapPoint( QPointF point )
const;
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Calculator for a numeric histogram from a list of values.
Represents a vector layer which manages a vector based dataset.