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 int SelectRefChartByFamily(ChartFamilyEnum family);
140
141 LLRegion &GetFullQuiltRegion(void) { return m_covered_region; }
142 OCPNRegion &GetFullQuiltRenderedRegion(void) { return m_rendered_region; }
143 bool IsChartSmallestScale(int dbIndex);
144
145 int AdjustRefOnZoomOut(double proposed_scale_onscreen);
146 int AdjustRefOnZoomIn(double proposed_scale_onscreen);
147 // int AdjustRefOnZoom( bool b_zin, ChartFamilyEnum family, ChartTypeEnum
148 // type, double proposed_scale_onscreen );
149 int AdjustRefSelection(const ViewPort &vp_in);
150
151 void SetHiliteIndex(int index) { m_nHiLiteIndex = index; }
152 void SetHiliteIndexArray(const std::vector<int> &index_array) {
153 m_HiLiteIndexArray = index_array;
154 }
155 void ClearHiliteIndexArray() { m_HiLiteIndexArray.clear(); }
156
157 void SetReferenceChart(int dbIndex);
158 int GetRefChartdbIndex(void) { return m_refchart_dbIndex; }
159
160 ChartBase *GetRefChart();
161
162 int GetQuiltProj(void) { return m_quilt_proj; }
163 double GetMaxErrorFactor() { return m_max_error_factor; }
164 double GetRefScale() { return m_reference_scale; }
165
166 ChartFamilyEnum GetRefFamily() { return (ChartFamilyEnum)m_reference_family; }
167
168 void SetPreferrefFamily(ChartFamilyEnum family) {
169 m_preferred_family = family;
170 }
171
172 double GetRefNativeScale();
173
174 std::vector<int> GetCandidatedbIndexArray(bool from_ref_chart,
175 bool exclude_user_hidden);
176 std::vector<int> &GetExtendedStackIndexArray() {
177 return m_extended_stack_array;
178 }
179 std::vector<int> GetEclipsedStackIndexArray() {
180 return m_eclipsed_stack_array;
181 }
182 std::vector<int> &GetFullscreenIndexArray() {
183 return m_fullscreen_index_array;
184 }
185
186 unsigned long GetXStackHash() { return m_xa_hash; }
187
188 bool IsBusy() { return m_bbusy; }
189 QuiltPatch *GetCurrentPatch();
190 bool IsChartInQuilt(ChartBase *pc);
191 bool IsChartInQuilt(wxString &full_path);
192
193 bool IsQuiltVector(void);
194 bool DoesQuiltContainPlugins(void);
195
196 LLRegion GetHiliteRegion();
197 std::vector<int> &GetHiLiteIndexArray() { return m_HiLiteIndexArray; }
198
199 static LLRegion GetChartQuiltRegion(const ChartTableEntry &cte, ViewPort &vp);
200
201 int GetNomScaleMin(int scale, ChartTypeEnum type, ChartFamilyEnum family);
202 int GetNomScaleMax(int scale, ChartTypeEnum type, ChartFamilyEnum family);
203 ChartFamilyEnum GetPreferredFamily(void) { return m_preferred_family; }
204
205private:
206 bool BuildExtendedChartStackAndCandidateArray(int ref_db_index,
207 ViewPort &vp_in);
208 int AdjustRefOnZoom(bool b_zin, ChartFamilyEnum family, ChartTypeEnum type,
209 double proposed_scale_onscreen);
210
211 bool DoRenderQuiltRegionViewOnDC(wxMemoryDC &dc, ViewPort &vp,
212 OCPNRegion &chart_region);
213 bool DoRenderQuiltRegionViewOnDCTextOnly(wxMemoryDC &dc, ViewPort &vp,
214 OCPNRegion &chart_region);
215
216 void EmptyCandidateArray(void);
217 void SubstituteClearDC(wxMemoryDC &dc, ViewPort &vp);
218 int GetNewRefChart(void);
219 const LLRegion &GetTilesetRegion(int dbIndex);
220
221 bool IsChartS57Overlay(int db_index);
222
223 LLRegion m_covered_region;
224 OCPNRegion m_rendered_region; // used only in dc mode
225
226 PatchList m_PatchList;
227 wxBitmap *m_pBM;
228
229 bool m_bcomposed;
230 wxPatchListNode *cnode;
231 bool m_bbusy;
232 int m_quilt_proj;
233
234 ArrayOfSortedQuiltCandidates *m_pcandidate_array;
235 std::vector<int> m_last_index_array;
236 std::vector<int> m_index_array;
237 std::vector<int> m_extended_stack_array;
238 std::vector<int> m_eclipsed_stack_array;
239 std::vector<int> m_fullscreen_index_array;
240
241 ViewPort m_vp_quilt;
242 ViewPort m_vp_rendered; // last VP rendered
243
244 int m_nHiLiteIndex;
245 std::vector<int> m_HiLiteIndexArray;
246 int m_refchart_dbIndex;
247 int m_reference_scale;
248 int m_reference_type;
249 int m_reference_family;
250 bool m_bneed_clear;
251 LLRegion m_back_region;
252 wxString m_quilt_depth_unit;
253 double m_max_error_factor;
254 double m_canvas_scale_factor;
255 int m_canvas_width;
256 bool m_bquilt_has_overlays;
257 unsigned long m_xa_hash;
258 int m_zout_dbindex;
259 int m_zout_family;
260 int m_zout_type;
261
262 int m_lost_refchart_dbIndex;
263 bool m_b_hidef;
264
265 bool m_bquiltskew;
266 bool m_bquiltanyproj;
267 ChartFamilyEnum m_preferred_family;
268 ChartCanvas *m_parent;
269};
270
271#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:1763
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.