43DashboardInstrument_GPS::DashboardInstrument_GPS(
44 wxWindow* parent, wxWindowID
id, wxString title,
47 m_refDim = GetCharHeight() * 80 / 100;
48 m_refDim *= OCPN_GetWinDIPScaleFactor() < 1.0
49 ? 2.0 * OCPN_GetWinDIPScaleFactor()
53 m_cy = m_refDim * 35 / 10;
54 m_radius = m_refDim * 2;
55 m_scaleDelta = m_refDim / 2;
56 m_scaleBase = (m_radius * 2) + (2 * m_refDim);
58 for (
int idx = 0; idx < 12; idx++) {
59 m_SatInfo[idx].SatNumber = 0;
60 m_SatInfo[idx].ElevationDegrees = 0;
61 m_SatInfo[idx].AzimuthDegreesTrue = 0;
62 m_SatInfo[idx].SignalToNoiseRatio = 0;
65 talkerID = wxEmptyString;
66 for (
int i = 0; i < GNSS_SYSTEM; i++) {
69 m_lastShift = wxDateTime::Now();
71 s_gTalker = wxEmptyString;
76wxSize DashboardInstrument_GPS::GetSize(
int orient, wxSize hint) {
81 f = m_Properties->m_TitleFont.GetChosenFont();
83 f = g_pFontTitle->GetChosenFont();
84 dc.GetTextExtent(m_title, &w, &m_TitleHeight, 0, 0, &f);
86 if (orient == wxHORIZONTAL) {
88 return wxSize(w, wxMax(hint.y, m_TitleHeight + (m_refDim * 84 / 10)));
92 return wxSize(w, m_TitleHeight + (m_refDim * 84 / 10));
96void DashboardInstrument_GPS::SetSatInfo(
int cnt,
int seq, wxString talk,
104 if (seq < 1 || seq > 3)
return;
106 if (talkerID != wxEmptyString) {
111 wxDateTime now = wxDateTime::Now();
112 wxTimeSpan sinceLastShift = now - m_lastShift;
113 if (sinceLastShift.GetSeconds() > 20) {
119 bool secondturn =
false;
120 int im = m_iMaster == GNSS_SYSTEM - 1 ? 0 : m_iMaster + 1;
121 for (
int i = im; i < GNSS_SYSTEM; i++) {
122 wxTimeSpan lastUpdate = now - m_Gtime[i];
123 if (lastUpdate.GetSeconds() < 6) {
129 if (i == 5 && !secondturn) {
135 if (talkerID == _T(
"GP")) {
137 if (m_iMaster != 1)
return;
140 if (m_MaxSatCount > m_SatCount)
143 m_MaxSatCount = m_SatCount;
144 s_gTalker = wxString::Format(_T(
"GPS\n%d"), m_SatCount);
145 }
else if (talkerID == _T(
"GL")) {
147 if (m_iMaster != 2)
return;
149 if (m_MaxSatCount > m_SatCount)
152 m_MaxSatCount = m_SatCount;
153 s_gTalker = wxString::Format(_T(
"GLONASS\n%d"), m_SatCount);
154 }
else if (talkerID == _T(
"GA")) {
156 if (m_iMaster != 3)
return;
158 if (m_MaxSatCount > m_SatCount)
161 m_MaxSatCount = m_SatCount;
162 s_gTalker = wxString::Format(_T(
"Galileo\n%d"), m_SatCount);
163 }
else if (talkerID == _T(
"GB") || talkerID == _T(
"BD")) {
165 if (m_iMaster != 4)
return;
167 if (m_MaxSatCount > m_SatCount)
170 m_MaxSatCount = m_SatCount;
171 s_gTalker = wxString::Format(_T(
"BeiDou\n%d"), m_SatCount);
172 }
else if (talkerID == _T(
"GI")) {
174 if (m_iMaster != 5)
return;
176 if (m_MaxSatCount > m_SatCount)
179 m_MaxSatCount = m_SatCount;
180 s_gTalker = wxString::Format(_T(
"NavIC\n%d"), m_SatCount);
181 }
else if (talkerID == _T(
"GQ")) {
183 if (m_iMaster != 0)
return;
185 if (m_MaxSatCount > m_SatCount)
188 m_MaxSatCount = m_SatCount;
189 s_gTalker = wxString::Format(_T(
"QZSS\n%d"), m_SatCount);
192 s_gTalker = wxString::Format(_T(
"%s\n%d"), talkerID, m_SatCount);
196 int lidx = (seq - 1) * 4;
197 for (
int idx = 0; idx < 4; idx++) {
198 m_SatInfo[lidx + idx].SatNumber = sats[idx].SatNumber;
199 m_SatInfo[lidx + idx].ElevationDegrees = sats[idx].ElevationDegrees;
200 m_SatInfo[lidx + idx].AzimuthDegreesTrue = sats[idx].AzimuthDegreesTrue;
201 m_SatInfo[lidx + idx].SignalToNoiseRatio = sats[idx].SignalToNoiseRatio;
204 for (
int idx = m_SatCount; idx < 12; idx++) {
205 m_SatInfo[idx].SatNumber = 0;
206 m_SatInfo[idx].SignalToNoiseRatio = 0;
210void DashboardInstrument_GPS::Draw(wxGCDC* dc) {
216void DashboardInstrument_GPS::DrawFrame(wxGCDC* dc) {
217 wxSize size = GetClientSize();
220 cb = GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour);
222 GetGlobalColor(_T(
"DASHB"), &cb);
223 dc->SetTextBackground(cb);
224 dc->SetBackgroundMode(wxSOLID);
228 cl = GetColourSchemeBackgroundColour(m_Properties->m_TitleBackgroundColour);
230 GetGlobalColor(_T(
"DASHL"), &cl);
231 dc->SetTextForeground(cl);
232 dc->SetBrush(*wxTRANSPARENT_BRUSH);
235 pen.SetStyle(wxPENSTYLE_SOLID);
237 GetGlobalColor(_T(
"DASHF"), &cf);
242 dc->DrawCircle(m_cx, m_cy, m_radius);
244 dc->SetFont((m_Properties->m_SmallFont.GetChosenFont()));
246 dc->SetFont((g_pFontSmall->GetChosenFont()));
252 f = m_Properties->m_SmallFont.GetChosenFont();
254 f = g_pFontSmall->GetChosenFont();
255 sdc.GetTextExtent(_T(
"W"), &width, &height, NULL, NULL, &f);
257 wxBitmap tbm(width, height, -1);
259 tdc.SetBackground(cb);
261 tdc.SetTextBackground(cb);
262 tdc.SetBackgroundMode(wxSOLID);
264 tdc.SetFont(m_Properties->m_SmallFont.GetChosenFont());
265 tdc.SetTextForeground(
266 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
268 tdc.SetFont(g_pFontSmall->GetChosenFont());
269 tdc.SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
272 tdc.DrawText(_(
"N"), 0, 0);
273 dc->Blit(m_cx - 3, m_cy - m_radius - 6, width, height, &tdc, 0, 0);
276 tdc.DrawText(_(
"E"), 0, 0);
277 dc->Blit(m_cx + m_radius - 4, m_cy - 5, width, height, &tdc, 0, 0);
280 tdc.DrawText(_(
"S"), 0, 0);
281 dc->Blit(m_cx - 3, m_cy + m_radius - 6, width, height, &tdc, 0, 0);
284 tdc.DrawText(_(
"W"), 0, 0);
285 dc->Blit(m_cx - m_radius - 4, m_cy - 5, width, height, &tdc, 0, 0);
287 tdc.SelectObject(wxNullBitmap);
289 dc->SetBackgroundMode(wxTRANSPARENT);
291 dc->DrawLine(3, m_scaleBase, size.x - 3, m_scaleBase);
292 dc->DrawLine(3, m_scaleBase + 4 * m_scaleDelta, size.x - 3,
293 m_scaleBase + 4 * m_scaleDelta);
295 pen.SetStyle(wxPENSTYLE_DOT);
297 dc->DrawCircle(m_cx, m_cy, m_radius * sin(deg2rad(45)));
298 dc->DrawCircle(m_cx, m_cy, m_radius * sin(deg2rad(20)));
302 pen.SetStyle(wxPENSTYLE_SHORT_DASH);
305 dc->DrawLine(3, m_scaleBase + 1 * m_scaleDelta, size.x - 3,
306 m_scaleBase + 1 * m_scaleDelta);
307 dc->DrawLine(3, m_scaleBase + 2 * m_scaleDelta, size.x - 3,
308 m_scaleBase + 2 * m_scaleDelta);
309 dc->DrawLine(3, m_scaleBase + 3 * m_scaleDelta, size.x - 3,
310 m_scaleBase + 3 * m_scaleDelta);
313void DashboardInstrument_GPS::DrawBackground(wxGCDC* dc) {
319 f = m_Properties->m_SmallFont.GetChosenFont();
321 f = g_pFontSmall->GetChosenFont();
322 sdc.GetTextExtent(_T(
"W"), &width, &height, NULL, NULL, &f);
325 wxBitmap tbm(dc->GetSize().x, height, -1);
329 c2 = GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour);
331 GetGlobalColor(_T(
"DASHB"), &c2);
332 tdc.SetBackground(c2);
336 tdc.SetFont(m_Properties->m_SmallFont.GetChosenFont());
337 cl = GetColourSchemeFont(m_Properties->m_SmallFont.GetColour());
339 tdc.SetFont(g_pFontSmall->GetChosenFont());
340 GetGlobalColor(_T(
"DASHF"), &cl);
342 tdc.SetTextForeground(cl);
343 tdc.SetTextBackground(c2);
345 int pitch = m_refDim;
346 int offset = m_refDim * 15 / 100;
347 for (
int idx = 0; idx < 12; idx++) {
348 if (m_SatInfo[idx].SatNumber) {
349 wxString satno = wxString::Format(_T(
"%02d"), m_SatInfo[idx].SatNumber);
351 satno = satno.Right(2);
352 tdc.DrawText(satno, idx * pitch + offset, 0);
354 tdc.DrawText(
" -", idx * pitch + offset, 0);
357 tdc.SelectObject(wxNullBitmap);
359 int scaleDelta = m_refDim / 2;
360 int scaleBase = (m_radius * 2) + (2 * m_refDim);
362 dc->DrawBitmap(tbm, 0, scaleBase + (scaleDelta * 45 / 10),
false);
365void DashboardInstrument_GPS::DrawForeground(wxGCDC* dc) {
368 cl = GetColourSchemeFont(m_Properties->m_DataFont.GetColour());
370 cl = GetColourSchemeFont(g_pFontData->GetColour());
374 dc->SetPen(*wxTRANSPARENT_PEN);
375 dc->SetTextBackground(cl);
378 GetGlobalColor(_T(
"DASHF"), &cf);
379 dc->SetTextForeground(cf);
380 dc->SetBackgroundMode(wxSOLID);
384 cb = GetColourSchemeBackgroundColour(m_Properties->m_TitleBackgroundColour);
386 GetGlobalColor(_T(
"DASHL"), &cb);
388 dc->SetTextBackground(cb);
390 int m_scaleDelta = m_refDim / 2;
391 int m_scaleBase = (m_radius * 2) + (2 * m_refDim);
392 int pitch = m_refDim;
393 int offset = m_refDim * 12 / 100;
395 for (
int idx = 0; idx < 12; idx++) {
396 if (m_SatInfo[idx].SignalToNoiseRatio) {
397 int h = m_SatInfo[idx].SignalToNoiseRatio * m_refDim / 24;
398 dc->DrawRectangle(idx * pitch + offset,
399 m_scaleBase + (4 * m_scaleDelta) - h, pitch * 60 / 100,
404 wxString label =
"00";
409 f = m_Properties->m_SmallFont.GetChosenFont();
411 f = g_pFontSmall->GetChosenFont();
413 sdc.GetTextExtent(label, &width, &height, 0, 0, &f);
415 dc->SetBackgroundMode(wxTRANSPARENT);
417 for (
int idx = 0; idx < 12; idx++) {
418 if (m_SatInfo[idx].SignalToNoiseRatio) {
419 label.Printf(_T(
"%02d"), m_SatInfo[idx].SatNumber);
423 cos(deg2rad(m_SatInfo[idx].AzimuthDegreesTrue - ANGLE_OFFSET)) *
424 sin(deg2rad(ANGLE_OFFSET - m_SatInfo[idx].ElevationDegrees)) -
429 sin(deg2rad(m_SatInfo[idx].AzimuthDegreesTrue - ANGLE_OFFSET)) *
430 sin(deg2rad(ANGLE_OFFSET - m_SatInfo[idx].ElevationDegrees)) -
432 dc->DrawText(label, posx, posy);
435 dc->SetBackgroundMode(wxSOLID);
436 if (talkerID != wxEmptyString) dc->DrawText(s_gTalker, 1, m_refDim * 3 / 2);