7#include "color_handler.h"
12#include "glChartCanvas.h"
15extern wxColour g_colourTrackLineColour;
17extern wxColor GetDimColor(wxColor c);
18extern bool g_bHighliteTracks;
19extern float g_GLMinSymbolLineWidth;
27 cc->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
30 pen = g_pRouteMan->GetRoutePointPen();
35 wxRect r1(r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2);
44 wxColour hi_colour = pen->GetColour();
45 unsigned char transparency = 100;
48 AlphaBlending(dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width,
49 hilitebox.height, radius, hi_colour, transparency);
52void TrackGui::Finalize() {
53 if (m_track.SubTracks.size())
58 int n = m_track.TrackPoints.size() - 1;
61 std::vector<SubTrack> new_level;
64 for (
int i = 0; i < n; i++) {
65 new_level[i].m_box.SetFromSegment(
66 m_track.TrackPoints[i]->m_lat, m_track.TrackPoints[i]->m_lon,
67 m_track.TrackPoints[i + 1]->m_lat,
68 m_track.TrackPoints[i + 1]->m_lon);
69 new_level[i].m_scale = 0;
72 for (
int i = 0; i < n; i++) {
74 new_level[i].m_box = m_track.SubTracks[level - 1][p].m_box;
75 if (p + 1 < (
int)m_track.SubTracks[level - 1].size())
76 new_level[i].m_box.Expand(m_track.SubTracks[level - 1][p + 1].m_box);
78 int left = i << level;
79 int right = wxMin(left + (1 << level), m_track.TrackPoints.size() - 1);
80 new_level[i].m_scale = m_track.ComputeScale(left, right);
83 m_track.SubTracks.push_back(new_level);
85 if (n > 1 && n & 1) n++;
95 std::list<std::list<wxPoint> > &pointlists,
98 if (!m_track.IsVisible() || m_track.GetnPoints() == 0)
return;
101 Segments(cc, pointlists, box, VP.view_scale_ppm);
103 if(GetnPoints() > 40000) {
104 double t = sw.GetTime();
106 for(std::list< std::list<wxPoint> >::iterator lines = pointlists.begin();
107 lines != pointlists.end(); lines++) {
108 if(lines->size() > 1)
112 printf(
"assemble time %f %f segments %f seg/ms\n", sw.GetTime(), c, c/t);
118 if (m_track.IsRunning()) {
119 std::list<wxPoint> new_list;
120 pointlists.push_back(new_list);
121 AddPointToList(cc, pointlists, m_track.TrackPoints.size() - 1);
123 cc->GetCanvasPointPix(gLat, gLon, &r);
124 pointlists.back().push_back(r);
130 std::list<std::list<wxPoint> > pointlists;
131 GetPointLists(cc, pointlists, VP, box);
133 if (!pointlists.size())
return;
136 wxColour basic_colour;
137 if (m_track.IsRunning())
138 basic_colour = GetGlobalColor(_T (
"URED" ));
140 basic_colour = GetDimColor(g_colourTrackLineColour);
142 wxPenStyle style = wxPENSTYLE_SOLID;
143 int width = g_pRouteMan->GetTrackPen()->GetWidth();
145 if (m_track.m_style != wxPENSTYLE_INVALID) style = m_track.m_style;
146 if (m_track.m_width != WIDTH_UNDEFINED) width = m_track.m_width;
147 if (m_track.m_Colour == wxEmptyString) {
150 for (
unsigned int i = 0; i <
sizeof(::GpxxColorNames) /
sizeof(wxString);
152 if (m_track.m_Colour == ::GpxxColorNames[i]) {
153 col = ::GpxxColors[i];
160 if (g_bHighliteTracks) {
161 double radius_meters = 20;
162 radius = radius_meters * VP.view_scale_ppm;
163 if (radius < 1.0) radius = 0;
167 dc.SetPen(*wxThePenList->FindOrCreatePen(col, width, style));
168 dc.SetBrush(*wxTheBrushList->FindOrCreateBrush(col, wxBRUSHSTYLE_SOLID));
169 for (std::list<std::list<wxPoint> >::iterator lines = pointlists.begin();
170 lines != pointlists.end(); lines++) {
172 wxPoint *points =
new wxPoint[lines->size()];
174 for (std::list<wxPoint>::iterator line = lines->begin();
175 line != lines->end(); line++) {
180 int hilite_width = radius;
181 if (hilite_width >= 1.0) {
182 wxPen psave = dc.GetPen();
184 dc.StrokeLines(i, points);
186 wxColor trackLine_dim_colour = GetDimColor(g_colourTrackLineColour);
187 wxColour hilt(trackLine_dim_colour.Red(), trackLine_dim_colour.Green(),
188 trackLine_dim_colour.Blue(), 128);
190 wxPen HiPen(hilt, hilite_width, wxPENSTYLE_SOLID);
193 dc.StrokeLines(i, points);
197 dc.StrokeLines(i, points);
203 if (m_track.m_HighlightedTrackPoint >= 0)
204 TrackPointGui(m_track.TrackPoints[m_track.m_HighlightedTrackPoint]).Draw(cc, dc);
209 std::list<std::list<wxPoint> > &pointlists,
210 const LLBBox &box,
double scale) {
211 if (!m_track.SubTracks.size())
return;
213 int level = m_track.SubTracks.size() - 1, last = -2;
214 Assemble(cc, pointlists, box, 1 /
scale /
scale, last, level, 0);
220 std::list<std::list<wxPoint> > &pointlists,
221 const LLBBox &box,
double scale,
int &last,
int level,
223 if (pos == (
int)m_track.SubTracks[level].size())
return;
225 SubTrack &s = m_track.SubTracks[level][pos];
226 if (box.IntersectOut(s.m_box))
return;
228 if (s.m_scale <
scale) {
231 if (last < pos - 1) {
232 std::list<wxPoint> new_list;
233 pointlists.push_back(new_list);
236 if (last < pos) AddPointToList(cc, pointlists, pos);
237 last = wxMin(pos + (1 << level), m_track.TrackPoints.size() - 1);
238 AddPointToList(cc, pointlists, last);
240 Assemble(cc, pointlists, box,
scale, last, level - 1, pos << 1);
241 Assemble(cc, pointlists, box,
scale, last, level - 1, (pos << 1) + 1);
246 std::list<std::list<wxPoint> > &pointlists,
int n) {
247 wxPoint r(INVALID_COORD, INVALID_COORD);
248 if ((
size_t)n < m_track.TrackPoints.size())
249 cc->GetCanvasPointPix(m_track.TrackPoints[n]->m_lat, m_track.TrackPoints[n]->m_lon, &r);
251 std::list<wxPoint> &pointlist = pointlists.back();
252 if (r.x == INVALID_COORD) {
253 if (pointlist.size()) {
254 std::list<wxPoint> new_list;
255 pointlists.push_back(new_list);
260 if (pointlist.size() == 0)
261 pointlist.push_back(r);
263 wxPoint l = pointlist.back();
265 if ((abs(r.x - l.x) > 1) || (abs(r.y - l.y) > 1)) pointlist.push_back(r);