OpenCPN Partial API docs
Loading...
Searching...
No Matches
compass.cpp
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2010 by David S. Register *
3 * Copyright (C) 2010 by Jean-Eudes Onfray *
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
25#include "compass.h"
26
27#include <wx/wxprec.h>
28
29#ifndef WX_PRECOMP
30#include <wx/wx.h>
31#endif
32
33DashboardInstrument_Compass::DashboardInstrument_Compass(
34 wxWindow* parent, wxWindowID id, wxString title,
35 InstrumentProperties* Properties, DASH_CAP cap_flag)
36 : DashboardInstrument_Dial(parent, id, title, Properties, cap_flag, 0, 360,
37 0, 360) {
38 SetOptionMarker(5, DIAL_MARKER_SIMPLE, 2);
39 SetOptionLabel(20, DIAL_LABEL_ROTATED);
40 SetOptionMainValue("%.0f", DIAL_POSITION_INSIDE);
41}
42
43void DashboardInstrument_Compass::SetData(DASH_CAP st, double data,
44 wxString unit) {
45 m_gps_wd = false;
46 if (std::isnan(data)) m_gps_wd = true;
47
48 if (st == m_main_value_cap) {
49 // Rotate the rose
50 m_angle_start = static_cast<int>(-data);
51 // Required to display data
52 m_main_value = data;
53 m_main_value_unit = unit;
54 } else if (st == m_extra_value_cap) {
55 m_extra_value = data;
56 m_extra_value_unit = unit;
57 }
58 Refresh();
59}
60
61void DashboardInstrument_Compass::DrawBackground(wxGCDC* dc) {
62 DrawBoat(dc, m_cx, m_cy, m_radius);
63 if (!m_gps_wd) // Don't draw if no GPS
64 DrawCompassRose(dc, m_cx, m_cy, static_cast<int>(0.7 * m_radius),
65 m_angle_start, true, m_Properties);
66}
67
68void DashboardInstrument_Compass::DrawForeground(wxGCDC* dc) {
69 // We dont want the default foreground (arrow) drawn
70}
DASH_CAP
Definition instrument.h:77
Dashboard compass instrument.