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#include "observable_evtvar.h"
52#include "ocpn_plugin.h"
53
54class wxGLContext;
55class GSHHSChart;
56class IDX_entry;
57class ocpnCompass;
58class TimedPopupWin;
59class Track;
60
61// Useful static routines
62void ShowAISTargetQueryDialog(wxWindow *parent, int mmsi);
63
64//--------------------------------------------------------
65// Screen Brightness Control Support Routines
66//
67//--------------------------------------------------------
68
69int InitScreenBrightness(void);
70int RestoreScreenBrightness(void);
71int SetScreenBrightness(int brightness);
72
73// Set up the preferred quilt type
74#define QUILT_TYPE_2
75
76//----------------------------------------------------------------------------
77// Forward Declarations
78//----------------------------------------------------------------------------
79class Route;
80class TCWin;
81class RoutePoint;
82class SelectItem;
83class BoundingBox;
84class ocpnBitmap;
85class WVSChart;
86class MyFrame;
87class ChartBaseBSB;
88class ChartBase;
89class AisTargetData;
90class S57ObjectTree;
91class S57ObjectDesc;
92class RolloverWin;
93class Quilt;
94class PixelCache;
95class ChInfoWin;
96class glChartCanvas;
98class ChartStack;
99class Piano;
100class canvasConfig;
101class MUIBar;
102
103enum // specify the render behaviour of SetViewPoint()
104{
105 CURRENT_RENDER, // use the current render type
106 FORCE_SUBSAMPLE // force sub-sampled render, with re-render timer
107};
108
109// Cursor region enumerator
110enum {
111 CENTER,
112 MID_RIGHT,
113 MID_LEFT,
114 MID_TOP,
115 MID_BOT,
116};
117
118typedef enum ownship_state_t {
119 SHIP_NORMAL = 0,
120 SHIP_LOWACCURACY,
121 SHIP_INVALID
122} _ownship_state_t;
123
124enum { ID_S57QUERYTREECTRL = 10000, ID_AISDIALOGOK };
125
126enum {
127 ID_PIANO_DISABLE_QUILT_CHART = 32000,
128 ID_PIANO_ENABLE_QUILT_CHART,
129 ID_PIANO_CONTRACT_PIANO,
130 ID_PIANO_EXPAND_PIANO
131};
132
133enum { NORTH_UP_MODE, COURSE_UP_MODE, HEAD_UP_MODE };
134
153class ChartCanvas : public wxWindow {
154 friend class glChartCanvas;
155
156public:
157 ChartCanvas(wxFrame *frame, int canvasIndex, wxWindow *nmea_log);
158 ~ChartCanvas();
159
160 void SetupGlCanvas();
161
162 // Methods
163 void OnKeyDown(wxKeyEvent &event);
164 void OnKeyUp(wxKeyEvent &event);
165 void OnKeyChar(wxKeyEvent &event);
166 void OnPaint(wxPaintEvent &event);
167 void PaintCleanup();
168 void Scroll(int dx, int dy);
169 void ResetGridFont() { m_pgridFont = nullptr; }
170
171 void OnToolLeftClick(wxCommandEvent &event);
172
173 bool MouseEventOverlayWindows(wxMouseEvent &event);
174 bool MouseEventChartBar(wxMouseEvent &event);
175 bool MouseEventMUIBar(wxMouseEvent &event);
176 bool MouseEventToolbar(wxMouseEvent &event);
177 bool MouseEventIENCBar(wxMouseEvent &event);
178
179 bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick = true);
180 bool MouseEventProcessObjects(wxMouseEvent &event);
196 bool MouseEventProcessCanvas(wxMouseEvent &event);
197 void SetCanvasCursor(wxMouseEvent &event);
198 void OnKillFocus(wxFocusEvent &WXUNUSED(event));
199 void OnSetFocus(wxFocusEvent &WXUNUSED(event));
200#ifdef HAVE_WX_GESTURE_EVENTS
201 void OnZoom(wxZoomGestureEvent &event);
202 void OnLongPress(wxLongPressEvent &event);
203 void OnPressAndTap(wxPressAndTapEvent &event);
204
205 void OnLeftDown(wxMouseEvent &evt);
206 void OnLeftUp(wxMouseEvent &evt);
207
208 void OnRightUp(wxMouseEvent &event);
209 void OnRightDown(wxMouseEvent &event);
210
211 void OnDoubleLeftClick(wxMouseEvent &event);
212
213 void OnWheel(wxMouseEvent &event);
214 void OnMotion(wxMouseEvent &event);
215#endif /* HAVE_WX_GESTURE_EVENTS */
216
217 void PopupMenuHandler(wxCommandEvent &event);
218 bool IsPrimaryCanvas() { return (m_canvasIndex == 0); }
219
220 bool SetUserOwnship();
221
222 double GetCanvasRangeMeters();
223 void SetCanvasRangeMeters(double range);
224
225 void EnablePaint(bool b_enable);
226 virtual bool SetCursor(const wxCursor &c);
227 virtual void Refresh(bool eraseBackground = true,
228 const wxRect *rect = (const wxRect *)NULL);
229 virtual void Update();
230
231 void LostMouseCapture(wxMouseCaptureLostEvent &event);
232
233 void CancelMouseRoute();
237 void SetDisplaySizeMM(double size);
241 double GetDisplaySizeMM() { return m_display_size_mm; }
242
254 bool SetVPScale(double sc, bool b_refresh = true);
255 bool SetVPProjection(int projection);
263 bool SetViewPoint(double lat, double lon);
264 bool SetViewPointByCorners(double latSW, double lonSW, double latNE,
265 double lonNE);
280 bool SetViewPoint(double lat, double lon, double scale_ppm, double skew,
281 double rotation, int projection = 0, bool b_adjust = true,
282 bool b_refresh = true);
283 void ReloadVP(bool b_adjust = true);
284 void LoadVP(ViewPort &vp, bool b_adjust = true);
285
286 ChartStack *GetpCurrentStack() { return m_pCurrentStack; }
287 void SetGroupIndex(int index, bool autoswitch = false);
288 bool CheckGroup(int igroup);
289 void canvasRefreshGroupIndex(void);
290 void canvasChartsRefresh(int dbi_hint);
291
292 void CheckGroupValid(bool showMessage = true, bool switchGroup0 = true);
293
294 void UpdateCanvasS52PLIBConfig();
295
296 void TriggerDeferredFocus();
297 void OnDeferredFocusTimerEvent(wxTimerEvent &event);
298 void OnRouteFinishTimerEvent(wxTimerEvent &event);
299
300 void ClearS52PLIBStateHash() { m_s52StateHash = 0; }
301 void SetupCanvasQuiltMode(void);
302 void ApplyCanvasConfig(canvasConfig *pcc);
303
304 bool SetVPRotation(double angle);
305 double GetVPRotation(void) { return GetVP().rotation; }
306 double GetVPSkew(void) { return GetVP().skew; }
307 double GetVPTilt(void) { return GetVP().tilt; }
308
309 void ClearbFollow(void);
310 void SetbFollow(void);
311 void TogglebFollow(void);
312 bool GetbFollow() { return m_bFollow; }
313
314 void JumpToPosition(double lat, double lon, double scale);
315 void SetFirstAuto(bool b_auto) { m_bFirstAuto = b_auto; }
316 void SetAbsoluteMinScale(double min_scale);
317 std::shared_ptr<PI_PointContext> GetCanvasContextAtPoint(int x, int y);
318
331 void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
345 void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
346 wxPoint2DDouble *r);
347
364 bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
365
386 bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
387
403 void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
404 void WarpPointerDeferred(int x, int y);
405 void UpdateShips();
406 void UpdateAIS();
407 void UpdateAlerts(); // pjotrc 2010.02.22
408 void ToggleCPAWarn();
409
410 bool IsMeasureActive() { return m_bMeasure_Active; }
411 wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
412 Undo *undo;
413
414 int GetUpMode() { return m_upMode; }
415 bool GetLookahead() { return m_bLookAhead; }
416
417 void UnlockQuilt();
418 void SetQuiltMode(bool b_quilt);
419 bool GetQuiltMode(void);
420 std::vector<int> GetQuiltIndexArray(void);
421 bool IsQuiltDelta(void);
422 void SetQuiltChartHiLiteIndex(int dbIndex);
423 void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
424 void ClearQuiltChartHiLiteIndexArray();
425 int GetQuiltReferenceChartIndex(void);
426 double GetBestStartScale(int dbi_hint, const ViewPort &vp);
427 void ConfigureChartBar();
428
429 int GetNextContextMenuId();
430
431 TCWin *getTCWin() { return pCwin; }
432
433 bool StartTimedMovement(bool stoptimer = true);
434 void DoTimedMovement();
447 void DoMovement(long dt);
448 void StopMovement();
449
450 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
451 void DoTimedMovementVP();
452 void StopMovementVP();
453
454 void StartTimedMovementTarget();
455 void DoTimedMovementTarget();
456 void StopMovementTarget();
457
458 void SetColorScheme(ColorScheme cs);
459 ColorScheme GetColorScheme() { return m_cs; }
460
461 void CanvasApplyLocale();
462 void RebuildCursors();
463
464 // Accessors
465 int GetCanvasWidth() { return m_canvas_width; }
466 int GetCanvasHeight() { return m_canvas_height; }
468 float GetVPScale() { return GetVP().view_scale_ppm; }
471 float GetVPChartScale() { return GetVP().chart_scale; }
479 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
484 double GetCanvasTrueScale() { return m_true_scale_ppm; }
485 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
486 ViewPort *GetpVP() { return &VPoint; }
487 void SetVP(ViewPort &);
488 ChartBase *GetChartAtCursor();
489 ChartBase *GetOverlayChartAtCursor();
490 Piano *GetPiano() { return m_Piano; }
491 int GetPianoHeight();
492
493 bool isRouteEditing(void) {
494 return m_bRouteEditing && m_pRoutePointEditTarget;
495 }
496 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
497
498 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
499 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
500
501 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
502 bool GetbTCUpdate() { return m_bTCupdate; }
503 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
504 bool GetbShowCurrent() { return m_bShowCurrent; }
505 void SetbShowTide(bool f) { m_bShowTide = f; }
506 bool GetbShowTide() { return m_bShowTide; }
507 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
508 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
510 double GetPixPerMM() { return m_pix_per_mm; }
511
512 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
513 void SetCursorStatus(double cursor_lat, double cursor_lon);
514 void GetCursorLatLon(double *lat, double *lon);
517 bool PanCanvas(double dx, double dy);
518 void StopAutoPan(void);
519
538 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
539 bool stoptimer = true);
540
552 void ZoomCanvasSimple(double factor);
553
554 void RotateCanvas(double dir);
555 void DoRotateCanvas(double rotation);
556 void DoTiltCanvas(double tilt);
557
558 void ShowAISTargetList(void);
559
560 void ShowGoToPosition(void);
561 void HideGlobalToolbar();
562 void ShowGlobalToolbar();
563
564 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
565 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
566 bool GetShowGrid() { return m_bDisplayGrid; }
567 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
568 bool GetShowOutlines() { return m_bShowOutlines; }
569 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
570 bool GetShowChartbar() { return true; }
571 wxRect GetMUIBarRect();
572 void SetMUIBarPosition();
573 void DestroyMuiBar();
574 void CreateMUIBar();
575
576 void ToggleChartOutlines(void);
577 void ToggleCanvasQuiltMode(void);
578
579 wxString GetScaleText() { return m_scaleText; }
580 double GetScaleValue() { return m_scaleValue; }
581 bool GetShowAIS() { return m_bShowAIS; }
582 void SetShowAIS(bool show);
583 bool GetAttenAIS() { return m_bShowAISScaled; }
584 void SetAttenAIS(bool show);
585 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
586 bool GetShowFocusBar() { return m_show_focus_bar; }
587 MUIBar *GetMUIBar() { return m_muiBar; }
588 void SetAlertString(wxString str) { m_alertString = str; }
589 wxString GetAlertString() { return m_alertString; }
590 bool GetShowENCText() { return m_encShowText; }
591 void SetShowENCText(bool show);
592
593 bool GetShowENCDepth() { return m_encShowDepth; }
594 void SetShowENCDepth(bool show);
595
596 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
597 void SetShowENCLightDesc(bool show);
598
599 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
600 void SetShowENCBuoyLabels(bool show);
601
602 bool GetShowENCLights() { return m_encShowLights; }
603 void SetShowENCLights(bool show);
604
605 int GetENCDisplayCategory() { return m_encDisplayCategory; }
606 void SetENCDisplayCategory(int category);
607
608 bool GetShowENCAnchor() { return m_encShowAnchor; }
609 void SetShowENCAnchor(bool show);
610
611 bool GetShowENCDataQual() { return m_encShowDataQual; }
612 void SetShowENCDataQual(bool show);
613
614 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
615 int m_canvasIndex;
616 void ShowTides(bool bShow);
617 void ShowCurrents(bool bShow);
618 void SetUpMode(int mode);
619 void ToggleLookahead();
620 void SetShowGPS(bool show);
621 void UpdateFollowButtonState(void);
622 void InvalidateGL();
623 bool IsTileOverlayIndexInYesShow(int index);
624 bool IsTileOverlayIndexInNoShow(int index);
625 void AddTileOverlayIndexToNoShow(int index);
626 int m_groupIndex;
627 Route *m_pMouseRoute;
628 bool m_bMeasure_Active;
629 ViewPort &GetVP();
630 ChartBase *m_singleChart;
631 Quilt *m_pQuilt;
632 wxString FindValidUploadPort();
633 wxString m_active_upload_port;
634
635 // protected:
636
637 // private:
638 ChartBase *GetLargestScaleQuiltChart();
639 ChartBase *GetFirstQuiltChart();
640 ChartBase *GetNextQuiltChart();
641 int GetQuiltChartCount();
642 void InvalidateAllQuiltPatchs(void);
643 void SetQuiltRefChart(int dbIndex);
644 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
645 bool flag2 = true);
646 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
647 std::vector<int> &GetQuiltFullScreendbIndexArray();
648 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
649 int GetQuiltRefChartdbIndex(void);
650 void InvalidateQuilt(void);
651 double GetQuiltMaxErrorFactor();
652 bool IsChartQuiltableRef(int db_index);
653 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
654 int GetCanvasChartNativeScale();
655 int FindClosestCanvasChartdbIndex(int scale);
656 void UpdateCanvasOnGroupChange(void);
657
658 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
659 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
660 void ShowRoutePropertiesDialog(wxString title, Route *selected);
661 void ShowTrackPropertiesDialog(Track *selected);
662 void DrawTCWindow(int x, int y, void *pIDX);
663
664 void UpdateGPSCompassStatusBox(bool b_force_new);
665 ocpnCompass *GetCompass() { return m_Compass; }
666
667 wxColour GetFogColor() { return m_fog_color; }
668
669 void ShowChartInfoWindow(int x, int dbIndex);
670 void HideChartInfoWindow(void);
671 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
672 const std::vector<int> &index_vector);
673
674 void StartMeasureRoute();
675 void CancelMeasureRoute();
676
677 bool DoCanvasUpdate(void);
678 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
679 void SelectQuiltRefChart(int selected_index);
680 double GetBestVPScale(ChartBase *pchart);
681 void selectCanvasChartDisplay(int type, int family);
682 void RemoveChartFromQuilt(int dbIndex);
683
684 void HandlePianoClick(int selected_index,
685 const std::vector<int> &selected_dbIndex_array);
686 void HandlePianoRClick(int x, int y, int selected_index,
687 const std::vector<int> &selected_dbIndex_array);
688 void HandlePianoRollover(int selected_index,
689 const std::vector<int> &selected_dbIndex_array,
690 int n_charts, int scale);
691 void ClearPianoRollover();
692 void UpdateCanvasControlBar(void);
693 void FormatPianoKeys(void);
694 void PianoPopupMenu(int x, int y, int selected_index,
695 const std::vector<int> &selected_dbIndex_array);
696 void OnPianoMenuDisableChart(wxCommandEvent &event);
697 void OnPianoMenuEnableChart(wxCommandEvent &event);
698
699 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
700 bool DoCanvasCOGSet(void);
701 void ApplyGlobalSettings();
702 void SetShowGPSCompassWindow(bool bshow);
703 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
704 void FreezePiano() { m_pianoFrozen = true; }
705 void ThawPiano() { m_pianoFrozen = false; }
706 void StartChartDragInertia();
707 void SetupGridFont();
708
709 // Todo build more accessors
710 bool m_bFollow;
711 wxCursor *pCursorPencil;
712 wxCursor *pCursorArrow;
713 wxCursor *pCursorCross;
714 wxCursor *pPlugIn_Cursor;
715 TCWin *pCwin;
716 wxBitmap *pscratch_bm;
717 bool m_brepaint_piano;
750 wxPoint r_rband;
751 double m_prev_rlat;
752 double m_prev_rlon;
753 RoutePoint *m_prev_pMousePoint;
754 bool m_bShowNavobjects;
755 int m_routeState;
756 int m_upMode;
757 bool m_bLookAhead;
758
759#ifdef HAVE_WX_GESTURE_EVENTS
760 double m_oldVPSScale;
761 bool m_popupWanted;
762 bool m_leftdown;
763 wxPoint m_zoomStartPoint;
764#endif /* HAVE_WX_GESTURE_EVENTS */
765
766 void DrawBlinkObjects(void);
767
768 void StartRoute(void);
769 wxString FinishRoute(void);
770
771#ifdef ocpnUSE_GL
772 glChartCanvas *GetglCanvas() { return m_glcc; }
773#endif
774
775 bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
776
777 bool m_FinishRouteOnKillFocus;
778 bool m_bMeasure_DistCircle;
779 bool m_bAppendingRoute;
780 int m_nMeasureState;
781 Route *m_pMeasureRoute;
782 MyFrame *parent_frame;
783 CanvasMenuHandler *m_canvasMenu;
784 int GetMinAvailableGshhgQuality() {
785 return pWorldBackgroundChart->GetMinAvailableQuality();
786 }
787 int GetMaxAvailableGshhgQuality() {
788 return pWorldBackgroundChart->GetMaxAvailableQuality();
789 }
790 Route *GetSelectedRoute() const { return m_pSelectedRoute; }
791 Track *GetSelectedTrack() const { return m_pSelectedTrack; }
792 RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
793
794 void SetAISCanvasDisplayStyle(int StyleIndx);
795 void TouchAISToolActive(void);
796 void UpdateAISTBTool(void);
797
798 void SelectChartFromStack(int index, bool bDir = false,
799 ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
800 ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
801 void SelectdbChart(int dbindex);
802
803 void DoCanvasStackDelta(int direction);
804
805 void ProcessNewGUIScale();
806
807 bool m_b_paint_enable;
808
809 wxRect GetScaleBarRect() { return m_scaleBarRect; }
810 void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
811
812 std::vector<int> m_tile_noshow_index_array;
813 std::vector<int> m_tile_yesshow_index_array;
814 std::vector<int> m_quilt_noshow_index_array;
815
816 std::vector<int> GetQuiltNoshowIindexArray() {
817 return m_quilt_noshow_index_array;
818 }
828 double GetDisplayScale() { return m_displayScale; }
829 void ResetOwnshipOffset() { m_OSoffsetx = m_OSoffsety = 0; }
830 NotificationsList *GetNotificationsList() { return m_NotificationsList; }
831
832 int PrepareContextSelections(double lat, double lon);
833
834 RoutePoint *GetFoundRoutepoint() { return m_pFoundRoutePoint; }
835
841
842private:
856 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
857
858 int AdjustQuiltRefChart();
859 bool UpdateS52State();
860 void CallPopupMenu(int x, int y);
861 bool IsTempMenuBarEnabled();
862 bool InvokeCanvasMenu(int x, int y, int seltype);
863
864 ViewPort VPoint;
865 void PositionConsole(void);
866 wxWindow *m_nmea_log;
867
868 wxColour PredColor();
869 wxColour ShipColor();
870
871 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
872 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
873 wxPoint &GpsOffsetPixels,
874 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
875 float &scale_factor_y);
876
877 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
878 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
879 wxPoint2DDouble lGPSPoint);
880
881 ChInfoWin *m_pCIWin;
882
883 bool m_bShowCurrent;
884 bool m_bShowTide;
885 int cursor_region;
886 bool m_bTCupdate;
887 wxString m_scaleText;
888 double m_scaleValue;
889 bool m_bShowScaleInStatusBar;
890 wxRect bbRect;
891
892 wxPoint LastShipPoint;
893 wxPoint LastPredPoint;
894 bool m_bDrawingRoute;
895 bool m_bRouteEditing;
896 bool m_bMarkEditing;
897 bool m_bRoutePoinDragging;
898 bool m_bIsInRadius;
899 bool m_bMayToggleMenuBar;
900
901 RoutePoint *m_pRoutePointEditTarget;
902 RoutePoint *m_lastRoutePointEditTarget;
903 SelectItem *m_pFoundPoint;
904 bool m_bChartDragging;
905 Route *m_pSelectedRoute;
906 Track *m_pSelectedTrack;
907 wxArrayPtrVoid *m_pEditRouteArray;
908 RoutePoint *m_pFoundRoutePoint;
909
910 int m_FoundAIS_MMSI;
911
912 wxCursor *pCursorLeft;
913 wxCursor *pCursorRight;
914 wxCursor *pCursorUp;
915 wxCursor *pCursorDown;
916
917 wxCursor *pCursorUpLeft;
918 wxCursor *pCursorUpRight;
919 wxCursor *pCursorDownLeft;
920 wxCursor *pCursorDownRight;
921
922 int popx, popy;
923
924 wxBitmap *pThumbDIBShow;
925 wxBitmap *pThumbShowing;
926
927 bool bShowingCurrent;
928 bool bShowingTide;
929
936 double m_canvas_scale_factor;
938 double m_pix_per_mm;
939 double m_display_size_mm;
940
941 double m_absolute_min_scale_ppm;
942
943 bool singleClickEventIsValid;
944 wxMouseEvent singleClickEvent;
945
946 std::vector<s57Sector_t> extendedSectorLegs;
947 wxFont m_overzoomFont;
948 int m_overzoomTextWidth;
949 int m_overzoomTextHeight;
950
951 // Methods
952 void OnActivate(wxActivateEvent &event);
953 void OnSize(wxSizeEvent &event);
954 void MouseTimedEvent(wxTimerEvent &event);
955 void MouseEvent(wxMouseEvent &event);
956 void ShipDraw(ocpnDC &dc);
957 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
958 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
959 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
960
961 void RotateTimerEvent(wxTimerEvent &event);
962 void PanTimerEvent(wxTimerEvent &event);
963 void MovementTimerEvent(wxTimerEvent &);
964 void MovementStopTimerEvent(wxTimerEvent &);
965 void OnCursorTrackTimerEvent(wxTimerEvent &event);
966
967 void MovementVPTimerEvent(wxTimerEvent &event);
968
969 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
970 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
971 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
972 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
973 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
974 void DrawAnchorWatchPoints(ocpnDC &dc);
975 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
976
977 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
978 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
979 void RebuildTideSelectList(LLBBox &BBox);
980 void RebuildCurrentSelectList(LLBBox &BBox);
981
982 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
983 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
984 void RenderRouteLegs(ocpnDC &dc);
985 void RenderVisibleSectorLights(ocpnDC &dc);
986
987 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
988
989 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
990 void ScaleBarDraw(ocpnDC &dc);
991
992 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
993 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
994
995 emboss_data *EmbossDepthScale();
996 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
997 const wxString &str, ColorScheme cs);
998 void CreateDepthUnitEmbossMaps(ColorScheme cs);
999 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
1000
1001 void CreateOZEmbossMapData(ColorScheme cs);
1002 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
1003 void SetOverzoomFont();
1004
1005 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
1006 // void EmbossCM93Offset ( wxMemoryDC *pdc);
1007
1008 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
1009
1010 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
1011 void HandleNotificationMouseClick();
1012
1013 // Data
1015 int m_canvas_width;
1017 int m_canvas_height;
1018
1019 int xr_margin; // chart scroll margins, control cursor, etc.
1020 int xl_margin;
1021 int yt_margin;
1022 int yb_margin;
1023
1024 wxPoint last_drag;
1025
1026 wxMemoryDC *pmemdc;
1027
1028 int warp_x, warp_y;
1029 bool warp_flag;
1030
1031 wxTimer *
1032 pPanTimer; // This timer used for auto panning on route creation and edit
1033 wxTimer *
1034 pMovementTimer; // This timer used for smooth movement in non-opengl mode
1035 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
1036 // event is lost
1037 wxTimer *pCurTrackTimer; // This timer used to update the status window on
1038 // mouse idle
1039 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
1040 // mouse moves
1041 wxTimer *m_DoubleClickTimer;
1042 wxTimer m_routeFinishTimer;
1043
1044 wxTimer m_RolloverPopupTimer;
1045
1046 wxTimer m_VPMovementTimer;
1047
1048 int m_wheelzoom_stop_oneshot;
1049 int m_last_wheel_dir;
1050 wxStopWatch m_wheelstopwatch;
1051 double m_zoom_target;
1052
1053 int m_curtrack_timer_msec;
1054 int m_rollover_popup_timer_msec;
1055
1056 GSHHSChart *pWorldBackgroundChart;
1057
1058 ChartBaseBSB *pCBSB;
1059 wxBitmap *pss_overlay_bmp;
1060 wxMask *pss_overlay_mask;
1061
1062 wxRect ship_draw_rect;
1063 wxRect ship_draw_last_rect;
1064 wxRect ais_draw_rect;
1065 wxRect alert_draw_rect; // pjotrc 2010.02.22
1066
1067 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
1068 wxMemoryDC m_dc_route; // seen in mouse->edit->route
1069
1070 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
1071 emboss_data *m_pEM_Meters;
1072 emboss_data *m_pEM_Fathoms;
1073
1074 emboss_data *m_pEM_OverZoom;
1075 // emboss_data *m_pEM_CM93Offset; // Flav
1076
1092 double m_true_scale_ppm;
1093
1094 ownship_state_t m_ownship_state;
1095
1096 ColorScheme m_cs;
1097
1098 wxBitmap m_bmTideDay;
1099 wxBitmap m_bmTideDusk;
1100 wxBitmap m_bmTideNight;
1101 wxBitmap m_bmCurrentDay;
1102 wxBitmap m_bmCurrentDusk;
1103 wxBitmap m_bmCurrentNight;
1104 wxBitmap m_cTideBitmap;
1105 wxBitmap m_cCurrentBitmap;
1106
1107 RolloverWin *m_pRouteRolloverWin;
1108 RolloverWin *m_pTrackRolloverWin;
1109 RolloverWin *m_pAISRolloverWin;
1110
1111 TimedPopupWin *m_pBrightPopup;
1112
1113 wxImage m_os_image_red_day;
1114 wxImage m_os_image_red_dusk;
1115 wxImage m_os_image_red_night;
1116 wxImage m_os_image_grey_day;
1117 wxImage m_os_image_grey_dusk;
1118 wxImage m_os_image_grey_night;
1119 wxImage m_os_image_yellow_day;
1120 wxImage m_os_image_yellow_dusk;
1121 wxImage m_os_image_yellow_night;
1122
1123 wxImage *m_pos_image_red;
1124 wxImage *m_pos_image_grey;
1125 wxImage *m_pos_image_yellow;
1126
1127 wxImage *m_pos_image_user;
1128 wxImage *m_pos_image_user_grey;
1129 wxImage *m_pos_image_user_yellow;
1130
1131 wxImage *m_pos_image_user_day;
1132 wxImage *m_pos_image_user_dusk;
1133 wxImage *m_pos_image_user_night;
1134 wxImage *m_pos_image_user_grey_day;
1135 wxImage *m_pos_image_user_grey_dusk;
1136 wxImage *m_pos_image_user_grey_night;
1137 wxImage *m_pos_image_user_yellow_day;
1138 wxImage *m_pos_image_user_yellow_dusk;
1139 wxImage *m_pos_image_user_yellow_night;
1140
1141 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1142 int m_cur_ship_pix;
1143 bool m_cur_ship_pix_isgrey;
1144 ColorScheme m_ship_cs;
1145
1146 ViewPort m_cache_vp;
1147 wxBitmap *m_prot_bm;
1148 wxPoint m_roffset;
1149
1150 bool m_b_rot_hidef;
1151
1152 SelectItem *m_pRolloverRouteSeg;
1153 SelectItem *m_pRolloverTrackSeg;
1154
1155 double m_wheel_lat, m_wheel_lon;
1156 int m_wheel_x, m_wheel_y;
1157
1158 ViewPort m_bm_cache_vp;
1159 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1160 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1161
1162 bool m_bbrightdir;
1163 int m_brightmod;
1164
1165 bool m_bzooming, m_bzooming_to_cursor;
1166 IDX_entry *m_pIDXCandidate;
1167
1168 // #ifdef ocpnUSE_GL
1169 glChartCanvas *m_glcc;
1170 // #endif
1171
1172 // Smooth movement member variables
1173 wxPoint m_pan_drag;
1174 int m_panx, m_pany, m_modkeys;
1175 double m_panspeed;
1176 bool m_bmouse_key_mod;
1177 double m_zoom_factor, m_rotation_speed;
1183 int m_mustmove;
1184
1185 wxDateTime m_last_movement_time;
1186
1187 int m_AISRollover_MMSI;
1188 bool m_bsectors_shown;
1189 bool m_bedge_pan;
1190 double m_displayed_scale_factor;
1191
1192 wxColour m_fog_color;
1193 bool m_disable_edge_pan;
1194 wxFont *m_pgridFont;
1195
1196 bool m_dragoffsetSet;
1197
1198 bool m_bautofind;
1199 bool m_bFirstAuto;
1200 double m_vLat, m_vLon;
1201 ChartStack *m_pCurrentStack;
1202 Piano *m_Piano;
1203 bool m_bpersistent_quilt;
1204
1205 wxMenu *m_piano_ctx_menu;
1206 int menu_selected_dbIndex, menu_selected_index;
1207
1208 ocpnCompass *m_Compass;
1209 bool m_bShowGPS;
1210
1211 wxRect m_mainlast_tb_rect;
1212 int m_restore_dbindex;
1213 int m_restore_group;
1214
1215 MUIBar *m_muiBar;
1216 wxSize m_muiBarHOSize;
1217
1218 bool m_bShowOutlines;
1219 bool m_bDisplayGrid;
1220 bool m_bShowDepthUnits;
1221 bool m_bShowAIS;
1222 bool m_bShowAISScaled;
1223
1224 // S52PLib state storage
1225 long m_s52StateHash;
1226 bool m_encShowText;
1227 bool m_encShowDepth;
1228 bool m_encShowLightDesc;
1229 bool m_encShowBuoyLabels;
1230 int m_encDisplayCategory;
1231 bool m_encShowLights;
1232 bool m_encShowAnchor;
1233 bool m_encShowDataQual;
1234
1235 wxTimer m_deferredFocusTimer;
1236 float m_focus_indicator_pix;
1237 bool m_bENCGroup;
1238 bool m_last_TBviz;
1239
1240 double m_OSoffsetx, m_OSoffsety;
1241 bool m_MouseDragging;
1242
1243 wxString m_alertString;
1244 wxRect m_scaleBarRect;
1245 bool m_bShowCompassWin;
1246 bool m_pianoFrozen;
1247
1248 double m_sector_glat, m_sector_glon;
1249 std::vector<s57Sector_t> m_sectorlegsVisible;
1250 bool m_bShowVisibleSectors;
1252 double m_displayScale;
1253 bool m_show_focus_bar;
1254
1255 double m_panx_target_final;
1256 double m_pany_target_final;
1257 double m_panx_target_now;
1258 double m_pany_target_now;
1259
1260 double m_start_lat, m_start_lon;
1261 double m_target_lat, m_target_lon;
1262 double m_run_lat, m_run_lon;
1263 bool m_timed_move_vp_active;
1264 int m_timedVP_step;
1265 int m_stvpc;
1266
1267 double meters_to_shift = 0;
1268 double dir_to_shift = 0;
1269
1270 // Chart drag inertia support
1271 wxTimer m_chart_drag_inertia_timer;
1272 void OnChartDragInertiaTimer(wxTimerEvent &event);
1273
1274 uint64_t m_last_drag_time;
1275 int m_chart_drag_total_x;
1276 int m_chart_drag_total_y;
1277 double m_chart_drag_total_time;
1278 double m_chart_drag_velocity_x;
1279 double m_chart_drag_velocity_y;
1280 wxLongLong m_chart_drag_inertia_time;
1281 wxLongLong m_chart_drag_inertia_start_time;
1282 bool m_chart_drag_inertia_active;
1283 double m_last_elapsed;
1284 std::vector<int> m_drag_vec_x;
1285 std::vector<int> m_drag_vec_y;
1286 std::vector<double> m_drag_vec_t;
1287 int m_inertia_last_drag_x;
1288 int m_inertia_last_drag_y;
1289
1290 // For Jump animation
1291 wxTimer m_easeTimer;
1292 wxLongLong m_animationStart;
1293 wxLongLong m_animationDuration; // e.g. 300 ms
1294 double m_startLat, m_startLon, m_startScale;
1295 double m_endLat, m_endLon, m_endScale;
1296 bool m_animationActive;
1297 void OnJumpEaseTimer(wxTimerEvent &event);
1298 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1299
1300 NotificationButton *m_notification_button;
1301 NotificationsList *m_NotificationsList;
1302 ObservableListener evt_notificationlist_change_listener;
1303 DECLARE_EVENT_TABLE()
1304};
1305
1306// CUSTOMIZATION - FORMAT MINUTES
1307
1308wxString minutesToHoursDays(float timeInMinutes);
1309
1310// END OF CUSTOMIZATION - FORMAT MINUTES
1311
1316#ifndef wxCLOSE_BOX
1317#define wxCLOSE_BOX 0x1000
1318#endif
1319#ifndef wxFIXED_MINSIZE
1320#define wxFIXED_MINSIZE 0
1321#endif
1322
1323#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:153
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:4574
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:471
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4570
void DoMovement(long dt)
Performs a step of smooth movement animation on the chart canvas.
Definition chcanv.cpp:3669
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:4520
double m_cursor_lat
The latitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:749
double GetCanvasScaleFactor()
Return the number of logical pixels per meter for the screen.
Definition chcanv.h:479
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:510
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
Definition chcanv.h:241
double GetDisplayScale()
Get the ratio of physical to logical pixel for the display.
Definition chcanv.h:828
void SetDisplaySizeMM(double size)
Set the width of the screen in millimeters.
Definition chcanv.cpp:2406
int PrepareContextSelections(double lat, double lon)
Definition chcanv.cpp:8073
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition chcanv.cpp:7883
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:5098
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:468
EventVar json_msg
Notified with message targeting all plugins.
Definition chcanv.h:840
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:484
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4651
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5369
double m_cursor_lon
The longitude in degrees corresponding to the most recently processed cursor position.
Definition chcanv.h:733
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
Definition chcanv.cpp:4595
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:4657
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4515
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5388
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:10227
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:136
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
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
Basic DataMonitor logging interface: LogLine (reflects a line in the log) and NmeaLog,...
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.