Hello,
Little modification for displaying bearing and distance to lighthouse and buoys.
File chcanv.cpp:
Add in function void ChartCanvas::OnCursorTrackTimerEvent( wxTimerEvent& event )
after: if( s57_CheckExtendedLightSectors( mouse_x, mouse_y, VPoint, extendedSectorLegs ) ) { ReloadVP( false );}
if( s57_CheckLight(mouse_x, mouse_y, VPoint) ) { // Check is it lighouse (buoy)
wxSize win_size;
m_pRolloverWin = new RolloverWin( this );
win_size.Set( mouse_x * 90 / 100, mouse_y * 80 / 100 );
wxString sd ;
double brg, dist;
double cursor_lat, cursor_lon;
cc1->GetCanvasPixPoint ( mouse_x, mouse_y, cursor_lat, cursor_lon );
DistanceBearingMercator(cursor_lat, cursor_lon, gLat, gLon, &brg, &dist);
sd.Printf( wxString("%03d° ", wxConvUTF8 ), (int)brg );
sd << FormatDistanceAdaptive( dist );
m_pRolloverWin->SetString( sd );
m_pRolloverWin->SetBestPosition( mouse_x, mouse_y, 1, 1, TC_ROLLOVER, win_size );
m_pRolloverWin->SetBitmap( TC_ROLLOVER );
m_pRolloverWin->IsActive( true );
//ShowRollover = false;
}
if( m_pRolloverWin && m_pRolloverWin->IsShown() && !ShowRollover ) {
m_pRolloverWin->Hide();
m_pRolloverWin = NULL; }
In file s57chart.cpp at the end:
bool s57_CheckLight( int mx, int my, ViewPort& viewport ) {
double cursor_lat, cursor_lon;
static double lastLat, lastLon;
bool lights = false;
if( !ps52plib || !ps52plib->m_bExtendLightSectors ) return false;
cc1->GetCanvasPixPoint ( mx, my, cursor_lat, cursor_lon );
if( lastLat == cursor_lat && lastLon == cursor_lon ) return false;
lastLat = cursor_lat;
lastLon = cursor_lon;
ChartBase *targetchart = cc1->GetChartAtCursor();
s57chart *chart = dynamic_cast<s57chart*>( targetchart );
if( chart ) {
float selectRadius = 2 / ( viewport.view_scale_ppm * 1852 * 60 );
ListOfObjRazRules* rule_list =
chart->GetObjRuleListAtLatLon( cursor_lat, cursor_lon, selectRadius, &viewport );
wxPoint2DDouble lightPosD(0,0);
for( ListOfObjRazRules::Node *node = rule_list->GetLast(); node; node = node->GetPrevious() ) {
ObjRazRules *current = node->GetData();
S57Obj* light = current->obj;
if( !strcmp( light->FeatureName, "LIGHTS" ) ) {
lights = true;
break;
}
}
}
return lights;
}
In file s57chart.h after bool s57_CheckExtendedLightSectors( int mx, int my, ViewPort& VPoint, std::vector<s57Sector_t>& sectorlegs ); :
bool s57_CheckLight( int mx, int my , ViewPort& viewport );
It should lok like this:
ImageShack® - Online Photo and Video Hosting