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
135class ChartCanvas : public wxWindow {
136 friend class glChartCanvas;
137
138public:
139 ChartCanvas(wxFrame *frame, int canvasIndex);
140 ~ChartCanvas();
141
142 void SetupGlCanvas();
143
144 // Methods
145 void OnKeyDown(wxKeyEvent &event);
146 void OnKeyUp(wxKeyEvent &event);
147 void OnKeyChar(wxKeyEvent &event);
148 void OnPaint(wxPaintEvent &event);
149 void PaintCleanup();
150 void Scroll(int dx, int dy);
151 void OnToolLeftClick(wxCommandEvent &event);
152
153 bool MouseEventOverlayWindows(wxMouseEvent &event);
154 bool MouseEventChartBar(wxMouseEvent &event);
155 bool MouseEventMUIBar(wxMouseEvent &event);
156 bool MouseEventToolbar(wxMouseEvent &event);
157 bool MouseEventIENCBar(wxMouseEvent &event);
158
159 bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick = true);
160 bool MouseEventProcessObjects(wxMouseEvent &event);
176 bool MouseEventProcessCanvas(wxMouseEvent &event);
177 void SetCanvasCursor(wxMouseEvent &event);
178 void OnKillFocus(wxFocusEvent &WXUNUSED(event));
179 void OnSetFocus(wxFocusEvent &WXUNUSED(event));
180#ifdef HAVE_WX_GESTURE_EVENTS
181 void OnZoom(wxZoomGestureEvent &event);
182 void OnLongPress(wxLongPressEvent &event);
183 void OnPressAndTap(wxPressAndTapEvent &event);
184
185 void OnLeftDown(wxMouseEvent &evt);
186 void OnLeftUp(wxMouseEvent &evt);
187
188 void OnRightUp(wxMouseEvent &event);
189 void OnRightDown(wxMouseEvent &event);
190
191 void OnDoubleLeftClick(wxMouseEvent &event);
192
193 void OnWheel(wxMouseEvent &event);
194 void OnMotion(wxMouseEvent &event);
195#endif /* HAVE_WX_GESTURE_EVENTS */
196
197 void PopupMenuHandler(wxCommandEvent &event);
198 bool IsPrimaryCanvas() { return (m_canvasIndex == 0); }
199
200 bool SetUserOwnship();
201
202 double GetCanvasRangeMeters();
203 void SetCanvasRangeMeters(double range);
204
205 void EnablePaint(bool b_enable);
206 virtual bool SetCursor(const wxCursor &c);
207 virtual void Refresh(bool eraseBackground = true,
208 const wxRect *rect = (const wxRect *)NULL);
209 virtual void Update();
210
211 void LostMouseCapture(wxMouseCaptureLostEvent &event);
212
213 void CancelMouseRoute();
217 void SetDisplaySizeMM(double size);
221 double GetDisplaySizeMM() { return m_display_size_mm; }
222
234 bool SetVPScale(double sc, bool b_refresh = true);
235 bool SetVPProjection(int projection);
243 bool SetViewPoint(double lat, double lon);
244 bool SetViewPointByCorners(double latSW, double lonSW, double latNE,
245 double lonNE);
260 bool SetViewPoint(double lat, double lon, double scale_ppm, double skew,
261 double rotation, int projection = 0, bool b_adjust = true,
262 bool b_refresh = true);
263 void ReloadVP(bool b_adjust = true);
264 void LoadVP(ViewPort &vp, bool b_adjust = true);
265
266 ChartStack *GetpCurrentStack() { return m_pCurrentStack; }
267 void SetGroupIndex(int index, bool autoswitch = false);
268 bool CheckGroup(int igroup);
269 void canvasRefreshGroupIndex(void);
270 void canvasChartsRefresh(int dbi_hint);
271
272 void CheckGroupValid(bool showMessage = true, bool switchGroup0 = true);
273
274 void UpdateCanvasS52PLIBConfig();
275
276 void TriggerDeferredFocus();
277 void OnDeferredFocusTimerEvent(wxTimerEvent &event);
278 void OnRouteFinishTimerEvent(wxTimerEvent &event);
279
280 void ClearS52PLIBStateHash() { m_s52StateHash = 0; }
281 void SetupCanvasQuiltMode(void);
282 void ApplyCanvasConfig(canvasConfig *pcc);
283
284 bool SetVPRotation(double angle);
285 double GetVPRotation(void) { return GetVP().rotation; }
286 double GetVPSkew(void) { return GetVP().skew; }
287 double GetVPTilt(void) { return GetVP().tilt; }
288
289 void ClearbFollow(void);
290 void SetbFollow(void);
291 void TogglebFollow(void);
292 bool GetbFollow() { return m_bFollow; }
293
294 void JumpToPosition(double lat, double lon, double scale);
295 void SetFirstAuto(bool b_auto) { m_bFirstAuto = b_auto; }
296
309 void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
323 void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
324 wxPoint2DDouble *r);
325
340 bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
341
360 bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
361
375 void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
376 void WarpPointerDeferred(int x, int y);
377 void UpdateShips();
378 void UpdateAIS();
379 void UpdateAlerts(); // pjotrc 2010.02.22
380 void ToggleCPAWarn();
381
382 bool IsMeasureActive() { return m_bMeasure_Active; }
383 wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
384 Undo *undo;
385
386 int GetUpMode() { return m_upMode; }
387 bool GetLookahead() { return m_bLookAhead; }
388
389 void UnlockQuilt();
390 void SetQuiltMode(bool b_quilt);
391 bool GetQuiltMode(void);
392 std::vector<int> GetQuiltIndexArray(void);
393 bool IsQuiltDelta(void);
394 void SetQuiltChartHiLiteIndex(int dbIndex);
395 void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
396 void ClearQuiltChartHiLiteIndexArray();
397 int GetQuiltReferenceChartIndex(void);
398 double GetBestStartScale(int dbi_hint, const ViewPort &vp);
399 void ConfigureChartBar();
400
401 int GetNextContextMenuId();
402
403 TCWin *getTCWin() { return pCwin; }
404
405 bool StartTimedMovement(bool stoptimer = true);
406 void DoTimedMovement();
407 void DoMovement(long dt);
408 void StopMovement();
409
410 void StartTimedMovementVP(double target_lat, double target_lon, int nstep);
411 void DoTimedMovementVP();
412 void StopMovementVP();
413
414 void StartTimedMovementTarget();
415 void DoTimedMovementTarget();
416 void StopMovementTarget();
417
418 void SetColorScheme(ColorScheme cs);
419 ColorScheme GetColorScheme() { return m_cs; }
420
421 void CanvasApplyLocale();
422 void RebuildCursors();
423
424 // Accessors
425 int GetCanvasWidth() { return m_canvas_width; }
426 int GetCanvasHeight() { return m_canvas_height; }
428 float GetVPScale() { return GetVP().view_scale_ppm; }
431 float GetVPChartScale() { return GetVP().chart_scale; }
439 double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
444 double GetCanvasTrueScale() { return m_true_scale_ppm; }
445 double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
446 ViewPort *GetpVP() { return &VPoint; }
447 void SetVP(ViewPort &);
448 ChartBase *GetChartAtCursor();
449 ChartBase *GetOverlayChartAtCursor();
450 Piano *GetPiano() { return m_Piano; }
451 int GetPianoHeight();
452
453 bool isRouteEditing(void) {
454 return m_bRouteEditing && m_pRoutePointEditTarget;
455 }
456 bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
457
458 GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
459 void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
460
461 void SetbTCUpdate(bool f) { m_bTCupdate = f; }
462 bool GetbTCUpdate() { return m_bTCupdate; }
463 void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
464 bool GetbShowCurrent() { return m_bShowCurrent; }
465 void SetbShowTide(bool f) { m_bShowTide = f; }
466 bool GetbShowTide() { return m_bShowTide; }
467 void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
468 bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
470 double GetPixPerMM() { return m_pix_per_mm; }
471
472 void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
473 void SetCursorStatus(double cursor_lat, double cursor_lon);
474 void GetCursorLatLon(double *lat, double *lon);
477 bool PanCanvas(double dx, double dy);
478 void StopAutoPan(void);
479
498 void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
499 bool stoptimer = true);
500
512 void ZoomCanvasSimple(double factor);
513
527 void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
528
529 void RotateCanvas(double dir);
530 void DoRotateCanvas(double rotation);
531 void DoTiltCanvas(double tilt);
532
533 void ShowAISTargetList(void);
534
535 void ShowGoToPosition(void);
536 void HideGlobalToolbar();
537 void ShowGlobalToolbar();
538
539 bool GetShowDepthUnits() { return m_bShowDepthUnits; }
540 void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
541 bool GetShowGrid() { return m_bDisplayGrid; }
542 void SetShowGrid(bool show) { m_bDisplayGrid = show; }
543 bool GetShowOutlines() { return m_bShowOutlines; }
544 void SetShowOutlines(bool show) { m_bShowOutlines = show; }
545 bool GetShowChartbar() { return true; }
546 wxRect GetMUIBarRect();
547 void SetMUIBarPosition();
548 void DestroyMuiBar();
549 void CreateMUIBar();
550
551 void ToggleChartOutlines(void);
552 void ToggleCanvasQuiltMode(void);
553
554 wxString GetScaleText() { return m_scaleText; }
555 double GetScaleValue() { return m_scaleValue; }
556 bool GetShowAIS() { return m_bShowAIS; }
557 void SetShowAIS(bool show);
558 bool GetAttenAIS() { return m_bShowAISScaled; }
559 void SetAttenAIS(bool show);
560 void SetShowFocusBar(bool enable) { m_show_focus_bar = enable; }
561 bool GetShowFocusBar() { return m_show_focus_bar; }
562 MUIBar *GetMUIBar() { return m_muiBar; }
563 void SetAlertString(wxString str) { m_alertString = str; }
564 wxString GetAlertString() { return m_alertString; }
565 bool GetShowENCText() { return m_encShowText; }
566 void SetShowENCText(bool show);
567
568 bool GetShowENCDepth() { return m_encShowDepth; }
569 void SetShowENCDepth(bool show);
570
571 bool GetShowENCLightDesc() { return m_encShowLightDesc; }
572 void SetShowENCLightDesc(bool show);
573
574 bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
575 void SetShowENCBuoyLabels(bool show);
576
577 bool GetShowENCLights() { return m_encShowLights; }
578 void SetShowENCLights(bool show);
579
580 int GetENCDisplayCategory() { return m_encDisplayCategory; }
581 void SetENCDisplayCategory(int category);
582
583 bool GetShowENCAnchor() { return m_encShowAnchor; }
584 void SetShowENCAnchor(bool show);
585
586 bool GetShowENCDataQual() { return m_encShowDataQual; }
587 void SetShowENCDataQual(bool show);
588
589 void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
590 int m_canvasIndex;
591 void ShowTides(bool bShow);
592 void ShowCurrents(bool bShow);
593 void SetUpMode(int mode);
594 void ToggleLookahead();
595 void SetShowGPS(bool show);
596 void UpdateFollowButtonState(void);
597 void InvalidateGL();
598 bool IsTileOverlayIndexInYesShow(int index);
599 bool IsTileOverlayIndexInNoShow(int index);
600 void AddTileOverlayIndexToNoShow(int index);
601 int m_groupIndex;
602 Route *m_pMouseRoute;
603 bool m_bMeasure_Active;
604 ViewPort &GetVP();
605 ChartBase *m_singleChart;
606 Quilt *m_pQuilt;
607 wxString FindValidUploadPort();
608 wxString m_active_upload_port;
609
610 // protected:
611
612 // private:
613 ChartBase *GetLargestScaleQuiltChart();
614 ChartBase *GetFirstQuiltChart();
615 ChartBase *GetNextQuiltChart();
616 int GetQuiltChartCount();
617 void InvalidateAllQuiltPatchs(void);
618 void SetQuiltRefChart(int dbIndex);
619 std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
620 bool flag2 = true);
621 std::vector<int> &GetQuiltExtendedStackdbIndexArray();
622 std::vector<int> &GetQuiltFullScreendbIndexArray();
623 std::vector<int> GetQuiltEclipsedStackdbIndexArray();
624 int GetQuiltRefChartdbIndex(void);
625 void InvalidateQuilt(void);
626 double GetQuiltMaxErrorFactor();
627 bool IsChartQuiltableRef(int db_index);
628 bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
629 int GetCanvasChartNativeScale();
630 int FindClosestCanvasChartdbIndex(int scale);
631 void UpdateCanvasOnGroupChange(void);
632
633 void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
634 void ShowMarkPropertiesDialog(RoutePoint *markPoint);
635 void ShowRoutePropertiesDialog(wxString title, Route *selected);
636 void ShowTrackPropertiesDialog(Track *selected);
637 void DrawTCWindow(int x, int y, void *pIDX);
638
639 void UpdateGPSCompassStatusBox(bool b_force_new);
640 ocpnCompass *GetCompass() { return m_Compass; }
641
642 wxColour GetFogColor() { return m_fog_color; }
643
644 void ShowChartInfoWindow(int x, int dbIndex);
645 void HideChartInfoWindow(void);
646 void ShowCompositeInfoWindow(int x, int n_charts, int scale,
647 const std::vector<int> &index_vector);
648
649 void StartMeasureRoute();
650 void CancelMeasureRoute();
651
652 bool DoCanvasUpdate(void);
653 void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
654 void SelectQuiltRefChart(int selected_index);
655 double GetBestVPScale(ChartBase *pchart);
656 void selectCanvasChartDisplay(int type, int family);
657 void RemoveChartFromQuilt(int dbIndex);
658
659 void HandlePianoClick(int selected_index,
660 const std::vector<int> &selected_dbIndex_array);
661 void HandlePianoRClick(int x, int y, int selected_index,
662 const std::vector<int> &selected_dbIndex_array);
663 void HandlePianoRollover(int selected_index,
664 const std::vector<int> &selected_dbIndex_array,
665 int n_charts, int scale);
666 void ClearPianoRollover();
667 void UpdateCanvasControlBar(void);
668 void FormatPianoKeys(void);
669 void PianoPopupMenu(int x, int y, int selected_index,
670 const std::vector<int> &selected_dbIndex_array);
671 void OnPianoMenuDisableChart(wxCommandEvent &event);
672 void OnPianoMenuEnableChart(wxCommandEvent &event);
673
674 bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
675 bool DoCanvasCOGSet(void);
676 void ApplyGlobalSettings();
677 void SetShowGPSCompassWindow(bool bshow);
678 bool GetShowGPSCompassWindow() { return m_bShowCompassWin; }
679 void FreezePiano() { m_pianoFrozen = true; }
680 void ThawPiano() { m_pianoFrozen = false; }
681 void StartChartDragInertia();
682
683 // Todo build more accessors
684 bool m_bFollow;
685 wxCursor *pCursorPencil;
686 wxCursor *pCursorArrow;
687 wxCursor *pCursorCross;
688 wxCursor *pPlugIn_Cursor;
689 TCWin *pCwin;
690 wxBitmap *pscratch_bm;
691 bool m_brepaint_piano;
692 double
694 double
696 wxPoint r_rband;
697 double m_prev_rlat;
698 double m_prev_rlon;
699 RoutePoint *m_prev_pMousePoint;
700 bool m_bShowNavobjects;
701 int m_routeState;
702 int m_upMode;
703 bool m_bLookAhead;
704
705#ifdef HAVE_WX_GESTURE_EVENTS
706 double m_oldVPSScale;
707 bool m_popupWanted;
708 bool m_leftdown;
709 wxPoint m_zoomStartPoint;
710#endif /* HAVE_WX_GESTURE_EVENTS */
711
712 void DrawBlinkObjects(void);
713
714 void StartRoute(void);
715 void FinishRoute(void);
716
717#ifdef ocpnUSE_GL
718 glChartCanvas *GetglCanvas() { return m_glcc; }
719#endif
720
721 bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
722
723 bool m_FinishRouteOnKillFocus;
724 bool m_bMeasure_DistCircle;
725 bool m_bAppendingRoute;
726 int m_nMeasureState;
727 Route *m_pMeasureRoute;
728 MyFrame *parent_frame;
729 CanvasMenuHandler *m_canvasMenu;
730 int GetMinAvailableGshhgQuality() {
731 return pWorldBackgroundChart->GetMinAvailableQuality();
732 }
733 int GetMaxAvailableGshhgQuality() {
734 return pWorldBackgroundChart->GetMaxAvailableQuality();
735 }
736 Route *GetSelectedRoute() const { return m_pSelectedRoute; }
737 Track *GetSelectedTrack() const { return m_pSelectedTrack; }
738 RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
739
740 void SetAISCanvasDisplayStyle(int StyleIndx);
741 void TouchAISToolActive(void);
742 void UpdateAISTBTool(void);
743
744 void SelectChartFromStack(int index, bool bDir = false,
745 ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
746 ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
747 void SelectdbChart(int dbindex);
748
749 void DoCanvasStackDelta(int direction);
750
751 void ProcessNewGUIScale();
752
753 bool m_b_paint_enable;
754
755 wxRect GetScaleBarRect() { return m_scaleBarRect; }
756 void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
757
758 std::vector<int> m_tile_noshow_index_array;
759 std::vector<int> m_tile_yesshow_index_array;
760 std::vector<int> m_quilt_noshow_index_array;
761
762 std::vector<int> GetQuiltNoshowIindexArray() {
763 return m_quilt_noshow_index_array;
764 }
774 double GetDisplayScale() { return m_displayScale; }
775 void ResetOwnshipOffset() { m_OSoffsetx = m_OSoffsety = 0; }
776
777private:
778 int AdjustQuiltRefChart();
779
780 bool UpdateS52State();
781
782 void CallPopupMenu(int x, int y);
783
784 bool IsTempMenuBarEnabled();
785 bool InvokeCanvasMenu(int x, int y, int seltype);
786
787 ViewPort VPoint;
788 void PositionConsole(void);
789
790 wxColour PredColor();
791 wxColour ShipColor();
792
793 void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
794 int ownShipLength, wxPoint2DDouble &lShipMidPoint,
795 wxPoint &GpsOffsetPixels,
796 wxPoint2DDouble lGPSPoint, float &scale_factor_x,
797 float &scale_factor_y);
798
799 void ShipDrawLargeScale(ocpnDC &dc, wxPoint2DDouble lShipMidPoint);
800 void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
801 wxPoint2DDouble lGPSPoint);
802
803 ChInfoWin *m_pCIWin;
804
805 bool m_bShowCurrent;
806 bool m_bShowTide;
807 int cursor_region;
808 bool m_bTCupdate;
809 wxString m_scaleText;
810 double m_scaleValue;
811 bool m_bShowScaleInStatusBar;
812 wxRect bbRect;
813
814 wxPoint LastShipPoint;
815 wxPoint LastPredPoint;
816 bool m_bDrawingRoute;
817 bool m_bRouteEditing;
818 bool m_bMarkEditing;
819 bool m_bRoutePoinDragging;
820 bool m_bIsInRadius;
821 bool m_bMayToggleMenuBar;
822
823 RoutePoint *m_pRoutePointEditTarget;
824 RoutePoint *m_lastRoutePointEditTarget;
825 SelectItem *m_pFoundPoint;
826 bool m_bChartDragging;
827 Route *m_pSelectedRoute;
828 Track *m_pSelectedTrack;
829 wxArrayPtrVoid *m_pEditRouteArray;
830 RoutePoint *m_pFoundRoutePoint;
831
832 int m_FoundAIS_MMSI;
833
834 wxCursor *pCursorLeft;
835 wxCursor *pCursorRight;
836 wxCursor *pCursorUp;
837 wxCursor *pCursorDown;
838
839 wxCursor *pCursorUpLeft;
840 wxCursor *pCursorUpRight;
841 wxCursor *pCursorDownLeft;
842 wxCursor *pCursorDownRight;
843
844 int popx, popy;
845
846 wxBitmap *pThumbDIBShow;
847 wxBitmap *pThumbShowing;
848
849 bool bShowingCurrent;
850 bool bShowingTide;
851
858 double m_canvas_scale_factor;
860 double m_pix_per_mm;
861 double m_display_size_mm;
862
863 double m_absolute_min_scale_ppm;
864
865 bool singleClickEventIsValid;
866 wxMouseEvent singleClickEvent;
867
868 std::vector<s57Sector_t> extendedSectorLegs;
869 wxFont m_overzoomFont;
870 int m_overzoomTextWidth;
871 int m_overzoomTextHeight;
872
873 // Methods
874 void OnActivate(wxActivateEvent &event);
875 void OnSize(wxSizeEvent &event);
876 void MouseTimedEvent(wxTimerEvent &event);
877 void MouseEvent(wxMouseEvent &event);
878 void ShipDraw(ocpnDC &dc);
879 void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
880 void OnRolloverPopupTimerEvent(wxTimerEvent &event);
881 void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
882
883 void RotateTimerEvent(wxTimerEvent &event);
884 void PanTimerEvent(wxTimerEvent &event);
885 void MovementTimerEvent(wxTimerEvent &);
886 void MovementStopTimerEvent(wxTimerEvent &);
887 void OnCursorTrackTimerEvent(wxTimerEvent &event);
888
889 void MovementVPTimerEvent(wxTimerEvent &event);
890
891 void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
892 void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
893 void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
894 void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
895 void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
896 void DrawAnchorWatchPoints(ocpnDC &dc);
897 double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
898
899 void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
900 void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
901 void RebuildTideSelectList(LLBBox &BBox);
902 void RebuildCurrentSelectList(LLBBox &BBox);
903
904 void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
905 void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
906 void RenderRouteLegs(ocpnDC &dc);
907 void RenderVisibleSectorLights(ocpnDC &dc);
908
909 void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
910
911 void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
912 void ScaleBarDraw(ocpnDC &dc);
913
914 void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
915 void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
916
917 emboss_data *EmbossDepthScale();
918 emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
919 const wxString &str, ColorScheme cs);
920 void CreateDepthUnitEmbossMaps(ColorScheme cs);
921 wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
922
923 void CreateOZEmbossMapData(ColorScheme cs);
924 emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
925 void SetOverzoomFont();
926
927 // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
928 // void EmbossCM93Offset ( wxMemoryDC *pdc);
929
930 void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
931
932 void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
933
934 // Data
936 int m_canvas_width;
938 int m_canvas_height;
939
940 int xr_margin; // chart scroll margins, control cursor, etc.
941 int xl_margin;
942 int yt_margin;
943 int yb_margin;
944
945 wxPoint last_drag;
946
947 wxMemoryDC *pmemdc;
948
949 int warp_x, warp_y;
950 bool warp_flag;
951
952 wxTimer *
953 pPanTimer; // This timer used for auto panning on route creation and edit
954 wxTimer *
955 pMovementTimer; // This timer used for smooth movement in non-opengl mode
956 wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
957 // event is lost
958 wxTimer *pCurTrackTimer; // This timer used to update the status window on
959 // mouse idle
960 wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
961 // mouse moves
962 wxTimer *m_DoubleClickTimer;
963 wxTimer m_routeFinishTimer;
964
965 wxTimer m_RolloverPopupTimer;
966
967 wxTimer m_VPMovementTimer;
968
969 int m_wheelzoom_stop_oneshot;
970 int m_last_wheel_dir;
971 wxStopWatch m_wheelstopwatch;
972 double m_zoom_target;
973
974 int m_curtrack_timer_msec;
975 int m_rollover_popup_timer_msec;
976
977 GSHHSChart *pWorldBackgroundChart;
978
979 ChartBaseBSB *pCBSB;
980 wxBitmap *pss_overlay_bmp;
981 wxMask *pss_overlay_mask;
982
983 wxRect ship_draw_rect;
984 wxRect ship_draw_last_rect;
985 wxRect ais_draw_rect;
986 wxRect alert_draw_rect; // pjotrc 2010.02.22
987
988 wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
989 wxMemoryDC m_dc_route; // seen in mouse->edit->route
990
991 emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
992 emboss_data *m_pEM_Meters;
993 emboss_data *m_pEM_Fathoms;
994
995 emboss_data *m_pEM_OverZoom;
996 // emboss_data *m_pEM_CM93Offset; // Flav
997
1013 double m_true_scale_ppm;
1014
1015 ownship_state_t m_ownship_state;
1016
1017 ColorScheme m_cs;
1018
1019 wxBitmap m_bmTideDay;
1020 wxBitmap m_bmTideDusk;
1021 wxBitmap m_bmTideNight;
1022 wxBitmap m_bmCurrentDay;
1023 wxBitmap m_bmCurrentDusk;
1024 wxBitmap m_bmCurrentNight;
1025 wxBitmap m_cTideBitmap;
1026 wxBitmap m_cCurrentBitmap;
1027
1028 RolloverWin *m_pRouteRolloverWin;
1029 RolloverWin *m_pTrackRolloverWin;
1030 RolloverWin *m_pAISRolloverWin;
1031
1032 TimedPopupWin *m_pBrightPopup;
1033
1034 wxImage m_os_image_red_day;
1035 wxImage m_os_image_red_dusk;
1036 wxImage m_os_image_red_night;
1037 wxImage m_os_image_grey_day;
1038 wxImage m_os_image_grey_dusk;
1039 wxImage m_os_image_grey_night;
1040 wxImage m_os_image_yellow_day;
1041 wxImage m_os_image_yellow_dusk;
1042 wxImage m_os_image_yellow_night;
1043
1044 wxImage *m_pos_image_red;
1045 wxImage *m_pos_image_grey;
1046 wxImage *m_pos_image_yellow;
1047
1048 wxImage *m_pos_image_user;
1049 wxImage *m_pos_image_user_grey;
1050 wxImage *m_pos_image_user_yellow;
1051
1052 wxImage *m_pos_image_user_day;
1053 wxImage *m_pos_image_user_dusk;
1054 wxImage *m_pos_image_user_night;
1055 wxImage *m_pos_image_user_grey_day;
1056 wxImage *m_pos_image_user_grey_dusk;
1057 wxImage *m_pos_image_user_grey_night;
1058 wxImage *m_pos_image_user_yellow_day;
1059 wxImage *m_pos_image_user_yellow_dusk;
1060 wxImage *m_pos_image_user_yellow_night;
1061
1062 wxImage m_ship_pix_image; // cached ship draw image for high overzoom
1063 int m_cur_ship_pix;
1064 bool m_cur_ship_pix_isgrey;
1065 ColorScheme m_ship_cs;
1066
1067 ViewPort m_cache_vp;
1068 wxBitmap *m_prot_bm;
1069 wxPoint m_roffset;
1070
1071 bool m_b_rot_hidef;
1072
1073 SelectItem *m_pRolloverRouteSeg;
1074 SelectItem *m_pRolloverTrackSeg;
1075
1076 double m_wheel_lat, m_wheel_lon;
1077 int m_wheel_x, m_wheel_y;
1078
1079 ViewPort m_bm_cache_vp;
1080 wxBitmap m_working_bm; // Used to build quilt in OnPaint()
1081 wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
1082
1083 bool m_bbrightdir;
1084 int m_brightmod;
1085
1086 bool m_bzooming, m_bzooming_to_cursor;
1087 IDX_entry *m_pIDXCandidate;
1088
1089 // #ifdef ocpnUSE_GL
1090 glChartCanvas *m_glcc;
1091 // #endif
1092
1093 // Smooth movement member variables
1094 wxPoint m_pan_drag;
1095 int m_panx, m_pany, m_modkeys;
1096 double m_panspeed;
1097 bool m_bmouse_key_mod;
1098 double m_zoom_factor, m_rotation_speed;
1099 int m_mustmove;
1100
1101 wxDateTime m_last_movement_time;
1102
1103 int m_AISRollover_MMSI;
1104 bool m_bsectors_shown;
1105 bool m_bedge_pan;
1106 double m_displayed_scale_factor;
1107
1108 wxColour m_fog_color;
1109 bool m_disable_edge_pan;
1110 wxFont *m_pgridFont;
1111
1112 bool m_dragoffsetSet;
1113
1114 bool m_bautofind;
1115 bool m_bFirstAuto;
1116 double m_vLat, m_vLon;
1117 ChartStack *m_pCurrentStack;
1118 Piano *m_Piano;
1119 bool m_bpersistent_quilt;
1120
1121 wxMenu *m_piano_ctx_menu;
1122 int menu_selected_dbIndex, menu_selected_index;
1123
1124 ocpnCompass *m_Compass;
1125 bool m_bShowGPS;
1126
1127 wxRect m_mainlast_tb_rect;
1128 int m_restore_dbindex;
1129 int m_restore_group;
1130
1131 MUIBar *m_muiBar;
1132 wxSize m_muiBarHOSize;
1133
1134 bool m_bShowOutlines;
1135 bool m_bDisplayGrid;
1136 bool m_bShowDepthUnits;
1137 bool m_bShowAIS;
1138 bool m_bShowAISScaled;
1139
1140 // S52PLib state storage
1141 long m_s52StateHash;
1142 bool m_encShowText;
1143 bool m_encShowDepth;
1144 bool m_encShowLightDesc;
1145 bool m_encShowBuoyLabels;
1146 int m_encDisplayCategory;
1147 bool m_encShowLights;
1148 bool m_encShowAnchor;
1149 bool m_encShowDataQual;
1150
1151 wxTimer m_deferredFocusTimer;
1152 float m_focus_indicator_pix;
1153 bool m_bENCGroup;
1154 bool m_last_TBviz;
1155
1156 double m_OSoffsetx, m_OSoffsety;
1157 bool m_MouseDragging;
1158
1159 wxString m_alertString;
1160 wxRect m_scaleBarRect;
1161 bool m_bShowCompassWin;
1162 bool m_pianoFrozen;
1163
1164 double m_sector_glat, m_sector_glon;
1165 std::vector<s57Sector_t> m_sectorlegsVisible;
1166 bool m_bShowVisibleSectors;
1168 double m_displayScale;
1169 bool m_show_focus_bar;
1170
1171 double m_panx_target_final;
1172 double m_pany_target_final;
1173 double m_panx_target_now;
1174 double m_pany_target_now;
1175
1176 double m_start_lat, m_start_lon;
1177 double m_target_lat, m_target_lon;
1178 double m_run_lat, m_run_lon;
1179 bool m_timed_move_vp_active;
1180 int m_timedVP_step;
1181 int m_stvpc;
1182
1183 double meters_to_shift = 0;
1184 double dir_to_shift = 0;
1185
1186 // Chart drag inertia support
1187 wxTimer m_chart_drag_inertia_timer;
1188 void OnChartDragInertiaTimer(wxTimerEvent &event);
1189
1190 uint64_t m_last_drag_time;
1191 int m_chart_drag_total_x;
1192 int m_chart_drag_total_y;
1193 double m_chart_drag_total_time;
1194 double m_chart_drag_velocity_x;
1195 double m_chart_drag_velocity_y;
1196 wxLongLong m_chart_drag_inertia_time;
1197 wxLongLong m_chart_drag_inertia_start_time;
1198 bool m_chart_drag_inertia_active;
1199 double m_last_elapsed;
1200 std::vector<int> m_drag_vec_x;
1201 std::vector<int> m_drag_vec_y;
1202 std::vector<double> m_drag_vec_t;
1203 int m_inertia_last_drag_x;
1204 int m_inertia_last_drag_y;
1205
1206 // For Jump animation
1207 wxTimer m_easeTimer;
1208 wxLongLong m_animationStart;
1209 wxLongLong m_animationDuration; // e.g. 300 ms
1210 double m_startLat, m_startLon, m_startScale;
1211 double m_endLat, m_endLon, m_endScale;
1212 bool m_animationActive;
1213 void OnJumpEaseTimer(wxTimerEvent &event);
1214 bool StartSmoothJump(double lat, double lon, double scale_ppm);
1215
1216 DECLARE_EVENT_TABLE()
1217};
1218
1219// CUSTOMIZATION - FORMAT MINUTES
1220
1221wxString minutesToHoursDays(float timeInMinutes);
1222
1223// END OF CUSTOMIZATION - FORMAT MINUTES
1224
1229#ifndef wxCLOSE_BOX
1230#define wxCLOSE_BOX 0x1000
1231#endif
1232#ifndef wxFIXED_MINSIZE
1233#define wxFIXED_MINSIZE 0
1234#endif
1235
1236#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
Chart display canvas.
Definition chcanv.h:135
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:4522
float GetVPChartScale()
Return the ViewPort chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition chcanv.h:431
bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) rounded to nearest integer.
Definition chcanv.cpp:4518
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:4468
double m_cursor_lat
The latitude at the mouse cursor position in degrees.
Definition chcanv.h:695
double GetCanvasScaleFactor()
Return the number of logical pixels per meter for the screen.
Definition chcanv.h:439
double GetPixPerMM()
Get the number of logical pixels per millimeter on the screen.
Definition chcanv.h:470
double GetDisplaySizeMM()
Get the width of the screen in millimeters.
Definition chcanv.h:221
double GetDisplayScale()
Get the ratio of physical to logical pixel for the display.
Definition chcanv.h:774
void SetDisplaySizeMM(double size)
Set the width of the screen in millimeters.
Definition chcanv.cpp:2361
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition chcanv.cpp:7481
bool PanCanvas(double dx, double dy)
Pans (moves) the canvas by the specified physical pixels in x and y directions.
Definition chcanv.cpp:5019
float GetVPScale()
Return the ViewPort scale factor, in physical pixels per meter.
Definition chcanv.h:428
void DoZoomCanvas(double factor, bool can_zoom_to_cursor=true)
Internal function that implements the actual zoom operation.
Definition chcanv.cpp:4624
double GetCanvasTrueScale()
Return the physical pixels per meter at chart center, accounting for latitude distortion.
Definition chcanv.h:444
void ZoomCanvasSimple(double factor)
Perform an immediate zoom operation without smooth transitions.
Definition chcanv.cpp:4599
bool SetVPScale(double sc, bool b_refresh=true)
Sets the viewport scale while maintaining the center point.
Definition chcanv.cpp:5293
double m_cursor_lon
The longitude at the mouse cursor position in degrees.
Definition chcanv.h:693
void GetCanvasPixPoint(double x, double y, double &lat, double &lon)
Convert canvas pixel coordinates (physical pixels) to latitude/longitude.
Definition chcanv.cpp:4543
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:4604
void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r)
Convert latitude/longitude to canvas pixel coordinates (physical pixels) with double precision.
Definition chcanv.cpp:4463
bool SetViewPoint(double lat, double lon)
Set the viewport center point.
Definition chcanv.cpp:5312
bool MouseEventProcessCanvas(wxMouseEvent &event)
Processes mouse events for core chart panning and zooming operations.
Definition chcanv.cpp:9798
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
Definition piano.h:65
Definition Quilt.h:83
Definition route.h:75
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:78
Definition undo.h:60
Represents the view port for chart display in OpenCPN.
Definition viewport.h:84
double view_scale_ppm
Requested view scale in physical pixels per meter (ppm), before applying projections.
Definition viewport.h:199
double rotation
Rotation angle of the viewport in radians.
Definition viewport.h:209
double tilt
Tilt angle for perspective view in radians.
Definition viewport.h:211
double skew
Angular distortion (shear transform) applied to the viewport in radians.
Definition viewport.h:207
double chart_scale
Chart scale denominator (e.g., 50000 for a 1:50000 scale).
Definition viewport.h:214
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