34#include "wind_history.h"
44DashboardInstrument_WindDirHistory::DashboardInstrument_WindDirHistory(
45 wxWindow* parent, wxWindowID
id, wxString title,
48 m_cap_flag.set(OCPN_DBP_STC_TWS);
49 SetDrawSoloInPane(
true);
54 m_WindSpeedUnit = _(
"-");
55 m_TotalMaxWindSpd = 0;
62 f = m_Properties->m_DataFont.GetChosenFont();
64 f = g_pFontData->GetChosenFont();
65 dc.GetTextExtent(
"TWS----", &w, &h, 0, 0, &f);
66 m_TopLineHeight = wxMax(30, h);
76 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
77 m_ArrayWindDirHistory[idx] = -1;
78 m_ArrayWindSpdHistory[idx] = -1;
79 m_ExpSmoothArrayWindSpd[idx] = -1;
80 m_ExpSmoothArrayWindDir[idx] = -1;
81 m_ArrayRecTime[idx] = wxDateTime::Now().GetTm();
82 m_ArrayRecTime[idx].year = 999;
85 m_WindowRect = GetClientRect();
86 m_DrawAreaRect = GetClientRect();
87 m_DrawAreaRect.SetHeight(m_WindowRect.height - m_TopLineHeight -
91wxSize DashboardInstrument_WindDirHistory::GetSize(
int orient, wxSize hint) {
96 f = m_Properties->m_TitleFont.GetChosenFont();
98 f = g_pFontTitle->GetChosenFont();
100 wxString widthdummy =
"Left Space TWS 25.5 kn TWD 320 right s";
101 dc.GetTextExtent(widthdummy, &w, &m_TitleHeight, 0, 0, &f);
102 if (orient == wxHORIZONTAL) {
103 return wxSize(DefaultWidth, wxMax(m_TitleHeight + 140, hint.y));
105 return wxSize(wxMax(hint.x, w), wxMax(m_TitleHeight + 140, hint.y));
109void DashboardInstrument_WindDirHistory::SetData(DASH_CAP st,
double data,
111 if (st == OCPN_DBP_STC_TWD || st == OCPN_DBP_STC_TWS) {
112 if (m_SetNewData < 1) {
113 if (st == OCPN_DBP_STC_TWD) {
114 if (std::isnan(data)) {
117 m_WindSpd = m_WindDir = NAN;
120 if (m_DirRecCnt <= 5) {
121 m_DirStartVal += data;
126 if (st == OCPN_DBP_STC_TWS && !std::isnan(data) && data < 200.0) {
129 if (
unit != m_WindSpeedUnit && m_WindSpeedUnit != _(
"-")) {
132 m_WindSpeedUnit =
unit;
133 if (m_SpdRecCnt <= 5) {
134 m_SpdStartVal += data;
138 if (m_SpdRecCnt == 5 && m_DirRecCnt == 5) {
139 m_WindSpd = m_SpdStartVal / 5;
140 m_WindDir = m_DirStartVal / 5;
141 m_oldDirVal = m_WindDir;
146 if (m_SpdRecCnt > 5 && m_DirRecCnt > 5) {
148 m_SampleCount = m_SampleCount < WIND_RECORD_COUNT ? m_SampleCount + 1
154 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
155 if (WIND_RECORD_COUNT - m_SampleCount <= idx)
156 m_MinWindDir = wxMin(m_ArrayWindDirHistory[idx], m_MinWindDir);
157 m_MaxWindDir = wxMax(m_ArrayWindDirHistory[idx - 1], m_MaxWindDir);
158 m_MaxWindSpd = wxMax(m_ArrayWindSpdHistory[idx - 1], m_MaxWindSpd);
159 m_ArrayWindDirHistory[idx - 1] = m_ArrayWindDirHistory[idx];
160 m_ArrayWindSpdHistory[idx - 1] = m_ArrayWindSpdHistory[idx];
161 m_ExpSmoothArrayWindSpd[idx - 1] = m_ExpSmoothArrayWindSpd[idx];
162 m_ExpSmoothArrayWindDir[idx - 1] = m_ExpSmoothArrayWindDir[idx];
163 m_ArrayRecTime[idx - 1] = m_ArrayRecTime[idx];
165 double diff = m_WindDir - m_oldDirVal;
168 }
else if (diff > 270) {
171 m_ArrayWindDirHistory[WIND_RECORD_COUNT - 1] = m_WindDir;
172 m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 1] = m_WindSpd;
173 if (m_SampleCount < 2) {
174 m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 2] = m_WindSpd;
175 m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 2] = m_WindSpd;
176 m_ArrayWindDirHistory[WIND_RECORD_COUNT - 2] = m_WindDir;
177 m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 2] = m_WindDir;
179 m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 1] =
180 alpha * m_ArrayWindSpdHistory[WIND_RECORD_COUNT - 2] +
181 (1 - alpha) * m_ExpSmoothArrayWindSpd[WIND_RECORD_COUNT - 2];
182 m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 1] =
183 alpha * m_ArrayWindDirHistory[WIND_RECORD_COUNT - 2] +
184 (1 - alpha) * m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 2];
185 m_ArrayRecTime[WIND_RECORD_COUNT - 1] = wxDateTime::Now().GetTm();
186 m_oldDirVal = m_ExpSmoothArrayWindDir[WIND_RECORD_COUNT - 1];
188 m_MaxWindDir = wxMax(m_WindDir, m_MaxWindDir);
189 m_MinWindDir = wxMin(m_WindDir, m_MinWindDir);
190 m_MaxWindSpd = wxMax(m_WindSpd, m_MaxWindSpd);
192 m_TotalMaxWindSpd = wxMax(m_WindSpd, m_TotalMaxWindSpd);
196 SetMinMaxWindScale();
205void DashboardInstrument_WindDirHistory::ResetData() {
210 m_TotalMaxWindSpd = 0;
221 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
222 m_ArrayWindDirHistory[idx] = -1;
223 m_ArrayWindSpdHistory[idx] = -1;
224 m_ExpSmoothArrayWindSpd[idx] = -1;
225 m_ExpSmoothArrayWindDir[idx] = -1;
226 m_ArrayRecTime[idx] = wxDateTime::Now().GetTm();
227 m_ArrayRecTime[idx].year = 999;
231void DashboardInstrument_WindDirHistory::Draw(wxGCDC* dc) {
232 m_WindowRect = GetClientRect();
233 m_DrawAreaRect = GetClientRect();
234 m_DrawAreaRect.SetHeight(m_WindowRect.height - m_TopLineHeight -
236 m_DrawAreaRect.SetX(m_LeftLegend + 3);
244void DashboardInstrument_WindDirHistory::SetMinMaxWindScale() {
249 int fulldeg = m_MaxWindDir / 90;
252 fulldeg = m_MaxWindDir < 0 ? 0 : 1;
253 else if (m_MaxWindDir > 0)
255 m_MaxWindDir = fulldeg * 90;
257 fulldeg = m_MinWindDir / 90;
259 fulldeg = m_MinWindDir < 0 ? -1 : 0;
261 fulldeg = m_MinWindDir > 0 ? fulldeg : (fulldeg - 1);
262 m_MinWindDir = fulldeg * 90;
266 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
267 if (m_WindDirRange > 360) {
269 m_WindDir - m_MinWindDir;
271 m_MaxWindDir - m_WindDir;
272 if (diff2min > diff2max) {
273 while (m_WindDirRange > 360) {
275 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
278 if (diff2min < diff2max) {
279 while (m_WindDirRange > 360) {
281 m_WindDirRange = m_MaxWindDir - m_MinWindDir;
289void DashboardInstrument_WindDirHistory::DrawWindDirScale(wxGCDC* dc) {
290 wxString label1, label2, label3, label4, label5;
294 cl = wxColour(204, 41, 41, 255);
296 dc->SetTextForeground(
297 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
298 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
300 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
301 dc->SetFont(g_pFontSmall->GetChosenFont());
311 double tempdir = m_MinWindDir;
312 while (tempdir < 0) tempdir += 360;
313 while (tempdir >= 360) tempdir -= 360;
314 label1 = GetWindDirStr(wxString::Format(_T(
"%.1f"), tempdir));
316 tempdir = m_MinWindDir + m_WindDirRange / 4.;
317 while (tempdir < 0) tempdir += 360;
318 while (tempdir >= 360) tempdir -= 360;
319 label2 = GetWindDirStr(wxString::Format(_T(
"%.1f"), tempdir));
321 tempdir = m_MinWindDir + m_WindDirRange / 2;
322 while (tempdir < 0) tempdir += 360;
323 while (tempdir >= 360) tempdir -= 360;
324 label3 = GetWindDirStr(wxString::Format(_T(
"%.1f"), tempdir));
326 tempdir = m_MinWindDir + m_WindDirRange * 0.75;
327 while (tempdir < 0) tempdir += 360;
328 while (tempdir >= 360) tempdir -= 360;
329 label4 = GetWindDirStr(wxString::Format(_T(
"%.1f"), tempdir));
331 tempdir = m_MaxWindDir;
332 while (tempdir < 0) tempdir += 360;
333 while (tempdir >= 360) tempdir -= 360;
334 label5 = GetWindDirStr(wxString::Format(_T(
"%.1f"), tempdir));
341 f = m_Properties->m_SmallFont.GetChosenFont();
342 dc->GetTextExtent(label5, &width, &height, 0, 0, &f);
343 m_RightLegend = width;
344 dc->GetTextExtent(label4, &width, &height, 0, 0, &f);
345 m_RightLegend = wxMax(width, m_RightLegend);
346 dc->GetTextExtent(label3, &width, &height, 0, 0, &f);
347 m_RightLegend = wxMax(width, m_RightLegend);
348 dc->GetTextExtent(label2, &width, &height, 0, 0, &f);
349 m_RightLegend = wxMax(width, m_RightLegend);
350 dc->GetTextExtent(label1, &width, &height, 0, 0, &f);
351 m_RightLegend = wxMax(width, m_RightLegend);
353 f = g_pFontSmall->GetChosenFont();
354 dc->GetTextExtent(label5, &width, &height, 0, 0, &f);
355 m_RightLegend = width;
356 dc->GetTextExtent(label4, &width, &height, 0, 0, &f);
357 m_RightLegend = wxMax(width, m_RightLegend);
358 dc->GetTextExtent(label3, &width, &height, 0, 0, &f);
359 m_RightLegend = wxMax(width, m_RightLegend);
360 dc->GetTextExtent(label2, &width, &height, 0, 0, &f);
361 m_RightLegend = wxMax(width, m_RightLegend);
362 dc->GetTextExtent(label1, &width, &height, 0, 0, &f);
363 m_RightLegend = wxMax(width, m_RightLegend);
366 dc->DrawText(label5, m_WindowRect.width - m_RightLegend,
367 m_TopLineHeight - height / 2);
368 dc->DrawText(label4, m_WindowRect.width - m_RightLegend,
369 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 4 - height / 2));
370 dc->DrawText(label3, m_WindowRect.width - m_RightLegend,
371 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 2 - height / 2));
373 label2, m_WindowRect.width - m_RightLegend,
374 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75 - height / 2));
375 dc->DrawText(label1, m_WindowRect.width - m_RightLegend,
376 (
int)(m_TopLineHeight + m_DrawAreaRect.height - height / 2));
382void DashboardInstrument_WindDirHistory::DrawWindSpeedScale(wxGCDC* dc) {
383 wxString label1, label2, label3, label4, label5;
391 dc->SetTextForeground(
392 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
393 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
395 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
396 dc->SetFont(g_pFontSmall->GetChosenFont());
399 m_MaxWindSpdScale = (int)m_MaxWindSpd + 1;
401 label1.Printf(_(
"--- %s"), m_WindSpeedUnit.c_str());
414 label1.Printf(_T(
"%.0f %s"), m_MaxWindSpdScale, m_WindSpeedUnit.c_str());
416 WindSpdScale = m_MaxWindSpdScale * 3. / 4.;
418 val1 = (int)((WindSpdScale - (
int)WindSpdScale) * 100);
419 if (val1 == 25 || val1 == 75)
420 label2.Printf(_T(
"%.2f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
422 label2.Printf(_T(
"%.1f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
424 label2.Printf(_T(
"%.0f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
426 WindSpdScale = m_MaxWindSpdScale / 2.;
428 if ((
int)(WindSpdScale * 10) % 10 == 5)
429 label3.Printf(_T(
"%.1f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
431 label3.Printf(_T(
"%.0f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
434 WindSpdScale = m_MaxWindSpdScale / 4.;
436 val1 = (int)((WindSpdScale - (
int)WindSpdScale) * 100);
437 if (val1 == 25 || val1 == 75)
438 label4.Printf(_T(
"%.2f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
440 label4.Printf(_T(
"%.1f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
442 label4.Printf(_T(
"%.0f %s"), WindSpdScale, m_WindSpeedUnit.c_str());
445 label5.Printf(_T(
"%.0f %s"), 0.0, m_WindSpeedUnit.c_str());
449 f = m_Properties->m_SmallFont.GetChosenFont();
451 f = g_pFontSmall->GetChosenFont();
452 dc->GetTextExtent(label1, &m_LeftLegend, &height, 0, 0, &f);
453 dc->DrawText(label1, 4, (
int)(m_TopLineHeight - height / 2));
455 f = m_Properties->m_SmallFont.GetChosenFont();
457 f = g_pFontSmall->GetChosenFont();
458 dc->GetTextExtent(label2, &width, &height, 0, 0, &f);
459 dc->DrawText(label2, 4,
460 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 4 - height / 2));
461 m_LeftLegend = wxMax(width, m_LeftLegend);
463 f = m_Properties->m_SmallFont.GetChosenFont();
465 f = g_pFontSmall->GetChosenFont();
466 dc->GetTextExtent(label3, &width, &height, 0, 0, &f);
467 dc->DrawText(label3, 4,
468 (
int)(m_TopLineHeight + m_DrawAreaRect.height / 2 - height / 2));
469 m_LeftLegend = wxMax(width, m_LeftLegend);
471 f = m_Properties->m_SmallFont.GetChosenFont();
473 f = g_pFontSmall->GetChosenFont();
474 dc->GetTextExtent(label4, &width, &height, 0, 0, &f);
477 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75 - height / 2));
478 m_LeftLegend = wxMax(width, m_LeftLegend);
480 f = m_Properties->m_SmallFont.GetChosenFont();
482 f = g_pFontSmall->GetChosenFont();
483 dc->GetTextExtent(label5, &width, &height, 0, 0, &f);
484 dc->DrawText(label5, 4,
485 (
int)(m_TopLineHeight + m_DrawAreaRect.height - height / 2));
486 m_LeftLegend = wxMax(width, m_LeftLegend);
493void DashboardInstrument_WindDirHistory::DrawBackground(wxGCDC* dc) {
494 wxString label, label1, label2, label3, label4, label5;
500 DrawWindDirScale(dc);
501 DrawWindSpeedScale(dc);
506 GetGlobalColor(_T(
"UBLCK"), &cl);
509 dc->DrawLine(m_LeftLegend + 3, m_TopLineHeight,
510 m_WindowRect.width - 3 - m_RightLegend,
512 dc->DrawLine(m_LeftLegend + 3, (
int)(m_TopLineHeight + m_DrawAreaRect.height),
513 m_WindowRect.width - 3 - m_RightLegend,
514 (
int)(m_TopLineHeight + m_DrawAreaRect.height));
515 pen.SetStyle(wxPENSTYLE_DOT);
517 dc->DrawLine(m_LeftLegend + 3,
518 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.25),
519 m_WindowRect.width - 3 - m_RightLegend,
520 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.25));
521 dc->DrawLine(m_LeftLegend + 3,
522 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75),
523 m_WindowRect.width - 3 - m_RightLegend,
524 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.75));
526 pen.SetStyle(wxPENSTYLE_SHORT_DASH);
529 dc->DrawLine(m_LeftLegend + 3,
530 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.5),
531 m_WindowRect.width - 3 - m_RightLegend,
532 (
int)(m_TopLineHeight + m_DrawAreaRect.height * 0.5));
539wxString DashboardInstrument_WindDirHistory::GetWindDirStr(wxString WindDir) {
540 if (WindDir == _T(
"0.0") || WindDir == _T(
"360.0"))
542 else if (WindDir == _T(
"22.5"))
544 else if (WindDir == _T(
"45.0"))
546 else if (WindDir == _T(
"67.5"))
548 else if (WindDir == _T(
"90.0"))
550 else if (WindDir == _T(
"112.5"))
552 else if (WindDir == _T(
"135.0"))
554 else if (WindDir == _T(
"157.5"))
556 else if (WindDir == _T(
"180.0"))
558 else if (WindDir == _T(
"202.5"))
560 else if (WindDir == _T(
"225.0"))
562 else if (WindDir == _T(
"247.5"))
564 else if (WindDir == _T(
"270.0"))
566 else if (WindDir == _T(
"292.5"))
568 else if (WindDir == _T(
"315.0"))
570 else if (WindDir == _T(
"337.5"))
579void DashboardInstrument_WindDirHistory::DrawForeground(wxGCDC* dc) {
582 int width, height, min, hour;
584 wxString WindAngle, WindSpeed;
591 dc->SetFont((g_pFontSmall->GetChosenFont()));
592 col = wxColour(204, 41, 41, 255);
595 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
596 dc->SetTextForeground(
597 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
599 dc->SetFont(g_pFontSmall->GetChosenFont());
600 if (GetColourSchemeFont(g_pFontLabel->GetColour()) ==
601 GetColourSchemeFont(g_pFontLabel->GetColour()))
602 dc->SetTextForeground(col);
604 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
607 WindAngle = _T(
"TWD --- ");
610 while (dir > 360) dir -= 360;
611 while (dir < 0) dir += 360;
612 if (!std::isnan(dir))
613 WindAngle = wxString::Format(_T(
"TWD %3.0f"), dir) + DEGREE_SIGN;
615 WindAngle = wxString::Format(_T(
"TWD ---")) + DEGREE_SIGN;
619 f = m_Properties->m_SmallFont.GetChosenFont();
621 f = g_pFontLabel->GetChosenFont();
623 dc->GetTextExtent(WindAngle, °w, °h, 0, 0, &f);
624 dc->DrawText(WindAngle, m_WindowRect.width - m_RightLegend - degw, 3);
626 pen.SetStyle(wxPENSTYLE_SOLID);
628#if wxCHECK_VERSION(3, 1, 6)
630 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetRed();
632 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetGreen();
634 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).GetBlue();
637 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Red();
639 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Green();
641 GetColourSchemeFont(m_Properties->m_DataFont.GetColour()).Blue();
643 pen.SetColour(wxColour(r, g, b, 96));
645 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
646 GetColourSchemeFont(g_pFontLabel->GetColour()))
647 pen.SetColour(wxColour(204, 41, 41, 96));
649#if wxCHECK_VERSION(3, 1, 6)
650 unsigned int r = GetColourSchemeFont(g_pFontData->GetColour()).GetRed();
651 unsigned int g = GetColourSchemeFont(g_pFontData->GetColour()).GetGreen();
652 unsigned int b = GetColourSchemeFont(g_pFontData->GetColour()).GetBlue();
654 unsigned int r = GetColourSchemeFont(g_pFontData->GetColour()).Red();
655 unsigned int g = GetColourSchemeFont(g_pFontData->GetColour()).Green();
656 unsigned int b = GetColourSchemeFont(g_pFontData->GetColour()).Blue();
658 pen.SetColour(wxColour(r, g, b, 96));
664 ratioH = (double)m_DrawAreaRect.height / m_WindDirRange;
665 m_DrawAreaRect.SetWidth(m_WindowRect.width - 6 - m_LeftLegend -
667 m_ratioW = double(m_DrawAreaRect.width) / (WIND_RECORD_COUNT - 1);
672 wxPoint points[WIND_RECORD_COUNT + 2];
673 wxPoint wdDraw[WIND_RECORD_COUNT + 2];
675 wdDraw[ld].x = m_ratioW + 3 + m_LeftLegend;
676 wdDraw[ld].y = m_TopLineHeight + m_DrawAreaRect.height -
677 (m_ArrayWindDirHistory[1] - m_MinWindDir) * ratioH;
679 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
680 points[idx].x = idx * m_ratioW + 3 + m_LeftLegend;
681 points[idx].y = m_TopLineHeight + m_DrawAreaRect.height -
682 (m_ArrayWindDirHistory[idx] - m_MinWindDir) * ratioH;
683 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
684 points[idx].y > m_TopLineHeight &&
685 points[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
686 wdDraw[ld] = points[idx];
690 if (ld > 1) dc->DrawLines(ld, wdDraw);
695 pen.SetStyle(wxPENSTYLE_SOLID);
698 pen.SetColour(GetColourSchemeFont(m_Properties->m_DataFont.GetColour()));
700 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
701 GetColourSchemeFont(g_pFontLabel->GetColour()))
702 pen.SetColour(wxColour(204, 41, 41, 255));
704 pen.SetColour(GetColourSchemeFont(g_pFontData->GetColour()));
710 wdDraw[ld].x = m_ratioW + 3 + m_LeftLegend;
711 wdDraw[ld].y = m_TopLineHeight + m_DrawAreaRect.height -
712 (m_ExpSmoothArrayWindDir[ld] - m_MinWindDir) * ratioH;
714 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
715 points[idx].x = idx * m_ratioW + 3 + m_LeftLegend;
716 points[idx].y = m_TopLineHeight + m_DrawAreaRect.height -
717 (m_ExpSmoothArrayWindDir[idx] - m_MinWindDir) * ratioH;
718 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
719 points[idx].y > m_TopLineHeight &&
720 points[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
721 wdDraw[ld] = points[idx];
725 if (ld > 1) dc->DrawLines(ld, wdDraw);
730 col = wxColour(61, 61, 204, 255);
732 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
733 dc->SetTextForeground(
734 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
736 dc->SetFont(g_pFontSmall->GetChosenFont());
737 if (GetColourSchemeFont(g_pFontSmall->GetColour()) ==
738 GetColourSchemeFont(g_pFontSmall->GetColour()))
739 dc->SetTextForeground(col);
741 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
743 if (!std::isnan(m_WindSpd))
744 WindSpeed = wxString::Format(_T(
"TWS %3.1f %s "), m_WindSpd,
745 m_WindSpeedUnit.c_str());
747 WindSpeed = wxString::Format(_T(
"TWS --- %s "), m_WindSpeedUnit.c_str());
749 f = m_Properties->m_LabelFont.GetChosenFont();
750 dc->GetTextExtent(WindSpeed, &speedw, °h, 0, 0, &f);
752 f = g_pFontSmall->GetChosenFont();
753 dc->GetTextExtent(WindSpeed, &speedw, °h, 0, 0, &f);
755 dc->DrawText(WindSpeed, m_LeftLegend, 3);
757 dc->SetFont((g_pFontSmall->GetChosenFont()));
760 f = m_Properties->m_SmallFont.GetChosenFont();
761 dc->GetTextExtent(WindSpeed, &labelw, &labelh, 0, 0, &f);
762 dc->SetFont(m_Properties->m_SmallFont.GetChosenFont());
763 dc->SetTextForeground(
764 GetColourSchemeFont(m_Properties->m_SmallFont.GetColour()));
766 f = g_pFontSmall->GetChosenFont();
767 dc->GetTextExtent(WindSpeed, &labelw, &labelh, 0, 0, &f);
768 dc->SetFont(g_pFontSmall->GetChosenFont());
769 dc->SetTextForeground(GetColourSchemeFont(g_pFontSmall->GetColour()));
773 while (m_ArrayRecTime[i].year == 999 && i < WIND_RECORD_COUNT - 1) i++;
774 if (i == WIND_RECORD_COUNT - 1) {
778 wxDateTime localTime(m_ArrayRecTime[i]);
779 min = localTime.GetMinute();
780 hour = localTime.GetHour();
783 wxString statistics =
784 wxString::Format(_(
" Max %.1f %s since %02d:%02d Overall %.1f"),
785 m_MaxWindSpd, m_WindSpeedUnit.c_str(), hour, min,
786 m_TotalMaxWindSpd, m_WindSpeedUnit.c_str());
788 dc->GetTextExtent(statistics, &statw, &stath, 0, 0, &f);
790 (m_WindowRect.width - m_LeftLegend - speedw - degw - m_RightLegend);
792 dc->DrawText(statistics, speedw + m_LeftLegend, 3);
794 dc->GetTextExtent(statistics.Left(12), &statw, &stath, 0, 0, &f);
796 dc->DrawText(statistics.Left(12), speedw + m_LeftLegend, 3);
799 pen.SetStyle(wxPENSTYLE_SOLID);
801#if wxCHECK_VERSION(3, 1, 6)
803 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetRed();
805 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetGreen();
807 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).GetBlue();
810 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Red();
812 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Green();
814 GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()).Blue();
816 pen.SetColour(wxColour(r, g, b, 96));
818 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
819 GetColourSchemeFont(g_pFontLabel->GetColour()))
820 pen.SetColour(wxColour(61, 61, 204, 96));
822#if wxCHECK_VERSION(3, 1, 6)
823 unsigned int r = GetColourSchemeFont(g_pFontLabel->GetColour()).GetRed();
825 GetColourSchemeFont(g_pFontLabel->GetColour()).GetGreen();
826 unsigned int b = GetColourSchemeFont(g_pFontLabel->GetColour()).GetBlue();
828 unsigned int r = GetColourSchemeFont(g_pFontLabel->GetColour()).Red();
829 unsigned int g = GetColourSchemeFont(g_pFontLabel->GetColour()).Green();
830 unsigned int b = GetColourSchemeFont(g_pFontLabel->GetColour()).Blue();
832 pen.SetColour(wxColour(r, g, b, 96));
838 ratioH = (double)m_DrawAreaRect.height / m_MaxWindSpdScale;
839 wxPoint pointsSpd[WIND_RECORD_COUNT + 2];
840 wxPoint spdDraw[WIND_RECORD_COUNT + 2];
847 spdDraw[ls].x = 1 * m_ratioW + 3 + m_LeftLegend;
848 spdDraw[ls].y = m_TopLineHeight + m_DrawAreaRect.height -
849 m_ArrayWindSpdHistory[1] * ratioH;
851 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
852 pointsSpd[idx].x = idx * m_ratioW + 3 + m_LeftLegend;
853 pointsSpd[idx].y = m_TopLineHeight + m_DrawAreaRect.height -
854 m_ArrayWindSpdHistory[idx] * ratioH;
855 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
856 pointsSpd[idx].y > m_TopLineHeight &&
857 pointsSpd[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
858 spdDraw[ls] = pointsSpd[idx];
862 if (ls > 1) dc->DrawLines(ls, spdDraw);
867 pen.SetStyle(wxPENSTYLE_SOLID);
869 pen.SetColour(GetColourSchemeFont(m_Properties->m_LabelFont.GetColour()));
871 if (GetColourSchemeFont(g_pFontData->GetColour()) ==
872 GetColourSchemeFont(g_pFontLabel->GetColour()))
873 pen.SetColour(wxColour(61, 61, 204, 255));
875 pen.SetColour(GetColourSchemeFont(g_pFontLabel->GetColour()));
881 spdDraw[ls].x = 1 * m_ratioW + 3 + m_LeftLegend;
882 spdDraw[ls].y = m_TopLineHeight + m_DrawAreaRect.height -
883 m_ExpSmoothArrayWindSpd[1] * ratioH;
885 for (
int idx = 1; idx < WIND_RECORD_COUNT; idx++) {
886 pointsSpd[idx].x = idx * m_ratioW + 3 + m_LeftLegend;
887 pointsSpd[idx].y = m_TopLineHeight + m_DrawAreaRect.height -
888 m_ExpSmoothArrayWindSpd[idx] * ratioH;
889 if (WIND_RECORD_COUNT - m_SampleCount <= idx &&
890 pointsSpd[idx].y > m_TopLineHeight &&
891 pointsSpd[idx].y <= m_TopLineHeight + m_DrawAreaRect.height) {
892 spdDraw[ls] = pointsSpd[idx];
896 if (ls > 1) dc->DrawLines(ls, spdDraw);
901 GetGlobalColor(_T(
"DASHL"), &col);
903 pen.SetStyle(wxPENSTYLE_DOT);
905 dc->SetTextForeground(col);
906 dc->SetFont((g_pFontSmall->GetChosenFont()));
909 for (
int idx = 0; idx < WIND_RECORD_COUNT; idx++) {
910 if (m_ArrayRecTime[idx].year != 999) {
911 wxDateTime localTime(m_ArrayRecTime[idx]);
912 hour = localTime.GetHour();
913 min = localTime.GetMinute();
914 if ((hour * 100 + min) != done && (min % 15 == 0)) {
915 pointTime.x = idx * m_ratioW + 3 + m_LeftLegend;
916 dc->DrawLine(pointTime.x, m_TopLineHeight + 1, pointTime.x,
917 (m_TopLineHeight + m_DrawAreaRect.height + 1));
918 label.Printf(_T(
"%02d:%02d"), hour, min);
919 f = g_pFontSmall->GetChosenFont();
920 dc->GetTextExtent(label, &width, &height, 0, 0, &f);
921 dc->DrawText(label, pointTime.x - width / 2,
922 m_WindowRect.height - height);
923 done = hour * 100 + min;