OpenCurves  0.9
functionmavg.h
1 //
2 // author
3 //
4 // Copyright (c) CSIRO 2015
5 //
6 #ifndef FUNCTIONMAVG_H_
7 #define FUNCTIONMAVG_H_
8 
9 #include "plotsconfig.h"
10 
11 #include "functiondefinition.h"
12 
13 #include <QList>
14 #include <QPointF>
15 
22 {
23 public:
26  FunctionMAvg(const QString &category = QString());
27 
29  void evaluate(PlotFunctionResult &result, double time, unsigned int argc, const double *argv, const PlotFunctionInfo &info, void *context) const override;
30 
32  void *createContext() const override;
33 
35  void destroyContext(void *context) const override;
36 
37 private:
39  struct Context
40  {
41  QList<QPointF> window;
42  double total;
43  };
44 
51  static double addWindowAndAverage(double time, double value, double windowSizeValue, Context &context);
52 };
53 
54 #endif // FUNCTIONMAVG_H_
const QString & category() const
Access the function categorisation for UI grouping.
Definition: functiondefinition.h:57
void * createContext() const override
Creates the history object.
Plot sampling progress information for PlotFunction.
Definition: plotfunctioninfo.h:16
unsigned argc() const
Access the minimum argument count.
Definition: functiondefinition.h:93
FunctionMAvg(const QString &category=QString())
Constructor.
void evaluate(PlotFunctionResult &result, double time, unsigned int argc, const double *argv, const PlotFunctionInfo &info, void *context) const override
Updates the window and evaluates the average on that window.
Result value from a PlotFunction.
Definition: plotfunctionresult.h:27
void destroyContext(void *context) const override
Destroys the history object.
Defines a function which can be used with the FunctionRegister.
Definition: functiondefinition.h:34
A function which evaluates a moving average.
Definition: functionmavg.h:21