<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 &quot;^com_alma_[a-zA-Z0-9_]+$&quot;) </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">#&gt; 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 &quot;com_alma_rd_tracker_EXPORT&quot;)</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&#39;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&#39;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(&quot;C:\\work\\pruebas-bin\\CTKTest\\Plugins\\com.alma.rd.tracker&quot;);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>//ctkPluginFrameworkLauncher::addSearchPath(&quot;C:\\work\\pruebas-bin\\CTKTest\\Plugins\\com.alma.rd.tracker\\Release&quot;);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>ctkPluginFrameworkLauncher::addSearchPath(&quot;C:/work/pruebas-bin/CTKTest/Plugins/com.alma.rd.tracker/Release&quot;);</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(&quot;com.alma.rd.tracker&quot;);</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">        </span>}catch(ctkPluginException &amp;e) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>std::cout &lt;&lt; e.message().toStdString() &lt;&lt; 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 &lt;&lt; e2-&gt;message().toStdString() &lt;&lt; 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 &amp;e) {</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>std::cout &lt;&lt; e.what() &lt;&lt; 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 &lt;&lt; e2-&gt;message().toStdString() &lt;&lt; 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(&quot;org.commontk.eventadmin&quot;);<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 &lt;&lt; &quot;org.commontk.eventadmin started succesfully&quot; &lt;&lt; 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-&gt;getServiceReference&lt;ctkEventAdmin&gt;();</font></div>
<div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>ctkEventAdmin* eventAdmin = pluginContext-&gt;getService&lt;ctkEventAdmin&gt;(eventAdminRef);</font></div><div><font face="courier new, monospace"><span class="" style="white-space:pre">                </span>eventAdmin-&gt;sendEvent(ctkEvent(&quot;mydomain/tutorial/CustomEvent&quot;));<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 &lt;&lt; &quot;org.commontk.eventadmin not started&quot; &lt;&lt; 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(&quot;com.alma.rd.trackerlistener&quot;);</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 &lt;&lt; &quot;com.alma.rd.trackerlistenerservice started succesfully&quot; &lt;&lt; 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 &lt;&lt; &quot;com.alma.rd.trackerlistenerservice not started&quot; &lt;&lt; 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&#39;ve stripped the code from unnecesary files and I&#39;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">&lt;<a href="mailto:s.zelzer@dkfz-heidelberg.de" target="_blank">s.zelzer@dkfz-heidelberg.de</a>&gt;</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 &lt;<a href="mailto:Florian.Ganglberger@student.i-med.ac.at">Florian.Ganglberger@student.i-med.ac.at</a>&gt;<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 &quot;Create a new<br>
CTK Plugin&quot; [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 &lt;<a href="mailto:jchris.fillionr@kitware.com">jchris.fillionr@kitware.com</a>&gt;:<br>
&gt; Hi Florian,<br>
&gt;<br>
&gt; Seem the following page could be helpful:<br>
&gt; <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>
&gt;<br>
&gt; And more particularly:<br>
&gt; <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>

&gt;<br>
&gt; Hth<br>
&gt; Jc<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Fri, May 24, 2013 at 9:07 AM, Florian Ganglberger<br>
&gt; &lt;<a href="mailto:Florian.Ganglberger@student.i-med.ac.at">Florian.Ganglberger@student.i-med.ac.at</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi all,<br>
&gt;&gt; I&#39;m new to CTK. Me and my colleges want to develop a CTK application<br>
&gt;&gt; that involves IGSTK for tracking. Unfortunately we can not find any<br>
&gt;&gt; suitable example application / tutorial to learn how to use the plugin<br>
&gt;&gt; framework. Do you have any suggestions for us? Or maybe a nice person<br>
&gt;&gt; can send us a minimal example application ;-)<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; Ctk-developers mailing list<br>
&gt;&gt; <a href="mailto:Ctk-developers@commontk.org">Ctk-developers@commontk.org</a><br>
&gt;&gt; <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>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; +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>