root / ezdop / src / host / hunter / src / histogram.h @ 676acd5c
History | View | Annotate | Download (2.3 kB)
| 1 | /*
|
|---|---|
| 2 | Copyright 2006 Johnathan Corgan. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or modify |
| 5 | it under the terms of the GNU General Public License version 2 |
| 6 | as published by the Free Software Foundation. |
| 7 | |
| 8 | This software is distributed in the hope that it will be useful, |
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | GNU General Public License for more details. |
| 12 | |
| 13 | You should have received a copy of the GNU General Public License |
| 14 | along with GNU Radio; see the file COPYING. If not, write to |
| 15 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | Boston, MA 02111-1307, USA. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __HISTOGRAM_H__
|
| 20 | #define __HISTOGRAM_H__
|
| 21 | |
| 22 | // Application level includes
|
| 23 | #include "sample.h" |
| 24 | |
| 25 | // wxWidgets includes
|
| 26 | #include <wx/panel.h> |
| 27 | |
| 28 | // System level includes
|
| 29 | #include <vector> |
| 30 | |
| 31 | class ErrorHistogram |
| 32 | {
|
| 33 | public:
|
| 34 | ErrorHistogram(); |
| 35 | |
| 36 | void Reset();
|
| 37 | void Calc(const std::vector<Sample> &samples, const Spherical &location); |
| 38 | void Add(float angle, float magnitude, float ierror, float qerror); // analytic errors are -pi to pi |
| 39 | void Normalize();
|
| 40 | |
| 41 | int Count() const { return m_count; } |
| 42 | int Mode() const { return m_mode; } |
| 43 | float ModalFrequency() const { return m_modal_frequency; } |
| 44 | float Mean() const { return m_mean; } |
| 45 | float Concentration() const { return m_conc; } |
| 46 | const std::vector<float> &Data() const { return m_bins; } |
| 47 | |
| 48 | private:
|
| 49 | int m_mode;
|
| 50 | float m_modal_frequency;
|
| 51 | float m_isum;
|
| 52 | float m_qsum;
|
| 53 | float m_msum;
|
| 54 | float m_conc;
|
| 55 | float m_mean;
|
| 56 | int m_count;
|
| 57 | std::vector<float> m_bins;
|
| 58 | }; |
| 59 | |
| 60 | class HistogramPanel : public wxPanel |
| 61 | {
|
| 62 | public:
|
| 63 | enum Mode { Rectangular, Polar };
|
| 64 | |
| 65 | HistogramPanel(wxWindow *parent); |
| 66 | void SetData(const ErrorHistogram &histogram); |
| 67 | void SetMode(Mode mode) { m_mode = mode; Refresh(); }
|
| 68 | |
| 69 | // Event handlers
|
| 70 | void OnPaint(wxPaintEvent &event);
|
| 71 | void OnSize(wxSizeEvent &event);
|
| 72 | |
| 73 | private:
|
| 74 | void draw_panel(wxDC &dc);
|
| 75 | ErrorHistogram m_histogram; |
| 76 | |
| 77 | // State
|
| 78 | Mode m_mode; |
| 79 | |
| 80 | // Window size derived parameters
|
| 81 | wxPoint m_center; |
| 82 | int m_width;
|
| 83 | int m_height;
|
| 84 | int m_extent;
|
| 85 | |
| 86 | DECLARE_EVENT_TABLE(); |
| 87 | }; |
| 88 | |
| 89 | #endif
|