void RoutePoint::Draw( ocpnDC& dc, wxPoint *rpn ) { wxPoint r; wxRect hilitebox; cc1->GetCanvasPointPix( m_lat, m_lon, &r ); // return the home point in this dc to allow "connect the dots" if( NULL != rpn ) *rpn = r; if( !m_bIsVisible ) // pjotrc 2010.02.13, 2011.02.24 return; // Optimization, especially apparent on tracks in normal cases if( m_IconName == _T("empty") && !m_bShowName && !m_bPtIsSelected ) return; wxPen *pen; if( m_bBlink ) pen = g_pRouteMan->GetActiveRoutePointPen(); else pen = g_pRouteMan->GetRoutePointPen(); // Substitue icon? wxBitmap *pbm; if( ( m_bIsActive ) && ( m_IconName != _T("mob") ) ) pbm = pWayPointMan->GetIconBitmap( _T ( "activepoint" ) ); else pbm = m_pbmIcon; wxBitmap *pbms = NULL; if( g_ChartScaleFactorExp > 1.0){ if(m_IconScaleFactor != g_ChartScaleFactorExp){ wxImage scaled_image = pbm->ConvertToImage(); int new_width = pbm->GetWidth() * g_ChartScaleFactorExp; int new_height = pbm->GetHeight() * g_ChartScaleFactorExp; m_ScaledBMP = wxBitmap(scaled_image.Scale(new_width, new_height, wxIMAGE_QUALITY_HIGH)); m_IconScaleFactor = g_ChartScaleFactorExp; } if( m_ScaledBMP.IsOk() ) pbm = &m_ScaledBMP; } int sx2 = pbm->GetWidth() / 2; int sy2 = pbm->GetHeight() / 2; // Calculate the mark drawing extents wxRect r1( r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2 ); // the bitmap extents if( m_bShowName ) { if( 0 == m_pMarkFont ) { m_pMarkFont = FontMgr::Get().GetFont( _( "Marks" ) ); m_FontColor = FontMgr::Get().GetFontColor( _( "Marks" ) ); CalculateNameExtents(); } if( m_pMarkFont ) { wxRect r2( r.x + m_NameLocationOffsetX, r.y + m_NameLocationOffsetY, m_NameExtents.x, m_NameExtents.y ); r1.Union( r2 ); } } hilitebox = r1; hilitebox.x -= r.x; hilitebox.y -= r.y; float radius; if( g_btouch ){ hilitebox.Inflate( 20 ); radius = 20.0f; } else{ hilitebox.Inflate( 4 ); radius = 4.0f; } wxColour hi_colour = pen->GetColour(); unsigned char transparency = 100; if( m_bIsBeingEdited ){ hi_colour = GetGlobalColor( _T ( "YELO1" ) ); transparency = 150; } // Highlite any selected point if( m_bPtIsSelected || m_bIsBeingEdited) { AlphaBlending( dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width, hilitebox.height, radius, hi_colour, transparency ); } bool bDrawHL = false; if( m_bBlink && ( gFrame->nBlinkerTick & 1 ) ) bDrawHL = true; if( ( !bDrawHL ) && ( NULL != m_pbmIcon ) ) { dc.DrawBitmap( *pbm, r.x - sx2, r.y - sy2, true ); // on MSW, the dc Bounding box is not updated on DrawBitmap() method. // Do it explicitely here for all platforms. dc.CalcBoundingBox( r.x - sx2, r.y - sy2 ); dc.CalcBoundingBox( r.x + sx2, r.y + sy2 ); } if( m_bShowName ) { if( m_pMarkFont ) { dc.SetFont( *m_pMarkFont ); dc.SetTextForeground( m_FontColor ); dc.DrawText( m_MarkName, r.x + m_NameLocationOffsetX, r.y + m_NameLocationOffsetY ); } } // Draw waypoint radar rings if activated if( m_iWaypointRangeRingsNumber && m_bShowWaypointRangeRings ) { double factor = 1.00; if( m_iWaypointRangeRingsStepUnits == 1 ) // nautical miles factor = 1 / 1.852; factor *= m_fWaypointRangeRingsStep; double tlat, tlon; wxPoint r1; ll_gc_ll( m_lat, m_lon, 0, factor, &tlat, &tlon ); cc1->GetCanvasPointPix( tlat, tlon, &r1 ); double lpp = sqrt( pow( (double) (r.x - r1.x), 2) + pow( (double) (r.y - r1.y), 2 ) ); int pix_radius = (int) lpp; wxPen ppPen1( m_wxcWaypointRangeRingsColour, 2 ); wxBrush saveBrush = dc.GetBrush(); wxPen savePen = dc.GetPen(); dc.SetPen( ppPen1 ); dc.SetBrush( wxBrush( m_wxcWaypointRangeRingsColour, wxBRUSHSTYLE_TRANSPARENT ) ); for( int i = 1; i <= m_iWaypointRangeRingsNumber; i++ ) dc.StrokeCircle( r.x, r.y, i * pix_radius ); dc.SetPen( savePen ); dc.SetBrush( saveBrush ); } // Save the current draw rectangle in the current DC // This will be useful for fast icon redraws CurrentRect_in_DC.x = r.x + hilitebox.x; CurrentRect_in_DC.y = r.y + hilitebox.y; CurrentRect_in_DC.width = hilitebox.width; CurrentRect_in_DC.height = hilitebox.height; if( m_bBlink ) g_blink_rect = CurrentRect_in_DC; // also save for global blinker delete pbms; // the potentially scaled bitmap }
void RoutePoint::Draw( ocpnDC& dc, wxPoint *rpn ) { wxPoint r; wxRect hilitebox; unsigned char transparency = 100; cc1->GetCanvasPointPix( m_lat, m_lon, &r ); // return the home point in this dc to allow "connect the dots" if( NULL != rpn ) *rpn = r; if( !m_bIsVisible /*&& !m_bIsInTrack*/) // pjotrc 2010.02.13, 2011.02.24 return; // Optimization, especially apparent on tracks in normal cases if( m_IconName == _T("empty") && !m_bShowName && !m_bPtIsSelected ) return; wxPen *pen; if( m_bBlink ) pen = g_pRouteMan->GetActiveRoutePointPen(); else pen = g_pRouteMan->GetRoutePointPen(); // Substitue icon? wxBitmap *pbm; if( ( m_bIsActive ) && ( m_IconName != _T("mob") ) ) pbm = pWayPointMan->GetIconBitmap( _T ( "activepoint" ) ); else pbm = m_pbmIcon; int sx2 = pbm->GetWidth() / 2; int sy2 = pbm->GetHeight() / 2; // Calculate the mark drawing extents wxRect r1( r.x - sx2, r.y - sy2, sx2 * 2, sy2 * 2 ); // the bitmap extents if( m_bShowName ) { if( 0 == m_pMarkFont ) { m_pMarkFont = pFontMgr->GetFont( _( "Marks" ) ); m_FontColor = pFontMgr->GetFontColor( _("Marks") ); CalculateNameExtents(); } if( m_pMarkFont ) { wxRect r2( r.x + m_NameLocationOffsetX, r.y + m_NameLocationOffsetY, m_NameExtents.x, m_NameExtents.y ); r1.Union( r2 ); } } hilitebox = r1; hilitebox.x -= r.x; hilitebox.y -= r.y; hilitebox.Inflate( 2 ); // Highlite any selected point if( m_bPtIsSelected ) { AlphaBlending( dc, r.x + hilitebox.x, r.y + hilitebox.y, hilitebox.width, hilitebox.height, 0.0, pen->GetColour(), transparency ); } bool bDrawHL = false; if( m_bBlink && ( gFrame->nBlinkerTick & 1 ) ) bDrawHL = true; if( ( !bDrawHL ) && ( NULL != m_pbmIcon ) ) { dc.DrawBitmap( *pbm, r.x - sx2, r.y - sy2, true ); // on MSW, the dc Bounding box is not updated on DrawBitmap() method. // Do it explicitely here for all platforms. dc.CalcBoundingBox( r.x - sx2, r.y - sy2 ); dc.CalcBoundingBox( r.x + sx2, r.y + sy2 ); } if( m_bShowName ) { if( m_pMarkFont ) { dc.SetFont( *m_pMarkFont ); dc.SetTextForeground( m_FontColor ); dc.DrawText( m_MarkName, r.x + m_NameLocationOffsetX, r.y + m_NameLocationOffsetY ); } } // Save the current draw rectangle in the current DC // This will be useful for fast icon redraws CurrentRect_in_DC.x = r.x + hilitebox.x; CurrentRect_in_DC.y = r.y + hilitebox.y; CurrentRect_in_DC.width = hilitebox.width; CurrentRect_in_DC.height = hilitebox.height; if( m_bBlink ) g_blink_rect = CurrentRect_in_DC; // also save for global blinker }