Cruisers Forum
 


Reply
  This discussion is proudly sponsored by:
Please support our sponsors and let them know you heard about their products on Cruisers Forums. Advertise Here
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 25-07-2012, 11:46   #1
Registered User

Join Date: Jun 2012
Location: on SaltyPaws
Boat: Helia 44
Posts: 66
Calculator_pi New Finished Plugin for OpenCPN

I proudly present a new and ready to go plugin for OpenCPN: calculator_pi, a symbolic calculator. Need to calculate hull speed or visibility range of a lighthouse? The Calculator_pi is there to help.

Have a look at the plugin here: https://github.com/SaltyPaws/calculator_pi.git

The plugin submission form is currently not working for me, so please let me know how I can officially submit the plugin.

Please let me know your favorite nautical equations.

Examples of expression that work in the calculator are: (comments are in brackets, some results depend on other example calculations):
=========
Hull speed:
LWL=48 (water line lenght in feet)
vhull=1.34*LWL^(1/2) (hull speed in knots)

Conversions:
ftm=0.3048 (feet to meters)
km_to_nm=0.539957 (Kilometers to nautical Mile)
ftm*LWL (waterline length in meters)

Distance to horizon
R=6378.1*1000 (Radius of the earth in m)
H=2.5 (Height of the eye above sea-level in m)
d = R * acos(R/(R + h)) (Distance to horizon in m)
ans*km_to_nm (Distance to horizon in nm)

Distance to lighthouse
H1=200 (height of lighthouse in m)
d1 = R*acos(R/(R + H1)) (Distance to horizon in m)
distance=d1+d (visibility range of lighthouse in m)
SaltyPaws is offline   Reply With Quote
Old 25-07-2012, 12:31   #2
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,251
Re: Calculator_pi New finished plugin for OpenCPN

Salty...
Congrats!
There are two little glitches preventing a successful build on Windoze, first one being a simple
Code:
diff --git a/src/expression_parser/parser.cpp b/src/expression_parser/parser.cpp
index ce624ae..4031fa2 100644
--- a/src/expression_parser/parser.cpp
+++ b/src/expression_parser/parser.cpp
@@ -32,7 +32,9 @@

 using namespace std;

-
+#ifndef snprintf
+  #define snprintf  _snprintf
+#endif

 /*
  * constructor.
The other is _img_psd_calculator_web_icon_blue2 in icons.cpp - MSVC does not like lines 209828 characters long for some reason

Pavel
nohal is offline   Reply With Quote
Old 25-07-2012, 13:05   #3
Registered User

Join Date: Jun 2012
Location: on SaltyPaws
Boat: Helia 44
Posts: 66
Re: Calculator_pi New finished plugin for OpenCPN

Hi Pavel,

Thank you for responding so quickly. I have added you as collaborator for the project and I have made the change as suggested in your patch. However, this breaks the linux build. I have added #ifdef OS_WINDOWS and this builds ok. Let me know if it fixes this issue on windows as well.

The other issue is also be easy to solve, as we don't need _img_psd_calculator_web_icon_blue2 in icons.cpp. I have removed it by deleting the image and running the icon generation script again. I have added optipng to the icon generation script (bash version) to make the icons.cpp file even leaner.

Let me know if these fixes resolve the build issues.
SaltyPaws is offline   Reply With Quote
Old 25-07-2012, 14:14   #4
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,251
Re: Calculator_pi New finished plugin for OpenCPN

Yep, now the build is OK. The window was set to minimal size on the first run, but otherwise it looks like running well.

Pavel
nohal is offline   Reply With Quote
Old 25-07-2012, 14:28   #5
Registered User

Join Date: Dec 2005
Location: Helsingborg
Boat: Dufour 35
Posts: 3,891
Re: Calculator_pi New finished plugin for OpenCPN

Linux did not like the conditional around snprintf at all.
Quote:
error: ‘_snprintf’ was not declared in this scope
Commenting out the whole thing solved that problem.
Another thing is that half the buttons are invisible due the separator to the next plugin, in the plugin tab. The debug plugin has the same problem.
The plugin starts in a very small window in the upper left corner of the screen.
Thomas
cagney is offline   Reply With Quote
Old 25-07-2012, 19:04   #6
Registered User
 
sinbad7's Avatar

Join Date: Sep 2003
Location: Ubatuba,SP,Brazil (Ex Norway)
Boat: (Ex) Alu. 60' yacht-"Eight Bells"
Posts: 2,731
Images: 57
Send a message via Skype™ to sinbad7
Re: Calculator_pi New finished plugin for OpenCPN

And here is another,very useful marine calculator:
You can also easily copy the html to your HD for off-line work.

Tore
__________________
"And all I ask is a tall ship and a star to steer her by."
sinbad7 is offline   Reply With Quote
Old 27-07-2012, 09:58   #7
Registered User

Join Date: Jun 2012
Location: on SaltyPaws
Boat: Helia 44
Posts: 66
Re: Calculator_pi New finished plugin for OpenCPN

I have fixed 3 small issues:

*The small window on first time run.
*Plugin menu show half buttons (added \n)
*snprintf issue --> I have swapped the #ifdef with #if defined with a larger range for Windows definitions so let me know if this addresses your issue cagney.

Let me know how I can officially submit the plug-in.
SaltyPaws is offline   Reply With Quote
Old 28-07-2012, 01:52   #8
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,251
Re: Calculator_pi New finished plugin for OpenCPN

The plugin is now linked from PlugIns | Official OpenCPN Homepage
I did the Windows build, but the barbecue smells so well that you will have to wait for the Linux libs

Pavel
nohal is offline   Reply With Quote
Old 28-07-2012, 03:16   #9
Registered User
 
Gilletarom's Avatar

Join Date: Mar 2010
Location: France
Boat: 10.50 mètres
Posts: 3,042
Re: Calculator_pi New finished plugin for OpenCPN

Quote:
Originally Posted by nohal View Post
.... but the barbecue smells so well that you will have to wait for .....

Pavel
How Pavel, your favorite barbecue to OpenCPN .... Tssss ....
Gilletarom is offline   Reply With Quote
Old 28-07-2012, 13:01   #10
Registered User

Join Date: Jul 2009
Location: The Netherlands
Boat: Koopmans, 33 ft cutter
Posts: 170
Re: Calculator_pi New finished plugin for OpenCPN

Sorry Pawel, to spoil the bbq. When I open the help file of the plugin and click the calculate button with nothing or text in the input field OpenCPN crashes.
Zoef is offline   Reply With Quote
Old 31-07-2012, 03:12   #11
Registered User
 
Gilletarom's Avatar

Join Date: Mar 2010
Location: France
Boat: 10.50 mètres
Posts: 3,042
Re: Calculator_pi New finished plugin for OpenCPN

Hello,

1° if I click twice on "Calculate" with enter nohing in the calculous window ... Then Crash.

2° Problem with the littele screen (10124X600). It is necessary to have a vertical slider.

Best regards

Gilletarom
Attached Thumbnails
Click image for larger version

Name:	2012-07-28_Click-twice_on_Calculate.jpg
Views:	407
Size:	150.4 KB
ID:	44215   Click image for larger version

Name:	2012-07-28_Click-twice_on_Calculate_II.jpg
Views:	363
Size:	34.6 KB
ID:	44216  

Click image for larger version

Name:	2012-07-28_1024X600_Small_screen.jpg
Views:	485
Size:	155.2 KB
ID:	44217  
Gilletarom is offline   Reply With Quote
Old 31-07-2012, 09:27   #12
Registered User

Join Date: Jun 2012
Location: on SaltyPaws
Boat: Helia 44
Posts: 66
Re: Calculator_pi New finished plugin for OpenCPN

Hi Zoef & Gilletarom,

This crash is something that does not happen when running under ubuntu linux. I cant replicate the bug. The design behaviour is:
press calculate on empty box-->
"Error: Empty expression (col 1)"
press calculate on this line:
"Error: Syntax error in part ": Empty expression (col 1)" (col 6)"

Could you please test what happens when you calculate 10**10
the response should be Error: Unknown operator ** (col 3)

Are you able to get normal calcs to work (e.g. e^pi or sin(1) or 23423423/234234+10)?
what happens when you enter a short line of text e.g. "test"

What version of windows and Opencpn are you using? I am trying to work out if this is something in the plugin back-end or in the front end string conversion.
SaltyPaws is offline   Reply With Quote
Old 31-07-2012, 12:45   #13
Registered User

Join Date: Feb 2010
Location: Tierra del Fuego
Boat: Phantom 19
Posts: 6,251
Re: Calculator_pi New finished plugin for OpenCPN

Guys...
I think I've fixed the cause of the crashes on Windows, please redownload and test.
@Salty: pull request is on github

Pavel
nohal is offline   Reply With Quote
Old 31-07-2012, 13:47   #14
Registered User

Join Date: Jul 2009
Location: The Netherlands
Boat: Koopmans, 33 ft cutter
Posts: 170
Re: Calculator_pi New finished plugin for OpenCPN

Hi Pavel,
You fixed the crashes. Great! Now, I must miss something. What does the calculator do in a more sailor-friendly way than the calculator (with fast key) I have in Windows accessories?
Klaas
Zoef is offline   Reply With Quote
Old 01-08-2012, 04:32   #15
Registered User
 
Gilletarom's Avatar

Join Date: Mar 2010
Location: France
Boat: 10.50 mètres
Posts: 3,042
Re: Calculator_pi New finished plugin for OpenCPN

Hello,

Quote:
Originally Posted by nohal View Post
Guys...
I think I've fixed the cause of the crashes on Windows, please redownload and test.
@Salty: pull request is on github

Pavel
yes, bug solve ... but ...
now if i click many and many then the message is more long at each click !

By example :
"Error: Syntax error in part ": Syntax error in part ": Syntax error in part ": Empty expression (col 1)" (col 6)" (col 6)" (col 6)"

This kind of message is not easy to undestand by not geeks !

Perhaps, a good idea : clear the message at second click.

Gilletarom.
Gilletarom is offline   Reply With Quote
Reply

Tags
opencpn

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 05:53.


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.