OpenCPN Partial API docs
Loading...
Searching...
No Matches
compass.cpp
1/******************************************************************************
2 * $Id: compass.cpp, 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#include "compass.h"
30
31// For compilers that support precompilation, includes "wx/wx.h".
32#include <wx/wxprec.h>
33
34#ifdef __BORLANDC__
35#pragma hdrstop
36#endif
37
38// for all others, include the necessary headers (this file is usually all you
39// need because it includes almost all "standard" wxWidgets headers)
40#ifndef WX_PRECOMP
41#include <wx/wx.h>
42#endif
43
44DashboardInstrument_Compass::DashboardInstrument_Compass(
45 wxWindow* parent, wxWindowID id, wxString title,
46 InstrumentProperties* Properties, DASH_CAP cap_flag)
47 : DashboardInstrument_Dial(parent, id, title, Properties, cap_flag, 0, 360,
48 0, 360) {
49 SetOptionMarker(5, DIAL_MARKER_SIMPLE, 2);
50 SetOptionLabel(20, DIAL_LABEL_ROTATED);
51 SetOptionMainValue(_T("%.0f"), DIAL_POSITION_INSIDE);
52}
53
54void DashboardInstrument_Compass::SetData(DASH_CAP st, double data,
55 wxString unit) {
56 double cdata = data;
57 m_gpsWD = false;
58 if (std::isnan(data)) m_gpsWD = true;
59
60 if (st == m_MainValueCap) {
61 // Rotate the rose
62 m_AngleStart = -data;
63 // Required to display data
64 m_MainValue = data;
65 m_MainValueUnit = unit;
66 } else if (st == m_ExtraValueCap) {
67 m_ExtraValue = data;
68 m_ExtraValueUnit = unit;
69 }
70 Refresh();
71}
72
73void DashboardInstrument_Compass::DrawBackground(wxGCDC* dc) {
74 DrawBoat(dc, m_cx, m_cy, m_radius);
75 if (!m_gpsWD) // Don't draw if no GPS
76 DrawCompassRose(dc, m_cx, m_cy, 0.7 * m_radius, m_AngleStart, true,
77 m_Properties);
78}
79
80void DashboardInstrument_Compass::DrawForeground(wxGCDC* dc) {
81 // We dont want the default foreground (arrow) drawn
82}