30#include <wx/artprov.h>
31#include <wx/statline.h>
41#include "androidUTIL.h"
47extern s52plib* ps52plib;
58EVT_CLOSE(CanvasOptions::OnClose)
71 long mstyle = wxNO_BORDER | wxFRAME_NO_TASKBAR;
73 mstyle |= wxSTAY_ON_TOP;
76 wxDialog::Create(parent, wxID_ANY,
"", wxDefaultPosition, wxDefaultSize,
79 wxBoxSizer* topsizer =
new wxBoxSizer(wxVERTICAL);
82 m_sWindow =
new wxScrolledWindow(
this, wxID_ANY, wxDefaultPosition,
83 wxDefaultSize, wxVSCROLL | wxSUNKEN_BORDER);
84 topsizer->Add(m_sWindow, 1, wxEXPAND);
86 m_sWindow->SetScrollRate(0, 5);
89 int group_item_spacing = 0;
90 int interGroupSpace = border_size * 2;
92 wxSizerFlags verticalInputFlags = wxSizerFlags(0)
95 .Border(wxALL, group_item_spacing);
96 wxSizerFlags inputFlags =
97 wxSizerFlags(0).Align(wxALIGN_LEFT).Border(wxALL, group_item_spacing);
99 wxScrolledWindow* pDisplayPanel = m_sWindow;
101 wxBoxSizer* generalSizer =
new wxBoxSizer(wxVERTICAL);
102 pDisplayPanel->SetSizer(generalSizer);
105 wxStaticText* optionsLabelBox =
106 new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Chart Panel Options"));
107 generalSizer->Add(optionsLabelBox, 0, wxALL | wxEXPAND, border_size);
108 wxStaticLine* m_staticLine121 =
109 new wxStaticLine(pDisplayPanel, wxID_ANY, wxDefaultPosition,
110 wxDefaultSize, wxLI_HORIZONTAL);
111 generalSizer->Add(m_staticLine121, 0, wxALL | wxEXPAND, border_size);
114 generalSizer->Add(0, interGroupSpace);
130 wxStaticBoxSizer* boxNavMode =
new wxStaticBoxSizer(
131 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Navigation Mode")),
133 generalSizer->Add(boxNavMode, 0, wxALL | wxEXPAND, border_size);
135 wxBoxSizer* rowOrientation =
new wxBoxSizer(wxVERTICAL);
136 boxNavMode->Add(rowOrientation);
138 pCBNorthUp =
new wxRadioButton(pDisplayPanel, wxID_ANY, _(
"North Up"),
139 wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
140 rowOrientation->Add(pCBNorthUp, inputFlags);
141 pCBNorthUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
142 wxCommandEventHandler(CanvasOptions::OnOptionChange),
147 rowOrientation->Add(pCBCourseUp, wxSizerFlags(0)
149 .Border(wxLEFT, group_item_spacing * 2));
150 pCBCourseUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
151 wxCommandEventHandler(CanvasOptions::OnOptionChange),
156 rowOrientation->Add(pCBHeadUp, wxSizerFlags(0)
158 .Border(wxLEFT, group_item_spacing * 2));
159 pCBHeadUp->Connect(wxEVT_COMMAND_RADIOBUTTON_SELECTED,
160 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
165 boxNavMode->Add(pCBLookAhead, verticalInputFlags);
166 pCBLookAhead->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
167 wxCommandEventHandler(CanvasOptions::OnOptionChange),
171 generalSizer->Add(0, interGroupSpace);
174 wxStaticBoxSizer* boxDisp =
new wxStaticBoxSizer(
175 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Display Options")),
177 generalSizer->Add(boxDisp, 0, wxALL | wxEXPAND, border_size);
180 _(
"Enable Chart Quilting"));
181 boxDisp->Add(pCDOQuilting, verticalInputFlags);
182 pCDOQuilting->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
183 wxCommandEventHandler(CanvasOptions::OnOptionChange),
188 boxDisp->Add(pSDisplayGrid, verticalInputFlags);
189 pSDisplayGrid->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
190 wxCommandEventHandler(CanvasOptions::OnOptionChange),
194 _(
"Show Chart Outlines"));
195 boxDisp->Add(pCDOOutlines, verticalInputFlags);
196 pCDOOutlines->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
197 wxCommandEventHandler(CanvasOptions::OnOptionChange),
201 _(
"Show Depth Units"));
202 boxDisp->Add(pSDepthUnits, verticalInputFlags);
203 pSDepthUnits->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
204 wxCommandEventHandler(CanvasOptions::OnOptionChange),
208 wxStaticBoxSizer* boxAIS =
new wxStaticBoxSizer(
209 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"AIS")), wxVERTICAL);
210 generalSizer->Add(boxAIS, 0, wxALL | wxEXPAND, border_size);
213 _(
"Show AIS targets"));
214 boxAIS->Add(pCBShowAIS, verticalInputFlags);
215 pCBShowAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
216 wxCommandEventHandler(CanvasOptions::OnOptionChange),
220 _(
"Minimize less critical targets"));
221 boxAIS->Add(pCBAttenAIS, verticalInputFlags);
222 pCBAttenAIS->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
223 wxCommandEventHandler(CanvasOptions::OnOptionChange),
227 generalSizer->Add(0, interGroupSpace);
230 wxStaticBoxSizer* boxTC =
new wxStaticBoxSizer(
231 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Tides and Currents")),
233 generalSizer->Add(boxTC, 0, wxALL | wxEXPAND, border_size);
236 _(
"Show Tide stations"));
237 boxTC->Add(pCDOTides, verticalInputFlags);
238 pCDOTides->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
239 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
244 boxTC->Add(pCDOCurrents, verticalInputFlags);
245 pCDOCurrents->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
246 wxCommandEventHandler(CanvasOptions::OnOptionChange),
250 generalSizer->Add(0, interGroupSpace);
253 wxStaticBoxSizer* boxENC =
new wxStaticBoxSizer(
254 new wxStaticBox(pDisplayPanel, wxID_ANY, _(
"Vector Charts")), wxVERTICAL);
255 generalSizer->Add(boxENC, 0, wxALL | wxEXPAND, border_size);
259 boxENC->Add(pCDOENCText, verticalInputFlags);
260 pCDOENCText->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
261 wxCommandEventHandler(CanvasOptions::OnOptionChange),
266 boxENC->Add(pCBENCDepth, verticalInputFlags);
267 pCBENCDepth->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
268 wxCommandEventHandler(CanvasOptions::OnOptionChange),
272 _(
"Buoy/Light Labels"));
273 boxENC->Add(pCBENCBuoyLabels, verticalInputFlags);
274 pCBENCBuoyLabels->Connect(
275 wxEVT_COMMAND_CHECKBOX_CLICKED,
276 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
280 boxENC->Add(pCBENCLights, verticalInputFlags);
281 pCBENCLights->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
282 wxCommandEventHandler(CanvasOptions::OnOptionChange),
286 _(
"Light Descriptions"));
287 boxENC->Add(pCBENCLightDesc, verticalInputFlags);
288 pCBENCLightDesc->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED,
289 wxCommandEventHandler(CanvasOptions::OnOptionChange),
293 _(
"Anchoring Info"));
294 boxENC->Add(pCBENCAnchorDetails, verticalInputFlags);
295 pCBENCAnchorDetails->Connect(
296 wxEVT_COMMAND_CHECKBOX_CLICKED,
297 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
299 pCBENCVisibleSectors =
301 _(
"Show visible sector lights"));
302 boxENC->Add(pCBENCVisibleSectors, verticalInputFlags);
303 pCBENCVisibleSectors->Connect(
304 wxEVT_COMMAND_CHECKBOX_CLICKED,
305 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
309 _(
"Show chart data quality"));
310 boxENC->Add(pCBENCDataQuality, verticalInputFlags);
311 pCBENCDataQuality->Connect(
312 wxEVT_COMMAND_CHECKBOX_CLICKED,
313 wxCommandEventHandler(CanvasOptions::OnOptionChange), NULL,
this);
316 boxENC->Add(0, interGroupSpace);
319 boxENC->Add(
new wxStaticText(pDisplayPanel, wxID_ANY, _(
"Display Category")),
321 wxString pDispCatStrings[] = {_(
"Base"), _(
"Standard"), _(
"All"),
323 m_pDispCat =
new wxChoice(pDisplayPanel,
ID_CODISPCAT, wxDefaultPosition,
324 wxDefaultSize, 4, pDispCatStrings);
325 boxENC->Add(m_pDispCat, 0, wxALIGN_CENTER_HORIZONTAL, 0);
326 m_pDispCat->Connect(wxEVT_COMMAND_CHOICE_SELECTED,
327 wxCommandEventHandler(CanvasOptions::OnOptionChange),
331 GetHandle()->setStyleSheet(getAdjustedDialogStyleSheet());
334 RefreshControlValues();
341void CanvasOptions::OnEraseBackground(wxEraseEvent& event) {}
343void CanvasOptions::OnClose(wxCloseEvent& event) {
348void CanvasOptions::OnOptionChange(wxCommandEvent& event) {
349 UpdateCanvasOptions();
352void CanvasOptions::RefreshControlValues(
void) {
353 auto parentCanvas =
dynamic_cast<ChartCanvas*
>(m_parent);
355 if (!parentCanvas)
return;
357 m_bmode_change_while_hidden = !wxWindow::IsShown();
363 int mode = parentCanvas->GetUpMode();
364 if (mode == NORTH_UP_MODE)
365 pCBNorthUp->SetValue(
true);
366 else if (mode == COURSE_UP_MODE)
367 pCBCourseUp->SetValue(
true);
369 pCBHeadUp->SetValue(
true);
371 pCBLookAhead->SetValue(parentCanvas->GetLookahead());
374 pCDOQuilting->SetValue(parentCanvas->GetQuiltMode());
375 pSDisplayGrid->SetValue(parentCanvas->GetShowGrid());
376 pCDOOutlines->SetValue(parentCanvas->GetShowOutlines());
377 pSDepthUnits->SetValue(parentCanvas->GetShowDepthUnits());
380 pCBShowAIS->SetValue(parentCanvas->GetShowAIS());
381 pCBAttenAIS->SetValue(parentCanvas->GetAttenAIS());
384 pCDOTides->SetValue(parentCanvas->GetbShowTide());
385 pCDOCurrents->SetValue(parentCanvas->GetbShowCurrent());
389 pCDOENCText->SetValue(parentCanvas->GetShowENCText());
390 pCBENCDepth->SetValue(parentCanvas->GetShowENCDepth());
391 pCBENCLightDesc->SetValue(parentCanvas->GetShowENCLightDesc());
392 pCBENCBuoyLabels->SetValue(parentCanvas->GetShowENCBuoyLabels());
393 pCBENCLights->SetValue(parentCanvas->GetShowENCLights());
394 pCBENCAnchorDetails->SetValue(parentCanvas->GetShowENCAnchor());
395 pCBENCVisibleSectors->SetValue(parentCanvas->GetShowVisibleSectors());
396 pCBENCDataQuality->SetValue(parentCanvas->GetShowENCDataQual());
402 switch (parentCanvas->GetENCDisplayCategory()) {
412 case (MARINERS_STANDARD):
419 m_pDispCat->SetSelection(nset);
423 pCDOENCText->Enable(m_ENCAvail);
424 pCBENCDepth->Enable(m_ENCAvail);
425 pCBENCLightDesc->Enable(m_ENCAvail && parentCanvas->GetShowENCLights());
426 pCBENCBuoyLabels->Enable(m_ENCAvail);
427 pCBENCLights->Enable(m_ENCAvail);
428 pCBENCVisibleSectors->Enable(m_ENCAvail);
432 pCBENCDataQuality->Enable(m_ENCAvail && (nset > 1));
433 pCBENCAnchorDetails->Enable(m_ENCAvail && (nset > 1));
437 pCDOENCText->Disable();
438 pCBENCDepth->Disable();
439 pCBENCLightDesc->Disable();
440 pCBENCBuoyLabels->Disable();
441 pCBENCLights->Disable();
442 pCBENCVisibleSectors->Disable();
443 pCBENCDataQuality->Disable();
446 m_pDispCat->Enable(m_ENCAvail);
449 pCBENCLightDesc->Enable(pCDOENCText->GetValue());
450 pCBENCBuoyLabels->Enable(pCDOENCText->GetValue());
453void CanvasOptions::SetENCAvailable(
bool avail) {
455 RefreshControlValues();
458void CanvasOptions::UpdateCanvasOptions(
void) {
459 auto parentCanvas =
dynamic_cast<ChartCanvas*
>(m_parent);
460 if (!parentCanvas)
return;
462 bool b_needRefresh =
false;
463 bool b_needReLoad =
false;
470 if (pCDOQuilting->GetValue() != parentCanvas->GetQuiltMode()) {
471 parentCanvas->ToggleCanvasQuiltMode();
474 if (pSDisplayGrid->GetValue() != parentCanvas->GetShowGrid()) {
475 parentCanvas->SetShowGrid(pSDisplayGrid->GetValue());
476 b_needRefresh =
true;
479 if (pCDOOutlines->GetValue() != parentCanvas->GetShowOutlines()) {
480 parentCanvas->SetShowOutlines(pCDOOutlines->GetValue());
481 b_needRefresh =
true;
483 if (pSDepthUnits->GetValue() != parentCanvas->GetShowDepthUnits()) {
484 parentCanvas->SetShowDepthUnits(pSDepthUnits->GetValue());
485 b_needRefresh =
true;
488 if (pCBShowAIS->GetValue() != parentCanvas->GetShowAIS()) {
489 parentCanvas->SetShowAIS(pCBShowAIS->GetValue());
490 b_needRefresh =
true;
493 if (pCBAttenAIS->GetValue() != parentCanvas->GetAttenAIS()) {
494 parentCanvas->SetAttenAIS(pCBAttenAIS->GetValue());
495 b_needRefresh =
true;
498 if (pCDOTides->GetValue() != parentCanvas->GetbShowTide()) {
499 parentCanvas->ShowTides(pCDOTides->GetValue());
500 b_needRefresh =
true;
502 if (pCDOCurrents->GetValue() != parentCanvas->GetbShowCurrent()) {
503 parentCanvas->ShowCurrents(pCDOCurrents->GetValue());
504 b_needRefresh =
true;
508 if (pCDOENCText->GetValue() != parentCanvas->GetShowENCText()) {
509 parentCanvas->SetShowENCText(pCDOENCText->GetValue());
513 if (pCBENCDepth->GetValue() != parentCanvas->GetShowENCDepth()) {
514 parentCanvas->SetShowENCDepth(pCBENCDepth->GetValue());
518 if (pCBENCLightDesc->GetValue() != parentCanvas->GetShowENCLightDesc()) {
519 parentCanvas->SetShowENCLightDesc(pCBENCLightDesc->GetValue());
523 if (pCBENCBuoyLabels->GetValue() != parentCanvas->GetShowENCBuoyLabels()) {
524 parentCanvas->SetShowENCBuoyLabels(pCBENCBuoyLabels->GetValue());
528 if (pCBENCLights->GetValue() != parentCanvas->GetShowENCLights()) {
529 parentCanvas->SetShowENCLights(pCBENCLights->GetValue());
533 if (pCBENCAnchorDetails->GetValue() != parentCanvas->GetShowENCAnchor()) {
534 parentCanvas->SetShowENCAnchor(pCBENCAnchorDetails->GetValue());
538 if (pCBENCVisibleSectors->GetValue() !=
539 parentCanvas->GetShowVisibleSectors()) {
540 parentCanvas->SetShowVisibleSectors(pCBENCVisibleSectors->GetValue());
544 if (pCBENCDataQuality->GetValue() != parentCanvas->GetShowENCDataQual()) {
545 parentCanvas->SetShowENCDataQual(pCBENCDataQuality->GetValue());
550 if (pCBENCDataQuality->GetValue()) {
551 if (ps52plib) ps52plib->m_bShowMeta =
true;
552 parentCanvas->UpdateCanvasS52PLIBConfig();
555 if (!m_bmode_change_while_hidden) {
556 int newMode = NORTH_UP_MODE;
557 if (pCBCourseUp->GetValue())
558 newMode = COURSE_UP_MODE;
559 else if (pCBHeadUp->GetValue())
560 newMode = HEAD_UP_MODE;
562 if (newMode != parentCanvas->GetUpMode()) {
563 parentCanvas->SetUpMode(newMode);
568 if (pCBLookAhead->GetValue() != parentCanvas->GetLookahead()) {
569 parentCanvas->ToggleLookahead();
570 parentCanvas->UpdateFollowButtonState();
575 switch (parentCanvas->GetENCDisplayCategory()) {
585 case (MARINERS_STANDARD):
593 if (m_pDispCat->GetSelection() != nset) {
594 int valSet = STANDARD;
595 int newSet = m_pDispCat->GetSelection();
598 valSet = DISPLAYBASE;
607 valSet = MARINERS_STANDARD;
613 parentCanvas->SetENCDisplayCategory(valSet);
618 pCBENCAnchorDetails->Enable(newSet > 1);
622 parentCanvas->ReloadVP();
623 }
else if (b_needRefresh) {
624 parentCanvas->Refresh(
true);
625 parentCanvas->InvalidateGL();
628 RefreshControlValues();
Class CanvasOptions and helpers – Canvas options Window/Dialog.
@ IDCO_QUILTCHECKBOX1
ID for checkbox to enable chart quilting.
@ IDCO_ENCTEXT_CHECKBOX1
ID for checkbox to show ENC (Electronic Navigational Chart) text.
@ IDCO_CURRENTS_CHECKBOX
ID for checkbox to show currents.
@ IDCO_ENCVISIBLESECTORS_CHECKBOX1
ID for checkbox to show ENC visible light sectors.
@ IDCO_SHOW_AIS_CHECKBOX
ID for checkbox to show AIS (Automatic Identification System) targets.
@ ID_CODISPCAT
ID for control to set ENC display category.
@ IDCO_ENCDEPTH_CHECKBOX1
ID for checkbox to show ENC depths.
@ IDCO_TIDES_CHECKBOX
ID for checkbox to show tides.
@ IDCO_OUTLINECHECKBOX1
ID for checkbox to show chart outlines.
@ IDCO_ATTEN_AIS_CHECKBOX
ID for checkbox to attenuate AIS targets.
@ IDCO_ENCDATAQUALITY_CHECKBOX
ID for checkbox to show ENC data quality indicators.
@ IDCO_ENCBUOYLABEL_CHECKBOX1
ID for checkbox to show ENC buoy labels.
@ IDCO_HEADUPCHECKBOX
ID for checkbox to set head-up orientation.
@ IDCO_ENCBUOY_CHECKBOX1
ID for checkbox to show ENC buoys.
@ IDCO_ENCANCHOR_CHECKBOX1
ID for checkbox to show ENC anchor details.
@ IDCO_CHECK_LOOKAHEAD
ID for checkbox to enable look-ahead mode.
@ IDCO_COURSEUPCHECKBOX
ID for checkbox to set course-up orientation.
@ IDCO_CHECK_DISPLAYGRID
ID for checkbox to display grid.
@ IDCO_SHOWDEPTHUNITSBOX1
ID for checkbox to show depth units.
Generic Chart canvas base.
Represents the Canvas Options dialog.
ChartCanvas - Main chart display and interaction component.
wxFont * GetOCPNScaledFont(wxString item, int default_size)
Retrieves a font from FontMgr, optionally scaled for physical readability.
General purpose GUI support.