<div dir="ltr"><div style>Hi all</div>I tried to do a plugin test some time ago but unfortunately I could not develop it much becasue I had more urgent and important work to do :(<div style><br></div><div style>I managed to create a minium skeleton of plugin enabled app and test plugin. I home might help someone advance a bit. Here is my recipe:</div>
<div style><br></div><div style>TOP LEVEL SOURCE DIRECTORY (</div><div style>A CmakeLists.txt file with the project general infor and the plugin enabling commands with something like this:</div><div style>-----------------------------------------------------------------------------------------</div>
<div style><div><font face="courier new, monospace">cmake_minimum_required(VERSION 2.8)</font></div><div><font face="courier new, monospace">PROJECT(MyViewer)</font></div><div><font face="courier new, monospace">FIND_PACKAGE(Qt4 REQUIRED)</font></div>
<div><font face="courier new, monospace">INCLUDE(${QT_USE_FILE}) # include UseQt4.cmake</font></div><div><font face="courier new, monospace">FIND_PACKAGE(CTK REQUIRED)</font></div><div><font face="courier new, monospace">INCLUDE(${CTK_USE_FILE}) # include UseCTK.cmake</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># Extract all library names starting with org_mydomain_ this regular domain defines your plugins</font></div><div><font face="courier new, monospace">macro(GetMyTargetLibraries all_target_libraries varname)</font></div>
<div><font face="courier new, monospace"> set(re_ctkplugin "^com_alma_[a-zA-Z0-9_]+$") </font></div><div><font face="courier new, monospace"> set(_tmp_list)</font></div><div><font face="courier new, monospace"> list(APPEND _tmp_list ${all_target_libraries})</font></div>
<div><font face="courier new, monospace"> ctkMacroListFilter(_tmp_list re_ctkplugin OUTPUT_VARIABLE ${varname})</font></div><div><font face="courier new, monospace">endmacro()</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">#> Create a list of available plug-ins and make them known to the build system</font></div><div><font face="courier new, monospace">set(plugins</font></div><div><font face="courier new, monospace"> Plugins/com.alma.rd.tracker:ON</font></div>
<div><font face="courier new, monospace">)</font></div><div><font face="courier new, monospace">ctkMacroSetupPlugins(${plugins})</font></div><div><font face="courier new, monospace">add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/CoreApp) # This is the main App, that should load</font></div>
<div>------------------------------------------------------------------------------------------------------------</div></div><div style>Now, I Have a Root\Plugins\com.alma.rd.tracker directory with another CMakelistst.txt for the plugin itself:</div>
<div style>-------------------------------------------------------------------------------</div><div style><div><font face="courier new, monospace">PROJECT(com_alma_rd_tracker) #IIRC this projectname is important </font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">set(PLUGIN_export_directive "com_alma_rd_tracker_EXPORT")</font></div><div><font face="courier new, monospace"><br>
</font></div><div><font face="courier new, monospace">set(PLUGIN_SRCS</font></div><div><font face="courier new, monospace"> TrackerListenerActivator.cpp </font></div><div><font face="courier new, monospace"> TrackerListenerLogic.cpp</font></div>
<div><font face="courier new, monospace"> TrackerListenerLogic.h</font></div><div><font face="courier new, monospace">)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># Files which should be processed by Qts moc</font></div>
<div><font face="courier new, monospace">set(PLUGIN_MOC_SRCS<span class="" style="white-space:pre"> </span></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>TrackerListenerActivator.h</font></div>
<div><font face="courier new, monospace">)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># Qt Designer files which should be processed by Qts uic</font></div>
<div><font face="courier new, monospace">set(PLUGIN_UI_FORMS</font></div><div><font face="courier new, monospace">)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"># QRC Files which should be compiled into the plugin</font></div>
<div><font face="courier new, monospace">set(PLUGIN_resources</font></div><div><font face="courier new, monospace">)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">#Compute the plugin dependencies</font></div>
<div><font face="courier new, monospace">ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)</font></div><div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace">ctkMacroBuildPlugin(</font></div>
<div><font face="courier new, monospace"> NAME ${PROJECT_NAME}</font></div><div><font face="courier new, monospace"> EXPORT_DIRECTIVE ${PLUGIN_export_directive}</font></div><div><font face="courier new, monospace"> SRCS ${PLUGIN_SRCS}</font></div>
<div><font face="courier new, monospace"> MOC_SRCS ${PLUGIN_MOC_SRCS}</font></div><div><font face="courier new, monospace"> UI_FORMS ${PLUGIN_UI_FORMS}</font></div><div><font face="courier new, monospace"> RESOURCES ${PLUGIN_resources}</font></div>
<div><font face="courier new, monospace"> TARGET_LIBRARIES ${PLUGIN_target_libraries}</font></div><div><font face="courier new, monospace">)</font></div></div><div style>---------------------------------------------------------------------------------------------------</div>
<div style><br></div><div style>The TrackerListenerActivator class is the interface with the CTK's plugin system while the logic class should do whatever work the plugin is supposed to do.</div><div style><br></div><div style>
The CoreApp folders is there the main APP that can list and use plugins lies... The CMakeLists.txt in this folder does no have any plugin specific command at all.</div><div style>Inside CoreApp\MainWindow.cxx I have a initplugin function: You'll see that I was testing the exact way to init the plugins when I had to put the project away.<b> I cannot guarantee that this code really works 100% but I think it will be a good starting point for anyone willing to try CTK plugins:</b></div>
<div style><br></div><div style>________________________________________________________________________________________________</div><div style><div><font face="courier new, monospace">void</font></div><div><font face="courier new, monospace">MainWindow::InitPluginSystem() {</font></div>
<div><span class="" style="white-space:pre"><font face="courier new, monospace"> </font></span></div><div><span class="" style="white-space:pre"><font face="courier new, monospace"> </font></span></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>//ctkPluginFrameworkLauncher::addSearchPath("C:\\work\\pruebas-bin\\CTKTest\\Plugins\\com.alma.rd.tracker");</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>//ctkPluginFrameworkLauncher::addSearchPath("C:\\work\\pruebas-bin\\CTKTest\\Plugins\\com.alma.rd.tracker\\Release");</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>ctkPluginFrameworkLauncher::addSearchPath("C:/work/pruebas-bin/CTKTest/Plugins/com.alma.rd.tracker/Release");</font></div><div>
<span class="" style="white-space:pre"><font face="courier new, monospace"> </font></span></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>bool succeeded = false;</font></div><div>
<font face="courier new, monospace"><span class="" style="white-space:pre"> </span>try {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>succeeded = ctkPluginFrameworkLauncher::start("com.alma.rd.tracker");</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>}catch(ctkPluginException &e) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << e.message().toStdString() << std::endl;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>const ctkException* e2 = e.cause();</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>if(e2)</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << e2->message().toStdString() << std::endl;</font></div><div><span class="" style="white-space:pre"><font face="courier new, monospace"> </font></span></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>}catch(ctkRuntimeException &e) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << e.what() << std::endl;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>const ctkException* e2 = e.cause();</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>if(e2)</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << e2->message().toStdString() << std::endl;</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>}</font></div>
<div><font face="courier new, monospace"><br></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>/*</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>succeeded = ctkPluginFrameworkLauncher::start("org.commontk.eventadmin");<span class="" style="white-space:pre"> </span></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>if (succeeded) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << "org.commontk.eventadmin started succesfully" << std::endl;<span class="" style="white-space:pre"> </span></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>ctkPluginContext* pluginContext = ctkPluginFrameworkLauncher::getPluginContext();</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>ctkServiceReference eventAdminRef = pluginContext->getServiceReference<ctkEventAdmin>();</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>ctkEventAdmin* eventAdmin = pluginContext->getService<ctkEventAdmin>(eventAdminRef);</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>eventAdmin->sendEvent(ctkEvent("mydomain/tutorial/CustomEvent"));<span class="" style="white-space:pre"> </span></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>} else </font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << "org.commontk.eventadmin not started" << std::endl;</font></div>
<div><span class="" style="white-space:pre"><font face="courier new, monospace"> </font></span></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>succeeded = ctkPluginFrameworkLauncher::start("com.alma.rd.trackerlistener");</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>if (succeeded) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << "com.alma.rd.trackerlistenerservice started succesfully" << std::endl;<span class="" style="white-space:pre"> </span></font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>} else<span class="" style="white-space:pre"> </span></font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>std::cout << "com.alma.rd.trackerlistenerservice not started" << std::endl;</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>*/<span class="" style="white-space:pre"> </span></font></div><div><font face="courier new, monospace">}</font></div><div>________________________________________________________________________________________________<br>
</div><div style>I've stripped the code from unnecesary files and I've attached the relevant code bits in this email.</div><div style><br></div><div style>I hope it helps to some degree.</div><div style><br></div>
<div style>Best Regards</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, May 24, 2013 at 10:57 PM, Zelzer, Sascha <span dir="ltr"><<a href="mailto:s.zelzer@dkfz-heidelberg.de" target="_blank">s.zelzer@dkfz-heidelberg.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
There is an application in CTK called PluginGenerator helping you with generating a plugin.<br>
<br>
I am traveling right now but will send you more information soon.<br>
<br>
Thanks,<br>
<br>
Sascha<br>
<br>
<br>
Von Samsung Mobile gesendet<br>
<br>
<br>
<br>
-------- Ursprüngliche Nachricht --------<br>
Von: Florian Ganglberger <<a href="mailto:Florian.Ganglberger@student.i-med.ac.at">Florian.Ganglberger@student.i-med.ac.at</a>><br>
Datum:<br>
An: <a href="mailto:ctk-developers@commontk.org">ctk-developers@commontk.org</a><br>
Betreff: Re: [Ctk-developers] CTK plugin framework tutorial/example<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
Hi Jean-Christophe,<br>
I have already had a look at the wiki. Unfortunately the "Create a new<br>
CTK Plugin" [1] page is empty which would help us a lot...<br>
<br>
[1] <a href="http://www.commontk.org/index.php/Documentation/CTK_Plugin_Framework:_Creating_a_new_CTK_Plugin" target="_blank">http://www.commontk.org/index.php/Documentation/CTK_Plugin_Framework:_Creating_a_new_CTK_Plugin</a><br>
<br>
2013/5/24 Jean-Christophe Fillion-Robin <<a href="mailto:jchris.fillionr@kitware.com">jchris.fillionr@kitware.com</a>>:<br>
> Hi Florian,<br>
><br>
> Seem the following page could be helpful:<br>
> <a href="http://www.commontk.org/index.php/Documentation/Plugin_Framework#Documentation" target="_blank">http://www.commontk.org/index.php/Documentation/Plugin_Framework#Documentation</a><br>
><br>
> And more particularly:<br>
> <a href="http://www.commontk.org/index.php/Documentation/CTK_Plugin_Framework:_Embedding_the_CTK_Plugin_Framework" target="_blank">http://www.commontk.org/index.php/Documentation/CTK_Plugin_Framework:_Embedding_the_CTK_Plugin_Framework</a><br>
><br>
> Hth<br>
> Jc<br>
><br>
><br>
><br>
><br>
> On Fri, May 24, 2013 at 9:07 AM, Florian Ganglberger<br>
> <<a href="mailto:Florian.Ganglberger@student.i-med.ac.at">Florian.Ganglberger@student.i-med.ac.at</a>> wrote:<br>
>><br>
>> Hi all,<br>
>> I'm new to CTK. Me and my colleges want to develop a CTK application<br>
>> that involves IGSTK for tracking. Unfortunately we can not find any<br>
>> suitable example application / tutorial to learn how to use the plugin<br>
>> framework. Do you have any suggestions for us? Or maybe a nice person<br>
>> can send us a minimal example application ;-)<br>
>> _______________________________________________<br>
>> Ctk-developers mailing list<br>
>> <a href="mailto:Ctk-developers@commontk.org">Ctk-developers@commontk.org</a><br>
>> <a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers</a><br>
><br>
><br>
><br>
><br>
> --<br>
> +1 919 869 8849<br>
_______________________________________________<br>
Ctk-developers mailing list<br>
<a href="mailto:Ctk-developers@commontk.org">Ctk-developers@commontk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers</a><br>
_______________________________________________<br>
Ctk-developers mailing list<br>
<a href="mailto:Ctk-developers@commontk.org">Ctk-developers@commontk.org</a><br>
<a href="http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers" target="_blank">http://public.kitware.com/cgi-bin/mailman/listinfo/ctk-developers</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. (+34) 932 380 592<br> <a href="http://www.alma3d.com">www.alma3d.com</a>
</div>