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