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