OpenCPN Partial API docs
Loading...
Searching...
No Matches
altitude.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 by Andreas Merz *
3 * Copyright (C) 2010 by Jean-Eudes Onfray *
4 * Copyright (C) 2010 by David S. Register *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
18 **************************************************************************/
19
26#ifndef ALTITUDE_H_
27#define ALTITUDE_H_
28
29// For compilers that support precompilation, includes "wx/wx.h".
30#include <wx/wxprec.h>
31
32// for all others, include the necessary headers (this file is usually all you
33// need because it includes almost all "standard" wxWidgets headers)
34#ifndef WX_PRECOMP
35#include <wx/wx.h>
36#endif
37
38#include "instrument.h"
39
40// Warn: div by 0 if count == 1
41#define ALTITUDE_RECORD_COUNT 30
42
44public:
45 DashboardInstrument_Altitude(wxWindow* parent, wxWindowID id, wxString title,
46 InstrumentProperties* Properties);
47
48 ~DashboardInstrument_Altitude() override = default;
49
50 wxSize GetSize(int orient, wxSize hint) override;
51 void SetData(DASH_CAP, double, wxString) override;
52
53private:
54protected:
55 const int c_grid_lines = 4;
56 double m_array_altitude[ALTITUDE_RECORD_COUNT]; // FIFO
57 double m_min_altitude;
58 double m_max_altitude;
59 double m_range = c_grid_lines; // will change in 1 2 5 steps
60 double m_altitude; // the actual measurement value
61 double m_mean_altitude = 0.0; // moving average
62 double m_sum2_altitude = 0.0; // squared sum moving average
63 int m_cnt_valid = 0; // number of valid FIFO entries
64 int m_attenuation = 1; // 1 2 5
65 int m_decade = 1; // 1 10 100 1000 ..
66 wxString m_altitude_unit;
67 wxString m_temp;
68
69 void Draw(wxGCDC* dc) override;
70 void DrawBackground(wxGCDC* dc);
71 void DrawForeground(wxGCDC* dc);
72
73 // plot scaling utilities
74 void SetAttenuation(int steps);
75 int GetAttenuation() const;
76};
77
78#endif // ALTITUDE_H_
Dashboard instrument base class.
DASH_CAP
Definition instrument.h:77