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