36DashboardInstrument_GPS::DashboardInstrument_GPS(
37 wxWindow* parent, wxWindowID
id, wxString title,
40 m_ref_dim = wxWindow::GetCharHeight() * 80 / 100;
46 m_cy =
static_cast<int>(m_ref_dim * 35 / 10);
47 m_radius = m_ref_dim * 2;
48 m_scale_delta = m_ref_dim / 2;
49 m_scale_base = (m_radius * 2) + (2 * m_ref_dim);
51 for (
int idx = 0; idx < 12; idx++) {
52 m_sat_info[idx].SatNumber = 0;
53 m_sat_info[idx].ElevationDegrees = 0;
54 m_sat_info[idx].AzimuthDegreesTrue = 0;
55 m_sat_info[idx].SignalToNoiseRatio = 0;
58 talker_id = wxEmptyString;
59 for (
int i = 0; i < GNSS_SYSTEM; i++) {
62 m_last_shift = wxDateTime::Now();
64 m_talker = wxEmptyString;
69wxSize DashboardInstrument_GPS::GetSize(
int orient, wxSize hint) {
74 f = m_Properties->m_TitleFont.GetChosenFont();
76 f = g_pFontTitle->GetChosenFont();
77 dc.GetTextExtent(m_title, &w, &m_TitleHeight,
nullptr,
nullptr, &f);
79 if (orient == wxHORIZONTAL) {
81 return wxSize(w, wxMax(hint.y, m_TitleHeight + (m_ref_dim * 84 / 10)));
85 return wxSize(w, m_TitleHeight + (m_ref_dim * 84 / 10));
89void DashboardInstrument_GPS::SetSatInfo(
int cnt,
int seq, wxString talk,
97 if (seq < 1 || seq > 3)
return;
99 if (talker_id != wxEmptyString) {
104 wxDateTime now = wxDateTime::Now();
105 wxTimeSpan sinceLastShift = now - m_last_shift;
106 if (sinceLastShift.GetSeconds() > 20) {
112 bool secondturn =
false;
113 int im = m_master == GNSS_SYSTEM - 1 ? 0 : m_master + 1;
114 for (
int i = im; i < GNSS_SYSTEM; i++) {
115 wxTimeSpan lastUpdate = now - m_gtime[i];
116 if (lastUpdate.GetSeconds() < 6) {
122 if (i == 5 && !secondturn) {
128 if (talker_id ==
"GP") {
130 if (m_master != 1)
return;
133 if (m_max_sat_count > m_sat_count)
136 m_max_sat_count = m_sat_count;
137 m_talker = wxString::Format(
"GPS\n%d", m_sat_count);
138 }
else if (talker_id ==
"GL") {
140 if (m_master != 2)
return;
142 if (m_max_sat_count > m_sat_count)
145 m_max_sat_count = m_sat_count;
146 m_talker = wxString::Format(
"GLONASS\n%d", m_sat_count);
147 }
else if (talker_id ==
"GA") {
149 if (m_master != 3)
return;
151 if (m_max_sat_count > m_sat_count)
154 m_max_sat_count = m_sat_count;
155 m_talker = wxString::Format(
"Galileo\n%d", m_sat_count);
156 }
else if (talker_id ==
"GB" || talker_id ==
"BD") {
158 if (m_master != 4)
return;
160 if (m_max_sat_count > m_sat_count)
163 m_max_sat_count = m_sat_count;
164 m_talker = wxString::Format(
"BeiDou\n%d", m_sat_count);
165 }
else if (talker_id ==
"GI") {
167 if (m_master != 5)
return;
169 if (m_max_sat_count > m_sat_count)
172 m_max_sat_count = m_sat_count;
173 m_talker = wxString::Format(
"NavIC\n%d", m_sat_count);
174 }
else if (talker_id ==
"GQ") {
176 if (m_master != 0)
return;
178 if (m_max_sat_count > m_sat_count)
181 m_max_sat_count = m_sat_count;
182 m_talker = wxString::Format(
"QZSS\n%d", m_sat_count);
185 m_talker = wxString::Format(
"%s\n%d", talker_id, m_sat_count);
189 int lidx = (seq - 1) * 4;
190 for (
int idx = 0; idx < 4; idx++) {
191 m_sat_info[lidx + idx].SatNumber = sats[idx].SatNumber;
192 m_sat_info[lidx + idx].ElevationDegrees = sats[idx].ElevationDegrees;
193 m_sat_info[lidx + idx].AzimuthDegreesTrue = sats[idx].AzimuthDegreesTrue;
194 m_sat_info[lidx + idx].SignalToNoiseRatio = sats[idx].SignalToNoiseRatio;
197 for (
int idx = m_sat_count; idx < 12; idx++) {
198 m_sat_info[idx].SatNumber = 0;
199 m_sat_info[idx].SignalToNoiseRatio = 0;
203void DashboardInstrument_GPS::Draw(wxGCDC* dc) {
209void DashboardInstrument_GPS::DrawFrame(wxGCDC* dc) {
210 wxSize size = GetClientSize();
213 cb = GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour);
215 GetGlobalColor(
"DASHB", &cb);
216 dc->SetTextBackground(cb);
217 dc->SetBackgroundMode(wxSOLID);
221 cl = GetColourSchemeBackgroundColour(m_Properties->m_TitleBackgroundColour);
223 GetGlobalColor(
"DASHL", &cl);
224 dc->SetTextForeground(cl);
225 dc->SetBrush(*wxTRANSPARENT_BRUSH);
228 pen.SetStyle(wxPENSTYLE_SOLID);
230 GetGlobalColor(
"DASHF", &cf);
235 dc->DrawCircle(m_cx, m_cy, m_radius);
237 dc->SetFont((m_Properties->m_SmallFont.GetChosenFont()));
239 dc->SetFont((g_pFontSmall->GetChosenFont()));
245 f = m_Properties->m_SmallFont.GetChosenFont();
247 f = g_pFontSmall->GetChosenFont();
248 sdc.GetTextExtent(
"W", &width, &height,
nullptr,
nullptr, &f);
250 wxBitmap tbm(width, height, -1);
252 tdc.SetBackground(cb);
254 tdc.SetTextBackground(cb);
255 tdc.SetBackgroundMode(wxSOLID);
257 tdc.SetFont(m_Properties->m_SmallFont.GetChosenFont());
258 tdc.SetTextForeground(
259 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
261 tdc.SetFont(g_pFontSmall->GetChosenFont());
262 tdc.SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
265 tdc.DrawText(_(
"N"), 0, 0);
266 dc->Blit(m_cx - 3, m_cy - m_radius - 6, width, height, &tdc, 0, 0);
269 tdc.DrawText(_(
"E"), 0, 0);
270 dc->Blit(m_cx + m_radius - 4, m_cy - 5, width, height, &tdc, 0, 0);
273 tdc.DrawText(_(
"S"), 0, 0);
274 dc->Blit(m_cx - 3, m_cy + m_radius - 6, width, height, &tdc, 0, 0);
277 tdc.DrawText(_(
"W"), 0, 0);
278 dc->Blit(m_cx - m_radius - 4, m_cy - 5, width, height, &tdc, 0, 0);
280 tdc.SelectObject(wxNullBitmap);
282 dc->SetBackgroundMode(wxTRANSPARENT);
284 dc->DrawLine(3, m_scale_base, size.x - 3, m_scale_base);
285 dc->DrawLine(3, m_scale_base + 4 * m_scale_delta, size.x - 3,
286 m_scale_base + 4 * m_scale_delta);
288 pen.SetStyle(wxPENSTYLE_DOT);
290 dc->DrawCircle(m_cx, m_cy, m_radius * sin(deg2rad(45)));
291 dc->DrawCircle(m_cx, m_cy, m_radius * sin(deg2rad(20)));
295 pen.SetStyle(wxPENSTYLE_SHORT_DASH);
298 dc->DrawLine(3, m_scale_base + 1 * m_scale_delta, size.x - 3,
299 m_scale_base + 1 * m_scale_delta);
300 dc->DrawLine(3, m_scale_base + 2 * m_scale_delta, size.x - 3,
301 m_scale_base + 2 * m_scale_delta);
302 dc->DrawLine(3, m_scale_base + 3 * m_scale_delta, size.x - 3,
303 m_scale_base + 3 * m_scale_delta);
306void DashboardInstrument_GPS::DrawBackground(wxGCDC* dc) {
312 f = m_Properties->m_SmallFont.GetChosenFont();
314 f = g_pFontSmall->GetChosenFont();
315 sdc.GetTextExtent(
"W", &width, &height,
nullptr,
nullptr, &f);
318 wxBitmap tbm(dc->GetSize().x, height, -1);
322 c2 = GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour);
324 GetGlobalColor(
"DASHB", &c2);
325 tdc.SetBackground(c2);
329 tdc.SetFont(m_Properties->m_SmallFont.GetChosenFont());
330 cl = GetColourSchemeFont(m_Properties->m_SmallFont.GetColour());
332 tdc.SetFont(g_pFontSmall->GetChosenFont());
333 GetGlobalColor(
"DASHF", &cl);
335 tdc.SetTextForeground(cl);
336 tdc.SetTextBackground(c2);
338 int pitch = m_ref_dim;
339 int offset = m_ref_dim * 15 / 100;
340 for (
int idx = 0; idx < 12; idx++) {
341 if (m_sat_info[idx].SatNumber) {
342 wxString satno = wxString::Format(
"%02d", m_sat_info[idx].SatNumber);
344 satno = satno.Right(2);
345 tdc.DrawText(satno, idx * pitch + offset, 0);
347 tdc.DrawText(
" -", idx * pitch + offset, 0);
350 tdc.SelectObject(wxNullBitmap);
352 int scaleDelta = m_ref_dim / 2;
353 int scaleBase = (m_radius * 2) + (2 * m_ref_dim);
355 dc->DrawBitmap(tbm, 0, scaleBase + (scaleDelta * 45 / 10),
false);
358void DashboardInstrument_GPS::DrawForeground(wxGCDC* dc) {
361 cl = GetColourSchemeFont(m_Properties->m_DataFont.GetColour());
363 cl = GetColourSchemeFont(g_pFontData->GetColour());
367 dc->SetPen(*wxTRANSPARENT_PEN);
368 dc->SetTextBackground(cl);
371 GetGlobalColor(
"DASHF", &cf);
372 dc->SetTextForeground(cf);
373 dc->SetBackgroundMode(wxSOLID);
377 cb = GetColourSchemeBackgroundColour(m_Properties->m_TitleBackgroundColour);
379 GetGlobalColor(
"DASHL", &cb);
381 dc->SetTextBackground(cb);
383 int m_scaleDelta = m_ref_dim / 2;
384 int m_scaleBase = (m_radius * 2) + (2 * m_ref_dim);
385 int pitch = m_ref_dim;
386 int offset = m_ref_dim * 12 / 100;
388 for (
int idx = 0; idx < 12; idx++) {
389 if (m_sat_info[idx].SignalToNoiseRatio) {
390 int h = m_sat_info[idx].SignalToNoiseRatio * m_ref_dim / 24;
391 dc->DrawRectangle(idx * pitch + offset,
392 m_scaleBase + (4 * m_scaleDelta) - h, pitch * 60 / 100,
397 wxString label =
"00";
402 f = m_Properties->m_SmallFont.GetChosenFont();
404 f = g_pFontSmall->GetChosenFont();
406 sdc.GetTextExtent(label, &width, &height,
nullptr,
nullptr, &f);
408 dc->SetBackgroundMode(wxTRANSPARENT);
410 for (
int idx = 0; idx < 12; idx++) {
411 if (m_sat_info[idx].SignalToNoiseRatio) {
412 label.Printf(
"%02d", m_sat_info[idx].SatNumber);
416 cos(deg2rad(m_sat_info[idx].AzimuthDegreesTrue - ANGLE_OFFSET)) *
417 sin(deg2rad(ANGLE_OFFSET - m_sat_info[idx].ElevationDegrees)) -
422 sin(deg2rad(m_sat_info[idx].AzimuthDegreesTrue - ANGLE_OFFSET)) *
423 sin(deg2rad(ANGLE_OFFSET - m_sat_info[idx].ElevationDegrees)) -
425 dc->DrawText(label, posx, posy);
428 dc->SetBackgroundMode(wxSOLID);
429 if (talker_id != wxEmptyString) dc->DrawText(m_talker, 1, m_ref_dim * 3 / 2);
Dashboard dial instrument.
Dashboard GPS instrument.
@ OCPN_DBP_STC_GPS
GPS status.
double OCPN_GetWinDIPScaleFactor()
Gets Windows-specific DPI scaling factor.