1 /*************************************************************************** 2 * 3 * Project: OpenCPN 4 * 5 *************************************************************************** 6 * Copyright (C) 2013 by David S. Register * 7 * * 8 * This program is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU General Public License as published by * 10 * the Free Software Foundation; either version 2 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This program is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU General Public License * 19 * along with this program; if not, write to the * 20 * Free Software Foundation, Inc., * 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 22 **************************************************************************/ 23 24 #ifndef __ROUTEPOINT_H__ 25 #define __ROUTEPOINT_H__ 26 27 #include <wx/string.h> 28 #include <wx/datetime.h> 29 #include <wx/gdicmn.h> 30 #include <wx/gauge.h> 31 #include <wx/clrpicker.h> 32 #include "Hyperlink.h" 33 34 #define MAX_INT_VAL 2147483647 //max possible integer value before 'rollover' 35 #define SCAMIN_MIN 10000 //minimal allowed ScaMin setting. prevents always hiding 36 37 #define ETA_FORMAT_STR "%x %H:%M" 38 //"%d/%m/%Y %H:%M" //"%Y-%m-%d %H:%M" 39 40 class ocpnDC; 41 class wxDC; 42 class ChartCanvas; 43 44 class RoutePoint 45 { 46 public: 47 RoutePoint(double lat, double lon, const wxString& icon_ident, const wxString& name, const wxString &pGUID = wxEmptyString, bool bAddToList = true); 48 RoutePoint( RoutePoint* orig ); 49 RoutePoint(); 50 virtual ~RoutePoint(void); 51 void Draw(ocpnDC& dc, ChartCanvas *canvas, wxPoint *rpn = NULL, bool boverride_viz = false); 52 void ReLoadIcon(void); 53 54 void SetPosition(double lat, double lon); GetLatitude()55 double GetLatitude() { return m_lat; }; GetLongitude()56 double GetLongitude() { return m_lon; }; 57 void CalculateDCRect(wxDC& dc, ChartCanvas *canvas, wxRect *prect); GetBBox()58 LLBBox &GetBBox(){ return m_wpBBox; } 59 60 bool IsSame(RoutePoint *pOtherRP); // toh, 2009.02.11 IsVisible()61 bool IsVisible() { return m_bIsVisible; } IsListed()62 bool IsListed() { return m_bIsListed; } IsNameShown()63 bool IsNameShown() { return m_bShowName; } 64 bool IsVisibleSelectable(ChartCanvas *canvas, bool boverrideViz = false); 65 void SetVisible(bool viz = true){ m_bIsVisible = viz; } 66 void SetListed(bool viz = true){ m_bIsListed = viz; } 67 void SetNameShown(bool viz = true) { m_bShowName = viz; } GetName(void)68 virtual wxString GetName(void){ return m_MarkName; } GetDescription(void)69 wxString GetDescription(void) { return m_MarkDescription; } 70 71 wxDateTime GetCreateTime(void); 72 void SetCreateTime( wxDateTime dt ); 73 GetIconName(void)74 wxString GetIconName(void){ return m_IconName; } GetIconBitmap()75 wxBitmap *GetIconBitmap(){ return m_pbmIcon; } SetIconName(wxString name)76 void SetIconName( wxString name ){ m_IconName = name; } 77 GetSelectNode(void)78 void *GetSelectNode(void) { return m_SelectNode; } SetSelectNode(void * node)79 void SetSelectNode(void* node) { m_SelectNode = node; } 80 GetManagerListNode(void)81 void *GetManagerListNode(void) { return m_ManagerNode; } SetManagerListNode(void * node)82 void SetManagerListNode(void* node) { m_ManagerNode = node; } 83 84 void SetName(const wxString & name); 85 void CalculateNameExtents(void); 86 SetCourse(double course)87 void SetCourse( double course) { m_routeprop_course = course; }; GetCourse()88 double GetCourse() { return m_routeprop_course; }; SetDistance(double distance)89 void SetDistance( double distance) { m_routeprop_distance = distance; }; GetDistance()90 double GetDistance() { return m_routeprop_distance; }; 91 SetWaypointArrivalRadius(double dArrivalDistance)92 void SetWaypointArrivalRadius(double dArrivalDistance) { m_WaypointArrivalRadius = dArrivalDistance; }; SetWaypointArrivalRadius(wxString wxArrivalDistance)93 void SetWaypointArrivalRadius( wxString wxArrivalDistance ) { wxArrivalDistance.ToDouble( &m_WaypointArrivalRadius ); }; 94 double GetWaypointArrivalRadius(); GetShowWaypointRangeRings(void)95 bool GetShowWaypointRangeRings(void) { return m_bShowWaypointRangeRings; }; 96 int GetWaypointRangeRingsNumber(void); 97 float GetWaypointRangeRingsStep(void); 98 int GetWaypointRangeRingsStepUnits(void); 99 wxColour GetWaypointRangeRingsColour(void); SetShowWaypointRangeRings(bool b_showWaypointRangeRings)100 void SetShowWaypointRangeRings(bool b_showWaypointRangeRings) { m_bShowWaypointRangeRings = b_showWaypointRangeRings; }; SetWaypointRangeRingsNumber(int i_WaypointRangeRingsNumber)101 void SetWaypointRangeRingsNumber(int i_WaypointRangeRingsNumber) { m_iWaypointRangeRingsNumber = i_WaypointRangeRingsNumber; }; SetWaypointRangeRingsStep(float f_WaypointRangeRingsStep)102 void SetWaypointRangeRingsStep(float f_WaypointRangeRingsStep) { m_fWaypointRangeRingsStep = f_WaypointRangeRingsStep; }; SetWaypointRangeRingsStepUnits(int i_WaypointRangeRingsStepUnits)103 void SetWaypointRangeRingsStepUnits(int i_WaypointRangeRingsStepUnits) { m_iWaypointRangeRingsStepUnits = i_WaypointRangeRingsStepUnits; }; SetWaypointRangeRingsColour(wxColour wxc_WaypointRangeRingsColour)104 void SetWaypointRangeRingsColour( wxColour wxc_WaypointRangeRingsColour ) { m_wxcWaypointRangeRingsColour = wxc_WaypointRangeRingsColour; }; 105 void SetScaMin(wxString str); 106 void SetScaMin(long val); GetScaMin()107 long GetScaMin(){return m_ScaMin; }; 108 void SetScaMax(wxString str); 109 void SetScaMax(long val); GetScaMax()110 long GetScaMax(){return m_ScaMax; }; GetUseSca()111 bool GetUseSca(){return b_UseScamin; }; SetUseSca(bool value)112 void SetUseSca( bool value ){ b_UseScamin = value; }; 113 bool SendToGPS(const wxString& com_name, wxGauge *pProgress); 114 void EnableDragHandle(bool bEnable); IsDragHandleEnabled()115 bool IsDragHandleEnabled(){ return m_bDrawDragHandle; } 116 wxPoint2DDouble GetDragHandlePoint( ChartCanvas *canvas ); 117 void SetPointFromDraghandlePoint(ChartCanvas *canvas, double lat, double lon); 118 void SetPointFromDraghandlePoint(ChartCanvas *canvas, int x, int y); 119 void PresetDragOffset( ChartCanvas *canvas, int x, int y); 120 void ShowScaleWarningMessage(ChartCanvas *canvas); 121 void SetPlannedSpeed(double spd); 122 double GetPlannedSpeed(); 123 wxDateTime GetETD(); 124 wxDateTime GetManualETD(); 125 void SetETD(const wxDateTime &etd); 126 bool SetETD(const wxString &ts); 127 wxDateTime GetETA(); 128 wxString GetETE(); 129 void SetETE(wxLongLong secs); 130 131 double m_lat, m_lon; 132 double m_seg_len; // length in NMI to this point 133 // undefined for starting point 134 double m_seg_vmg; 135 wxDateTime m_seg_etd; 136 wxDateTime m_seg_eta; 137 wxLongLong m_seg_ete = 0; 138 bool m_manual_etd{false}; 139 140 bool m_bPtIsSelected; 141 bool m_bRPIsBeingEdited; 142 143 bool m_bIsInRoute; 144 bool m_bIsolatedMark; // This is an isolated mark 145 146 bool m_bKeepXRoute; // This is a mark which is part of a route/track 147 // and is also an isolated mark, so should not be deleted with 148 // route 149 150 bool m_bIsVisible; // true if should be drawn, false if invisible 151 bool m_bIsListed; 152 bool m_bIsActive; 153 wxString m_MarkDescription; 154 wxString m_GUID; 155 156 wxString m_TideStation; 157 158 wxFont *m_pMarkFont; 159 wxColour m_FontColor; 160 161 wxSize m_NameExtents; 162 163 bool m_bBlink; 164 bool m_bDynamicName; 165 bool m_bShowName, m_bShowNameData; 166 wxRect CurrentRect_in_DC; 167 int m_NameLocationOffsetX; 168 int m_NameLocationOffsetY; 169 bool m_bIsInLayer; 170 int m_LayerID; 171 172 double m_routeprop_course; // course from this waypoint to the next waypoint if in a route. 173 double m_routeprop_distance; // distance from this waypoint to the next waypoint if in a route. 174 175 bool m_btemp; 176 177 bool m_bShowWaypointRangeRings; 178 int m_iWaypointRangeRingsNumber; 179 float m_fWaypointRangeRingsStep; 180 int m_iWaypointRangeRingsStepUnits; 181 wxColour m_wxcWaypointRangeRingsColour; 182 183 184 #ifdef ocpnUSE_GL 185 void DrawGL( ViewPort &vp, ChartCanvas *canvas, bool use_cached_screen_coords=false, bool bVizOverride=false ); 186 unsigned int m_iTextTexture; 187 int m_iTextTextureWidth, m_iTextTextureHeight; 188 189 LLBBox m_wpBBox; 190 double m_wpBBox_view_scale_ppm, m_wpBBox_rotation; 191 192 bool m_pos_on_screen; 193 wxPoint2DDouble m_screen_pos; // cached for arrows and points 194 #endif 195 196 double m_WaypointArrivalRadius; 197 HyperlinkList *m_HyperlinkList; 198 199 wxString m_timestring; 200 201 wxDateTime m_CreateTimeX; 202 private: 203 wxPoint2DDouble computeDragHandlePoint(ChartCanvas *canvas); 204 205 wxString m_MarkName; 206 wxBitmap *m_pbmIcon; 207 wxString m_IconName; 208 209 void *m_SelectNode; 210 void *m_ManagerNode; 211 212 float m_IconScaleFactor; 213 wxBitmap m_ScaledBMP; 214 bool m_bPreScaled; 215 bool m_bDrawDragHandle; 216 wxBitmap m_dragIcon; 217 int m_drag_line_length_man, m_drag_icon_offset; 218 double m_dragHandleLat, m_dragHandleLon; 219 int m_draggingOffsetx, m_draggingOffsety; 220 bool b_UseScamin; 221 long m_ScaMin; 222 long m_ScaMax; 223 double m_PlannedSpeed; 224 225 #ifdef ocpnUSE_GL 226 unsigned int m_dragIconTexture; 227 int m_dragIconTextureWidth, m_dragIconTextureHeight; 228 #endif 229 230 }; 231 232 WX_DECLARE_LIST(RoutePoint, RoutePointList);// establish class as list member 233 234 #endif 235