OpenCPN Partial API docs
Loading...
Searching...
No Matches
chcanv.h
Go to the documentation of this file.
1
2/**************************************************************************
3 * Copyright (C) 2010 by David S. Register *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef _CHCANV_H__
26#define _CHCANV_H__
27
28#include "gl_headers.h" // Must go before wx/glcanvas
29
30#include <wx/datetime.h>
31#include <wx/grid.h>
32#include <wx/treectrl.h>
33
34#ifdef ocpnUSE_GL
35#include <wx/glcanvas.h>
36#endif
37
38#include "model/route.h"
39#include "model/route_point.h"
40#include "model/select_item.h"
41
42#include "bbox.h"
43#include "canvas_menu.h"
44#include "chartdb.h"
45#include "chartimg.h"
46#include "ch_info_win.h"
47#include "compass.h"
48#include "emboss_data.h"
49#include "gshhs.h"
50#include "gui_lib.h"
51#include "IDX_entry.h"
52#include "MUIBar.h"
53#include "notification_manager_gui.h"
54#include "observable_evtvar.h"
55#include "observable.h"
56#include "ocpCursor.h"
57#include "ocpn_frame.h"
58#include "ocpn_pixel.h"
59#include "ocpn_plugin.h"
60#include "piano.h"
61#include "Quilt.h"
62#include "RolloverWin.h"
63#include "S57Sector.h"
64#include "TCWin.h"
65#include "undo.h"
66
67class CanvasMenuHandler; // circular
68
69class ChartCanvas; // forward
72
73// Useful static routines
74void ShowAISTargetQueryDialog(wxWindow *parent, int mmsi);
75
76// Set up the preferred quilt type
77#define QUILT_TYPE_2
78
79//----------------------------------------------------------------------------
80// Forward Declarations
81//----------------------------------------------------------------------------
82
83//--------------------------------------------------------
84// Screen Brightness Control Support Routines
85//
86//--------------------------------------------------------
87
88int InitScreenBrightness(void);
89int RestoreScreenBrightness(void);
90int SetScreenBrightness(int brig1Ghtness);
91
92enum // specify the render behaviour of SetViewPoint()
93{
94 CURRENT_RENDER, // use the current render type
95 FORCE_SUBSAMPLE // force sub-sampled render, with re-render timer
96};
97
98// Cursor region enumerator
99enum {
100 CENTER,
101 MID_RIGHT,
102 MID_LEFT,
103 MID_TOP,
104 MID_BOT,
105};
106
107typedef enum ownship_state_t {
108 SHIP_NORMAL = 0,
109 SHIP_LOWACCURACY,
110 SHIP_INVALID
111} _ownship_state_t;
112
113enum { ID_S57QUERYTREECTRL = 10000, ID_AISDIALOGOK };
114
115enum {
116 ID_PIANO_DISABLE_QUILT_CHART = 32000,
117 ID_PIANO_ENABLE_QUILT_CHART,
118 ID_PIANO_CONTRACT_PIANO,
119 ID_PIANO_EXPAND_PIANO
120};
121
122enum { NORTH_UP_MODE, COURSE_UP_MODE, HEAD_UP_MODE };
123
124extern void pupHandler_PasteRoute();
125
126extern void pupHandler_PasteWaypoint();
127
128extern void pupHandler_PasteTrack();
129
130class canvasConfig; // circular
131class Quilt; // circular
132
151class ChartCanvas : public wxWindow {
152 friend class glChartCanvas;
153
154public:
155 ChartCanvas(wxFrame *frame, int canvasIndex, wxWindow *nmea_log);
156 ~ChartCanvas();
157
158 void SetupGlCanvas();
159
160 // Methods
161 void OnKeyDown(wxKeyEvent &event);
162 void OnKeyUp(wxKeyEvent &event);
163 void OnKeyChar(wxKeyEvent &event);
164 void OnPaint(wxPaintEvent &event);
165 void PaintCleanup();
166 void Scroll(int dx, int dy);
167 void ResetGridFont() { m_pgridFont = nullptr; }
168
169 void OnToolLeftClick(wxCommandEvent &event);
170
171 bool MouseEventOverlayWindows(wxMouseEvent &event);
172 bool MouseEventChartBar(wxMouseEvent &event);
173 bool MouseEventMUIBar(wxMouseEvent &event);
174 bool MouseEventToolbar(wxMouseEvent &event);
175 bool MouseEventIENCBar(wxMouseEvent &event);
176
177 bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick = true);
178 bool MouseEventProcessObjects(wxMouseEvent &event);
194 bool MouseEventProcessCanvas(wxMouseEvent &event);
195 void SetCanvasCursor(wxMouseEvent &event);
196 void OnKillFocus(wxFocusEvent &WXUNUSED(event));
197 void OnSetFocus(wxFocusEvent &WXUNUSED(event));
198#ifdef HAVE_WX_GESTURE_EVENTS
199 void OnZoom(wxZoomGestureEvent &event);
200 void OnLongPress(wxLongPressEvent &event);
201 void OnPressAndTap(wxPressAndTapEvent &event);
202
203 void OnLeftDown(wxMouseEvent &evt);
204 void OnLeftUp(wxMouseEvent &evt);
205
206 void OnRightUp(wxMouseEvent &event);
207 void OnRightDown(wxMouseEvent &event);
208
209 void OnDoubleLeftClick(wxMouseEvent &event);
210
211 void OnWheel(wxMouseEvent &event);
212 void OnMotion(wxMouseEvent &event);
213#endif /* HAVE_WX_GESTURE_EVENTS */
214
215 void PopupMenuHandler(wxCommandEvent &event);
216 bool IsPrimaryCanvas() { return (m_canvasIndex == 0); }
217
218 bool SetUserOwnship();
219
220 double GetCanvasRangeMeters();
221 void SetCanvasRangeMeters(double range);
222
223 void EnablePaint(bool b_enable);
224 bool SetCursor(const wxCursor &c) override;
225 void Refresh(bool eraseBackground = true,
226 const wxRect *rect = nullptr) override;
227 void Update() override;
228
229 void LostMouseCapture(wxMouseCaptureLostEvent &event);
230
231 void CancelMouseRoute();
235 void SetDisplaySizeMM(double size);
239 double GetDisplaySizeMM() { return m_display_size_mm; }
240
252 bool SetVPScale(double sc, bool b_refresh = true);
253 bool SetVPProjection(int projection);
261 bool SetViewPoint(double lat, double lon);
262 bool SetViewPointByCorners(double latSW, double lonSW, double latNE,
263 double lonNE);
278 bool SetViewPoint(double lat, double lon, double scale_ppm, double skew,
279 double rotation, int projection = 0, bool b_adjust = true,
280 bool b_refresh = true);
281 void ReloadVP(bool b_adjust = true);
282 void LoadVP(ViewPort &vp, bool b_adjust = true);
283
284 ChartStack *GetpCurrentStack() { return m_pCurrentStack; }
285 void SetGroupIndex(int index, bool autoswitch = false);
286 bool CheckGroup(int igroup);
287 void canvasRefreshGroupIndex(void);
288 void canvasChartsRefresh(int dbi_hint);
289
290 void CheckGroupValid(bool showMessage = true, bool switchGroup0 = true);
291
292 void UpdateCanvasS52PLIBConfig();
293
294 void TriggerDeferredFocus();
295 void OnDeferredFocusTimerEvent(wxTimerEvent &event);
296 void OnRouteFinishTimerEvent(wxTimerEvent &event);
297
298 void ClearS52PLIBStateHash() { m_s52StateHash = 0; }
299 void SetupCanvasQuiltMode(void);
300 void ApplyCanvasConfig(canvasConfig *pcc);
301
302 bool SetVPRotation(double angle);
303 double GetVPRotation(void) { return GetVP().rotation; }
304 double GetVPSkew(void) { return GetVP().skew; }
305 double GetVPTilt(void) { return GetVP().tilt; }
306
307 void ClearbFollow(void);
308 void SetbFollow(void);
309 void TogglebFollow(void);
310 bool GetbFollow() { return m_bFollow; }
311
312 void JumpToPosition(double lat, double lon, double scale);
313 void SetFirstAuto(bool b_auto) { m_bFirstAuto = b_auto; }
314 void SetAbsoluteMinScale(double min_scale);
315 std::shared_ptr<PI_PointContext> GetCanvasContextAtPoint(int x, int y);
316
329 void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
343 void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
344 wxPoint2DDouble *r);
345
362 bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
363
384 bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
385
401 void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
402 void WarpPointerDeferred(int x, int y);
403 void UpdateShips();
404 void UpdateAIS();
405 void UpdateAlerts(); // pjotrc 2010.02.22
406 void ToggleCPAWarn();
407
408 bool IsMeasureActive() { return m_bMeasure_Active; }
409 wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
410 Undo *undo;
411
412 int GetUpMode() { return m_upMode; }
413 bool GetLookahead() { return m_bLookAhead; }
414
415 void UnlockQuilt();
416 void SetQuiltMode(bool b_quilt);
417 bool GetQuiltMode(void);
418 std::vector<int> GetQuiltIndexArray(void);
419 bool IsQuiltDelta(void);
420 void SetQuiltChartHiLiteIndex(int dbIndex);
421 void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
422 void ClearQuiltChartHiLiteIndexArray();
423 int GetQuiltReferenceChartIndex(void);
424 double GetBestStartScale(int dbi_hint, const ViewPort &vp);
425 void ConfigureChartBar();
426
427 int GetNextContextMenuId();
428
429 TCWin *getTCWin() { return pCwin; }
430
431 bool StartTimedMovement(bool stoptimer = true);
432 void DoTimedMovement();
445 void DoMovement(long dt);
446 void StopMovement();
447
448 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
449 void DoTimedMovementVP();
450 void StopMovementVP();
451
452 void StartTimedMovementTarget();
453 void DoTimedMovementTarget();
454 void StopMovementTarget();
455
456 void SetColorScheme(ColorScheme cs);
457 ColorScheme GetColorScheme() { return m_cs; }
458
459 void CanvasApplyLocale();
460 void RebuildCursors();
461
462 // Accessors
463 int GetCanvasWidth() { return m_canvas_width; }
464 int GetCanvasHeight() { return m_canvas_height; }
466 float GetVPScale() { return GetVP().view_scale_ppm; }
469 float GetVPChartScale() { return GetVP().chart_scale; }
477 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
482 double GetCanvasTrueScale() { return m_true_scale_ppm; }
483 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
484 ViewPort *GetpVP() { return &VPoint; }
485 void SetVP(ViewPort &);
486 ChartBase *GetChartAtCursor();
487 ChartBase *GetOverlayChartAtCursor();
488 Piano *GetPiano() { return m_Piano; }
489 int GetPianoHeight();
490
491 bool isRouteEditing(void) {
492 return m_bRouteEditing && m_pRoutePointEditTarget;
493 }
494 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
495
496 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
497 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
498
499 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
500 bool GetbTCUpdate() { return m_bTCupdate; }
501 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
502 bool GetbShowCurrent() { return m_bShowCurrent; }
503 void SetbShowTide(bool f) { m_bShowTide = f; }
504 bool GetbShowTide() { return m_bShowTide; }
505 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
506 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
508 double GetPixPerMM() { return m_pix_per_mm; }
509
510 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
511 void SetCursorStatus(double cursor_lat, double cursor_lon);
512 void GetCursorLatLon(double *lat, double *lon);
515 bool PanCanvas(double dx, double dy);
516 void StopAutoPan(void);
517 bool IsOwnshipOnScreen();
518
537 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
538 bool stoptimer = true);
539
551 void ZoomCanvasSimple(double factor);
552
553 void RotateCanvas(double dir);
554 void DoRotateCanvas(double rotation);
555 void DoTiltCanvas(double tilt);
556
557 void ShowAISTargetList(void);
558
559 void ShowGoToPosition(void);
560 void HideGlobalToolbar();
561 void ShowGlobalToolbar();
562
563 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
564 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
565 bool GetShowGrid() { return m_bDisplayGrid; }
566 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
567 bool GetShowOutlines() { return m_bShowOutlines; }
568 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
569 bool GetShowChartbar() { return true; }
570 wxRect GetMUIBarRect();
571 void SetMUIBarPosition();
572 void DestroyMuiBar();
573 void CreateMUIBar();
574
575 void ToggleChartOutlines(void);
576 void ToggleCanvasQuiltMode(void);
577
578 wxString GetScaleText() { return m_scaleText; }
579 double GetScaleValue() { return m_scaleValue; }
580 bool GetShowAIS() { return m_bShowAIS; }
581 void SetShowAIS(bool show);
582 bool GetAttenAIS() { return m_bShowAISScaled; }
583 void SetAttenAIS(bool show);
584 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
585 bool GetShowFocusBar() { return m_show_focus_bar; }
586 MUIBar *GetMUIBar() { return m_muiBar; }
587 void SetAlertString(wxString str) { m_alertString = str; }
588 wxString GetAlertString() { return m_alertString; }
589 bool GetShowENCText() { return m_encShowText; }
590 void SetShowENCText(bool show);
591
592 bool GetShowENCDepth() { return m_encShowDepth; }
593 void SetShowENCDepth(bool show);
594
595 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
596 void SetShowENCLightDesc(bool show);
597
598 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
599 void SetShowENCBuoyLabels(bool show);
600
601 bool GetShowENCLights() { return m_encShowLights; }
602 void SetShowENCLights(bool show);
603
604 int GetENCDisplayCategory() { return m_encDisplayCategory; }
605 void SetENCDisplayCategory(int category);
606
607 bool GetShowENCAnchor() { return m_encShowAnchor; }
608 void SetShowENCAnchor(bool show);
609
610 bool GetShowENCDataQual() { return m_encShowDataQual; }
611 void SetShowENCDataQual(bool show);
612
613 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
614 int m_canvasIndex;
615 void ShowTides(bool bShow);
616 void ShowCurrents(bool bShow);
617 void SetUpMode(int mode);
618 void ToggleLookahead();
619 void SetShowGPS(bool show);
620 void UpdateFollowButtonState(void);
621 void InvalidateGL();
622 bool IsTileOverlayIndexInYesShow(int index);
623 bool IsTileOverlayIndexInNoShow(int index);
624 void AddTileOverlayIndexToNoShow(int index);
625 int m_groupIndex;
626 Route *m_pMouseRoute;
627 bool m_bMeasure_Active;
628 ViewPort &GetVP();
629 ChartBase *m_singleChart;
630 Quilt *m_pQuilt;
631 wxString FindValidUploadPort();
632 wxString m_active_upload_port;
633
634 // protected:
635
636 // private:
637 ChartBase *GetLargestScaleQuiltChart();
638 ChartBase *GetFirstQuiltChart();
639 ChartBase *GetNextQuiltChart();
640 int GetQuiltChartCount();
641 void InvalidateAllQuiltPatchs(void);
642 void SetQuiltRefChart(int dbIndex);
643 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
644 bool flag2 = true);
645 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
646 std::vector<int> &GetQuiltFullScreendbIndexArray();
647 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
648 int GetQuiltRefChartdbIndex(void);
649 void InvalidateQuilt(void);
650 double GetQuiltMaxErrorFactor();
651 bool IsChartQuiltableRef(int db_index);
652 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
653 int GetCanvasChartNativeScale();
654 int FindClosestCanvasChartdbIndex(int scale);
655 void UpdateCanvasOnGroupChange(void);
656
657 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
658 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
659 void ShowRoutePropertiesDialog(wxString title, Route *selected);
660 void ShowTrackPropertiesDialog(Track *selected);
663 void DrawTCWindow(int x, int y, void *pIDX);
664
677 void ShowSingleTideDialog(int x, int y, void *pvIDX);
678
680 bool IsTideDialogOpen() const;
681
683 void CloseTideDialog();
684
685 void UpdateGPSCompassStatusBox(bool b_force_new);
686 ocpnCompass *GetCompass() { return m_Compass; }
687
688 wxColour GetFogColor() { return m_fog_color; }
689
690 void ShowChartInfoWindow(int x, int dbIndex);
691 void HideChartInfoWindow(void);
692 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
693 const std::vector<int> &index_vector);
694
695 void StartMeasureRoute();
696 void CancelMeasureRoute();
697
698 bool DoCanvasUpdate(void);
699 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
700 void SelectQuiltRefChart(int selected_index);
701 double GetBestVPScale(ChartBase *pchart);
702 void selectCanvasChartDisplay(int type, int family);
703 void RemoveChartFromQuilt(int dbIndex);
704
705 void HandlePianoClick(int selected_index,
706 const std::vector<int> &selected_dbIndex_array);
707 void HandlePianoRClick(int x, int y, int selected_index,
708 const std::vector<int> &selected_dbIndex_array);
709 void HandlePianoRollover(int selected_index,
710 const std::vector<int> &selected_dbIndex_array,
711 int n_charts, int scale);
712 void ClearPianoRollover();
713 void UpdateCanvasControlBar(void);
714 void FormatPianoKeys(void);
715 void PianoPopupMenu(int x, int y, int selected_index,
716 const std::vector<int> &selected_dbIndex_array);
717 void OnPianoMenuDisableChart(wxCommandEvent &event);
718 void OnPianoMenuEnableChart(wxCommandEvent &event);
719
720 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
721 bool DoCanvasCOGSet(void);
722 void ApplyGlobalSettings();
723 void SetShowGPSCompassWindow(bool bshow);
724 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
725 void FreezePiano() { m_pianoFrozen = true; }
726 void ThawPiano() { m_pianoFrozen = false; }
727 void StartChartDragInertia();
728 void SetupGridFont();
729
730 // Todo build more accessors
731 bool m_bFollow;
732 wxCursor *pCursorPencil;
733 wxCursor *pCursorArrow;
734 wxCursor *pCursorCross;
735 wxCursor *pPlugIn_Cursor;
736 TCWin *pCwin;
737 wxBitmap *pscratch_bm;
738 bool m_brepaint_piano;
771 wxPoint r_rband;
772 double m_prev_rlat;
773 double m_prev_rlon;
774 RoutePoint *m_prev_pMousePoint;
775 bool m_bShowNavobjects;
776 int m_routeState;
777 int m_upMode;
778 bool m_bLookAhead;
779
780#ifdef HAVE_WX_GESTURE_EVENTS
781 double m_oldVPSScale;
782 bool m_popupWanted;
783 bool m_leftdown;
784 wxPoint m_zoomStartPoint;
785#endif /* HAVE_WX_GESTURE_EVENTS */
786
787 void DrawBlinkObjects(void);
788
789 void StartRoute(void);
790 wxString FinishRoute(void);
791
792#ifdef ocpnUSE_GL
793 glChartCanvas *GetglCanvas() { return m_glcc; }
794#endif
795
796 bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
797
798 bool m_FinishRouteOnKillFocus;
799 bool m_bMeasure_DistCircle;
800 bool m_bAppendingRoute;
801 int m_nMeasureState;
802 Route *m_pMeasureRoute;
803 MyFrame *parent_frame;
804 CanvasMenuHandler *m_canvasMenu;
805 int GetMinAvailableGshhgQuality() {
806 return pWorldBackgroundChart->GetMinAvailableQuality();
807 }
808 int GetMaxAvailableGshhgQuality() {
809 return pWorldBackgroundChart->GetMaxAvailableQuality();
810 }
811 Route *GetSelectedRoute() const { return m_pSelectedRoute; }
812 Track *GetSelectedTrack() const { return m_pSelectedTrack; }
813 RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
814
815 void SetAISCanvasDisplayStyle(int StyleIndx);
816 void TouchAISToolActive(void);
817 void UpdateAISTBTool(void);
818
819 void SelectChartFromStack(int index, bool bDir = false,
820 ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
821 ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
822 void SelectdbChart(int dbindex);
823
824 void DoCanvasStackDelta(int direction);
825
826 void ProcessNewGUIScale();
827
828 bool m_b_paint_enable;
829
830 wxRect GetScaleBarRect() { return m_scaleBarRect; }
831 void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
832
833 std::vector<int> m_tile_noshow_index_array;
834 std::vector<int> m_tile_yesshow_index_array;
835 std::vector<int> m_quilt_noshow_index_array;
836
837 std::vector<int> GetQuiltNoshowIindexArray() {
838 return m_quilt_noshow_index_array;
839 }
849 double GetDisplayScale() { return m_displayScale; }
850 void ResetOwnshipOffset() { m_OSoffsetx = m_OSoffsety = 0; }
851 NotificationsList *GetNotificationsList() { return m_NotificationsList; }
852
853 int PrepareContextSelections(double lat, double lon);
854
855 RoutePoint *GetFoundRoutepoint() { return m_pFoundRoutePoint; }
856
862
863private:
877 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
878
879 int AdjustQuiltRefChart();
880 bool UpdateS52State();
881 void CallPopupMenu(int x, int y);
882 bool IsTempMenuBarEnabled();
883 bool InvokeCanvasMenu(int x, int y, int seltype);
884
885 ViewPort VPoint;
886 void PositionConsole(void);
887 wxWindow *m_nmea_log;
888
889 wxColour PredColor();
890 wxColour ShipColor();
891
892 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
893 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
894 wxPoint &GpsOffsetPixels,
895 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
896 float &scale_factor_y);
897
898 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
899 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
900 wxPoint2DDouble lGPSPoint);
901
902 ChInfoWin *m_pCIWin;
903
904 bool m_bShowCurrent;
905 bool m_bShowTide;
906 int cursor_region;
907 bool m_bTCupdate;
908 wxString m_scaleText;
909 double m_scaleValue;
910 bool m_bShowScaleInStatusBar;
911 wxRect bbRect;
912
913 wxPoint LastShipPoint;
914 wxPoint LastPredPoint;
915 bool m_bDrawingRoute;
916 bool m_bRouteEditing;
917 bool m_bMarkEditing;
918 bool m_bRoutePoinDragging;
919 bool m_bIsInRadius;
920 bool m_bMayToggleMenuBar;
921
922 RoutePoint *m_pRoutePointEditTarget;
923 RoutePoint *m_lastRoutePointEditTarget;
924 SelectItem *m_pFoundPoint;
925 bool m_bChartDragging;
926 Route *m_pSelectedRoute;
927 Track *m_pSelectedTrack;
928 wxArrayPtrVoid *m_pEditRouteArray;
929 RoutePoint *m_pFoundRoutePoint;
930
931 int m_FoundAIS_MMSI;
932
933 wxCursor *pCursorLeft;
934 wxCursor *pCursorRight;
935 wxCursor *pCursorUp;
936 wxCursor *pCursorDown;
937
938 wxCursor *pCursorUpLeft;
939 wxCursor *pCursorUpRight;
940 wxCursor *pCursorDownLeft;
941 wxCursor *pCursorDownRight;
942
943 int popx, popy;
944
945 wxBitmap *pThumbDIBShow;
946 wxBitmap *pThumbShowing;
947
948 bool bShowingCurrent;
949 bool bShowingTide;
950
957 double m_canvas_scale_factor;
959 double m_pix_per_mm;
960 double m_display_size_mm;
961
962 double m_absolute_min_scale_ppm;
963
964 bool singleClickEventIsValid;
965 wxMouseEvent singleClickEvent;
966
967 std::vector<s57Sector_t> extendedSectorLegs;
968 wxFont m_overzoomFont;
969 int m_overzoomTextWidth;
970 int m_overzoomTextHeight;
971
972 // Methods
973 void OnActivate(wxActivateEvent &event);
974 void OnSize(wxSizeEvent &event);
975 void MouseTimedEvent(wxTimerEvent &event);
976 void MouseEvent(wxMouseEvent &event);
977 void ShipDraw(ocpnDC &dc);
978 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
979 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
980 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
981
982 void RotateTimerEvent(wxTimerEvent &event);
983 void PanTimerEvent(wxTimerEvent &event);
984 void MovementTimerEvent(wxTimerEvent &);
985 void MovementStopTimerEvent(wxTimerEvent &);
986 void OnCursorTrackTimerEvent(wxTimerEvent &event);
987
988 void MovementVPTimerEvent(wxTimerEvent &event);
989
990 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
991 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
992 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
993 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
994 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
995 void DrawAnchorWatchPoints(ocpnDC &dc);
996 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
997
998 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
999 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
1000 void RebuildTideSelectList(LLBBox &BBox);
1001 void RebuildCurrentSelectList(LLBBox &BBox);
1002
1003 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
1004 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
1005 void RenderRouteLegs(ocpnDC &dc);
1006 void RenderVisibleSectorLights(ocpnDC &dc);
1007
1008 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
1009
1010 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
1011 void ScaleBarDraw(ocpnDC &dc);
1012
1013 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
1014 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
1015
1016 emboss_data *EmbossDepthScale();
1017 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
1018 const wxString &str, ColorScheme cs);
1019 void CreateDepthUnitEmbossMaps(ColorScheme cs);
1020 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
1021
1022 void CreateOZEmbossMapData(ColorScheme cs);
1023 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
1024 void SetOverzoomFont();
1025
1026 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
1027 // void EmbossCM93Offset ( wxMemoryDC *pdc);
1028
1029 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
1030
1031 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
1032 void HandleNotificationMouseClick();
1033
1034 // Data
1036 int m_canvas_width;
1038 int m_canvas_height;
1039
1040 int xr_margin; // chart scroll margins, control cursor, etc.
1041 int xl_margin;
1042 int yt_margin;
1043 int yb_margin;
1044
1045 wxPoint last_drag;
1046
1047 wxMemoryDC *pmemdc;
1048
1049 int warp_x, warp_y;
1050 bool warp_flag;
1051
1052 wxTimer *
1053 pPanTimer; // This timer used for auto panning on route creation and edit
1054 wxTimer *
1055 pMovementTimer; // This timer used for smooth movement in non-opengl mode
1056 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
1057 // event is lost
1058 wxTimer *pCurTrackTimer; // This timer used to update the status window on
1059 // mouse idle
1060 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
1061 // mouse moves
1062 wxTimer *m_DoubleClickTimer;
1063 wxTimer m_routeFinishTimer;
1064
1065 wxTimer m_RolloverPopupTimer;
1066
1067 wxTimer m_VPMovementTimer;
1068
1069 int m_wheelzoom_stop_oneshot;
1070 int m_last_wheel_dir;
1071 wxStopWatch m_wheelstopwatch;
1072 double m_zoom_target;
1073
1074 int m_curtrack_timer_msec;
1075 int m_rollover_popup_timer_msec;
1076
1077 GSHHSChart *pWorldBackgroundChart;
1078
1079 ChartBaseBSB *pCBSB;
1080 wxBitmap *pss_overlay_bmp;
1081 wxMask *pss_overlay_mask;
1082
1083 wxRect ship_draw_rect;
1084 wxRect ship_draw_last_rect;
1085 wxRect ais_draw_rect;
1086 wxRect alert_draw_rect; // pjotrc 2010.02.22
1087
1088 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
1089 wxMemoryDC m_dc_route; // seen in mouse->edit->route
1090
1091 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
1092 emboss_data *m_pEM_Meters;
1093 emboss_data *m_pEM_Fathoms;
1094
1095 emboss_data *m_pEM_OverZoom;
1096 // emboss_data *m_pEM_CM93Offset; // Flav
1097
1113 double m_true_scale_ppm;
1114
1115 ownship_state_t m_ownship_state;
1116
1117 ColorScheme m_cs;
1118
1119 wxBitmap m_bmTideDay;
1120 wxBitmap m_bmTideDusk;
1121 wxBitmap m_bmTideNight;
1122 wxBitmap m_bmCurrentDay;
1123 wxBitmap m_bmCurrentDusk;
1124 wxBitmap m_bmCurrentNight;
1125 wxBitmap m_cTideBitmap;
1126 wxBitmap m_cCurrentBitmap;
1127
1128 RolloverWin *m_pRouteRolloverWin;
1129 RolloverWin *m_pTrackRolloverWin;
1130 RolloverWin *m_pAISRolloverWin;
1131
1132 TimedPopupWin *m_pBrightPopup;
1133
1134 wxImage m_os_image_red_day;
1135 wxImage m_os_image_red_dusk;
1136 wxImage m_os_image_red_night;
1137 wxImage m_os_image_grey_day;
1138 wxImage m_os_image_grey_dusk;
1139 wxImage m_os_image_grey_night;
1140 wxImage m_os_image_yellow_day;
1141 wxImage m_os_image_yellow_dusk;
1142 wxImage m_os_image_yellow_night;
1143
1144 wxImage *m_pos_image_red;
1145 wxImage *m_pos_image_grey;
1146 wxImage *m_pos_image_yellow;
1147
1148 wxImage *m_pos_image_user;
1149 wxImage *m_pos_image_user_grey;
1150 wxImage *m_pos_image_user_yellow;
1151
1152 wxImage *m_pos_image_user_day;
1153 wxImage *m_pos_image_user_dusk;
1154 wxImage *m_pos_image_user_night;
1155 wxImage *m_pos_image_user_grey_day;
1156 wxImage *m_pos_image_user_grey_dusk;
1157 wxImage *m_pos_image_user_grey_night;
1158 wxImage *m_pos_image_user_yellow_day;
1159 wxImage *m_pos_image_user_yellow_dusk;
1160 wxImage *m_pos_image_user_yellow_night;
1161
1162 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1163 int m_cur_ship_pix;
1164 bool m_cur_ship_pix_isgrey;
1165 ColorScheme m_ship_cs;
1166
1167 ViewPort m_cache_vp;
1168 wxBitmap *m_prot_bm;
1169 wxPoint m_roffset;
1170
1171 bool m_b_rot_hidef;
1172
1173 SelectItem *m_pRolloverRouteSeg;
1174 SelectItem *m_pRolloverTrackSeg;
1175
1176 double m_wheel_lat, m_wheel_lon;
1177 int m_wheel_x, m_wheel_y;
1178
1179 ViewPort m_bm_cache_vp;
1180 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1181 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1182
1183 bool m_bbrightdir;
1184 int m_brightmod;
1185
1186 bool m_bzooming, m_bzooming_to_cursor;
1187 IDX_entry *m_pIDXCandidate;
1188
1189 // #ifdef ocpnUSE_GL
1190 glChartCanvas *m_glcc;
1191 // #endif
1192
1193 // Smooth movement member variables
1194 wxPoint m_pan_drag;
1195 int m_panx, m_pany, m_modkeys;
1196 double m_panspeed;
1197 bool m_bmouse_key_mod;
1198 double m_zoom_factor, m_rotation_speed;
1204 int m_mustmove;
1205
1206 wxDateTime m_last_movement_time;
1207
1208 int m_AISRollover_MMSI;
1209 bool m_bsectors_shown;
1210 bool m_bedge_pan;
1211 double m_displayed_scale_factor;
1212
1213 wxColour m_fog_color;
1214 bool m_disable_edge_pan;
1215 wxFont *m_pgridFont;
1216
1217 bool m_dragoffsetSet;
1218
1219 bool m_bautofind;
1220 bool m_bFirstAuto;
1221 double m_vLat, m_vLon;
1222 ChartStack *m_pCurrentStack;
1223 Piano *m_Piano;
1224 bool m_bpersistent_quilt;
1225
1226 wxMenu *m_piano_ctx_menu;
1227 int menu_selected_dbIndex, menu_selected_index;
1228
1229 ocpnCompass *m_Compass;
1230 bool m_bShowGPS;
1231
1232 wxRect m_mainlast_tb_rect;
1233 int m_restore_dbindex;
1234 int m_restore_group;
1235
1236 MUIBar *m_muiBar;
1237 wxSize m_muiBarHOSize;
1238
1239 bool m_bShowOutlines;
1240 bool m_bDisplayGrid;
1241 bool m_bShowDepthUnits;
1242 bool m_bShowAIS;
1243 bool m_bShowAISScaled;
1244
1245 // S52PLib state storage
1246 long m_s52StateHash;
1247 bool m_encShowText;
1248 bool m_encShowDepth;
1249 bool m_encShowLightDesc;
1250 bool m_encShowBuoyLabels;
1251 int m_encDisplayCategory;
1252 bool m_encShowLights;
1253 bool m_encShowAnchor;
1254 bool m_encShowDataQual;
1255
1256 wxTimer m_deferredFocusTimer;
1257 float m_focus_indicator_pix;
1258 bool m_bENCGroup;
1259 bool m_last_TBviz;
1260
1261 double m_OSoffsetx, m_OSoffsety;
1262 bool m_MouseDragging;
1263
1264 wxString m_alertString;
1265 wxRect m_scaleBarRect;
1266 bool m_bShowCompassWin;
1267 bool m_pianoFrozen;
1268
1269 double m_sector_glat, m_sector_glon;
1270 std::vector<s57Sector_t> m_sectorlegsVisible;
1271 bool m_bShowVisibleSectors;
1273 double m_displayScale;
1274 bool m_show_focus_bar;
1275
1276 double m_panx_target_final;
1277 double m_pany_target_final;
1278 double m_panx_target_now;
1279 double m_pany_target_now;
1280
1281 double m_start_lat, m_start_lon;
1282 double m_target_lat, m_target_lon;
1283 double m_run_lat, m_run_lon;
1284 bool m_timed_move_vp_active;
1285 int m_timedVP_step;
1286 int m_stvpc;
1287
1288 double meters_to_shift = 0;
1289 double dir_to_shift = 0;
1290
1291 // Chart drag inertia support
1292 wxTimer m_chart_drag_inertia_timer;
1293 void OnChartDragInertiaTimer(wxTimerEvent &event);
1294
1295 uint64_t m_last_drag_time;
1296 int m_chart_drag_total_x;
1297 int m_chart_drag_total_y;
1298 double m_chart_drag_total_time;
1299 double m_chart_drag_velocity_x;
1300 double m_chart_drag_velocity_y;
1301 wxLongLong m_chart_drag_inertia_time;
1302 wxLongLong m_chart_drag_inertia_start_time;
1303 bool m_chart_drag_inertia_active;
1304 double m_last_elapsed;
1305 std::vector<int> m_drag_vec_x;
1306 std::vector<int> m_drag_vec_y;
1307 std::vector<double> m_drag_vec_t;
1308 int m_inertia_last_drag_x;
1309 int m_inertia_last_drag_y;
1310
1311 // For Jump animation
1312 wxTimer m_easeTimer;
1313 wxLongLong m_animationStart;
1314 wxLongLong m_animationDuration; // e.g. 300 ms
1315 double m_startLat, m_startLon, m_startScale;
1316 double m_endLat, m_endLon, m_endScale;
1317 bool m_animationActive;
1318 void OnJumpEaseTimer(wxTimerEvent &event);
1319 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1320
1321 NotificationButton *m_notification_button;
1322 NotificationsList *m_NotificationsList;
1323 ObservableListener evt_notificationlist_change_listener;
1324 DECLARE_EVENT_TABLE()
1325};
1326
1327// CUSTOMIZATION - FORMAT MINUTES
1328
1329wxString minutesToHoursDays(float timeInMinutes);
1330
1331// END OF CUSTOMIZATION - FORMAT MINUTES
1332
1337#ifndef wxCLOSE_BOX
1338#define wxCLOSE_BOX 0x1000
1339#endif
1340#ifndef wxFIXED_MINSIZE
1341#define wxFIXED_MINSIZE 0
1342#endif
1343
1344#endif // _CHCANV_H__
Canvas context (right click) menu handler.
Chart info panel.
Charts database management
BSB chart management.
ChartCanvas * g_focusCanvas
Global instance.
Definition chcanv.cpp:1194
ChartCanvas * g_overlayCanvas
Global instance.
Definition chcanv.cpp:1193
Handles context menu events for the chart canvas.
Definition canvas_menu.h:49
A custom panel for displaying chart information.
Definition ch_info_win.h:36
Base class for BSB (Maptech/NOS) format nautical charts.
Definition chartimg.h:127
Base class for all chart types.
Definition chartbase.h:125
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:151
void CloseTideDialog()
Close any open tide dialog.
Definition chcanv.cpp:13587
bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates rounded to nearest integer using specified vie...
Definition chcanv.cpp:4391
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:469
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4387
void DoMovement(long dt)
Performs a step of smooth movement animation on the chart canvas.
Definition chcanv.cpp:3486
void ShowSingleTideDialog(int x, int y, void *pvIDX)
Display tide/current dialog with single-instance management.
Definition chcanv.cpp:13546
void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision,...
Definition chcanv.cpp:4337
double m_cursor_lat
The latitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:770
double GetCanvasScaleFactor()
Return the number of logical pixels per meter for the screen.
Definition chcanv.h:477
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:508
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
Definition chcanv.h:239
double GetDisplayScale()
Get the ratio of physical to logical pixel for the display.
Definition chcanv.h:849
void SetDisplaySizeMM(double size)
Set the width of the screen in millimeters.
Definition chcanv.cpp:2222
int PrepareContextSelections(double lat, double lon)
Definition chcanv.cpp:7897
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition chcanv.cpp:7707
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:4915
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:466
EventVar json_msg
Notified with message targeting all plugins.
Definition chcanv.h:861
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:482
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4468
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5196
double m_cursor_lon
The longitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:754
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
Definition chcanv.cpp:4412
bool IsTideDialogOpen() const
Definition chcanv.cpp:13585
void ZoomCanvas(double factor, bool can_zoom_to_cursor=true, bool stoptimer=true)
Perform a smooth zoom operation on the chart canvas by the specified factor.
Definition chcanv.cpp:4474
void DrawTCWindow(int x, int y, void *pIDX)
Legacy tide dialog creation method.
Definition chcanv.cpp:13542
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4332
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5215
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:10051
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
Represents an index entry for tidal and current data.
Definition IDX_entry.h:49
Modern User Interface Control Bar for OpenCPN.
Definition MUIBar.h:63
Main application frame.
Definition ocpn_frame.h:138
Keeps listening over its lifespan, removes itself on destruction.
Definition observable.h:155
Definition piano.h:65
Definition Quilt.h:83
Represents a waypoint or mark within the navigation system.
Definition route_point.h:70
Represents a navigational route in the navigation system.
Definition route.h:98
Definition TCWin.h:45
Represents a track, which is a series of connected track points.
Definition track.h:114
Definition undo.h:60
ViewPort - Core geographic projection and coordinate transformation engine.
Definition viewport.h:84
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
Definition viewport.h:232
double rotation
Rotation angle of the viewport in radians.
Definition viewport.h:242
double tilt
Tilt angle for perspective view in radians.
Definition viewport.h:244
double skew
Angular distortion (shear transform) applied to the viewport in radians.
Definition viewport.h:240
double chart_scale
Chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition viewport.h:247
Encapsulates persistent canvas configuration.
Stores emboss effect data for textures.
Definition emboss_data.h:35
OpenGL chart rendering canvas.
Represents a compass display in the OpenCPN navigation system.
Definition compass.h:39
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:60
Platform independent GL includes.
General purpose GUI support.
General observable implementation with several specializations.
A common variable shared between producer and consumer which supports Listen() and Notify().
PlugIn Object Definition/API.
void SetENCDisplayCategory(PI_DisCat cat, int CanvasIndex)
Sets ENC (Electronic Navigation Chart) feature display category.
PI_DisCat GetENCDisplayCategory(int CanvasIndex)
Gets current ENC display category.
void JumpToPosition(double lat, double lon, double scale)
Centers chart display on specified position at given scale.