1 #if defined(__ANDROID__)
3 #include <GL/gl_private.h>
6 #elif defined(ocpnUSE_GL)
12 #elif defined(__WXOSX__)
13 #include <OpenGL/gl.h>
14 #include <OpenGL/glu.h>
15 typedef void (* _GLUfuncptr)();
16 #define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
18 #elif defined(__WXQT__) || defined(__WXGTK__)
25 #include <wx/colour.h>
26 #include <wx/gdicmn.h>
30 #include "model/comm_n0183_output.h"
31 #include "model/georef.h"
32 #include "model/multiplexer.h"
33 #include "model/own_ship.h"
34 #include "model/route.h"
35 #include "model/routeman.h"
37 #include "color_handler.h"
39 #include "glChartCanvas.h"
40 #include "n0183_ctx_factory.h"
42 #include "ocpn_frame.h"
43 #include "OCPNPlatform.h"
45 #include "route_point_gui.h"
47 #include "svg_utils.h"
49 #include "waypointman_gui.h"
54 extern float g_MarkScaleFactorExp;
66 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
69 if (NULL != rpn) *rpn = r;
71 if (!
RoutePointGui(m_point).IsVisibleSelectable(canvas, boverride_viz))
return;
74 if( (abs(r.x) > canvas->GetCanvasWidth() * 4 ) ||
75 (abs(r.y) > canvas->GetCanvasHeight() * 4))
79 if ((abs(r.x) == INVALID_COORD ) ||
80 (abs(r.y) == INVALID_COORD) )
86 if (m_point.m_IconName == _T(
"empty") && !m_point.m_bShowName
87 && !m_point.m_bPtIsSelected){
93 pen = g_pRouteMan->GetActiveRoutePointPen();
95 pen = g_pRouteMan->GetRoutePointPen();
98 if (m_point.m_IconIsDirty) ReLoadIcon();
100 if ((m_point.m_bIsActive) && (m_point.m_IconName != _T(
"mob")))
101 pbm = pWayPointMan->GetIconBitmap(_T (
"activepoint" ));
103 pbm = m_point.m_pbmIcon;
105 wxBitmap *pbms = NULL;
106 if ((g_MarkScaleFactorExp > 1.0) && !m_point.m_bPreScaled) {
107 if (m_point.m_IconScaleFactor != g_MarkScaleFactorExp) {
108 wxImage scaled_image = pbm->ConvertToImage();
109 int new_width = pbm->GetWidth() * g_MarkScaleFactorExp;
110 int new_height = pbm->GetHeight() * g_MarkScaleFactorExp;
111 m_point.m_ScaledBMP = wxBitmap(
112 scaled_image.Scale(new_width, new_height, wxIMAGE_QUALITY_HIGH));
114 m_point.m_IconScaleFactor = g_MarkScaleFactorExp;
116 if (m_point.m_ScaledBMP.IsOk()) pbm = &m_point.m_ScaledBMP;
119 int sx2 = pbm->GetWidth() / 2;
120 int sy2 = pbm->GetHeight() / 2;
123 wxRect r1(r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2);
125 if (m_point.m_bShowName) {
126 if (0 == m_point.m_pMarkFont) {
127 wxFont *dFont = FontMgr::Get().GetFont(_(
"Marks"));
128 int font_size = wxMax(8, dFont->GetPointSize());
129 font_size /= OCPN_GetWinDIPScaleFactor();
131 m_point.m_pMarkFont = FontMgr::Get().FindOrCreateFont(
132 font_size, dFont->GetFamily(), dFont->GetStyle(), dFont->GetWeight(),
133 false, dFont->GetFaceName());
135 m_point.m_FontColor = FontMgr::Get().GetFontColor(_(
"Marks"));
136 m_point.CalculateNameExtents();
139 if (m_point.m_pMarkFont) {
140 wxRect r2(r.x + m_point.m_NameLocationOffsetX, r.y + m_point.m_NameLocationOffsetY,
141 m_point.m_NameExtents.x, m_point.m_NameExtents.y);
151 hilitebox.Inflate(20);
154 hilitebox.Inflate(4);
158 wxColour hi_colour = pen->GetColour();
159 unsigned char transparency = 100;
160 if (m_point.m_bRPIsBeingEdited) {
161 hi_colour = GetGlobalColor(_T (
"YELO1" ));
166 if (m_point.m_bPtIsSelected || m_point.m_bRPIsBeingEdited) {
167 AlphaBlending(dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width,
168 hilitebox.height, radius, hi_colour, transparency);
171 bool bDrawHL =
false;
173 if (m_point.m_bBlink && (gFrame->nBlinkerTick & 1)) bDrawHL =
true;
175 if ((!bDrawHL) && (NULL != m_point.m_pbmIcon)) {
176 dc.DrawBitmap(*pbm, r.x - sx2, r.y - sy2,
true);
179 dc.CalcBoundingBox(r.x - sx2, r.y - sy2);
180 dc.CalcBoundingBox(r.x + sx2, r.y + sy2);
183 if (m_point.m_bShowName && m_point.m_MarkName.Length()) {
184 if (m_point.m_pMarkFont) {
185 dc.SetFont(*m_point.m_pMarkFont);
186 dc.SetTextForeground(m_point.m_FontColor);
188 dc.DrawText(m_point.m_MarkName, r.x + m_point.m_NameLocationOffsetX,
189 r.y + m_point.m_NameLocationOffsetY);
194 if (m_point.m_iWaypointRangeRingsNumber && m_point.m_bShowWaypointRangeRings) {
195 double factor = 1.00;
196 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
199 factor *= m_point.m_fWaypointRangeRingsStep;
203 ll_gc_ll(m_point.m_lat, m_point.m_lon, 0, factor, &tlat, &tlon);
204 canvas->GetCanvasPointPix(tlat, tlon, &r1);
207 sqrt(pow((
double)(r.x - r1.x), 2) + pow((
double)(r.y - r1.y), 2));
208 int pix_radius = (int)lpp;
210 wxPen ppPen1(m_point.m_wxcWaypointRangeRingsColour, 2);
211 wxBrush saveBrush = dc.GetBrush();
212 wxPen savePen = dc.GetPen();
215 wxBrush(m_point.m_wxcWaypointRangeRingsColour, wxBRUSHSTYLE_TRANSPARENT));
217 for (
int i = 1; i <= m_point.m_iWaypointRangeRingsNumber; i++)
218 dc.StrokeCircle(r.x, r.y, i * pix_radius);
220 dc.SetBrush(saveBrush);
225 m_point.CurrentRect_in_DC.x = r.x + hilitebox.x;
226 m_point.CurrentRect_in_DC.y = r.y + hilitebox.y;
227 m_point.CurrentRect_in_DC.width = hilitebox.width;
228 m_point.CurrentRect_in_DC.height = hilitebox.height;
230 if (m_point.m_bBlink)
231 g_blink_rect = m_point.CurrentRect_in_DC;
238 bool use_cached_screen_coords,
bool bVizOverride) {
239 if (!
RoutePointGui(m_point).IsVisibleSelectable(canvas, bVizOverride))
return;
242 if (m_point.m_IconName == _T(
"empty") && !m_point.m_bShowName && !m_point.m_bPtIsSelected)
return;
244 if (m_point.m_wpBBox.GetValid() && vp.view_scale_ppm == m_point.m_wpBBox_view_scale_ppm &&
245 vp.rotation == m_point.m_wpBBox_rotation) {
247 LLBBox vpBBox = vp.GetBBox();
248 if (vpBBox.IntersectOut(m_point.m_wpBBox)) {
250 if (m_point.m_bShowWaypointRangeRings && (m_point.m_iWaypointRangeRingsNumber > 0)) {
251 double factor = 1.00;
252 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
255 double radius = factor * m_point.m_iWaypointRangeRingsNumber *
256 m_point.m_fWaypointRangeRingsStep / 60.;
258 LLBBox radar_box = m_point.m_wpBBox;
259 radar_box.EnLarge(radius * 2);
260 if (vpBBox.IntersectOut(radar_box)) {
270 unsigned char transparency = 150;
272 if (use_cached_screen_coords && m_point.m_pos_on_screen)
273 r.x = m_point.m_screen_pos.m_x, r.y = m_point.m_screen_pos.m_y;
275 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
277 if (r.x == INVALID_COORD)
return;
280 if (m_point.m_IconIsDirty) ReLoadIcon();
282 if ((m_point.m_bIsActive) && (m_point.m_IconName != _T(
"mob")))
283 pbm = pWayPointMan->GetIconBitmap(_T (
"activepoint" ));
285 pbm = m_point.m_pbmIcon;
288 if (!pbm || !pbm->IsOk())
return;
290 int sx2 = pbm->GetWidth() / 2;
291 int sy2 = pbm->GetHeight() / 2;
294 wxRect r1(r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2);
297 if (m_point.m_bShowName) {
298 if (!m_point.m_pMarkFont) {
299 wxFont *dFont = FontMgr::Get().GetFont(_(
"Marks"));
300 int font_size = wxMax(8, dFont->GetPointSize());
301 font_size /= OCPN_GetWinDIPScaleFactor();
303 m_point.m_pMarkFont = FontMgr::Get().FindOrCreateFont(
304 font_size, dFont->GetFamily(), dFont->GetStyle(), dFont->GetWeight(),
305 false, dFont->GetFaceName());
307 m_point.m_FontColor = FontMgr::Get().GetFontColor(_(
"Marks"));
308 if (m_point.m_iTextTexture) {
309 glDeleteTextures(1, &m_point.m_iTextTexture);
310 m_point.m_iTextTexture = 0;
313 m_point.CalculateNameExtents();
316 if (m_point.m_pMarkFont) {
317 wxRect r2(r.x + m_point.m_NameLocationOffsetX, r.y + m_point.m_NameLocationOffsetY,
318 m_point.m_NameExtents.x, m_point.m_NameExtents.y);
327 if (!m_point.m_bPreScaled) {
328 hilitebox.x *= g_MarkScaleFactorExp;
329 hilitebox.y *= g_MarkScaleFactorExp;
330 hilitebox.width *= g_MarkScaleFactorExp;
331 hilitebox.height *= g_MarkScaleFactorExp;
336 hilitebox.Inflate(20);
339 hilitebox.Inflate(4);
344 if (!m_point.m_wpBBox.GetValid() || vp.view_scale_ppm != m_point.m_wpBBox_view_scale_ppm ||
345 vp.rotation != m_point.m_wpBBox_rotation) {
346 double lat1, lon1, lat2, lon2;
347 canvas->GetCanvasPixPoint(r.x + hilitebox.x,
348 r.y + hilitebox.y + hilitebox.height, lat1, lon1);
349 canvas->GetCanvasPixPoint(r.x + hilitebox.x + hilitebox.width,
350 r.y + hilitebox.y, lat2, lon2);
353 m_point.m_wpBBox.Set(lat1, lon1, lat2, lon2 + 360);
355 m_point.m_wpBBox.Set(lat1, lon1, lat2, lon2);
357 m_point.m_wpBBox_view_scale_ppm = vp.view_scale_ppm;
358 m_point.m_wpBBox_rotation = vp.rotation;
367 if (m_point.m_bPtIsSelected) {
369 if (m_point.m_bBlink) {
370 wxPen *pen = g_pRouteMan->GetActiveRoutePointPen();
371 hi_colour = pen->GetColour();
373 hi_colour = GetGlobalColor(_T (
"YELO1" ));
376 AlphaBlending(dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width,
377 hilitebox.height, radius, hi_colour, transparency);
380 bool bDrawHL =
false;
382 if (m_point.m_bBlink && (gFrame->nBlinkerTick & 1)) bDrawHL =
true;
384 if ((!bDrawHL) && (NULL != m_point.m_pbmIcon)) {
386 unsigned int IconTexture =
389 glBindTexture(GL_TEXTURE_2D, IconTexture);
391 glEnable(GL_TEXTURE_2D);
394 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
395 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
397 int w = r1.width, h = r1.height;
400 if (!m_point.m_bPreScaled) {
401 scale = g_MarkScaleFactorExp;
405 scale *= GetOCPNCanvasWindow()->GetContentScaleFactor();
407 float ws = r1.width *
scale;
408 float hs = r1.height *
scale;
409 float xs = r.x - ws / 2.;
410 float ys = r.y - hs / 2.;
411 float u = (float)w / glw, v = (
float)h / glh;
432 coords[6] = xs, coords[7] = ys + hs;
434 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
437 glDisable(GL_TEXTURE_2D);
440 if (m_point.m_bShowName && m_point.m_pMarkFont) {
441 int w = m_point.m_NameExtents.x, h = m_point.m_NameExtents.y;
442 if (!m_point.m_iTextTexture && w && h) {
446 dc.SelectObject(tbm);
447 dc.SetBackground(wxBrush(*wxBLACK));
449 dc.SetFont(*m_pMarkFont);
450 dc.SetTextForeground(*wxWHITE);
451 dc.DrawText(m_MarkName, 0, 0);
452 dc.SelectObject(wxNullBitmap);
455 wxImage image = tbm.ConvertToImage();
456 unsigned char *d = image.GetData();
457 unsigned char *e =
new unsigned char[w * h];
459 for (
int p = 0; p < w * h; p++) e[p] = d[3 * p + 0];
463 glGenTextures(1, &m_iTextTexture);
464 glBindTexture(GL_TEXTURE_2D, m_iTextTexture);
466 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
467 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
469 m_iTextTextureWidth = NextPow2(w);
470 m_iTextTextureHeight = NextPow2(h);
471 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_iTextTextureWidth,
472 m_iTextTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
473 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA, GL_UNSIGNED_BYTE,
478 sdc.SetFont(*m_point.m_pMarkFont);
483 temp_dc.SelectObject(bmp);
486 temp_dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
490 temp_dc.SetFont(*m_point.m_pMarkFont);
491 temp_dc.SetTextForeground(wxColour(255, 255, 255));
492 temp_dc.DrawText(m_point.m_MarkName, 0, 0);
493 temp_dc.SelectObject(wxNullBitmap);
497 wxImage image = bmp.ConvertToImage();
499 unsigned char *data =
new unsigned char[w * h * 4];
500 unsigned char *im = image.GetData();
503 unsigned int r = m_point.m_FontColor.Red();
504 unsigned int g = m_point.m_FontColor.Green();
505 unsigned int b = m_point.m_FontColor.Blue();
506 for (
int i = 0; i < h; i++) {
507 for (
int j = 0; j < w; j++) {
508 unsigned int index = ((i * w) + j) * 4;
512 data[index + 3] = im[((i * w) + j) * 3];
517 glGenTextures(1, &m_point.m_iTextTexture);
519 glBindTexture(GL_TEXTURE_2D, m_point.m_iTextTexture);
521 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
522 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
524 m_point.m_iTextTextureWidth = NextPow2(w);
525 m_point.m_iTextTextureHeight = NextPow2(h);
526 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_point.m_iTextTextureWidth,
527 m_point.m_iTextTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
528 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE,
533 glEnable(GL_TEXTURE_2D);
535 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
540 if (m_point.m_iTextTexture) {
542 glBindTexture(GL_TEXTURE_2D, m_point.m_iTextTexture);
544 glEnable(GL_TEXTURE_2D);
547 int x = r.x + m_point.m_NameLocationOffsetX, y = r.y + m_point.m_NameLocationOffsetY;
548 float u = (float)w / m_point.m_iTextTextureWidth,
549 v = (
float)h / m_point.m_iTextTextureHeight;
569 coords[6] = x, coords[7] = y + h;
571 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
574 glDisable(GL_TEXTURE_2D);
579 if (m_point.m_iWaypointRangeRingsNumber && m_point.m_bShowWaypointRangeRings) {
580 double factor = 1.00;
581 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
584 factor *= m_point.m_fWaypointRangeRingsStep;
588 ll_gc_ll(m_point.m_lat, m_point.m_lon, 0, factor, &tlat, &tlon);
589 canvas->GetCanvasPointPix(tlat, tlon, &r1);
592 sqrt(pow((
double)(r.x - r1.x), 2) + pow((
double)(r.y - r1.y), 2));
593 int pix_radius = (int)lpp;
595 extern wxColor GetDimColor(wxColor c);
596 wxColor ring_dim_color = GetDimColor(m_point.m_wxcWaypointRangeRingsColour);
599 double platform_pen_width = wxRound(
600 wxMax(1.0, g_Platform->GetDisplayDPmm() / 2));
601 wxPen ppPen1(ring_dim_color, platform_pen_width);
602 wxBrush saveBrush = dc.GetBrush();
603 wxPen savePen = dc.GetPen();
605 dc.SetBrush(wxBrush(ring_dim_color, wxBRUSHSTYLE_TRANSPARENT));
607 for (
int i = 1; i <= m_point.m_iWaypointRangeRingsNumber; i++)
608 dc.StrokeCircle(r.x, r.y, i * pix_radius);
610 dc.SetBrush(saveBrush);
614 if (m_point.m_bDrawDragHandle) {
616 double platform_pen_width = wxRound(
617 wxMax(1.0, g_Platform->GetDisplayDPmm() /
620 wxColor dh_color = GetGlobalColor(_T (
"YELO1" ));
621 wxPen ppPen1(dh_color, 3 * platform_pen_width);
623 dc.DrawLine(r.x + hilitebox.width / 4, r.y + hilitebox.height / 4,
624 r.x + m_point.m_drag_line_length_man, r.y + m_point.m_drag_line_length_man);
626 dh_color = wxColor(0, 0, 0);
627 wxPen ppPen2(dh_color, platform_pen_width);
629 dc.DrawLine(r.x + hilitebox.width / 4, r.y + hilitebox.height / 4,
630 r.x + m_point.m_drag_line_length_man, r.y + m_point.m_drag_line_length_man);
633 glBindTexture(GL_TEXTURE_2D, m_point.m_dragIconTexture);
635 glEnable(GL_TEXTURE_2D);
638 int x = r.x + m_point.m_drag_icon_offset, y = r.y + m_point.m_drag_icon_offset,
639 w = m_point.m_dragIcon.GetWidth(), h = m_point.m_dragIcon.GetHeight();
643 float ws = w *
scale;
644 float hs = h *
scale;
645 float xs = x - ws / 2.;
646 float ys = y - hs / 2.;
647 float u = (float)w / m_point.m_dragIconTextureWidth,
648 v = (
float)h / m_point.m_dragIconTextureWidth;
669 coords[6] = xs, coords[7] = ys + hs;
671 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
674 glDisable(GL_TEXTURE_2D);
677 if (m_point.m_bBlink)
678 g_blink_rect =m_point. CurrentRect_in_DC;
681 m_point.CurrentRect_in_DC.x = r.x + hilitebox.x;
682 m_point.CurrentRect_in_DC.y = r.y + hilitebox.y;
683 m_point.CurrentRect_in_DC.width = hilitebox.width;
684 m_point.CurrentRect_in_DC.height = hilitebox.height;
686 if (m_point.m_bBlink)
687 g_blink_rect = m_point.CurrentRect_in_DC;
691 void RoutePointGui::CalculateDCRect(wxDC &dc,
ChartCanvas *canvas, wxRect *prect) {
693 dc.ResetBoundingBox();
694 dc.DestroyClippingRegion();
698 odc.SetVP(canvas->GetVP());
700 Draw(odc, canvas, NULL);
703 prect->x = dc.MinX() - 1;
704 prect->y = dc.MinY() - 1;
705 prect->width = dc.MaxX() - dc.MinX() + 2;
706 prect->height = dc.MaxY() - dc.MinY() + 2;
710 bool RoutePointGui::IsVisibleSelectable(
ChartCanvas* cc,
bool boverrideViz) {
711 return m_point.IsVisibleSelectable(cc->GetScaleValue(), boverrideViz);
714 wxPoint2DDouble RoutePointGui::GetDragHandlePoint(
ChartCanvas *canvas) {
715 if (!m_point.m_bDrawDragHandle)
716 return wxPoint2DDouble(m_point.m_lon, m_point.m_lat);
718 return computeDragHandlePoint(canvas);
721 void RoutePointGui::SetPointFromDraghandlePoint(
ChartCanvas *canvas,
double lat,
724 canvas->GetCanvasPointPix(lat, lon, &r);
726 canvas->GetCanvasPixPoint(r.x - m_point.m_drag_icon_offset, r.y - m_point.m_drag_icon_offset,
728 m_point.m_lat = tlat;
729 m_point.m_lon = tlon;
732 void RoutePointGui::SetPointFromDraghandlePoint(
ChartCanvas *canvas,
int x,
735 canvas->GetCanvasPixPoint(x - m_point.m_drag_icon_offset - m_point.m_draggingOffsetx,
736 y - m_point.m_drag_icon_offset - m_point.m_draggingOffsety, tlat,
738 m_point.m_lat = tlat;
739 m_point.m_lon = tlon;
742 void RoutePointGui::PresetDragOffset(
ChartCanvas *canvas,
int x,
int y) {
744 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
746 m_point.m_draggingOffsetx = x - (r.x + m_point.m_drag_icon_offset);
747 m_point.m_draggingOffsety = y - (r.y + m_point.m_drag_icon_offset);
750 wxPoint2DDouble RoutePointGui::computeDragHandlePoint(
ChartCanvas *canvas) {
752 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
754 canvas->GetCanvasPixPoint(r.x + m_point.m_drag_icon_offset, r.y + m_point.m_drag_icon_offset,
758 m_point.m_dragHandleLat = lat;
759 m_point.m_dragHandleLon = lon;
761 return wxPoint2DDouble(lon, lat);
764 void RoutePointGui::ShowScaleWarningMessage(
ChartCanvas *canvas) {
765 wxString strA = _(
"The ScaMin value for new waypoints is set to");
766 wxString strB = _(
"but current chartscale is");
768 _(
"Therefore the new waypoint will not be visible at this zoom level.");
770 wxString::Format(_T(
"%s %li,\n %s %.0f.\n%s"), strA, m_point.GetScaMin(), strB,
771 canvas->GetScaleValue(), strC);
772 OCPNMessageBox(canvas, MessStr);
775 void RoutePointGui::EnableDragHandle(
bool bEnable) {
776 m_point.m_bDrawDragHandle = bEnable;
778 if (!m_point.m_dragIcon.IsOk()) {
781 int bm_size = g_Platform->GetDisplayDPmm() * 9;
784 wxString UserIconPath = g_Platform->GetSharedDataDir()
785 + _T(
"uidata") + wxFileName::GetPathSeparator();
787 m_point.m_dragIcon = LoadSVG(UserIconPath + _T(
"DragHandle.svg"), bm_size,
788 bm_size, m_point.m_pbmIcon);
793 if (m_point.m_dragIconTexture == 0) {
794 glGenTextures(1, &m_point.m_dragIconTexture);
795 glBindTexture(GL_TEXTURE_2D, m_point.m_dragIconTexture);
797 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
798 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
799 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
801 wxImage image = m_point.m_dragIcon.ConvertToImage();
802 int w = image.GetWidth(), h = image.GetHeight();
804 m_point.m_dragIconTextureWidth = NextPow2(w);
805 m_point.m_dragIconTextureHeight = NextPow2(h);
807 unsigned char *d = image.GetData();
808 unsigned char *a = image.GetAlpha();
810 unsigned char mr, mg, mb;
811 image.GetOrFindMaskColour(&mr, &mg, &mb);
813 unsigned char *e =
new unsigned char[4 * w * h];
815 for (
int y = 0; y < h; y++)
816 for (
int x = 0; x < w; x++) {
817 unsigned char r, g, b;
818 int off = (y * image.GetWidth() + x);
827 a ? a[off] : ((r == mr) && (g == mg) && (b == mb) ? 0 : 255);
831 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_point.m_dragIconTextureWidth,
832 m_point.m_dragIconTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
834 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE,
842 if (m_point.m_dragIcon.IsOk()) {
843 m_point.m_drag_line_length_man = bm_size;
844 m_point.m_drag_icon_offset = bm_size;
846 m_point.m_drag_line_length_man = 64;
847 m_point.m_drag_icon_offset = 64;
853 void RoutePointGui::ReLoadIcon(
void) {
854 if (!pWayPointMan)
return;
855 bool icon_exists = pWayPointMan->DoesIconExist(m_point.m_IconName);
857 wxString iconUse = m_point.m_IconName;
861 wxString tentative_icon = m_point.m_IconName.Lower();
862 if (pWayPointMan->DoesIconExist(tentative_icon)) {
864 m_point.m_IconName = tentative_icon;
865 iconUse = m_point.m_IconName;
870 if (!pWayPointMan->DoesIconExist(_T(
"tempsub"))) {
873 wxBitmap bmp = style->GetIcon(_T(
"circle"));
875 wxImage image = bmp.ConvertToImage();
876 WayPointmanGui(*pWayPointMan).ProcessIcon(image,
"tempsub",
"tempsub");
880 iconUse = _T(
"tempsub");
884 m_point.m_pbmIcon = pWayPointMan->GetIconBitmap(iconUse);
885 m_point.m_bPreScaled = pWayPointMan->GetIconPrescaled(iconUse);
888 m_point.m_wpBBox_view_scale_ppm = -1;
890 m_point.m_iTextTexture = 0;
893 m_point.m_IconScaleFactor = -1;
894 m_point.m_pMarkFont = 0;
895 m_point.m_IconIsDirty =
false;
898 bool RoutePointGui::SendToGPS(
const wxString &com_name,
SendToGpsDlg *dialog) {
901 ::wxBeginBusyCursor();
902 int result = SendWaypointToGPS_N0183(&m_point, com_name, *g_pMUX, dlg_ctx);
907 msg = _(
"Waypoint(s) Transmitted.");
909 if (result == ERR_GARMIN_INITIALIZE)
910 msg = _(
"Error on Waypoint Upload. Garmin GPS not connected");
912 msg = _(
"Error on Waypoint Upload. Please check logfiles...");
915 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxOK | wxICON_INFORMATION);
917 return (result == 0);
920 int RoutePointGui::GetIconImageIndex() {
921 if (m_point.IsShared()) {
923 wxArrayPtrVoid *proute_array = g_pRouteMan->GetRouteArrayContaining(&m_point);
926 bool brp_viz =
false;
928 for (
unsigned int ir = 0; ir < proute_array->GetCount(); ir++) {
930 if (pr->IsVisible()) {
938 return (pWayPointMan->GetFIconImageListIndex(GetIconBitmap()));
940 if (m_point.IsVisible())
941 return (pWayPointMan->GetIconImageListIndex(GetIconBitmap()));
943 return (pWayPointMan->GetXIconImageListIndex(GetIconBitmap()));
948 if (m_point.IsVisible())
949 return (pWayPointMan->GetIconImageListIndex(GetIconBitmap()));
951 return (pWayPointMan->GetXIconImageListIndex(GetIconBitmap()));
Route "Send to GPS..." Dialog Definition.