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 19-09-2024, 13:37   #1
Registered User

Join Date: Sep 2024
Posts: 4
Help wanted with plugin development

Hi,
I've been trying for 3 days in a row now to create a plugin with the simple functionality of having a button on the UI with the text 'Home' on it that when pushed moves the chart to a specific set of coordinates, rotation and scale.
These parameters should be user defined via UI and saved within the program for all upcomming program boots untill changed by the user.

I've downloaded, build and installed the whole development package, but keep getting stuck on different levels of my process.
Latest and I think the furthest I got was with my plugin written based on the demo_pi and need to build the plugin. In the build process I keep being stuck on a missing target cmake document apparently needed for the build process.
So I would like either with help setting my system up to make the plugin myself. Or for someone to create this relative simple plugin for me.
I must admit i'm not into programming for a living and have hobby based knowledge and some AI help here and there to get where I want to be. For this AI seems also to be stuck on the issue.


Thanks in advance!
Hylke
HylkeW is offline   Reply With Quote
Old 19-09-2024, 14:55   #2
Registered User

Join Date: Mar 2011
Posts: 768
Re: Help wanted with plugin development

Quote:
Latest and I think the furthest I got was with my plugin written based on the demo_pi
The built-in demo plugin, other than illustrating a few plugin API's is a poor example to use for plugin development, as it is built within core OpenCPN.

You're better off using another plugin as a template, as it is built outside of the core OpenCPN and has the appropriate cmake build environment.

Note that it is also useful to be able to build core OpenCPN as that enables you to more easily debug your own plugin.

There are two "styles" of plugin templates, one that is used by Jon Gough's testplugin and another used by Mike Rossiter (aka Rasbats) shipdriver. Most of the other third party plugins use either of these templates.

If you can get either of those to build on your PC, then it is simply a matter of writing your own code and modifying the cmakelists.txt file with the appropriate details for your plugin.

Also suggest that you follow the developer guidelines. Pavel has provided some useful documentation here

Good luck.
stevead is offline   Reply With Quote
Old 20-09-2024, 02:28   #3
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 325
Do it in JavaScript!

No need to write a plugin. Just use the JavaScript plugin and run a simple script like this:.

Code:
homePosition = {latitude: 55+45/60, longitude: 12+40/60};
scale = 1/10;	//pixels per metre

OCPNonContextMenu(goHome, "Centre home");
consolePark();

function goHome(){
	OCPNcentreCanvas(homePosition, scale);
	OCPNonContextMenu(goHome, "Centre home");
	}
You set homePosition to wherever that is and the scale to whatever you want.

The script adds an item Centre home to the context menu and parks the console out of the way. When you select the context menu item, it runs the function goHome which centres the canvas as required and then re-adds the context menu item for next time.

It would be a simple matter to extend the script to allow you to select the home position on the chart rather than coding it in.
__________________
If all else fails, read the instructions.
Antipole is offline   Reply With Quote
Old 24-09-2024, 05:48   #4
Registered User

Join Date: Sep 2024
Posts: 4
Re: Help wanted with plugin development

Quote:
Originally Posted by stevead View Post
The built-in demo plugin, other than illustrating a few plugin API's is a poor example to use for plugin development, as it is built within core OpenCPN.

You're better off using another plugin as a template, as it is built outside of the core OpenCPN and has the appropriate cmake build environment.

Note that it is also useful to be able to build core OpenCPN as that enables you to more easily debug your own plugin.

There are two "styles" of plugin templates, one that is used by Jon Gough's testplugin and another used by Mike Rossiter (aka Rasbats) shipdriver. Most of the other third party plugins use either of these templates.

If you can get either of those to build on your PC, then it is simply a matter of writing your own code and modifying the cmakelists.txt file with the appropriate details for your plugin.

Also suggest that you follow the developer guidelines. Pavel has provided some useful documentation here

Good luck.

Thank you for these instructions,

Folowing these exact steps, succesfull Release Win32 build with VS2022, copying the dashboard plugin, editing it and trying to build it I run into this issue:

-- Configuring done (3.1s)
CMake Error at CMakeLists.txt:23 (TARGET_LINK_LIBRARIES):
Target "HomePlugin" links to:

ocpn:pencpn

but the target was not found. Possible reasons include:

* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.



-- Generating done (0.1s)
CMake Generate step failed. Build files cannot be regenerated correctly.
HylkeW is offline   Reply With Quote
Old 24-09-2024, 05:53   #5
Registered User

Join Date: Sep 2024
Posts: 4
Re: Do it in JavaScript!

Quote:
Originally Posted by Antipole View Post
No need to write a plugin. Just use the JavaScript plugin and run a simple script like this:.

Code:
homePosition = {latitude: 55+45/60, longitude: 12+40/60};
scale = 1/10;    //pixels per metre

OCPNonContextMenu(goHome, "Centre home");
consolePark();

function goHome(){
    OCPNcentreCanvas(homePosition, scale);
    OCPNonContextMenu(goHome, "Centre home");
    }
You set homePosition to wherever that is and the scale to whatever you want.

The script adds an item Centre home to the context menu and parks the console out of the way. When you select the context menu item, it runs the function goHome which centres the canvas as required and then re-adds the context menu item for next time.

It would be a simple matter to extend the script to allow you to select the home position on the chart rather than coding it in.

Wow, didn't know of the existance of this plugin and love it already.
However, a UI button is mandatory for my (touch screen) application, and I don't seem to be able to use the OpenCPN API's OCPNaddToolbarButton function from the Javascript libraries.
HylkeW is offline   Reply With Quote
Old 24-09-2024, 06:22   #6
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 325
Re: Help wanted with plugin development

Quote:
Wow, didn't know of the existance of this plugin and love it already.
However, a UI button is mandatory for my (touch screen) application, and I don't seem to be able to use the OpenCPN API's OCPNaddToolbarButton function from the Javascript libraries.
I haven't used OCPN with a touch screen. You seem to be saying you cannot access the context menu on such? Is that so?

You could create a dialogue with a button to click on, although it would occupy screen space.
Another and simpler option would be to click on the console close button to trigger the action.
If either of these is good for you, I could give you a start on that, when I have time - not likely today.
__________________
If all else fails, read the instructions.
Antipole is offline   Reply With Quote
Old 24-09-2024, 07:10   #7
Registered User

Join Date: Sep 2024
Posts: 4
Re: Help wanted with plugin development

Quote:
Originally Posted by Antipole View Post
I haven't used OCPN with a touch screen. You seem to be saying you cannot access the context menu on such? Is that so?

You could create a dialogue with a button to click on, although it would occupy screen space.
Another and simpler option would be to click on the console close button to trigger the action.
If either of these is good for you, I could give you a start on that, when I have time - not likely today.

I think when doing a long press on the screen the contex menu is opened, but that's not intuitive eneugh for this requirement. Should basically be as simple as the + and - zoom buttons in the bottom.
I still hope to get it working with a plugin as apart from building it I believe the functionality isn't complicated at all and OpenCPN API provides all neccesary functions. If I'm not able to create a plugin after all the dialogue might be the alternative.
In any case the Javascript plugin will certainly come of help somewhere for me, so thanks again for this suggestion!
HylkeW is offline   Reply With Quote
Old 24-09-2024, 07:17   #8
Registered User
 
Antipole's Avatar

Join Date: Oct 2019
Location: Emsworth, UK
Boat: Alubat Ovni 395
Posts: 325
Re: Help wanted with plugin development

Here's a version of the script that is triggered when you click on the console close button.

Code:
homePosition = {latitude: 55+45/60, longitude: 12+40/60};
scale = 1/10;    //pixels per metre

onCloseButton(goHome);
consolePark();

function goHome(){
    OCPNcentreCanvas(homePosition, scale);
    onCloseButton(goHome);
    }
__________________
If all else fails, read the instructions.
Antipole is offline   Reply With Quote
Reply

Tags
men, plug, plugin, wanted

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenCPN PlugIn Development bdbcat OpenCPN 161 04-09-2019 12:50
Plugin development... How to receive chart objects in my plugin? dmartinez OpenCPN 6 04-08-2017 00:56
Plugin development help need. stn92 OpenCPN 0 09-03-2017 10:39
Plugin Development Help THEMuffinMan7 OpenCPN 40 30-11-2016 15:33
New Plugin Development on Linux globalkeith OpenCPN 5 03-05-2012 07:16

Advertise Here


All times are GMT -7. The time now is 07:28.


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.