37DashboardInstrument_WindDirHistory::DashboardInstrument_WindDirHistory(
38 wxWindow* parent, wxWindowID
id, wxString title,
43 SetDrawSoloInPane(
true);
48 m_WindSpeedUnit = _(
"-");
49 m_TotalMaxWindSpd = 0;
56 f = m_Properties->m_DataFont.GetChosenFont();
58 f = g_pFontData->GetChosenFont();
59 dc.GetTextExtent(
"TWS----", &w, &h,
nullptr,
nullptr, &f);
60 m_TopLineHeight = wxMax(30, h);
70 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
71 m_ArrayWindDirHistory[idx] = -1;
72 m_ArrayWindSpdHistory[idx] = -1;
73 m_ExpSmoothArrayWindSpd[idx] = -1;
74 m_ExpSmoothArrayWindDir[idx] = -1;
75 m_ArrayRecTime[idx] = wxDateTime::Now().GetTm();
76 m_ArrayRecTime[idx].year = 999;
79 m_WindowRect = GetClientRect();
80 m_DrawAreaRect = GetClientRect();
81 m_DrawAreaRect.SetHeight(m_WindowRect.height - m_TopLineHeight -
85wxSize DashboardInstrument_WindDirHistory::GetSize(
int orient, wxSize hint) {
90 f = m_Properties->m_TitleFont.GetChosenFont();
92 f = g_pFontTitle->GetChosenFont();
94 wxString widthdummy =
"Left Space TWS 25.5 kn TWD 320 right s";
95 dc.GetTextExtent(widthdummy, &w, &m_TitleHeight,
nullptr,
nullptr, &f);
96 if (orient == wxHORIZONTAL) {
97 return wxSize(DefaultWidth, wxMax(m_TitleHeight + 140, hint.y));
99 return wxSize(wxMax(hint.x, w), wxMax(m_TitleHeight + 140, hint.y));
103void DashboardInstrument_WindDirHistory::SetData(
DASH_CAP st,
double data,
106 if (m_SetNewData < 1) {
108 if (std::isnan(data)) {
111 m_WindSpd = m_WindDir = NAN;
114 if (m_DirRecCnt <= 5) {
115 m_DirStartVal +=
static_cast<int>(data);
123 if (
unit != m_WindSpeedUnit && m_WindSpeedUnit != _(
"-")) {
126 m_WindSpeedUnit =
unit;
127 if (m_SpdRecCnt <= 5) {
128 m_SpdStartVal +=
static_cast<int>(data);
132 if (m_SpdRecCnt == 5 && m_DirRecCnt == 5) {
133 m_WindSpd =
static_cast<int>(m_SpdStartVal / 5);
134 m_WindDir =
static_cast<int>(m_DirStartVal / 5);
135 m_oldDirVal = m_WindDir;
140 if (m_SpdRecCnt > 5 && m_DirRecCnt > 5) {
142 m_SampleCount = m_SampleCount < WIND_RECORD_COUNT ? m_SampleCount + 1
148 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
149 if (WIND_RECORD_COUNT - m_SampleCount <= idx)
150 m_MinWindDir = wxMin(m_ArrayWindDirHistory[idx], m_MinWindDir);
151 m_MaxWindDir = wxMax(m_ArrayWindDirHistory[idx - 1], m_MaxWindDir);
152 m_MaxWindSpd = wxMax(m_ArrayWindSpdHistory[idx - 1], m_MaxWindSpd);
153 m_ArrayWindDirHistory[idx - 1] = m_ArrayWindDirHistory[idx];
154 m_ArrayWindSpdHistory[idx - 1] = m_ArrayWindSpdHistory[idx];
155 m_ExpSmoothArrayWindSpd[idx - 1] = m_ExpSmoothArrayWindSpd[idx];
156 m_ExpSmoothArrayWindDir[idx - 1] = m_ExpSmoothArrayWindDir[idx];
157 m_ArrayRecTime[idx - 1] = m_ArrayRecTime[idx];
159 double diff = m_WindDir - m_oldDirVal;
162 }
else if (diff > 270) {
165 m_ArrayWindDirHistory[WIND_RECORD_COUNT - 1] = m_WindDir;
166 m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 1] = m_WindSpd;
167 if (m_SampleCount < 2) {
168 m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 2] = m_WindSpd;
169 m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 2] = m_WindSpd;
170 m_ArrayWindDirHistory[WIND_RECORD_COUNT - 2] = m_WindDir;
171 m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 2] = m_WindDir;
173 m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 1] =
174 alpha * m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 2] +
175 (1 - alpha) * m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 2];
176 m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 1] =
177 alpha * m_ArrayWindDirHistory[WIND_RECORD_COUNT - 2] +
178 (1 - alpha) * m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 2];
179 m_ArrayRecTime[WIND_RECORD_COUNT - 1] = wxDateTime::Now().GetTm();
180 m_oldDirVal = m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 1];
182 m_MaxWindDir = wxMax(m_WindDir, m_MaxWindDir);
183 m_MinWindDir = wxMin(m_WindDir, m_MinWindDir);
184 m_MaxWindSpd = wxMax(m_WindSpd, m_MaxWindSpd);
186 m_TotalMaxWindSpd = wxMax(m_WindSpd, m_TotalMaxWindSpd);
190 SetMinMaxWindScale();
199void DashboardInstrument_WindDirHistory::ResetData() {
204 m_TotalMaxWindSpd = 0;
215 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
216 m_ArrayWindDirHistory[idx] = -1;
217 m_ArrayWindSpdHistory[idx] = -1;
218 m_ExpSmoothArrayWindSpd[idx] = -1;
219 m_ExpSmoothArrayWindDir[idx] = -1;
220 m_ArrayRecTime[idx] = wxDateTime::Now().GetTm();
221 m_ArrayRecTime[idx].year = 999;
225void DashboardInstrument_WindDirHistory::Draw(wxGCDC* dc) {
226 m_WindowRect = GetClientRect();
227 m_DrawAreaRect = GetClientRect();
228 m_DrawAreaRect.SetHeight(m_WindowRect.height - m_TopLineHeight -
230 m_DrawAreaRect.SetX(m_LeftLegend + 3);
238void DashboardInstrument_WindDirHistory::SetMinMaxWindScale() {
244 int fulldeg =
static_cast<int>(m_MaxWindDir / 90);
246 fulldeg = m_MaxWindDir < 0 ? 0 : 1;
247 else if (m_MaxWindDir > 0)
249 m_MaxWindDir = fulldeg * 90;
251 fulldeg =
static_cast<int>(m_MinWindDir / 90);
253 fulldeg = m_MinWindDir < 0 ? -1 : 0;
255 fulldeg = m_MinWindDir > 0 ? fulldeg : (fulldeg - 1);
256 m_MinWindDir = fulldeg * 90;
260 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
261 if (m_WindDirRange > 360) {
262 int diff2min =
static_cast<int>(m_WindDir - m_MinWindDir);
264 int diff2max =
static_cast<int>(m_MaxWindDir - m_WindDir);
266 if (diff2min > diff2max) {
267 while (m_WindDirRange > 360) {
269 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
272 if (diff2min < diff2max) {
273 while (m_WindDirRange > 360) {
275 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
283void DashboardInstrument_WindDirHistory::DrawWindDirScale(wxGCDC* dc) {
284 wxString label1, label2, label3, label4, label5;
288 dc->SetTextForeground(
289 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
290 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
292 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
293 dc->SetFont(g_pFontSmall->GetChosenFont());
303 double tempdir = m_MinWindDir;
304 while (tempdir < 0) tempdir += 360;
305 while (tempdir >= 360) tempdir -= 360;
306 label1 = GetWindDirStr(wxString::Format(
"%.1f", tempdir));
308 tempdir = m_MinWindDir + m_WindDirRange / 4.;
309 while (tempdir < 0) tempdir += 360;
310 while (tempdir >= 360) tempdir -= 360;
311 label2 = GetWindDirStr(wxString::Format(
"%.1f", tempdir));
313 tempdir = m_MinWindDir + m_WindDirRange / 2;
314 while (tempdir < 0) tempdir += 360;
315 while (tempdir >= 360) tempdir -= 360;
316 label3 = GetWindDirStr(wxString::Format(
"%.1f", tempdir));
318 tempdir = m_MinWindDir + m_WindDirRange * 0.75;
319 while (tempdir < 0) tempdir += 360;
320 while (tempdir >= 360) tempdir -= 360;
321 label4 = GetWindDirStr(wxString::Format(
"%.1f", tempdir));
323 tempdir = m_MaxWindDir;
324 while (tempdir < 0) tempdir += 360;
325 while (tempdir >= 360) tempdir -= 360;
326 label5 = GetWindDirStr(wxString::Format(
"%.1f", tempdir));
333 f = m_Properties->m_SmallFont.GetChosenFont();
334 dc->GetTextExtent(label5, &width, &height,
nullptr,
nullptr, &f);
335 m_RightLegend = width;
336 dc->GetTextExtent(label4, &width, &height,
nullptr,
nullptr, &f);
337 m_RightLegend = wxMax(width, m_RightLegend);
338 dc->GetTextExtent(label3, &width, &height,
nullptr,
nullptr, &f);
339 m_RightLegend = wxMax(width, m_RightLegend);
340 dc->GetTextExtent(label2, &width, &height,
nullptr,
nullptr, &f);
341 m_RightLegend = wxMax(width, m_RightLegend);
342 dc->GetTextExtent(label1, &width, &height,
nullptr,
nullptr, &f);
343 m_RightLegend = wxMax(width, m_RightLegend);
345 f = g_pFontSmall->GetChosenFont();
346 dc->GetTextExtent(label5, &width, &height,
nullptr,
nullptr, &f);
347 m_RightLegend = width;
348 dc->GetTextExtent(label4, &width, &height,
nullptr,
nullptr, &f);
349 m_RightLegend = wxMax(width, m_RightLegend);
350 dc->GetTextExtent(label3, &width, &height,
nullptr,
nullptr, &f);
351 m_RightLegend = wxMax(width, m_RightLegend);
352 dc->GetTextExtent(label2, &width, &height,
nullptr,
nullptr, &f);
353 m_RightLegend = wxMax(width, m_RightLegend);
354 dc->GetTextExtent(label1, &width, &height,
nullptr,
nullptr, &f);
355 m_RightLegend = wxMax(width, m_RightLegend);
358 dc->DrawText(label5, m_WindowRect.width - m_RightLegend,
359 m_TopLineHeight - height / 2);
360 dc->DrawText(label4, m_WindowRect.width - m_RightLegend,
361 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 4 - height / 2));
362 dc->DrawText(label3, m_WindowRect.width - m_RightLegend,
363 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 2 - height / 2));
365 label2, m_WindowRect.width - m_RightLegend,
366 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75 - height / 2));
367 dc->DrawText(label1, m_WindowRect.width - m_RightLegend,
368 (
int)(m_TopLineHeight + m_DrawAreaRect.height - height / 2));
374void DashboardInstrument_WindDirHistory::DrawWindSpeedScale(wxGCDC* dc) {
375 wxString label1, label2, label3, label4, label5;
383 dc->SetTextForeground(
384 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
385 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
387 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
388 dc->SetFont(g_pFontSmall->GetChosenFont());
391 m_MaxWindSpdScale = (int)m_MaxWindSpd + 1;
393 label1.Printf(_(
"--- %s"), m_WindSpeedUnit.c_str());
406 label1.Printf(
"%.0f %s", m_MaxWindSpdScale, m_WindSpeedUnit.c_str());
408 WindSpdScale = m_MaxWindSpdScale * 3. / 4.;
410 val1 = (int)((WindSpdScale - (
int)WindSpdScale) * 100);
411 if (val1 == 25 || val1 == 75)
412 label2.Printf(
"%.2f %s", WindSpdScale, m_WindSpeedUnit.c_str());
414 label2.Printf(
"%.1f %s", WindSpdScale, m_WindSpeedUnit.c_str());
416 label2.Printf(
"%.0f %s", WindSpdScale, m_WindSpeedUnit.c_str());
418 WindSpdScale = m_MaxWindSpdScale / 2.;
420 if ((
int)(WindSpdScale * 10) % 10 == 5)
421 label3.Printf(
"%.1f %s", WindSpdScale, m_WindSpeedUnit.c_str());
423 label3.Printf(
"%.0f %s", WindSpdScale, m_WindSpeedUnit.c_str());
426 WindSpdScale = m_MaxWindSpdScale / 4.;
428 val1 = (int)((WindSpdScale - (
int)WindSpdScale) * 100);
429 if (val1 == 25 || val1 == 75)
430 label4.Printf(
"%.2f %s", WindSpdScale, m_WindSpeedUnit.c_str());
432 label4.Printf(
"%.1f %s", WindSpdScale, m_WindSpeedUnit.c_str());
434 label4.Printf(
"%.0f %s", WindSpdScale, m_WindSpeedUnit.c_str());
437 label5.Printf(
"%.0f %s", 0.0, m_WindSpeedUnit.c_str());
441 f = m_Properties->m_SmallFont.GetChosenFont();
443 f = g_pFontSmall->GetChosenFont();
444 dc->GetTextExtent(label1, &m_LeftLegend, &height,
nullptr,
nullptr, &f);
445 dc->DrawText(label1, 4, (
int)(m_TopLineHeight - height / 2));
447 f = m_Properties->m_SmallFont.GetChosenFont();
449 f = g_pFontSmall->GetChosenFont();
450 dc->GetTextExtent(label2, &width, &height,
nullptr,
nullptr, &f);
451 dc->DrawText(label2, 4,
452 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 4 - height / 2));
453 m_LeftLegend = wxMax(width, m_LeftLegend);
455 f = m_Properties->m_SmallFont.GetChosenFont();
457 f = g_pFontSmall->GetChosenFont();
458 dc->GetTextExtent(label3, &width, &height,
nullptr,
nullptr, &f);
459 dc->DrawText(label3, 4,
460 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 2 - height / 2));
461 m_LeftLegend = wxMax(width, m_LeftLegend);
463 f = m_Properties->m_SmallFont.GetChosenFont();
465 f = g_pFontSmall->GetChosenFont();
466 dc->GetTextExtent(label4, &width, &height,
nullptr,
nullptr, &f);
469 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75 - height / 2));
470 m_LeftLegend = wxMax(width, m_LeftLegend);
472 f = m_Properties->m_SmallFont.GetChosenFont();
474 f = g_pFontSmall->GetChosenFont();
475 dc->GetTextExtent(label5, &width, &height,
nullptr,
nullptr, &f);
476 dc->DrawText(label5, 4,
477 (
int)(m_TopLineHeight + m_DrawAreaRect.height - height / 2));
478 m_LeftLegend = wxMax(width, m_LeftLegend);
485void DashboardInstrument_WindDirHistory::DrawBackground(wxGCDC* dc) {
486 wxString label, label1, label2, label3, label4, label5;
492 DrawWindDirScale(dc);
493 DrawWindSpeedScale(dc);
498 GetGlobalColor(
"UBLCK", &cl);
501 dc->DrawLine(m_LeftLegend + 3, m_TopLineHeight,
502 m_WindowRect.width - 3 - m_RightLegend,
504 dc->DrawLine(m_LeftLegend + 3, (
int)(m_TopLineHeight + m_DrawAreaRect.height),
505 m_WindowRect.width - 3 - m_RightLegend,
506 (
int)(m_TopLineHeight + m_DrawAreaRect.height));
507 pen.SetStyle(wxPENSTYLE_DOT);
509 dc->DrawLine(m_LeftLegend + 3,
510 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.25),
511 m_WindowRect.width - 3 - m_RightLegend,
512 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.25));
513 dc->DrawLine(m_LeftLegend + 3,
514 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75),
515 m_WindowRect.width - 3 - m_RightLegend,
516 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75));
518 pen.SetStyle(wxPENSTYLE_SHORT_DASH);
521 dc->DrawLine(m_LeftLegend + 3,
522 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.5),
523 m_WindowRect.width - 3 - m_RightLegend,
524 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.5));
531wxString DashboardInstrument_WindDirHistory::GetWindDirStr(wxString WindDir) {
532 if (WindDir ==
"0.0" || WindDir ==
"360.0")
534 else if (WindDir ==
"22.5")
536 else if (WindDir ==
"45.0")
538 else if (WindDir ==
"67.5")
540 else if (WindDir ==
"90.0")
542 else if (WindDir ==
"112.5")
544 else if (WindDir ==
"135.0")
546 else if (WindDir ==
"157.5")
548 else if (WindDir ==
"180.0")
550 else if (WindDir ==
"202.5")
552 else if (WindDir ==
"225.0")
554 else if (WindDir ==
"247.5")
556 else if (WindDir ==
"270.0")
558 else if (WindDir ==
"292.5")
560 else if (WindDir ==
"315.0")
562 else if (WindDir ==
"337.5")
571void DashboardInstrument_WindDirHistory::DrawForeground(wxGCDC* dc) {
574 int width, height, min, hour;
576 wxString WindAngle, WindSpeed;
583 dc->SetFont((g_pFontSmall->GetChosenFont()));
584 col = wxColour(204, 41, 41, 255);
587 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
588 dc->SetTextForeground(
589 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
591 dc->SetFont(g_pFontSmall->GetChosenFont());
592 if (GetColourSchemeFont(g_pFontLabel->GetColour()) ==
593 GetColourSchemeFont(g_pFontLabel->GetColour()))
594 dc->SetTextForeground(col);
596 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
599 WindAngle =
"TWD --- ";
602 while (dir > 360) dir -= 360;
603 while (dir < 0) dir += 360;
604 if (!std::isnan(dir))
605 WindAngle = wxString::Format(
"TWD %3.0f", dir) + DEGREE_SIGN;
607 WindAngle = wxString::Format(
"TWD ---") + DEGREE_SIGN;
611 f = m_Properties->m_SmallFont.GetChosenFont();
613 f = g_pFontLabel->GetChosenFont();
615 dc->GetTextExtent(WindAngle, °w, °h,
nullptr,
nullptr, &f);
616 dc->DrawText(WindAngle, m_WindowRect.width - m_RightLegend - degw, 3);
618 pen.SetStyle(wxPENSTYLE_SOLID);
620#if wxCHECK_VERSION(3, 1, 6)
622 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetRed();
624 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetGreen();
626 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetBlue();
629 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Red();
631 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Green();
633 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Blue();
635 pen.SetColour(wxColour(r, g, b, 96));
637 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
638 GetColourSchemeFont(g_pFontLabel->GetColour()))
639 pen.SetColour(wxColour(204, 41, 41, 96));
641#if wxCHECK_VERSION(3, 1, 6)
642 unsigned int r = GetColourSchemeFont(g_pFontData->GetColour()).GetRed();
643 unsigned int g = GetColourSchemeFont(g_pFontData->GetColour()).GetGreen();
644 unsigned int b = GetColourSchemeFont(g_pFontData->GetColour()).GetBlue();
646 unsigned int r = GetColourSchemeFont(g_pFontData->GetColour()).Red();
647 unsigned int g = GetColourSchemeFont(g_pFontData->GetColour()).Green();
648 unsigned int b = GetColourSchemeFont(g_pFontData->GetColour()).Blue();
650 pen.SetColour(wxColour(r, g, b, 96));
656 ratioH = (double)m_DrawAreaRect.height / m_WindDirRange;
657 m_DrawAreaRect.SetWidth(m_WindowRect.width - 6 - m_LeftLegend -
659 m_ratioW = double(m_DrawAreaRect.width) / (WIND_RECORD_COUNT - 1);
664 wxPoint points[WIND_RECORD_COUNT + 2];
665 wxPoint wdDraw[WIND_RECORD_COUNT + 2];
667 wdDraw[ld].x =
static_cast<int>(m_ratioW + 3 + m_LeftLegend);
669 static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
670 (m_ArrayWindDirHistory[1] - m_MinWindDir) * ratioH);
672 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
673 points[idx].x =
static_cast<int>(idx * m_ratioW + 3 + m_LeftLegend);
675 static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
676 (m_ArrayWindDirHistory[idx] - m_MinWindDir) * ratioH);
677 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
678 points[idx].y > m_TopLineHeight &&
679 points[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
680 wdDraw[ld] = points[idx];
684 if (ld > 1) dc->DrawLines(ld, wdDraw);
689 pen.SetStyle(wxPENSTYLE_SOLID);
692 pen.SetColour(GetColourSchemeFont(m_Properties->m_DataFont.GetColour()));
694 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
695 GetColourSchemeFont(g_pFontLabel->GetColour()))
696 pen.SetColour(wxColour(204, 41, 41, 255));
698 pen.SetColour(GetColourSchemeFont(g_pFontData->GetColour()));
704 wdDraw[ld].x =
static_cast<int>(m_ratioW + 3 + m_LeftLegend);
706 static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
707 (m_ExpSmoothArrayWindDir[ld] - m_MinWindDir) * ratioH);
709 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
710 points[idx].x =
static_cast<int>(idx * m_ratioW + 3 + m_LeftLegend);
711 points[idx].y =
static_cast<int>(
712 m_TopLineHeight + m_DrawAreaRect.height -
713 (m_ExpSmoothArrayWindDir[idx] - m_MinWindDir) * ratioH);
714 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
715 points[idx].y > m_TopLineHeight &&
716 points[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
717 wdDraw[ld] = points[idx];
721 if (ld > 1) dc->DrawLines(ld, wdDraw);
726 col = wxColour(61, 61, 204, 255);
728 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
729 dc->SetTextForeground(
730 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
732 dc->SetFont(g_pFontSmall->GetChosenFont());
733 if (GetColourSchemeFont(g_pFontSmall->GetColour()) ==
734 GetColourSchemeFont(g_pFontSmall->GetColour()))
735 dc->SetTextForeground(col);
737 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
739 if (!std::isnan(m_WindSpd))
741 wxString::Format(
"TWS %3.1f %s ", m_WindSpd, m_WindSpeedUnit.c_str());
743 WindSpeed = wxString::Format(
"TWS --- %s ", m_WindSpeedUnit.c_str());
745 f = m_Properties->m_LabelFont.GetChosenFont();
746 dc->GetTextExtent(WindSpeed, &speedw, °h,
nullptr,
nullptr, &f);
748 f = g_pFontSmall->GetChosenFont();
749 dc->GetTextExtent(WindSpeed, &speedw, °h,
nullptr,
nullptr, &f);
751 dc->DrawText(WindSpeed, m_LeftLegend, 3);
753 dc->SetFont((g_pFontSmall->GetChosenFont()));
756 f = m_Properties->m_SmallFont.GetChosenFont();
757 dc->GetTextExtent(WindSpeed, &labelw, &labelh,
nullptr,
nullptr, &f);
758 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
759 dc->SetTextForeground(
760 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
762 f = g_pFontSmall->GetChosenFont();
763 dc->GetTextExtent(WindSpeed, &labelw, &labelh,
nullptr,
nullptr, &f);
764 dc->SetFont(g_pFontSmall->GetChosenFont());
765 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
769 while (m_ArrayRecTime[i].year == 999 && i < WIND_RECORD_COUNT - 1) i++;
770 if (i == WIND_RECORD_COUNT - 1) {
774 wxDateTime localTime(m_ArrayRecTime[i]);
775 min = localTime.GetMinute();
776 hour = localTime.GetHour();
779 wxString statistics =
780 wxString::Format(_(
" Max %.1f %s since %02d:%02d Overall %.1f"),
781 m_MaxWindSpd, m_WindSpeedUnit.c_str(), hour, min,
782 m_TotalMaxWindSpd, m_WindSpeedUnit.c_str());
784 dc->GetTextExtent(statistics, &statw, &stath,
nullptr,
nullptr, &f);
786 (m_WindowRect.width - m_LeftLegend - speedw - degw - m_RightLegend);
788 dc->DrawText(statistics, speedw + m_LeftLegend, 3);
790 dc->GetTextExtent(statistics.Left(12), &statw, &stath,
nullptr,
nullptr,
793 dc->DrawText(statistics.Left(12), speedw + m_LeftLegend, 3);
796 pen.SetStyle(wxPENSTYLE_SOLID);
798#if wxCHECK_VERSION(3, 1, 6)
800 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetRed();
802 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetGreen();
804 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetBlue();
807 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Red();
809 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Green();
811 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Blue();
813 pen.SetColour(wxColour(r, g, b, 96));
815 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
816 GetColourSchemeFont(g_pFontLabel->GetColour()))
817 pen.SetColour(wxColour(61, 61, 204, 96));
819#if wxCHECK_VERSION(3, 1, 6)
820 unsigned int r = GetColourSchemeFont(g_pFontLabel->GetColour()).GetRed();
822 GetColourSchemeFont(g_pFontLabel->GetColour()).GetGreen();
823 unsigned int b = GetColourSchemeFont(g_pFontLabel->GetColour()).GetBlue();
825 unsigned int r = GetColourSchemeFont(g_pFontLabel->GetColour()).Red();
826 unsigned int g = GetColourSchemeFont(g_pFontLabel->GetColour()).Green();
827 unsigned int b = GetColourSchemeFont(g_pFontLabel->GetColour()).Blue();
829 pen.SetColour(wxColour(r, g, b, 96));
835 ratioH = (double)m_DrawAreaRect.height / m_MaxWindSpdScale;
836 wxPoint pointsSpd[WIND_RECORD_COUNT + 2];
837 wxPoint spdDraw[WIND_RECORD_COUNT + 2];
844 spdDraw[ls].x =
static_cast<int>(1 * m_ratioW + 3 + m_LeftLegend);
845 spdDraw[ls].y =
static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
846 m_ArrayWindSpdHistory[1] * ratioH);
848 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
849 pointsSpd[idx].x =
static_cast<int>(idx * m_ratioW + 3 + m_LeftLegend);
851 static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
852 m_ArrayWindSpdHistory[idx] * ratioH);
853 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
854 pointsSpd[idx].y > m_TopLineHeight &&
855 pointsSpd[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
856 spdDraw[ls] = pointsSpd[idx];
860 if (ls > 1) dc->DrawLines(ls, spdDraw);
865 pen.SetStyle(wxPENSTYLE_SOLID);
867 pen.SetColour(GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()));
869 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
870 GetColourSchemeFont(g_pFontLabel->GetColour()))
871 pen.SetColour(wxColour(61, 61, 204, 255));
873 pen.SetColour(GetColourSchemeFont(g_pFontLabel->GetColour()));
879 spdDraw[ls].x =
static_cast<int>(1 * m_ratioW + 3 + m_LeftLegend);
880 spdDraw[ls].y =
static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
881 m_ExpSmoothArrayWindSpd[1] * ratioH);
883 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
884 pointsSpd[idx].x =
static_cast<int>(idx * m_ratioW + 3 + m_LeftLegend);
886 static_cast<int>(m_TopLineHeight + m_DrawAreaRect.height -
887 m_ExpSmoothArrayWindSpd[idx] * ratioH);
888 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
889 pointsSpd[idx].y > m_TopLineHeight &&
890 pointsSpd[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
891 spdDraw[ls] = pointsSpd[idx];
895 if (ls > 1) dc->DrawLines(ls, spdDraw);
900 GetGlobalColor(
"DASHL", &col);
902 pen.SetStyle(wxPENSTYLE_DOT);
904 dc->SetTextForeground(col);
905 dc->SetFont((g_pFontSmall->GetChosenFont()));
908 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
909 if (m_ArrayRecTime[idx].year != 999) {
910 wxDateTime localTime(m_ArrayRecTime[idx]);
911 hour = localTime.GetHour();
912 min = localTime.GetMinute();
913 if ((hour * 100 + min) != done && (min % 15 == 0)) {
914 pointTime.x =
static_cast<int>(idx * m_ratioW + 3 + m_LeftLegend);
915 dc->DrawLine(pointTime.x, m_TopLineHeight + 1, pointTime.x,
916 (m_TopLineHeight + m_DrawAreaRect.height + 1));
917 label.Printf(
"%02d:%02d", hour, min);
918 f = g_pFontSmall->GetChosenFont();
919 dc->GetTextExtent(label, &width, &height,
nullptr,
nullptr, &f);
920 dc->DrawText(label, pointTime.x - width / 2,
921 m_WindowRect.height - height);
922 done = hour * 100 + min;
@ OCPN_DBP_STC_TWD
True Wind Direction (from NMEA device if available, otherwise TWA + magnetic variation)
@ OCPN_DBP_STC_TWS
True wind speed.
Dashboard wind history instrument.