Cruisers Forum
 


Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 16-04-2013, 05:20   #1
Registered User

Join Date: Mar 2011
Posts: 39
Little Lighthouse/ buoy mod

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
useris is offline   Reply With Quote
Old 16-04-2013, 08:17   #2
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 4,119
Re: Little Lighthouse/ buoy mod

Useris..
I do appreciate your sharing. My aim is to learn more and you really supports that.
Thanks
Håkan
Hakan is offline   Reply With Quote
Old 16-04-2013, 10:12   #3
Registered User

Join Date: Mar 2011
Posts: 39
Re: Little Lighthouse/ buoy mod

I'm learning too

Quote:
Originally Posted by Hakan View Post
Useris..
I do appreciate your sharing. My aim is to learn more and you really supports that.
Thanks
Håkan
useris is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Advertise Here


All times are GMT -7. The time now is 18:47.


Google+
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Social Knowledge Networks
Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2024, vBulletin Solutions, Inc.

ShowCase vBulletin Plugins by Drive Thru Online, Inc.