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