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
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
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:233
Manages a database of charts, including reading, writing, and querying chart information.
Definition chartdbs.h:308
Represents an entry in the chart table, containing information about a single chart.
Definition chartdbs.h:181