瀏覽代碼

Cleanup interfaces and make Slicer xsd the default.

Sascha Zelzer 13 年之前
父節點
當前提交
925abc77c0

+ 6 - 6
Applications/ctkCLIPluginExplorer/ctkCLIPluginExplorerMain.cpp

@@ -22,21 +22,21 @@
 // Qt includes
 #include <QCoreApplication>
 #include <QDebug>
+#include <QFile>
 
 // CTK includes
-//#include <ctkPluginManager.h>
+#include <ctkModuleDescription.h>
 
 int main(int argc, char** argv)
 {
   QCoreApplication app(argc, argv);
 
-//  ctkPluginManager pluginManager;
-//  pluginManager.addSearchPath("/home/sascha/git/CTK-bin/CTK-build/bin/Plugins");
-//  pluginManager.startAllPlugins();
+  QIODevice* input = new QFile("/home/sascha/tmp/slicer_md1.xml");
 
-//  qDebug() << "List of services: " <<  pluginManager.serviceManager()->findServices();
+  ctkModuleDescription* descr = ctkModuleDescription::parse(input);
 
-//  QObject* service = pluginManager.serviceManager()->loadInterface("org.commontk.cli.ICLIManager");
+  QTextStream cout(stdout, QIODevice::WriteOnly);
+  cout << *descr;
 
   return 0;
 }

+ 1 - 1
Applications/ctkCLIPluginExplorer/target_libraries.cmake

@@ -5,5 +5,5 @@
 # 
 
 set(target_libraries
-  CTKPluginFramework
+  CTKModuleDescription
   )

+ 4 - 0
CMakeLists.txt

@@ -504,6 +504,10 @@ ctk_app_option(ctkExampleHostedApp
 ctk_app_option(ctkEventBusDemo
                "Build the DICOM example application" OFF
                CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
+
+ctk_app_option(ctkCLIPluginExplorer
+               "Build the Command Line Interface Plugin Explorer" OFF
+               CTK_BUILD_EXAMPLES)
                
 ctk_app_option(ctkPluginBrowser
                "Build the DICOM example application" OFF

+ 24 - 22
Libs/ModuleDescription/CMakeLists.txt

@@ -16,36 +16,32 @@ set(KIT_export_directive "CTK_MODULDESC_EXPORT")
 set(KIT_SRCS
   ctkModuleDescription.h
   ctkModuleDescription.cpp
+  #ctkModuleDescriptionReader.h
+  ctkModuleDescriptionReader.cpp
   ctkModuleParameter.h
   ctkModuleParameter.cpp
   ctkModuleParameterGroup.h
   ctkModuleParameterGroup.cpp
-  ctkModuleParameterGroupValue.h
-  ctkModuleParameterGroupValue.cpp
-  ctkModuleParameterValue.h
-  ctkModuleParameterValue.cpp
-  ctkModuleDescriptionReaderInterface.cpp
-  ctkModuleDescriptionReaderInterface.h
-  ctkModuleDescriptionReader.h
-  ctkModuleDescriptionReader.cpp
-  ctkModuleDescriptionConverterInterface.h
-  ctkModuleDescriptionConverter.h
-  ctkModuleDescriptionConverter.cpp
-  ctkModuleDescriptionExecutionInterface.h
-  ctkModuleDescriptionExecution.h
-  ctkModuleDescriptionExecution.cpp
-  ctkModuleValues.h
-  ctkModuleValues.cpp
+  #ctkModuleParameterGroupValue.h
+  #ctkModuleParameterGroupValue.cpp
+  #ctkModuleParameterValue.h
+  #ctkModuleParameterValue.cpp
+  #ctkModuleDescriptionConverterInterface.h
+  #ctkModuleDescriptionConverter.h
+  #ctkModuleDescriptionConverter.cpp
+  #ctkModuleDescriptionExecutionInterface.h
+  #ctkModuleDescriptionExecution.h
+  #ctkModuleDescriptionExecution.cpp
+  #ctkModuleValues.h
+  #ctkModuleValues.cpp
   )
 
 # Headers that should run through moc
 set(KIT_MOC_SRCS
-  ctkModuleDescriptionReaderInterface.h
-  ctkModuleDescriptionReader.h
-  ctkModuleDescriptionConverterInterface.h
-  ctkModuleDescriptionConverter.h
-  ctkModuleDescriptionExecutionInterface.h
-  ctkModuleDescriptionExecution.h
+  #ctkModuleDescriptionConverterInterface.h
+  #ctkModuleDescriptionConverter.h
+  #ctkModuleDescriptionExecutionInterface.h
+  #ctkModuleDescriptionExecution.h
 )
 
 # UI files
@@ -54,8 +50,12 @@ set(KIT_UI_FORMS
 
 # Resources
 set(KIT_resources
+  Resources/ctkModuleDescription.qrc
 )
 
+set(QT_USE_QTXMLPATTERNS 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)
@@ -72,6 +72,8 @@ ctkMacroBuildLib(
   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}

+ 5 - 0
Libs/ModuleDescription/Resources/ctkModuleDescription.qrc

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

+ 146 - 0
Libs/ModuleDescription/Resources/ctkModuleDescription.xsd

@@ -0,0 +1,146 @@
+<?xml version="1.0"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+    <xsd:element name="executable">
+        <xsd:complexType>
+            <xsd:sequence>
+                <xsd:element name="category" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="index" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="title" type="xsd:string" maxOccurs="1"/>
+                <xsd:element name="description" type="xsd:string" maxOccurs="1"/>
+                <xsd:element name="version" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="documentation-url" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="license" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="contributor" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="acknowledgements" type="xsd:string" minOccurs="0"/>
+                <xsd:element name="parameters" type="parameters" maxOccurs="unbounded"/>
+            </xsd:sequence>
+        </xsd:complexType>
+    </xsd:element>
+
+    <xsd:complexType name="parameters">
+      <xsd:choice minOccurs="0" maxOccurs="unbounded">
+        <xsd:element name="label" type="xsd:string"/>
+        <xsd:element name="description" type="xsd:string"/>
+        <xsd:element name="integer" type="scalarType"/>
+        <xsd:element name="integer-vector" type="scalarType"/>
+        <xsd:element name="boolean" type="scalarType"/>
+        <xsd:element name="boolean-vector" type="scalarType"/>
+        <xsd:element name="float" type="scalarType"/>
+        <xsd:element name="float-vector" type="scalarType"/>
+        <xsd:element name="double" type="scalarType"/>
+        <xsd:element name="double-vector" type="scalarType"/>
+        <xsd:element name="string" type="paramType"/>
+        <xsd:element name="string-vector" type="paramType"/>
+        <xsd:element name="point" type="pointType"/>
+        <xsd:element name="point-vector" type="pointType"/>
+        <xsd:element name="region" type="pointType"/>
+        <xsd:element name="region-vector" type="pointType"/>
+        <xsd:element name="string-enumeration" type="enumerationType"/>
+        <xsd:element name="integer-enumeration" type="enumerationType"/>
+        <xsd:element name="float-enumeration" type="enumerationType"/>
+        <xsd:element name="double-enumeration" type="enumerationType"/>
+        <xsd:element name="file" type="indexedParamType"/>
+        <xsd:element name="directory" type="paramType"/>
+        <xsd:element name="transform" type="typedIndexParamType"/>
+        <xsd:element name="image" type="typedIndexParamType"/>
+        <xsd:element name="geometry" type="typedIndexParamType"/>
+        <xsd:element name="table" type="typedIndexParamType"/>
+        <xsd:element name="measurement" type="typedIndexParamType"/>
+      </xsd:choice>
+    </xsd:complexType>
+
+    <xsd:complexType name="paramType">    
+      <xsd:choice minOccurs="0" maxOccurs="unbounded">
+        <xsd:element name="name" type="xsd:string"/>
+        <xsd:element name="flag" type="flagType" />
+        <xsd:element name="longflag" type="flagType"/>
+        <xsd:element name="description" type="xsd:string"/>
+        <xsd:element name="label" type="xsd:string"/>
+        <xsd:element name="default" type="xsd:string"/>
+      </xsd:choice>
+      <xsd:attribute name="multiple" type="xsd:boolean"/>
+      <xsd:attribute name="hidden" type="xsd:boolean"/>
+    </xsd:complexType>
+    
+    <xsd:complexType name="scalarType" >
+      <xsd:complexContent>
+        <xsd:extension base="paramType">
+          <xsd:sequence>
+            <xsd:element name="constraints" type="constraintsType"  minOccurs="0" />
+          </xsd:sequence>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:complexType name="pointType" >
+      <xsd:complexContent>
+        <xsd:extension base="paramType">
+          <xsd:attribute name="coordinateSystem">
+            <xsd:simpleType>
+              <xsd:restriction base="xsd:string">
+                <xsd:enumeration value="RAS"/>
+                <xsd:enumeration value="IJK"/>
+              </xsd:restriction>
+            </xsd:simpleType>
+          </xsd:attribute>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:complexType name="enumerationType" >
+      <xsd:complexContent>
+        <xsd:extension base="paramType">
+          <xsd:sequence>
+            <xsd:element name="element" type="xsd:string"/>
+          </xsd:sequence>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+
+    <xsd:complexType name="indexedParamType" >
+      <xsd:all>
+        <xsd:element name="name" type="xsd:string"/>
+        <xsd:element name="label" type="xsd:string"/>
+        <xsd:element name="description" type="xsd:string"/>
+        <xsd:element name="channel" maxOccurs="1">
+          <xsd:simpleType>
+            <xsd:restriction base="xsd:string">
+              <xsd:enumeration value="input"/>
+              <xsd:enumeration value="output"/>
+            </xsd:restriction>
+          </xsd:simpleType>
+        </xsd:element>
+        <xsd:element name="index" type="xsd:nonNegativeInteger"/>
+      </xsd:all>
+      <xsd:attribute name="fileExtensions" type="xsd:string"/>
+    </xsd:complexType>
+
+    <xsd:complexType name="typedIndexParamType" >
+      <xsd:complexContent>
+        <xsd:extension base="indexedParamType">
+          <xsd:attribute name="reference" type="xsd:string"/>
+          <xsd:attribute name="type" type="xsd:string"/>
+          <xsd:attribute name="hidden" type="xsd:boolean"/>
+        </xsd:extension>
+      </xsd:complexContent>
+    </xsd:complexType>
+    
+    <xsd:complexType name="flagType">
+      <xsd:simpleContent>
+        <xsd:extension base="xsd:string">
+          <xsd:attribute name="alias" type="xsd:string"/>
+          <xsd:attribute name="deprecatedalias" type="xsd:string"/>
+        </xsd:extension>
+      </xsd:simpleContent>
+    </xsd:complexType>
+    
+    <xsd:complexType name="constraintsType">
+      <xsd:sequence>
+        <xsd:element name="minimum" type="xsd:double"/>
+        <xsd:element name="maximum" type="xsd:double"/>
+        <xsd:element name="step" type="xsd:double"/>
+      </xsd:sequence>
+    </xsd:complexType>
+
+</xsd:schema>

+ 266 - 68
Libs/ModuleDescription/ctkModuleDescription.cpp

@@ -5,7 +5,7 @@ Library: CTK
 Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
+you may not use d file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
@@ -23,87 +23,271 @@ limitations under the License.
 #include "QFile"
 #include "QTextStream"
 
+struct ctkModuleDescriptionPrivate
+{
+  ~ctkModuleDescriptionPrivate()
+  {
+    qDeleteAll(ParameterGroups);
+  }
+
+  QString Title;
+  QString Category;
+  QString Index;
+  QString Description;
+  QString Version;
+  QString DocumentationURL;
+  QString License;
+  QString Acknowledgements;
+  QString Contributor;
+  QString Type;
+  QString Target;
+  QString Location;
+  QString AlternativeType;
+  QString AlternativeTarget;
+  QString AlternativeLocation;
+
+  QIcon Logo;
+
+  QList<ctkModuleParameterGroup*> ParameterGroups;
+
+  //ModuleProcessInformation ProcessInformation;
+};
+
 //----------------------------------------------------------------------------
-void ctkModuleDescription::addParameterGroup( ctkModuleParameterGroup* group )
+ctkModuleDescription::ctkModuleDescription()
+  : d_ptr(new ctkModuleDescriptionPrivate)
 {
-  Q_ASSERT(group);
-	this->ParameterGroups.push_back(group);
 }
 
 //----------------------------------------------------------------------------
-const QVector<ctkModuleParameterGroup*>& ctkModuleDescription::parameterGroups() const
+ctkModuleDescription::~ctkModuleDescription()
 {
-	return this->ParameterGroups;
+  delete d_ptr;
 }
 
+
 //----------------------------------------------------------------------------
-bool ctkModuleDescription::hasReturnParameters() const
+void ctkModuleDescription::setCategory(const QString& cat)
 {
-  // iterate over each parameter group
-  foreach( const ctkModuleParameterGroup* group, this->ParameterGroups)
-    {
-    if (group->hasReturnParameters())
-      {
-      return true;
-      }
-    }
+  Q_D(ctkModuleDescription);
+  d->Category = cat;
+}
 
-  return false;
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::category() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Category;
 }
 
 //----------------------------------------------------------------------------
-bool ctkModuleDescription::setParameterDefaultValue(const QString& name, const QString& value)
+void ctkModuleDescription::setIndex(const QString& ind)
 {
-  ctkModuleParameter* param = this->parameter( name );
-  if ( param )
-    {
-    (*param)[ "Default" ] = value;
-    return true;
-    }
+  Q_D(ctkModuleDescription);
+  d->Index = ind;
+}
 
-  return false;
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::index() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Index;
 }
 
 //----------------------------------------------------------------------------
-ctkModuleParameterGroup* ctkModuleDescription::parameterGroup(const QString& parameterName)const
+void ctkModuleDescription::setTitle(const QString& title)
 {
-  // iterate over each parameter group
-  foreach( ctkModuleParameterGroup* group, this->ParameterGroups)
-    {
-    ctkModuleParameter* param = group->parameter(parameterName);
-    if (param)
-      {
-      return group;
-      }    
-    }
-  return 0;
+  Q_D(ctkModuleDescription);
+  d->Title = title;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::title() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Title;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setDescription(const QString& description)
+{
+  Q_D(ctkModuleDescription);
+  d->Description = description;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::description() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Description;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setVersion(const QString& version)
+{
+  Q_D(ctkModuleDescription);
+  d->Version = version;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::version() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Version;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setDocumentationURL(const QString& documentationURL)
+{
+  Q_D(ctkModuleDescription);
+  d->DocumentationURL = documentationURL;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::documentationURL() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->DocumentationURL;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setLicense(const QString& license)
+{
+  Q_D(ctkModuleDescription);
+  d->License = license;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::license() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->License;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setAcknowledgements(const QString& acknowledgements)
+{
+  Q_D(ctkModuleDescription);
+  d->Acknowledgements = acknowledgements;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::acknowledgements() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Acknowledgements;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setContributor(const QString& contributor)
+{
+  Q_D(ctkModuleDescription);
+  d->Contributor = contributor;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::contributor() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Contributor;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setLocation(const QString& target)
+{
+  Q_D(ctkModuleDescription);
+  d->Location = target;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleDescription::location() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Location;
 }
 
 //----------------------------------------------------------------------------
-ctkModuleParameter* ctkModuleDescription::parameter(const QString& name)const
+void ctkModuleDescription::setLogo(const QIcon& logo)
 {
+  Q_D(ctkModuleDescription);
+  d->Logo = logo;
+}
+
+//----------------------------------------------------------------------------
+QIcon ctkModuleDescription::logo() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->Logo;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::addParameterGroup(ctkModuleParameterGroup* group)
+{
+  Q_D(ctkModuleDescription);
+  d->ParameterGroups.push_back(group);
+}
+
+//----------------------------------------------------------------------------
+QList<ctkModuleParameterGroup*> ctkModuleDescription::parameterGroups() const
+{
+  Q_D(const ctkModuleDescription);
+  return d->ParameterGroups;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleDescription::setParameterGroups(const QList<ctkModuleParameterGroup*>& groups)
+{
+  Q_D(ctkModuleDescription);
+  d->ParameterGroups = groups;
+}
+
+//----------------------------------------------------------------------------
+bool ctkModuleDescription::hasParameter(const QString& name) const
+{
+  Q_D(const ctkModuleDescription);
   // iterate over each parameter group
-  foreach( const ctkModuleParameterGroup* group, this->ParameterGroups)
-    {
+  foreach(const ctkModuleParameterGroup* group, d->ParameterGroups)
+  {
+    if (group->hasParameter(name)) return true;
+  }
+  return false;
+}
+
+//----------------------------------------------------------------------------
+ctkModuleParameter* ctkModuleDescription::parameter(const QString& name) const
+{
+  Q_D(const ctkModuleDescription);
+  foreach(const ctkModuleParameterGroup* group, d->ParameterGroups)
+  {
     ctkModuleParameter* param = group->parameter(name);
-    if (param)
-      {
-      return param;
-      }    
-    }
+    if (param) return param;
+  }
   return 0;
 }
 
 //----------------------------------------------------------------------------
-void ctkModuleDescription ::setIcon(const QIcon& logo)
+bool ctkModuleDescription::hasReturnParameters() const
 {
-  this->Icon = logo;
+  Q_D(const ctkModuleDescription);
+  // iterate over each parameter group
+  foreach(const ctkModuleParameterGroup* group, d->ParameterGroups)
+  {
+    if (group->hasReturnParameters()) return true;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------------
-const QIcon& ctkModuleDescription::icon() const
+bool ctkModuleDescription::setParameterDefaultValue(const QString& name,
+                                                    const QString& value)
 {
-  return this->Icon;
+  ctkModuleParameter* param = parameter(name);
+  if (param)
+  {
+    param->setDefaultValue(value);
+    return true;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------------
@@ -113,14 +297,14 @@ bool ctkModuleDescription ::readParameterFile(const QString& filename)
 
   QFile file(filename);
   if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
-    {
-    std::cout << "Parameter file " << filename.toStdString( ) << " could not be opened." << std::endl;
+  {
+    std::cout << "Parameter file " << filename.toStdString( ) << " could not be opened." << '\n';
     return false;
-    }
+  }
 
   QTextStream in(&file);
   while (!in.atEnd())
-    {
+  {
     QString line = in.readLine();
 
     // split the line into key: value
@@ -130,26 +314,26 @@ bool ctkModuleDescription ::readParameterFile(const QString& filename)
     QStringList list = line.split( "=" );
     key = list[ 0 ].trimmed();
     if ( list.size() == 1 )
-      {
+    {
       continue;
-      }
+    }
     value = list[ 1 ].trimmed();
 
     
     // std::cout << "key=" << key << ", value=" << value << "!" << endl;
 
-    ctkModuleParameter *param = this->parameter( key );
-    if ( param )
+    ctkModuleParameter* param = this->parameter(key);
+    if (param)
+    {
+      if (value != param->defaultValue())
       {
-      if (value != (*param)["Default"] )
-        {
-        (*param)["Default"] = value;
+        param->setDefaultValue(value);
         modified = true;
 
         // multiple="true" may have to be handled differently
-        }
       }
     }
+  }
 
   return modified;
 }
@@ -158,20 +342,22 @@ bool ctkModuleDescription ::readParameterFile(const QString& filename)
 bool ctkModuleDescription::
 writeParameterFile(const QString& filename, bool withHandlesToBulkParameters)const
 {
+  Q_D(const ctkModuleDescription);
+
   QFile rtp(filename);
 
   if (!rtp.open(QIODevice::WriteOnly | QIODevice::Text))
     {
-    std::cout << "Parameter file " << filename.toStdString() << " could not be opened for writing." << std::endl;
+    std::cout << "Parameter file " << filename.toStdString() << " could not be opened for writing." << '\n';
     return false;
     }
 
   QTextStream in(&rtp);
   // iterate over each parameter group
-  foreach(const ctkModuleParameterGroup* group, this->ParameterGroups)
-    {
+  foreach(const ctkModuleParameterGroup* group, d->ParameterGroups)
+  {
     group->writeParameterFile(in, withHandlesToBulkParameters);
-    }
+  }
 
   return true;
 }
@@ -179,14 +365,26 @@ writeParameterFile(const QString& filename, bool withHandlesToBulkParameters)con
 //----------------------------------------------------------------------------
 QTextStream & operator<<(QTextStream &os, const ctkModuleDescription &module)
 {
-  os << QHash<QString, QString>(module);
-  os << "Icon: " << QBool(!module.icon().isNull()) << '\n';
+  os << "Title: " << module.title() << '\n';
+  os << "Category: " << module.category() << '\n';
+  os << "Index: " << module.index() << '\n';
+  os << "Description: " << module.description() << '\n';
+  os << "Version: " << module.version() << '\n';
+  os << "DocumentationURL: " << module.documentationURL() << '\n';
+  os << "License: " << module.license() << '\n';
+  os << "Contributor: " << module.contributor() << '\n';
+  os << "Acknowledgements: " << module.acknowledgements() << '\n';
+  os << "Location: " << module.location() << '\n';
+  //os << "Logo: " << module.GetLogo() << '\n';
+
+  //os << "ProcessInformation: " << '\n'
+  //   << *(module.GetProcessInformation());
 
   os << "ParameterGroups: " << '\n';
-  foreach(const ctkModuleParameterGroup* group, module.ParameterGroups)
-    {
+  foreach(const ctkModuleParameterGroup* group, module.parameterGroups())
+  {
     os << *group;
-    }
+  }
   return os;
 }
 

+ 68 - 36
Libs/ModuleDescription/ctkModuleDescription.h

@@ -21,14 +21,12 @@
 #ifndef __ctkModuleDescription_h
 #define __ctkModuleDescription_h
 
-// Qt includes
-#include <QHash>
 #include <QIcon>
-#include <QVector>
 
-// Module parameter
 #include "ctkModuleParameterGroup.h"
 
+struct ctkModuleDescriptionPrivate;
+
 /**
 * Description of the parameters of a module
 *
@@ -38,41 +36,73 @@
 * For example:
 * - Target: This is the entry point for a shared object module and the full 
 * command (with path) for an executable.
-* - Type: Unknown, SharedObjectModule, CommandLineModule
-* - AlternativeTarget: This is the entry
-* point for a shared object module and the full command (with path)
-* for an executable. The alternative target is used for a second version
-* of a module (whose type differs from the primary target,
-* executable verses shared object).
-* - Location: This is path to the file (shared
-* object or executable) for the module
-* - AlternativeLocation: This is path to the
-* file (shared object or executable) for a second version of the
-* module (usually a different type from the primary).
+* - Location: This is path to the executable for the module
 */
-class CTK_MODULDESC_EXPORT ctkModuleDescription : public QHash<QString, QString>
+class CTK_MODULDESC_EXPORT ctkModuleDescription
 {
+  Q_DECLARE_PRIVATE(ctkModuleDescription)
+
 public:
-  // Optional icon associated to the module
-  void setIcon(const QIcon& logo);
-  const QIcon& icon() const;
-  
+
+  ~ctkModuleDescription();
+
+  static ctkModuleDescription* parse(QIODevice* input);
+
+  void setCategory(const QString& cat);
+  QString category() const;
+
+  void setIndex(const QString& ind);
+  QString index() const;
+
+  void setTitle(const QString& title);
+  QString title() const;
+
+  void setDescription(const QString& description);
+  QString description() const;
+
+  void setVersion(const QString& version);
+  QString version() const;
+
+  void setDocumentationURL(const QString& documentationURL);
+  QString documentationURL() const;
+
+  void setLicense(const QString& license);
+  QString license() const;
+
+  void setAcknowledgements(const QString& acknowledgements);
+  QString acknowledgements() const;
+
+  void setContributor(const QString& contributor);
+  QString contributor() const;
+
+  /// Set the location for the module.  This is path to the file for the module.
+  void setLocation(const QString& target);
+  /// Get the location for the module.  This is path to the file for the module.
+  QString location() const;
+
+  void setLogo(const QIcon& logo);
+  QIcon logo() const;
+
   void addParameterGroup(ctkModuleParameterGroup* group);
+  QList<ctkModuleParameterGroup*> parameterGroups() const;
+  void setParameterGroups(const QList<ctkModuleParameterGroup*>& groups);
+
+  bool hasParameter(const QString& name) const;
+
+  ctkModuleParameter* parameter(const QString& name) const;
 
-  const QVector<ctkModuleParameterGroup*>& parameterGroups() const;
-  
-  // Return the group that contain the parameter associated to the name
-  ctkModuleParameterGroup* parameterGroup(const QString& parameterName) const;
-  // Return the first parameter corresponding to the name from any group
-  ctkModuleParameter* parameter(const QString& parameterName) const;
-  
   // Does the module have any simple (primitive) return types?
   bool hasReturnParameters() const;
 
-  /// TODO: move to ctkModuleParameter
-  bool setParameterDefaultValue(const QString& parameterName,
+  bool setParameterDefaultValue(const QString& name,
                                 const QString& value);
 
+//  const ModuleProcessInformation* processInformation() const
+//  {return &ProcessInformation;}
+
+//  ModuleProcessInformation* processInformation()
+//  {return &ProcessInformation;}
+
   ///
   /// Read a parameter file. Syntax of file is "name: value" for each
   /// parameter. Returns a bool indicating whether any parameter value
@@ -84,16 +114,18 @@ public:
   /// the parameters.  The "withHandlesToBulkParameters" parameter
   /// controls whether the handles to the bulk parameters (image,
   /// geometry, etc.) are written to the file.
-  bool writeParameterFile(const QString& filename, bool withHandlesToBulkParameters = true)const;
+  bool writeParameterFile(const QString& filename, bool withHandlesToBulkParameters = true) const;
 
 private:
-  friend CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleDescription &module);
-  /// Groups of parameters
-  QVector<ctkModuleParameterGroup*> ParameterGroups;
-  /// Icon of the module
-  QIcon Icon;
+
+  ctkModuleDescription();
+
+  Q_DISABLE_COPY(ctkModuleDescription)
+
+  ctkModuleDescriptionPrivate * const d_ptr;
+
 };
 
-CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleDescription &module);
+CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream& os, const ctkModuleDescription& module);
 
 #endif

File diff suppressed because it is too large
+ 1823 - 10
Libs/ModuleDescription/ctkModuleDescriptionReader.cpp


+ 34 - 30
Libs/ModuleDescription/ctkModuleDescriptionReader.h

@@ -1,50 +1,54 @@
 /*=============================================================================
 
-Library: CTK
+  Library: CTK
 
-Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
+  Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
 
-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
+  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
+    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.
+  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 __ctkModuleDescriptionReader_h
-#define __ctkModuleDescriptionReader_h
+#ifndef __ctkSlicerModuleReader_h
+#define __ctkSlicerModuleReader_h
 
-#include "ctkModuleDescriptionExport.h"
-#include "ctkModuleDescriptionReaderInterface.h"
+// Qt includes
+#include <QRegExp>
+#include <QStack>
+#include <QXmlAttributes>
+#include <QXmlDefaultHandler>
 
-class QIODevice;
-/** 
- * \brief Base XML Reader of ModuleDescription
- *
- * This specialized ctkModuleDescriptionReaderInterface can initialize
- * a module description from an XML file. update() must be reimplemented
- * in inherited classes.
+// CTK includes
+#include <ctkModuleDescriptionExport.h>
+
+/**
+ * Reader of default module XML description
+ * Freely inspired from 
+ * Slicer/Libs/SlicerExecutionModel/ModuleDescriptionParser/ModuleDescriptionParser.cxx
  */
-class CTK_MODULDESC_EXPORT ctkModuleDescriptionReader :
-  public ctkModuleDescriptionReaderInterface
+class CTK_MODULDESC_EXPORT ctkModuleDescriptionParser
 {
-  Q_OBJECT
+
 public:
-  ctkModuleDescriptionReader();
 
-  //! xml is the content of the XML file
-  void setInput(QIODevice * device);
-  QIODevice* input()const;
+  void setInput(QIODevice* input);
+
+  void parseDescription();
+
+  ctkModuleDescription* moduleDescription() const;
 
 protected:
-  QIODevice*           Device;
+
+  virtual bool validate() const;
 };
 
 #endif

+ 0 - 28
Libs/ModuleDescription/ctkModuleDescriptionReaderInterface.cpp

@@ -1,28 +0,0 @@
-/*=============================================================================
-
-Library: CTK
-
-Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
-
-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.
-
-=============================================================================*/
-
-// CTK includes
-#include "ctkModuleDescriptionReaderInterface.h"
-
-//-----------------------------------------------------------------------------
-const ctkModuleDescription& ctkModuleDescriptionReaderInterface::moduleDescription()const
-{
-  return this->ModuleDescription;
-}

+ 0 - 51
Libs/ModuleDescription/ctkModuleDescriptionReaderInterface.h

@@ -1,51 +0,0 @@
-/*=============================================================================
-
-Library: CTK
-
-Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
-
-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 __ctkModuleDescriptionReaderInterface_h
-#define __ctkModuleDescriptionReaderInterface_h
-
-// Qt includes
-#include <QObject>
-#include <QString>
-
-// CTK includes
-#include "ctkModuleDescription.h"
-#include "ctkModuleDescriptionExport.h"
-
-/** 
- * \brief Interface of ModuleDescription reader
- */
-class CTK_MODULDESC_EXPORT ctkModuleDescriptionReaderInterface : public QObject
-{
-  Q_OBJECT
-public:
-
-  //!
-  virtual void update( ) = 0;
-
-  //! Returns the populated module description.
-  //! Note: the module description is set after update() is called
-  const ctkModuleDescription &moduleDescription() const;
-
-protected:
-  ctkModuleDescription ModuleDescription;
-};
-
-#endif

+ 527 - 38
Libs/ModuleDescription/ctkModuleParameter.cpp

@@ -5,7 +5,7 @@ Library: CTK
 Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
+you may not use d file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
@@ -21,72 +21,561 @@ limitations under the License.
 #include "ctkModuleParameter.h"
 #include <QStringList>
 
+struct ctkModuleParameterPrivate
+{
+  ctkModuleParameterPrivate()
+    : Multiple("false"), Aggregate("false")
+  {}
+
+  QString Tag;
+  QString Name;
+  QString Description;
+  QString Label;
+  QString CPPType;
+  QString Type;
+  QString Reference;
+  QString Hidden;
+  QString ArgType;
+  QString StringToType;
+  QString Default;
+  QString Flag;
+  QString LongFlag;
+  QString Constraints;
+  QString Minimum;
+  QString Maximum;
+  QString Step;
+  QString Channel;
+  QString Index;
+  QString Multiple;
+  QString Aggregate;
+  QString FileExtensionsAsString;
+  QStringList FileExtensions;
+  QString CoordinateSystem;
+  QStringList Elements;
+  QString FlagAliasesAsString;
+  QString DeprecatedFlagAliasesAsString;
+  QString LongFlagAliasesAsString;
+  QString DeprecatedLongFlagAliasesAsString;
+  QStringList FlagAliases;
+  QStringList DeprecatedFlagAliases;
+  QStringList LongFlagAliases;
+  QStringList DeprecatedLongFlagAliases;
+
+  QStringList splitAndTrim(const QString& str, const QString& separator)
+  {
+    QStringList l = str.split(separator, QString::SkipEmptyParts);
+    l.removeDuplicates();
+    // trim the strings
+    QMutableStringListIterator i(l);
+    while(i.hasNext())
+    {
+      QString& n = i.next();
+      n = n.trimmed();
+    }
+    return l;
+  }
+};
+
+//----------------------------------------------------------------------------
+ctkModuleParameter::ctkModuleParameter()
+  : d_ptr(new ctkModuleParameterPrivate)
+{ }
+
+//----------------------------------------------------------------------------
+ctkModuleParameter::~ctkModuleParameter()
+{
+  delete d_ptr;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setTag(const QString& tag)
+{
+  Q_D(ctkModuleParameter);
+  d->Tag = tag;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::tag() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Tag;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setCPPType(const QString& type)
+{
+  Q_D(ctkModuleParameter);
+  d->CPPType = type;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::cppType() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->CPPType;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setType(const QString& type)
+{
+  Q_D(ctkModuleParameter);
+  d->Type = type;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::type() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Type;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setReference(const QString& ref)
+{
+  Q_D(ctkModuleParameter);
+  d->Reference = ref;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::reference() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Reference;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setHidden(const QString& hidden)
+{
+  Q_D(ctkModuleParameter);
+  d->Hidden = hidden;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::hidden() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Hidden;
+}
+
 //----------------------------------------------------------------------------
 bool ctkModuleParameter::isReturnParameter() const
 {
+  Q_D(const ctkModuleParameter);
   // could check for tag == float, int, float-vector, ...
-  return (*this)["Channel"] == "output" 
-         && !this->isFlagParameter()
-         && !this->isIndexParameter();
+  if (d->Channel == "output"
+      && !this->isFlagParameter() && !this->isIndexParameter())
+  {
+    return true;
+  }
+  return false;
 }
 
 //----------------------------------------------------------------------------
 bool ctkModuleParameter::isFlagParameter() const
 {
-  return ((*this)["Flag"] != "" || (*this)[ "LongFlag" ] != "");
+  Q_D(const ctkModuleParameter);
+  return (d->Flag != "" || d->LongFlag != "");
 }
 
 //----------------------------------------------------------------------------
 bool ctkModuleParameter::isIndexParameter() const
 {
-  return ((*this)[ "Index" ] != "");
+  Q_D(const ctkModuleParameter);
+  return (d->Index != "");
 }
 
-//-----------------------------------------------------------------------------
-QTextStream & operator<<(QTextStream &os, const ctkModuleParameter &parameter)
-{ 
-  os << "    Parameter" << endl;
-  os << "      ";
-  os.setFieldWidth(7);
-  os.setFieldAlignment(QTextStream::AlignLeft);
-  os << QHash<QString, QString>( parameter );
-  os.setFieldWidth(0);
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setArgType(const QString& argType)
+{
+  Q_D(ctkModuleParameter);
+  d->ArgType = argType;
+}
 
-  os << "Flag aliases: ";
-  os << parameter["FlagAliases"].split( "," );
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::argType() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->ArgType;
+}
 
-  os << "      " << "Deprecated Flag aliases: ";
-  os << parameter["DeprecatedFlagAliases"].split( "," );
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setStringToType(const QString& stringToType)
+{
+  Q_D(ctkModuleParameter);
+  d->StringToType = stringToType;
+}
 
-  os << "      " << "LongFlag aliases: ";
-  os << parameter["LongFlagAliases"].split( "," );
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::stringToType() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->StringToType;
+}
 
-  os << "      " << "Deprecated LongFlag aliases: ";
-  os << parameter["DeprecatedLongFlagAliases"].split( "," );
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setName(const QString& name)
+{
+  Q_D(ctkModuleParameter);
+  d->Name = name;
+}
 
-  os << "      " << "FileExtensions: ";
-  os << parameter["FileExtensions"].split( "," );
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::name() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Name;
+}
 
-  return os;
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setLongFlag(const QString& longFlag)
+{
+  Q_D(ctkModuleParameter);
+  d->LongFlag = longFlag;
 }
 
 //----------------------------------------------------------------------------
-QTextStream & operator<<(QTextStream &os, const QStringList &list)
+QString ctkModuleParameter::longFlag() const
 {
-  os << list.join(", ") << endl;
-  return os;
+  Q_D(const ctkModuleParameter);
+  return d->LongFlag;
 }
 
 //----------------------------------------------------------------------------
-QTextStream & operator<<(QTextStream &os, const QHash<QString, QString> &hash)
-{ 
-  QHash<QString,QString>::const_iterator itProp;
-  for ( itProp = hash.begin( ) ; 
-        itProp != hash.end( ) ; 
-        itProp++ )
-    {
-    os << itProp.key( ) << ": " << itProp.value( ) << '\n';
-    }
+void ctkModuleParameter::setLongFlagAliasesAsString(const QString& aliases)
+{
+  Q_D(ctkModuleParameter);
+  d->LongFlagAliases = d->splitAndTrim(aliases, ",");
+  d->LongFlagAliasesAsString = d->LongFlagAliases.join(", ");
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::longFlagAliasesAsString() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->LongFlagAliasesAsString;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::longFlagAliases() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->LongFlagAliases;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setDeprecatedLongFlagAliasesAsString(const QString& aliases)
+{
+  Q_D(ctkModuleParameter);
+  d->DeprecatedLongFlagAliases = d->splitAndTrim(aliases, ",");
+  d->DeprecatedLongFlagAliasesAsString = d->DeprecatedLongFlagAliases.join(", ");
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::deprecatedLongFlagAliasesAsString() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->DeprecatedLongFlagAliasesAsString;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::deprecatedLongFlagAliases() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->DeprecatedLongFlagAliases;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setLabel(const QString& label)
+{
+  Q_D(ctkModuleParameter);
+  d->Label = label;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::label() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Label;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setConstraints(const QString& constraints)
+{
+  Q_D(ctkModuleParameter);
+  d->Constraints = constraints;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::constraints() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Constraints;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setMaximum(const QString& maximum)
+{
+  Q_D(ctkModuleParameter);
+  d->Maximum = maximum;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::maximum() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Maximum;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setMinimum(const QString& minimum)
+{
+  Q_D(ctkModuleParameter);
+  d->Minimum = minimum;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::minimum() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Minimum;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setStep(const QString& step)
+{
+  Q_D(ctkModuleParameter);
+  d->Step = step;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::step() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Step;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setDescription(const QString& description)
+{
+  Q_D(ctkModuleParameter);
+  d->Description = description;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::description() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Description;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setChannel(const QString& channel)
+{
+  Q_D(ctkModuleParameter);
+  d->Channel = channel;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::channel() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Channel;
+}
 
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setIndex(const QString& index)
+{
+  Q_D(ctkModuleParameter);
+  d->Index = index;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::index() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Index;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setDefaultValue(const QString& def)
+{
+  Q_D(ctkModuleParameter);
+  d->Default = def;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::defaultValue() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Default;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setFlag(const QString& flag)
+{
+  Q_D(ctkModuleParameter);
+  d->Flag = flag;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::flag() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Flag;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setFlagAliasesAsString(const QString& aliases)
+{
+  Q_D(ctkModuleParameter);
+  d->FlagAliases = d->splitAndTrim(aliases, ",");
+  d->FlagAliasesAsString = d->FlagAliases.join(", ");
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::flagAliasesAsString() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->FlagAliasesAsString;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::flagAliases() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->FlagAliases;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setDeprecatedFlagAliasesAsString(const QString& aliases)
+{
+  Q_D(ctkModuleParameter);
+  d->DeprecatedFlagAliases = d->splitAndTrim(aliases, ",");
+  d->DeprecatedFlagAliasesAsString = d->DeprecatedFlagAliases.join(", ");
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::deprecatedFlagAliasesAsString() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->DeprecatedFlagAliasesAsString;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::deprecatedFlagAliases() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->DeprecatedFlagAliases;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setMultiple(const QString& multiple)
+{
+  Q_D(ctkModuleParameter);
+  d->Multiple = multiple;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::multiple() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Multiple;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setAggregate(const QString& aggregate)
+{
+  Q_D(ctkModuleParameter);
+  d->Aggregate = aggregate;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::aggregate() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Aggregate;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setFileExtensionsAsString(const QString& extensions)
+{
+  Q_D(ctkModuleParameter);
+  d->FileExtensions = d->splitAndTrim(extensions, ",");
+  d->FileExtensionsAsString = d->FileExtensions.join(",");
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::fileExtensionsAsString() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->FileExtensionsAsString;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::fileExtensions() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->FileExtensions;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameter::setCoordinateSystem(const QString& coordinateSystem)
+{
+  Q_D(ctkModuleParameter);
+  d->CoordinateSystem = coordinateSystem;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameter::coordinateSystem() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->CoordinateSystem;
+}
+
+//----------------------------------------------------------------------------
+QStringList ctkModuleParameter::elements() const
+{
+  Q_D(const ctkModuleParameter);
+  return d->Elements;
+}
+
+//----------------------------------------------------------------------------
+//QStringList& ctkModuleParameter::elements()
+//{
+//  return d->Elements;
+//}
+
+//----------------------------------------------------------------------------
+QTextStream& operator<<(QTextStream& os, const ctkModuleParameter& parameter)
+{
+  os << "    Parameter" << '\n';
+  os << "      " << "Tag: " << parameter.tag() << '\n';
+  os << "      " << "Name: " << parameter.name() << '\n';
+  os << "      " << "Description: " << parameter.description() << '\n';
+  os << "      " << "Label: " << parameter.label() << '\n';
+  os << "      " << "Type: " << parameter.type() << '\n';
+  os << "      " << "Reference: " << parameter.reference() << '\n';
+  os << "      " << "Hidden: " << parameter.hidden() << '\n';
+  os << "      " << "CPPType: " << parameter.cppType() << '\n';
+  os << "      " << "ArgType: " << parameter.argType() << '\n';
+  os << "      " << "StringToType: " << parameter.stringToType() << '\n';
+  os << "      " << "Default: " << parameter.defaultValue() << '\n';
+  os << "      " << "Elements: " << parameter.elements().join(", ") << '\n';
+  os << "      " << "Constraints: " << parameter.constraints() << '\n';
+  os << "      " << "Minimum: " << parameter.minimum() << '\n';
+  os << "      " << "Maximum: " << parameter.maximum() << '\n';
+  os << "      " << "Step: " << parameter.step() << '\n';
+  os << "      " << "Flag: " << parameter.flag() << '\n';
+  os << "      " << "Flag aliases: " << parameter.flagAliasesAsString() << '\n';
+  os << "      " << "Deprecated Flag aliases: " << parameter.deprecatedFlagAliasesAsString() << '\n';
+  os << "      " << "LongFlag: " << parameter.longFlag() << '\n';
+  os << "      " << "LongFlag aliases: " << parameter.longFlagAliasesAsString() << '\n';
+  os << "      " << "Deprecated LongFlag aliases: " << parameter.deprecatedLongFlagAliasesAsString() << '\n';
+  os << "      " << "Channel: " << parameter.channel() << '\n';
+  os << "      " << "Index: " << parameter.index() << '\n';
+  os << "      " << "Multiple: " << parameter.multiple() << '\n';
+  os << "      " << "Aggregate: " << parameter.aggregate() << '\n';
+  os << "      " << "FileExtensions: " << parameter.fileExtensionsAsString() << '\n';
+  os << "      " << "CoordinateSystem: " << parameter.coordinateSystem() << '\n';
   return os;
 }

+ 110 - 10
Libs/ModuleDescription/ctkModuleParameter.h

@@ -23,9 +23,10 @@
 
 #include "ctkModuleDescriptionExport.h"
 
-#include <QHash>
 #include <QTextStream>
 
+class ctkModuleParameterPrivate;
+
 /** 
  *  \brief Single parameter to a module, like a threshold of a filter.
  *
@@ -35,22 +36,121 @@
  * stored.
  *
  */
-class CTK_MODULDESC_EXPORT ctkModuleParameter : public QHash<QString, QString>
+class CTK_MODULDESC_EXPORT ctkModuleParameter
 {
+  Q_DECLARE_PRIVATE(ctkModuleParameter)
+
 public:
-  /// Simple return types are parameters on output channel with no
-  /// flags and without a specified index 
+
+  ctkModuleParameter();
+  ~ctkModuleParameter();
+
+  void setTag(const QString& tag);
+  QString tag() const;
+
+  void setCPPType(const QString& type);
+  QString cppType() const;
+
+  void setType(const QString& type);
+  QString type() const;
+
+  void setReference(const QString& ref);
+  QString reference() const;
+
+  void setHidden(const QString& hidden);
+  QString hidden() const;
+
+  // Simple return types are parameters on output channel with no
+  // flags and without a specified index
   bool isReturnParameter() const;
-  
-  /// Has a flag or a long flag?
+
+  // Has a flag or a long flag?
   bool isFlagParameter() const;
 
-  /// Is an index type?
+  // Is an index type?
   bool isIndexParameter() const;
+
+  void setArgType(const QString& argType);
+  QString argType() const;
+
+  void setStringToType(const QString& stringToType);
+  QString stringToType() const;
+
+  void setName(const QString& name);
+  QString name() const;
+
+  void setLongFlag(const QString& longFlag);
+  QString longFlag() const;
+
+  void setLongFlagAliasesAsString(const QString& aliases);
+  QString longFlagAliasesAsString() const;
+  QStringList longFlagAliases() const;
+
+  void setDeprecatedLongFlagAliasesAsString(const QString& aliases);
+  QString deprecatedLongFlagAliasesAsString() const;
+  QStringList deprecatedLongFlagAliases() const;
+
+  void setLabel(const QString& label);
+  QString label() const;
+
+  void setConstraints(const QString& constraints);
+  QString constraints() const;
+
+  void setMaximum(const QString& maximum);
+  QString maximum() const;
+
+  void setMinimum(const QString& minimum);
+  QString minimum() const;
+
+  void setStep(const QString& step);
+  QString step() const;
+
+  void setDescription(const QString& description);
+  QString description() const;
+
+  void setChannel(const QString& channel);
+  QString channel() const;
+
+  void setIndex(const QString& index);
+  QString index() const;
+
+  void setDefaultValue(const QString& def);
+  QString defaultValue() const;
+
+  void setFlag(const QString& flag);
+  QString flag() const;
+
+  void setFlagAliasesAsString(const QString& aliases);
+  QString flagAliasesAsString() const;
+  QStringList flagAliases() const;
+
+  void setDeprecatedFlagAliasesAsString(const QString& aliases);
+  QString deprecatedFlagAliasesAsString() const;
+  QStringList deprecatedFlagAliases() const;
+
+  void setMultiple(const QString& multiple);
+  QString multiple() const;
+
+  void setAggregate(const QString& aggregate);
+  QString aggregate() const;
+
+  void setFileExtensionsAsString(const QString& extensions);
+  QString fileExtensionsAsString() const;
+  QStringList fileExtensions() const;
+
+  void setCoordinateSystem(const QString& coordinateSystem);
+  QString coordinateSystem() const;
+
+  QStringList elements() const;
+  //QStringList& elements();
+
+private:
+
+  Q_DISABLE_COPY(ctkModuleParameter)
+
+  ctkModuleParameterPrivate * const d_ptr;
 };
 
-CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleParameter &parameter);
-CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const QStringList &list);
-CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const QHash<QString, QString> &hash);
+CTK_MODULDESC_EXPORT QTextStream& operator<<(QTextStream& os, const ctkModuleParameter& parameter);
 
 #endif

+ 113 - 49
Libs/ModuleDescription/ctkModuleParameterGroup.cpp

@@ -5,7 +5,7 @@ Library: CTK
 Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
 
 Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
+you may not use d file except in compliance with the License.
 You may obtain a copy of the License at
 
 http://www.apache.org/licenses/LICENSE-2.0
@@ -20,91 +20,155 @@ limitations under the License.
 
 #include "ctkModuleParameterGroup.h"
 
+struct ctkModuleParameterGroupPrivate
+{
+  ~ctkModuleParameterGroupPrivate()
+  {
+    qDeleteAll(Parameters);
+  }
+
+  QString Label;
+  QString Description;
+  QString Advanced;
+  QList<ctkModuleParameter*> Parameters;
+};
+
+//----------------------------------------------------------------------------
+ctkModuleParameterGroup::ctkModuleParameterGroup()
+  : d_ptr(new ctkModuleParameterGroupPrivate())
+{
+}
+
 //----------------------------------------------------------------------------
 ctkModuleParameterGroup::~ctkModuleParameterGroup()
 {
-  foreach(ctkModuleParameter* param, this->Parameters)
-    {
-    delete param;
-    }
-  this->Parameters.clear();
+  delete d_ptr;
 }
 
 //----------------------------------------------------------------------------
-void ctkModuleParameterGroup::addParameter( ctkModuleParameter* parameter )
+void ctkModuleParameterGroup::setLabel(const QString& label)
 {
-  Q_ASSERT(parameter);
-  this->Parameters.push_back(parameter);
+  Q_D(ctkModuleParameterGroup);
+  d->Label = label;
 }
 
 //----------------------------------------------------------------------------
-const QVector<ctkModuleParameter*>& ctkModuleParameterGroup::parameters() const
+QString ctkModuleParameterGroup::label() const
 {
-	return this->Parameters;
+  Q_D(const ctkModuleParameterGroup);
+  return d->Label;
 }
 
 //----------------------------------------------------------------------------
-ctkModuleParameter* ctkModuleParameterGroup::parameter( const QString& parameterName )const
+void ctkModuleParameterGroup::setDescription(const QString& description)
 {
-  foreach(ctkModuleParameter* param, this->Parameters)
-    {
-    if ((*param)["Name"] == parameterName)
-      {
-      return param;
-      }
-    }
+  Q_D(ctkModuleParameterGroup);
+  d->Description = description;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameterGroup::description() const
+{
+  Q_D(const ctkModuleParameterGroup);
+  return d->Description;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameterGroup::setAdvanced(const QString& advanced)
+{
+  Q_D(ctkModuleParameterGroup);
+  d->Advanced = advanced;
+}
+
+//----------------------------------------------------------------------------
+QString ctkModuleParameterGroup::advanced() const
+{
+  Q_D(const ctkModuleParameterGroup);
+  return d->Advanced;
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameterGroup::addParameter(ctkModuleParameter* parameter)
+{
+  Q_D(ctkModuleParameterGroup);
+  d->Parameters.push_back(parameter);
+}
+
+//----------------------------------------------------------------------------
+QList<ctkModuleParameter*> ctkModuleParameterGroup::parameters() const
+{
+  Q_D(const ctkModuleParameterGroup);
+  return d->Parameters;
+}
+
+//----------------------------------------------------------------------------
+bool ctkModuleParameterGroup::hasParameter(const QString& name) const
+{
+  Q_D(const ctkModuleParameterGroup);
+  foreach(const ctkModuleParameter* param, d->Parameters)
+  {
+    if (param->name() == name) return true;
+  }
+  return false;
+}
+
+//----------------------------------------------------------------------------
+ctkModuleParameter* ctkModuleParameterGroup::parameter(const QString& name) const
+{
+  Q_D(const ctkModuleParameterGroup);
+  foreach(ctkModuleParameter* param, d->Parameters)
+  {
+    if (param->name() == name) return param;
+  }
   return 0;
 }
 
 //----------------------------------------------------------------------------
 bool ctkModuleParameterGroup::hasReturnParameters() const
 {
-  // iterate over each parameter in this group
-  foreach(const ctkModuleParameter* param, this->Parameters)
-    {
+  Q_D(const ctkModuleParameterGroup);
+  // iterate over each parameter in d group
+  foreach(const ctkModuleParameter* param, d->Parameters)
+  {
     if (param->isReturnParameter())
-      {
+    {
       return true;
-      }
     }
+  }
   return false;
 }
 
 //----------------------------------------------------------------------------
-bool ctkModuleParameterGroup::
-writeParameterFile(QTextStream& in, bool withHandlesToBulkParameters)const
+bool ctkModuleParameterGroup::writeParameterFile(QTextStream& in, bool withHandlesToBulkParameters) const
 {
-  // iterate over each parameter in this group
-  foreach(const ctkModuleParameter* moduleParameter, this->Parameters)
-    {
-    const ctkModuleParameter& param = *moduleParameter;
+  Q_D(const ctkModuleParameterGroup);
+  // iterate over each parameter in d group
+  foreach(const ctkModuleParameter* param, d->Parameters)
+  {
     // write out all parameters or just the ones that are not bulk parameters
-    if (withHandlesToBulkParameters
-        || (!withHandlesToBulkParameters 
-            && (param[ "Tag" ] != "image"
-            && param[ "Tag" ] != "geometry"
-            && param[ "Tag" ] != "transform"
-            && param[ "Tag" ] != "table"
-            && param[ "Tag" ] != "measurement"
-            && param[ "Tag" ] != "point"  // point and region are special
-            && param[ "Tag" ] != "region")))
-      {
-      in << param[ "Name" ] << " = " << param[ "Default" ] << endl;
+    QString tag = param->tag();
+    if (withHandlesToBulkParameters ||
+        !(tag == "image" || tag == "geometry" || tag == "transform" ||
+          tag == "table" || tag == "measurement" ||
+          tag == "point" || tag == "region"))  // point and region are special
+    {
+      in << param->name() << " = " << param->defaultValue() << endl;
       // multiple="true" may have to be handled differently
-      }
     }
+  }
   return true;
 }
 
 //----------------------------------------------------------------------------
 QTextStream & operator<<(QTextStream &os, const ctkModuleParameterGroup &group)
 { 
-  os << QHash<QString, QString>(group);
-
-  os << "  Parameters: " << endl;
-  foreach (const ctkModuleParameter* it, group.Parameters)
-    {
-    os << *it;
-    }
+  os << "  Advanced: " << group.advanced() << '\n';
+  os << "  Label: " << group.label() << '\n';
+  os << "  Description: " << group.description() << '\n';
+  os << "  Parameters: " << '\n';
+  foreach(ctkModuleParameter* param, group.parameters())
+  {
+    os << *param;
+  }
   return os;
 }

+ 29 - 15
Libs/ModuleDescription/ctkModuleParameterGroup.h

@@ -23,34 +23,48 @@
 
 #include "ctkModuleParameter.h"
 
-#include <QHash>
-#include <QVector>
+class ctkModuleParameterGroupPrivate;
 
 /** 
 *  \brief Group of parameters
 *
 */
-class CTK_MODULDESC_EXPORT ctkModuleParameterGroup : public QHash<QString, QString>
+class CTK_MODULDESC_EXPORT ctkModuleParameterGroup
 {
+  Q_DECLARE_PRIVATE(ctkModuleParameterGroup)
+
 public:
-  virtual ~ctkModuleParameterGroup();
+
+  ctkModuleParameterGroup();
+  ~ctkModuleParameterGroup();
   
-  /// Takes ownership of parameter
+  void setLabel(const QString& label);
+  QString label() const;
+
+  void setDescription(const QString& description);
+  QString description() const;
+
+  void setAdvanced(const QString& advanced);
+  QString advanced() const;
+
   void addParameter(ctkModuleParameter* parameter);
-  const QVector<ctkModuleParameter*>& parameters() const;
+  QList<ctkModuleParameter*> parameters() const;
 
-  /// Returns 0 if not found.
-  ctkModuleParameter* parameter(const QString& parameterName)const;
-  /// Returns true if at least 1 parameter is a return type
-  bool hasReturnParameters()const;
-  bool writeParameterFile(QTextStream& in, bool withHandlesToBulkParameters = true)const;
+  bool hasParameter(const QString& name) const;
+
+  ctkModuleParameter* parameter(const QString& name) const;
+
+  bool hasReturnParameters() const;
+
+  bool writeParameterFile(QTextStream& in, bool withHandlesToBulkParameters) const;
   
 private:
-  friend CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleParameterGroup &group);
-  ///
-  QVector<ctkModuleParameter*> Parameters;
+
+  Q_DISABLE_COPY(ctkModuleParameterGroup)
+
+  ctkModuleParameterGroupPrivate * const d_ptr;
 };
 
-CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleParameterGroup &group);
+CTK_MODULDESC_EXPORT QTextStream & operator<<(QTextStream &os, const ctkModuleParameterGroup& group);
 
 #endif

+ 158 - 0
Libs/ModuleDescription/ctkSlicerModuleStringConverter.cpp

@@ -0,0 +1,158 @@
+/*=============================================================================
+
+Library: CTK
+
+Copyright (c) 2010 CISTIB - Universtitat Pompeu Fabra
+
+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 "ctkSlicerModuleStringConverter.h"
+#include <QVector>
+
+
+void ctkSlicerModuleStringConverter::update()
+{
+  SetTarget( );
+
+  SetAllParameters( );
+}
+
+const QVariant ctkSlicerModuleStringConverter::GetOutput()
+{
+  return this->CommandLineAsString;
+}
+
+void ctkSlicerModuleStringConverter::SetAllParameters()
+{
+  foreach( const ctkModuleParameterGroup* itGroup, this->ModuleDescription.parameterGroups())
+  {
+    foreach( const ctkModuleParameter* itParam, itGroup->parameters())
+    {
+      SetParameterValue( *itParam );
+    }
+  }
+}
+
+void ctkSlicerModuleStringConverter::SetParameterValue( const ctkModuleParameter &param )
+{
+  QString prefix;
+  QString flag;
+  bool hasFlag = false;
+
+  if ( param["LongFlag"] != "")
+  {
+    prefix = "--";
+    flag = param["LongFlag"];
+    hasFlag = true;
+  }
+  else if (param["Flag"] != "")
+  {
+    prefix = "-";
+    flag = param["Flag"];
+    hasFlag = true;
+  }
+
+
+  if (hasFlag)
+  {
+    if (   param["Tag"] != "boolean"
+      && param["Tag"] != "file" 
+      && param["Tag"] != "directory"
+      && param["Tag"] != "string"
+      && param["Tag"] != "integer-vector"
+      && param["Tag"] != "float-vector"
+      && param["Tag"] != "double-vector"
+      && param["Tag"] != "string-vector"
+      && param["Tag"] != "image"
+      && param["Tag"] != "point"
+      && param["Tag"] != "region"
+      && param["Tag"] != "transform"
+      && param["Tag"] != "geometry"
+      && param["Tag"] != "table"
+      && param["Tag"] != "measurement")
+    {
+      // simple parameter, write flag and value
+      this->CommandLineAsString.push_back(prefix + flag);
+      this->CommandLineAsString.push_back(param["Default"]);
+    }
+    else if (param["Tag"] == "boolean" && param["Default"] == "true")
+    {
+      this->CommandLineAsString.push_back(prefix + flag);
+    }
+    else if (param["Tag"] == "file" 
+      || param["Tag"] == "directory"
+      || param["Tag"] == "string"
+      || param["Tag"] == "integer-vector"
+      || param["Tag"] == "float-vector"
+      || param["Tag"] == "double-vector"
+      || param["Tag"] == "string-vector")
+    {
+      // Only write out the flag if value is not empty
+      if ( param["Default"] != "")
+      {
+        this->CommandLineAsString.push_back(prefix + flag);
+        this->CommandLineAsString.push_back( param["Default"] );
+      }
+    }
+    // data passed as parameter
+    else if ( param["Tag"] == "image" 
+      || param["Tag"] == "geometry"
+      || param["Tag"] == "transform" 
+      || param["Tag"] == "table" 
+      || param["Tag"] == "measurement" )
+    {
+      if ( param["Default"] != "")
+      {
+        this->CommandLineAsString.push_back(prefix + flag);
+        this->CommandLineAsString.push_back(param["Default"]);
+      }
+    }
+    else if ( param["Tag"] == "region" )
+    {
+      this->CommandLineAsString.push_back(prefix + flag);
+      this->CommandLineAsString.push_back( param["Default"] );
+    }
+    else if ( param["Tag"] == "point" )
+    {
+      QStringList points = param["Default"].split( ";");
+      foreach ( const QString &it, points )
+      {
+        this->CommandLineAsString.push_back(prefix + flag);
+        this->CommandLineAsString.push_back( it );
+      }
+    }
+
+  }
+
+  // If index is not empty -> It's a command line argument arg0, arg1, ... without flag prefix
+  if ( param["Index"] != "")
+  {
+    this->CommandLineAsString.push_back( param["Default"] );
+  }
+}
+
+void ctkSlicerModuleStringConverter::SetTarget()
+{
+  this->CommandLineAsString.clear();
+
+  if (!this->ModuleDescription["Location"].isEmpty() && 
+    this->ModuleDescription["Location"] != this->ModuleDescription["Target"])
+  {
+    this->CommandLineAsString.push_back(this->ModuleDescription["Location"]);
+  }
+  this->CommandLineAsString.push_back( this->ModuleDescription["Target"] );
+}
+
+

+ 65 - 0
Libs/ModuleDescription/ctkSlicerModuleStringConverter.h

@@ -0,0 +1,65 @@
+/*=============================================================================
+
+  Library: CTK
+
+  Copyright (c) 2010 CISTIB - Universtitat Pompeu Fabra
+
+  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 __ctkSlicerModuleStringConverter_h
+#define __ctkSlicerModuleStringConverter_h
+
+#include <string>
+
+#include "ctkModuleDescriptionConverter.h"
+
+class ModuleDescription;
+class ModuleParameterGroup;
+
+
+/**
+ * Convert Slicer Module description to command line string QStringList
+ *
+ */
+class ctkSlicerModuleStringConverter : public ctkModuleDescriptionConverter
+{
+  Q_OBJECT
+public:
+  ctkSlicerModuleStringConverter() {};
+  ~ctkSlicerModuleStringConverter() {};
+
+  ///
+  void update( );
+
+  ///
+  virtual const QVariant GetOutput( );
+
+protected:
+
+  //!
+  void SetAllParameters();
+
+  //!
+  void SetParameterValue( const ctkModuleParameter &param );
+
+  ///
+  void SetTarget();
+
+protected:
+
+  QStringList CommandLineAsString;
+};
+
+#endif