OpenCPN Partial API docs
Loading...
Searching...
No Matches
Quilt.h
1/******************************************************************************
2 *
3 * Project: OpenCPN
4 *
5 ***************************************************************************
6 * Copyright (C) 2013 by David S. Register *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the *
20 * Free Software Foundation, Inc., *
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
22 ***************************************************************************
23 */
24
25#ifndef __QUIT_H__
26#define __QUIT_H__
27
28#include "LLRegion.h"
29#include "OCPNRegion.h"
30#include "chcanv.h"
31#include "viewport.h"
32#include "chartdb.h"
33
34extern bool g_bopengl;
35
36struct ChartTableEntry;
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 b_locked = false;
60 last_factor = -1;
61 }
62
63 const LLRegion &GetCandidateRegion();
64 LLRegion &GetReducedCandidateRegion(double factor);
65 void SetScale(int scale);
66 bool Scale_eq(int b) const { return abs(ChartScale - b) <= rounding; }
67 bool Scale_ge(int b) const { return Scale_eq(b) || ChartScale > b; }
68
69 int dbIndex;
70 int ChartScale;
71 int rounding;
72 bool b_include;
73 bool b_eclipsed;
74 bool b_locked;
75
76private:
77 double last_factor;
78 LLRegion reduced_candidate_region;
79};
80
81WX_DECLARE_LIST(QuiltPatch, PatchList);
82WX_DEFINE_SORTED_ARRAY(QuiltCandidate *, ArrayOfSortedQuiltCandidates);
83
84class Quilt {
85public:
86 Quilt(ChartCanvas *parent);
87 ~Quilt();
88
89 void SetQuiltParameters(double CanvasScaleFactor, int CanvasWidth) {
90 m_canvas_scale_factor = CanvasScaleFactor;
91 m_canvas_width = CanvasWidth;
92 }
93
94 void EnableHighDefinitionZoom(bool value) { m_b_hidef = value; }
95
96 void UnlockQuilt();
97 bool Compose(const ViewPort &vp);
98 bool IsComposed() { return m_bcomposed; }
99 ChartBase *GetFirstChart();
100 ChartBase *GetNextChart();
101 ChartBase *GetLargestScaleChart();
102 ChartBase *GetNextSmallerScaleChart();
103
104 std::vector<int> GetQuiltIndexArray(void);
105 bool IsQuiltDelta(ViewPort &vp);
106 bool IsChartQuiltableRef(int db_index);
107 ViewPort &GetQuiltVP() { return m_vp_quilt; }
108 wxString GetQuiltDepthUnit() { return m_quilt_depth_unit; }
109 void SetRenderedVP(ViewPort &vp) { m_vp_rendered = vp; }
110 bool HasOverlays(void) { return m_bquilt_has_overlays; }
111
112 int GetExtendedStackCount(void) { return m_extended_stack_array.size(); }
113
114 int GetnCharts() { return m_PatchList.GetCount(); }
115 double GetBestStartScale(int dbi_ref_hint, const ViewPort &vp_in);
116
117 void ComputeRenderRegion(ViewPort &vp, OCPNRegion &chart_region);
118 bool RenderQuiltRegionViewOnDCNoText(wxMemoryDC &dc, ViewPort &vp,
119 OCPNRegion &chart_region);
120 bool RenderQuiltRegionViewOnDCTextOnly(wxMemoryDC &dc, ViewPort &vp,
121 OCPNRegion &chart_region);
122
123 bool IsVPBlittable(ViewPort &VPoint, int dx, int dy,
124 bool b_allow_vector = false);
125 ChartBase *GetChartAtPix(ViewPort &VPoint, wxPoint p);
126 ChartBase *GetOverlayChartAtPix(ViewPort &VPoint, wxPoint p);
127 int GetChartdbIndexAtPix(ViewPort &VPoint, wxPoint p);
128 void InvalidateAllQuiltPatchs(void);
129 void Invalidate(void) {
130 m_bcomposed = false;
131 m_vp_quilt.Invalidate();
132 m_zout_dbindex = -1;
133
134 // Quilting of skewed raster charts is allowed for OpenGL only
135 m_bquiltskew = g_bopengl;
136 // Quilting of different projections is allowed for OpenGL only
137 m_bquiltanyproj = g_bopengl;
138 }
139 void AdjustQuiltVP(ViewPort &vp_last, ViewPort &vp_proposed);
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 SetReferenceChart(int dbIndex) {
153 m_refchart_dbIndex = dbIndex;
154 if (dbIndex >= 0) {
155 m_zout_family = -1;
156 }
157 }
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
183 unsigned long GetXStackHash() { return m_xa_hash; }
184
185 bool IsBusy() { return m_bbusy; }
186 QuiltPatch *GetCurrentPatch();
187 bool IsChartInQuilt(ChartBase *pc);
188 bool IsChartInQuilt(wxString &full_path);
189
190 bool IsQuiltVector(void);
191 bool DoesQuiltContainPlugins(void);
192
193 LLRegion GetHiliteRegion();
194 static LLRegion GetChartQuiltRegion(const ChartTableEntry &cte, ViewPort &vp);
195
196 int GetNomScaleMin(int scale, ChartTypeEnum type, ChartFamilyEnum family);
197 int GetNomScaleMax(int scale, ChartTypeEnum type, ChartFamilyEnum family);
198 ChartFamilyEnum GetPreferredFamily(void) { return m_preferred_family; }
199
200private:
201 bool BuildExtendedChartStackAndCandidateArray(int ref_db_index,
202 ViewPort &vp_in);
203 int AdjustRefOnZoom(bool b_zin, ChartFamilyEnum family, ChartTypeEnum type,
204 double proposed_scale_onscreen);
205
206 bool DoRenderQuiltRegionViewOnDC(wxMemoryDC &dc, ViewPort &vp,
207 OCPNRegion &chart_region);
208 bool DoRenderQuiltRegionViewOnDCTextOnly(wxMemoryDC &dc, ViewPort &vp,
209 OCPNRegion &chart_region);
210
211 void EmptyCandidateArray(void);
212 void SubstituteClearDC(wxMemoryDC &dc, ViewPort &vp);
213 int GetNewRefChart(void);
214 const LLRegion &GetTilesetRegion(int dbIndex);
215
216 bool IsChartS57Overlay(int db_index);
217
218 LLRegion m_covered_region;
219 OCPNRegion m_rendered_region; // used only in dc mode
220
221 PatchList m_PatchList;
222 wxBitmap *m_pBM;
223
224 bool m_bcomposed;
225 wxPatchListNode *cnode;
226 bool m_bbusy;
227 int m_quilt_proj;
228
229 ArrayOfSortedQuiltCandidates *m_pcandidate_array;
230 std::vector<int> m_last_index_array;
231 std::vector<int> m_index_array;
232 std::vector<int> m_extended_stack_array;
233 std::vector<int> m_eclipsed_stack_array;
234
235 ViewPort m_vp_quilt;
236 ViewPort m_vp_rendered; // last VP rendered
237
238 int m_nHiLiteIndex;
239 int m_refchart_dbIndex;
240 int m_reference_scale;
241 int m_reference_type;
242 int m_reference_family;
243 bool m_bneed_clear;
244 LLRegion m_back_region;
245 wxString m_quilt_depth_unit;
246 double m_max_error_factor;
247 double m_canvas_scale_factor;
248 int m_canvas_width;
249 bool m_bquilt_has_overlays;
250 unsigned long m_xa_hash;
251 int m_zout_dbindex;
252 int m_zout_family;
253 int m_zout_type;
254
255 int m_lost_refchart_dbIndex;
256 bool m_b_hidef;
257
258 bool m_bquiltskew;
259 bool m_bquiltanyproj;
260 ChartFamilyEnum m_preferred_family;
261 ChartCanvas *m_parent;
262};
263
264#endif
Definition: Quilt.h:84
bool Compose(const ViewPort &vp)
Definition: Quilt.cpp:1643
Definition: Quilt.cpp:864