16#ifndef QGSCURVEEDITORWIDGET_H
17#define QGSCURVEEDITORWIDGET_H
25#include <qwt_global.h>
34class QwtPlotHistogram;
36class QgsCurveEditorPlotEventFilter;
51class QgsHistogramValuesGatherer :
public QThread
56 QgsHistogramValuesGatherer() =
default;
61 if ( mExpression.isEmpty() || !mLayer )
63 mHistogram.setValues( QList<double>() );
70 mHistogram.setValues( mLayer, mExpression, mFeedback );
73 mFeedbackMutex.lock();
76 mFeedbackMutex.unlock();
78 emit calculatedHistogram();
85 mFeedbackMutex.lock();
88 mFeedbackMutex.unlock();
94 bool wasCanceled()
const {
return mWasCanceled; }
96 const QgsHistogram &histogram()
const {
return mHistogram; }
107 QString expression()
const
111 void setExpression(
const QString &expression )
113 mExpression = expression;
121 void calculatedHistogram();
124 QPointer<const QgsVectorLayer> mLayer =
nullptr;
128 QMutex mFeedbackMutex;
129 bool mWasCanceled =
false;
172 void setHistogramSource(
const QgsVectorLayer *layer,
const QString &expression );
195 void setMinHistogramValueRange(
double minValueRange );
202 void setMaxHistogramValueRange(
double maxValueRange );
210 void keyPressEvent( QKeyEvent *event )
override;
214 void plotMousePress( QPointF point );
215 void plotMouseRelease( QPointF point );
216 void plotMouseMove( QPointF point );
221 QwtPlot *mPlot =
nullptr;
223 QwtPlotCurve *mPlotCurve =
nullptr;
225 QList<QwtPlotMarker *> mMarkers;
226 QgsCurveEditorPlotEventFilter *mPlotFilter =
nullptr;
227 int mCurrentPlotMarkerIndex = -1;
229 std::unique_ptr<QgsHistogramValuesGatherer> mGatherer;
230 std::unique_ptr<QgsHistogram> mHistogram;
231 double mMinValueRange = 0.0;
232 double mMaxValueRange = 1.0;
234 QwtPlotHistogram *mPlotHistogram =
nullptr;
237 void addPlotMarker(
double x,
double y,
bool isSelected =
false );
238 void updateHistogram();
240 int findNearestControlPoint( QPointF point )
const;
242 QwtPlotHistogram *createPlotHistogram(
const QBrush &brush,
const QPen &pen = Qt::NoPen )
const;
252class GUI_EXPORT QgsCurveEditorPlotEventFilter :
public QObject
257 QgsCurveEditorPlotEventFilter( QwtPlot *plot );
259 bool eventFilter( QObject *
object, QEvent *event )
override;
263 void mousePress( QPointF );
264 void mouseRelease( QPointF );
265 void mouseMove( QPointF );
268 QwtPlot *mPlot =
nullptr;
269 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 data sets.