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;
174 void setHistogramSource(
const QgsVectorLayer *layer,
const QString &expression );
197 void setMinHistogramValueRange(
double minValueRange );
204 void setMaxHistogramValueRange(
double maxValueRange );
216 void plotMousePress( QPointF point );
217 void plotMouseRelease( QPointF point );
218 void plotMouseMove( QPointF point );
223 QwtPlot *mPlot =
nullptr;
225 QwtPlotCurve *mPlotCurve =
nullptr;
227 QList<QwtPlotMarker *> mMarkers;
228 QgsCurveEditorPlotEventFilter *mPlotFilter =
nullptr;
229 int mCurrentPlotMarkerIndex = -1;
231 std::unique_ptr<QgsHistogramValuesGatherer> mGatherer;
232 std::unique_ptr<QgsHistogram> mHistogram;
233 double mMinValueRange = 0.0;
234 double mMaxValueRange = 1.0;
236 QwtPlotHistogram *mPlotHistogram =
nullptr;
239 void addPlotMarker(
double x,
double y,
bool isSelected =
false );
240 void updateHistogram();
242 int findNearestControlPoint( QPointF point )
const;
244 QwtPlotHistogram *createPlotHistogram(
const QBrush &brush,
const QPen &pen = Qt::NoPen )
const;
254class GUI_EXPORT QgsCurveEditorPlotEventFilter :
public QObject
259 QgsCurveEditorPlotEventFilter( QwtPlot *plot );
261 bool eventFilter( QObject *
object, QEvent *event )
override;
265 void mousePress( QPointF );
266 void mouseRelease( QPointF );
267 void mouseMove( QPointF );
270 QwtPlot *mPlot =
nullptr;
271 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.