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 OnToolLeftClick(wxCommandEvent &event);
168
169 bool MouseEventOverlayWindows(wxMouseEvent &event);
170 bool MouseEventChartBar(wxMouseEvent &event);
171 bool MouseEventMUIBar(wxMouseEvent &event);
172 bool MouseEventToolbar(wxMouseEvent &event);
173 bool MouseEventIENCBar(wxMouseEvent &event);
174
175 bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick = true);
176 bool MouseEventProcessObjects(wxMouseEvent &event);
192 bool MouseEventProcessCanvas(wxMouseEvent &event);
193 void SetCanvasCursor(wxMouseEvent &event);
194 void OnKillFocus(wxFocusEvent &WXUNUSED(event));
195 void OnSetFocus(wxFocusEvent &WXUNUSED(event));
196#ifdef HAVE_WX_GESTURE_EVENTS
197 void OnZoom(wxZoomGestureEvent &event);
198 void OnLongPress(wxLongPressEvent &event);
199 void OnPressAndTap(wxPressAndTapEvent &event);
200
201 void OnLeftDown(wxMouseEvent &evt);
202 void OnLeftUp(wxMouseEvent &evt);
203
204 void OnRightUp(wxMouseEvent &event);
205 void OnRightDown(wxMouseEvent &event);
206
207 void OnDoubleLeftClick(wxMouseEvent &event);
208
209 void OnWheel(wxMouseEvent &event);
210 void OnMotion(wxMouseEvent &event);
211#endif /* HAVE_WX_GESTURE_EVENTS */
212
213 void PopupMenuHandler(wxCommandEvent &event);
214 bool IsPrimaryCanvas() { return (m_canvasIndex == 0); }
215
216 bool SetUserOwnship();
217
218 double GetCanvasRangeMeters();
219 void SetCanvasRangeMeters(double range);
220
221 void EnablePaint(bool b_enable);
222 virtual bool SetCursor(const wxCursor &c);
223 virtual void Refresh(bool eraseBackground = true,
224 const wxRect *rect = (const wxRect *)NULL);
225 virtual void Update();
226
227 void LostMouseCapture(wxMouseCaptureLostEvent &event);
228
229 void CancelMouseRoute();
233 void SetDisplaySizeMM(double size);
237 double GetDisplaySizeMM() { return m_display_size_mm; }
238
250 bool SetVPScale(double sc, bool b_refresh = true);
251 bool SetVPProjection(int projection);
259 bool SetViewPoint(double lat, double lon);
260 bool SetViewPointByCorners(double latSW, double lonSW, double latNE,
261 double lonNE);
276 bool SetViewPoint(double lat, double lon, double scale_ppm, double skew,
277 double rotation, int projection = 0, bool b_adjust = true,
278 bool b_refresh = true);
279 void ReloadVP(bool b_adjust = true);
280 void LoadVP(ViewPort &vp, bool b_adjust = true);
281
282 ChartStack *GetpCurrentStack() { return m_pCurrentStack; }
283 void SetGroupIndex(int index, bool autoswitch = false);
284 bool CheckGroup(int igroup);
285 void canvasRefreshGroupIndex(void);
286 void canvasChartsRefresh(int dbi_hint);
287
288 void CheckGroupValid(bool showMessage = true, bool switchGroup0 = true);
289
290 void UpdateCanvasS52PLIBConfig();
291
292 void TriggerDeferredFocus();
293 void OnDeferredFocusTimerEvent(wxTimerEvent &event);
294 void OnRouteFinishTimerEvent(wxTimerEvent &event);
295
296 void ClearS52PLIBStateHash() { m_s52StateHash = 0; }
297 void SetupCanvasQuiltMode(void);
298 void ApplyCanvasConfig(canvasConfig *pcc);
299
300 bool SetVPRotation(double angle);
301 double GetVPRotation(void) { return GetVP().rotation; }
302 double GetVPSkew(void) { return GetVP().skew; }
303 double GetVPTilt(void) { return GetVP().tilt; }
304
305 void ClearbFollow(void);
306 void SetbFollow(void);
307 void TogglebFollow(void);
308 bool GetbFollow() { return m_bFollow; }
309
310 void JumpToPosition(double lat, double lon, double scale);
311 void SetFirstAuto(bool b_auto) { m_bFirstAuto = b_auto; }
312
325 void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
339 void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
340 wxPoint2DDouble *r);
341
358 bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
359
380 bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
381
397 void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
398 void WarpPointerDeferred(int x, int y);
399 void UpdateShips();
400 void UpdateAIS();
401 void UpdateAlerts(); // pjotrc 2010.02.22
402 void ToggleCPAWarn();
403
404 bool IsMeasureActive() { return m_bMeasure_Active; }
405 wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
406 Undo *undo;
407
408 int GetUpMode() { return m_upMode; }
409 bool GetLookahead() { return m_bLookAhead; }
410
411 void UnlockQuilt();
412 void SetQuiltMode(bool b_quilt);
413 bool GetQuiltMode(void);
414 std::vector<int> GetQuiltIndexArray(void);
415 bool IsQuiltDelta(void);
416 void SetQuiltChartHiLiteIndex(int dbIndex);
417 void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
418 void ClearQuiltChartHiLiteIndexArray();
419 int GetQuiltReferenceChartIndex(void);
420 double GetBestStartScale(int dbi_hint, const ViewPort &vp);
421 void ConfigureChartBar();
422
423 int GetNextContextMenuId();
424
425 TCWin *getTCWin() { return pCwin; }
426
427 bool StartTimedMovement(bool stoptimer = true);
428 void DoTimedMovement();
441 void DoMovement(long dt);
442 void StopMovement();
443
444 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
445 void DoTimedMovementVP();
446 void StopMovementVP();
447
448 void StartTimedMovementTarget();
449 void DoTimedMovementTarget();
450 void StopMovementTarget();
451
452 void SetColorScheme(ColorScheme cs);
453 ColorScheme GetColorScheme() { return m_cs; }
454
455 void CanvasApplyLocale();
456 void RebuildCursors();
457
458 // Accessors
459 int GetCanvasWidth() { return m_canvas_width; }
460 int GetCanvasHeight() { return m_canvas_height; }
462 float GetVPScale() { return GetVP().view_scale_ppm; }
465 float GetVPChartScale() { return GetVP().chart_scale; }
473 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
478 double GetCanvasTrueScale() { return m_true_scale_ppm; }
479 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
480 ViewPort *GetpVP() { return &VPoint; }
481 void SetVP(ViewPort &);
482 ChartBase *GetChartAtCursor();
483 ChartBase *GetOverlayChartAtCursor();
484 Piano *GetPiano() { return m_Piano; }
485 int GetPianoHeight();
486
487 bool isRouteEditing(void) {
488 return m_bRouteEditing && m_pRoutePointEditTarget;
489 }
490 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
491
492 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
493 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
494
495 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
496 bool GetbTCUpdate() { return m_bTCupdate; }
497 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
498 bool GetbShowCurrent() { return m_bShowCurrent; }
499 void SetbShowTide(bool f) { m_bShowTide = f; }
500 bool GetbShowTide() { return m_bShowTide; }
501 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
502 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
504 double GetPixPerMM() { return m_pix_per_mm; }
505
506 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
507 void SetCursorStatus(double cursor_lat, double cursor_lon);
508 void GetCursorLatLon(double *lat, double *lon);
511 bool PanCanvas(double dx, double dy);
512 void StopAutoPan(void);
513
532 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
533 bool stoptimer = true);
534
546 void ZoomCanvasSimple(double factor);
547
561 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
562
563 void RotateCanvas(double dir);
564 void DoRotateCanvas(double rotation);
565 void DoTiltCanvas(double tilt);
566
567 void ShowAISTargetList(void);
568
569 void ShowGoToPosition(void);
570 void HideGlobalToolbar();
571 void ShowGlobalToolbar();
572
573 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
574 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
575 bool GetShowGrid() { return m_bDisplayGrid; }
576 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
577 bool GetShowOutlines() { return m_bShowOutlines; }
578 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
579 bool GetShowChartbar() { return true; }
580 wxRect GetMUIBarRect();
581 void SetMUIBarPosition();
582 void DestroyMuiBar();
583 void CreateMUIBar();
584
585 void ToggleChartOutlines(void);
586 void ToggleCanvasQuiltMode(void);
587
588 wxString GetScaleText() { return m_scaleText; }
589 double GetScaleValue() { return m_scaleValue; }
590 bool GetShowAIS() { return m_bShowAIS; }
591 void SetShowAIS(bool show);
592 bool GetAttenAIS() { return m_bShowAISScaled; }
593 void SetAttenAIS(bool show);
594 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
595 bool GetShowFocusBar() { return m_show_focus_bar; }
596 MUIBar *GetMUIBar() { return m_muiBar; }
597 void SetAlertString(wxString str) { m_alertString = str; }
598 wxString GetAlertString() { return m_alertString; }
599 bool GetShowENCText() { return m_encShowText; }
600 void SetShowENCText(bool show);
601
602 bool GetShowENCDepth() { return m_encShowDepth; }
603 void SetShowENCDepth(bool show);
604
605 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
606 void SetShowENCLightDesc(bool show);
607
608 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
609 void SetShowENCBuoyLabels(bool show);
610
611 bool GetShowENCLights() { return m_encShowLights; }
612 void SetShowENCLights(bool show);
613
614 int GetENCDisplayCategory() { return m_encDisplayCategory; }
615 void SetENCDisplayCategory(int category);
616
617 bool GetShowENCAnchor() { return m_encShowAnchor; }
618 void SetShowENCAnchor(bool show);
619
620 bool GetShowENCDataQual() { return m_encShowDataQual; }
621 void SetShowENCDataQual(bool show);
622
623 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
624 int m_canvasIndex;
625 void ShowTides(bool bShow);
626 void ShowCurrents(bool bShow);
627 void SetUpMode(int mode);
628 void ToggleLookahead();
629 void SetShowGPS(bool show);
630 void UpdateFollowButtonState(void);
631 void InvalidateGL();
632 bool IsTileOverlayIndexInYesShow(int index);
633 bool IsTileOverlayIndexInNoShow(int index);
634 void AddTileOverlayIndexToNoShow(int index);
635 int m_groupIndex;
636 Route *m_pMouseRoute;
637 bool m_bMeasure_Active;
638 ViewPort &GetVP();
639 ChartBase *m_singleChart;
640 Quilt *m_pQuilt;
641 wxString FindValidUploadPort();
642 wxString m_active_upload_port;
643
644 // protected:
645
646 // private:
647 ChartBase *GetLargestScaleQuiltChart();
648 ChartBase *GetFirstQuiltChart();
649 ChartBase *GetNextQuiltChart();
650 int GetQuiltChartCount();
651 void InvalidateAllQuiltPatchs(void);
652 void SetQuiltRefChart(int dbIndex);
653 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
654 bool flag2 = true);
655 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
656 std::vector<int> &GetQuiltFullScreendbIndexArray();
657 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
658 int GetQuiltRefChartdbIndex(void);
659 void InvalidateQuilt(void);
660 double GetQuiltMaxErrorFactor();
661 bool IsChartQuiltableRef(int db_index);
662 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
663 int GetCanvasChartNativeScale();
664 int FindClosestCanvasChartdbIndex(int scale);
665 void UpdateCanvasOnGroupChange(void);
666
667 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
668 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
669 void ShowRoutePropertiesDialog(wxString title, Route *selected);
670 void ShowTrackPropertiesDialog(Track *selected);
671 void DrawTCWindow(int x, int y, void *pIDX);
672
673 void UpdateGPSCompassStatusBox(bool b_force_new);
674 ocpnCompass *GetCompass() { return m_Compass; }
675
676 wxColour GetFogColor() { return m_fog_color; }
677
678 void ShowChartInfoWindow(int x, int dbIndex);
679 void HideChartInfoWindow(void);
680 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
681 const std::vector<int> &index_vector);
682
683 void StartMeasureRoute();
684 void CancelMeasureRoute();
685
686 bool DoCanvasUpdate(void);
687 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
688 void SelectQuiltRefChart(int selected_index);
689 double GetBestVPScale(ChartBase *pchart);
690 void selectCanvasChartDisplay(int type, int family);
691 void RemoveChartFromQuilt(int dbIndex);
692
693 void HandlePianoClick(int selected_index,
694 const std::vector<int> &selected_dbIndex_array);
695 void HandlePianoRClick(int x, int y, int selected_index,
696 const std::vector<int> &selected_dbIndex_array);
697 void HandlePianoRollover(int selected_index,
698 const std::vector<int> &selected_dbIndex_array,
699 int n_charts, int scale);
700 void ClearPianoRollover();
701 void UpdateCanvasControlBar(void);
702 void FormatPianoKeys(void);
703 void PianoPopupMenu(int x, int y, int selected_index,
704 const std::vector<int> &selected_dbIndex_array);
705 void OnPianoMenuDisableChart(wxCommandEvent &event);
706 void OnPianoMenuEnableChart(wxCommandEvent &event);
707
708 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
709 bool DoCanvasCOGSet(void);
710 void ApplyGlobalSettings();
711 void SetShowGPSCompassWindow(bool bshow);
712 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
713 void FreezePiano() { m_pianoFrozen = true; }
714 void ThawPiano() { m_pianoFrozen = false; }
715 void StartChartDragInertia();
716
717 // Todo build more accessors
718 bool m_bFollow;
719 wxCursor *pCursorPencil;
720 wxCursor *pCursorArrow;
721 wxCursor *pCursorCross;
722 wxCursor *pPlugIn_Cursor;
723 TCWin *pCwin;
724 wxBitmap *pscratch_bm;
725 bool m_brepaint_piano;
758 wxPoint r_rband;
759 double m_prev_rlat;
760 double m_prev_rlon;
761 RoutePoint *m_prev_pMousePoint;
762 bool m_bShowNavobjects;
763 int m_routeState;
764 int m_upMode;
765 bool m_bLookAhead;
766
767#ifdef HAVE_WX_GESTURE_EVENTS
768 double m_oldVPSScale;
769 bool m_popupWanted;
770 bool m_leftdown;
771 wxPoint m_zoomStartPoint;
772#endif /* HAVE_WX_GESTURE_EVENTS */
773
774 void DrawBlinkObjects(void);
775
776 void StartRoute(void);
777 void FinishRoute(void);
778
779#ifdef ocpnUSE_GL
780 glChartCanvas *GetglCanvas() { return m_glcc; }
781#endif
782
783 bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
784
785 bool m_FinishRouteOnKillFocus;
786 bool m_bMeasure_DistCircle;
787 bool m_bAppendingRoute;
788 int m_nMeasureState;
789 Route *m_pMeasureRoute;
790 MyFrame *parent_frame;
791 CanvasMenuHandler *m_canvasMenu;
792 int GetMinAvailableGshhgQuality() {
793 return pWorldBackgroundChart->GetMinAvailableQuality();
794 }
795 int GetMaxAvailableGshhgQuality() {
796 return pWorldBackgroundChart->GetMaxAvailableQuality();
797 }
798 Route *GetSelectedRoute() const { return m_pSelectedRoute; }
799 Track *GetSelectedTrack() const { return m_pSelectedTrack; }
800 RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
801
802 void SetAISCanvasDisplayStyle(int StyleIndx);
803 void TouchAISToolActive(void);
804 void UpdateAISTBTool(void);
805
806 void SelectChartFromStack(int index, bool bDir = false,
807 ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
808 ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
809 void SelectdbChart(int dbindex);
810
811 void DoCanvasStackDelta(int direction);
812
813 void ProcessNewGUIScale();
814
815 bool m_b_paint_enable;
816
817 wxRect GetScaleBarRect() { return m_scaleBarRect; }
818 void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
819
820 std::vector<int> m_tile_noshow_index_array;
821 std::vector<int> m_tile_yesshow_index_array;
822 std::vector<int> m_quilt_noshow_index_array;
823
824 std::vector<int> GetQuiltNoshowIindexArray() {
825 return m_quilt_noshow_index_array;
826 }
836 double GetDisplayScale() { return m_displayScale; }
837 void ResetOwnshipOffset() { m_OSoffsetx = m_OSoffsety = 0; }
838
839private:
840 int AdjustQuiltRefChart();
841
842 bool UpdateS52State();
843
844 void CallPopupMenu(int x, int y);
845
846 bool IsTempMenuBarEnabled();
847 bool InvokeCanvasMenu(int x, int y, int seltype);
848
849 ViewPort VPoint;
850 void PositionConsole(void);
851 wxWindow *m_nmea_log;
852
853 wxColour PredColor();
854 wxColour ShipColor();
855
856 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
857 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
858 wxPoint &GpsOffsetPixels,
859 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
860 float &scale_factor_y);
861
862 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
863 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
864 wxPoint2DDouble lGPSPoint);
865
866 ChInfoWin *m_pCIWin;
867
868 bool m_bShowCurrent;
869 bool m_bShowTide;
870 int cursor_region;
871 bool m_bTCupdate;
872 wxString m_scaleText;
873 double m_scaleValue;
874 bool m_bShowScaleInStatusBar;
875 wxRect bbRect;
876
877 wxPoint LastShipPoint;
878 wxPoint LastPredPoint;
879 bool m_bDrawingRoute;
880 bool m_bRouteEditing;
881 bool m_bMarkEditing;
882 bool m_bRoutePoinDragging;
883 bool m_bIsInRadius;
884 bool m_bMayToggleMenuBar;
885
886 RoutePoint *m_pRoutePointEditTarget;
887 RoutePoint *m_lastRoutePointEditTarget;
888 SelectItem *m_pFoundPoint;
889 bool m_bChartDragging;
890 Route *m_pSelectedRoute;
891 Track *m_pSelectedTrack;
892 wxArrayPtrVoid *m_pEditRouteArray;
893 RoutePoint *m_pFoundRoutePoint;
894
895 int m_FoundAIS_MMSI;
896
897 wxCursor *pCursorLeft;
898 wxCursor *pCursorRight;
899 wxCursor *pCursorUp;
900 wxCursor *pCursorDown;
901
902 wxCursor *pCursorUpLeft;
903 wxCursor *pCursorUpRight;
904 wxCursor *pCursorDownLeft;
905 wxCursor *pCursorDownRight;
906
907 int popx, popy;
908
909 wxBitmap *pThumbDIBShow;
910 wxBitmap *pThumbShowing;
911
912 bool bShowingCurrent;
913 bool bShowingTide;
914
921 double m_canvas_scale_factor;
923 double m_pix_per_mm;
924 double m_display_size_mm;
925
926 double m_absolute_min_scale_ppm;
927
928 bool singleClickEventIsValid;
929 wxMouseEvent singleClickEvent;
930
931 std::vector<s57Sector_t> extendedSectorLegs;
932 wxFont m_overzoomFont;
933 int m_overzoomTextWidth;
934 int m_overzoomTextHeight;
935
936 // Methods
937 void OnActivate(wxActivateEvent &event);
938 void OnSize(wxSizeEvent &event);
939 void MouseTimedEvent(wxTimerEvent &event);
940 void MouseEvent(wxMouseEvent &event);
941 void ShipDraw(ocpnDC &dc);
942 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
943 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
944 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
945
946 void RotateTimerEvent(wxTimerEvent &event);
947 void PanTimerEvent(wxTimerEvent &event);
948 void MovementTimerEvent(wxTimerEvent &);
949 void MovementStopTimerEvent(wxTimerEvent &);
950 void OnCursorTrackTimerEvent(wxTimerEvent &event);
951
952 void MovementVPTimerEvent(wxTimerEvent &event);
953
954 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
955 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
956 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
957 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
958 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
959 void DrawAnchorWatchPoints(ocpnDC &dc);
960 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
961
962 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
963 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
964 void RebuildTideSelectList(LLBBox &BBox);
965 void RebuildCurrentSelectList(LLBBox &BBox);
966
967 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
968 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
969 void RenderRouteLegs(ocpnDC &dc);
970 void RenderVisibleSectorLights(ocpnDC &dc);
971
972 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
973
974 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
975 void ScaleBarDraw(ocpnDC &dc);
976
977 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
978 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
979
980 emboss_data *EmbossDepthScale();
981 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
982 const wxString &str, ColorScheme cs);
983 void CreateDepthUnitEmbossMaps(ColorScheme cs);
984 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
985
986 void CreateOZEmbossMapData(ColorScheme cs);
987 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
988 void SetOverzoomFont();
989
990 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
991 // void EmbossCM93Offset ( wxMemoryDC *pdc);
992
993 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
994
995 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
996 void HandleNotificationMouseClick();
997
998 // Data
1000 int m_canvas_width;
1002 int m_canvas_height;
1003
1004 int xr_margin; // chart scroll margins, control cursor, etc.
1005 int xl_margin;
1006 int yt_margin;
1007 int yb_margin;
1008
1009 wxPoint last_drag;
1010
1011 wxMemoryDC *pmemdc;
1012
1013 int warp_x, warp_y;
1014 bool warp_flag;
1015
1016 wxTimer *
1017 pPanTimer; // This timer used for auto panning on route creation and edit
1018 wxTimer *
1019 pMovementTimer; // This timer used for smooth movement in non-opengl mode
1020 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
1021 // event is lost
1022 wxTimer *pCurTrackTimer; // This timer used to update the status window on
1023 // mouse idle
1024 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
1025 // mouse moves
1026 wxTimer *m_DoubleClickTimer;
1027 wxTimer m_routeFinishTimer;
1028
1029 wxTimer m_RolloverPopupTimer;
1030
1031 wxTimer m_VPMovementTimer;
1032
1033 int m_wheelzoom_stop_oneshot;
1034 int m_last_wheel_dir;
1035 wxStopWatch m_wheelstopwatch;
1036 double m_zoom_target;
1037
1038 int m_curtrack_timer_msec;
1039 int m_rollover_popup_timer_msec;
1040
1041 GSHHSChart *pWorldBackgroundChart;
1042
1043 ChartBaseBSB *pCBSB;
1044 wxBitmap *pss_overlay_bmp;
1045 wxMask *pss_overlay_mask;
1046
1047 wxRect ship_draw_rect;
1048 wxRect ship_draw_last_rect;
1049 wxRect ais_draw_rect;
1050 wxRect alert_draw_rect; // pjotrc 2010.02.22
1051
1052 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
1053 wxMemoryDC m_dc_route; // seen in mouse->edit->route
1054
1055 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
1056 emboss_data *m_pEM_Meters;
1057 emboss_data *m_pEM_Fathoms;
1058
1059 emboss_data *m_pEM_OverZoom;
1060 // emboss_data *m_pEM_CM93Offset; // Flav
1061
1077 double m_true_scale_ppm;
1078
1079 ownship_state_t m_ownship_state;
1080
1081 ColorScheme m_cs;
1082
1083 wxBitmap m_bmTideDay;
1084 wxBitmap m_bmTideDusk;
1085 wxBitmap m_bmTideNight;
1086 wxBitmap m_bmCurrentDay;
1087 wxBitmap m_bmCurrentDusk;
1088 wxBitmap m_bmCurrentNight;
1089 wxBitmap m_cTideBitmap;
1090 wxBitmap m_cCurrentBitmap;
1091
1092 RolloverWin *m_pRouteRolloverWin;
1093 RolloverWin *m_pTrackRolloverWin;
1094 RolloverWin *m_pAISRolloverWin;
1095
1096 TimedPopupWin *m_pBrightPopup;
1097
1098 wxImage m_os_image_red_day;
1099 wxImage m_os_image_red_dusk;
1100 wxImage m_os_image_red_night;
1101 wxImage m_os_image_grey_day;
1102 wxImage m_os_image_grey_dusk;
1103 wxImage m_os_image_grey_night;
1104 wxImage m_os_image_yellow_day;
1105 wxImage m_os_image_yellow_dusk;
1106 wxImage m_os_image_yellow_night;
1107
1108 wxImage *m_pos_image_red;
1109 wxImage *m_pos_image_grey;
1110 wxImage *m_pos_image_yellow;
1111
1112 wxImage *m_pos_image_user;
1113 wxImage *m_pos_image_user_grey;
1114 wxImage *m_pos_image_user_yellow;
1115
1116 wxImage *m_pos_image_user_day;
1117 wxImage *m_pos_image_user_dusk;
1118 wxImage *m_pos_image_user_night;
1119 wxImage *m_pos_image_user_grey_day;
1120 wxImage *m_pos_image_user_grey_dusk;
1121 wxImage *m_pos_image_user_grey_night;
1122 wxImage *m_pos_image_user_yellow_day;
1123 wxImage *m_pos_image_user_yellow_dusk;
1124 wxImage *m_pos_image_user_yellow_night;
1125
1126 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1127 int m_cur_ship_pix;
1128 bool m_cur_ship_pix_isgrey;
1129 ColorScheme m_ship_cs;
1130
1131 ViewPort m_cache_vp;
1132 wxBitmap *m_prot_bm;
1133 wxPoint m_roffset;
1134
1135 bool m_b_rot_hidef;
1136
1137 SelectItem *m_pRolloverRouteSeg;
1138 SelectItem *m_pRolloverTrackSeg;
1139
1140 double m_wheel_lat, m_wheel_lon;
1141 int m_wheel_x, m_wheel_y;
1142
1143 ViewPort m_bm_cache_vp;
1144 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1145 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1146
1147 bool m_bbrightdir;
1148 int m_brightmod;
1149
1150 bool m_bzooming, m_bzooming_to_cursor;
1151 IDX_entry *m_pIDXCandidate;
1152
1153 // #ifdef ocpnUSE_GL
1154 glChartCanvas *m_glcc;
1155 // #endif
1156
1157 // Smooth movement member variables
1158 wxPoint m_pan_drag;
1159 int m_panx, m_pany, m_modkeys;
1160 double m_panspeed;
1161 bool m_bmouse_key_mod;
1162 double m_zoom_factor, m_rotation_speed;
1168 int m_mustmove;
1169
1170 wxDateTime m_last_movement_time;
1171
1172 int m_AISRollover_MMSI;
1173 bool m_bsectors_shown;
1174 bool m_bedge_pan;
1175 double m_displayed_scale_factor;
1176
1177 wxColour m_fog_color;
1178 bool m_disable_edge_pan;
1179 wxFont *m_pgridFont;
1180
1181 bool m_dragoffsetSet;
1182
1183 bool m_bautofind;
1184 bool m_bFirstAuto;
1185 double m_vLat, m_vLon;
1186 ChartStack *m_pCurrentStack;
1187 Piano *m_Piano;
1188 bool m_bpersistent_quilt;
1189
1190 wxMenu *m_piano_ctx_menu;
1191 int menu_selected_dbIndex, menu_selected_index;
1192
1193 ocpnCompass *m_Compass;
1194 bool m_bShowGPS;
1195
1196 wxRect m_mainlast_tb_rect;
1197 int m_restore_dbindex;
1198 int m_restore_group;
1199
1200 MUIBar *m_muiBar;
1201 wxSize m_muiBarHOSize;
1202
1203 bool m_bShowOutlines;
1204 bool m_bDisplayGrid;
1205 bool m_bShowDepthUnits;
1206 bool m_bShowAIS;
1207 bool m_bShowAISScaled;
1208
1209 // S52PLib state storage
1210 long m_s52StateHash;
1211 bool m_encShowText;
1212 bool m_encShowDepth;
1213 bool m_encShowLightDesc;
1214 bool m_encShowBuoyLabels;
1215 int m_encDisplayCategory;
1216 bool m_encShowLights;
1217 bool m_encShowAnchor;
1218 bool m_encShowDataQual;
1219
1220 wxTimer m_deferredFocusTimer;
1221 float m_focus_indicator_pix;
1222 bool m_bENCGroup;
1223 bool m_last_TBviz;
1224
1225 double m_OSoffsetx, m_OSoffsety;
1226 bool m_MouseDragging;
1227
1228 wxString m_alertString;
1229 wxRect m_scaleBarRect;
1230 bool m_bShowCompassWin;
1231 bool m_pianoFrozen;
1232
1233 double m_sector_glat, m_sector_glon;
1234 std::vector<s57Sector_t> m_sectorlegsVisible;
1235 bool m_bShowVisibleSectors;
1237 double m_displayScale;
1238 bool m_show_focus_bar;
1239
1240 double m_panx_target_final;
1241 double m_pany_target_final;
1242 double m_panx_target_now;
1243 double m_pany_target_now;
1244
1245 double m_start_lat, m_start_lon;
1246 double m_target_lat, m_target_lon;
1247 double m_run_lat, m_run_lon;
1248 bool m_timed_move_vp_active;
1249 int m_timedVP_step;
1250 int m_stvpc;
1251
1252 double meters_to_shift = 0;
1253 double dir_to_shift = 0;
1254
1255 // Chart drag inertia support
1256 wxTimer m_chart_drag_inertia_timer;
1257 void OnChartDragInertiaTimer(wxTimerEvent &event);
1258
1259 uint64_t m_last_drag_time;
1260 int m_chart_drag_total_x;
1261 int m_chart_drag_total_y;
1262 double m_chart_drag_total_time;
1263 double m_chart_drag_velocity_x;
1264 double m_chart_drag_velocity_y;
1265 wxLongLong m_chart_drag_inertia_time;
1266 wxLongLong m_chart_drag_inertia_start_time;
1267 bool m_chart_drag_inertia_active;
1268 double m_last_elapsed;
1269 std::vector<int> m_drag_vec_x;
1270 std::vector<int> m_drag_vec_y;
1271 std::vector<double> m_drag_vec_t;
1272 int m_inertia_last_drag_x;
1273 int m_inertia_last_drag_y;
1274
1275 // For Jump animation
1276 wxTimer m_easeTimer;
1277 wxLongLong m_animationStart;
1278 wxLongLong m_animationDuration; // e.g. 300 ms
1279 double m_startLat, m_startLon, m_startScale;
1280 double m_endLat, m_endLon, m_endScale;
1281 bool m_animationActive;
1282 void OnJumpEaseTimer(wxTimerEvent &event);
1283 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1284
1285 NotificationButton *m_notification_button;
1286 NotificationsList *m_NotificationsList;
1287 ObservableListener evt_notificationlist_change_listener;
1288 DECLARE_EVENT_TABLE()
1289};
1290
1291// CUSTOMIZATION - FORMAT MINUTES
1292
1293wxString minutesToHoursDays(float timeInMinutes);
1294
1295// END OF CUSTOMIZATION - FORMAT MINUTES
1296
1301#ifndef wxCLOSE_BOX
1302#define wxCLOSE_BOX 0x1000
1303#endif
1304#ifndef wxFIXED_MINSIZE
1305#define wxFIXED_MINSIZE 0
1306#endif
1307
1308#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:4553
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:465
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4549
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:4499
double m_cursor_lat
The latitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:757
double GetCanvasScaleFactor()
Return the number of logical pixels per meter for the screen.
Definition chcanv.h:473
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:504
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
Definition chcanv.h:237
double GetDisplayScale()
Get the ratio of physical to logical pixel for the display.
Definition chcanv.h:836
void SetDisplaySizeMM(double size)
Set the width of the screen in millimeters.
Definition chcanv.cpp:2402
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition chcanv.cpp:7558
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:5050
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:462
void DoZoomCanvas(double factor, bool can_zoom_to_cursor=true)
Internal function that implements the actual zoom operation.
Definition chcanv.cpp:4655
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:478
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4630
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5329
double m_cursor_lon
The longitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:741
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
Definition chcanv.cpp:4574
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:4635
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4494
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5348
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:9878
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.