OpenCPN Partial API docs
Loading...
Searching...
No Matches
clock.h
Go to the documentation of this file.
1
/**************************************************************************
2
* Copyright (C) 2010 by Pavel Kalian *
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
25
#ifndef CLOCK_H_
26
#define CLOCK_H_
27
28
// For compilers that support precompilation, includes "wx/wx.h".
29
#include <wx/wxprec.h>
30
31
// for all others, include the necessary headers (this file is usually all you
32
// need because it includes almost all "standard" wxWidgets headers)
33
#ifndef WX_PRECOMP
34
#include <wx/wx.h>
35
#endif
36
37
#include "
instrument.h
"
38
39
extern
int
g_iUTCOffset;
// get offset from dashboard_pi.cpp
40
48
class
DashboardInstrument_Clock
:
public
DashboardInstrument_Single
{
49
public
:
50
DashboardInstrument_Clock
(wxWindow *parent, wxWindowID
id
, wxString title,
51
InstrumentProperties
*Properties,
52
DASH_CAP
cap_flag =
OCPN_DBP_STC_CLK
,
53
wxString format =
"%02i:%02i:%02i UTC"
);
54
55
~DashboardInstrument_Clock
()
override
=
default
;
56
57
void
SetData(
DASH_CAP
,
double
, wxString)
override
;
58
virtual
void
SetUtcTime(wxDateTime value);
59
wxString GetDisplayTime(wxDateTime UTCtime);
60
[[nodiscard]]
bool
GetUtc()
const
{
return
bUTC; }
61
void
SetUtc(
bool
flag) { bUTC = flag; }
62
InstrumentProperties
*m_Properties;
63
64
private
:
65
bool
bUTC;
66
};
67
76
class
DashboardInstrument_Moon
:
public
DashboardInstrument_Clock
{
77
public
:
78
DashboardInstrument_Moon
(wxWindow *parent, wxWindowID
id
, wxString title,
79
InstrumentProperties
*Properties);
80
~DashboardInstrument_Moon
()
override
=
default
;
81
82
wxSize GetSize(
int
orient, wxSize hint)
override
;
83
void
SetData(
DASH_CAP
,
double
, wxString)
override
;
84
void
SetUtcTime(wxDateTime value)
override
;
85
86
protected
:
87
void
Draw(wxGCDC *dc)
override
;
88
89
private
:
90
int
moon_phase(
int
y,
int
m,
int
d);
91
int
m_phase;
92
int
m_radius;
93
wxString m_hemisphere;
94
};
95
99
class
DashboardInstrument_Sun
:
public
DashboardInstrument_Clock
{
100
public
:
101
DashboardInstrument_Sun
(wxWindow *parent, wxWindowID
id
, wxString title,
102
InstrumentProperties
*Properties,
103
wxString format =
"%02i:%02i:%02i UTC"
);
104
105
~DashboardInstrument_Sun
()
override
=
default
;
106
107
wxSize GetSize(
int
orient, wxSize hint)
override
;
108
void
SetData(
DASH_CAP
st,
double
data, wxString
unit
)
override
;
109
void
SetUtcTime(wxDateTime value)
override
;
110
111
protected
:
112
void
Draw(wxGCDC *dc)
override
;
113
114
private
:
115
wxString m_sunrise;
116
wxString m_sunset;
117
double
m_lat;
118
double
m_lon;
119
wxDateTime m_dt;
120
121
void
calculateSun(
double
latit,
double
longit, wxDateTime &sunrise,
122
wxDateTime &sunset);
123
};
124
128
class
DashboardInstrument_CPUClock
:
public
DashboardInstrument_Clock
{
129
public
:
130
DashboardInstrument_CPUClock
(wxWindow *parent, wxWindowID
id
, wxString title,
131
InstrumentProperties
*Properties,
132
wxString format =
"%02i:%02i:%02i UTC"
);
133
134
~DashboardInstrument_CPUClock
()
override
=
default
;
135
136
void
SetData(
DASH_CAP
,
double
, wxString)
override
;
137
138
void
SetUtcTime(wxDateTime value)
override
;
139
};
140
#endif
// CLOCK_H_
DashboardInstrument_CPUClock
A dashboard instrument that displays the current computer time.
Definition
clock.h:128
DashboardInstrument_Clock
A dashboard instrument that displays the GNSS clock time, if available.
Definition
clock.h:48
DashboardInstrument_Moon
A dashboard instrument that displays current moon phase information.
Definition
clock.h:76
DashboardInstrument_Single
Definition
instrument.h:248
DashboardInstrument_Sun
A dashboard instrument that displays sunrise and sunset times.
Definition
clock.h:99
InstrumentProperties
Definition
instrument.h:128
instrument.h
Dashboard instrument base class.
DASH_CAP
DASH_CAP
Definition
instrument.h:77
OCPN_DBP_STC_CLK
@ OCPN_DBP_STC_CLK
Clock.
Definition
instrument.h:101
unit
Definition
tc_data_factory.h:39
plugins
dashboard_pi
src
clock.h
Generated on Mon Aug 17 2026 02:23:19 for OpenCPN Partial API docs by
1.9.8