OpenCPN Partial API docs
Loading...
Searching...
No Matches
chcanv.h
1
2/***************************************************************************
3 *
4 * Project: OpenCPN
5 * Purpose: Chart Canvas
6 * Author: David Register
7 *
8 ***************************************************************************
9 * Copyright (C) 2010 by David S. Register *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25 **************************************************************************/
26
27#ifndef _CHCANV_H__
28#define _CHCANV_H__
29
30#include <cstdint>
31#include "bbox.h"
32
33#include <wx/datetime.h>
34#include <wx/treectrl.h>
35#include <wx/dirctrl.h>
36#include <wx/sound.h>
37#include <wx/grid.h>
38#include <wx/wxhtml.h>
39
40#include "model/nmea_log.h"
41#include "ocpndc.h"
42#include "undo.h"
43
44#include "ocpCursor.h"
45#include "timers.h"
46#include "emboss_data.h"
47#include "S57Sector.h"
48#include "gshhs.h"
49#include "notification_manager_gui.h"
50#include "observable.h"
51
52class wxGLContext;
53class GSHHSChart;
54class IDX_entry;
55class ocpnCompass;
56class TimedPopupWin;
57class Track;
58
59// Useful static routines
60void ShowAISTargetQueryDialog(wxWindow *parent, int mmsi);
61
62//--------------------------------------------------------
63// Screen Brightness Control Support Routines
64//
65//--------------------------------------------------------
66
67int InitScreenBrightness(void);
68int RestoreScreenBrightness(void);
69int SetScreenBrightness(int brightness);
70
71// Set up the preferred quilt type
72#define QUILT_TYPE_2
73
74//----------------------------------------------------------------------------
75// Forward Declarations
76//----------------------------------------------------------------------------
77class Route;
78class TCWin;
79class RoutePoint;
80class SelectItem;
81class BoundingBox;
82class ocpnBitmap;
83class WVSChart;
84class MyFrame;
85class ChartBaseBSB;
86class ChartBase;
87class AisTargetData;
88class S57ObjectTree;
89class S57ObjectDesc;
90class RolloverWin;
91class Quilt;
92class PixelCache;
93class ChInfoWin;
94class glChartCanvas;
96class ChartStack;
97class Piano;
98class canvasConfig;
99class MUIBar;
100
101enum // specify the render behaviour of SetViewPoint()
102{
103 CURRENT_RENDER, // use the current render type
104 FORCE_SUBSAMPLE // force sub-sampled render, with re-render timer
105};
106
107// Cursor region enumerator
108enum {
109 CENTER,
110 MID_RIGHT,
111 MID_LEFT,
112 MID_TOP,
113 MID_BOT,
114};
115
116typedef enum ownship_state_t {
117 SHIP_NORMAL = 0,
118 SHIP_LOWACCURACY,
119 SHIP_INVALID
120} _ownship_state_t;
121
122enum { ID_S57QUERYTREECTRL = 10000, ID_AISDIALOGOK };
123
124enum {
125 ID_PIANO_DISABLE_QUILT_CHART = 32000,
126 ID_PIANO_ENABLE_QUILT_CHART,
127 ID_PIANO_CONTRACT_PIANO,
128 ID_PIANO_EXPAND_PIANO
129};
130
131enum { NORTH_UP_MODE, COURSE_UP_MODE, HEAD_UP_MODE };
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 virtual bool SetCursor(const wxCursor &c);
225 virtual void Refresh(bool eraseBackground = true,
226 const wxRect *rect = (const wxRect *)NULL);
227 virtual void Update();
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
327 void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
341 void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
342 wxPoint2DDouble *r);
343
360 bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
361
382 bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
383
399 void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
400 void WarpPointerDeferred(int x, int y);
401 void UpdateShips();
402 void UpdateAIS();
403 void UpdateAlerts(); // pjotrc 2010.02.22
404 void ToggleCPAWarn();
405
406 bool IsMeasureActive() { return m_bMeasure_Active; }
407 wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
408 Undo *undo;
409
410 int GetUpMode() { return m_upMode; }
411 bool GetLookahead() { return m_bLookAhead; }
412
413 void UnlockQuilt();
414 void SetQuiltMode(bool b_quilt);
415 bool GetQuiltMode(void);
416 std::vector<int> GetQuiltIndexArray(void);
417 bool IsQuiltDelta(void);
418 void SetQuiltChartHiLiteIndex(int dbIndex);
419 void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
420 void ClearQuiltChartHiLiteIndexArray();
421 int GetQuiltReferenceChartIndex(void);
422 double GetBestStartScale(int dbi_hint, const ViewPort &vp);
423 void ConfigureChartBar();
424
425 int GetNextContextMenuId();
426
427 TCWin *getTCWin() { return pCwin; }
428
429 bool StartTimedMovement(bool stoptimer = true);
430 void DoTimedMovement();
443 void DoMovement(long dt);
444 void StopMovement();
445
446 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
447 void DoTimedMovementVP();
448 void StopMovementVP();
449
450 void StartTimedMovementTarget();
451 void DoTimedMovementTarget();
452 void StopMovementTarget();
453
454 void SetColorScheme(ColorScheme cs);
455 ColorScheme GetColorScheme() { return m_cs; }
456
457 void CanvasApplyLocale();
458 void RebuildCursors();
459
460 // Accessors
461 int GetCanvasWidth() { return m_canvas_width; }
462 int GetCanvasHeight() { return m_canvas_height; }
464 float GetVPScale() { return GetVP().view_scale_ppm; }
467 float GetVPChartScale() { return GetVP().chart_scale; }
475 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
480 double GetCanvasTrueScale() { return m_true_scale_ppm; }
481 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
482 ViewPort *GetpVP() { return &VPoint; }
483 void SetVP(ViewPort &);
484 ChartBase *GetChartAtCursor();
485 ChartBase *GetOverlayChartAtCursor();
486 Piano *GetPiano() { return m_Piano; }
487 int GetPianoHeight();
488
489 bool isRouteEditing(void) {
490 return m_bRouteEditing && m_pRoutePointEditTarget;
491 }
492 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
493
494 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
495 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
496
497 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
498 bool GetbTCUpdate() { return m_bTCupdate; }
499 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
500 bool GetbShowCurrent() { return m_bShowCurrent; }
501 void SetbShowTide(bool f) { m_bShowTide = f; }
502 bool GetbShowTide() { return m_bShowTide; }
503 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
504 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
506 double GetPixPerMM() { return m_pix_per_mm; }
507
508 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
509 void SetCursorStatus(double cursor_lat, double cursor_lon);
510 void GetCursorLatLon(double *lat, double *lon);
513 bool PanCanvas(double dx, double dy);
514 void StopAutoPan(void);
515
534 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
535 bool stoptimer = true);
536
548 void ZoomCanvasSimple(double factor);
549
550 void RotateCanvas(double dir);
551 void DoRotateCanvas(double rotation);
552 void DoTiltCanvas(double tilt);
553
554 void ShowAISTargetList(void);
555
556 void ShowGoToPosition(void);
557 void HideGlobalToolbar();
558 void ShowGlobalToolbar();
559
560 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
561 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
562 bool GetShowGrid() { return m_bDisplayGrid; }
563 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
564 bool GetShowOutlines() { return m_bShowOutlines; }
565 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
566 bool GetShowChartbar() { return true; }
567 wxRect GetMUIBarRect();
568 void SetMUIBarPosition();
569 void DestroyMuiBar();
570 void CreateMUIBar();
571
572 void ToggleChartOutlines(void);
573 void ToggleCanvasQuiltMode(void);
574
575 wxString GetScaleText() { return m_scaleText; }
576 double GetScaleValue() { return m_scaleValue; }
577 bool GetShowAIS() { return m_bShowAIS; }
578 void SetShowAIS(bool show);
579 bool GetAttenAIS() { return m_bShowAISScaled; }
580 void SetAttenAIS(bool show);
581 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
582 bool GetShowFocusBar() { return m_show_focus_bar; }
583 MUIBar *GetMUIBar() { return m_muiBar; }
584 void SetAlertString(wxString str) { m_alertString = str; }
585 wxString GetAlertString() { return m_alertString; }
586 bool GetShowENCText() { return m_encShowText; }
587 void SetShowENCText(bool show);
588
589 bool GetShowENCDepth() { return m_encShowDepth; }
590 void SetShowENCDepth(bool show);
591
592 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
593 void SetShowENCLightDesc(bool show);
594
595 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
596 void SetShowENCBuoyLabels(bool show);
597
598 bool GetShowENCLights() { return m_encShowLights; }
599 void SetShowENCLights(bool show);
600
601 int GetENCDisplayCategory() { return m_encDisplayCategory; }
602 void SetENCDisplayCategory(int category);
603
604 bool GetShowENCAnchor() { return m_encShowAnchor; }
605 void SetShowENCAnchor(bool show);
606
607 bool GetShowENCDataQual() { return m_encShowDataQual; }
608 void SetShowENCDataQual(bool show);
609
610 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
611 int m_canvasIndex;
612 void ShowTides(bool bShow);
613 void ShowCurrents(bool bShow);
614 void SetUpMode(int mode);
615 void ToggleLookahead();
616 void SetShowGPS(bool show);
617 void UpdateFollowButtonState(void);
618 void InvalidateGL();
619 bool IsTileOverlayIndexInYesShow(int index);
620 bool IsTileOverlayIndexInNoShow(int index);
621 void AddTileOverlayIndexToNoShow(int index);
622 int m_groupIndex;
623 Route *m_pMouseRoute;
624 bool m_bMeasure_Active;
625 ViewPort &GetVP();
626 ChartBase *m_singleChart;
627 Quilt *m_pQuilt;
628 wxString FindValidUploadPort();
629 wxString m_active_upload_port;
630
631 // protected:
632
633 // private:
634 ChartBase *GetLargestScaleQuiltChart();
635 ChartBase *GetFirstQuiltChart();
636 ChartBase *GetNextQuiltChart();
637 int GetQuiltChartCount();
638 void InvalidateAllQuiltPatchs(void);
639 void SetQuiltRefChart(int dbIndex);
640 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
641 bool flag2 = true);
642 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
643 std::vector<int> &GetQuiltFullScreendbIndexArray();
644 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
645 int GetQuiltRefChartdbIndex(void);
646 void InvalidateQuilt(void);
647 double GetQuiltMaxErrorFactor();
648 bool IsChartQuiltableRef(int db_index);
649 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
650 int GetCanvasChartNativeScale();
651 int FindClosestCanvasChartdbIndex(int scale);
652 void UpdateCanvasOnGroupChange(void);
653
654 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
655 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
656 void ShowRoutePropertiesDialog(wxString title, Route *selected);
657 void ShowTrackPropertiesDialog(Track *selected);
658 void DrawTCWindow(int x, int y, void *pIDX);
659
660 void UpdateGPSCompassStatusBox(bool b_force_new);
661 ocpnCompass *GetCompass() { return m_Compass; }
662
663 wxColour GetFogColor() { return m_fog_color; }
664
665 void ShowChartInfoWindow(int x, int dbIndex);
666 void HideChartInfoWindow(void);
667 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
668 const std::vector<int> &index_vector);
669
670 void StartMeasureRoute();
671 void CancelMeasureRoute();
672
673 bool DoCanvasUpdate(void);
674 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
675 void SelectQuiltRefChart(int selected_index);
676 double GetBestVPScale(ChartBase *pchart);
677 void selectCanvasChartDisplay(int type, int family);
678 void RemoveChartFromQuilt(int dbIndex);
679
680 void HandlePianoClick(int selected_index,
681 const std::vector<int> &selected_dbIndex_array);
682 void HandlePianoRClick(int x, int y, int selected_index,
683 const std::vector<int> &selected_dbIndex_array);
684 void HandlePianoRollover(int selected_index,
685 const std::vector<int> &selected_dbIndex_array,
686 int n_charts, int scale);
687 void ClearPianoRollover();
688 void UpdateCanvasControlBar(void);
689 void FormatPianoKeys(void);
690 void PianoPopupMenu(int x, int y, int selected_index,
691 const std::vector<int> &selected_dbIndex_array);
692 void OnPianoMenuDisableChart(wxCommandEvent &event);
693 void OnPianoMenuEnableChart(wxCommandEvent &event);
694
695 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
696 bool DoCanvasCOGSet(void);
697 void ApplyGlobalSettings();
698 void SetShowGPSCompassWindow(bool bshow);
699 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
700 void FreezePiano() { m_pianoFrozen = true; }
701 void ThawPiano() { m_pianoFrozen = false; }
702 void StartChartDragInertia();
703 void SetupGridFont();
704
705 // Todo build more accessors
706 bool m_bFollow;
707 wxCursor *pCursorPencil;
708 wxCursor *pCursorArrow;
709 wxCursor *pCursorCross;
710 wxCursor *pPlugIn_Cursor;
711 TCWin *pCwin;
712 wxBitmap *pscratch_bm;
713 bool m_brepaint_piano;
746 wxPoint r_rband;
747 double m_prev_rlat;
748 double m_prev_rlon;
749 RoutePoint *m_prev_pMousePoint;
750 bool m_bShowNavobjects;
751 int m_routeState;
752 int m_upMode;
753 bool m_bLookAhead;
754
755#ifdef HAVE_WX_GESTURE_EVENTS
756 double m_oldVPSScale;
757 bool m_popupWanted;
758 bool m_leftdown;
759 wxPoint m_zoomStartPoint;
760#endif /* HAVE_WX_GESTURE_EVENTS */
761
762 void DrawBlinkObjects(void);
763
764 void StartRoute(void);
765 void FinishRoute(void);
766
767#ifdef ocpnUSE_GL
768 glChartCanvas *GetglCanvas() { return m_glcc; }
769#endif
770
771 bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
772
773 bool m_FinishRouteOnKillFocus;
774 bool m_bMeasure_DistCircle;
775 bool m_bAppendingRoute;
776 int m_nMeasureState;
777 Route *m_pMeasureRoute;
778 MyFrame *parent_frame;
779 CanvasMenuHandler *m_canvasMenu;
780 int GetMinAvailableGshhgQuality() {
781 return pWorldBackgroundChart->GetMinAvailableQuality();
782 }
783 int GetMaxAvailableGshhgQuality() {
784 return pWorldBackgroundChart->GetMaxAvailableQuality();
785 }
786 Route *GetSelectedRoute() const { return m_pSelectedRoute; }
787 Track *GetSelectedTrack() const { return m_pSelectedTrack; }
788 RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
789
790 void SetAISCanvasDisplayStyle(int StyleIndx);
791 void TouchAISToolActive(void);
792 void UpdateAISTBTool(void);
793
794 void SelectChartFromStack(int index, bool bDir = false,
795 ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
796 ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
797 void SelectdbChart(int dbindex);
798
799 void DoCanvasStackDelta(int direction);
800
801 void ProcessNewGUIScale();
802
803 bool m_b_paint_enable;
804
805 wxRect GetScaleBarRect() { return m_scaleBarRect; }
806 void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
807
808 std::vector<int> m_tile_noshow_index_array;
809 std::vector<int> m_tile_yesshow_index_array;
810 std::vector<int> m_quilt_noshow_index_array;
811
812 std::vector<int> GetQuiltNoshowIindexArray() {
813 return m_quilt_noshow_index_array;
814 }
824 double GetDisplayScale() { return m_displayScale; }
825 void ResetOwnshipOffset() { m_OSoffsetx = m_OSoffsety = 0; }
826 NotificationsList *GetNotificationsList() { return m_NotificationsList; }
827
828private:
842 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
843
844 int AdjustQuiltRefChart();
845
846 bool UpdateS52State();
847
848 void CallPopupMenu(int x, int y);
849
850 bool IsTempMenuBarEnabled();
851 bool InvokeCanvasMenu(int x, int y, int seltype);
852
853 ViewPort VPoint;
854 void PositionConsole(void);
855 wxWindow *m_nmea_log;
856
857 wxColour PredColor();
858 wxColour ShipColor();
859
860 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
861 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
862 wxPoint &GpsOffsetPixels,
863 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
864 float &scale_factor_y);
865
866 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
867 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
868 wxPoint2DDouble lGPSPoint);
869
870 ChInfoWin *m_pCIWin;
871
872 bool m_bShowCurrent;
873 bool m_bShowTide;
874 int cursor_region;
875 bool m_bTCupdate;
876 wxString m_scaleText;
877 double m_scaleValue;
878 bool m_bShowScaleInStatusBar;
879 wxRect bbRect;
880
881 wxPoint LastShipPoint;
882 wxPoint LastPredPoint;
883 bool m_bDrawingRoute;
884 bool m_bRouteEditing;
885 bool m_bMarkEditing;
886 bool m_bRoutePoinDragging;
887 bool m_bIsInRadius;
888 bool m_bMayToggleMenuBar;
889
890 RoutePoint *m_pRoutePointEditTarget;
891 RoutePoint *m_lastRoutePointEditTarget;
892 SelectItem *m_pFoundPoint;
893 bool m_bChartDragging;
894 Route *m_pSelectedRoute;
895 Track *m_pSelectedTrack;
896 wxArrayPtrVoid *m_pEditRouteArray;
897 RoutePoint *m_pFoundRoutePoint;
898
899 int m_FoundAIS_MMSI;
900
901 wxCursor *pCursorLeft;
902 wxCursor *pCursorRight;
903 wxCursor *pCursorUp;
904 wxCursor *pCursorDown;
905
906 wxCursor *pCursorUpLeft;
907 wxCursor *pCursorUpRight;
908 wxCursor *pCursorDownLeft;
909 wxCursor *pCursorDownRight;
910
911 int popx, popy;
912
913 wxBitmap *pThumbDIBShow;
914 wxBitmap *pThumbShowing;
915
916 bool bShowingCurrent;
917 bool bShowingTide;
918
925 double m_canvas_scale_factor;
927 double m_pix_per_mm;
928 double m_display_size_mm;
929
930 double m_absolute_min_scale_ppm;
931
932 bool singleClickEventIsValid;
933 wxMouseEvent singleClickEvent;
934
935 std::vector<s57Sector_t> extendedSectorLegs;
936 wxFont m_overzoomFont;
937 int m_overzoomTextWidth;
938 int m_overzoomTextHeight;
939
940 // Methods
941 void OnActivate(wxActivateEvent &event);
942 void OnSize(wxSizeEvent &event);
943 void MouseTimedEvent(wxTimerEvent &event);
944 void MouseEvent(wxMouseEvent &event);
945 void ShipDraw(ocpnDC &dc);
946 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
947 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
948 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
949
950 void RotateTimerEvent(wxTimerEvent &event);
951 void PanTimerEvent(wxTimerEvent &event);
952 void MovementTimerEvent(wxTimerEvent &);
953 void MovementStopTimerEvent(wxTimerEvent &);
954 void OnCursorTrackTimerEvent(wxTimerEvent &event);
955
956 void MovementVPTimerEvent(wxTimerEvent &event);
957
958 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
959 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
960 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
961 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
962 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
963 void DrawAnchorWatchPoints(ocpnDC &dc);
964 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
965
966 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
967 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
968 void RebuildTideSelectList(LLBBox &BBox);
969 void RebuildCurrentSelectList(LLBBox &BBox);
970
971 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
972 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
973 void RenderRouteLegs(ocpnDC &dc);
974 void RenderVisibleSectorLights(ocpnDC &dc);
975
976 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
977
978 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
979 void ScaleBarDraw(ocpnDC &dc);
980
981 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
982 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
983
984 emboss_data *EmbossDepthScale();
985 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
986 const wxString &str, ColorScheme cs);
987 void CreateDepthUnitEmbossMaps(ColorScheme cs);
988 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
989
990 void CreateOZEmbossMapData(ColorScheme cs);
991 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
992 void SetOverzoomFont();
993
994 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
995 // void EmbossCM93Offset ( wxMemoryDC *pdc);
996
997 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
998
999 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
1000 void HandleNotificationMouseClick();
1001
1002 // Data
1004 int m_canvas_width;
1006 int m_canvas_height;
1007
1008 int xr_margin; // chart scroll margins, control cursor, etc.
1009 int xl_margin;
1010 int yt_margin;
1011 int yb_margin;
1012
1013 wxPoint last_drag;
1014
1015 wxMemoryDC *pmemdc;
1016
1017 int warp_x, warp_y;
1018 bool warp_flag;
1019
1020 wxTimer *
1021 pPanTimer; // This timer used for auto panning on route creation and edit
1022 wxTimer *
1023 pMovementTimer; // This timer used for smooth movement in non-opengl mode
1024 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
1025 // event is lost
1026 wxTimer *pCurTrackTimer; // This timer used to update the status window on
1027 // mouse idle
1028 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
1029 // mouse moves
1030 wxTimer *m_DoubleClickTimer;
1031 wxTimer m_routeFinishTimer;
1032
1033 wxTimer m_RolloverPopupTimer;
1034
1035 wxTimer m_VPMovementTimer;
1036
1037 int m_wheelzoom_stop_oneshot;
1038 int m_last_wheel_dir;
1039 wxStopWatch m_wheelstopwatch;
1040 double m_zoom_target;
1041
1042 int m_curtrack_timer_msec;
1043 int m_rollover_popup_timer_msec;
1044
1045 GSHHSChart *pWorldBackgroundChart;
1046
1047 ChartBaseBSB *pCBSB;
1048 wxBitmap *pss_overlay_bmp;
1049 wxMask *pss_overlay_mask;
1050
1051 wxRect ship_draw_rect;
1052 wxRect ship_draw_last_rect;
1053 wxRect ais_draw_rect;
1054 wxRect alert_draw_rect; // pjotrc 2010.02.22
1055
1056 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
1057 wxMemoryDC m_dc_route; // seen in mouse->edit->route
1058
1059 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
1060 emboss_data *m_pEM_Meters;
1061 emboss_data *m_pEM_Fathoms;
1062
1063 emboss_data *m_pEM_OverZoom;
1064 // emboss_data *m_pEM_CM93Offset; // Flav
1065
1081 double m_true_scale_ppm;
1082
1083 ownship_state_t m_ownship_state;
1084
1085 ColorScheme m_cs;
1086
1087 wxBitmap m_bmTideDay;
1088 wxBitmap m_bmTideDusk;
1089 wxBitmap m_bmTideNight;
1090 wxBitmap m_bmCurrentDay;
1091 wxBitmap m_bmCurrentDusk;
1092 wxBitmap m_bmCurrentNight;
1093 wxBitmap m_cTideBitmap;
1094 wxBitmap m_cCurrentBitmap;
1095
1096 RolloverWin *m_pRouteRolloverWin;
1097 RolloverWin *m_pTrackRolloverWin;
1098 RolloverWin *m_pAISRolloverWin;
1099
1100 TimedPopupWin *m_pBrightPopup;
1101
1102 wxImage m_os_image_red_day;
1103 wxImage m_os_image_red_dusk;
1104 wxImage m_os_image_red_night;
1105 wxImage m_os_image_grey_day;
1106 wxImage m_os_image_grey_dusk;
1107 wxImage m_os_image_grey_night;
1108 wxImage m_os_image_yellow_day;
1109 wxImage m_os_image_yellow_dusk;
1110 wxImage m_os_image_yellow_night;
1111
1112 wxImage *m_pos_image_red;
1113 wxImage *m_pos_image_grey;
1114 wxImage *m_pos_image_yellow;
1115
1116 wxImage *m_pos_image_user;
1117 wxImage *m_pos_image_user_grey;
1118 wxImage *m_pos_image_user_yellow;
1119
1120 wxImage *m_pos_image_user_day;
1121 wxImage *m_pos_image_user_dusk;
1122 wxImage *m_pos_image_user_night;
1123 wxImage *m_pos_image_user_grey_day;
1124 wxImage *m_pos_image_user_grey_dusk;
1125 wxImage *m_pos_image_user_grey_night;
1126 wxImage *m_pos_image_user_yellow_day;
1127 wxImage *m_pos_image_user_yellow_dusk;
1128 wxImage *m_pos_image_user_yellow_night;
1129
1130 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1131 int m_cur_ship_pix;
1132 bool m_cur_ship_pix_isgrey;
1133 ColorScheme m_ship_cs;
1134
1135 ViewPort m_cache_vp;
1136 wxBitmap *m_prot_bm;
1137 wxPoint m_roffset;
1138
1139 bool m_b_rot_hidef;
1140
1141 SelectItem *m_pRolloverRouteSeg;
1142 SelectItem *m_pRolloverTrackSeg;
1143
1144 double m_wheel_lat, m_wheel_lon;
1145 int m_wheel_x, m_wheel_y;
1146
1147 ViewPort m_bm_cache_vp;
1148 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1149 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1150
1151 bool m_bbrightdir;
1152 int m_brightmod;
1153
1154 bool m_bzooming, m_bzooming_to_cursor;
1155 IDX_entry *m_pIDXCandidate;
1156
1157 // #ifdef ocpnUSE_GL
1158 glChartCanvas *m_glcc;
1159 // #endif
1160
1161 // Smooth movement member variables
1162 wxPoint m_pan_drag;
1163 int m_panx, m_pany, m_modkeys;
1164 double m_panspeed;
1165 bool m_bmouse_key_mod;
1166 double m_zoom_factor, m_rotation_speed;
1172 int m_mustmove;
1173
1174 wxDateTime m_last_movement_time;
1175
1176 int m_AISRollover_MMSI;
1177 bool m_bsectors_shown;
1178 bool m_bedge_pan;
1179 double m_displayed_scale_factor;
1180
1181 wxColour m_fog_color;
1182 bool m_disable_edge_pan;
1183 wxFont *m_pgridFont;
1184
1185 bool m_dragoffsetSet;
1186
1187 bool m_bautofind;
1188 bool m_bFirstAuto;
1189 double m_vLat, m_vLon;
1190 ChartStack *m_pCurrentStack;
1191 Piano *m_Piano;
1192 bool m_bpersistent_quilt;
1193
1194 wxMenu *m_piano_ctx_menu;
1195 int menu_selected_dbIndex, menu_selected_index;
1196
1197 ocpnCompass *m_Compass;
1198 bool m_bShowGPS;
1199
1200 wxRect m_mainlast_tb_rect;
1201 int m_restore_dbindex;
1202 int m_restore_group;
1203
1204 MUIBar *m_muiBar;
1205 wxSize m_muiBarHOSize;
1206
1207 bool m_bShowOutlines;
1208 bool m_bDisplayGrid;
1209 bool m_bShowDepthUnits;
1210 bool m_bShowAIS;
1211 bool m_bShowAISScaled;
1212
1213 // S52PLib state storage
1214 long m_s52StateHash;
1215 bool m_encShowText;
1216 bool m_encShowDepth;
1217 bool m_encShowLightDesc;
1218 bool m_encShowBuoyLabels;
1219 int m_encDisplayCategory;
1220 bool m_encShowLights;
1221 bool m_encShowAnchor;
1222 bool m_encShowDataQual;
1223
1224 wxTimer m_deferredFocusTimer;
1225 float m_focus_indicator_pix;
1226 bool m_bENCGroup;
1227 bool m_last_TBviz;
1228
1229 double m_OSoffsetx, m_OSoffsety;
1230 bool m_MouseDragging;
1231
1232 wxString m_alertString;
1233 wxRect m_scaleBarRect;
1234 bool m_bShowCompassWin;
1235 bool m_pianoFrozen;
1236
1237 double m_sector_glat, m_sector_glon;
1238 std::vector<s57Sector_t> m_sectorlegsVisible;
1239 bool m_bShowVisibleSectors;
1241 double m_displayScale;
1242 bool m_show_focus_bar;
1243
1244 double m_panx_target_final;
1245 double m_pany_target_final;
1246 double m_panx_target_now;
1247 double m_pany_target_now;
1248
1249 double m_start_lat, m_start_lon;
1250 double m_target_lat, m_target_lon;
1251 double m_run_lat, m_run_lon;
1252 bool m_timed_move_vp_active;
1253 int m_timedVP_step;
1254 int m_stvpc;
1255
1256 double meters_to_shift = 0;
1257 double dir_to_shift = 0;
1258
1259 // Chart drag inertia support
1260 wxTimer m_chart_drag_inertia_timer;
1261 void OnChartDragInertiaTimer(wxTimerEvent &event);
1262
1263 uint64_t m_last_drag_time;
1264 int m_chart_drag_total_x;
1265 int m_chart_drag_total_y;
1266 double m_chart_drag_total_time;
1267 double m_chart_drag_velocity_x;
1268 double m_chart_drag_velocity_y;
1269 wxLongLong m_chart_drag_inertia_time;
1270 wxLongLong m_chart_drag_inertia_start_time;
1271 bool m_chart_drag_inertia_active;
1272 double m_last_elapsed;
1273 std::vector<int> m_drag_vec_x;
1274 std::vector<int> m_drag_vec_y;
1275 std::vector<double> m_drag_vec_t;
1276 int m_inertia_last_drag_x;
1277 int m_inertia_last_drag_y;
1278
1279 // For Jump animation
1280 wxTimer m_easeTimer;
1281 wxLongLong m_animationStart;
1282 wxLongLong m_animationDuration; // e.g. 300 ms
1283 double m_startLat, m_startLon, m_startScale;
1284 double m_endLat, m_endLon, m_endScale;
1285 bool m_animationActive;
1286 void OnJumpEaseTimer(wxTimerEvent &event);
1287 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1288
1289 NotificationButton *m_notification_button;
1290 NotificationsList *m_NotificationsList;
1291 ObservableListener evt_notificationlist_change_listener;
1292 DECLARE_EVENT_TABLE()
1293};
1294
1295// CUSTOMIZATION - FORMAT MINUTES
1296
1297wxString minutesToHoursDays(float timeInMinutes);
1298
1299// END OF CUSTOMIZATION - FORMAT MINUTES
1300
1305#ifndef wxCLOSE_BOX
1306#define wxCLOSE_BOX 0x1000
1307#endif
1308#ifndef wxFIXED_MINSIZE
1309#define wxFIXED_MINSIZE 0
1310#endif
1311
1312#endif // _CHCANV_H__
Handles context menu events for the chart canvas.
Definition canvasMenu.h:82
A custom panel for displaying chart information.
Definition ChInfoWin.h:36
Base class for BSB (Maptech/NOS) format nautical charts.
Definition chartimg.h:131
Base class for all chart types.
Definition chartbase.h:119
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:151
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:4571
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:467
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4567
void DoMovement(long dt)
Performs a step of smooth movement animation on the chart canvas.
Definition chcanv.cpp:3666
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:4517
double m_cursor_lat
The latitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:745
double GetCanvasScaleFactor()
Return the number of logical pixels per meter for the screen.
Definition chcanv.h:475
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:506
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:824
void SetDisplaySizeMM(double size)
Set the width of the screen in millimeters.
Definition chcanv.cpp:2403
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition chcanv.cpp:7573
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:5070
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:464
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:480
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4648
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5349
double m_cursor_lon
The longitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:729
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
Definition chcanv.cpp:4592
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:4654
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4512
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5368
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:9921
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:136
Keeps listening over it's lifespan, removes itself on destruction.
Definition observable.h:131
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
Describes an S57 object (feature) in an Electronic Navigational Chart.
Definition TCWin.h:46
Represents a track, which is a series of connected track points.
Definition track.h:111
Definition undo.h:60
ViewPort - Core geographic projection and coordinate transformation engine.
Definition viewport.h:81
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
Definition viewport.h:229
double rotation
Rotation angle of the viewport in radians.
Definition viewport.h:239
double tilt
Tilt angle for perspective view in radians.
Definition viewport.h:241
double skew
Angular distortion (shear transform) applied to the viewport in radians.
Definition viewport.h:237
double chart_scale
Chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition viewport.h:244
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:37
Device context class that can use either wxDC or OpenGL for drawing.
Definition ocpndc.h:64
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.