41#include "wx/tokenzr.h"
46DashboardInstrument_Wind::DashboardInstrument_Wind(
47 wxWindow* parent, wxWindowID
id, wxString title,
51 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
53 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
54 "",
"150",
"120",
"90",
"60",
"30"};
55 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
58void DashboardInstrument_Wind::DrawBackground(wxGCDC* dc) {
59 DrawBoat(dc, m_cx, m_cy, m_radius);
62DashboardInstrument_WindCompass::DashboardInstrument_WindCompass(
63 wxWindow* parent, wxWindowID
id, wxString title,
67 SetOptionMarker(5, DIAL_MARKER_SIMPLE, 2);
68 wxString labels[] = {_(
"N"), _(
"NE"), _(
"E"), _(
"SE"),
69 _(
"S"), _(
"SW"), _(
"W"), _(
"NW")};
70 SetOptionLabel(45, DIAL_LABEL_HORIZONTAL, wxArrayString(8, labels));
73void DashboardInstrument_WindCompass::DrawBackground(wxGCDC* dc) {
74 DrawCompassRose(dc, m_cx, m_cy, m_radius * 0.85, m_AngleStart,
false,
81DashboardInstrument_TrueWindAngle::DashboardInstrument_TrueWindAngle(
82 wxWindow* parent, wxWindowID
id, wxString title,
86 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
88 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
89 "",
"150",
"120",
"90",
"60",
"30"};
90 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
93void DashboardInstrument_TrueWindAngle::DrawBackground(wxGCDC* dc) {
94 DrawBoat(dc, m_cx, m_cy, m_radius);
101DashboardInstrument_AppTrueWindAngle::DashboardInstrument_AppTrueWindAngle(
102 wxWindow* parent, wxWindowID
id, wxString title,
106 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
108 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
109 "",
"150",
"120",
"90",
"60",
"30"};
110 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
113void DashboardInstrument_AppTrueWindAngle::DrawBackground(wxGCDC* dc) {
114 DrawBoat(dc, m_cx, m_cy, m_radius);
117void DashboardInstrument_AppTrueWindAngle::SetData(DASH_CAP st,
double data,
119 if (st == OCPN_DBP_STC_TWA) {
120 m_MainValueTrue = data;
121 m_MainValueTrueUnit =
unit;
122 m_MainValueOption2 = DIAL_POSITION_BOTTOMLEFT;
123 }
else if (st == OCPN_DBP_STC_AWA) {
124 m_MainValueApp = data;
125 m_MainValueAppUnit =
unit;
126 m_MainValueOption1 = DIAL_POSITION_TOPLEFT;
127 }
else if (st == OCPN_DBP_STC_AWS) {
128 m_ExtraValueApp = data;
129 m_ExtraValueAppUnit =
unit;
130 m_ExtraValueOption1 = DIAL_POSITION_TOPRIGHT;
131 }
else if (st == OCPN_DBP_STC_TWS) {
132 m_ExtraValueTrue = data;
133 m_ExtraValueTrueUnit =
unit;
134 m_ExtraValueOption2 = DIAL_POSITION_BOTTOMRIGHT;
138void DashboardInstrument_AppTrueWindAngle::Draw(wxGCDC* bdc) {
141 GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour));
143 GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour));
146 GetGlobalColor(
"DASHB", &c1);
148 bdc->SetBackground(b1);
152 wxSize size = GetClientSize();
156 f = m_Properties->m_LabelFont.GetChosenFont();
158 f = g_pFontLabel->GetChosenFont();
159 bdc->GetTextExtent(
"000", &width, &height, 0, 0, &f);
161 int availableHeight = GetDataBottom(size.y) - m_DataTop;
162 InitTitleAndDataPosition(availableHeight);
163 availableHeight -= height;
164 m_cy = m_DataTop + height / 2;
165 m_cy += availableHeight / 2;
166 m_radius = availableHeight / 2.0 * 0.95;
172 DrawData(bdc, m_MainValueApp, m_MainValueAppUnit, m_MainValueFormat,
174 DrawData(bdc, m_MainValueTrue, m_MainValueTrueUnit, m_MainValueFormat,
176 DrawData(bdc, m_ExtraValueApp, m_ExtraValueAppUnit, m_ExtraValueFormat,
177 m_ExtraValueOption1);
178 DrawData(bdc, m_ExtraValueTrue, m_ExtraValueTrueUnit, m_ExtraValueFormat,
179 m_ExtraValueOption2);
182void DashboardInstrument_AppTrueWindAngle::DrawForeground(wxGCDC* dc) {
189 GetGlobalColor(
"DASH2", &cl);
191 pen1.SetStyle(wxPENSTYLE_SOLID);
195 GetGlobalColor(
"DASH1", &cl);
197 brush1.SetStyle(wxBRUSHSTYLE_SOLID);
198 brush1.SetColour(cl);
199 dc->SetBrush(brush1);
200 dc->DrawCircle(m_cx, m_cy, m_radius / 8);
203 dc->SetPen(*wxTRANSPARENT_PEN);
205 cl = GetColourSchemeFont(m_Properties->m_Arrow_Second_Colour);
207 GetGlobalColor(
"BLUE3", &cl);
209 brush2.SetStyle(wxBRUSHSTYLE_SOLID);
210 brush2.SetColour(cl);
211 dc->SetBrush(brush2);
215 if (m_MainValueTrueUnit ==
"\u00B0L")
216 data = 360 - m_MainValueTrue;
218 data = m_MainValueTrue;
221 if (data < m_MainValueMin)
222 val = m_MainValueMin;
223 else if (data > m_MainValueMax)
224 val = m_MainValueMax;
228 value = deg2rad((val - m_MainValueMin) * m_AngleRange /
229 (m_MainValueMax - m_MainValueMin)) +
230 deg2rad(m_AngleStart - ANGLE_OFFSET);
232 points[0].x = m_cx + (m_radius * 0.95 * cos(value - .010));
233 points[0].y = m_cy + (m_radius * 0.95 * sin(value - .010));
234 points[1].x = m_cx + (m_radius * 0.95 * cos(value + .015));
235 points[1].y = m_cy + (m_radius * 0.95 * sin(value + .015));
236 points[2].x = m_cx + (m_radius * 0.22 * cos(value + 2.8));
237 points[2].y = m_cy + (m_radius * 0.22 * sin(value + 2.8));
238 points[3].x = m_cx + (m_radius * 0.22 * cos(value - 2.8));
239 points[3].y = m_cy + (m_radius * 0.22 * sin(value - 2.8));
240 dc->DrawPolygon(4, points, 0, 0);
243 dc->SetPen(*wxTRANSPARENT_PEN);
245 cl = GetColourSchemeFont(m_Properties->m_Arrow_First_Colour);
247 GetGlobalColor(
"DASHN", &cl);
249 brush.SetStyle(wxBRUSHSTYLE_SOLID);
255 if (m_MainValueAppUnit ==
"\u00B0L")
256 data = 360 - m_MainValueApp;
258 data = m_MainValueApp;
261 if (data < m_MainValueMin)
262 val = m_MainValueMin;
263 else if (data > m_MainValueMax)
264 val = m_MainValueMax;
268 value = deg2rad((val - m_MainValueMin) * m_AngleRange /
269 (m_MainValueMax - m_MainValueMin)) +
270 deg2rad(m_AngleStart - ANGLE_OFFSET);
272 points[0].x = m_cx + (m_radius * 0.95 * cos(value - .010));
273 points[0].y = m_cy + (m_radius * 0.95 * sin(value - .010));
274 points[1].x = m_cx + (m_radius * 0.95 * cos(value + .015));
275 points[1].y = m_cy + (m_radius * 0.95 * sin(value + .015));
276 points[2].x = m_cx + (m_radius * 0.22 * cos(value + 2.8));
277 points[2].y = m_cy + (m_radius * 0.22 * sin(value + 2.8));
278 points[3].x = m_cx + (m_radius * 0.22 * cos(value - 2.8));
279 points[3].y = m_cy + (m_radius * 0.22 * sin(value - 2.8));
280 dc->DrawPolygon(4, points, 0, 0);
282void DashboardInstrument_AppTrueWindAngle::DrawData(
283 wxGCDC* dc,
double value, wxString
unit, wxString format,
284 DialPositionOption position) {
285 if (position == DIAL_POSITION_NONE)
return;
289 dc->SetFont(m_Properties->m_LabelFont.GetChosenFont());
290 cl = GetColourSchemeFont(m_Properties->m_LabelFont.GetColour());
292 dc->SetFont(g_pFontLabel->GetChosenFont());
293 cl = GetColourSchemeFont(g_pFontLabel->GetColour());
296 dc->SetTextForeground(cl);
298 wxSize size = GetClientSize();
301 if (!std::isnan(value)) {
302 if (
unit ==
"\u00B0")
303 text = wxString::Format(format, value) + DEGREE_SIGN;
304 else if (
unit ==
"\u00B0L")
306 text = wxString::Format(format, value) + DEGREE_SIGN;
307 else if (
unit ==
"\u00B0R")
308 text = wxString::Format(format, value) + DEGREE_SIGN;
309 else if (
unit ==
"\u00B0T")
310 text = wxString::Format(format, value) + DEGREE_SIGN +
"T";
311 else if (
unit ==
"\u00B0M")
312 text = wxString::Format(format, value) + DEGREE_SIGN +
"M";
313 else if (
unit ==
"N")
314 text = wxString::Format(format, value) +
" Kts";
316 text = wxString::Format(format, value) +
" " +
unit;
323 f = m_Properties->m_LabelFont.GetChosenFont();
325 f = g_pFontLabel->GetChosenFont();
326 dc->GetMultiLineTextExtent(text, &width, &height, NULL, &f);
329 TextPoint.width = width;
330 TextPoint.height = height;
334 case DIAL_POSITION_NONE:
338 case DIAL_POSITION_INSIDE: {
339 TextPoint.x = m_cx - (width / 2) - 1;
340 TextPoint.y = ((size.y - m_InstrumentSpacing) * .75) - height;
341 if ((g_TitleAlignment & wxALIGN_BOTTOM) != 0)
342 TextPoint.y -= m_TitleHeight;
343 GetGlobalColor(
"DASHL", &cl);
344 int penwidth = size.x / 100;
346 wxThePenList->FindOrCreatePen(cl, penwidth, wxPENSTYLE_SOLID);
348 GetGlobalColor(
"DASHB", &cl);
352 dc->DrawRoundedRectangle(TextPoint.x - 2, TextPoint.y - 2, width + 4,
356 case DIAL_POSITION_TOPLEFT:
357 GetGlobalColor(
"DASHN", &c3);
359 TextPoint.y = m_DataTop;
362 case DIAL_POSITION_TOPRIGHT:
363 GetGlobalColor(
"DASHN", &c3);
364 TextPoint.x = size.x - width - 1;
365 TextPoint.y = m_DataTop;
367 case DIAL_POSITION_BOTTOMLEFT:
368 GetGlobalColor(
"BLUE3", &c3);
371 TextPoint.y = GetDataBottom(size.y) - height;
373 case DIAL_POSITION_BOTTOMRIGHT:
374 GetGlobalColor(
"BLUE3", &c3);
375 TextPoint.x = size.x - width - 1;
376 TextPoint.y = GetDataBottom(size.y) - height;
382 GetGlobalColor(
"DASHB", &c2);
383 wxStringTokenizer tkz(text,
"\n");
386 token = tkz.GetNextToken();
387 while (token.Length()) {
389 f = m_Properties->m_LabelFont.GetChosenFont();
390 dc->GetTextExtent(token, &width, &height, NULL, NULL, &f);
392 f = g_pFontLabel->GetChosenFont();
393 dc->GetTextExtent(token, &width, &height, NULL, NULL, &f);
395 dc->DrawText(token, TextPoint.x, TextPoint.y);
396 TextPoint.y += height;
397 token = tkz.GetNextToken();