Explorar el Código

Added parameter value classes to miror descriptions.

Enabled compilation in main cmakelist.
Yves Martelli hace 13 años
padre
commit
05502efb68

+ 4 - 3
CMakeLists.txt

@@ -206,7 +206,6 @@ include(CMake/ctkFunctionCompileSnippets.cmake)
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
 # Testing
 # Testing
 #
 #
-
 include(CTest)
 include(CTest)
 mark_as_advanced(BUILD_TESTING)
 mark_as_advanced(BUILD_TESTING)
 
 
@@ -450,8 +449,8 @@ ctk_lib_option(Visualization/VTK/Core
 ctk_lib_option(Visualization/VTK/Widgets
 ctk_lib_option(Visualization/VTK/Widgets
                "Build the VTK Widgets library" OFF)
                "Build the VTK Widgets library" OFF)
                
                
-#ctk_lib_option(ModuleDescription
-#               "Build the Command Line Module Description library" OFF)
+ctk_lib_option(ModuleDescription
+               "Build the Command Line Module Description library" OFF)
 
 
 #ctk_lib_option(Visualization/XIP
 #ctk_lib_option(Visualization/XIP
 #               "Build the XIP library" OFF)
 #               "Build the XIP library" OFF)
@@ -604,6 +603,7 @@ ctk_plugin_option(org.commontk.eventbus
 #       OPT2:ON
 #       OPT2:ON
 #       )
 #       )
 
 
+
 # Create list of directories corresponding to the enabled targets
 # Create list of directories corresponding to the enabled targets
 set(target_directories)
 set(target_directories)
 
 
@@ -757,6 +757,7 @@ if(CTK_SUPERBUILD)
   return()
   return()
 endif()
 endif()
 
 
+
 #-----------------------------------------------------------------------------
 #-----------------------------------------------------------------------------
 # Expand variables containing include and library directories for external projects
 # Expand variables containing include and library directories for external projects
 # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions
 # This relies on the variable EXTERNAL_TARGETS set in ctkMacroValidateBuildOptions

+ 8 - 2
Libs/ModuleDescription/CMakeLists.txt

@@ -20,6 +20,10 @@ set(KIT_SRCS
   ctkModuleParameter.cpp
   ctkModuleParameter.cpp
   ctkModuleParameterGroup.h
   ctkModuleParameterGroup.h
   ctkModuleParameterGroup.cpp
   ctkModuleParameterGroup.cpp
+  ctkModuleParameterGroupValue.h
+  ctkModuleParameterGroupValue.cpp
+  ctkModuleParameterValue.h
+  ctkModuleParameterValue.cpp
   ctkModuleDescriptionReaderInterface.cpp
   ctkModuleDescriptionReaderInterface.cpp
   ctkModuleDescriptionReaderInterface.h
   ctkModuleDescriptionReaderInterface.h
   ctkModuleDescriptionReader.h
   ctkModuleDescriptionReader.h
@@ -30,6 +34,8 @@ set(KIT_SRCS
   ctkModuleDescriptionExecutionInterface.h
   ctkModuleDescriptionExecutionInterface.h
   ctkModuleDescriptionExecution.h
   ctkModuleDescriptionExecution.h
   ctkModuleDescriptionExecution.cpp
   ctkModuleDescriptionExecution.cpp
+  ctkModuleValues.h
+  ctkModuleValues.cpp
   )
   )
 
 
 # Headers that should run through moc
 # Headers that should run through moc
@@ -50,9 +56,9 @@ set(KIT_UI_FORMS
 set(KIT_resources
 set(KIT_resources
 )
 )
 
 
-# Target libraries - See CMake/ctkMacroGetTargetLibraries.cmake
+# Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
 # The following macro will read the target libraries from the file 'target_libraries.cmake'
 # The following macro will read the target libraries from the file 'target_libraries.cmake'
-ctkMacroGetTargetLibraries(KIT_target_libraries)
+ctkFunctionGetTargetLibraries(KIT_target_libraries)
 
 
 ctkMacroBuildLib(
 ctkMacroBuildLib(
   NAME ${PROJECT_NAME}
   NAME ${PROJECT_NAME}

+ 50 - 0
Libs/ModuleDescription/ctkModuleParameterGroupValue.cpp

@@ -0,0 +1,50 @@
+/*=============================================================================
+
+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.
+
+=============================================================================*/
+
+#include "ctkModuleParameterGroupValue.h"
+
+//----------------------------------------------------------------------------
+ctkModuleParameterGroupValue::~ctkModuleParameterGroupValue()
+{
+  foreach(ctkModuleParameterValue* value, this->Values)
+    {
+    delete value;
+    }
+  this->Values.clear();
+}
+
+//----------------------------------------------------------------------------
+const QVector<ctkModuleParameterValue*>& ctkModuleParameterGroupValue::values() const
+{
+	return this->Values;
+}
+
+//----------------------------------------------------------------------------
+ctkModuleParameterValue* ctkModuleParameterGroupValue::value( const QString& parameterName )const
+{
+  foreach(ctkModuleParameterValue* value, this->Values)
+    {
+    if (value->parameter()["Name"] == parameterName)
+      {
+      return value;
+      }
+    }
+  return 0;
+}

+ 47 - 0
Libs/ModuleDescription/ctkModuleParameterGroupValue.h

@@ -0,0 +1,47 @@
+/*=============================================================================
+
+  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 __ctkModuleParameterGroupValue_h
+#define __ctkModuleParameterGroupValue_h
+
+#include "ctkModuleParameterValue.h"
+#include "QVector"
+
+/** 
+*  \brief Group of parameters value
+*
+*/
+class CTK_MODULDESC_EXPORT ctkModuleParameterGroupValue
+{
+public:
+  virtual ~ctkModuleParameterGroupValue();
+  
+  /// Takes ownership of parameter
+  const QVector<ctkModuleParameterValue*>& values() const;
+
+  /// Returns 0 if not found.
+  ctkModuleParameterValue* value(const QString& parameterName)const;
+  
+private:
+  ///
+  QVector<ctkModuleParameterValue*> Values;
+};
+
+#endif

+ 72 - 0
Libs/ModuleDescription/ctkModuleParameterValue.cpp

@@ -0,0 +1,72 @@
+/*=============================================================================
+
+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.
+
+=============================================================================*/
+
+#include "ctkModuleParameterValue.h"
+#include "QDebug"
+
+//----------------------------------------------------------------------------
+ctkModuleParameterValue::ctkModuleParameterValue( const ctkModuleParameter& param)
+: Parameter( param )
+{
+}
+
+//----------------------------------------------------------------------------
+void ctkModuleParameterValue::setValue( const QVariant& val)
+{
+  value = val;
+}
+
+//----------------------------------------------------------------------------
+const QVariant& ctkModuleParameterValue::getValue() const
+{
+  return value;
+}
+
+//----------------------------------------------------------------------------
+const ctkModuleParameter& ctkModuleParameterValue::parameter() const
+{
+  return Parameter;
+}
+
+void ctkModuleParameterValue::setDefaultValue()
+{
+  QVariant::Type type = value.type();
+  if (type == QVariant::Bool)
+    {
+      value = (Parameter["Default"].compare("true", Qt::CaseInsensitive) == 0);
+    }
+  else if (type == QVariant::Int)
+    {
+      value = Parameter["Default"].toInt();
+    }
+  else if (type == QVariant::Double)
+    {
+      value = Parameter["Default"].toDouble();
+    }
+  else if (type == QVariant::String)
+    {
+      value = Parameter["Default"];
+    }
+  else
+    {
+    qDebug() << "Unknown widget value type:" << type;
+    }
+
+}

+ 55 - 0
Libs/ModuleDescription/ctkModuleParameterValue.h

@@ -0,0 +1,55 @@
+/*=============================================================================
+
+  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 __ctkModuleParameterValue_h
+#define __ctkModuleParameterValue_h
+
+#include "CTKModuleDescriptionExport.h"
+#include "CTKModuleParameter.h"
+#include "QVariant.h"
+
+/** 
+ *  \brief Single parameter value to a module, like a threshold of a filter.
+ *
+ * ctkModuleParameterValue describes a single parameter value to a
+ * module. Information on the parameter type, name, flag, label,
+ * description, channel, index, default, and constraints can be
+ * stored.
+ *
+ */
+class CTK_MODULDESC_EXPORT ctkModuleParameterValue
+{
+public:
+  // constructor
+  ctkModuleParameterValue( const ctkModuleParameter& param );
+  // set the value
+  void setValue( const QVariant& value );
+  // set the value to the defaut one
+  void setDefaultValue();
+  // get the value
+  const QVariant& getValue() const;
+  // get the associated ctkModuleParameter
+  const ctkModuleParameter& parameter() const;
+private:
+  QVariant value;
+  const ctkModuleParameter& Parameter;
+};
+
+#endif

+ 61 - 0
Libs/ModuleDescription/ctkModuleValues.cpp

@@ -0,0 +1,61 @@
+/*=============================================================================
+
+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.
+
+=============================================================================*/
+
+#include "ctkModuleValues.h"
+#include <iostream>
+#include "QFile"
+#include "QTextStream"
+#include "ctkModuleParameterGroup.h"
+
+//----------------------------------------------------------------------------
+const QVector<ctkModuleParameterGroupValue*>& ctkModuleValues::valueGroups() const
+{
+	return this->ValueGroups;
+}
+
+//----------------------------------------------------------------------------
+ctkModuleParameterGroupValue* ctkModuleValues::valueGroup(const QString& parameterName)const
+{
+  // iterate over each parameter group
+  foreach( ctkModuleParameterGroupValue* group, this->ValueGroups)
+    {
+    ctkModuleParameterValue* value = group->value(parameterName);
+    if (value)
+      {
+      return group;
+      }    
+    }
+  return 0;
+}
+
+//----------------------------------------------------------------------------
+ctkModuleParameterValue* ctkModuleValues::value(const QString& parameterName)const
+{
+  // iterate over each parameter group
+  foreach( const ctkModuleParameterGroupValue* group, this->ValueGroups)
+    {
+    ctkModuleParameterValue* value = group->value(parameterName);
+    if (value)
+      {
+      return value;
+      }    
+    }
+  return 0;
+}

+ 67 - 0
Libs/ModuleDescription/ctkModuleValues.h

@@ -0,0 +1,67 @@
+/*=============================================================================
+
+  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 __ctkModuleValues_h
+#define __ctkModuleValues_h
+
+// Qt includes
+#include <QVector>
+
+// Module parameter
+#include "ctkModuleParameterGroupValue.h"
+
+/**
+* Description of the parameters values of a module
+*
+* The parameters can be used for automated GUI generation or execution
+* of the module.
+*
+* 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).
+*/
+class CTK_MODULDESC_EXPORT ctkModuleValues
+{
+public:
+
+  const QVector<ctkModuleParameterGroupValue*>& valueGroups() const;
+  
+  // Return the group that contain the parameter value associated to the name
+  ctkModuleParameterGroupValue* valueGroup(const QString& parameterName) const;
+  // Return the first parameter value corresponding to the name from any group
+  ctkModuleParameterValue* value(const QString& parameterName) const;
+  
+private:
+  /// Groups of parameters
+  QVector<ctkModuleParameterGroupValue*> ValueGroups;
+};
+
+#endif