7#include "color_handler.h"
8#include "comm_n0183_output.h"
12#include "route_point_gui.h"
13#include "ocpn_frame.h"
15#include "glChartCanvas.h"
17#include "OCPNPlatform.h"
20#include "waypointman_gui.h"
23#include "ocpn_plugin.h"
26extern float g_MarkScaleFactorExp;
30extern wxRect g_blink_rect;
41 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
44 if (NULL != rpn) *rpn = r;
46 if (!
RoutePointGui(m_point).IsVisibleSelectable(canvas, boverride_viz))
return;
49 if( (abs(r.x) > canvas->GetCanvasWidth() * 4 ) ||
50 (abs(r.y) > canvas->GetCanvasHeight() * 4))
54 if ((abs(r.x) == INVALID_COORD ) ||
55 (abs(r.y) == INVALID_COORD) )
61 if (m_point.m_IconName == _T(
"empty") && !m_point.m_bShowName
62 && !m_point.m_bPtIsSelected){
68 pen = g_pRouteMan->GetActiveRoutePointPen();
70 pen = g_pRouteMan->GetRoutePointPen();
73 if (m_point.m_IconIsDirty) ReLoadIcon();
75 if ((m_point.m_bIsActive) && (m_point.m_IconName != _T(
"mob")))
76 pbm = pWayPointMan->GetIconBitmap(_T (
"activepoint" ));
78 pbm = m_point.m_pbmIcon;
80 wxBitmap *pbms = NULL;
81 if ((g_MarkScaleFactorExp > 1.0) && !m_point.m_bPreScaled) {
82 if (m_point.m_IconScaleFactor != g_MarkScaleFactorExp) {
83 wxImage scaled_image = pbm->ConvertToImage();
84 int new_width = pbm->GetWidth() * g_MarkScaleFactorExp;
85 int new_height = pbm->GetHeight() * g_MarkScaleFactorExp;
86 m_point.m_ScaledBMP = wxBitmap(
87 scaled_image.Scale(new_width, new_height, wxIMAGE_QUALITY_HIGH));
89 m_point.m_IconScaleFactor = g_MarkScaleFactorExp;
91 if (m_point.m_ScaledBMP.IsOk()) pbm = &m_point.m_ScaledBMP;
94 int sx2 = pbm->GetWidth() / 2;
95 int sy2 = pbm->GetHeight() / 2;
98 wxRect r1(r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2);
100 if (m_point.m_bShowName) {
101 if (0 == m_point.m_pMarkFont) {
102 wxFont *dFont = FontMgr::Get().GetFont(_(
"Marks"));
103 int font_size = wxMax(8, dFont->GetPointSize());
104 font_size /= OCPN_GetWinDIPScaleFactor();
106 m_point.m_pMarkFont = FontMgr::Get().FindOrCreateFont(
107 font_size, dFont->GetFamily(), dFont->GetStyle(), dFont->GetWeight(),
108 false, dFont->GetFaceName());
110 m_point.m_FontColor = FontMgr::Get().GetFontColor(_(
"Marks"));
111 m_point.CalculateNameExtents();
114 if (m_point.m_pMarkFont) {
115 wxRect r2(r.x + m_point.m_NameLocationOffsetX, r.y + m_point.m_NameLocationOffsetY,
116 m_point.m_NameExtents.x, m_point.m_NameExtents.y);
126 hilitebox.Inflate(20);
129 hilitebox.Inflate(4);
133 wxColour hi_colour = pen->GetColour();
134 unsigned char transparency = 100;
135 if (m_point.m_bRPIsBeingEdited) {
136 hi_colour = GetGlobalColor(_T (
"YELO1" ));
141 if (m_point.m_bPtIsSelected || m_point.m_bRPIsBeingEdited) {
142 AlphaBlending(dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width,
143 hilitebox.height, radius, hi_colour, transparency);
146 bool bDrawHL =
false;
148 if (m_point.m_bBlink && (gFrame->nBlinkerTick & 1)) bDrawHL =
true;
150 if ((!bDrawHL) && (NULL != m_point.m_pbmIcon)) {
151 dc.DrawBitmap(*pbm, r.x - sx2, r.y - sy2,
true);
154 dc.CalcBoundingBox(r.x - sx2, r.y - sy2);
155 dc.CalcBoundingBox(r.x + sx2, r.y + sy2);
158 if (m_point.m_bShowName && m_point.m_MarkName.Length()) {
159 if (m_point.m_pMarkFont) {
160 dc.SetFont(*m_point.m_pMarkFont);
161 dc.SetTextForeground(m_point.m_FontColor);
163 dc.DrawText(m_point.m_MarkName, r.x + m_point.m_NameLocationOffsetX,
164 r.y + m_point.m_NameLocationOffsetY);
169 if (m_point.m_iWaypointRangeRingsNumber && m_point.m_bShowWaypointRangeRings) {
170 double factor = 1.00;
171 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
174 factor *= m_point.m_fWaypointRangeRingsStep;
178 ll_gc_ll(m_point.m_lat, m_point.m_lon, 0, factor, &tlat, &tlon);
179 canvas->GetCanvasPointPix(tlat, tlon, &r1);
182 sqrt(pow((
double)(r.x - r1.x), 2) + pow((
double)(r.y - r1.y), 2));
183 int pix_radius = (int)lpp;
185 wxPen ppPen1(m_point.m_wxcWaypointRangeRingsColour, 2);
186 wxBrush saveBrush = dc.GetBrush();
187 wxPen savePen = dc.GetPen();
190 wxBrush(m_point.m_wxcWaypointRangeRingsColour, wxBRUSHSTYLE_TRANSPARENT));
192 for (
int i = 1; i <= m_point.m_iWaypointRangeRingsNumber; i++)
193 dc.StrokeCircle(r.x, r.y, i * pix_radius);
195 dc.SetBrush(saveBrush);
200 m_point.CurrentRect_in_DC.x = r.x + hilitebox.x;
201 m_point.CurrentRect_in_DC.y = r.y + hilitebox.y;
202 m_point.CurrentRect_in_DC.width = hilitebox.width;
203 m_point.CurrentRect_in_DC.height = hilitebox.height;
205 if (m_point.m_bBlink)
206 g_blink_rect = m_point.CurrentRect_in_DC;
213 bool use_cached_screen_coords,
bool bVizOverride) {
214 if (!
RoutePointGui(m_point).IsVisibleSelectable(canvas, bVizOverride))
return;
217 if (m_point.m_IconName == _T(
"empty") && !m_point.m_bShowName && !m_point.m_bPtIsSelected)
return;
219 if (m_point.m_wpBBox.GetValid() && vp.view_scale_ppm == m_point.m_wpBBox_view_scale_ppm &&
220 vp.rotation == m_point.m_wpBBox_rotation) {
222 LLBBox vpBBox = vp.GetBBox();
223 if (vpBBox.IntersectOut(m_point.m_wpBBox)) {
225 if (m_point.m_bShowWaypointRangeRings && (m_point.m_iWaypointRangeRingsNumber > 0)) {
226 double factor = 1.00;
227 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
230 double radius = factor * m_point.m_iWaypointRangeRingsNumber *
231 m_point.m_fWaypointRangeRingsStep / 60.;
233 LLBBox radar_box = m_point.m_wpBBox;
234 radar_box.EnLarge(radius * 2);
235 if (vpBBox.IntersectOut(radar_box)) {
245 unsigned char transparency = 150;
247 if (use_cached_screen_coords && m_point.m_pos_on_screen)
248 r.x = m_point.m_screen_pos.m_x, r.y = m_point.m_screen_pos.m_y;
250 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
252 if (r.x == INVALID_COORD)
return;
255 if (m_point.m_IconIsDirty) ReLoadIcon();
257 if ((m_point.m_bIsActive) && (m_point.m_IconName != _T(
"mob")))
258 pbm = pWayPointMan->GetIconBitmap(_T (
"activepoint" ));
260 pbm = m_point.m_pbmIcon;
263 if (!pbm || !pbm->IsOk())
return;
265 int sx2 = pbm->GetWidth() / 2;
266 int sy2 = pbm->GetHeight() / 2;
269 wxRect r1(r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2);
272 if (m_point.m_bShowName) {
273 if (!m_point.m_pMarkFont) {
274 wxFont *dFont = FontMgr::Get().GetFont(_(
"Marks"));
275 int font_size = wxMax(8, dFont->GetPointSize());
276 font_size /= OCPN_GetWinDIPScaleFactor();
278 m_point.m_pMarkFont = FontMgr::Get().FindOrCreateFont(
279 font_size, dFont->GetFamily(), dFont->GetStyle(), dFont->GetWeight(),
280 false, dFont->GetFaceName());
282 m_point.m_FontColor = FontMgr::Get().GetFontColor(_(
"Marks"));
283 if (m_point.m_iTextTexture) {
284 glDeleteTextures(1, &m_point.m_iTextTexture);
285 m_point.m_iTextTexture = 0;
288 m_point.CalculateNameExtents();
291 if (m_point.m_pMarkFont) {
292 wxRect r2(r.x + m_point.m_NameLocationOffsetX, r.y + m_point.m_NameLocationOffsetY,
293 m_point.m_NameExtents.x, m_point.m_NameExtents.y);
302 if (!m_point.m_bPreScaled) {
303 hilitebox.x *= g_MarkScaleFactorExp;
304 hilitebox.y *= g_MarkScaleFactorExp;
305 hilitebox.width *= g_MarkScaleFactorExp;
306 hilitebox.height *= g_MarkScaleFactorExp;
311 hilitebox.Inflate(20);
314 hilitebox.Inflate(4);
319 if (!m_point.m_wpBBox.GetValid() || vp.view_scale_ppm != m_point.m_wpBBox_view_scale_ppm ||
320 vp.rotation != m_point.m_wpBBox_rotation) {
321 double lat1, lon1, lat2, lon2;
322 canvas->GetCanvasPixPoint(r.x + hilitebox.x,
323 r.y + hilitebox.y + hilitebox.height, lat1, lon1);
324 canvas->GetCanvasPixPoint(r.x + hilitebox.x + hilitebox.width,
325 r.y + hilitebox.y, lat2, lon2);
328 m_point.m_wpBBox.Set(lat1, lon1, lat2, lon2 + 360);
330 m_point.m_wpBBox.Set(lat1, lon1, lat2, lon2);
332 m_point.m_wpBBox_view_scale_ppm = vp.view_scale_ppm;
333 m_point.m_wpBBox_rotation = vp.rotation;
342 if (m_point.m_bPtIsSelected) {
344 if (m_point.m_bBlink) {
345 wxPen *pen = g_pRouteMan->GetActiveRoutePointPen();
346 hi_colour = pen->GetColour();
348 hi_colour = GetGlobalColor(_T (
"YELO1" ));
351 AlphaBlending(dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width,
352 hilitebox.height, radius, hi_colour, transparency);
355 bool bDrawHL =
false;
357 if (m_point.m_bBlink && (gFrame->nBlinkerTick & 1)) bDrawHL =
true;
359 if ((!bDrawHL) && (NULL != m_point.m_pbmIcon)) {
361 unsigned int IconTexture = pWayPointMan->GetIconTexture(pbm, glw, glh);
363 glBindTexture(GL_TEXTURE_2D, IconTexture);
365 glEnable(GL_TEXTURE_2D);
368 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
369 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
371 int w = r1.width, h = r1.height;
374 if (!m_point.m_bPreScaled) {
375 scale = g_MarkScaleFactorExp;
378 float ws = r1.width *
scale;
379 float hs = r1.height *
scale;
380 float xs = r.x - ws / 2.;
381 float ys = r.y - hs / 2.;
382 float u = (float)w / glw, v = (
float)h / glh;
403 coords[6] = xs, coords[7] = ys + hs;
405 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
408 glDisable(GL_TEXTURE_2D);
411 if (m_point.m_bShowName && m_point.m_pMarkFont) {
412 int w = m_point.m_NameExtents.x, h = m_point.m_NameExtents.y;
413 if (!m_point.m_iTextTexture && w && h) {
417 dc.SelectObject(tbm);
418 dc.SetBackground(wxBrush(*wxBLACK));
420 dc.SetFont(*m_pMarkFont);
421 dc.SetTextForeground(*wxWHITE);
422 dc.DrawText(m_MarkName, 0, 0);
423 dc.SelectObject(wxNullBitmap);
426 wxImage image = tbm.ConvertToImage();
427 unsigned char *d = image.GetData();
428 unsigned char *e =
new unsigned char[w * h];
430 for (
int p = 0; p < w * h; p++) e[p] = d[3 * p + 0];
434 glGenTextures(1, &m_iTextTexture);
435 glBindTexture(GL_TEXTURE_2D, m_iTextTexture);
437 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
438 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
440 m_iTextTextureWidth = NextPow2(w);
441 m_iTextTextureHeight = NextPow2(h);
442 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, m_iTextTextureWidth,
443 m_iTextTextureHeight, 0, GL_ALPHA, GL_UNSIGNED_BYTE, NULL);
444 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_ALPHA, GL_UNSIGNED_BYTE,
449 sdc.SetFont(*m_point.m_pMarkFont);
450 sdc.GetTextExtent(m_point.m_MarkName, &w, &h, NULL, NULL, m_point.m_pMarkFont);
455 temp_dc.SelectObject(bmp);
458 temp_dc.SetBackground(wxBrush(wxColour(0, 0, 0)));
462 temp_dc.SetFont(*m_point.m_pMarkFont);
463 temp_dc.SetTextForeground(wxColour(255, 255, 255));
464 temp_dc.DrawText(m_point.m_MarkName, 0, 0);
465 temp_dc.SelectObject(wxNullBitmap);
469 wxImage image = bmp.ConvertToImage();
471 unsigned char *data =
new unsigned char[w * h * 4];
472 unsigned char *im = image.GetData();
475 unsigned int r = m_point.m_FontColor.Red();
476 unsigned int g = m_point.m_FontColor.Green();
477 unsigned int b = m_point.m_FontColor.Blue();
478 for (
int i = 0; i < h; i++) {
479 for (
int j = 0; j < w; j++) {
480 unsigned int index = ((i * w) + j) * 4;
484 data[index + 3] = im[((i * w) + j) * 3];
489 glGenTextures(1, &m_point.m_iTextTexture);
491 glBindTexture(GL_TEXTURE_2D, m_point.m_iTextTexture);
493 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
494 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
496 m_point.m_iTextTextureWidth = NextPow2(w);
497 m_point.m_iTextTextureHeight = NextPow2(h);
498 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_point.m_iTextTextureWidth,
499 m_point.m_iTextTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
500 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE,
503 glEnable(GL_TEXTURE_2D);
505 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
510 if (m_point.m_iTextTexture) {
512 glBindTexture(GL_TEXTURE_2D, m_point.m_iTextTexture);
514 glEnable(GL_TEXTURE_2D);
517 int x = r.x + m_point.m_NameLocationOffsetX, y = r.y + m_point.m_NameLocationOffsetY;
518 float u = (float)w / m_point.m_iTextTextureWidth,
519 v = (
float)h / m_point.m_iTextTextureHeight;
539 coords[6] = x, coords[7] = y + h;
541 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
544 glDisable(GL_TEXTURE_2D);
549 if (m_point.m_iWaypointRangeRingsNumber && m_point.m_bShowWaypointRangeRings) {
550 double factor = 1.00;
551 if (m_point.m_iWaypointRangeRingsStepUnits == 1)
554 factor *= m_point.m_fWaypointRangeRingsStep;
558 ll_gc_ll(m_point.m_lat, m_point.m_lon, 0, factor, &tlat, &tlon);
559 canvas->GetCanvasPointPix(tlat, tlon, &r1);
562 sqrt(pow((
double)(r.x - r1.x), 2) + pow((
double)(r.y - r1.y), 2));
563 int pix_radius = (int)lpp;
565 extern wxColor GetDimColor(wxColor c);
566 wxColor ring_dim_color = GetDimColor(m_point.m_wxcWaypointRangeRingsColour);
569 double platform_pen_width = wxRound(
570 wxMax(1.0, g_Platform->GetDisplayDPmm() / 2));
571 wxPen ppPen1(ring_dim_color, platform_pen_width);
572 wxBrush saveBrush = dc.GetBrush();
573 wxPen savePen = dc.GetPen();
575 dc.SetBrush(wxBrush(ring_dim_color, wxBRUSHSTYLE_TRANSPARENT));
577 for (
int i = 1; i <= m_point.m_iWaypointRangeRingsNumber; i++)
578 dc.StrokeCircle(r.x, r.y, i * pix_radius);
580 dc.SetBrush(saveBrush);
584 if (m_point.m_bDrawDragHandle) {
586 double platform_pen_width = wxRound(
587 wxMax(1.0, g_Platform->GetDisplayDPmm() /
590 wxColor dh_color = GetGlobalColor(_T (
"YELO1" ));
591 wxPen ppPen1(dh_color, 3 * platform_pen_width);
593 dc.DrawLine(r.x + hilitebox.width / 4, r.y + hilitebox.height / 4,
594 r.x + m_point.m_drag_line_length_man, r.y + m_point.m_drag_line_length_man);
596 dh_color = wxColor(0, 0, 0);
597 wxPen ppPen2(dh_color, platform_pen_width);
599 dc.DrawLine(r.x + hilitebox.width / 4, r.y + hilitebox.height / 4,
600 r.x + m_point.m_drag_line_length_man, r.y + m_point.m_drag_line_length_man);
603 glBindTexture(GL_TEXTURE_2D, m_point.m_dragIconTexture);
605 glEnable(GL_TEXTURE_2D);
608 int x = r.x + m_point.m_drag_icon_offset, y = r.y + m_point.m_drag_icon_offset,
609 w = m_point.m_dragIcon.GetWidth(), h = m_point.m_dragIcon.GetHeight();
613 float ws = w *
scale;
614 float hs = h *
scale;
615 float xs = x - ws / 2.;
616 float ys = y - hs / 2.;
617 float u = (float)w / m_point.m_dragIconTextureWidth,
618 v = (
float)h / m_point.m_dragIconTextureWidth;
639 coords[6] = xs, coords[7] = ys + hs;
641 glChartCanvas::RenderSingleTexture(dc, coords, uv, &vp, 0, 0, 0);
644 glDisable(GL_TEXTURE_2D);
647 if (m_point.m_bBlink)
648 g_blink_rect =m_point. CurrentRect_in_DC;
651 m_point.CurrentRect_in_DC.x = r.x + hilitebox.x;
652 m_point.CurrentRect_in_DC.y = r.y + hilitebox.y;
653 m_point.CurrentRect_in_DC.width = hilitebox.width;
654 m_point.CurrentRect_in_DC.height = hilitebox.height;
656 if (m_point.m_bBlink)
657 g_blink_rect = m_point.CurrentRect_in_DC;
661void RoutePointGui::CalculateDCRect(wxDC &dc,
ChartCanvas *canvas, wxRect *prect) {
662 dc.ResetBoundingBox();
663 dc.DestroyClippingRegion();
667 Draw(odc, canvas, NULL);
670 prect->x = dc.MinX() - 1;
671 prect->y = dc.MinY() - 1;
672 prect->width = dc.MaxX() - dc.MinX() + 2;
673 prect->height = dc.MaxY() - dc.MinY() + 2;
676bool RoutePointGui::IsVisibleSelectable(
ChartCanvas* cc,
bool boverrideViz) {
677 return m_point.IsVisibleSelectable(cc->GetScaleValue(), boverrideViz);
680wxPoint2DDouble RoutePointGui::GetDragHandlePoint(
ChartCanvas *canvas) {
681 if (!m_point.m_bDrawDragHandle)
682 return wxPoint2DDouble(m_point.m_lon, m_point.m_lat);
684 return computeDragHandlePoint(canvas);
687void RoutePointGui::SetPointFromDraghandlePoint(
ChartCanvas *canvas,
double lat,
690 canvas->GetCanvasPointPix(lat, lon, &r);
692 canvas->GetCanvasPixPoint(r.x - m_point.m_drag_icon_offset, r.y - m_point.m_drag_icon_offset,
694 m_point.m_lat = tlat;
695 m_point.m_lon = tlon;
698void RoutePointGui::SetPointFromDraghandlePoint(
ChartCanvas *canvas,
int x,
701 canvas->GetCanvasPixPoint(x - m_point.m_drag_icon_offset - m_point.m_draggingOffsetx,
702 y - m_point.m_drag_icon_offset - m_point.m_draggingOffsety, tlat,
704 m_point.m_lat = tlat;
705 m_point.m_lon = tlon;
708void RoutePointGui::PresetDragOffset(
ChartCanvas *canvas,
int x,
int y) {
710 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
712 m_point.m_draggingOffsetx = x - (r.x + m_point.m_drag_icon_offset);
713 m_point.m_draggingOffsety = y - (r.y + m_point.m_drag_icon_offset);
716wxPoint2DDouble RoutePointGui::computeDragHandlePoint(
ChartCanvas *canvas) {
718 canvas->GetCanvasPointPix(m_point.m_lat, m_point.m_lon, &r);
720 canvas->GetCanvasPixPoint(r.x + m_point.m_drag_icon_offset, r.y + m_point.m_drag_icon_offset,
724 m_point.m_dragHandleLat = lat;
725 m_point.m_dragHandleLon = lon;
727 return wxPoint2DDouble(lon, lat);
730void RoutePointGui::ShowScaleWarningMessage(
ChartCanvas *canvas) {
731 wxString strA = _(
"The ScaMin value for new waypoints is set to");
732 wxString strB = _(
"but current chartscale is");
734 _(
"Therefore the new waypoint will not be visible at this zoom level.");
736 wxString::Format(_T(
"%s %li,\n %s %.0f.\n%s"), strA, m_point.GetScaMin(), strB,
737 canvas->GetScaleValue(), strC);
738 OCPNMessageBox(canvas, MessStr);
741void RoutePointGui::EnableDragHandle(
bool bEnable) {
742 m_point.m_bDrawDragHandle = bEnable;
744 if (!m_point.m_dragIcon.IsOk()) {
747 int bm_size = g_Platform->GetDisplayDPmm() * 9;
750 wxString UserIconPath = g_Platform->GetSharedDataDir()
751 + _T(
"uidata") + wxFileName::GetPathSeparator();
753 m_point.m_dragIcon = LoadSVG(UserIconPath + _T(
"DragHandle.svg"), bm_size,
754 bm_size, m_point.m_pbmIcon);
759 if (m_point.m_dragIconTexture == 0) {
760 glGenTextures(1, &m_point.m_dragIconTexture);
761 glBindTexture(GL_TEXTURE_2D, m_point.m_dragIconTexture);
763 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
764 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
765 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
767 wxImage image = m_point.m_dragIcon.ConvertToImage();
768 int w = image.GetWidth(), h = image.GetHeight();
770 m_point.m_dragIconTextureWidth = NextPow2(w);
771 m_point.m_dragIconTextureHeight = NextPow2(h);
773 unsigned char *d = image.GetData();
774 unsigned char *a = image.GetAlpha();
776 unsigned char mr, mg, mb;
777 image.GetOrFindMaskColour(&mr, &mg, &mb);
779 unsigned char *e =
new unsigned char[4 * w * h];
781 for (
int y = 0; y < h; y++)
782 for (
int x = 0; x < w; x++) {
783 unsigned char r, g, b;
784 int off = (y * image.GetWidth() + x);
793 a ? a[off] : ((r == mr) && (g == mg) && (b == mb) ? 0 : 255);
797 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_point.m_dragIconTextureWidth,
798 m_point.m_dragIconTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE,
800 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE,
808 if (m_point.m_dragIcon.IsOk()) {
809 m_point.m_drag_line_length_man = bm_size;
810 m_point.m_drag_icon_offset = bm_size;
812 m_point.m_drag_line_length_man = 64;
813 m_point.m_drag_icon_offset = 64;
819void RoutePointGui::ReLoadIcon(
void) {
820 if (!pWayPointMan)
return;
821 bool icon_exists = pWayPointMan->DoesIconExist(m_point.m_IconName);
823 wxString iconUse = m_point.m_IconName;
827 wxString tentative_icon = m_point.m_IconName.Lower();
828 if (pWayPointMan->DoesIconExist(tentative_icon)) {
830 m_point.m_IconName = tentative_icon;
831 iconUse = m_point.m_IconName;
836 if (!pWayPointMan->DoesIconExist(_T(
"tempsub"))) {
839 wxBitmap bmp = style->GetIcon(_T(
"circle"));
845 iconUse = _T(
"tempsub");
849 m_point.m_pbmIcon = pWayPointMan->GetIconBitmap(iconUse);
850 m_point.m_bPreScaled = pWayPointMan->GetIconPrescaled(iconUse);
853 m_point.m_wpBBox_view_scale_ppm = -1;
855 m_point.m_iTextTexture = 0;
858 m_point.m_IconScaleFactor = -1;
859 m_point.m_pMarkFont = 0;
860 m_point.m_IconIsDirty =
false;
863bool RoutePointGui::SendToGPS(
const wxString &com_name,
SendToGpsDlg *dialog) {
864 int result = SendWaypointToGPS_N0183(&m_point, com_name);
868 msg = _(
"Waypoint(s) Transmitted.");
870 if (result == ERR_GARMIN_INITIALIZE)
871 msg = _(
"Error on Waypoint Upload. Garmin GPS not connected");
873 msg = _(
"Error on Waypoint Upload. Please check logfiles...");
876 OCPNMessageBox(NULL, msg, _(
"OpenCPN Info"), wxOK | wxICON_INFORMATION);
878 return (result == 0);
881int RoutePointGui::GetIconImageIndex() {
882 if (m_point.IsShared()) {
884 wxArrayPtrVoid *proute_array = g_pRouteMan->GetRouteArrayContaining(&m_point);
887 bool brp_viz =
false;
889 for (
unsigned int ir = 0; ir < proute_array->GetCount(); ir++) {
891 if (pr->IsVisible()) {
899 return (pWayPointMan->GetFIconImageListIndex(GetIconBitmap()));
901 if (m_point.IsVisible())
902 return (pWayPointMan->GetIconImageListIndex(GetIconBitmap()));
904 return (pWayPointMan->GetXIconImageListIndex(GetIconBitmap()));
909 if (m_point.IsVisible())
910 return (pWayPointMan->GetIconImageListIndex(GetIconBitmap()));
912 return (pWayPointMan->GetXIconImageListIndex(GetIconBitmap()));
Route "Send to GPS..." Dialog Definition.