Kaynağa Gözat

Added experimental second front- (QtWebKit) and backend (function pointer).

Sascha Zelzer 13 yıl önce
ebeveyn
işleme
cc4b2ed8a6
23 değiştirilmiş dosya ile 1523 ekleme ve 0 silme
  1. 11 0
      Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.cpp
  2. 2 0
      Applications/ctkCommandLineModuleExplorer/target_libraries.cmake
  3. 5 0
      CMakeLists.txt
  4. 67 0
      Libs/CommandLineModules/Backend/FunctionPointer/CMakeLists.txt
  5. 45 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPDescriptionPrivate.cpp
  6. 47 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPDescriptionPrivate.h
  7. 94 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPTypeTraits.h
  8. 60 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPUtil.cpp
  9. 115 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPUtil_p.h
  10. 212 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFunctionPointer.cpp
  11. 153 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFunctionPointer.h
  12. 78 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleFunctionPointerTask.cpp
  13. 47 0
      Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleFunctionPointerTask_p.h
  14. 9 0
      Libs/CommandLineModules/Backend/FunctionPointer/target_libraries.cmake
  15. 66 0
      Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt
  16. 203 0
      Libs/CommandLineModules/Frontend/QtWebKit/Resources/ctkCmdLineModuleXmlToPlainHtml.xsl
  17. 5 0
      Libs/CommandLineModules/Frontend/QtWebKit/Resources/ctkCmdLineModulesFrontendQtWebKit.qrc
  18. 78 0
      Libs/CommandLineModules/Frontend/QtWebKit/Resources/result.html
  19. 39 0
      Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendFactoryQtWebKit.cpp
  20. 41 0
      Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendFactoryQtWebKit.h
  21. 87 0
      Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendQtWebKit.cpp
  22. 50 0
      Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendQtWebKit.h
  23. 9 0
      Libs/CommandLineModules/Frontend/QtWebKit/target_libraries.cmake

+ 11 - 0
Applications/ctkCommandLineModuleExplorer/ctkCmdLineModuleExplorerMainWindow.cpp

@@ -29,7 +29,9 @@
 #include <ctkCmdLineModuleManager.h>
 #include <ctkCmdLineModuleDescription.h>
 #include <ctkCmdLineModuleFrontendFactoryQtGui.h>
+#include <ctkCmdLineModuleFrontendFactoryQtWebKit.h>
 #include <ctkCmdLineModuleBackendLocalProcess.h>
+#include <ctkCmdLineModuleBackendFunctionPointer.h>
 #include <ctkException.h>
 
 #include <ctkSettingsDialog.h>
@@ -48,12 +50,16 @@ ctkCLModuleExplorerMainWindow::ctkCLModuleExplorerMainWindow(QWidget *parent) :
 
   // Frontends
   moduleFrontendFactories << new ctkCmdLineModuleFrontendFactoryQtGui;
+  moduleFrontendFactories << new ctkCmdLineModuleFrontendFactoryQtWebKit;
   defaultModuleFrontendFactory = moduleFrontendFactories.front();
 
   ui->modulesTreeWidget->setModuleFrontendFactories(moduleFrontendFactories);
 
   // Backends
+  ctkCmdLineModuleBackendFunctionPointer* backendFunctionPointer = new ctkCmdLineModuleBackendFunctionPointer;
+
   moduleBackends.push_back(new ctkCmdLineModuleBackendLocalProcess);
+  moduleBackends.push_back(backendFunctionPointer);
   for(int i = 0; i < moduleBackends.size(); ++i)
   {
     moduleManager.registerBackend(moduleBackends[i]);
@@ -85,6 +91,11 @@ ctkCLModuleExplorerMainWindow::ctkCLModuleExplorerMainWindow(QWidget *parent) :
   connect(&currentFutureWatcher, SIGNAL(canceled()), SLOT(currentModuleCanceled()));
   connect(&currentFutureWatcher, SIGNAL(finished()), SLOT(currentModuleFinished()));
 
+  foreach(QUrl fpModule, backendFunctionPointer->registeredFunctionPointers())
+  {
+    moduleManager.registerModule(fpModule);
+  }
+
   directoryWatcher.setDebug(true);
   directoryWatcher.setDirectories(QStringList(QCoreApplication::applicationDirPath()));
 

+ 2 - 0
Applications/ctkCommandLineModuleExplorer/target_libraries.cmake

@@ -6,6 +6,8 @@
 
 set(target_libraries
   CTKCommandLineModulesFrontendQtGui
+  CTKCommandLineModulesFrontendQtWebKit
   CTKCommandLineModulesBackendLocalProcess
+  CTKCommandLineModulesBackendFunctionPointer
   CTKWidgets
   )

+ 5 - 0
CMakeLists.txt

@@ -451,6 +451,9 @@ ctk_lib_option(Visualization/VTK/Widgets
                
 ctk_lib_option(CommandLineModules/Core
                "Build the Command Line Module core library" OFF)
+               
+ctk_lib_option(CommandLineModules/Frontend/QtWebKit
+               "Build the QtWebKit based Command Line Module front-end" OFF)
 
 ctk_lib_option(CommandLineModules/Frontend/QtGui
                "Build the QtGui based Command Line Module front-end" OFF)
@@ -458,6 +461,8 @@ ctk_lib_option(CommandLineModules/Frontend/QtGui
 ctk_lib_option(CommandLineModules/Backend/LocalProcess
                "Build the Command Line Module back-end for local processes" OFF)
                
+ctk_lib_option(CommandLineModules/Backend/FunctionPointer
+               "Build the Command Line Module back-end for function pointers" OFF)
 
 #ctk_lib_option(Visualization/XIP
 #               "Build the XIP library" OFF)

+ 67 - 0
Libs/CommandLineModules/Backend/FunctionPointer/CMakeLists.txt

@@ -0,0 +1,67 @@
+project(CTKCommandLineModulesBackendFunctionPointer)
+
+#
+# 3rd party dependencies
+#
+
+#
+# See CTK/CMake/ctkMacroBuildLib.cmake for details
+#
+
+set(KIT_export_directive "CTK_CMDLINEMODULEBACKENDFP_EXPORT")
+
+# Additional directories to include
+
+# Source files
+set(KIT_SRCS
+  ctkCmdLineModuleBackendFPTypeTraits.h
+  ctkCmdLineModuleBackendFPUtil.cpp
+  ctkCmdLineModuleBackendFPUtil_p.h
+  ctkCmdLineModuleBackendFunctionPointer.cpp
+  ctkCmdLineModuleBackendFPDescriptionPrivate.cpp
+  ctkCmdLineModuleFunctionPointerTask.cpp
+  ctkCmdLineModuleFunctionPointerTask_p.h
+)
+
+# Headers that should run through moc
+set(KIT_MOC_SRCS
+)
+
+# UI files
+set(KIT_UI_FORMS
+)
+
+# Resources
+set(KIT_resources
+)
+
+# Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkFunctionGetTargetLibraries(KIT_target_libraries)
+
+ctkMacroBuildLib(
+  NAME ${PROJECT_NAME}
+  EXPORT_DIRECTIVE ${KIT_export_directive}
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+  )
+
+target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
+
+if(CTK_WRAP_PYTHONQT_FULL OR CTK_WRAP_PYTHONQT_LIGHT)
+  ctkMacroBuildLibWrapper(
+    TARGET ${PROJECT_NAME}
+    SRCS ${KIT_SRCS}
+    WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+    )
+endif()
+
+# Testing
+if(BUILD_TESTING)
+  #add_subdirectory(Testing)
+endif()

+ 45 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPDescriptionPrivate.cpp

@@ -0,0 +1,45 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleBackendFPDescriptionPrivate.h"
+
+QString ctkCmdLineModuleBackendFunctionPointer::DescriptionPrivate::xmlDescription() const
+{
+  QString xml;
+  QTextStream str(&xml);
+  str << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
+  str << "<executable>\n";
+  str << "  <category>" + ModuleCategory + "</category>\n";
+  str << "  <title>" + ModuleTitle + "</title>\n";
+  str << "  <description>" + ModuleDescription + "</description>\n";
+  str << "  <contributor>" + ModuleContributor + "</contributor>\n";
+  str << "  <parameters>\n";
+  str << "    <label>Function Parameters</label>\n";
+  str << "    <description>Parameters for calling a function pointer.</description>\n";
+  foreach (QString param, paramDescriptions)
+  {
+    str << param;
+  }
+  str << "  </parameters>\n";
+  str << "</executable>\n";
+
+  return xml;
+}

+ 47 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPDescriptionPrivate.h

@@ -0,0 +1,47 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEBACKENDFUNCTIONPOINTERDESCRIPTIONPRIVATE_H
+#define CTKCMDLINEMODULEBACKENDFUNCTIONPOINTERDESCRIPTIONPRIVATE_H
+
+#include "ctkCmdLineModuleBackendFunctionPointer.h"
+
+#include "ctkCmdLineModuleBackendFPUtil_p.h"
+
+class ctkCmdLineModuleBackendFunctionPointer::DescriptionPrivate : public QSharedData
+{
+public:
+
+  QString xmlDescription() const;
+
+  QUrl ModuleLocation;
+  QString ModuleCategory;
+  QString ModuleTitle;
+  QString ModuleDescription;
+  QString ModuleVersion;
+  QString ModuleContributor;
+
+  ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy FpProxy;
+
+  QList<QString> paramDescriptions;
+};
+
+#endif // CTKCMDLINEMODULEBACKENDFUNCTIONPOINTERDESCRIPTIONPRIVATE_H

+ 94 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPTypeTraits.h

@@ -0,0 +1,94 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H
+#define CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H
+
+namespace ctk {
+namespace CmdLineModuleBackendFunctionPointer {
+
+struct NullType {};
+
+template<bool flag, typename T, typename U>
+struct Select
+{
+  typedef T Result;
+};
+
+template<typename T, typename U>
+struct Select<false, T, U>
+{
+  typedef U Result;
+};
+
+template<typename T>
+class TypeTraits
+{
+private:
+
+  template<class U> struct PointerTraits
+  {
+    enum { result = false };
+    typedef NullType PointeeType;
+  };
+  template<class U> struct PointerTraits<U*>
+  {
+    enum { result = true };
+    typedef U PointeeType;
+  };
+  template<class U> struct ReferenceTraits
+  {
+    enum { result = false };
+    typedef NullType ReferenceType;
+  };
+  template<class U> struct ReferenceTraits<U&>
+  {
+    enum { result = true };
+    typedef U ReferenceType;
+  };
+
+  template<class U> struct UnConst
+  {
+    typedef U Result;
+  };
+  template<class U> struct UnConst<const U>
+  {
+    typedef U Result;
+  };
+
+public:
+
+  typedef typename PointerTraits<T>::PointeeType PointeeType;
+  typedef typename ReferenceTraits<T>::ReferenceType ReferenceType;
+
+  enum { isPointer = PointerTraits<T>::result };
+  enum { isReference = ReferenceTraits<T>::result };
+
+  typedef typename Select<isPointer, typename UnConst<PointeeType>::Result,
+                                     typename Select<isReference, typename UnConst<ReferenceType>::Result, typename UnConst<T>::Result>::Result >::Result RawType;
+};
+
+
+}
+}
+
+
+#endif // CTKCMDLINEMODULEBACKENDFPTYPETRAITS_H

+ 60 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPUtil.cpp

@@ -0,0 +1,60 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleBackendFPUtil_p.h"
+
+
+namespace ctk {
+namespace CmdLineModuleBackendFunctionPointer {
+
+FunctionPointerHolderBase::~FunctionPointerHolderBase()
+{
+}
+
+
+FunctionPointerProxy::FunctionPointerProxy()
+  : FpHolder(NULL)
+{}
+
+FunctionPointerProxy::~FunctionPointerProxy()
+{
+  delete FpHolder;
+}
+
+FunctionPointerProxy::FunctionPointerProxy(const FunctionPointerProxy& other)
+  : FpHolder(other.FpHolder->clone())
+{
+}
+
+FunctionPointerProxy& FunctionPointerProxy::operator=(const FunctionPointerProxy& other)
+{
+  delete this->FpHolder;
+  this->FpHolder = other.FpHolder->clone();
+  return *this;
+}
+
+void FunctionPointerProxy::call(const QList<QVariant> &args)
+{
+  FpHolder->call(args);
+}
+
+}
+}

+ 115 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFPUtil_p.h

@@ -0,0 +1,115 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEBACKENDFPUTIL_P_H
+#define CTKCMDLINEMODULEBACKENDFPUTIL_P_H
+
+#include <QVariant>
+
+class ctkCmdLineModuleBackendFunctionPointer;
+
+namespace ctk {
+namespace CmdLineModuleBackendFunctionPointer {
+
+struct FunctionPointerHolderBase
+{
+  virtual ~FunctionPointerHolderBase();
+
+  virtual FunctionPointerHolderBase* clone() const = 0;
+
+  virtual void call(const QList<QVariant>& args) = 0;
+};
+
+
+template<typename A>
+struct FunctionPointerHolder : public FunctionPointerHolderBase
+{
+  typedef void (*FunctionPointerType)(A);
+
+  FunctionPointerHolder(FunctionPointerType fp) : Fp(fp) {}
+
+  FunctionPointerHolderBase* clone() const
+  {
+    return new FunctionPointerHolder(*this);
+  }
+
+  void call(const QList<QVariant>& args)
+  {
+    Q_ASSERT(args.size() > 0);
+    Q_ASSERT(args.at(0).canConvert<A>());
+    Fp(args.at(0).value<A>());
+  }
+
+  FunctionPointerType Fp;
+};
+
+template<typename A, typename B>
+struct FunctionPointerHolder2 : public FunctionPointerHolderBase
+{
+  typedef void (*FunctionPointerType)(A,B);
+
+  FunctionPointerHolder2(FunctionPointerType fp) : Fp(fp) {}
+
+  FunctionPointerHolderBase* clone() const
+  {
+    return new FunctionPointerHolder2(*this);
+  }
+
+  void call(const QList<QVariant>& args)
+  {
+    Q_ASSERT(args.size() > 1);
+    Q_ASSERT(args.at(0).canConvert<A>());
+    Q_ASSERT(args.at(1).canConvert<B>());
+    Fp(args.at(0).value<A>(), args.at(1).value<B>());
+  }
+
+  FunctionPointerType Fp;
+};
+
+struct FunctionPointerProxy
+{
+  FunctionPointerProxy();
+  ~FunctionPointerProxy();
+
+  FunctionPointerProxy(const FunctionPointerProxy& other);
+  FunctionPointerProxy& operator=(const FunctionPointerProxy& other);
+
+  template<typename A>
+  FunctionPointerProxy(void (*fp)(A))
+    : FpHolder(new FunctionPointerHolder<A>(fp)) {}
+
+  template<typename A, typename B>
+  FunctionPointerProxy(void (*fp)(A,B))
+    : FpHolder(new FunctionPointerHolder2<A,B>(fp)) {}
+
+  void call(const QList<QVariant>& args);
+
+private:
+
+  friend class ::ctkCmdLineModuleBackendFunctionPointer;
+
+  FunctionPointerHolderBase* FpHolder;
+};
+
+}
+}
+
+#endif // CTKCMDLINEMODULEBACKENDFPUTIL_P_H

+ 212 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFunctionPointer.cpp

@@ -0,0 +1,212 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleBackendFunctionPointer.h"
+
+#include "ctkCmdLineModuleBackendFPUtil_p.h"
+#include "ctkCmdLineModuleBackendFPDescriptionPrivate.h"
+#include "ctkCmdLineModuleFunctionPointerTask_p.h"
+
+#include "ctkCmdLineModuleFuture.h"
+#include "ctkCmdLineModuleFrontend.h"
+
+#include <QByteArray>
+#include <QString>
+#include <QList>
+#include <QHash>
+#include <QUrl>
+
+namespace ctk {
+namespace CmdLineModuleBackendFunctionPointer {
+
+template<>
+CTK_CMDLINEMODULEBACKENDFP_EXPORT QString GetParameterTypeName<int>()
+{
+  return "integer";
+}
+
+template<>
+CTK_CMDLINEMODULEBACKENDFP_EXPORT QString GetParameterTypeName<QList<int> >()
+{
+  return "integer-vector";
+}
+
+}
+}
+
+void CalculateFibonacciNumbers(int level) //, QList<int>* result)
+{
+  qDebug() << "Number: 0";
+  if (level > 0)
+  {
+    sleep(1);
+    qDebug() << "Number: 1";
+    if (level == 1) return;
+  }
+
+  int first = 0;
+  int second = 1;
+  for (int i = 1; i < level; ++i)
+  {
+    int tmp = first;
+    first = second;
+    second = first + tmp;
+    sleep(1);
+    qDebug() << "Number:" << second;
+  }
+}
+
+ctkCmdLineModuleBackendFunctionPointer::Description::Description()
+  : d(new ctkCmdLineModuleBackendFunctionPointer::DescriptionPrivate)
+{
+}
+
+ctkCmdLineModuleBackendFunctionPointer::Description::~Description()
+{
+}
+
+QUrl ctkCmdLineModuleBackendFunctionPointer::Description::moduleLocation() const
+{
+  return d->ModuleLocation;
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::Description::moduleCategory() const
+{
+  return d->ModuleCategory;
+}
+
+void ctkCmdLineModuleBackendFunctionPointer::Description::setModuleCategory(const QString& category)
+{
+  d->ModuleCategory = category;
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::Description::moduleTitle() const
+{
+  return d->ModuleTitle;
+}
+
+void ctkCmdLineModuleBackendFunctionPointer::Description::setModuleTitle(const QString &title)
+{
+  d->ModuleTitle = title;
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::Description::moduleDescription() const
+{
+  return d->ModuleDescription;
+}
+
+void ctkCmdLineModuleBackendFunctionPointer::Description::setModuleDescription(const QString &description)
+{
+  d->ModuleDescription = description;
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::Description::moduleVersion() const
+{
+  return d->ModuleVersion;
+}
+
+void ctkCmdLineModuleBackendFunctionPointer::Description::setModuleVersion(const QString &version)
+{
+  d->ModuleVersion = version;
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::Description::moduleContributor() const
+{
+  return d->ModuleContributor;
+}
+
+void ctkCmdLineModuleBackendFunctionPointer::Description::setModuleContributor(const QString &contributor)
+{
+  d->ModuleContributor = contributor;
+}
+
+ctkCmdLineModuleBackendFunctionPointer::Description::Description(const QUrl &location,
+                                                                 const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy &fpProxy)
+  : d(new ctkCmdLineModuleBackendFunctionPointer::DescriptionPrivate)
+{
+  d->ModuleLocation = location;
+  d->FpProxy = fpProxy;
+}
+
+struct ctkCmdLineModuleBackendFunctionPointerPrivate
+{
+  QHash<QUrl, ctkCmdLineModuleBackendFunctionPointer::Description> UrlToFpDescription;
+};
+
+ctkCmdLineModuleBackendFunctionPointer::ctkCmdLineModuleBackendFunctionPointer()
+  : d(new ctkCmdLineModuleBackendFunctionPointerPrivate)
+{
+  this->registerFunctionPointer("Fibonacci Number", CalculateFibonacciNumbers, "Count");
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::name() const
+{
+  return "Function Pointer (experimental)";
+}
+
+QString ctkCmdLineModuleBackendFunctionPointer::description() const
+{
+  return "Calls a previously registered function pointer.";
+}
+
+QList<QString> ctkCmdLineModuleBackendFunctionPointer::schemes() const
+{
+  static QList<QString> supportedSchemes = QList<QString>() << "fp";
+  return supportedSchemes;
+}
+
+QByteArray ctkCmdLineModuleBackendFunctionPointer::rawXmlDescription(const QUrl& location)
+{
+  if (!d->UrlToFpDescription.contains(location)) return QByteArray();
+  return QByteArray(qPrintable(d->UrlToFpDescription[location].d->xmlDescription()));
+}
+
+ctkCmdLineModuleFuture ctkCmdLineModuleBackendFunctionPointer::run(ctkCmdLineModuleFrontend *frontend)
+{
+  QUrl url = frontend->location();
+
+  const Description& descr = d->UrlToFpDescription[url];
+  QList<QVariant> args = frontend->values().values();
+
+  // Instances of ctkCmdLineModuleFunctionPointerTask are auto-deleted by the
+  // thread pool
+  ctkCmdLineModuleFunctionPointerTask* fpTask = new ctkCmdLineModuleFunctionPointerTask(descr, args);
+  return fpTask->start();
+}
+
+QList<QUrl> ctkCmdLineModuleBackendFunctionPointer::registeredFunctionPointers() const
+{
+  return d->UrlToFpDescription.keys();
+}
+
+ctkCmdLineModuleBackendFunctionPointer::Description*
+ctkCmdLineModuleBackendFunctionPointer::registerFunctionPointerProxy(const QString& title,
+                                                                     const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy& proxy,
+                                                                     const QList<QString>& params)
+{
+  QUrl url(QString("fp://0x%1").arg(reinterpret_cast<quintptr>(proxy.FpHolder)));
+  d->UrlToFpDescription[url] = Description(url, proxy);
+
+  Description& fpDescr = d->UrlToFpDescription[url];
+  fpDescr.setModuleTitle(title);
+  fpDescr.d->paramDescriptions = params;
+  return &fpDescr;
+}

+ 153 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleBackendFunctionPointer.h

@@ -0,0 +1,153 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEBACKENDFUNCTIONPOINTER_H
+#define CTKCMDLINEMODULEBACKENDFUNCTIONPOINTER_H
+
+#include "ctkCmdLineModuleBackend.h"
+
+#include "ctkCommandLineModulesBackendFunctionPointerExport.h"
+#include "ctkCmdLineModuleBackendFPTypeTraits.h"
+
+#include <QScopedPointer>
+#include <QSharedPointer>
+#include <QString>
+#include <QUrl>
+#include <QMetaType>
+
+#include <QDebug>
+
+
+namespace ctk {
+namespace CmdLineModuleBackendFunctionPointer {
+
+struct FunctionPointerProxy;
+
+template<typename T>
+QString GetParameterTypeName();
+
+}
+}
+
+Q_DECLARE_METATYPE(QList<int>*)
+
+struct ctkCmdLineModuleBackendFunctionPointerPrivate;
+
+class CTK_CMDLINEMODULEBACKENDFP_EXPORT ctkCmdLineModuleBackendFunctionPointer : public ctkCmdLineModuleBackend
+{
+
+public:
+
+  class DescriptionPrivate;
+
+  class Description
+  {
+  public:
+
+    Description();
+    ~Description();
+
+    QUrl moduleLocation() const;
+
+    QString moduleCategory() const;
+    void setModuleCategory(const QString &category);
+
+    QString moduleTitle() const;
+    void setModuleTitle(const QString& title);
+
+    QString moduleDescription() const;
+    void setModuleDescription(const QString& description);
+
+    QString moduleVersion() const;
+    void setModuleVersion(const QString& version);
+
+    QString moduleContributor() const;
+    void setModuleContributor(const QString& contributor);
+
+  private:
+
+    friend class ctkCmdLineModuleBackendFunctionPointer;
+    friend class ctkCmdLineModuleFunctionPointerTask;
+    Description(const QUrl& location, const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy& fpProxy);
+
+    QSharedPointer<DescriptionPrivate> d;
+
+  };
+
+  ctkCmdLineModuleBackendFunctionPointer();
+
+  virtual QString name() const;
+  virtual QString description() const;
+
+  virtual QList<QString> schemes() const;
+
+  virtual QByteArray rawXmlDescription(const QUrl& location);
+
+  virtual ctkCmdLineModuleFuture run(ctkCmdLineModuleFrontend *frontend);
+
+  QList<QUrl> registeredFunctionPointers() const;
+
+  template<typename A>
+  Description* registerFunctionPointer(const QString& title, void (*fp)(A),
+                                       const QString& paramLabel = QString(), const QString& paramDescr = QString())
+  {
+    QList<QString> params;
+    params << CreateXmlForParameter<A>(0, paramLabel, paramDescr);
+    return this->registerFunctionPointerProxy(title, ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy(fp), params);
+  }
+
+  template<typename A, typename B>
+  Description* registerFunctionPointer(const QString& title, void (*fp)(A,B),
+                                       const QString& paramLabel0 = QString(), const QString& paramDescr0 = QString(),
+                                       const QString& paramLabel1 = QString(), const QString& paramDescr1 = QString())
+  {
+    QList<QString> params;
+    params << CreateXmlForParameter<A>(0, paramLabel0, paramDescr0);
+    params << CreateXmlForParameter<B>(1, paramLabel1, paramDescr1);
+    return this->registerFunctionPointerProxy(title, ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy(fp), params);
+  }
+
+private:
+
+  Description* registerFunctionPointerProxy(const QString &title,
+                                            const ctk::CmdLineModuleBackendFunctionPointer::FunctionPointerProxy& proxy,
+                                            const QList<QString>& params);
+
+  template<typename T>
+  QString CreateXmlForParameter(int index, const QString& label = QString(), const QString& description = QString())
+  {
+    QString xmlParameter;
+    QTextStream str(&xmlParameter);
+    QString typeName = ctk::CmdLineModuleBackendFunctionPointer::GetParameterTypeName<typename ctk::CmdLineModuleBackendFunctionPointer::TypeTraits<T>::RawType>();
+    str << "    <" << typeName << ">\n";
+    str << "      <name>" << QString("param%1").arg(index) << "</name>\n";
+    str << "      <index>" << index << "</index>\n";
+    str << "      <description>" << (description.isEmpty() ? "Description not available." : description) << "</description>\n";
+    str << "      <label>" << (label.isEmpty() ? QString("Parameter %1").arg(index) : label) << "</label>\n";
+    str << "    </" << typeName << ">\n";
+    return xmlParameter;
+  }
+
+  QScopedPointer<ctkCmdLineModuleBackendFunctionPointerPrivate> d;
+
+};
+
+#endif // CTKCMDLINEMODULEBACKENDFUNCTIONPOINTER_H

+ 78 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleFunctionPointerTask.cpp

@@ -0,0 +1,78 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleFunctionPointerTask_p.h"
+
+#include "ctkCmdLineModuleBackendFPDescriptionPrivate.h"
+
+#include "ctkCmdLineModuleFuture.h"
+#include "ctkCmdLineModuleRunException.h"
+
+ctkCmdLineModuleFunctionPointerTask::ctkCmdLineModuleFunctionPointerTask(const ctkCmdLineModuleBackendFunctionPointer::Description &fpDescr, const QList<QVariant> &paramValues)
+  : FpDescription(fpDescr)
+  , ParamValues(paramValues)
+{
+}
+
+ctkCmdLineModuleFuture ctkCmdLineModuleFunctionPointerTask::start()
+{
+  this->setRunnable(this);
+  this->setProgressRange(0,0);
+  this->reportStarted();
+  ctkCmdLineModuleFuture future = this->future();
+  QThreadPool::globalInstance()->start(this, /*m_priority*/ 0);
+  return future;
+}
+
+void ctkCmdLineModuleFunctionPointerTask::run()
+{
+  if (this->isCanceled())
+  {
+    this->reportFinished();
+    return;
+  }
+
+  // call the function pointer and catch any exceptions
+  QString excMsg;
+  try
+  {
+    FpDescription.d->FpProxy.call(ParamValues);
+  }
+  catch (const std::exception& e)
+  {
+    excMsg = e.what();
+  }
+  catch (...)
+  {
+    excMsg = "Unknown exception.";
+  }
+
+  if (!excMsg.isNull())
+  {
+    this->reportException(ctkCmdLineModuleRunException(FpDescription.moduleLocation(), 0, excMsg));
+  }
+
+  this->setProgressRange(0,1);
+  this->setProgressValue(1);
+
+  //this->reportResult(result);
+  this->reportFinished();
+}

+ 47 - 0
Libs/CommandLineModules/Backend/FunctionPointer/ctkCmdLineModuleFunctionPointerTask_p.h

@@ -0,0 +1,47 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEFUNCTIONPOINTERTASK_P_H
+#define CTKCMDLINEMODULEFUNCTIONPOINTERTASK_P_H
+
+#include "ctkCmdLineModuleFutureInterface.h"
+
+#include "ctkCmdLineModuleBackendFunctionPointer.h"
+
+#include <QRunnable>
+
+class ctkCmdLineModuleFunctionPointerTask : public ctkCmdLineModuleFutureInterface, public QRunnable
+{
+public:
+
+  ctkCmdLineModuleFunctionPointerTask(const ctkCmdLineModuleBackendFunctionPointer::Description& fpDescr, const QList<QVariant>& paramValues);
+
+  ctkCmdLineModuleFuture start();
+
+  void run();
+
+private:
+
+  ctkCmdLineModuleBackendFunctionPointer::Description FpDescription;
+  QList<QVariant> ParamValues;
+};
+
+#endif // CTKCMDLINEMODULEFUNCTIONPOINTERTASK_P_H

+ 9 - 0
Libs/CommandLineModules/Backend/FunctionPointer/target_libraries.cmake

@@ -0,0 +1,9 @@
+#
+# See CMake/ctkMacroGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK libraries
+#
+
+set(target_libraries
+  CTKCommandLineModulesCore
+  )

+ 66 - 0
Libs/CommandLineModules/Frontend/QtWebKit/CMakeLists.txt

@@ -0,0 +1,66 @@
+project(CTKCommandLineModulesFrontendQtWebKit)
+
+#
+# 3rd party dependencies
+#
+
+#
+# See CTK/CMake/ctkMacroBuildLib.cmake for details
+#
+
+set(KIT_export_directive "CTK_CMDLINEMODULEQTWEBKIT_EXPORT")
+
+# Additional directories to include
+
+# Source files
+set(KIT_SRCS
+  ctkCmdLineModuleFrontendFactoryQtWebKit.cpp
+  ctkCmdLineModuleFrontendQtWebKit.cpp
+)
+
+# Headers that should run through moc
+set(KIT_MOC_SRCS
+)
+
+# UI files
+set(KIT_UI_FORMS
+)
+
+# Resources
+set(KIT_resources
+  Resources/ctkCmdLineModulesFrontendQtWebKit.qrc
+)
+
+set(QT_USE_QTWEBKIT 1)
+include(${QT_USE_FILE})
+
+# Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkFunctionGetTargetLibraries(KIT_target_libraries)
+
+ctkMacroBuildLib(
+  NAME ${PROJECT_NAME}
+  EXPORT_DIRECTIVE ${KIT_export_directive}
+  INCLUDE_DIRECTORIES ${KIT_include_directories}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+  )
+
+target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES})
+
+if(CTK_WRAP_PYTHONQT_FULL OR CTK_WRAP_PYTHONQT_LIGHT)
+  ctkMacroBuildLibWrapper(
+    TARGET ${PROJECT_NAME}
+    SRCS ${KIT_SRCS}
+    WRAPPER_LIBRARY_TYPE ${CTK_LIBRARY_MODE}
+    )
+endif()
+
+# Testing
+if(BUILD_TESTING)
+#  add_subdirectory(Testing)
+endif()

+ 203 - 0
Libs/CommandLineModules/Frontend/QtWebKit/Resources/ctkCmdLineModuleXmlToPlainHtml.xsl

@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0" 
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xmlns:fn="http://www.w3.org/2005/xpath-functions"
+  xmlns:xdt="http://www.w3.org/2005/xpath-datatypes"
+  xmlns:err="http://www.w3.org/2005/xqt-errors"
+  xmlns:ctk="http://www.commontk.org"
+  exclude-result-prefixes="xs xdt err fn">
+
+  <xsl:output method="xhtml" indent="yes"/>
+
+  <!--
+  ===================================================================
+    Utility XSLT 2.0 functions
+  ===================================================================
+  -->
+
+  <!-- Map xml parameter element names (types) to a class attribute. -->
+  <xsl:function name="ctk:mapTypeToXmlClass">
+    <xsl:param name="cliType"/>
+    <xsl:choose>
+      <xsl:when test="$cliType='boolean'">bool</xsl:when>
+      <xsl:when test="$cliType='integer'">number</xsl:when>
+      <xsl:when test="$cliType='float'">double</xsl:when>
+      <xsl:when test="$cliType=('point', 'region', 'image', 'file', 'directory', 'geometry', 'integer-vector', 'double-vector', 'float-vector', 'string-vector', 'integer-enumeration', 'double-enumeration', 'float-enumeration', 'string-enumeration')">string</xsl:when>
+      <xsl:otherwise><xsl:value-of select="$cliType"/></xsl:otherwise>
+    </xsl:choose>
+  </xsl:function>
+
+  <!-- Map xml parameter element names (types) to the Qt widget property containing
+       the current value. The property value type should match the (Qt) C++ type
+       (or be convertible to it). -->
+  <xsl:function name="ctk:mapTypeToQtValueProperty">
+    <xsl:param name="cliType"/>
+    <xsl:choose>
+      <xsl:when test="$cliType='boolean'">checked</xsl:when>
+      <xsl:when test="$cliType= ('point', 'region')">coordinates</xsl:when>
+      <xsl:when test="$cliType= ('image', 'file', 'directory', 'geometry')">currentPath</xsl:when>
+      <xsl:when test="$cliType= ('string', 'integer-vector', 'float-vector', 'double-vector', 'string-vector')">text</xsl:when>
+      <xsl:when test="$cliType= ('integer-enumeration', 'float-enumeration', 'double-enumeration', 'string-enumeration')">currentText</xsl:when>
+      <xsl:otherwise>value</xsl:otherwise>
+    </xsl:choose>
+  </xsl:function>
+
+  <!--
+  ===================================================================
+    Default templates for suppressing output if no more specific template exists
+  ===================================================================
+  -->
+
+  <!-- suppress text and attribute nodes not covered in subsequent template rule -->
+  <xsl:template match="text()|@*"/>
+
+  <!--
+  ===================================================================
+    Utility templates
+  ===================================================================
+  -->
+
+  <xsl:template match="parameters/label">
+    <p><xsl:value-of select="text()"/></p>
+  </xsl:template>
+
+  <!-- Add a tooltip property to a widget -->
+  <xsl:template match="description">
+    <property name="toolTip">
+      <string><xsl:value-of select="text()"/></string>
+    </property>
+  </xsl:template>
+
+  <!-- Set the default value by generating a Qt widget specific property which holds
+       the current value -->
+  <xsl:template match="default">
+    <property name="{ctk:mapTypeToQtValueProperty(name(..))}">
+      <xsl:element name="{ctk:mapTypeToXmlClass(name(..))}"><xsl:value-of select="text()"/></xsl:element>
+    </property>
+  </xsl:template>
+
+  <!-- Set Qt widget (spinbox) specific properties for applying constraints of scalar parameters -->
+  <xsl:template match="constraints/*[name()=('minimum','maximum')]">
+    <property name="{name()}">
+      <xsl:element name="{ctk:mapTypeToXmlClass(name(../..))}"><xsl:value-of select="text()"/></xsl:element>
+    </property>
+  </xsl:template>
+  <xsl:template match="constraints/step">
+    <property name="singleStep">
+      <xsl:element name="{ctk:mapTypeToXmlClass(name(../..))}"><xsl:value-of select="text()"/></xsl:element>
+    </property>
+    <!-- Also add the 'step' information under the original name -->
+    <property name="parameter:step">
+      <string><xsl:value-of select="text()"/></string>
+    </property>
+  </xsl:template>
+
+  <!-- A named template which will be called from each parameter (integer, float, image, etc.) element.
+       It assumes that it will be called from an enclosing Qt grid layout element and adds a label item -->
+  <xsl:template name="gridItemWithLabel">
+    <td><xsl:value-of select="./label"/></td>
+  </xsl:template>
+
+  <!-- A named template for adding properties common to all Qt widgets -->
+  <xsl:template name="commonWidgetProperties">
+    <xsl:apply-templates select="description"/> <!-- tooltip -->
+    <xsl:if test="@hidden='true'"> <!-- widget visibility -->
+      <property  name="visible">
+        <bool>false</bool>
+      </property>
+    </xsl:if>
+    <property name="parameter:valueProperty"> <!-- property name containing current value -->
+      <string><xsl:value-of select="ctk:mapTypeToQtValueProperty(name())"/></string>
+    </property>
+
+    <!-- add additional (optional) information as properties -->
+    <xsl:apply-templates select="default"/>
+  </xsl:template>
+
+  <!--
+  ===================================================================
+    Match elements from the XML description
+  ===================================================================
+  -->
+  <!-- start matching at 'executable' element -->
+  <xsl:template match="/executable">
+    <xsl:variable name="moduleTitle"><xsl:value-of select="title"/></xsl:variable>
+    <html>
+      <head>
+        <title><xsl:value-of select="title"/></title>
+      </head>
+      <body>
+        <form>
+        <div class="executable">
+          <!-- This will generate DIV elements with the specific widgets -->
+          <xsl:apply-templates select="parameters"/>
+        </div>
+        </form>
+      </body>
+    </html>
+  </xsl:template>
+
+  <!--
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    Parameters
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  -->
+  <!-- Match the 'parameters' element and create the parameter groups (QGroupBox) -->
+  <xsl:template match="parameters">
+    <xsl:variable name="groupLabel"><xsl:value-of select="label"/></xsl:variable>
+    <div class="parameters">
+      <xsl:apply-templates select="./label"/>
+      <xsl:apply-templates select="./description"/>
+      <table>
+        <xsl:apply-templates select="./description/following-sibling::*"/>
+      </table>
+    </div>
+  </xsl:template>
+
+  <!--
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    BOOLEAN parameter (default: QCheckbox)
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  -->
+
+  <xsl:template match="parameters/boolean">
+    <tr>
+      <xsl:call-template name="gridItemWithLabel"/>
+      <td><input type="checkbox" name="{name}"/></td>
+    </tr>
+  </xsl:template>
+  
+  <!--
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    IMAGE, FILE, GEOMETRY parameter (default: ctkPathLineEdit)
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  -->
+
+  <xsl:template match="parameters/*[name()=('image', 'file', 'geometry')]">
+    <tr>
+      <xsl:call-template name="gridItemWithLabel"/>
+      <td><input type="file" name="{name}"/></td>
+    </tr>
+  </xsl:template>
+  
+  <!--
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+    DEFAULT
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  -->
+  
+  <xsl:template match="parameters/*" priority="-1">
+    <tr>
+      <xsl:call-template name="gridItemWithLabel"/>
+      <td>
+        <input type="text" name="{name}">
+          <xsl:attribute name="value">
+            <xsl:value-of select="default/text()"/>
+          </xsl:attribute>
+        </input>
+      </td>
+    </tr>
+  </xsl:template>
+
+</xsl:stylesheet>

+ 5 - 0
Libs/CommandLineModules/Frontend/QtWebKit/Resources/ctkCmdLineModulesFrontendQtWebKit.qrc

@@ -0,0 +1,5 @@
+<RCC>
+    <qresource prefix="/">
+        <file>ctkCmdLineModuleXmlToPlainHtml.xsl</file>
+    </qresource>
+</RCC>

+ 78 - 0
Libs/CommandLineModules/Frontend/QtWebKit/Resources/result.html

@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?><html xmlns:ctk="http://www.commontk.org">
+   <head>
+      <title>2D Blurring</title>
+   </head>
+   <body>
+      <form>
+         <div class="executable">
+            <div class="parameters">
+               <p>Scalar Parameters</p>
+               <property name="toolTip">
+                  <string>
+                     Variations on scalar parameters
+                     
+                  </string>
+               </property>
+               <table>
+                  <tr>
+                     <td>Integer Parameter</td>
+                     <td>
+                        <input type="text"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>Boolean Parameter</td>
+                     <td>
+                        <input type="checkbox"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>Some file</td>
+                     <td>
+                        <input type="file"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>Some dir</td>
+                     <td>
+                        <input type="text"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>Some geom</td>
+                     <td>
+                        <input type="file"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>Double Parameter</td>
+                     <td>
+                        <input type="text"></input>
+                     </td>
+                  </tr>
+               </table>
+            </div>
+            <div class="parameters">
+               <p>Vector Parameters</p>
+               <property name="toolTip">
+                  <string>Variations on vector parameters</string>
+               </property>
+               <table>
+                  <tr>
+                     <td>Float Vector Parameter</td>
+                     <td>
+                        <input type="text"></input>
+                     </td>
+                  </tr>
+                  <tr>
+                     <td>String Vector Parameter</td>
+                     <td>
+                        <input type="text"></input>
+                     </td>
+                  </tr>
+               </table>
+            </div>
+         </div>
+      </form>
+   </body>
+</html>

+ 39 - 0
Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendFactoryQtWebKit.cpp

@@ -0,0 +1,39 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleFrontendFactoryQtWebKit.h"
+
+
+ctkCmdLineModuleFrontendQtWebKit *ctkCmdLineModuleFrontendFactoryQtWebKit::create(const ctkCmdLineModuleReference &moduleRef)
+{
+  return new ctkCmdLineModuleFrontendQtWebKit(moduleRef);
+}
+
+
+QString ctkCmdLineModuleFrontendFactoryQtWebKit::name() const
+{
+  return "Qt WebKit (experimental)";
+}
+
+QString ctkCmdLineModuleFrontendFactoryQtWebKit::description() const
+{
+  return "An experimental frontend using the QtWebKit library.";
+}

+ 41 - 0
Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendFactoryQtWebKit.h

@@ -0,0 +1,41 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEFRONTENDFACTORYQTWEBKIT_H
+#define CTKCMDLINEMODULEFRONTENDFACTORYQTWEBKIT_H
+
+#include "ctkCommandLineModulesFrontendQtWebKitExport.h"
+
+#include "ctkCmdLineModuleFrontendFactory.h"
+#include "ctkCmdLineModuleFrontendQtWebKit.h"
+
+class CTK_CMDLINEMODULEQTWEBKIT_EXPORT ctkCmdLineModuleFrontendFactoryQtWebKit : public ctkCmdLineModuleFrontendFactory
+{
+
+public:
+
+  virtual QString name() const;
+  virtual QString description() const;
+
+  virtual ctkCmdLineModuleFrontendQtWebKit* create(const ctkCmdLineModuleReference& moduleRef);
+};
+
+#endif // CTKCMDLINEMODULEFRONTENDFACTORYQTWEBKIT_H

+ 87 - 0
Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendQtWebKit.cpp

@@ -0,0 +1,87 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#include "ctkCmdLineModuleFrontendQtWebKit.h"
+
+#include "ctkCmdLineModuleXslTransform.h"
+#include "ctkCmdLineModuleReference.h"
+
+#include <QWebView>
+#include <QWebFrame>
+#include <QWebElement>
+#include <QBuffer>
+#include <QFile>
+
+#include <QDebug>
+
+ctkCmdLineModuleFrontendQtWebKit::ctkCmdLineModuleFrontendQtWebKit(const ctkCmdLineModuleReference& moduleRef)
+  : ctkCmdLineModuleFrontend(moduleRef)
+  , WebView(NULL)
+{
+
+}
+
+QObject* ctkCmdLineModuleFrontendQtWebKit::guiHandle() const
+{
+  if (WebView) return WebView;
+
+  QBuffer input;
+  input.setData(moduleReference().rawXmlDescription());
+
+  QBuffer htmlOutput;
+  htmlOutput.open(QIODevice::ReadWrite);
+  ctkCmdLineModuleXslTransform xslTransform(&input, &htmlOutput);
+  QFile htmlTransformation(":/ctkCmdLineModuleXmlToPlainHtml.xsl");
+
+  xslTransform.setXslTransformation(&htmlTransformation);
+  if (!xslTransform.transform())
+  {
+    // maybe throw an exception
+    qCritical() << xslTransform.errorString();
+    return 0;
+  }
+
+  this->WebView = new QWebView;
+  QByteArray htmlContent = htmlOutput.readAll();
+  this->WebView->setHtml(htmlContent);
+  return this->WebView;
+}
+
+QVariant ctkCmdLineModuleFrontendQtWebKit::value(const QString &parameter) const
+{
+  QWebElement webElement = this->WebView->page()->currentFrame()->findFirstElement("input[name=" + parameter + "]");
+  if (webElement.isNull()) return QVariant();
+  // Work around bug https://bugs.webkit.org/show_bug.cgi?id=32865 for input elements
+  QVariant value = webElement.evaluateJavaScript("this.value");
+  qDebug() << "Found element" << webElement.tagName() << "with value" << value;
+  return value;
+}
+
+void ctkCmdLineModuleFrontendQtWebKit::setValue(const QString &parameter, const QVariant &value)
+{
+  if (!this->WebView) return;
+
+  QWebElement webElement = this->WebView->page()->currentFrame()->findFirstElement("input[name=" + parameter + "]");
+  if (webElement.isNull()) return;
+
+  // Work around bug https://bugs.webkit.org/show_bug.cgi?id=32865 for input elements
+  webElement.evaluateJavaScript(QString("this.value='%1'").arg(value.toString()));
+}

+ 50 - 0
Libs/CommandLineModules/Frontend/QtWebKit/ctkCmdLineModuleFrontendQtWebKit.h

@@ -0,0 +1,50 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) German Cancer Research Center,
+    Division of Medical and Biological Informatics
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=============================================================================*/
+
+#ifndef CTKCMDLINEMODULEFRONTENDQTWEBKIT_H
+#define CTKCMDLINEMODULEFRONTENDQTWEBKIT_H
+
+#include "ctkCmdLineModuleFrontend.h"
+
+class QWebView;
+
+class ctkCmdLineModuleFrontendQtWebKit : public ctkCmdLineModuleFrontend
+{
+
+public:
+
+  ctkCmdLineModuleFrontendQtWebKit(const ctkCmdLineModuleReference& moduleRef);
+
+  // ctkCmdLineModuleFrontend overrides
+
+  virtual QObject* guiHandle() const;
+
+  virtual QVariant value(const QString& parameter) const;
+  virtual void setValue(const QString& parameter, const QVariant& value);
+
+  //virtual QList<QString> parameterNames() const;
+
+private:
+
+  mutable QWebView* WebView;
+};
+
+#endif // CTKCMDLINEMODULEFRONTENDQTWEBKIT_H

+ 9 - 0
Libs/CommandLineModules/Frontend/QtWebKit/target_libraries.cmake

@@ -0,0 +1,9 @@
+#
+# See CMake/ctkMacroGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK libraries
+#
+
+set(target_libraries
+  CTKCommandLineModulesCore
+)