30#include <wx/progdlg.h>
34#include "wx/filename.h"
37#include "wx/wfstream.h"
38#include "gdal/ogrsf_frmts.h"
43#include "s57RegistrarMgr.h"
44#include "S57ClassRegistrar.h"
47#include "OCPNRegion.h"
50#include "SencManager.h"
52#include "ocpn_plugin.h"
53#include <unordered_map>
63extern "C" bool s57_GetChartExtent(
const wxString &FullPath,
Extent *pext);
65void s57_DrawExtendedLightSectors(
ocpnDC &temp_dc,
ViewPort &VPoint,
66 std::vector<s57Sector_t> §orlegs);
67void s57_DrawExtendedLightSectorsGL(
ocpnDC &temp_dc,
ViewPort &VPoint,
68 std::vector<s57Sector_t> §orlegs);
69bool s57_CheckExtendedLightSectors(
ChartCanvas *cc,
int mx,
int my,
71 std::vector<s57Sector_t> §orlegs);
72bool s57_GetVisibleLightSectors(
ChartCanvas *cc,
double lat,
double lon,
74 std::vector<s57Sector_t> §orlegs);
83 BUILD_SENC_NOK_PERMANENT,
102class connector_segment;
105#include <wx/dynarray.h>
108WX_DECLARE_OBJARRAY(S57Obj, ArrayOfS57Obj);
110WX_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];
290 int GetLineFeaturePointArray(S57Obj *obj,
void **ret_array);
291 void SetSafetyContour(
void);
293 bool DoRenderViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint,
294 RenderTypeEnum option,
bool force_new_view);
296 bool DoRenderRegionViewOnDC(wxMemoryDC &dc,
const ViewPort &VPoint,
299 int DCRenderRect(wxMemoryDC &dcinput,
const ViewPort &vp, wxRect *rect);
300 bool DCRenderLPB(wxMemoryDC &dcinput,
const ViewPort &vp, wxRect *rect);
301 bool DCRenderText(wxMemoryDC &dcinput,
const ViewPort &vp);
303 int BuildSENCFile(
const wxString &FullPath000,
const wxString &SENCFileName,
304 bool b_progress =
true);
306 void SetLinePriorities(
void);
308 bool BuildThumbnail(
const wxString &bmpname);
309 bool CreateHeaderDataFromENC(
void);
310 bool CreateHeaderDataFromSENC(
void);
311 bool CreateHeaderDataFromoSENC(
void);
312 bool GetBaseFileAttr(
const wxString &file000);
317 bool InitENCMinimal(
const wxString &FullPath);
319 OGRFeature *GetChartFirstM_COVR(
int &catcov);
320 OGRFeature *GetChartNextM_COVR(
int &catcov);
322 void FreeObjectsAndRules();
323 const char *getName(OGRFeature *feature);
325 bool DoRenderOnGL(
const wxGLContext &glc,
const ViewPort &VPoint);
326 bool DoRenderOnGLText(
const wxGLContext &glc,
const ViewPort &VPoint);
327 bool DoRenderRegionViewOnGL(
const wxGLContext &glc,
const ViewPort &VPoint,
329 const LLRegion &Region,
bool b_overlay);
331 void BuildLineVBO(
void);
333 void ChangeThumbColor(ColorScheme cs);
335 bool s57_ProcessExtendedLightSectors(
ChartCanvas *cc,
338 ListOfObjRazRules *rule_list,
339 std::list<S57Obj*> *pi_rule_list,
340 std::vector<s57Sector_t> §orlegs);
346 wxString m_SENCFileName;
348 wxArrayString *m_tmpup_array;
351 wxBitmap *m_pCloneBM;
354 bool bGLUWarningSent;
356 wxBitmap *m_pDIBThumbDay;
357 wxBitmap *m_pDIBThumbDim;
358 wxBitmap *m_pDIBThumbOrphan;
359 bool m_bneed_new_thumbnail;
361 bool m_bbase_file_attr_known;
362 wxDateTime m_date000;
373 double *m_pvaldco_array;
375 float *m_line_vertex_buffer;
376 size_t m_vbo_byte_length;
378 bool m_blastS57TextRender;
379 wxString m_lastColorScheme;
380 wxRect m_last_vprect;
381 long m_plib_state_hash;
385 double m_next_safe_cnt;
389 std::unordered_map<unsigned, VE_Element *> m_ve_hash;
390 std::unordered_map<unsigned, VC_Element *> m_vc_hash;
391 std::vector<connector_segment *> m_pcs_vector;
392 std::vector<VE_Element *> m_pve_vector;
394 wxString m_TempFilePath;
395 bool m_disableBackgroundSENC;
398 sm_parms vp_transform;