OpenCPN Partial API docs
Loading...
Searching...
No Matches
dial.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 by Jean-Eudes Onfray *
3 * Copyright (C) 2010 by David S. Register *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
27#ifndef Dial_H_
28#define Dial_H_
29
30// For compilers that support precompilation, includes "wx/wx.h".
31#include <wx/wxprec.h>
32
33// for all others, include the necessary headers (this file is usually all you
34// need because it includes almost all "standard" wxWidgets headers)
35#ifndef WX_PRECOMP
36#include <wx/wx.h>
37#endif
38
39#include "instrument.h"
40
41#define ANGLE_OFFSET 90 // 0 degrees are at 12 o clock
42
43typedef enum {
44 DIAL_LABEL_NONE,
45 DIAL_LABEL_HORIZONTAL,
46 DIAL_LABEL_ROTATED
47} DialLabelOption;
48
49typedef enum {
50 DIAL_MARKER_NONE,
51 DIAL_MARKER_SIMPLE,
52 DIAL_MARKER_REDGREEN,
53 DIAL_MARKER_REDGREENBAR
54} DialMarkerOption;
55
56typedef enum {
57 DIAL_POSITION_NONE,
58 DIAL_POSITION_INSIDE,
59 DIAL_POSITION_TOPLEFT,
60 DIAL_POSITION_TOPRIGHT,
61 DIAL_POSITION_BOTTOMLEFT,
62 DIAL_POSITION_BOTTOMRIGHT,
63 DIAL_POSITION_BOTTOMMIDDLE
64} DialPositionOption;
65
66extern double rad2deg(double angle);
67extern double deg2rad(double angle);
68
69//+------------------------------------------------------------------------------
70//|
71//| CLASS:
72//| DashboardInstrument_Dial
73//|
74//| DESCRIPTION:
75//| This class creates a speedometer style control
76//|
77//+------------------------------------------------------------------------------
79public:
80 DashboardInstrument_Dial(wxWindow* parent, wxWindowID id, wxString title,
81 InstrumentProperties* Properties, DASH_CAP cap_flag,
82 int s_angle, int r_angle, int s_value, int e_value);
83
84 ~DashboardInstrument_Dial() override = default;
85
86 wxSize GetSize(int orient, wxSize hint) override;
87 void SetData(DASH_CAP, double, wxString) override;
88 void SetOptionMarker(double step, DialMarkerOption option, int offset) {
89 m_marker_step = step;
90 m_marker_option = option;
91 m_marker_offset = offset;
92 }
93 void SetOptionLabel(double step, DialLabelOption option,
94 wxArrayString labels = wxArrayString()) {
95 m_label_step = step;
96 m_label_option = option;
97 m_label_array = labels;
98 }
99 void SetOptionMainValue(wxString format, DialPositionOption option) {
100 m_main_value_format = format;
101 m_main_value_option = option;
102 }
103 void SetOptionExtraValue(DASH_CAP cap, wxString format,
104 DialPositionOption option) {
105 m_extra_value_cap = cap;
106 m_cap_flag.set(cap);
107 m_extra_value_format = format;
108 m_extra_value_option = option;
109 }
110
111private:
112protected:
113 int m_cx, m_cy, m_radius;
114 int m_angle_start, m_angle_range;
115 bool m_gps_wd;
116 double m_main_value;
117 DASH_CAP m_main_value_cap;
118 double m_main_value_min, m_main_value_max;
119 wxString m_main_value_format;
120 wxString m_main_value_unit;
121 DialPositionOption m_main_value_option;
122 double m_extra_value;
123 DASH_CAP m_extra_value_cap;
124 wxString m_extra_value_format;
125 wxString m_extra_value_unit;
126 DialPositionOption m_extra_value_option;
127 DialMarkerOption m_marker_option;
128 int m_marker_offset;
129 double m_marker_step, m_label_step;
130 DialLabelOption m_label_option;
131 wxArrayString m_label_array;
132
133 void Draw(wxGCDC* dc) override;
134 virtual void DrawFrame(wxGCDC* dc);
135 virtual void DrawMarkers(wxGCDC* dc);
136 virtual void DrawLabels(wxGCDC* dc);
137 virtual void DrawBackground(wxGCDC* dc);
138 virtual void DrawData(wxGCDC* dc, double value, wxString unit,
139 wxString format, DialPositionOption position);
140 virtual void DrawForeground(wxGCDC* dc);
141};
142
143/* Shared functions */
144void DrawCompassRose(wxGCDC* dc, int cx, int cy, int radius, int startangle,
145 bool showlabels, InstrumentProperties* Properties);
146void DrawBoat(wxGCDC* dc, int cx, int cy, int radius);
147
148#endif // Dial_H_
Dashboard instrument base class.
DASH_CAP
Definition instrument.h:77