OpenCPN Partial API docs
Loading...
Searching...
No Matches
chartdb.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose: Chart Database Object
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2010 by David S. Register *
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
19 * *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
24 ***************************************************************************
25 *
26 *
27 *
28 */
29
30#ifndef __CHARTDB_H__
31#define __CHARTDB_H__
32
33#include <wx/xml/xml.h>
34
35#include "chartbase.h"
36#include "chartdbs.h"
37
38#define MAXSTACK 100
39
40// ----------------------------------------------------------------------------
41// Constants, etc.
42// ----------------------------------------------------------------------------
43
44typedef struct {
45 float y;
46 float x;
47} MyFlPoint;
48
49// ----------------------------------------------------------------------------
50// Fwd Declarations
51// ----------------------------------------------------------------------------
52class ChartBase;
53
54// ----------------------------------------------------------------------------
55// ----------------------------------------------------------------------------
56
58public:
59 ChartStack() {
60 nEntry = 0;
61 CurrentStackEntry = 0;
62 b_valid = false;
63 }
64
65 bool b_valid;
66 int nEntry;
67 int CurrentStackEntry;
68 int GetCurrentEntrydbIndex(void);
69 void SetCurrentEntryFromdbIndex(int current_db_index);
70 int GetDBIndex(int stack_index);
71 void SetDBIndex(int stack_index, int db_index);
72 bool DoesStackContaindbIndex(int db_index);
73 void AddChart(int db_add);
74
75private:
76 int DBIndex[MAXSTACK];
77};
78
80public:
81 wxString FullPath;
82 void *pChart;
83 int RecentTime;
84 int dbIndex;
85 bool b_in_use;
86 int n_lock;
87};
88
95class ChartDB : public ChartDatabase {
96public:
97 ChartDB();
98 virtual ~ChartDB();
99
105 bool LoadBinary(const wxString &filename, ArrayOfCDI &dir_array_check);
106 bool SaveBinary(const wxString &filename) {
107 return ChartDatabase::Write(filename);
108 }
109
110 int BuildChartStack(ChartStack *cstk, float lat, float lon, int groupIndex);
111 int BuildChartStack(ChartStack *cstk, float lat, float lon, int db_add,
112 int groupIndex);
113 bool EqualStacks(ChartStack *, ChartStack *);
114 bool CopyStack(ChartStack *pa, ChartStack *pb);
115 wxString GetFullPath(ChartStack *ps, int stackindex);
116 int GetStackChartScale(ChartStack *ps, int stackindex, char *buf, int nbuf);
117 int GetCSPlyPoint(ChartStack *ps, int stackindex, int plyindex, float *lat,
118 float *lon);
119 ChartTypeEnum GetCSChartType(ChartStack *ps, int stackindex);
120 ChartFamilyEnum GetCSChartFamily(ChartStack *ps, int stackindex);
121 bool SearchForChartDir(const wxString &dir);
122 ChartBase *OpenStackChartConditional(ChartStack *ps, int start_index,
123 bool bLargest, ChartTypeEnum New_Type,
124 ChartFamilyEnum New_Family_Fallback);
125
126 wxArrayPtrVoid *GetChartCache(void) { return pChartCache; }
127 std::vector<int> GetCSArray(ChartStack *ps);
128
129 int GetStackEntry(ChartStack *ps, wxString fp);
130 bool IsChartInCache(int dbindex);
131 bool IsChartInCache(wxString path);
132 bool IsChartInGroup(const int db_index, const int group);
133 bool IsENCInGroup(const int group);
134 bool IsNonMBTileInGroup(const int group);
135 bool IsChartDirectoryExcluded(const std::string &chart_file);
136
137 ChartBase *OpenChartFromStack(ChartStack *pStack, int StackEntry,
138 ChartInitFlag iflag = FULL_INIT);
139 ChartBase *OpenChartFromDB(int index, ChartInitFlag init_flag);
140 ChartBase *OpenChartFromDBAndLock(int index, ChartInitFlag init_flag,
141 bool lock = true);
142 ChartBase *OpenChartFromDBAndLock(wxString chart_path,
143 ChartInitFlag init_flag);
144 ChartBase *OpenChartFromDB(wxString chart_path, ChartInitFlag init_flag);
145
146 void ApplyColorSchemeToCachedCharts(ColorScheme cs);
147 void PurgeCache();
148 void PurgeCachePlugins();
149 bool DeleteCacheChart(ChartBase *pChart);
150
151 void LockCache(bool bl) { m_b_locked = bl; }
152 void LockCache() { m_b_locked = true; }
153 void UnLockCache() { m_b_locked = false; }
154 bool IsCacheLocked() { return m_b_locked; }
155 wxXmlDocument GetXMLDescription(int dbIndex, bool b_getGeom);
156
157 bool LockCacheChart(int index);
158 bool IsChartLocked(int index);
159
160 void UnLockCacheChart(int index);
161 void UnLockAllCacheCharts();
162
163 void ClearCacheInUseFlags(void);
164 void PurgeCacheUnusedCharts(double factor);
165
166 bool IsBusy() { return m_b_busy; }
167 bool CheckExclusiveTileGroup(int canvasIndex);
168 bool CheckAnyCanvasExclusiveTileGroup();
169
170protected:
171 virtual ChartBase *GetChart(const wxChar *theFilePath,
172 ChartClassDescriptor &chart_desc) const;
173
174private:
175 InitReturn CreateChartTableEntry(wxString full_name, ChartTableEntry *pEntry);
176
177 int SearchDirAndAddSENC(wxString &dir, bool bshow_prog, bool bupdate);
178 bool CreateS57SENCChartTableEntry(wxString full_name, ChartTableEntry *pEntry,
179 Extent *pext);
180 bool CheckPositionWithinChart(int index, float lat, float lon);
181 ChartBase *OpenChartUsingCache(int dbindex, ChartInitFlag init_flag);
182 CacheEntry *FindOldestDeleteCandidate(bool blog);
183 void DeleteCacheEntry(int i, bool bDelTexture = false,
184 const wxString &msg = wxEmptyString);
185 void DeleteCacheEntry(CacheEntry *pce, bool bDelTexture = false,
186 const wxString &msg = wxEmptyString);
187
188 wxArrayPtrVoid *pChartCache;
189 int m_ticks;
190
191 bool m_b_locked;
192 bool m_b_busy;
193
194 wxCriticalSection m_critSect;
195 wxMutex m_cache_mutex;
196 int m_checkGroupIndex[2];
197 bool m_checkedTileOnly[2];
198};
199
200#endif
Base class for all chart types.
Definition chartbase.h:119
Manages the chart database and provides access to chart data.
Definition chartdb.h:95
bool LoadBinary(const wxString &filename, ArrayOfCDI &dir_array_check)
Load the chart database from a binary file.
Definition chartdb.cpp:234
Manages a database of charts, including reading, writing, and querying chart information.
Definition chartdbs.h:310
Represents an entry in the chart table, containing information about a single chart.
Definition chartdbs.h:181