OpenCurves  0.9
plotinstancesampler.h
1 //
2 // author Kazys Stepanas
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef PLOTINSTANCESAMPLER_H_
7 #define PLOTINSTANCESAMPLER_H_
8 
9 #include "plotsconfig.h"
10 
11 #include "qwt_series_data.h"
12 
13 class PlotInstance;
14 
24 class PlotInstanceSampler : public QwtSeriesData<QPointF>
25 {
26 public:
29  PlotInstanceSampler(const PlotInstance *curveData);
30 
32  void setCurve(const PlotInstance *curveData);
33 
36  inline const PlotInstance *curve() const { return _curve; }
37 
40  size_t size() const override;
41 
47  QPointF sample(size_t i) const override;
48 
51  QRectF boundingRect() const override;
52 
55 
58  QRectF calculateBoundingRect(size_t from = 0, size_t to = ~(size_t)(0u)) const;
59 
60 private:
64  double lookupSampleTime(double initialTime, size_t i) const;
65 
66  const PlotInstance *_curve;
67  mutable QRectF _boundingRect;
68  mutable size_t _lastRingHead;
69  mutable size_t _lastRingSize;
70 };
71 
72 #endif // PLOTINSTANCESAMPLER_H_
An adaptor class converting from PlotInstance data to QwtSeriesData.
Definition: plotinstancesampler.h:24
PlotInstanceSampler(const PlotInstance *curveData)
Create a sampler for the give plot.
size_t size() const override
Returns the number of samples in the PlotInstance.
void setCurve(const PlotInstance *curveData)
Sets the curve, replacing the existing curve.
Holds data for a single curve.
Definition: plotinstance.h:43
void invalidateBoundingRect()
Invalidate the bounding rectangle, to be recalculated.
QRectF boundingRect() const override
Overridden to recalculate the as required bounds.
QPointF sample(size_t i) const override
Samples the ith element of the plot.
QRectF calculateBoundingRect(size_t from=0, size_t to=~(size_t)(0u)) const
Calculate the bounds.
const PlotInstance * curve() const
Access the curve to sample.
Definition: plotinstancesampler.h:36