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