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();
429 void DoMovement(long dt);
430 void StopMovement();
431
432 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
433 void DoTimedMovementVP();
434 void StopMovementVP();
435
436 void StartTimedMovementTarget();
437 void DoTimedMovementTarget();
438 void StopMovementTarget();
439
440 void SetColorScheme(ColorScheme cs);
441 ColorScheme GetColorScheme() { return m_cs; }
442
443 void CanvasApplyLocale();
444 void RebuildCursors();
445
446 // Accessors
447 int GetCanvasWidth() { return m_canvas_width; }
448 int GetCanvasHeight() { return m_canvas_height; }
450 float GetVPScale() { return GetVP().view_scale_ppm; }
453 float GetVPChartScale() { return GetVP().chart_scale; }
461 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
466 double GetCanvasTrueScale() { return m_true_scale_ppm; }
467 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
468 ViewPort *GetpVP() { return &VPoint; }
469 void SetVP(ViewPort &);
470 ChartBase *GetChartAtCursor();
471 ChartBase *GetOverlayChartAtCursor();
472 Piano *GetPiano() { return m_Piano; }
473 int GetPianoHeight();
474
475 bool isRouteEditing(void) {
476 return m_bRouteEditing && m_pRoutePointEditTarget;
477 }
478 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
479
480 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
481 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
482
483 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
484 bool GetbTCUpdate() { return m_bTCupdate; }
485 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
486 bool GetbShowCurrent() { return m_bShowCurrent; }
487 void SetbShowTide(bool f) { m_bShowTide = f; }
488 bool GetbShowTide() { return m_bShowTide; }
489 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
490 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
492 double GetPixPerMM() { return m_pix_per_mm; }
493
494 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
495 void SetCursorStatus(double cursor_lat, double cursor_lon);
496 void GetCursorLatLon(double *lat, double *lon);
499 bool PanCanvas(double dx, double dy);
500 void StopAutoPan(void);
501
520 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
521 bool stoptimer = true);
522
534 void ZoomCanvasSimple(double factor);
535
549 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
550
551 void RotateCanvas(double dir);
552 void DoRotateCanvas(double rotation);
553 void DoTiltCanvas(double tilt);
554
555 void ShowAISTargetList(void);
556
557 void ShowGoToPosition(void);
558 void HideGlobalToolbar();
559 void ShowGlobalToolbar();
560
561 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
562 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
563 bool GetShowGrid() { return m_bDisplayGrid; }
564 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
565 bool GetShowOutlines() { return m_bShowOutlines; }
566 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
567 bool GetShowChartbar() { return true; }
568 wxRect GetMUIBarRect();
569 void SetMUIBarPosition();
570 void DestroyMuiBar();
571 void CreateMUIBar();
572
573 void ToggleChartOutlines(void);
574 void ToggleCanvasQuiltMode(void);
575
576 wxString GetScaleText() { return m_scaleText; }
577 double GetScaleValue() { return m_scaleValue; }
578 bool GetShowAIS() { return m_bShowAIS; }
579 void SetShowAIS(bool show);
580 bool GetAttenAIS() { return m_bShowAISScaled; }
581 void SetAttenAIS(bool show);
582 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
583 bool GetShowFocusBar() { return m_show_focus_bar; }
584 MUIBar *GetMUIBar() { return m_muiBar; }
585 void SetAlertString(wxString str) { m_alertString = str; }
586 wxString GetAlertString() { return m_alertString; }
587 bool GetShowENCText() { return m_encShowText; }
588 void SetShowENCText(bool show);
589
590 bool GetShowENCDepth() { return m_encShowDepth; }
591 void SetShowENCDepth(bool show);
592
593 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
594 void SetShowENCLightDesc(bool show);
595
596 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
597 void SetShowENCBuoyLabels(bool show);
598
599 bool GetShowENCLights() { return m_encShowLights; }
600 void SetShowENCLights(bool show);
601
602 int GetENCDisplayCategory() { return m_encDisplayCategory; }
603 void SetENCDisplayCategory(int category);
604
605 bool GetShowENCAnchor() { return m_encShowAnchor; }
606 void SetShowENCAnchor(bool show);
607
608 bool GetShowENCDataQual() { return m_encShowDataQual; }
609 void SetShowENCDataQual(bool show);
610
611 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
612 int m_canvasIndex;
613 void ShowTides(bool bShow);
614 void ShowCurrents(bool bShow);
615 void SetUpMode(int mode);
616 void ToggleLookahead();
617 void SetShowGPS(bool show);
618 void UpdateFollowButtonState(void);
619 void InvalidateGL();
620 bool IsTileOverlayIndexInYesShow(int index);
621 bool IsTileOverlayIndexInNoShow(int index);
622 void AddTileOverlayIndexToNoShow(int index);
623 int m_groupIndex;
624 Route *m_pMouseRoute;
625 bool m_bMeasure_Active;
626 ViewPort &GetVP();
627 ChartBase *m_singleChart;
628 Quilt *m_pQuilt;
629 wxString FindValidUploadPort();
630 wxString m_active_upload_port;
631
632 // protected:
633
634 // private:
635 ChartBase *GetLargestScaleQuiltChart();
636 ChartBase *GetFirstQuiltChart();
637 ChartBase *GetNextQuiltChart();
638 int GetQuiltChartCount();
639 void InvalidateAllQuiltPatchs(void);
640 void SetQuiltRefChart(int dbIndex);
641 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
642 bool flag2 = true);
643 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
644 std::vector<int> &GetQuiltFullScreendbIndexArray();
645 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
646 int GetQuiltRefChartdbIndex(void);
647 void InvalidateQuilt(void);
648 double GetQuiltMaxErrorFactor();
649 bool IsChartQuiltableRef(int db_index);
650 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
651 int GetCanvasChartNativeScale();
652 int FindClosestCanvasChartdbIndex(int scale);
653 void UpdateCanvasOnGroupChange(void);
654
655 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
656 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
657 void ShowRoutePropertiesDialog(wxString title, Route *selected);
658 void ShowTrackPropertiesDialog(Track *selected);
659 void DrawTCWindow(int x, int y, void *pIDX);
660
661 void UpdateGPSCompassStatusBox(bool b_force_new);
662 ocpnCompass *GetCompass() { return m_Compass; }
663
664 wxColour GetFogColor() { return m_fog_color; }
665
666 void ShowChartInfoWindow(int x, int dbIndex);
667 void HideChartInfoWindow(void);
668 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
669 const std::vector<int> &index_vector);
670
671 void StartMeasureRoute();
672 void CancelMeasureRoute();
673
674 bool DoCanvasUpdate(void);
675 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
676 void SelectQuiltRefChart(int selected_index);
677 double GetBestVPScale(ChartBase *pchart);
678 void selectCanvasChartDisplay(int type, int family);
679 void RemoveChartFromQuilt(int dbIndex);
680
681 void HandlePianoClick(int selected_index,
682 const std::vector<int> &selected_dbIndex_array);
683 void HandlePianoRClick(int x, int y, int selected_index,
684 const std::vector<int> &selected_dbIndex_array);
685 void HandlePianoRollover(int selected_index,
686 const std::vector<int> &selected_dbIndex_array,
687 int n_charts, int scale);
688 void ClearPianoRollover();
689 void UpdateCanvasControlBar(void);
690 void FormatPianoKeys(void);
691 void PianoPopupMenu(int x, int y, int selected_index,
692 const std::vector<int> &selected_dbIndex_array);
693 void OnPianoMenuDisableChart(wxCommandEvent &event);
694 void OnPianoMenuEnableChart(wxCommandEvent &event);
695
696 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
697 bool DoCanvasCOGSet(void);
698 void ApplyGlobalSettings();
699 void SetShowGPSCompassWindow(bool bshow);
700 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
701 void FreezePiano() { m_pianoFrozen = true; }
702 void ThawPiano() { m_pianoFrozen = false; }
703 void StartChartDragInertia();
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
827private:
828 int AdjustQuiltRefChart();
829
830 bool UpdateS52State();
831
832 void CallPopupMenu(int x, int y);
833
834 bool IsTempMenuBarEnabled();
835 bool InvokeCanvasMenu(int x, int y, int seltype);
836
837 ViewPort VPoint;
838 void PositionConsole(void);
839 wxWindow *m_nmea_log;
840
841 wxColour PredColor();
842 wxColour ShipColor();
843
844 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
845 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
846 wxPoint &GpsOffsetPixels,
847 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
848 float &scale_factor_y);
849
850 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
851 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
852 wxPoint2DDouble lGPSPoint);
853
854 ChInfoWin *m_pCIWin;
855
856 bool m_bShowCurrent;
857 bool m_bShowTide;
858 int cursor_region;
859 bool m_bTCupdate;
860 wxString m_scaleText;
861 double m_scaleValue;
862 bool m_bShowScaleInStatusBar;
863 wxRect bbRect;
864
865 wxPoint LastShipPoint;
866 wxPoint LastPredPoint;
867 bool m_bDrawingRoute;
868 bool m_bRouteEditing;
869 bool m_bMarkEditing;
870 bool m_bRoutePoinDragging;
871 bool m_bIsInRadius;
872 bool m_bMayToggleMenuBar;
873
874 RoutePoint *m_pRoutePointEditTarget;
875 RoutePoint *m_lastRoutePointEditTarget;
876 SelectItem *m_pFoundPoint;
877 bool m_bChartDragging;
878 Route *m_pSelectedRoute;
879 Track *m_pSelectedTrack;
880 wxArrayPtrVoid *m_pEditRouteArray;
881 RoutePoint *m_pFoundRoutePoint;
882
883 int m_FoundAIS_MMSI;
884
885 wxCursor *pCursorLeft;
886 wxCursor *pCursorRight;
887 wxCursor *pCursorUp;
888 wxCursor *pCursorDown;
889
890 wxCursor *pCursorUpLeft;
891 wxCursor *pCursorUpRight;
892 wxCursor *pCursorDownLeft;
893 wxCursor *pCursorDownRight;
894
895 int popx, popy;
896
897 wxBitmap *pThumbDIBShow;
898 wxBitmap *pThumbShowing;
899
900 bool bShowingCurrent;
901 bool bShowingTide;
902
909 double m_canvas_scale_factor;
911 double m_pix_per_mm;
912 double m_display_size_mm;
913
914 double m_absolute_min_scale_ppm;
915
916 bool singleClickEventIsValid;
917 wxMouseEvent singleClickEvent;
918
919 std::vector<s57Sector_t> extendedSectorLegs;
920 wxFont m_overzoomFont;
921 int m_overzoomTextWidth;
922 int m_overzoomTextHeight;
923
924 // Methods
925 void OnActivate(wxActivateEvent &event);
926 void OnSize(wxSizeEvent &event);
927 void MouseTimedEvent(wxTimerEvent &event);
928 void MouseEvent(wxMouseEvent &event);
929 void ShipDraw(ocpnDC &dc);
930 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
931 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
932 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
933
934 void RotateTimerEvent(wxTimerEvent &event);
935 void PanTimerEvent(wxTimerEvent &event);
936 void MovementTimerEvent(wxTimerEvent &);
937 void MovementStopTimerEvent(wxTimerEvent &);
938 void OnCursorTrackTimerEvent(wxTimerEvent &event);
939
940 void MovementVPTimerEvent(wxTimerEvent &event);
941
942 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
943 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
944 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
945 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
946 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
947 void DrawAnchorWatchPoints(ocpnDC &dc);
948 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
949
950 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
951 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
952 void RebuildTideSelectList(LLBBox &BBox);
953 void RebuildCurrentSelectList(LLBBox &BBox);
954
955 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
956 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
957 void RenderRouteLegs(ocpnDC &dc);
958 void RenderVisibleSectorLights(ocpnDC &dc);
959
960 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
961
962 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
963 void ScaleBarDraw(ocpnDC &dc);
964
965 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
966 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
967
968 emboss_data *EmbossDepthScale();
969 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
970 const wxString &str, ColorScheme cs);
971 void CreateDepthUnitEmbossMaps(ColorScheme cs);
972 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
973
974 void CreateOZEmbossMapData(ColorScheme cs);
975 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
976 void SetOverzoomFont();
977
978 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
979 // void EmbossCM93Offset ( wxMemoryDC *pdc);
980
981 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
982
983 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
984 void HandleNotificationMouseClick();
985
986 // Data
988 int m_canvas_width;
990 int m_canvas_height;
991
992 int xr_margin; // chart scroll margins, control cursor, etc.
993 int xl_margin;
994 int yt_margin;
995 int yb_margin;
996
997 wxPoint last_drag;
998
999 wxMemoryDC *pmemdc;
1000
1001 int warp_x, warp_y;
1002 bool warp_flag;
1003
1004 wxTimer *
1005 pPanTimer; // This timer used for auto panning on route creation and edit
1006 wxTimer *
1007 pMovementTimer; // This timer used for smooth movement in non-opengl mode
1008 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
1009 // event is lost
1010 wxTimer *pCurTrackTimer; // This timer used to update the status window on
1011 // mouse idle
1012 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
1013 // mouse moves
1014 wxTimer *m_DoubleClickTimer;
1015 wxTimer m_routeFinishTimer;
1016
1017 wxTimer m_RolloverPopupTimer;
1018
1019 wxTimer m_VPMovementTimer;
1020
1021 int m_wheelzoom_stop_oneshot;
1022 int m_last_wheel_dir;
1023 wxStopWatch m_wheelstopwatch;
1024 double m_zoom_target;
1025
1026 int m_curtrack_timer_msec;
1027 int m_rollover_popup_timer_msec;
1028
1029 GSHHSChart *pWorldBackgroundChart;
1030
1031 ChartBaseBSB *pCBSB;
1032 wxBitmap *pss_overlay_bmp;
1033 wxMask *pss_overlay_mask;
1034
1035 wxRect ship_draw_rect;
1036 wxRect ship_draw_last_rect;
1037 wxRect ais_draw_rect;
1038 wxRect alert_draw_rect; // pjotrc 2010.02.22
1039
1040 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
1041 wxMemoryDC m_dc_route; // seen in mouse->edit->route
1042
1043 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
1044 emboss_data *m_pEM_Meters;
1045 emboss_data *m_pEM_Fathoms;
1046
1047 emboss_data *m_pEM_OverZoom;
1048 // emboss_data *m_pEM_CM93Offset; // Flav
1049
1065 double m_true_scale_ppm;
1066
1067 ownship_state_t m_ownship_state;
1068
1069 ColorScheme m_cs;
1070
1071 wxBitmap m_bmTideDay;
1072 wxBitmap m_bmTideDusk;
1073 wxBitmap m_bmTideNight;
1074 wxBitmap m_bmCurrentDay;
1075 wxBitmap m_bmCurrentDusk;
1076 wxBitmap m_bmCurrentNight;
1077 wxBitmap m_cTideBitmap;
1078 wxBitmap m_cCurrentBitmap;
1079
1080 RolloverWin *m_pRouteRolloverWin;
1081 RolloverWin *m_pTrackRolloverWin;
1082 RolloverWin *m_pAISRolloverWin;
1083
1084 TimedPopupWin *m_pBrightPopup;
1085
1086 wxImage m_os_image_red_day;
1087 wxImage m_os_image_red_dusk;
1088 wxImage m_os_image_red_night;
1089 wxImage m_os_image_grey_day;
1090 wxImage m_os_image_grey_dusk;
1091 wxImage m_os_image_grey_night;
1092 wxImage m_os_image_yellow_day;
1093 wxImage m_os_image_yellow_dusk;
1094 wxImage m_os_image_yellow_night;
1095
1096 wxImage *m_pos_image_red;
1097 wxImage *m_pos_image_grey;
1098 wxImage *m_pos_image_yellow;
1099
1100 wxImage *m_pos_image_user;
1101 wxImage *m_pos_image_user_grey;
1102 wxImage *m_pos_image_user_yellow;
1103
1104 wxImage *m_pos_image_user_day;
1105 wxImage *m_pos_image_user_dusk;
1106 wxImage *m_pos_image_user_night;
1107 wxImage *m_pos_image_user_grey_day;
1108 wxImage *m_pos_image_user_grey_dusk;
1109 wxImage *m_pos_image_user_grey_night;
1110 wxImage *m_pos_image_user_yellow_day;
1111 wxImage *m_pos_image_user_yellow_dusk;
1112 wxImage *m_pos_image_user_yellow_night;
1113
1114 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1115 int m_cur_ship_pix;
1116 bool m_cur_ship_pix_isgrey;
1117 ColorScheme m_ship_cs;
1118
1119 ViewPort m_cache_vp;
1120 wxBitmap *m_prot_bm;
1121 wxPoint m_roffset;
1122
1123 bool m_b_rot_hidef;
1124
1125 SelectItem *m_pRolloverRouteSeg;
1126 SelectItem *m_pRolloverTrackSeg;
1127
1128 double m_wheel_lat, m_wheel_lon;
1129 int m_wheel_x, m_wheel_y;
1130
1131 ViewPort m_bm_cache_vp;
1132 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1133 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1134
1135 bool m_bbrightdir;
1136 int m_brightmod;
1137
1138 bool m_bzooming, m_bzooming_to_cursor;
1139 IDX_entry *m_pIDXCandidate;
1140
1141 // #ifdef ocpnUSE_GL
1142 glChartCanvas *m_glcc;
1143 // #endif
1144
1145 // Smooth movement member variables
1146 wxPoint m_pan_drag;
1147 int m_panx, m_pany, m_modkeys;
1148 double m_panspeed;
1149 bool m_bmouse_key_mod;
1150 double m_zoom_factor, m_rotation_speed;
1151 int m_mustmove;
1152
1153 wxDateTime m_last_movement_time;
1154
1155 int m_AISRollover_MMSI;
1156 bool m_bsectors_shown;
1157 bool m_bedge_pan;
1158 double m_displayed_scale_factor;
1159
1160 wxColour m_fog_color;
1161 bool m_disable_edge_pan;
1162 wxFont *m_pgridFont;
1163
1164 bool m_dragoffsetSet;
1165
1166 bool m_bautofind;
1167 bool m_bFirstAuto;
1168 double m_vLat, m_vLon;
1169 ChartStack *m_pCurrentStack;
1170 Piano *m_Piano;
1171 bool m_bpersistent_quilt;
1172
1173 wxMenu *m_piano_ctx_menu;
1174 int menu_selected_dbIndex, menu_selected_index;
1175
1176 ocpnCompass *m_Compass;
1177 bool m_bShowGPS;
1178
1179 wxRect m_mainlast_tb_rect;
1180 int m_restore_dbindex;
1181 int m_restore_group;
1182
1183 MUIBar *m_muiBar;
1184 wxSize m_muiBarHOSize;
1185
1186 bool m_bShowOutlines;
1187 bool m_bDisplayGrid;
1188 bool m_bShowDepthUnits;
1189 bool m_bShowAIS;
1190 bool m_bShowAISScaled;
1191
1192 // S52PLib state storage
1193 long m_s52StateHash;
1194 bool m_encShowText;
1195 bool m_encShowDepth;
1196 bool m_encShowLightDesc;
1197 bool m_encShowBuoyLabels;
1198 int m_encDisplayCategory;
1199 bool m_encShowLights;
1200 bool m_encShowAnchor;
1201 bool m_encShowDataQual;
1202
1203 wxTimer m_deferredFocusTimer;
1204 float m_focus_indicator_pix;
1205 bool m_bENCGroup;
1206 bool m_last_TBviz;
1207
1208 double m_OSoffsetx, m_OSoffsety;
1209 bool m_MouseDragging;
1210
1211 wxString m_alertString;
1212 wxRect m_scaleBarRect;
1213 bool m_bShowCompassWin;
1214 bool m_pianoFrozen;
1215
1216 double m_sector_glat, m_sector_glon;
1217 std::vector<s57Sector_t> m_sectorlegsVisible;
1218 bool m_bShowVisibleSectors;
1220 double m_displayScale;
1221 bool m_show_focus_bar;
1222
1223 double m_panx_target_final;
1224 double m_pany_target_final;
1225 double m_panx_target_now;
1226 double m_pany_target_now;
1227
1228 double m_start_lat, m_start_lon;
1229 double m_target_lat, m_target_lon;
1230 double m_run_lat, m_run_lon;
1231 bool m_timed_move_vp_active;
1232 int m_timedVP_step;
1233 int m_stvpc;
1234
1235 double meters_to_shift = 0;
1236 double dir_to_shift = 0;
1237
1238 // Chart drag inertia support
1239 wxTimer m_chart_drag_inertia_timer;
1240 void OnChartDragInertiaTimer(wxTimerEvent &event);
1241
1242 uint64_t m_last_drag_time;
1243 int m_chart_drag_total_x;
1244 int m_chart_drag_total_y;
1245 double m_chart_drag_total_time;
1246 double m_chart_drag_velocity_x;
1247 double m_chart_drag_velocity_y;
1248 wxLongLong m_chart_drag_inertia_time;
1249 wxLongLong m_chart_drag_inertia_start_time;
1250 bool m_chart_drag_inertia_active;
1251 double m_last_elapsed;
1252 std::vector<int> m_drag_vec_x;
1253 std::vector<int> m_drag_vec_y;
1254 std::vector<double> m_drag_vec_t;
1255 int m_inertia_last_drag_x;
1256 int m_inertia_last_drag_y;
1257
1258 // For Jump animation
1259 wxTimer m_easeTimer;
1260 wxLongLong m_animationStart;
1261 wxLongLong m_animationDuration; // e.g. 300 ms
1262 double m_startLat, m_startLon, m_startScale;
1263 double m_endLat, m_endLon, m_endScale;
1264 bool m_animationActive;
1265 void OnJumpEaseTimer(wxTimerEvent &event);
1266 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1267
1268 NotificationButton *m_notification_button;
1269 NotificationsList *m_NotificationsList;
1270 ObservableListener evt_notificationlist_change_listener;
1271 DECLARE_EVENT_TABLE()
1272};
1273
1274// CUSTOMIZATION - FORMAT MINUTES
1275
1276wxString minutesToHoursDays(float timeInMinutes);
1277
1278// END OF CUSTOMIZATION - FORMAT MINUTES
1279
1284#ifndef wxCLOSE_BOX
1285#define wxCLOSE_BOX 0x1000
1286#endif
1287#ifndef wxFIXED_MINSIZE
1288#define wxFIXED_MINSIZE 0
1289#endif
1290
1291#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:4569
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:453
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4565
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:4515
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:461
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:492
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:824
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:7574
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:5066
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:450
void DoZoomCanvas(double factor, bool can_zoom_to_cursor=true)
Internal function that implements the actual zoom operation.
Definition chcanv.cpp:4671
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:466
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4646
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5345
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:4590
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:4651
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4510
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5364
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:9894
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.