1 | // created: 2013/06/27
|
---|
2 | // filename: MeanFilter.h
|
---|
3 | //
|
---|
4 | // author: Guillaume Sanahuja
|
---|
5 | // Copyright Heudiasyc UMR UTC/CNRS 7253
|
---|
6 | //
|
---|
7 | // version: $Id: $
|
---|
8 | //
|
---|
9 | // purpose: object computing a mean filter
|
---|
10 | //
|
---|
11 | //
|
---|
12 | /*********************************************************************/
|
---|
13 |
|
---|
14 | #ifndef MEANFILTER_H
|
---|
15 | #define MEANFILTER_H
|
---|
16 |
|
---|
17 | // we fix the max number of elements to compute the mean
|
---|
18 | // this is a simple example, it should be dynamical
|
---|
19 | #define MAX_NUMBER_OF_ELEMENTS 200
|
---|
20 |
|
---|
21 | // necessary include, as IODevice is a base of our class
|
---|
22 | #include <IODevice.h>
|
---|
23 |
|
---|
24 | // forward declaration for other classes
|
---|
25 | namespace flair {
|
---|
26 | namespace core {
|
---|
27 | class Matrix;
|
---|
28 | }
|
---|
29 | namespace gui {
|
---|
30 | class LayoutPosition;
|
---|
31 | class GroupBox;
|
---|
32 | class SpinBox;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | // MeanFilter is a class computing a mean
|
---|
37 | // based on a parametrizable number of elements
|
---|
38 | // it derives on IODevice as it as an input and an output
|
---|
39 | // it is a filter, we extend the namespace
|
---|
40 | namespace flair {
|
---|
41 | namespace filter {
|
---|
42 | class MeanFilter : public core::IODevice {
|
---|
43 |
|
---|
44 | public:
|
---|
45 | /*!
|
---|
46 | * \brief Constructor
|
---|
47 | *
|
---|
48 | * Builds a mean filter. \n
|
---|
49 | * After calling this function, position will be deleted as it is no longer
|
---|
50 | *usefull. \n
|
---|
51 | *
|
---|
52 | * \param parent IODevice to use as parent
|
---|
53 | * \param position where to place settings
|
---|
54 | * \param name name of the object
|
---|
55 | */
|
---|
56 | MeanFilter(const core::IODevice *parent, const gui::LayoutPosition *position,
|
---|
57 | std::string name);
|
---|
58 |
|
---|
59 | /*!
|
---|
60 | * \brief Destructor
|
---|
61 | */
|
---|
62 | ~MeanFilter();
|
---|
63 |
|
---|
64 | /*!
|
---|
65 | * \brief Output matrix
|
---|
66 | *
|
---|
67 | * allows to access output matrix, to get signal value or to put it in a graph.
|
---|
68 | *\n
|
---|
69 | *
|
---|
70 | * \return pointer to the output matrix
|
---|
71 | */
|
---|
72 | core::Matrix *GetMatrix(void) const;
|
---|
73 |
|
---|
74 | /*!
|
---|
75 | * \brief Value
|
---|
76 | *
|
---|
77 | * this method is equivalent to GetMatrix()->Value(0,0)
|
---|
78 | *
|
---|
79 | * \return actual mean value
|
---|
80 | */
|
---|
81 | float GetValue(void) const;
|
---|
82 |
|
---|
83 | private:
|
---|
84 | // UpdateFrom method from base class IODevice
|
---|
85 | void UpdateFrom(const core::io_data *data);
|
---|
86 | gui::GroupBox *groupBox;
|
---|
87 | gui::SpinBox *numberOfElements;
|
---|
88 | core::Matrix *output;
|
---|
89 | float previousValues[MAX_NUMBER_OF_ELEMENTS]; // previous values storage
|
---|
90 | };
|
---|
91 | } // end namespace filter
|
---|
92 | } // end namespace flair
|
---|
93 | #endif // MEANFILTER_H
|
---|