OpenCPN Partial API docs
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 "bbox.h"
31 
32 #include <wx/datetime.h>
33 #include <wx/treectrl.h>
34 #include <wx/dirctrl.h>
35 #include <wx/sound.h>
36 #include <wx/grid.h>
37 #include <wx/wxhtml.h>
38 
39 #include "ocpndc.h"
40 #include "undo.h"
41 
42 #include "ocpCursor.h"
43 #include "timers.h"
44 #include "emboss_data.h"
45 #include "S57Sector.h"
46 #include "gshhs.h"
47 
48 class wxGLContext;
49 class GSHHSChart;
50 class IDX_entry;
51 class ocpnCompass;
52 class TimedPopupWin;
53 class Track;
54 
55 // Useful static routines
56 void ShowAISTargetQueryDialog(wxWindow *parent, int mmsi);
57 
58 //--------------------------------------------------------
59 // Screen Brightness Control Support Routines
60 //
61 //--------------------------------------------------------
62 
63 int InitScreenBrightness(void);
64 int RestoreScreenBrightness(void);
65 int SetScreenBrightness(int brightness);
66 
67 // Set up the preferred quilt type
68 #define QUILT_TYPE_2
69 
70 //----------------------------------------------------------------------------
71 // Forward Declarations
72 //----------------------------------------------------------------------------
73 class Route;
74 class TCWin;
75 class RoutePoint;
76 class SelectItem;
77 class BoundingBox;
78 class ocpnBitmap;
79 class WVSChart;
80 class MyFrame;
81 class ChartBaseBSB;
82 class ChartBase;
83 class AisTargetData;
84 class S57ObjectTree;
85 class S57ObjectDesc;
86 class RolloverWin;
87 class Quilt;
88 class PixelCache;
89 class ChInfoWin;
90 class glChartCanvas;
91 class CanvasMenuHandler;
92 class ChartStack;
93 class Piano;
94 class canvasConfig;
95 class MUIBar;
96 
97 enum // specify the render behaviour of SetViewPoint()
98 {
99  CURRENT_RENDER, // use the current render type
100  FORCE_SUBSAMPLE // force sub-sampled render, with re-render timer
101 };
102 
103 // Cursor region enumerator
104 enum {
105  CENTER,
106  MID_RIGHT,
107  MID_LEFT,
108  MID_TOP,
109  MID_BOT,
110 };
111 
112 typedef enum ownship_state_t {
113  SHIP_NORMAL = 0,
114  SHIP_LOWACCURACY,
115  SHIP_INVALID
116 } _ownship_state_t;
117 
118 enum { ID_S57QUERYTREECTRL = 10000, ID_AISDIALOGOK };
119 
120 enum { ID_PIANO_DISABLE_QUILT_CHART = 32000,
121  ID_PIANO_ENABLE_QUILT_CHART,
122  ID_PIANO_CONTRACT_PIANO,
123  ID_PIANO_EXPAND_PIANO
124 };
125 
126 enum { NORTH_UP_MODE, COURSE_UP_MODE, HEAD_UP_MODE };
127 
128 //----------------------------------------------------------------------------
129 // ChartCanvas
130 //----------------------------------------------------------------------------
131 class ChartCanvas : public wxWindow {
132  friend class glChartCanvas;
133 
134 public:
135  ChartCanvas(wxFrame *frame, int canvasIndex);
136  ~ChartCanvas();
137 
138  void SetupGlCanvas();
139 
140  // Methods
141  void OnKeyDown(wxKeyEvent &event);
142  void OnKeyUp(wxKeyEvent &event);
143  void OnKeyChar(wxKeyEvent &event);
144  void OnPaint(wxPaintEvent &event);
145  void PaintCleanup();
146  void Scroll(int dx, int dy);
147  void OnToolLeftClick(wxCommandEvent &event);
148 
149  bool MouseEventOverlayWindows(wxMouseEvent &event);
150  bool MouseEventChartBar(wxMouseEvent &event);
151  bool MouseEventMUIBar(wxMouseEvent &event);
152  bool MouseEventToolbar(wxMouseEvent &event);
153  bool MouseEventIENCBar(wxMouseEvent &event);
154 
155  bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick = true);
156  bool MouseEventProcessObjects(wxMouseEvent &event);
157  bool MouseEventProcessCanvas(wxMouseEvent &event);
158  void SetCanvasCursor(wxMouseEvent &event);
159  void OnKillFocus(wxFocusEvent &WXUNUSED(event));
160  void OnSetFocus(wxFocusEvent &WXUNUSED(event));
161 #ifdef HAVE_WX_GESTURE_EVENTS
162  void OnZoom(wxZoomGestureEvent& event);
163  void OnLongPress(wxLongPressEvent& event);
164  void OnPressAndTap(wxPressAndTapEvent& event);
165 
166  void OnLeftDown(wxMouseEvent& evt);
167  void OnLeftUp(wxMouseEvent& evt);
168 
169  void OnRightUp(wxMouseEvent& event);
170  void OnRightDown(wxMouseEvent& event);
171 
172  void OnDoubleLeftClick(wxMouseEvent& event);
173 
174  void OnWheel(wxMouseEvent& event);
175  void OnMotion(wxMouseEvent& event);
176 #endif /* HAVE_WX_GESTURE_EVENTS */
177 
178  void PopupMenuHandler(wxCommandEvent &event);
179  bool IsPrimaryCanvas() { return (m_canvasIndex == 0); }
180 
181  bool SetUserOwnship();
182 
183  double GetCanvasRangeMeters();
184  void SetCanvasRangeMeters(double range);
185 
186  void EnablePaint(bool b_enable);
187  virtual bool SetCursor(const wxCursor &c);
188  virtual void Refresh(bool eraseBackground = true,
189  const wxRect *rect = (const wxRect *)NULL);
190  virtual void Update();
191 
192  void LostMouseCapture(wxMouseCaptureLostEvent &event);
193 
194  void CancelMouseRoute();
195  void SetDisplaySizeMM(double size);
196  double GetDisplaySizeMM() { return m_display_size_mm; }
197 
198  bool SetVPScale(double sc, bool b_refresh = true);
199  bool SetVPProjection(int projection);
200  bool SetViewPoint(double lat, double lon);
201  bool SetViewPointByCorners(double latSW, double lonSW, double latNE,
202  double lonNE);
203  bool SetViewPoint(double lat, double lon, double scale_ppm, double skew,
204  double rotation, int projection = 0, bool b_adjust = true,
205  bool b_refresh = true);
206  void ReloadVP(bool b_adjust = true);
207  void LoadVP(ViewPort &vp, bool b_adjust = true);
208 
209  ChartStack *GetpCurrentStack() { return m_pCurrentStack; }
210  void SetGroupIndex(int index, bool autoswitch = false);
211  bool CheckGroup(int igroup);
212  void canvasRefreshGroupIndex(void);
213  void canvasChartsRefresh(int dbi_hint);
214 
215  void CheckGroupValid(bool showMessage = true, bool switchGroup0 = true);
216 
217  void UpdateCanvasS52PLIBConfig();
218 
219  void TriggerDeferredFocus();
220  void OnDeferredFocusTimerEvent(wxTimerEvent &event);
221  void OnRouteFinishTimerEvent(wxTimerEvent &event);
222 
223  void ClearS52PLIBStateHash() { m_s52StateHash = 0; }
224  void SetupCanvasQuiltMode(void);
225  void ApplyCanvasConfig(canvasConfig *pcc);
226 
227  bool SetVPRotation(double angle);
228  double GetVPRotation(void) { return GetVP().rotation; }
229  double GetVPSkew(void) { return GetVP().skew; }
230  double GetVPTilt(void) { return GetVP().tilt; }
231  void ClearbFollow(void);
232  void SetbFollow(void);
233  void TogglebFollow(void);
234  void JumpToPosition(double lat, double lon, double scale);
235  void SetFirstAuto(bool b_auto) { m_bFirstAuto = b_auto; }
236 
237  void GetDoubleCanvasPointPix(double rlat, double rlon, wxPoint2DDouble *r);
238  void GetDoubleCanvasPointPixVP(ViewPort &vp, double rlat, double rlon,
239  wxPoint2DDouble *r);
240  bool GetCanvasPointPix(double rlat, double rlon, wxPoint *r);
241  bool GetCanvasPointPixVP(ViewPort &vp, double rlat, double rlon, wxPoint *r);
242 
243  void GetCanvasPixPoint(double x, double y, double &lat, double &lon);
244  void WarpPointerDeferred(int x, int y);
245  void UpdateShips();
246  void UpdateAIS();
247  void UpdateAlerts(); // pjotrc 2010.02.22
248  void ToggleCPAWarn();
249 
250  bool IsMeasureActive() { return m_bMeasure_Active; }
251  wxBitmap &GetTideBitmap() { return m_cTideBitmap; }
252 
253  void UnlockQuilt();
254  void SetQuiltMode(bool b_quilt);
255  bool GetQuiltMode(void);
256  std::vector<int> GetQuiltIndexArray(void);
257  bool IsQuiltDelta(void);
258  void SetQuiltChartHiLiteIndex(int dbIndex);
259  void SetQuiltChartHiLiteIndexArray(std::vector<int> hilite_array);
260  void ClearQuiltChartHiLiteIndexArray();
261  int GetQuiltReferenceChartIndex(void);
262  double GetBestStartScale(int dbi_hint, const ViewPort &vp);
263  void ConfigureChartBar();
264 
265  int GetNextContextMenuId();
266 
267  TCWin *getTCWin() { return pCwin; }
268 
269  bool StartTimedMovement(bool stoptimer = true);
270  void DoTimedMovement();
271  void DoMovement(long dt);
272  void StopMovement();
273 
274  void SetColorScheme(ColorScheme cs);
275  ColorScheme GetColorScheme() { return m_cs; }
276 
277  void CanvasApplyLocale();
278  void RebuildCursors();
279 
280  // Accessors
281  int GetCanvasWidth() { return m_canvas_width; }
282  int GetCanvasHeight() { return m_canvas_height; }
283  float GetVPScale() { return GetVP().view_scale_ppm; }
284  float GetVPChartScale() { return GetVP().chart_scale; }
285  double GetCanvasScaleFactor() { return m_canvas_scale_factor; }
286  double GetCanvasTrueScale() { return m_true_scale_ppm; }
287  double GetAbsoluteMinScalePpm() { return m_absolute_min_scale_ppm; }
288  ViewPort &GetVP();
289  ViewPort *GetpVP() { return &VPoint; }
290  void SetVP(ViewPort &);
291  ChartBase *GetChartAtCursor();
292  ChartBase *GetOverlayChartAtCursor();
293  Piano *GetPiano() { return m_Piano; }
294  int GetPianoHeight();
295 
296  bool isRouteEditing(void) {
297  return m_bRouteEditing && m_pRoutePointEditTarget;
298  }
299  bool isMarkEditing(void) { return m_bMarkEditing && m_pRoutePointEditTarget; }
300 
301  GSHHSChart *GetWorldBackgroundChart() { return pWorldBackgroundChart; }
302  void ResetWorldBackgroundChart() { pWorldBackgroundChart->Reset(); }
303 
304  void SetbTCUpdate(bool f) { m_bTCupdate = f; }
305  bool GetbTCUpdate() { return m_bTCupdate; }
306  void SetbShowCurrent(bool f) { m_bShowCurrent = f; }
307  bool GetbShowCurrent() { return m_bShowCurrent; }
308  void SetbShowTide(bool f) { m_bShowTide = f; }
309  bool GetbShowTide() { return m_bShowTide; }
310  void SetShowVisibleSectors(bool val) { m_bShowVisibleSectors = val; }
311  bool GetShowVisibleSectors() { return m_bShowVisibleSectors; }
312 
313  double GetPixPerMM() { return m_pix_per_mm; }
314 
315  void SetOwnShipState(ownship_state_t state) { m_ownship_state = state; }
316  void SetCursorStatus(double cursor_lat, double cursor_lon);
317  void GetCursorLatLon(double *lat, double *lon);
318 
319  bool PanCanvas(double dx, double dy);
320  void StopAutoPan(void);
321 
322  void ZoomCanvas(double factor, bool can_zoom_to_cursor = true,
323  bool stoptimer = true);
324  void ZoomCanvasSimple(double factor);
325  void DoZoomCanvas(double factor, bool can_zoom_to_cursor = true);
326 
327  void RotateCanvas(double dir);
328  void DoRotateCanvas(double rotation);
329  void DoTiltCanvas(double tilt);
330 
331  void ShowAISTargetList(void);
332 
333  void ShowGoToPosition(void);
334  void HideGlobalToolbar();
335  void ShowGlobalToolbar();
336 
337  ChartBase *GetLargestScaleQuiltChart();
338  ChartBase *GetFirstQuiltChart();
339  ChartBase *GetNextQuiltChart();
340  int GetQuiltChartCount();
341  void InvalidateAllQuiltPatchs(void);
342  void SetQuiltRefChart(int dbIndex);
343  std::vector<int> GetQuiltCandidatedbIndexArray(bool flag1 = true,
344  bool flag2 = true);
345  std::vector<int> &GetQuiltExtendedStackdbIndexArray();
346  std::vector<int> &GetQuiltFullScreendbIndexArray();
347  std::vector<int> GetQuiltEclipsedStackdbIndexArray();
348  int GetQuiltRefChartdbIndex(void);
349  void InvalidateQuilt(void);
350  double GetQuiltMaxErrorFactor();
351  bool IsChartQuiltableRef(int db_index);
352  bool IsChartLargeEnoughToRender(ChartBase *chart, ViewPort &vp);
353  int GetCanvasChartNativeScale();
354  int FindClosestCanvasChartdbIndex(int scale);
355  void UpdateCanvasOnGroupChange(void);
356  void SetUpMode(int mode);
357  void ToggleLookahead();
358  void SetShowGPS(bool show);
359 
360  void ShowObjectQueryWindow(int x, int y, float zlat, float zlon);
361  void ShowMarkPropertiesDialog(RoutePoint *markPoint);
362  void ShowRoutePropertiesDialog(wxString title, Route *selected);
363  void ShowTrackPropertiesDialog(Track *selected);
364  void DrawTCWindow(int x, int y, void *pIDX);
365 
366  void UpdateGPSCompassStatusBox(bool b_force_new);
367  ocpnCompass *GetCompass() { return m_Compass; }
368 
369  wxColour GetFogColor() { return m_fog_color; }
370 
371  void ShowChartInfoWindow(int x, int dbIndex);
372  void HideChartInfoWindow(void);
373  void ShowCompositeInfoWindow(int x, int n_charts,
374  int scale, const std::vector<int> &index_vector);
375 
376  void StartMeasureRoute();
377  void CancelMeasureRoute();
378 
379  bool DoCanvasUpdate(void);
380  void SelectQuiltRefdbChart(int db_index, bool b_autoscale = true);
381  void SelectQuiltRefChart(int selected_index);
382  double GetBestVPScale(ChartBase *pchart);
383  void selectCanvasChartDisplay(int type, int family);
384  void RemoveChartFromQuilt(int dbIndex);
385 
386  void HandlePianoClick(int selected_index,
387  const std::vector<int> &selected_dbIndex_array);
388  void HandlePianoRClick(int x, int y, int selected_index,
389  const std::vector<int> &selected_dbIndex_array);
390  void HandlePianoRollover(int selected_index,
391  const std::vector<int> &selected_dbIndex_array,
392  int n_charts, int scale);
393  void ClearPianoRollover();
394  void UpdateCanvasControlBar(void);
395  void FormatPianoKeys(void);
396  void PianoPopupMenu(int x, int y, int selected_index,
397  const std::vector<int> &selected_dbIndex_array);
398  void OnPianoMenuDisableChart(wxCommandEvent &event);
399  void OnPianoMenuEnableChart(wxCommandEvent &event);
400 
401  bool IsPianoContextMenuActive() { return m_piano_ctx_menu != 0; }
402  bool DoCanvasCOGSet(void);
403  void UpdateFollowButtonState(void);
404  void ApplyGlobalSettings();
405  void SetShowGPSCompassWindow(bool bshow);
406 
407  void FreezePiano() { m_pianoFrozen = true; }
408  void ThawPiano() { m_pianoFrozen = false; }
409 
410  // Todo build more accessors
411  bool m_bFollow;
412  wxCursor *pCursorPencil;
413  wxCursor *pCursorArrow;
414  wxCursor *pCursorCross;
415  wxCursor *pPlugIn_Cursor;
416  TCWin *pCwin;
417  wxBitmap *pscratch_bm;
418  bool m_brepaint_piano;
419  double m_cursor_lon, m_cursor_lat;
420  Undo *undo;
421  wxPoint r_rband;
422  double m_prev_rlat;
423  double m_prev_rlon;
424  RoutePoint *m_prev_pMousePoint;
425  Quilt *m_pQuilt;
426  bool m_bShowNavobjects;
427  int m_canvasIndex;
428  int m_groupIndex;
429  int m_routeState;
430  ChartBase *m_singleChart;
431  int m_upMode;
432  bool m_bLookAhead;
433  double m_VPRotate;
434 
435 #ifdef HAVE_WX_GESTURE_EVENTS
436  double m_oldVPSScale;
437  bool m_popupWanted;
438  bool m_leftdown;
439  wxPoint m_zoomStartPoint;
440 #endif /* HAVE_WX_GESTURE_EVENTS */
441 
442  void DrawBlinkObjects(void);
443 
444  void StartRoute(void);
445  void FinishRoute(void);
446 
447  void InvalidateGL();
448 
449 #ifdef ocpnUSE_GL
450  glChartCanvas *GetglCanvas() { return m_glcc; }
451 #endif
452 
453  void JaggyCircle(ocpnDC &dc, wxPen pen, int x, int y, int radius);
454 
455  bool CheckEdgePan(int x, int y, bool bdragging, int margin, int delta);
456 
457  Route *m_pMouseRoute;
458  bool m_FinishRouteOnKillFocus;
459  bool m_bMeasure_Active;
460  bool m_bMeasure_DistCircle;
461  wxString m_active_upload_port;
462  bool m_bAppendingRoute;
463  int m_nMeasureState;
464  Route *m_pMeasureRoute;
465  MyFrame *parent_frame;
466  wxString FindValidUploadPort();
467  CanvasMenuHandler *m_canvasMenu;
468  int GetMinAvailableGshhgQuality() {
469  return pWorldBackgroundChart->GetMinAvailableQuality();
470  }
471  int GetMaxAvailableGshhgQuality() {
472  return pWorldBackgroundChart->GetMaxAvailableQuality();
473  }
474  Route *GetSelectedRoute() const { return m_pSelectedRoute; }
475  Track *GetSelectedTrack() const { return m_pSelectedTrack; }
476  RoutePoint *GetSelectedRoutePoint() const { return m_pFoundRoutePoint; }
477 
478  void SetAISCanvasDisplayStyle(int StyleIndx);
479  void TouchAISToolActive(void);
480  void UpdateAISTBTool(void);
481 
482 
483  void SelectChartFromStack(int index, bool bDir = false,
484  ChartTypeEnum New_Type = CHART_TYPE_DONTCARE,
485  ChartFamilyEnum New_Family = CHART_FAMILY_DONTCARE);
486  void SelectdbChart(int dbindex);
487 
488  void ShowTides(bool bShow);
489  void ShowCurrents(bool bShow);
490 
491  void DoCanvasStackDelta(int direction);
492 
493  void ProcessNewGUIScale();
494 
495  bool GetShowDepthUnits() { return m_bShowDepthUnits; }
496  void SetShowDepthUnits(bool show) { m_bShowDepthUnits = show; }
497  bool GetShowGrid() { return m_bDisplayGrid; }
498  void SetShowGrid(bool show) { m_bDisplayGrid = show; }
499  bool GetShowOutlines() { return m_bShowOutlines; }
500  void SetShowOutlines(bool show) { m_bShowOutlines = show; }
501  bool GetShowChartbar() { return true; }
502  wxRect GetMUIBarRect();
503  void SetMUIBarPosition();
504  void DestroyMuiBar();
505  void CreateMUIBar();
506 
507  void ToggleChartOutlines(void);
508  void ToggleCanvasQuiltMode(void);
509 
510  wxString GetScaleText() { return m_scaleText; }
511  double GetScaleValue() { return m_scaleValue; }
512 
513  bool m_b_paint_enable;
514 
515  bool GetShowENCText() { return m_encShowText; }
516  void SetShowENCText(bool show);
517 
518  bool GetShowENCDepth() { return m_encShowDepth; }
519  void SetShowENCDepth(bool show);
520 
521  bool GetShowENCLightDesc() { return m_encShowLightDesc; }
522  void SetShowENCLightDesc(bool show);
523 
524  bool GetShowENCBuoyLabels() { return m_encShowBuoyLabels; }
525  void SetShowENCBuoyLabels(bool show);
526 
527  bool GetShowENCLights() { return m_encShowLights; }
528  void SetShowENCLights(bool show);
529 
530  int GetENCDisplayCategory() { return m_encDisplayCategory; }
531  void SetENCDisplayCategory(int category);
532 
533  bool GetShowENCAnchor() { return m_encShowAnchor; }
534  void SetShowENCAnchor(bool show);
535 
536  bool GetShowENCDataQual() { return m_encShowDataQual; }
537  void SetShowENCDataQual(bool show);
538 
539  int GetUpMode() { return m_upMode; }
540  bool GetLookahead() { return m_bLookAhead; }
541 
542  bool GetShowAIS() { return m_bShowAIS; }
543  void SetShowAIS(bool show);
544  bool GetAttenAIS() { return m_bShowAISScaled; }
545  void SetAttenAIS(bool show);
546 
547  MUIBar *GetMUIBar() { return m_muiBar; }
548 
549  void SetAlertString(wxString str) { m_alertString = str; }
550  wxString GetAlertString() { return m_alertString; }
551 
552  wxRect GetScaleBarRect() { return m_scaleBarRect; }
553  void RenderAlertMessage(wxDC &dc, const ViewPort &vp);
554 
555  std::vector<int> m_tile_noshow_index_array;
556  std::vector<int> m_tile_yesshow_index_array;
557  std::vector<int> m_quilt_noshow_index_array;
558 
559  bool IsTileOverlayIndexInYesShow(int index);
560  bool IsTileOverlayIndexInNoShow(int index);
561  void AddTileOverlayIndexToNoShow(int index);
562 
563  std::vector<int> GetQuiltNoshowIindexArray() {
564  return m_quilt_noshow_index_array;
565  }
566  double GetDisplayScale(){ return m_displayScale; }
567 
568 private:
569  int AdjustQuiltRefChart();
570 
571  bool UpdateS52State();
572 
573  void CallPopupMenu(int x, int y);
574 
575  bool IsTempMenuBarEnabled();
576  bool InvokeCanvasMenu(int x, int y, int seltype);
577 
578  ViewPort VPoint;
579  void PositionConsole(void);
580 
581  wxColour PredColor();
582  wxColour ShipColor();
583 
584  void ComputeShipScaleFactor(float icon_hdt, int ownShipWidth,
585  int ownShipLength, wxPoint &lShipMidPoint,
586  wxPoint &GpsOffsetPixels, wxPoint lGPSPoint,
587  float &scale_factor_x, float &scale_factor_y);
588 
589  void ShipDrawLargeScale(ocpnDC &dc, wxPoint lShipMidPoint);
590  void ShipIndicatorsDraw(ocpnDC &dc, int img_height, wxPoint GPSOffsetPixels,
591  wxPoint lGPSPoint);
592 
593  ChInfoWin *m_pCIWin;
594 
595  bool m_bShowCurrent;
596  bool m_bShowTide;
597  int cursor_region;
598  bool m_bTCupdate;
599  wxString m_scaleText;
600  double m_scaleValue;
601  bool m_bShowScaleInStatusBar;
602  wxRect bbRect;
603 
604  wxPoint LastShipPoint;
605  wxPoint LastPredPoint;
606  bool m_bDrawingRoute;
607  bool m_bRouteEditing;
608  bool m_bMarkEditing;
609  bool m_bRoutePoinDragging;
610  bool m_bIsInRadius;
611  bool m_bMayToggleMenuBar;
612 
613  RoutePoint *m_pRoutePointEditTarget;
614  RoutePoint *m_lastRoutePointEditTarget;
615  SelectItem *m_pFoundPoint;
616  bool m_bChartDragging;
617  Route *m_pSelectedRoute;
618  Track *m_pSelectedTrack;
619  wxArrayPtrVoid *m_pEditRouteArray;
620  RoutePoint *m_pFoundRoutePoint;
621 
622  int m_FoundAIS_MMSI;
623 
624  wxCursor *pCursorLeft;
625  wxCursor *pCursorRight;
626  wxCursor *pCursorUp;
627  wxCursor *pCursorDown;
628 
629  wxCursor *pCursorUpLeft;
630  wxCursor *pCursorUpRight;
631  wxCursor *pCursorDownLeft;
632  wxCursor *pCursorDownRight;
633 
634  int popx, popy;
635 
636  wxBitmap *pThumbDIBShow;
637  wxBitmap *pThumbShowing;
638 
639  bool bShowingCurrent;
640  bool bShowingTide;
641 
642  double
643  m_canvas_scale_factor; // converter....
644  // useage....
645  // true_chart_scale_on_display =
646  // m_canvas_scale_factor / pixels_per_meter of
647  // displayed chart also may be considered as the
648  // "pixels-per-meter" of the canvas on-screen
649  double m_pix_per_mm; // pixels per millimeter on the screen
650  double m_display_size_mm;
651 
652  double m_absolute_min_scale_ppm;
653 
654  bool singleClickEventIsValid;
655  wxMouseEvent singleClickEvent;
656 
657  std::vector<s57Sector_t> extendedSectorLegs;
658  wxFont m_overzoomFont;
659  int m_overzoomTextWidth;
660  int m_overzoomTextHeight;
661 
662  // Methods
663  void OnActivate(wxActivateEvent &event);
664  void OnSize(wxSizeEvent &event);
665  void MouseTimedEvent(wxTimerEvent &event);
666  void MouseEvent(wxMouseEvent &event);
667  void ShipDraw(ocpnDC &dc);
668  void DrawArrow(ocpnDC &dc, int x, int y, double rot_angle, double scale);
669  void OnRolloverPopupTimerEvent(wxTimerEvent &event);
670  void FindRoutePointsAtCursor(float selectRadius, bool setBeingEdited);
671 
672  void RotateTimerEvent(wxTimerEvent &event);
673  void PanTimerEvent(wxTimerEvent &event);
674  void MovementTimerEvent(wxTimerEvent &);
675  void MovementStopTimerEvent(wxTimerEvent &);
676  void OnCursorTrackTimerEvent(wxTimerEvent &event);
677 
678  void DrawAllTracksInBBox(ocpnDC &dc, LLBBox &BltBBox);
679  void DrawActiveTrackInBBox(ocpnDC &dc, LLBBox &BltBBox);
680  void DrawAllRoutesInBBox(ocpnDC &dc, LLBBox &BltBBox);
681  void DrawActiveRouteInBBox(ocpnDC &dc, LLBBox &BltBBox);
682  void DrawAllWaypointsInBBox(ocpnDC &dc, LLBBox &BltBBox);
683  void DrawAnchorWatchPoints(ocpnDC &dc);
684  double GetAnchorWatchRadiusPixels(RoutePoint *pAnchorWatchPoint);
685 
686  void DrawAllTidesInBBox(ocpnDC &dc, LLBBox &BBox);
687  void DrawAllCurrentsInBBox(ocpnDC &dc, LLBBox &BBox);
688  void RebuildTideSelectList(LLBBox &BBox);
689  void RebuildCurrentSelectList(LLBBox &BBox);
690 
691  void RenderAllChartOutlines(ocpnDC &dc, ViewPort &vp);
692  void RenderChartOutline(ocpnDC &dc, int dbIndex, ViewPort &vp);
693  void RenderRouteLegs(ocpnDC &dc);
694  void RenderVisibleSectorLights(ocpnDC &dc);
695 
696  void AlertDraw(ocpnDC &dc); // pjotrc 2010.02.22
697 
698  void GridDraw(ocpnDC &dc); // Display lat/lon Grid in chart display
699  void ScaleBarDraw(ocpnDC &dc);
700 
701  void DrawOverlayObjects(ocpnDC &dc, const wxRegion &ru);
702  void RenderShipToActive(ocpnDC &dc, bool Use_Opengl);
703 
704  emboss_data *EmbossDepthScale();
705  emboss_data *CreateEmbossMapData(wxFont &font, int width, int height,
706  const wxString &str, ColorScheme cs);
707  void CreateDepthUnitEmbossMaps(ColorScheme cs);
708  wxBitmap CreateDimBitmap(wxBitmap &Bitmap, double factor);
709 
710  void CreateOZEmbossMapData(ColorScheme cs);
711  emboss_data *EmbossOverzoomIndicator(ocpnDC &dc);
712  void SetOverzoomFont();
713 
714  // void CreateCM93OffsetEmbossMapData(ColorScheme cs);
715  // void EmbossCM93Offset ( wxMemoryDC *pdc);
716 
717  void DrawEmboss(ocpnDC &dc, emboss_data *pemboss);
718 
719  void ShowBrightnessLevelTimedPopup(int brightness, int min, int max);
720 
721  // Data
722  int m_canvas_width, m_canvas_height;
723 
724  int xr_margin; // chart scroll margins, control cursor, etc.
725  int xl_margin;
726  int yt_margin;
727  int yb_margin;
728 
729  wxPoint last_drag;
730 
731  wxMemoryDC *pmemdc;
732 
733  int warp_x, warp_y;
734  bool warp_flag;
735 
736  wxTimer *
737  pPanTimer; // This timer used for auto panning on route creation and edit
738  wxTimer *
739  pMovementTimer; // This timer used for smooth movement in non-opengl mode
740  wxTimer *pMovementStopTimer; // This timer used to stop movement if a keyup
741  // event is lost
742  wxTimer *pCurTrackTimer; // This timer used to update the status window on
743  // mouse idle
744  wxTimer *pRotDefTimer; // This timer used to control rotaion rendering on
745  // mouse moves
746  wxTimer *m_DoubleClickTimer;
747  wxTimer m_routeFinishTimer;
748 
749  wxTimer m_RolloverPopupTimer;
750 
751  int m_wheelzoom_stop_oneshot;
752  int m_last_wheel_dir;
753  wxStopWatch m_wheelstopwatch;
754  double m_zoom_target;
755 
756  int m_curtrack_timer_msec;
757  int m_rollover_popup_timer_msec;
758 
759  GSHHSChart *pWorldBackgroundChart;
760 
761  ChartBaseBSB *pCBSB;
762  wxBitmap *pss_overlay_bmp;
763  wxMask *pss_overlay_mask;
764 
765  wxRect ship_draw_rect;
766  wxRect ship_draw_last_rect;
767  wxRect ais_draw_rect;
768  wxRect alert_draw_rect; // pjotrc 2010.02.22
769 
770  wxBitmap *proute_bm; // a bitmap and dc used to calculate route bounding box
771  wxMemoryDC m_dc_route; // seen in mouse->edit->route
772 
773  emboss_data *m_pEM_Feet; // maps for depth unit emboss pattern
774  emboss_data *m_pEM_Meters;
775  emboss_data *m_pEM_Fathoms;
776 
777  emboss_data *m_pEM_OverZoom;
778  // emboss_data *m_pEM_CM93Offset; // Flav
779 
780  double m_true_scale_ppm;
781 
782  ownship_state_t m_ownship_state;
783 
784  ColorScheme m_cs;
785 
786  wxBitmap m_bmTideDay;
787  wxBitmap m_bmTideDusk;
788  wxBitmap m_bmTideNight;
789  wxBitmap m_bmCurrentDay;
790  wxBitmap m_bmCurrentDusk;
791  wxBitmap m_bmCurrentNight;
792  wxBitmap m_cTideBitmap;
793  wxBitmap m_cCurrentBitmap;
794 
795  RolloverWin *m_pRouteRolloverWin;
796  RolloverWin *m_pTrackRolloverWin;
797  RolloverWin *m_pAISRolloverWin;
798 
799  TimedPopupWin *m_pBrightPopup;
800 
801  wxImage m_os_image_red_day;
802  wxImage m_os_image_red_dusk;
803  wxImage m_os_image_red_night;
804  wxImage m_os_image_grey_day;
805  wxImage m_os_image_grey_dusk;
806  wxImage m_os_image_grey_night;
807  wxImage m_os_image_yellow_day;
808  wxImage m_os_image_yellow_dusk;
809  wxImage m_os_image_yellow_night;
810 
811  wxImage *m_pos_image_red;
812  wxImage *m_pos_image_grey;
813  wxImage *m_pos_image_yellow;
814 
815  wxImage *m_pos_image_user;
816  wxImage *m_pos_image_user_grey;
817  wxImage *m_pos_image_user_yellow;
818 
819  wxImage *m_pos_image_user_day;
820  wxImage *m_pos_image_user_dusk;
821  wxImage *m_pos_image_user_night;
822  wxImage *m_pos_image_user_grey_day;
823  wxImage *m_pos_image_user_grey_dusk;
824  wxImage *m_pos_image_user_grey_night;
825  wxImage *m_pos_image_user_yellow_day;
826  wxImage *m_pos_image_user_yellow_dusk;
827  wxImage *m_pos_image_user_yellow_night;
828 
829  wxImage m_ship_pix_image; // cached ship draw image for high overzoom
830  int m_cur_ship_pix;
831  bool m_cur_ship_pix_isgrey;
832  ColorScheme m_ship_cs;
833 
834  ViewPort m_cache_vp;
835  wxBitmap *m_prot_bm;
836  wxPoint m_roffset;
837 
838  bool m_b_rot_hidef;
839 
840  SelectItem *m_pRolloverRouteSeg;
841  SelectItem *m_pRolloverTrackSeg;
842 
843  double m_wheel_lat, m_wheel_lon;
844  int m_wheel_x, m_wheel_y;
845 
846  ViewPort m_bm_cache_vp;
847  wxBitmap m_working_bm; // Used to build quilt in OnPaint()
848  wxBitmap m_cached_chart_bm; // A cached copy of the fully drawn quilt
849 
850  bool m_bbrightdir;
851  int m_brightmod;
852 
853  bool m_bzooming, m_bzooming_to_cursor;
854  IDX_entry *m_pIDXCandidate;
855 
856  //#ifdef ocpnUSE_GL
857  glChartCanvas *m_glcc;
858  //#endif
859 
860  // Smooth movement member variables
861  wxPoint m_pan_drag;
862  int m_panx, m_pany, m_modkeys;
863  double m_panspeed;
864  bool m_bmouse_key_mod;
865  double m_zoom_factor, m_rotation_speed;
866  int m_mustmove;
867 
868  wxDateTime m_last_movement_time;
869 
870  int m_AISRollover_MMSI;
871  bool m_bsectors_shown;
872  bool m_bedge_pan;
873  double m_displayed_scale_factor;
874 
875  wxColour m_fog_color;
876  bool m_disable_edge_pan;
877  wxFont *m_pgridFont;
878 
879  bool m_dragoffsetSet;
880 
881 
882  bool m_bautofind;
883  bool m_bFirstAuto;
884  double m_vLat, m_vLon;
885  ChartStack *m_pCurrentStack;
886  Piano *m_Piano;
887  bool m_bpersistent_quilt;
888 
889  wxMenu *m_piano_ctx_menu;
890  int menu_selected_dbIndex, menu_selected_index;
891 
892  ocpnCompass *m_Compass;
893  bool m_bShowGPS;
894 
895  wxRect m_mainlast_tb_rect;
896  int m_restore_dbindex;
897  int m_restore_group;
898 
899  MUIBar *m_muiBar;
900  wxSize m_muiBarHOSize;
901 
902  bool m_bShowOutlines;
903  bool m_bDisplayGrid;
904  bool m_bShowDepthUnits;
905  bool m_bShowAIS;
906  bool m_bShowAISScaled;
907 
908  // S52PLib state storage
909  long m_s52StateHash;
910  bool m_encShowText;
911  bool m_encShowDepth;
912  bool m_encShowLightDesc;
913  bool m_encShowBuoyLabels;
914  int m_encDisplayCategory;
915  bool m_encShowLights;
916  bool m_encShowAnchor;
917  bool m_encShowDataQual;
918 
919  wxTimer m_deferredFocusTimer;
920  float m_focus_indicator_pix;
921  bool m_bENCGroup;
922  bool m_last_TBviz;
923 
924  double m_OSoffsetx, m_OSoffsety;
925  bool m_MouseDragging;
926 
927  wxString m_alertString;
928  wxRect m_scaleBarRect;
929  bool m_bShowCompassWin;
930  bool m_pianoFrozen;
931 
932  double m_sector_glat, m_sector_glon;
933  std::vector<s57Sector_t> m_sectorlegsVisible;
934  bool m_bShowVisibleSectors;
935  double m_displayScale;
936 
937  DECLARE_EVENT_TABLE()
938 };
939 
940 // CUSTOMIZATION - FORMAT MINUTES
941 
942 wxString minutesToHoursDays(float timeInMinutes);
943 
944 // END OF CUSTOMIZATION - FORMAT MINUTES
945 
950 #ifndef wxCLOSE_BOX
951 #define wxCLOSE_BOX 0x1000
952 #endif
953 #ifndef wxFIXED_MINSIZE
954 #define wxFIXED_MINSIZE 0
955 #endif
956 
957 #endif // _CHCANV_H__
bool MouseEventSetup(wxMouseEvent &event, bool b_handle_dclick=true)
Definition: chcanv.cpp:7129
Definition: IDX_entry.h:41
Definition: MUIBar.h:58
Definition: piano.h:71
Definition: Quilt.h:83
Definition: route.h:75
Definition: TCWin.h:46
Definition: track.h:78
Definition: undo.h:60
Definition: ocpndc.h:58
Definition: Quilt.cpp:867