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; }
102 QString expression()
const {
return mExpression; }
103 void setExpression(
const QString &expression ) { mExpression = expression; }
110 void calculatedHistogram();
113 QPointer<const QgsVectorLayer> mLayer =
nullptr;
117 QMutex mFeedbackMutex;
118 bool mWasCanceled =
false;
161 void setHistogramSource(
const QgsVectorLayer *layer,
const QString &expression );
184 void setMinHistogramValueRange(
double minValueRange );
191 void setMaxHistogramValueRange(
double maxValueRange );
203 void plotMousePress( QPointF point );
204 void plotMouseRelease( QPointF point );
205 void plotMouseMove( QPointF point );
210 QwtPlot *mPlot =
nullptr;
212 QwtPlotCurve *mPlotCurve =
nullptr;
214 QList<QwtPlotMarker *> mMarkers;
215 QgsCurveEditorPlotEventFilter *mPlotFilter =
nullptr;
216 int mCurrentPlotMarkerIndex = -1;
218 std::unique_ptr<QgsHistogramValuesGatherer> mGatherer;
219 std::unique_ptr<QgsHistogram> mHistogram;
220 double mMinValueRange = 0.0;
221 double mMaxValueRange = 1.0;
223 QwtPlotHistogram *mPlotHistogram =
nullptr;
226 void addPlotMarker(
double x,
double y,
bool isSelected =
false );
227 void updateHistogram();
229 int findNearestControlPoint( QPointF point )
const;
231 QwtPlotHistogram *createPlotHistogram(
const QBrush &brush,
const QPen &pen = Qt::NoPen )
const;
241class GUI_EXPORT QgsCurveEditorPlotEventFilter :
public QObject
246 QgsCurveEditorPlotEventFilter( QwtPlot *plot );
248 bool eventFilter( QObject *
object, QEvent *event )
override;
252 void mousePress( QPointF );
253 void mouseRelease( QPointF );
254 void mouseMove( QPointF );
257 QwtPlot *mPlot =
nullptr;
258 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.