33#include <wx/tokenzr.h>
40DashboardInstrument_Wind::DashboardInstrument_Wind(
41 wxWindow* parent, wxWindowID
id, wxString title,
44 cap_flag, 0, 360, 0, 360) {
45 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
47 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
48 "",
"150",
"120",
"90",
"60",
"30"};
49 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
52void DashboardInstrument_Wind::DrawBackground(wxGCDC* dc) {
53 DrawBoat(dc, m_cx, m_cy, m_radius);
56DashboardInstrument_WindCompass::DashboardInstrument_WindCompass(
57 wxWindow* parent, wxWindowID
id, wxString title,
60 cap_flag, 0, 360, 0, 360) {
61 SetOptionMarker(5, DIAL_MARKER_SIMPLE, 2);
62 wxString labels[] = {_(
"N"), _(
"NE"), _(
"E"), _(
"SE"),
63 _(
"S"), _(
"SW"), _(
"W"), _(
"NW")};
64 SetOptionLabel(45, DIAL_LABEL_HORIZONTAL, wxArrayString(8, labels));
67void DashboardInstrument_WindCompass::DrawBackground(wxGCDC* dc) {
68 DrawCompassRose(dc, m_cx, m_cy,
static_cast<int>(m_radius * 0.85),
69 m_angle_start,
false, m_Properties);
75DashboardInstrument_TrueWindAngle::DashboardInstrument_TrueWindAngle(
76 wxWindow* parent, wxWindowID
id, wxString title,
79 cap_flag, 0, 360, 0, 360) {
80 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
82 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
83 "",
"150",
"120",
"90",
"60",
"30"};
84 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
87void DashboardInstrument_TrueWindAngle::DrawBackground(wxGCDC* dc) {
88 DrawBoat(dc, m_cx, m_cy, m_radius);
95DashboardInstrument_AppTrueWindAngle::DashboardInstrument_AppTrueWindAngle(
96 wxWindow* parent, wxWindowID
id, wxString title,
100 SetOptionMarker(10, DIAL_MARKER_REDGREENBAR, 3);
102 wxString labels[] = {
"",
"30",
"60",
"90",
"120",
"150",
103 "",
"150",
"120",
"90",
"60",
"30"};
104 SetOptionLabel(30, DIAL_LABEL_HORIZONTAL, wxArrayString(12, labels));
107void DashboardInstrument_AppTrueWindAngle::DrawBackground(wxGCDC* dc) {
108 DrawBoat(dc, m_cx, m_cy, m_radius);
111void DashboardInstrument_AppTrueWindAngle::SetData(
DASH_CAP st,
double data,
114 m_MainValueTrue = data;
115 m_MainValueTrueUnit =
unit;
116 m_MainValueOption2 = DIAL_POSITION_BOTTOMLEFT;
118 m_MainValueApp = data;
119 m_MainValueAppUnit =
unit;
120 m_MainValueOption1 = DIAL_POSITION_TOPLEFT;
122 m_ExtraValueApp = data;
123 m_ExtraValueAppUnit =
unit;
124 m_ExtraValueOption1 = DIAL_POSITION_TOPRIGHT;
126 m_ExtraValueTrue = data;
127 m_ExtraValueTrueUnit =
unit;
128 m_ExtraValueOption2 = DIAL_POSITION_BOTTOMRIGHT;
132void DashboardInstrument_AppTrueWindAngle::Draw(wxGCDC* bdc) {
135 GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour));
137 GetColourSchemeBackgroundColour(m_Properties->m_DataBackgroundColour));
140 GetGlobalColor(
"DASHB", &c1);
142 bdc->SetBackground(b1);
146 wxSize size = GetClientSize();
150 f = m_Properties->m_LabelFont.GetChosenFont();
152 f = g_pFontLabel->GetChosenFont();
153 bdc->GetTextExtent(
"000", &width, &height,
nullptr,
nullptr, &f);
155 int availableHeight = GetDataBottom(size.y) - m_DataTop;
156 InitTitleAndDataPosition(availableHeight);
157 availableHeight -= height;
158 m_cy = m_DataTop + height / 2;
159 m_cy += availableHeight / 2;
160 m_radius =
static_cast<int>(availableHeight / 2.0 * 0.95);
166 DrawData(bdc, m_MainValueApp, m_MainValueAppUnit, m_main_value_format,
168 DrawData(bdc, m_MainValueTrue, m_MainValueTrueUnit, m_main_value_format,
170 DrawData(bdc, m_ExtraValueApp, m_ExtraValueAppUnit, m_extra_value_format,
171 m_ExtraValueOption1);
172 DrawData(bdc, m_ExtraValueTrue, m_ExtraValueTrueUnit, m_extra_value_format,
173 m_ExtraValueOption2);
176void DashboardInstrument_AppTrueWindAngle::DrawForeground(wxGCDC* dc) {
183 GetGlobalColor(
"DASH2", &cl);
185 pen1.SetStyle(wxPENSTYLE_SOLID);
189 GetGlobalColor(
"DASH1", &cl);
191 brush1.SetStyle(wxBRUSHSTYLE_SOLID);
192 brush1.SetColour(cl);
193 dc->SetBrush(brush1);
194 dc->DrawCircle(m_cx, m_cy, m_radius / 8);
197 dc->SetPen(*wxTRANSPARENT_PEN);
199 cl = GetColourSchemeFont(m_Properties->m_Arrow_Second_Colour);
201 GetGlobalColor(
"BLUE3", &cl);
203 brush2.SetStyle(wxBRUSHSTYLE_SOLID);
204 brush2.SetColour(cl);
205 dc->SetBrush(brush2);
209 if (m_MainValueTrueUnit ==
"\u00B0L")
210 data = 360 - m_MainValueTrue;
212 data = m_MainValueTrue;
215 if (data < m_main_value_min)
216 val = m_main_value_min;
217 else if (data > m_main_value_max)
218 val = m_main_value_max;
222 value = deg2rad((val - m_main_value_min) * m_angle_range /
223 (m_main_value_max - m_main_value_min)) +
224 deg2rad(m_angle_start - ANGLE_OFFSET);
226 points[0].x =
static_cast<int>(m_cx + (m_radius * 0.95 * cos(value - .010)));
227 points[0].y =
static_cast<int>(m_cy + (m_radius * 0.95 * sin(value - .010)));
228 points[1].x =
static_cast<int>(m_cx + (m_radius * 0.95 * cos(value + .015)));
229 points[1].y =
static_cast<int>(m_cy + (m_radius * 0.95 * sin(value + .015)));
230 points[2].x =
static_cast<int>(m_cx + (m_radius * 0.22 * cos(value + 2.8)));
231 points[2].y =
static_cast<int>(m_cy + (m_radius * 0.22 * sin(value + 2.8)));
232 points[3].x =
static_cast<int>(m_cx + (m_radius * 0.22 * cos(value - 2.8)));
233 points[3].y =
static_cast<int>(m_cy + (m_radius * 0.22 * sin(value - 2.8)));
234 dc->DrawPolygon(4, points, 0, 0);
237 dc->SetPen(*wxTRANSPARENT_PEN);
239 cl = GetColourSchemeFont(m_Properties->m_Arrow_First_Colour);
241 GetGlobalColor(
"DASHN", &cl);
243 brush.SetStyle(wxBRUSHSTYLE_SOLID);
249 if (m_MainValueAppUnit ==
"\u00B0L")
250 data = 360 - m_MainValueApp;
252 data = m_MainValueApp;
255 if (data < m_main_value_min)
256 val = m_main_value_min;
257 else if (data > m_main_value_max)
258 val = m_main_value_max;
262 value = deg2rad((val - m_main_value_min) * m_angle_range /
263 (m_main_value_max - m_main_value_min)) +
264 deg2rad(m_angle_start - ANGLE_OFFSET);
266 points[0].x =
static_cast<int>(m_cx + (m_radius * 0.95 * cos(value - .010)));
267 points[0].y =
static_cast<int>(m_cy + (m_radius * 0.95 * sin(value - .010)));
268 points[1].x =
static_cast<int>(m_cx + (m_radius * 0.95 * cos(value + .015)));
269 points[1].y =
static_cast<int>(m_cy + (m_radius * 0.95 * sin(value + .015)));
270 points[2].x =
static_cast<int>(m_cx + (m_radius * 0.22 * cos(value + 2.8)));
271 points[2].y =
static_cast<int>(m_cy + (m_radius * 0.22 * sin(value + 2.8)));
272 points[3].x =
static_cast<int>(m_cx + (m_radius * 0.22 * cos(value - 2.8)));
273 points[3].y =
static_cast<int>(m_cy + (m_radius * 0.22 * sin(value - 2.8)));
274 dc->DrawPolygon(4, points, 0, 0);
276void DashboardInstrument_AppTrueWindAngle::DrawData(
277 wxGCDC* dc,
double value, wxString
unit, wxString format,
278 DialPositionOption position) {
279 if (position == DIAL_POSITION_NONE)
return;
283 dc->SetFont(m_Properties->m_LabelFont.GetChosenFont());
284 cl = GetColourSchemeFont(m_Properties->m_LabelFont.GetColour());
286 dc->SetFont(g_pFontLabel->GetChosenFont());
287 cl = GetColourSchemeFont(g_pFontLabel->GetColour());
290 dc->SetTextForeground(cl);
292 wxSize size = GetClientSize();
295 if (!std::isnan(value)) {
296 if (
unit ==
"\u00B0")
297 text = wxString::Format(format, value) + DEGREE_SIGN;
298 else if (
unit ==
"\u00B0L")
300 text = wxString::Format(format, value) + DEGREE_SIGN;
301 else if (
unit ==
"\u00B0R")
302 text = wxString::Format(format, value) + DEGREE_SIGN;
303 else if (
unit ==
"\u00B0T")
304 text = wxString::Format(format, value) + DEGREE_SIGN +
"T";
305 else if (
unit ==
"\u00B0M")
306 text = wxString::Format(format, value) + DEGREE_SIGN +
"M";
307 else if (
unit ==
"N")
308 text = wxString::Format(format, value) +
" Kts";
310 text = wxString::Format(format, value) +
" " +
unit;
317 f = m_Properties->m_LabelFont.GetChosenFont();
319 f = g_pFontLabel->GetChosenFont();
320 dc->GetMultiLineTextExtent(text, &width, &height,
nullptr, &f);
323 TextPoint.width = width;
324 TextPoint.height = height;
328 case DIAL_POSITION_NONE:
332 case DIAL_POSITION_INSIDE: {
333 TextPoint.x = m_cx - (width / 2) - 1;
334 TextPoint.y = ((size.y - m_InstrumentSpacing) * .75) - height;
335 if ((g_TitleAlignment & wxALIGN_BOTTOM) != 0)
336 TextPoint.y -= m_TitleHeight;
337 GetGlobalColor(
"DASHL", &cl);
338 int penwidth = size.x / 100;
340 wxThePenList->FindOrCreatePen(cl, penwidth, wxPENSTYLE_SOLID);
342 GetGlobalColor(
"DASHB", &cl);
346 dc->DrawRoundedRectangle(TextPoint.x - 2, TextPoint.y - 2, width + 4,
350 case DIAL_POSITION_TOPLEFT:
351 GetGlobalColor(
"DASHN", &c3);
353 TextPoint.y = m_DataTop;
356 case DIAL_POSITION_TOPRIGHT:
357 GetGlobalColor(
"DASHN", &c3);
358 TextPoint.x = size.x - width - 1;
359 TextPoint.y = m_DataTop;
361 case DIAL_POSITION_BOTTOMLEFT:
362 GetGlobalColor(
"BLUE3", &c3);
365 TextPoint.y = GetDataBottom(size.y) - height;
367 case DIAL_POSITION_BOTTOMRIGHT:
368 GetGlobalColor(
"BLUE3", &c3);
369 TextPoint.x = size.x - width - 1;
370 TextPoint.y = GetDataBottom(size.y) - height;
376 GetGlobalColor(
"DASHB", &c2);
377 wxStringTokenizer tkz(text,
"\n");
380 token = tkz.GetNextToken();
381 while (token.Length()) {
383 f = m_Properties->m_LabelFont.GetChosenFont();
384 dc->GetTextExtent(token, &width, &height,
nullptr,
nullptr, &f);
386 f = g_pFontLabel->GetChosenFont();
387 dc->GetTextExtent(token, &width, &height,
nullptr,
nullptr, &f);
389 dc->DrawText(token, TextPoint.x, TextPoint.y);
390 TextPoint.y += height;
391 token = tkz.GetNextToken();
@ OCPN_DBP_STC_AWA
Apparent wind angle.
@ OCPN_DBP_STC_AWS
Apparent wind speed.
@ OCPN_DBP_STC_TWA
True wind angle.
@ OCPN_DBP_STC_TWS
True wind speed.
Dashboard wind instrument implementation.