Cruisers Forum
 


Join CruisersForum Today

Reply
 
Thread Tools Rate Thread Display Modes
Old 26-03-2013, 11:26   #1
Registered User

Join Date: Mar 2011
Posts: 39
Little AIS mod

Hello,

I want create a little AIS mod - to display ship or base name (as i done in picture) if we have it.
It work's but I have some questions about better way to do it. I added in chcanv.cpp file :

wxString Name =wxString::FromUTF8(td->ShipName); // If there is better way to get Ship Name?
Name = Name.substr(0, Name.find(_T ("@"), 0)); // Some how I get name with @@@@@ at the end
Name = Name.substr(0, Name.find(_T ("Unknown"), 0)); // If we do not have ship's name nothing display

wxFont font;
font = wxFont( 10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ); // How to change font size depending on chart scale?
dc.SetFont(font );

dc.DrawText(Name, TargetPoint.x+10, TargetPoint.y-6); // How change font direction, because if ship's course 090 ship's icon hide ship's name

ImageShack® - Online Photo and Video Hosting

Thank you for answers
__________________

__________________
useris is offline   Reply With Quote
Old 26-03-2013, 11:56   #2
Registered User

Join Date: Jun 2008
Location: California Coast
Boat: Beneteau Oceanis 331
Posts: 680
Re: Little AIS mod

Hugh...what?
__________________

__________________
Liam Wald is offline   Reply With Quote
Old 26-03-2013, 13:11   #3
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
Re: Little AIS mod

useris...
1) make it configurable in options - it will clutter the chart in areas with heavy traffic IMO.
2) Do not try to rotate the text, people hate it, recalculate the offset based on the target heading instead to shift the text to the other side...
3) Have a look at https://github.com/OpenCPN/OpenCPN/b...canv.cpp#L5122 (actually at what precedes it)

Pavel
__________________
nohal is offline   Reply With Quote
Old 26-03-2013, 13:50   #4
Registered User

Join Date: Mar 2011
Posts: 39
Re: Little AIS mod

Quote:
Originally Posted by nohal View Post
useris...
1) make it configurable in options - it will clutter the chart in areas with heavy traffic IMO.
2) Do not try to rotate the text, people hate it, recalculate the offset based on the target heading instead to shift the text to the other side...
3) Have a look at https://github.com/OpenCPN/OpenCPN/b...canv.cpp#L5122 (actually at what precedes it)

Pavel
Ok, I understood. How get present chart scale? Ship's name would be depend on chart scale.
double true_scale_display = floor( VPoint.chart_scale / 100. ) * 100.;

Actually i did this modification, just want make it better
__________________
useris is offline   Reply With Quote
Old 27-03-2013, 13:31   #5
Registered User

Join Date: Mar 2011
Posts: 39
Re: Little AIS mod

If someone want AIS modification - it is display ship's name like in first picture and it depend on chart scale:
Need to edit chcanv.cpp
Around line no 6192 (dc.SetPen( wxPen( GetGlobalColor( _T ( "UBLCK" ) ) ) ) after add:

double true_scale_display = floor( VPoint.chart_scale / 100. ) * 100.;

if(true_scale_display<280000){ // from which scale to display name

wxString Name =wxString::FromUTF8(td->ShipName);
Name = Name.substr(0, Name.find(_T ("@"), 0));
Name = Name.substr(0, Name.find(_T ("Unknown"), 0));

if (Name!=_T("")) {
wxFont font;
font = wxFont( 10, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );
dc.SetFont(font );

if ((td->COG> 70) && (td->COG < 120)) {dc.DrawText(Name, TargetPoint.x-10, TargetPoint.y-6);
} else { dc.DrawText(Name, TargetPoint.x+10, TargetPoint.y-6); }

} //If name do not empty
} // if scale
__________________
useris is offline   Reply With Quote
Old 01-04-2013, 14:39   #6
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 1,967
Re: Little AIS mod

Hello
Useris' [Show Target Name] coded, compiled and running in Win32. Pavel's comment to include user choice in AIS options also included. Nice "good to have" thanks to useris and Pavel.
I can of course share it but I may need some "how to do advices" to put in a common repository.

Håkan
Attached Thumbnails
Click image for larger version

Name:	Pic_Target_Name.jpg
Views:	99
Size:	20.3 KB
ID:	58363   Click image for larger version

Name:	Pic_Option_Tratget_Name.jpg
Views:	100
Size:	74.5 KB
ID:	58364  

__________________
Hakan is offline   Reply With Quote
Old 01-04-2013, 17:49   #7
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 1,967
Re: Little AIS mod

Quote:
Originally Posted by Hakan View Post
Hello
Useris' [Show Target Name] coded, compiled and running in Win32.
I can of course share it but I may need some "how to do advices" to put in a common repository.
Håkan
All files used for this little hack are here:
https://dl.dropbox.com/u/5209364/AIS...arget_Name.zip
__________________
Hakan is offline   Reply With Quote
Old 01-04-2013, 19:02   #8
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
Re: Little AIS mod

Hakan...
Congrats Ready for the next small git lesson? If so, try
Code:
git diff
on your modified source.
Better say
Code:
git diff > mydiff.txt
I think it will save you a bit of work next time...
The resulting mydiff.txt is all that's needed to replay your changes on anybody's code using
Code:
git apply mydiff.txt
Pavel
__________________
nohal is offline   Reply With Quote
Old 02-04-2013, 07:06   #9
Long Range Cruiser
 
MarkJ's Avatar

Cruisers Forum Supporter

Join Date: Dec 2007
Location: Australian living on "Sea Life" currently in England.
Boat: Beneteau 393 "Sea Life"
Posts: 12,828
Images: 25
Re: Little AIS mod

Quote:
Originally Posted by Hakan View Post
All files used for this little hack are here:
https://dl.dropbox.com/u/5209364/AIS...arget_Name.zip
I just download it onto Win7 and it loads itself or do I put it somewhere, or do something to it?
I am a user, not a developer.

Thanks,


Mark
__________________
Notes on a Circumnavigation.
OurLifeAtSea.com

Somalia Pirates and our Convoy
MarkJ is offline   Reply With Quote
Old 02-04-2013, 07:23   #10
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 1,967
Re: Little AIS mod

Mark
Just download and unpack the zip file to any directory of your choice. There's a readme.txt included where I describe how to handle the files. You have to rename some files and do some copying. I hope it's clear enough. Otherwise it's due to my bad explanations and please come back and I'll try to describe it better.
Compared to our developers I'm a user as well but enjoys trying to learn some coding in C++.
Make a try! The only thing of importance is to not overwrite but rename the actual opencpn.exe so you can get it back whenever you want.
Håkan
__________________
Hakan is offline   Reply With Quote
Old 02-04-2013, 09:37   #11
Long Range Cruiser
 
MarkJ's Avatar

Cruisers Forum Supporter

Join Date: Dec 2007
Location: Australian living on "Sea Life" currently in England.
Boat: Beneteau 393 "Sea Life"
Posts: 12,828
Images: 25
Re: Little AIS mod

Thanks Hakan! that's great!

I will do it this afternoon!


Mark
__________________
Notes on a Circumnavigation.
OurLifeAtSea.com

Somalia Pirates and our Convoy
MarkJ is offline   Reply With Quote
Old 02-04-2013, 12:08   #12
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 1,967
Re: Little AIS mod

Quote:
Originally Posted by nohal View Post
Hakan...
Congrats Ready for the next small git lesson? If so, try
Code:
git diff
on your modified source.
Better say
Code:
git diff > mydiff.txt
I think it will save you a bit of work next time...
The resulting mydiff.txt is all that's needed to replay your changes on anybody's code using
Code:
git apply mydiff.txt
Pavel
Pavel..
Many thanks for your advices. Really appreciated.
I think I have to read GIT manual more though. The file mydiff.txt seems to include every code in the whole project and have the size of approx. 2.1 Mb. I was in the root directory, with .git, scr and so on just below, when issued the command you said.
Håkan
__________________
Hakan is offline   Reply With Quote
Old 02-04-2013, 14:21   #13
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
Windows new line characters, I would say. If you edit the source in VisualStudio, this should not happen, but once you touch it with notepad everything is messed up. You can configure git to take care of it though.
__________________
nohal is offline   Reply With Quote
Old 02-04-2013, 15:15   #14
Registered User

Join Date: Nov 2012
Location: Orust Sweden
Boat: Najad 34
Posts: 1,967
Re: Little AIS mod

Pavel..
All source is edited with VC++ 2010 I haven't touched it with notepad. But I may have answered "yes" to a repetitive question about adaptation to Windows CR/LF. Is that what you mean? If so I maybe have VC to recall it.
__________________
Hakan is offline   Reply With Quote
Old 02-04-2013, 15:28   #15
Registered User

Join Date: Feb 2010
Location: On the go. Not in Prague.
Posts: 4,016
Ahh, that's it. The correct answer is "leave as is". You can do Save as... - Save with Encoding... to restore the Unix LF line endings the source uses.
__________________

__________________
nohal is offline   Reply With Quote
Reply

Tags
ais

Thread Tools
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




Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -7. The time now is 16:02.


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

ShowCase vBulletin Plugins by Drive Thru Online, Inc.