26 #ifndef __S57CHART_H__
27 #define __S57CHART_H__
30 #include <wx/progdlg.h>
32 #include "chartbase.h"
34 #include "wx/filename.h"
36 #include "wx/stream.h"
37 #include "wx/wfstream.h"
38 #include "gdal/ogrsf_frmts.h"
42 #include "gdal/gdal.h"
43 #include "s57RegistrarMgr.h"
44 #include "S57ClassRegistrar.h"
46 #include "S57Sector.h"
47 #include "OCPNRegion.h"
50 #include "SencManager.h"
53 #include <unordered_map>
63 extern "C" bool s57_GetChartExtent(
const wxString &FullPath,
Extent *pext);
65 void s57_DrawExtendedLightSectors(
ocpnDC &temp_dc,
ViewPort &VPoint,
66 std::vector<s57Sector_t> §orlegs);
67 void s57_DrawExtendedLightSectorsGL(
ocpnDC &temp_dc,
ViewPort &VPoint,
68 std::vector<s57Sector_t> §orlegs);
69 bool s57_CheckExtendedLightSectors(
ChartCanvas *cc,
int mx,
int my,
71 std::vector<s57Sector_t> §orlegs);
72 bool s57_GetVisibleLightSectors(
ChartCanvas *cc,
double lat,
double lon,
74 std::vector<s57Sector_t> §orlegs);
83 BUILD_SENC_NOK_PERMANENT,
97 class OGRS57DataSource;
98 class S57ClassRegistrar;
102 class connector_segment;
105 #include <wx/dynarray.h>
108 WX_DECLARE_OBJARRAY(S57Obj, ArrayOfS57Obj);
110 WX_DECLARE_LIST(ObjRazRules, ListOfObjRazRules);
120 virtual InitReturn Init(
const wxString &name, ChartInitFlag flags);
124 virtual ThumbData *GetThumbData(
int tnx,
int tny,
float lat,
float lon);
125 virtual ThumbData *GetThumbData() {
return pThumbData; }
126 bool UpdateThumbData(
double lat,
double lon);
128 virtual int GetNativeScale() {
return m_Chart_Scale; }
129 virtual double GetNormalScaleMin(
double canvas_scale_factor,
130 bool b_allow_overzoom);
131 virtual double GetNormalScaleMax(
double canvas_scale_factor,
134 void SetNativeScale(
int s) { m_Chart_Scale = s; }
136 virtual bool RenderRegionViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint,
138 virtual bool RenderOverlayRegionViewOnDC(wxMemoryDC &dc,
142 virtual bool RenderRegionViewOnDCNoText(wxMemoryDC &dc,
145 virtual bool RenderRegionViewOnDCTextOnly(wxMemoryDC &dc,
149 virtual void GetValidCanvasRegion(
const ViewPort &VPoint,
151 virtual LLRegion GetValidRegion();
153 virtual void GetPointPix(ObjRazRules *rzRules,
float rlat,
float rlon,
155 virtual void GetPointPix(ObjRazRules *rzRules, wxPoint2DDouble *en,
156 wxPoint *r,
int nPoints);
157 virtual void GetPixPoint(
int pixx,
int pixy,
double *plat,
double *plon,
160 virtual void SetVPParms(
const ViewPort &vpt);
165 virtual double GetNearestPreferredScalePPM(
double target_scale_ppm) {
166 return target_scale_ppm;
169 void SetFullExtent(
Extent &ext);
170 bool GetChartExtent(
Extent *pext);
172 void SetColorScheme(ColorScheme cs,
bool bApplyImmediate =
true);
173 virtual void UpdateLUPs(
s57chart *pOwner);
175 int _insertRules(S57Obj *obj, LUPrec *LUP,
s57chart *pOwner);
177 virtual ListOfObjRazRules *GetObjRuleListAtLatLon(
178 float lat,
float lon,
float select_radius,
ViewPort *VPoint,
179 int selection_mask = MASK_ALL);
180 bool DoesLatLonSelectObject(
float lat,
float lon,
float select_radius,
182 bool IsPointInObjArea(
float lat,
float lon,
float select_radius, S57Obj *obj);
183 virtual ListOfObjRazRules *GetLightsObjRuleListVisibleAtLatLon(
184 float lat,
float lon,
ViewPort *VPoint);
186 wxString GetObjectAttributeValueAsString(S57Obj *obj,
int iatt,
187 wxString curAttrName);
188 static wxString GetAttributeValueAsString(S57attVal *pAttrVal,
191 wxString CreateObjDescriptions(ListOfObjRazRules *rule);
192 static wxString GetAttributeDecode(wxString &att,
int ival);
194 int BuildRAZFromSENCFile(
const wxString &SENCPath);
195 static void GetChartNameFromTXT(
const wxString &FullPath, wxString &Name);
196 wxString buildSENCName(
const wxString &name);
199 bool GetNearestSafeContour(
double safe_cnt,
double &next_safe_cnt);
201 virtual std::list<S57Obj*> *GetAssociatedObjects(S57Obj *obj);
203 virtual std::unordered_map<unsigned, VE_Element *> &Get_ve_hash(
void) {
206 virtual std::unordered_map<unsigned, VC_Element *> &Get_vc_hash(
void) {
210 virtual void ForceEdgePriorityEvaluate(
void);
212 float *GetLineVertexBuffer(
void) {
return m_line_vertex_buffer; }
214 void ClearRenderedTextCache();
216 double GetCalculatedSafetyContour(
void) {
return m_next_safe_cnt; }
218 virtual bool RenderRegionViewOnGL(
const wxGLContext &glc,
221 const LLRegion &Region);
222 virtual bool RenderOverlayRegionViewOnGL(
const wxGLContext &glc,
225 const LLRegion &Region);
226 virtual bool RenderRegionViewOnGLNoText(
const wxGLContext &glc,
229 const LLRegion &Region);
230 virtual bool RenderViewOnGLTextOnly(
const wxGLContext &glc,
236 wxArrayPtrVoid *pFloatingATONArray;
237 wxArrayPtrVoid *pRigidATONArray;
239 double ref_lat, ref_lon;
243 bool m_bLinePrioritySet;
246 double m_easting_vp_center, m_northing_vp_center;
247 double m_pixx_vp_center, m_pixy_vp_center;
248 double m_view_scale_ppm;
255 virtual bool IsCacheValid() {
return (pDIB !=
nullptr); }
256 virtual void InvalidateCache();
257 virtual bool RenderViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint);
259 virtual void ClearDepthContourArray(
void);
260 virtual void BuildDepthContourArray(
void);
261 int ValidateAndCountUpdates(
const wxFileName file000,
const wxString CopyDir,
262 wxString &LastUpdateDate,
bool b_copyfiles);
263 static int GetUpdateFileArray(
const wxFileName file000,
264 wxArrayString *UpFiles, wxDateTime date000,
266 wxString GetISDT(
void);
267 InitReturn PostInit(ChartInitFlag flags, ColorScheme cs);
269 char GetUsageChar(
void) {
return m_usage_char; }
270 static bool IsCellOverlayType(
const wxString &pFullPath);
276 chart_context *m_this_chart_context;
278 int FindOrCreateSenc(
const wxString &name,
bool b_progress =
true);
279 void DisableBackgroundSENC() { m_disableBackgroundSENC =
true; }
280 void EnableBackgroundSENC() { m_disableBackgroundSENC =
false; }
282 SENCThreadStatus m_SENCthreadStatus;
285 void AssembleLineGeometry(
void);
287 ObjRazRules *razRules[PRIO_NUM][LUPNAME_NUM];
288 double m_next_safe_cnt;
291 int GetLineFeaturePointArray(S57Obj *obj,
void **ret_array);
292 void SetSafetyContour(
void);
294 bool DoRenderViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint,
295 RenderTypeEnum option,
bool force_new_view);
297 bool DoRenderRegionViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint,
300 int DCRenderRect(wxMemoryDC &dcinput,
const ViewPort &vp, wxRect *rect);
301 bool DCRenderLPB(wxMemoryDC &dcinput,
const ViewPort &vp, wxRect *rect);
302 bool DCRenderText(wxMemoryDC &dcinput,
const ViewPort &vp);
304 int BuildSENCFile(
const wxString &FullPath000,
const wxString &SENCFileName,
305 bool b_progress =
true);
307 void SetLinePriorities(
void);
309 bool BuildThumbnail(
const wxString &bmpname);
310 bool CreateHeaderDataFromENC(
void);
311 bool CreateHeaderDataFromSENC(
void);
312 bool CreateHeaderDataFromoSENC(
void);
313 bool GetBaseFileAttr(
const wxString &file000);
318 bool InitENCMinimal(
const wxString &FullPath);
320 OGRFeature *GetChartFirstM_COVR(
int &catcov);
321 OGRFeature *GetChartNextM_COVR(
int &catcov);
323 void FreeObjectsAndRules();
324 const char *getName(OGRFeature *feature);
326 bool DoRenderOnGL(
const wxGLContext &glc,
const ViewPort &VPoint);
327 bool DoRenderOnGLText(
const wxGLContext &glc,
const ViewPort &VPoint);
328 bool DoRenderRegionViewOnGL(
const wxGLContext &glc,
const ViewPort &VPoint,
330 const LLRegion &Region,
bool b_overlay);
332 void BuildLineVBO(
void);
334 void ChangeThumbColor(ColorScheme cs);
336 bool s57_ProcessExtendedLightSectors(
ChartCanvas *cc,
339 ListOfObjRazRules *rule_list,
340 std::list<S57Obj*> *pi_rule_list,
341 std::vector<s57Sector_t> §orlegs);
342 void CreateChartContext();
343 void PopulateObjectsWithContext();
349 wxString m_SENCFileName;
351 wxArrayString *m_tmpup_array;
354 wxBitmap *m_pCloneBM;
357 bool bGLUWarningSent;
359 wxBitmap *m_pDIBThumbDay;
360 wxBitmap *m_pDIBThumbDim;
361 wxBitmap *m_pDIBThumbOrphan;
362 bool m_bneed_new_thumbnail;
364 bool m_bbase_file_attr_known;
365 wxDateTime m_date000;
371 OGRS57DataSource *m_pENCDS;
376 double *m_pvaldco_array;
378 float *m_line_vertex_buffer;
379 size_t m_vbo_byte_length;
381 bool m_blastS57TextRender;
382 wxString m_lastColorScheme;
383 wxRect m_last_vprect;
384 long m_plib_state_hash;
391 std::unordered_map<unsigned, VE_Element *> m_ve_hash;
392 std::unordered_map<unsigned, VC_Element *> m_vc_hash;
393 std::vector<connector_segment *> m_pcs_vector;
394 std::vector<VE_Element *> m_pve_vector;
396 wxString m_TempFilePath;
397 bool m_disableBackgroundSENC;
400 sm_parms vp_transform;