OpenCPN Partial API docs
Loading...
Searching...
No Matches
chartdb.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 __CHARTDB_H__
25#define __CHARTDB_H__
26
27#include <wx/xml/xml.h>
28
29#include "chartbase.h"
30#include "chartbase.h"
31#include "chartdbs.h"
32
33#define MAXSTACK 100
34
35// ----------------------------------------------------------------------------
36// Constants, etc.
37// ----------------------------------------------------------------------------
38
39typedef struct {
40 float y;
41 float x;
42} MyFlPoint;
43
44class ChartDB; // forward
45extern ChartDB *ChartData;
46
47// ----------------------------------------------------------------------------
48// ----------------------------------------------------------------------------
49
51extern std::vector<std::string> ChartDirectoryExcludedVector;
52
53class ChartDB; // forward
55
57public:
58 ChartStack() {
59 nEntry = 0;
60 CurrentStackEntry = 0;
61 b_valid = false;
62 }
63
64 bool b_valid;
65 int nEntry;
66 int CurrentStackEntry;
67 int GetCurrentEntrydbIndex(void);
68 void SetCurrentEntryFromdbIndex(int current_db_index);
69 int GetDBIndex(int stack_index);
70 void SetDBIndex(int stack_index, int db_index);
71 bool DoesStackContaindbIndex(int db_index);
72 void AddChart(int db_add);
73
74private:
75 int DBIndex[MAXSTACK];
76};
77
79public:
80 wxString FullPath;
81 void *pChart;
82 int RecentTime;
83 int dbIndex;
84 bool b_in_use;
85 int n_lock;
86};
87
94class ChartDB : public ChartDatabase {
95public:
96 ChartDB();
97 virtual ~ChartDB();
98
104 bool LoadBinary(const wxString &filename, ArrayOfCDI &dir_array_check);
105 bool SaveBinary(const wxString &filename) {
106 return ChartDatabase::Write(filename);
107 }
108
109 int BuildChartStack(ChartStack *cstk, float lat, float lon, int groupIndex);
110 int BuildChartStack(ChartStack *cstk, float lat, float lon, int db_add,
111 int groupIndex);
112 bool EqualStacks(ChartStack *, ChartStack *);
113 bool CopyStack(ChartStack *pa, ChartStack *pb);
114 wxString GetFullPath(ChartStack *ps, int stackindex);
115 int GetStackChartScale(ChartStack *ps, int stackindex, char *buf, int nbuf);
116 int GetCSPlyPoint(ChartStack *ps, int stackindex, int plyindex, float *lat,
117 float *lon);
118 ChartTypeEnum GetCSChartType(ChartStack *ps, int stackindex);
119 ChartFamilyEnum GetCSChartFamily(ChartStack *ps, int stackindex);
120 bool SearchForChartDir(const wxString &dir);
121 ChartBase *OpenStackChartConditional(ChartStack *ps, int start_index,
122 bool bLargest, ChartTypeEnum New_Type,
123 ChartFamilyEnum New_Family_Fallback);
124
125 wxArrayPtrVoid *GetChartCache(void) { return pChartCache; }
126 std::vector<int> GetCSArray(ChartStack *ps);
127
128 int GetStackEntry(ChartStack *ps, wxString fp);
129 bool IsChartInCache(int dbindex);
130 bool IsChartInCache(wxString path);
131 bool IsChartInGroup(const int db_index, const int group);
132 bool IsENCInGroup(const int group);
133 bool IsNonMBTileInGroup(const int group);
134 bool IsChartDirectoryExcluded(const std::string &chart_file);
135
136 ChartBase *OpenChartFromStack(ChartStack *pStack, int StackEntry,
137 ChartInitFlag iflag = FULL_INIT);
138 ChartBase *OpenChartFromDB(int index, ChartInitFlag init_flag);
139 ChartBase *OpenChartFromDBAndLock(int index, ChartInitFlag init_flag,
140 bool lock = true);
141 ChartBase *OpenChartFromDBAndLock(wxString chart_path,
142 ChartInitFlag init_flag);
143 ChartBase *OpenChartFromDB(wxString chart_path, ChartInitFlag init_flag);
144
145 void ApplyColorSchemeToCachedCharts(ColorScheme cs);
146 void PurgeCache();
147 void PurgeCachePlugins();
148 bool DeleteCacheChart(ChartBase *pChart);
149
150 void LockCache(bool bl) { m_b_locked = bl; }
151 void LockCache() { m_b_locked = true; }
152 void UnLockCache() { m_b_locked = false; }
153 bool IsCacheLocked() { return m_b_locked; }
154 wxXmlDocument GetXMLDescription(int dbIndex, bool b_getGeom);
155
156 bool LockCacheChart(int index);
157 bool IsChartLocked(int index);
158
159 void UnLockCacheChart(int index);
160 void UnLockAllCacheCharts();
161
162 void ClearCacheInUseFlags(void);
163 void PurgeCacheUnusedCharts(double factor);
164
165 bool IsBusy() { return m_b_busy; }
166 bool CheckExclusiveTileGroup(int canvasIndex);
167 bool CheckAnyCanvasExclusiveTileGroup();
168
169protected:
170 virtual ChartBase *GetChart(const wxChar *theFilePath,
171 ChartClassDescriptor &chart_desc) const;
172
173private:
174 InitReturn CreateChartTableEntry(wxString full_name, ChartTableEntry *pEntry);
175
176 int SearchDirAndAddSENC(wxString &dir, bool bshow_prog, bool bupdate);
177 bool CreateS57SENCChartTableEntry(wxString full_name, ChartTableEntry *pEntry,
178 Extent *pext);
179 bool CheckPositionWithinChart(int index, float lat, float lon);
180 ChartBase *OpenChartUsingCache(int dbindex, ChartInitFlag init_flag);
181 CacheEntry *FindOldestDeleteCandidate(bool blog);
182 void DeleteCacheEntry(int i, bool bDelTexture = false,
183 const wxString &msg = wxEmptyString);
184 void DeleteCacheEntry(CacheEntry *pce, bool bDelTexture = false,
185 const wxString &msg = wxEmptyString);
186
187 wxArrayPtrVoid *pChartCache;
188 int m_ticks;
189
190 bool m_b_locked;
191 bool m_b_busy;
192
193 wxCriticalSection m_critSect;
194 wxMutex m_cache_mutex;
195 int m_checkGroupIndex[2];
196 bool m_checkedTileOnly[2];
197};
198
199#endif
General chart base definitions.
std::vector< std::string > ChartDirectoryExcludedVector
Global instance.
Definition chartdb.cpp:74
ChartDB * ChartData
Global instance.
Definition chartdb.h:54
Basic chart info storage.
Base class for all chart types.
Definition chartbase.h:125
Manages the chart database and provides access to chart data.
Definition chartdb.h:94
bool LoadBinary(const wxString &filename, ArrayOfCDI &dir_array_check)
Load the chart database from a binary file.
Definition chartdb.cpp:231
Manages a database of charts, including reading, writing, and querying chart information.
Definition chartdbs.h:311
Represents an entry in the chart table, containing information about a single chart.
Definition chartdbs.h:182