OpenCPN Partial API docs
Loading...
Searching...
No Matches
dial.h
1/******************************************************************************
2 * $Id: dial.h, v1.0 2010/08/05 SethDart Exp $
3 *
4 * Project: OpenCPN
5 * Purpose: Dashboard Plugin
6 * Author: Jean-Eudes Onfray
7 * (Inspired by original work from Andreas Heiming)
8 *
9 ***************************************************************************
10 * Copyright (C) 2010 by David S. Register *
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
16 * *
17 * This program is distributed in the hope that it will be useful, *
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20 * GNU General Public License for more details. *
21 * *
22 * You should have received a copy of the GNU General Public License *
23 * along with this program; if not, write to the *
24 * Free Software Foundation, Inc., *
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
26 ***************************************************************************
27 */
28
29#ifndef __Dial_H__
30#define __Dial_H__
31
32// For compilers that support precompilation, includes "wx/wx.h".
33#include <wx/wxprec.h>
34
35#ifdef __BORLANDC__
36#pragma hdrstop
37#endif
38
39// for all others, include the necessary headers (this file is usually all you
40// need because it includes almost all "standard" wxWidgets headers)
41#ifndef WX_PRECOMP
42#include <wx/wx.h>
43#endif
44
45#include "instrument.h"
46
47#define ANGLE_OFFSET 90 // 0 degrees are at 12 o clock
48
49typedef enum {
50 DIAL_LABEL_NONE,
51 DIAL_LABEL_HORIZONTAL,
52 DIAL_LABEL_ROTATED
53} DialLabelOption;
54
55typedef enum {
56 DIAL_MARKER_NONE,
57 DIAL_MARKER_SIMPLE,
58 DIAL_MARKER_REDGREEN,
59 DIAL_MARKER_REDGREENBAR
60} DialMarkerOption;
61
62typedef enum {
63 DIAL_POSITION_NONE,
64 DIAL_POSITION_INSIDE,
65 DIAL_POSITION_TOPLEFT,
66 DIAL_POSITION_TOPRIGHT,
67 DIAL_POSITION_BOTTOMLEFT,
68 DIAL_POSITION_BOTTOMRIGHT,
69 DIAL_POSITION_BOTTOMMIDDLE
70} DialPositionOption;
71
72extern double rad2deg(double angle);
73extern double deg2rad(double angle);
74
75//+------------------------------------------------------------------------------
76//|
77//| CLASS:
78//| DashboardInstrument_Dial
79//|
80//| DESCRIPTION:
81//| This class creates a speedometer style control
82//|
83//+------------------------------------------------------------------------------
85public:
86 DashboardInstrument_Dial(wxWindow* parent, wxWindowID id, wxString title,
87 InstrumentProperties* Properties, DASH_CAP cap_flag,
88 int s_angle, int r_angle, int s_value, int e_value);
89
91
92 wxSize GetSize(int orient, wxSize hint);
93 void SetData(DASH_CAP, double, wxString);
94 void SetOptionMarker(double step, DialMarkerOption option, int offset) {
95 m_MarkerStep = step;
96 m_MarkerOption = option;
97 m_MarkerOffset = offset;
98 }
99 void SetOptionLabel(double step, DialLabelOption option,
100 wxArrayString labels = wxArrayString()) {
101 m_LabelStep = step;
102 m_LabelOption = option;
103 m_LabelArray = labels;
104 }
105 void SetOptionMainValue(wxString format, DialPositionOption option) {
106 m_MainValueFormat = format;
107 m_MainValueOption = option;
108 }
109 void SetOptionExtraValue(DASH_CAP cap, wxString format,
110 DialPositionOption option) {
111 m_ExtraValueCap = cap;
112 m_cap_flag.set(cap);
113 m_ExtraValueFormat = format;
114 m_ExtraValueOption = option;
115 }
116
117private:
118protected:
119 int m_cx, m_cy, m_radius;
120 int m_AngleStart, m_AngleRange;
121 bool m_gpsWD;
122 double m_MainValue;
123 DASH_CAP m_MainValueCap;
124 double m_MainValueMin, m_MainValueMax;
125 wxString m_MainValueFormat;
126 wxString m_MainValueUnit;
127 DialPositionOption m_MainValueOption;
128 double m_ExtraValue;
129 DASH_CAP m_ExtraValueCap;
130 wxString m_ExtraValueFormat;
131 wxString m_ExtraValueUnit;
132 DialPositionOption m_ExtraValueOption;
133 DialMarkerOption m_MarkerOption;
134 int m_MarkerOffset;
135 double m_MarkerStep, m_LabelStep;
136 DialLabelOption m_LabelOption;
137 wxArrayString m_LabelArray;
138
139 virtual void Draw(wxGCDC* dc);
140 virtual void DrawFrame(wxGCDC* dc);
141 virtual void DrawMarkers(wxGCDC* dc);
142 virtual void DrawLabels(wxGCDC* dc);
143 virtual void DrawBackground(wxGCDC* dc);
144 virtual void DrawData(wxGCDC* dc, double value, wxString unit,
145 wxString format, DialPositionOption position);
146 virtual void DrawForeground(wxGCDC* dc);
147};
148
149/* Shared functions */
150void DrawCompassRose(wxGCDC* dc, int cx, int cy, int radius, int startangle,
151 bool showlabels, InstrumentProperties* Properties);
152void DrawBoat(wxGCDC* dc, int cx, int cy, int radius);
153
154#endif // __Dial_H__