1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
/***************************************************************************
*
* Project: OpenCPN
* Purpose: ChartBase Definition
* Author: David Register
*
***************************************************************************
* Copyright (C) 2010 by David S. Register *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
**************************************************************************/
#ifndef _CHARTBASE_H_
#define _CHARTBASE_H_
#include "dychart.h"
#include "bbox.h"
#include "ocpn_types.h"
#include "LLRegion.h"
//----------------------------------------------------------------------------
// Forward Declarations
//----------------------------------------------------------------------------
class ViewPort;
class wxGLContext;
class OCPNRegion;
//----------------------------------------------------------------------------
// Constants. etc
//----------------------------------------------------------------------------
// ChartBase::Init() init_flags constants
typedef enum ChartInitFlag
{
FULL_INIT = 0,
HEADER_ONLY,
THUMB_ONLY
}_ChartInitFlag;
typedef enum RenderTypeEnum
{
DC_RENDER_ONLY = 0,
DC_RENDER_RETURN_DIB,
DC_RENDER_RETURN_IMAGE
}_RenderTypeEnum;
typedef enum InitReturn
{
INIT_OK = 0,
INIT_FAIL_RETRY, // Init failed, retry suggested
INIT_FAIL_REMOVE, // Init failed, suggest remove from further use
INIT_FAIL_NOERROR // Init failed, request no explicit error message
}_InitReturn;
class ThumbData
{
public:
ThumbData();
virtual ~ThumbData();
wxBitmap *pDIBThumb;
int ShipX;
int ShipY;
int Thumb_Size_X;
int Thumb_Size_Y;
};
typedef struct _Extent{
float SLAT;
float WLON;
float NLAT;
float ELON;
}Extent;
// Depth unit type enum
typedef enum ChartDepthUnitType
{
DEPTH_UNIT_UNKNOWN,
DEPTH_UNIT_FEET,
DEPTH_UNIT_METERS,
DEPTH_UNIT_FATHOMS
}_ChartDepthUnitType;
// Projection type enum
typedef enum OcpnProjType
{
PROJECTION_UNKNOWN,
PROJECTION_MERCATOR,
PROJECTION_TRANSVERSE_MERCATOR,
PROJECTION_POLYCONIC,
PROJECTION_ORTHOGRAPHIC,
PROJECTION_POLAR,
PROJECTION_STEREOGRAPHIC,
PROJECTION_GNOMONIC,
PROJECTION_EQUIRECTANGULAR,
PROJECTION_WEB_MERCATOR
}_OcpnProjType;
class Plypoint
{
public:
float ltp;
float lnp;
};
// ----------------------------------------------------------------------------
// ChartBase
// ----------------------------------------------------------------------------
class ChartBase
{
public:
ChartBase();
virtual ~ChartBase() = 0;
virtual InitReturn Init( const wxString& name, ChartInitFlag init_flags) = 0;
virtual void Activate(void) {};
virtual void Deactivate(void) {};
// Accessors
virtual ThumbData *GetThumbData(int tnx, int tny, float lat, float lon) = 0;
virtual ThumbData *GetThumbData() = 0;
virtual bool UpdateThumbData(double lat, double lon) = 0;
virtual double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom) = 0;
virtual double GetNormalScaleMax(double canvas_scale_factor, int canvas_width) = 0;
virtual bool GetChartExtent(Extent *pext) = 0;
virtual OcpnProjType GetChartProjectionType(){ return m_projection;}
virtual wxDateTime GetEditionDate(void){ return m_EdDate;}
virtual wxString GetPubDate(){ return m_PubYear;}
virtual int GetNativeScale(){ return m_Chart_Scale;}
wxString GetFullPath() const { return m_FullPath;}
wxString GetHashKey() const;
wxString GetName(){ return m_Name;}
wxString GetDescription() { return m_Description;}
wxString GetID(){ return m_ID;}
wxString GetSE(){ return m_SE;}
wxString GetDepthUnits(){ return m_DepthUnits;}
wxString GetSoundingsDatum(){ return m_SoundingsDatum;}
wxString GetDatumString(){ return m_datum_str;}
wxString GetExtraInfo(){ return m_ExtraInfo; }
double GetChart_Error_Factor(){ return Chart_Error_Factor; }
ChartTypeEnum GetChartType(){ return m_ChartType;}
ChartFamilyEnum GetChartFamily(){ return m_ChartFamily;}
double GetChartSkew(){ return m_Chart_Skew; }
virtual ChartDepthUnitType GetDepthUnitType(void) { return m_depth_unit_id;}
virtual bool IsReadyToRender(){ return bReadyToRender;}
virtual bool RenderRegionViewOnDC(wxMemoryDC& dc, const ViewPort& VPoint,
const OCPNRegion &Region) = 0;
virtual bool RenderRegionViewOnGL(const wxGLContext &glc, const ViewPort& VPoint,
const OCPNRegion &RectRegion, const LLRegion &Region) = 0;
virtual bool AdjustVP(ViewPort &vp_last, ViewPort &vp_proposed) = 0;
virtual void GetValidCanvasRegion(const ViewPort& VPoint, OCPNRegion *pValidRegion) = 0;
virtual LLRegion GetValidRegion() = 0;
virtual void SetColorScheme(ColorScheme cs, bool bApplyImmediate = true ) = 0;
virtual double GetNearestPreferredScalePPM(double target_scale_ppm) = 0;
virtual int GetCOVREntries(){ return m_nCOVREntries; }
virtual int GetCOVRTablePoints(int iTable) { return m_pCOVRTablePoints[iTable]; }
virtual int GetCOVRTablenPoints(int iTable){ return m_pCOVRTablePoints[iTable]; }
virtual float *GetCOVRTableHead(int iTable){ return m_pCOVRTable[iTable]; }
virtual int GetNoCOVREntries(){ return m_nNoCOVREntries; }
virtual int GetNoCOVRTablePoints(int iTable) { return m_pNoCOVRTablePoints[iTable]; }
virtual int GetNoCOVRTablenPoints(int iTable){ return m_pNoCOVRTablePoints[iTable]; }
virtual float *GetNoCOVRTableHead(int iTable){ return m_pNoCOVRTable[iTable]; }
protected:
int m_Chart_Scale;
ChartTypeEnum m_ChartType;
ChartFamilyEnum m_ChartFamily;
wxString m_FullPath;
wxString m_Name;
wxString m_Description;
wxString m_ID;
wxString m_SE;
wxString m_SoundingsDatum;
wxString m_datum_str;
wxString m_ExtraInfo;
wxString m_PubYear;
wxString m_DepthUnits;
OcpnProjType m_projection;
ChartDepthUnitType m_depth_unit_id;
wxDateTime m_EdDate;
ThumbData *pThumbData;
ColorScheme m_global_color_scheme;
bool bReadyToRender;
double Chart_Error_Factor;
double m_lon_datum_adjust; // Add these numbers to WGS84 position to obtain internal chart position
double m_lat_datum_adjust;
double m_Chart_Skew;
// Chart region coverage information
// Charts may have multiple valid regions within the lat/lon box described by the chart extent
// The following table structure contains this embedded information
// Typically, BSB charts will contain only one entry, corresponding to the PLY information in the chart header
// ENC charts often contain multiple entries
int m_nCOVREntries; // number of coverage table entries
int *m_pCOVRTablePoints; // int table of number of points in each coverage table entry
float **m_pCOVRTable; // table of pointers to list of floats describing valid COVR
int m_nNoCOVREntries; // number of NoCoverage table entries
int *m_pNoCOVRTablePoints; // int table of number of points in each NoCoverage table entry
float **m_pNoCOVRTable; // table of pointers to list of floats describing valid NOCOVR
};
// ----------------------------------------------------------------------------
// ChartDummy
// ----------------------------------------------------------------------------
class ChartDummy : public ChartBase
{
public:
ChartDummy();
virtual ~ChartDummy();
virtual InitReturn Init( const wxString& name, ChartInitFlag init_flags );
// Accessors
virtual ThumbData *GetThumbData(int tnx, int tny, float lat, float lon);
virtual ThumbData *GetThumbData() {return pThumbData;}
virtual bool UpdateThumbData(double lat, double lon);
double GetNormalScaleMin(double canvas_scale_factor, bool b_allow_overzoom){return 1.0;}
double GetNormalScaleMax(double canvas_scale_factor, int canvas_width){ return 2.0e7;}
virtual bool GetChartExtent(Extent *pext);
virtual bool RenderRegionViewOnDC(wxMemoryDC& dc, const ViewPort& VPoint,
const OCPNRegion &Region);
virtual bool RenderRegionViewOnGL(const wxGLContext &glc, const ViewPort& VPoint,
const OCPNRegion &RectRegion, const LLRegion &Region);
virtual bool AdjustVP(ViewPort &vp_last, ViewPort &vp_proposed);
virtual void GetValidCanvasRegion(const ViewPort& VPoint, OCPNRegion *pValidRegion);
virtual LLRegion GetValidRegion();
virtual void SetColorScheme(ColorScheme cs, bool bApplyImmediate);
virtual double GetNearestPreferredScalePPM(double target_scale_ppm){ return target_scale_ppm; }
private:
bool RenderViewOnDC(wxMemoryDC& dc, const ViewPort& VPoint);
wxBitmap *m_pBM;
};
#endif
|