139 const int tz_selection)
145 m_table.StartFillHeader();
149 if (dlg.IsEnabled(RoutePrintOptions::kWaypointName)) {
150 m_table << _(
"Waypoint");
152 if (dlg.IsEnabled(RoutePrintOptions::kWaypointPosition)) {
153 m_table << _(
"Position");
155 if (dlg.IsEnabled(RoutePrintOptions::kWaypointCourse)) {
156 m_table << _(
"Course");
158 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDistance)) {
159 m_table << _(
"Distance");
161 if (dlg.IsEnabled(RoutePrintOptions::kWaypointSpeed)) {
162 m_table << _(
"Speed");
164 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETA)) {
167 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETD)) {
170 if (dlg.IsEnabled(RoutePrintOptions::kWaypointTideEvent)) {
171 m_table << _(
"Next tide event");
173 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDescription)) {
174 m_table << _(
"Description");
178 m_table.StartFillWidths();
181 if (dlg.IsEnabled(RoutePrintOptions::kWaypointName)) {
184 if (dlg.IsEnabled(RoutePrintOptions::kWaypointPosition)) {
187 if (dlg.IsEnabled(RoutePrintOptions::kWaypointCourse)) {
190 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDistance)) {
193 if (dlg.IsEnabled(RoutePrintOptions::kWaypointSpeed)) {
196 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETA)) {
199 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETD)) {
202 if (dlg.IsEnabled(RoutePrintOptions::kWaypointTideEvent)) {
205 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDescription)) {
209 m_table.StartFillData();
211 for (
int n = 1; n <= m_route->GetnPoints(); n++) {
213 if (NULL == point)
continue;
221 if (dlg.IsEnabled(RoutePrintOptions::kWaypointName)) {
222 m_table << point->GetName();
224 if (dlg.IsEnabled(RoutePrintOptions::kWaypointPosition)) {
225 std::wostringstream point_position;
226 point_position << toSDMM(1, point->m_lat,
false) <<
"\n"
227 << toSDMM(2, point->m_lon,
false);
228 m_table << point_position.str();
230 if (dlg.IsEnabled(RoutePrintOptions::kWaypointCourse)) {
232 m_table << formatAngle(point->GetCourse());
237 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDistance)) {
239 std::ostringstream point_distance;
240 point_distance << std::fixed << std::setprecision(2) << std::setw(6)
242 << getUsrDistanceUnit();
243 m_table << point_distance.str();
248 if (dlg.IsEnabled(RoutePrintOptions::kWaypointSpeed)) {
249 std::wostringstream point_speed;
251 point_speed << std::fixed << std::setprecision(1);
253 point_speed << toUsrSpeed(m_route->m_PlannedSpeed);
257 point_speed << getUsrSpeedUnit().ToStdString();
258 m_table << point_speed.str();
263 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETA)) {
265 .FormatISOCombined(
' ');
267 if (dlg.IsEnabled(RoutePrintOptions::kWaypointETD)) {
271 .FormatISOCombined(
' ');
276 if (dlg.IsEnabled(RoutePrintOptions::kWaypointTideEvent)) {
277 std::wostringstream point_tide;
279 int station_id =
ptcmgr->GetStationIDXbyName(
281 if (station_id > 0) {
282 point_tide <<
ptcmgr->GetTidalEventStr(station_id, point->
GetETA(),
283 point->m_lat, point->m_lon,
286 m_table << point_tide.str();
294 if (dlg.IsEnabled(RoutePrintOptions::kWaypointDescription)) {
295 m_table << point->GetDescription();
333 wxFont title_font(16, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
335 wxFont subtitle_font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
336 wxFONTWEIGHT_NORMAL);
337 wxFont header_font(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
339 wxFont normal_font(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
340 wxFONTWEIGHT_NORMAL);
342 wxBrush brush(wxColour(255, 255, 255), wxBRUSHSTYLE_TRANSPARENT);
345 int current_x = m_margin_x;
346 int current_y = m_margin_y;
348 std::wostringstream title;
349 std::wostringstream subtitle;
350 std::wostringstream distance;
352 distance << std::fixed << std::setprecision(1)
354 << getUsrDistanceUnit().ToStdString();
356 if (m_route->m_RouteNameString.Trim().Len() > 0) {
357 title << m_route->m_RouteNameString.ToStdString();
358 title <<
" (" << distance.str() <<
")";
360 title << _(
"Total distance ") << distance.str();
363 if (m_route->m_RouteStartString.Trim().Len() > 0) {
364 subtitle << _(
"From") <<
" " << m_route->m_RouteStartString;
365 if (m_route->m_RouteEndString.Trim().Len() > 0) {
366 subtitle <<
" " << _(
"To") <<
" " << m_route->m_RouteEndString;
368 }
else if (m_route->m_RouteEndString.Trim().Len() > 0) {
369 subtitle << _(
"Destination") <<
" " << m_route->m_RouteEndString;
372 int title_width, title_height;
373 dc->SetFont(title_font);
374 dc->GetTextExtent(title.str(), &title_width, &title_height);
375 dc->DrawText(title.str(), current_x, current_y);
376 current_y += title_height + m_text_offset_y;
378 if (subtitle.str().length() > 0) {
379 int subtitle_width, subtitle_height;
380 dc->SetFont(subtitle_font);
381 dc->GetTextExtent(subtitle.str(), &subtitle_width, &subtitle_height);
382 dc->DrawText(subtitle.str(), current_x, current_y);
383 current_y += subtitle_height + m_text_offset_y;
386 dc->SetFont(normal_font);
389 if (page == 1 && m_route->m_RouteDescription.Trim().Len() > 0) {
390 int page_size_x, page_size_y;
391 dc->GetSize(&page_size_x, &page_size_y);
394 cell_desc.Init(m_route->m_RouteDescription, dc, page_size_x, m_margin_x);
395 dc->DrawText(cell_desc.GetText(), current_x, current_y);
396 current_y += cell_desc.GetHeight() + m_text_offset_y;
399 vector<PrintCell>& header_content = m_table.GetHeader();
400 for (
size_t j = 0; j < header_content.size(); j++) {
402 dc->DrawRectangle(current_x, current_y, cell.GetWidth() + m_text_offset_x,
403 cell.GetHeight() + m_text_offset_y);
404 dc->DrawText(cell.GetText(), current_x + m_text_offset_x,
405 current_y + m_text_offset_y);
406 current_x += cell.GetWidth() + m_text_offset_x;
409 wxFont routePrintFont_normal(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
410 wxFONTWEIGHT_NORMAL);
411 dc->SetFont(routePrintFont_normal);
413 vector<vector<PrintCell>>& cells = m_table.GetContent();
414 current_y += m_table.GetHeaderHeight() + m_text_offset_y;
415 int current_height = 0;
416 for (
size_t i = 0; i < cells.size(); i++) {
417 vector<PrintCell>& content_row = cells[i];
418 current_x = m_margin_x;
419 for (
size_t j = 0; j < content_row.size(); j++) {
421 if (cell.GetPage() == page) {
422 wxRect r(current_x, current_y, cell.GetWidth() + m_text_offset_x,
423 cell.GetHeight() + m_text_offset_y);
424 dc->DrawRectangle(r);
425 r.Offset(m_text_offset_x, m_text_offset_y);
426 dc->DrawLabel(cell.GetText(), r);
427 current_x += cell.GetWidth() + m_text_offset_x;
428 current_height = cell.GetHeight() + m_text_offset_y;
431 current_y += current_height;