OpenCPN Partial API docs
Loading...
Searching...
No Matches
quilt.h
Go to the documentation of this file.
1/**************************************************************************
2 * Copyright (C) 2013 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 _gui_quilt_h
25#define _gui_quilt_h
26
27#include <vector>
28
29#include "model/config_vars.h"
30
31#include "LLRegion.h"
32#include "ocpn_region.h"
33#include "chcanv.h"
34#include "viewport.h"
35#include "chartdb.h"
36#include "chartdbs.h"
37
39public:
40 QuiltPatch() {
41 b_Valid = false;
42 b_eclipsed = false;
43 b_overlay = false;
44 }
45 int dbIndex;
46 LLRegion ActiveRegion;
47 int ProjType;
48 bool b_Valid;
49 bool b_eclipsed;
50 bool b_overlay;
51 LLRegion quilt_region;
52};
53
55public:
57 b_include = false;
58 b_eclipsed = false;
59 last_factor = -1;
60 }
61
62 const LLRegion &GetCandidateRegion();
63 LLRegion &GetReducedCandidateRegion(double factor);
64 void SetScale(int scale);
65 bool Scale_eq(int b) const { return abs(ChartScale - b) <= rounding; }
66 bool Scale_ge(int b) const { return Scale_eq(b) || ChartScale > b; }
67
68 int dbIndex;
69 int ChartScale;
70 int rounding;
71 bool b_include;
72 bool b_eclipsed;
73
74private:
75 double last_factor;
76 LLRegion reduced_candidate_region;
77};
78
79WX_DECLARE_LIST(QuiltPatch, PatchList);
80WX_DEFINE_SORTED_ARRAY(QuiltCandidate *, ArrayOfSortedQuiltCandidates);
81
82class Quilt {
83public:
84 Quilt(ChartCanvas *parent);
85 ~Quilt();
86
87 void SetQuiltParameters(double CanvasScaleFactor, int CanvasWidth) {
88 m_canvas_scale_factor = CanvasScaleFactor;
89 m_canvas_width = CanvasWidth;
90 }
91
92 void EnableHighDefinitionZoom(bool value) { m_b_hidef = value; }
93
94 void UnlockQuilt();
95 bool Compose(const ViewPort &vp);
96 bool IsComposed() { return m_bcomposed; }
97 ChartBase *GetFirstChart();
98 ChartBase *GetNextChart();
99 ChartBase *GetLargestScaleChart();
100 ChartBase *GetNextSmallerScaleChart();
101
102 std::vector<int> GetQuiltIndexArray(void);
103 bool IsQuiltDelta(ViewPort &vp);
104 bool IsChartQuiltableRef(int db_index);
105 ViewPort &GetQuiltVP() { return m_vp_quilt; }
106 wxString GetQuiltDepthUnit() { return m_quilt_depth_unit; }
107 void SetRenderedVP(ViewPort &vp) { m_vp_rendered = vp; }
108 bool HasOverlays(void) { return m_bquilt_has_overlays; }
109
110 int GetExtendedStackCount(void) { return m_extended_stack_array.size(); }
111 int GetFullScreenIndexCount(void) { return m_fullscreen_index_array.size(); }
112
113 int GetnCharts() { return m_PatchList.GetCount(); }
114 double GetBestStartScale(int dbi_ref_hint, const ViewPort &vp_in);
115
116 void ComputeRenderRegion(ViewPort &vp, OCPNRegion &chart_region);
117 bool RenderQuiltRegionViewOnDCNoText(wxMemoryDC &dc, ViewPort &vp,
118 OCPNRegion &chart_region);
119 bool RenderQuiltRegionViewOnDCTextOnly(wxMemoryDC &dc, ViewPort &vp,
120 OCPNRegion &chart_region);
121
122 bool IsVPBlittable(ViewPort &VPoint, int dx, int dy,
123 bool b_allow_vector = false);
124 ChartBase *GetChartAtPix(ViewPort &VPoint, wxPoint p);
125 ChartBase *GetOverlayChartAtPix(ViewPort &VPoint, wxPoint p);
126 int GetChartdbIndexAtPix(ViewPort &VPoint, wxPoint p);
127 void InvalidateAllQuiltPatchs(void);
128 void Invalidate(void) {
129 m_bcomposed = false;
130 m_vp_quilt.Invalidate();
131 m_zout_dbindex = -1;
132
133 // Quilting of skewed raster charts is allowed for OpenGL only
134 m_bquiltskew = g_bopengl;
135 // Quilting of different projections is allowed for OpenGL only
136 m_bquiltanyproj = g_bopengl;
137 }
138 void AdjustQuiltVP(ViewPort &vp_last, ViewPort &vp_proposed);
139
140 LLRegion &GetFullQuiltRegion(void) { return m_covered_region; }
141 OCPNRegion &GetFullQuiltRenderedRegion(void) { return m_rendered_region; }
142 bool IsChartSmallestScale(int dbIndex);
143
144 int AdjustRefOnZoomOut(double proposed_scale_onscreen);
145 int AdjustRefOnZoomIn(double proposed_scale_onscreen);
146 // int AdjustRefOnZoom( bool b_zin, ChartFamilyEnum family, ChartTypeEnum
147 // type, double proposed_scale_onscreen );
148 int AdjustRefSelection(const ViewPort &vp_in);
149
150 void SetHiliteIndex(int index) { m_nHiLiteIndex = index; }
151 void SetHiliteIndexArray(const std::vector<int> &index_array) {
152 m_HiLiteIndexArray = index_array;
153 }
154 void ClearHiliteIndexArray() { m_HiLiteIndexArray.clear(); }
155
156 void SetReferenceChart(int dbIndex);
157 int GetRefChartdbIndex(void) { return m_refchart_dbIndex; }
158
159 ChartBase *GetRefChart();
160
161 int GetQuiltProj(void) { return m_quilt_proj; }
162 double GetMaxErrorFactor() { return m_max_error_factor; }
163 double GetRefScale() { return m_reference_scale; }
164
165 ChartFamilyEnum GetRefFamily() { return (ChartFamilyEnum)m_reference_family; }
166
167 void SetPreferrefFamily(ChartFamilyEnum family) {
168 m_preferred_family = family;
169 }
170
171 double GetRefNativeScale();
172
173 std::vector<int> GetCandidatedbIndexArray(bool from_ref_chart,
174 bool exclude_user_hidden);
175 std::vector<int> &GetExtendedStackIndexArray() {
176 return m_extended_stack_array;
177 }
178 std::vector<int> GetEclipsedStackIndexArray() {
179 return m_eclipsed_stack_array;
180 }
181 std::vector<int> &GetFullscreenIndexArray() {
182 return m_fullscreen_index_array;
183 }
184
185 unsigned long GetXStackHash() { return m_xa_hash; }
186
187 bool IsBusy() { return m_bbusy; }
188 QuiltPatch *GetCurrentPatch();
189 bool IsChartInQuilt(ChartBase *pc);
190 bool IsChartInQuilt(wxString &full_path);
191
192 bool IsQuiltVector(void);
193 bool DoesQuiltContainPlugins(void);
194
195 LLRegion GetHiliteRegion();
196 std::vector<int> &GetHiLiteIndexArray() { return m_HiLiteIndexArray; }
197
198 static LLRegion GetChartQuiltRegion(const ChartTableEntry &cte, ViewPort &vp);
199
200 int GetNomScaleMin(int scale, ChartTypeEnum type, ChartFamilyEnum family);
201 int GetNomScaleMax(int scale, ChartTypeEnum type, ChartFamilyEnum family);
202 ChartFamilyEnum GetPreferredFamily(void) { return m_preferred_family; }
203
204private:
205 bool BuildExtendedChartStackAndCandidateArray(int ref_db_index,
206 ViewPort &vp_in);
207 int AdjustRefOnZoom(bool b_zin, ChartFamilyEnum family, ChartTypeEnum type,
208 double proposed_scale_onscreen);
209
210 bool DoRenderQuiltRegionViewOnDC(wxMemoryDC &dc, ViewPort &vp,
211 OCPNRegion &chart_region);
212 bool DoRenderQuiltRegionViewOnDCTextOnly(wxMemoryDC &dc, ViewPort &vp,
213 OCPNRegion &chart_region);
214
215 void EmptyCandidateArray(void);
216 void SubstituteClearDC(wxMemoryDC &dc, ViewPort &vp);
217 int GetNewRefChart(void);
218 const LLRegion &GetTilesetRegion(int dbIndex);
219
220 bool IsChartS57Overlay(int db_index);
221
222 LLRegion m_covered_region;
223 OCPNRegion m_rendered_region; // used only in dc mode
224
225 PatchList m_PatchList;
226 wxBitmap *m_pBM;
227
228 bool m_bcomposed;
229 wxPatchListNode *cnode;
230 bool m_bbusy;
231 int m_quilt_proj;
232
233 ArrayOfSortedQuiltCandidates *m_pcandidate_array;
234 std::vector<int> m_last_index_array;
235 std::vector<int> m_index_array;
236 std::vector<int> m_extended_stack_array;
237 std::vector<int> m_eclipsed_stack_array;
238 std::vector<int> m_fullscreen_index_array;
239
240 ViewPort m_vp_quilt;
241 ViewPort m_vp_rendered; // last VP rendered
242
243 int m_nHiLiteIndex;
244 std::vector<int> m_HiLiteIndexArray;
245 int m_refchart_dbIndex;
246 int m_reference_scale;
247 int m_reference_type;
248 int m_reference_family;
249 bool m_bneed_clear;
250 LLRegion m_back_region;
251 wxString m_quilt_depth_unit;
252 double m_max_error_factor;
253 double m_canvas_scale_factor;
254 int m_canvas_width;
255 bool m_bquilt_has_overlays;
256 unsigned long m_xa_hash;
257 int m_zout_dbindex;
258 int m_zout_family;
259 int m_zout_type;
260
261 int m_lost_refchart_dbIndex;
262 bool m_b_hidef;
263
264 bool m_bquiltskew;
265 bool m_bquiltanyproj;
266 ChartFamilyEnum m_preferred_family;
267 ChartCanvas *m_parent;
268};
269
270#endif // _gui_quilt_h
Charts database management
Basic chart info storage.
Generic Chart canvas base.
Base class for all chart types.
Definition chartbase.h:125
ChartCanvas - Main chart display and interaction component.
Definition chcanv.h:157
A wrapper class for wxRegion with additional functionality.
Definition ocpn_region.h:37
Definition quilt.h:82
bool Compose(const ViewPort &vp)
Definition quilt.cpp:1718
ViewPort - Core geographic projection and coordinate transformation engine.
Definition viewport.h:56
Global variables stored in configuration file.
OpenCPN region handling.
Represents an entry in the chart table, containing information about a single chart.
Definition chartdbs.h:183
Geographic projection and coordinate transformations.