Browse Source

Merge branch 'mehrtash-ctk-dicom-object-list-widget' into ctk-dicom-object-list-widget

Alireza Mehrtash 11 years ago
parent
commit
506f46a555
37 changed files with 253 additions and 148 deletions
  1. 1 1
      Applications/ctkDICOM/CMakeLists.txt
  2. 1 1
      Applications/ctkDICOM2/CMakeLists.txt
  3. 2 2
      Applications/ctkDICOMDemoSCU/CMakeLists.txt
  4. 1 1
      Applications/ctkDICOMHost/CMakeLists.txt
  5. 1 1
      Applications/ctkDICOMIndexer/CMakeLists.txt
  6. 1 1
      Applications/ctkDICOMQuery/CMakeLists.txt
  7. 1 1
      Applications/ctkDICOMQueryRetrieve/CMakeLists.txt
  8. 1 1
      Applications/ctkDICOMRetrieve/CMakeLists.txt
  9. 1 1
      Applications/ctkEventBusDemo/CMakeLists.txt
  10. 1 1
      Applications/ctkExampleHost/CMakeLists.txt
  11. 2 2
      Applications/ctkExampleHostedApp/CMakeLists.txt
  12. 3 3
      Applications/ctkSimplePythonShell/Python/CMakeLists.txt
  13. 2 2
      Applications/ctkSimplePythonShell/Testing/Python/CMakeLists.txt
  14. 1 1
      CMake/LastConfigureStep/CMakeLists.txt
  15. 29 29
      CMakeLists.txt
  16. 1 1
      Libs/CommandLineModules/Documentation/CMakeLists.txt
  17. 64 61
      Libs/DICOM/Core/ctkDICOMObjectModel.cpp
  18. 1 1
      Libs/DICOM/Core/ctkDICOMObjectModel.h
  19. 4 4
      Libs/DICOM/Widgets/ctkDICOMObjectListWidget.cpp
  20. 5 5
      Libs/DICOM/Widgets/ctkDICOMObjectListWidget.h
  21. 1 1
      Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA1_test/CMakeLists.txt
  22. 1 1
      Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA2_test/CMakeLists.txt
  23. 1 1
      Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA_test/CMakeLists.txt
  24. 1 1
      Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginS_test/CMakeLists.txt
  25. 2 2
      Libs/PluginFramework/Testing/org.commontk.configadmintest/CMakeLists.txt
  26. 1 1
      Libs/PluginFramework/Testing/org.commontk.metatypetest/CMakeLists.txt
  27. 2 2
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest.perf/CMakeLists.txt
  28. 2 2
      Libs/PluginFramework/Testing/org.commontk.pluginfwtest/CMakeLists.txt
  29. 1 1
      Libs/Scripting/Python/Core/Python/CMakeLists.txt
  30. 26 0
      Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKObjectTestHelper.cpp
  31. 85 9
      Libs/Visualization/VTK/Core/ctkVTKObjectEventsObserver.cpp
  32. 1 1
      Libs/Widgets/Testing/Cpp/CMakeLists.txt
  33. 1 1
      Plugins/org.commontk.eventadmin/CMakeLists.txt
  34. 1 1
      Plugins/org.commontk.eventbus/CMakeLists.txt
  35. 2 2
      Plugins/org.commontk.plugingenerator.core/CMakeLists.txt
  36. 1 1
      Plugins/org.commontk.plugingenerator.ui/CMakeLists.txt
  37. 1 1
      Utilities/DGraph/CMakeLists.txt

+ 1 - 1
Applications/ctkDICOM/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOM)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMMain.cpp

+ 1 - 1
Applications/ctkDICOM2/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOM2)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOM2Main.cpp

+ 2 - 2
Applications/ctkDICOMDemoSCU/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOMDemoSCU)
 #
 # See CTK/CMake/ctkMacroBuildLib.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMDemoSCUMain.cpp
@@ -11,7 +11,7 @@ set(KIT_SRCS
 
 # Headers that should run through moc
 set(KIT_MOC_SRCS
-  
+
   )
 
 # UI files

+ 1 - 1
Applications/ctkDICOMHost/CMakeLists.txt

@@ -3,7 +3,7 @@ PROJECT(ctkDICOMHost)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 SET(KIT_SRCS
   ctkDICOMHostMain.cpp

+ 1 - 1
Applications/ctkDICOMIndexer/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOMIndexer)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMIndexerMain.cpp

+ 1 - 1
Applications/ctkDICOMQuery/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOMQuery)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMQueryMain.cpp

+ 1 - 1
Applications/ctkDICOMQueryRetrieve/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOMQueryRetrieve)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMQueryRetrieveMain.cpp

+ 1 - 1
Applications/ctkDICOMRetrieve/CMakeLists.txt

@@ -3,7 +3,7 @@ project(ctkDICOMRetrieve)
 #
 # See CTK/CMake/ctkMacroBuildApp.cmake for details
 #
-  
+
 # Source files
 set(KIT_SRCS
   ctkDICOMRetrieveMain.cpp

+ 1 - 1
Applications/ctkEventBusDemo/CMakeLists.txt

@@ -22,7 +22,7 @@ set(KIT_UI_FORMS
 
 # Resources
 set(KIT_resources
-  
+
 )
 
 # Target libraries - See CMake/ctkMacroGetTargetLibraries.cmake

+ 1 - 1
Applications/ctkExampleHost/CMakeLists.txt

@@ -22,7 +22,7 @@ set(KIT_UI_FORMS
 
 # Resources
 set(KIT_resources
-  
+
 )
 
 # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake

+ 2 - 2
Applications/ctkExampleHostedApp/CMakeLists.txt

@@ -15,12 +15,12 @@ set(KIT_MOC_SRCS
 
 # UI files
 set(KIT_UI_FORMS
-  
+
 )
 
 # Resources
 set(KIT_resources
-  
+
 )
 
 # Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake

+ 3 - 3
Applications/ctkSimplePythonShell/Python/CMakeLists.txt

@@ -3,10 +3,10 @@
 set(KIT_PYTHON_SCRIPTS
   ctkSimplePythonShell
   )
-  
+
 set(KIT_PYTHON_RESOURCES
   )
-  
+
 ctkMacroCompilePythonScript(
   TARGET_NAME ${PROJECT_NAME}
   SCRIPTS "${KIT_PYTHON_SCRIPTS}"
@@ -14,4 +14,4 @@ ctkMacroCompilePythonScript(
   DESTINATION_DIR ${CTK_BINARY_DIR}/bin/Python
   INSTALL_DIR ${CTK_INSTALL_BIN_DIR}
   )
-  
+

+ 2 - 2
Applications/ctkSimplePythonShell/Testing/Python/CMakeLists.txt

@@ -7,7 +7,7 @@ set(SCRIPTS
   wrappedSlotTest.py
   )
 
-# Since QTimer is part of QtCore and is used in both 'ctkWidgetsTest.py' and 'derivedQWidgetTest.py', 
+# Since QTimer is part of QtCore and is used in both 'ctkWidgetsTest.py' and 'derivedQWidgetTest.py',
 # these two tests should be included only if CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTCORE is ON
 
 if(CTK_LIB_Widgets AND CTK_LIB_Scripting/Python/Core_PYTHONQT_WRAP_QTCORE)
@@ -30,7 +30,7 @@ endif()
 foreach(script ${SCRIPTS})
   get_filename_component(scriptname ${script} NAME_WE)
   add_test(
-    NAME ctkSimplePythonShell_${scriptname} 
+    NAME ctkSimplePythonShell_${scriptname}
     COMMAND $<TARGET_FILE:ctkSimplePythonShell> ${CMAKE_CURRENT_SOURCE_DIR}/${script}
     )
   set_property(TEST ctkSimplePythonShell_${scriptname} PROPERTY LABELS ${KIT})

+ 1 - 1
CMake/LastConfigureStep/CMakeLists.txt

@@ -54,7 +54,7 @@ endforeach()
 
 set(CTK_EXTERNAL_LIBRARIES)
 
-# Loop over dependencies and append to CTK_EXTERNAL_LIBRARIES 
+# Loop over dependencies and append to CTK_EXTERNAL_LIBRARIES
 # target dependency which are neither CTK or static library
 set(link_type)
 foreach(ctk_target_dependency ${ctk_target_dependencies})

+ 29 - 29
CMakeLists.txt

@@ -306,7 +306,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
 
   ctkFunctionCheckCompilerFlags("-fdiagnostics-show-option" cflags)
   ctkFunctionCheckCompilerFlags("-Wl,--no-undefined" cflags)
-  
+
   ctkFunctionGetGccVersion(${CMAKE_CXX_COMPILER} GCC_VERSION)
 
   # With older version of gcc supporting the flag -fstack-protector-all, an extra dependency to libssp.so
@@ -371,7 +371,7 @@ ctk_enable_option(Widgets "Enable Qt Widget libraries" OFF
                   CTK_LIB_Widgets)
 
 # The CTK Plugin Framework, a dynamic component system based on OSGi.
-# This will enable only the framework itself.                  
+# This will enable only the framework itself.
 ctk_enable_option(PluginFramework "Enable Plugin Framework" OFF
                   CTK_LIB_PluginFramework)
 
@@ -450,34 +450,34 @@ ctk_lib_option(PluginFramework
 ctk_lib_option(Widgets
                "Build the Widgets library" OFF
                CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES) OR CTK_USE_QTTESTING)
-               
+
 ctk_lib_option(DICOM/Core
                "Build the DICOM Core library" OFF
                CTK_ENABLE_DICOM OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
-               
+
 ctk_lib_option(DICOM/Widgets
                "Build the DICOM Widgets library" OFF
                CTK_ENABLE_DICOM AND CTK_ENABLE_Widgets OR (CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES))
-               
+
 ctk_lib_option(ImageProcessing/ITK/Core
                "Build the ITK Core library" OFF)
-               
+
 ctk_lib_option(Scripting/Python/Core
                "Build the Python Core library" OFF)
-               
+
 ctk_lib_option(Scripting/Python/Widgets
                "Build the Python Widgets library" OFF
                CTK_LIB_Widgets AND CTK_ENABLE_Python_Wrapping)
-               
+
 ctk_lib_option(Visualization/VTK/Core
                "Build the VTK Core library" OFF)
-               
+
 ctk_lib_option(Visualization/VTK/Widgets
                "Build the VTK Widgets library" OFF)
-               
+
 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)
 
@@ -486,7 +486,7 @@ 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)
 
@@ -504,7 +504,7 @@ set(CTK_ENABLED_LIBS ${_enabled_libs} CACHE INTERNAL "" FORCE)
 #-----------------------------------------------------------------------------
 # CTK Applications - Use ON or OFF to indicate if the application should be built by default
 #
- 
+
 ctk_app_option(ctkDICOM
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
@@ -513,39 +513,39 @@ ctk_app_option(ctkDICOM
 ctk_app_option(ctkDICOM2
                "Build the new DICOM example application (experimental)" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMIndexer
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMDemoSCU
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMQuery
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMRetrieve
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMQueryRetrieve
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMHost
                "Build the DICOM application host example application" OFF
                CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkExampleHost
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkExampleHostedApp
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOMApplicationHosting AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkEventBusDemo
                "Build the DICOM example application" OFF
                CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
@@ -572,15 +572,15 @@ endif()
 ctk_app_option(ctkPluginBrowser
                "Build the DICOM example application" OFF
                CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkPluginGenerator
                "Build the DICOM example application" OFF
                CTK_ENABLE_PluginFramework AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkDICOMObjectViewer
                "Build the DICOM example application" OFF
                CTK_ENABLE_DICOM AND CTK_BUILD_EXAMPLES)
-               
+
 ctk_app_option(ctkSimplePythonShell
                "Build the DICOM example application" OFF
                CTK_ENABLE_Python_Wrapping AND CTK_BUILD_EXAMPLES)
@@ -614,7 +614,7 @@ set(plugin_list
   org.commontk.metatype
   )
 
-foreach(_plugin ${plugin_list})  
+foreach(_plugin ${plugin_list})
   ctk_plugin_option(${_plugin} "Build the ${_plugin} plugin." OFF)
 endforeach()
 
@@ -630,15 +630,15 @@ ctk_plugin_option(org.commontk.dah.hostedapp "Build the org.commontk.dah.hosteda
                   CTK_ENABLE_DICOMApplicationHosting)
 ctk_plugin_option(org.commontk.dah.host "Build the org.commontk.dah.host plugin." OFF
                   CTK_ENABLE_DICOMApplicationHosting)
-                  
+
 ctk_plugin_option(org.commontk.dah.exampleapp
                   "Build the org.commontk.dah.exampleapp plugin." OFF
                   CTK_APP_ctkExampleHostedApp)
-                  
+
 ctk_plugin_option(org.commontk.dah.cmdlinemoduleapp
                   "Build the org.commontk.dah.cmdlinemoduleapp plugin." OFF
                   CTK_APP_ctkCommandLineModuleApp)
-                  
+
 ctk_plugin_option(org.commontk.dah.examplehost
                   "Build the org.commontk.dah.examplehost plugin." OFF
                   CTK_APP_ctkExampleHost)

+ 1 - 1
Libs/CommandLineModules/Documentation/CMakeLists.txt

@@ -6,7 +6,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SO
 
 if (BUILD_TESTING AND
     CTK_LIB_CommandLineModules/Core AND CTK_LIB_CommandLineModules/Backend/LocalProcess)
-  
+
   # Compile source code snippets
   add_subdirectory(Snippets)
 endif()

+ 64 - 61
Libs/DICOM/Core/ctkDICOMObjectModel.cpp

@@ -51,8 +51,9 @@ public:
   void itemInsert( DcmItem *dataset, QStandardItem *parent);
   void seqInsert( DcmSequenceOfItems *dataset, QStandardItem *parent);
   QString getTagValue( DcmElement *dcmElem);
-  QStandardItem* populateModelRow(const QString& tagName,const QString& tagHexName,const QString& tagValue,
-    const QString& VRName, const QString& elementLengthQString, QStandardItem *parent);
+  QStandardItem* populateModelRow(const QString& tagName,const QString& tagHexName,
+    const QString& tagValue, const QString& VRName,
+    const QString& elementLengthQString, QStandardItem *parent);
 
   DcmFileFormat fileFormat;
   QStandardItem *rootItem;
@@ -66,6 +67,7 @@ ctkDICOMObjectModelPrivate::ctkDICOMObjectModelPrivate(ctkDICOMObjectModel& o):q
 ctkDICOMObjectModelPrivate::~ctkDICOMObjectModelPrivate()
 {
 }
+
 //------------------------------------------------------------------------------
 void ctkDICOMObjectModelPrivate::init()
 {
@@ -93,12 +95,12 @@ void ctkDICOMObjectModelPrivate::itemInsert( DcmItem *dataset, QStandardItem *pa
     QString tagName = tag.getTagName();
     //
     DcmTagKey tagX = tag.getXTag();
-    QString tagHexName = tagX.toString().c_str();    
+    QString tagHexName = tagX.toString().c_str();
     //
     DcmVR VR = dO->getVR();
     QString VRName = VR.getVRName();
     //
-        // Getting length
+    // Getting length
     int elementLength;
     elementLength = dO->getLength();
     QString elementLengthQString = QString::number(elementLength);
@@ -106,24 +108,24 @@ void ctkDICOMObjectModelPrivate::itemInsert( DcmItem *dataset, QStandardItem *pa
     DcmTag tagKey = tag.getXTag();
 	  // std::cout<< tagName.toUtf8().constData()<<std::endl;
     if( tagKey == DCM_SequenceDelimitationItem
-    || tagKey == DCM_ItemDelimitationItem
-    || "Item" == tagName)
+        || tagKey == DCM_ItemDelimitationItem
+        || "Item" == tagName)
       {
 	    return;
 	    }
-  
+
     DcmElement *dcmElem = dynamic_cast<DcmElement *> (dO);
     tagValue = getTagValue(dcmElem);
-  
+
     // Populate QStandardModel with current DICOM element tag name and value
     QStandardItem *tagItem = populateModelRow(tagName,tagHexName,tagValue,VRName,elementLengthQString,parent);
-    
+
     // check if the DICOM object is a SQ Data element and extract the nested DICOM objects
     if( dcmElem && !dcmElem->isLeaf())
-     {
-     // now dcmElem  points to a sequenceOfItems
-     ctkDICOMObjectModelPrivate::seqInsert( dynamic_cast<DcmSequenceOfItems*> (dcmElem), tagItem);   
-     }
+      {
+      // now dcmElem  points to a sequenceOfItems
+      ctkDICOMObjectModelPrivate::seqInsert( dynamic_cast<DcmSequenceOfItems*> (dcmElem), tagItem);
+      }
   }
 }
 
@@ -131,47 +133,47 @@ void ctkDICOMObjectModelPrivate::itemInsert( DcmItem *dataset, QStandardItem *pa
 //------------------------------------------------------------------------------
 void ctkDICOMObjectModelPrivate::seqInsert( DcmSequenceOfItems *dataset, QStandardItem *parent)
 {
-  DcmObject *dO = dataset->nextInContainer( NULL);
+  DcmObject *dO = dataset->nextInContainer(NULL);
 
- for( ; dO; dO = dataset->nextInContainer(dO))
-   {
+  for( ; dO; dO = dataset->nextInContainer(dO))
+    {
     DcmElement *dcmElem = dynamic_cast<DcmElement *> (dO);
     QString tagValue = "";
     DcmTag tag = dO->getTag();
     DcmTag tagKey = tag.getXTag();
     if( tagKey == DCM_SequenceDelimitationItem
-    || tagKey == DCM_ItemDelimitationItem)
-    {
+        || tagKey == DCM_ItemDelimitationItem)
+      {
       return;
-    }
-   
-   QString tagName = tag.getTagName();
-   //
-   DcmTagKey tagX = tag.getXTag();
-   QString tagHexName = tagX.toString().c_str();
-   //
-   DcmVR VR = dO->getVR();
-   QString VRName = VR.getVRName();
-   // Getting length
-   int elementLength;
-   elementLength = dO->getLength();
-   QString elementLengthQString = QString::number(elementLength);
-   //
-  if( dcmElem)
-   {
-     tagValue = getTagValue(dcmElem);
-   }
-  QStandardItem *tagItem = populateModelRow(tagName,tagHexName,tagValue,VRName,elementLengthQString,parent);
- 
-  if( dcmElem && !dcmElem->isLeaf())
-   {
-     ctkDICOMObjectModelPrivate::seqInsert( dynamic_cast<DcmSequenceOfItems*> (dcmElem), tagItem);   
-   }
-  else if( tag.getXTag() == DCM_Item)
-   {
-     itemInsert( dynamic_cast<DcmItem*> (dO), tagItem);   
+      }
+
+    QString tagName = tag.getTagName();
+    //
+    DcmTagKey tagX = tag.getXTag();
+    QString tagHexName = tagX.toString().c_str();
+    //
+    DcmVR VR = dO->getVR();
+    QString VRName = VR.getVRName();
+    // Getting length
+    int elementLength;
+    elementLength = dO->getLength();
+    QString elementLengthQString = QString::number(elementLength);
+    //
+    if( dcmElem)
+      {
+      tagValue = getTagValue(dcmElem);
+      }
+    QStandardItem *tagItem = populateModelRow(tagName,tagHexName,tagValue,VRName,elementLengthQString,parent);
+
+    if( dcmElem && !dcmElem->isLeaf())
+      {
+      ctkDICOMObjectModelPrivate::seqInsert( dynamic_cast<DcmSequenceOfItems*> (dcmElem), tagItem);
+      }
+    else if( tag.getXTag() == DCM_Item)
+      {
+      itemInsert( dynamic_cast<DcmItem*> (dO), tagItem);
+      }
    }
-  }
 }
 
 //------------------------------------------------------------------------------
@@ -183,14 +185,14 @@ QString ctkDICOMObjectModelPrivate::getTagValue( DcmElement *dcmElem)
   std::string sep;
   int mult = dcmElem->getVM();
   int pos;
-  
+
   if( mult>1)
     {
     value << "[" << mult << "] ";
     }
- 
+
   // TODO define max elem per line
-  
+
   for( pos=0; pos < mult; pos++)
     {
     value << sep;
@@ -203,17 +205,18 @@ QString ctkDICOMObjectModelPrivate::getTagValue( DcmElement *dcmElem)
     }
     if( pos < mult-1)
       {
-       value << " ...";
+      value << " ...";
       }
   tagValue = value.str().c_str();
-  
+
   return tagValue;
 }
 
 //------------------------------------------------------------------------------
- QStandardItem* ctkDICOMObjectModelPrivate::populateModelRow(const QString& tagName, const QString& tagHexName,
-   const QString& tagValue,const QString& VRName, const QString& elementLengthQString, QStandardItem *parent)
- {
+QStandardItem* ctkDICOMObjectModelPrivate::populateModelRow(const QString& tagName,
+   const QString& tagHexName, const QString& tagValue,const QString& VRName,
+   const QString& elementLengthQString, QStandardItem *parent)
+{
   // Create items
   QStandardItem *VRItem = new QStandardItem( VRName);
   QStandardItem *tagItem = new QStandardItem( tagName);
@@ -228,7 +231,7 @@ QString ctkDICOMObjectModelPrivate::getTagValue( DcmElement *dcmElem)
   valItem->setFlags(valItem->flags() & ~Qt::ItemIsEditable);
   // Insert items
   QList<QStandardItem *> modelRow;
-  
+
   modelRow.append( tagItem);
   modelRow.append( tagHexItem);
   modelRow.append( VRItem);
@@ -236,7 +239,7 @@ QString ctkDICOMObjectModelPrivate::getTagValue( DcmElement *dcmElem)
   modelRow.append( valItem);
   parent->appendRow( modelRow);
   return tagItem;
- }
+}
 
 //------------------------------------------------------------------------------
 ctkDICOMObjectModel::ctkDICOMObjectModel(QObject* parentObject)
@@ -245,7 +248,7 @@ ctkDICOMObjectModel::ctkDICOMObjectModel(QObject* parentObject)
 {
   Q_D(ctkDICOMObjectModel);
   d->init();
- }
+}
 
 //------------------------------------------------------------------------------
 ctkDICOMObjectModel::ctkDICOMObjectModel(const ctkDICOMObjectModel& other)
@@ -261,13 +264,13 @@ ctkDICOMObjectModel::~ctkDICOMObjectModel()
 void ctkDICOMObjectModel::setFile(const QString &fileName)
 {
   Q_D(ctkDICOMObjectModel);
- 
- OFCondition status = d->fileFormat.loadFile( fileName.toLatin1().data());
-  if( !status.good())
+
+  OFCondition status = d->fileFormat.loadFile( fileName.toLatin1().data());
+  if( !status.good() )
     {
 		// TODO: Add through error
     }
-  
+
   DcmDataset *dataset = d->fileFormat.getDataset();
   d->rootItem = ctkDICOMObjectModel::invisibleRootItem();
   d->itemInsert( dataset, d->rootItem);

+ 1 - 1
Libs/DICOM/Core/ctkDICOMObjectModel.h

@@ -35,7 +35,7 @@
 class ctkDICOMObjectModelPrivate;
 /// \ingroup DICOM_Core
 ///
-/// \brief .
+/// \brief Provides a Qt MVC-compatible wrapper around a ctkDICOMItem.
 ///
 class CTK_DICOM_CORE_EXPORT ctkDICOMObjectModel
 	: public QStandardItemModel

+ 4 - 4
Libs/DICOM/Widgets/ctkDICOMObjectListWidget.cpp

@@ -44,8 +44,8 @@ public:
   ~ctkDICOMObjectListWidgetPrivate();
   void populateDICOMObjectTreeView(const QString& fileName);
 
-QString currentFile;
-QStringList fileList;
+  QString currentFile;
+  QStringList fileList;
 
 };
 
@@ -109,13 +109,13 @@ void ctkDICOMObjectListWidget::setFileList(const QStringList& fileList)
   }
 }
 // --------------------------------------------------------------------------
-QString ctkDICOMObjectListWidget::currentFile()const
+QString ctkDICOMObjectListWidget::currentFile()
 {
   Q_D(const ctkDICOMObjectListWidget);
   return d->currentFile;
 }
 // --------------------------------------------------------------------------
-QStringList ctkDICOMObjectListWidget::fileList()const
+QStringList ctkDICOMObjectListWidget::fileList()
 {
   Q_D(const ctkDICOMObjectListWidget);
   return d->fileList;

+ 5 - 5
Libs/DICOM/Widgets/ctkDICOMObjectListWidget.h

@@ -31,9 +31,9 @@ class ctkDICOMObjectListWidgetPrivate;
 /// \ingroup DICOM_Widgets
 class CTK_DICOM_WIDGETS_EXPORT ctkDICOMObjectListWidget : public QWidget
 {
-    Q_OBJECT
-    Q_PROPERTY(QString currentFile READ currentFile WRITE setCurrentFile)
-    Q_PROPERTY(QStringList fileList READ fileList WRITE setFileList)
+  Q_OBJECT
+  Q_PROPERTY(QString currentFile READ currentFile WRITE setCurrentFile)
+  Q_PROPERTY(QStringList fileList READ fileList WRITE setFileList)
 
 public:
   typedef QWidget Superclass;
@@ -42,8 +42,8 @@ public:
   
   /// 
 
-  QString ctkDICOMObjectListWidget::currentFile()const;
-  QStringList ctkDICOMObjectListWidget::fileList()const;
+  QString currentFile();
+  QStringList fileList();
 
 protected:
   QScopedPointer<ctkDICOMObjectListWidgetPrivate> d_ptr;

+ 1 - 1
Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA1_test/CMakeLists.txt

@@ -14,7 +14,7 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA2_test/CMakeLists.txt

@@ -14,7 +14,7 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginA_test/CMakeLists.txt

@@ -14,7 +14,7 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Libs/PluginFramework/Testing/FrameworkTestPlugins/pluginS_test/CMakeLists.txt

@@ -17,7 +17,7 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 2 - 2
Libs/PluginFramework/Testing/org.commontk.configadmintest/CMakeLists.txt

@@ -28,11 +28,11 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_UI_FORMS
-  
+
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Libs/PluginFramework/Testing/org.commontk.metatypetest/CMakeLists.txt

@@ -19,7 +19,7 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 2 - 2
Libs/PluginFramework/Testing/org.commontk.pluginfwtest.perf/CMakeLists.txt

@@ -15,11 +15,11 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_UI_FORMS
-  
+
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 2 - 2
Libs/PluginFramework/Testing/org.commontk.pluginfwtest/CMakeLists.txt

@@ -17,11 +17,11 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_UI_FORMS
-  
+
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Libs/Scripting/Python/Core/Python/CMakeLists.txt

@@ -37,4 +37,4 @@ ctkMacroCompilePythonScript(
   DESTINATION_DIR ${CTK_BINARY_DIR}/bin/Python
   INSTALL_DIR ${CTK_INSTALL_BIN_DIR}
   )
-  
+

+ 26 - 0
Libs/Visualization/VTK/Core/Testing/Cpp/ctkVTKObjectTestHelper.cpp

@@ -27,6 +27,8 @@
 
 // VTK includes
 #include <vtkObject.h>
+#include <vtkTimerLog.h>
+#include <vtkSmartPointer.h>
 
 //------------------------------------------------------------------------------
 class ctkVTKObjectTestPrivate
@@ -84,6 +86,30 @@ bool ctkVTKObjectTest::test()
   
   vtkObject* object = vtkObject::New();
 
+
+  int numberOfConnections=10000;
+
+  qDebug() << "Create "<<numberOfConnections<<" connections...";
+  vtkSmartPointer<vtkTimerLog> timerLog = vtkSmartPointer<vtkTimerLog>::New();
+  timerLog->StartTimer();
+  for (int i = 1; i <= numberOfConnections; ++i)
+    {
+    this->qvtkConnect(object, i, this, SLOT(onVTKObjectModifiedPublic()));
+    }
+  timerLog->StopTimer();
+  double t1 = timerLog->GetElapsedTime();
+  qDebug() << "  elapsed time: " << t1 << "seconds";
+  
+  qDebug() << "Remove "<<numberOfConnections<<" connections...";
+  timerLog->StartTimer();
+  for (int i = numberOfConnections; i>=1 ; --i)
+    {
+    this->qvtkDisconnect(object, i, this, SLOT(onVTKObjectModifiedPublic()));
+    }
+  timerLog->StopTimer();
+  t1 = timerLog->GetElapsedTime();
+  qDebug() << "  elapsed time: " << t1 << "seconds";
+
   connection = this->qvtkConnect(object, vtkCommand::ModifiedEvent, 
                                  this, SLOT(onVTKObjectModifiedPublic()));
   if (connection.isEmpty() || object->GetReferenceCount() != 1)

+ 85 - 9
Libs/Visualization/VTK/Core/ctkVTKObjectEventsObserver.cpp

@@ -24,6 +24,7 @@
 #include <QList>
 #include <QHash>
 #include <QDebug>
+#include <QMultiMap>
 
 // CTK includes
 #include "ctkVTKObjectEventsObserver.h"
@@ -82,6 +83,10 @@ class ctkVTKObjectEventsObserverPrivate
 protected:
   ctkVTKObjectEventsObserver* const q_ptr;
 public:
+  /// ConnectionIndexType:
+  ///  key = hash (generated from the connection parameters)
+  ///  value = QT connection object name
+  typedef QMultiMap<unsigned long, ctkVTKConnection*> ConnectionIndexType;
   ctkVTKObjectEventsObserverPrivate(ctkVTKObjectEventsObserver& object);
 
   ///
@@ -104,9 +109,25 @@ public:
     return q->findChildren<ctkVTKConnection*>();
   }
 
+  /// Generate a number from the connection parameters that is most often
+  /// unique for each connection. The slot parameter is not used, as probably
+  /// the same objects with the same event are not connected to different slot.
+  static unsigned long generateConnectionIndexHash(const vtkObject* vtk_obj, unsigned long vtk_event, const QObject* qt_obj)
+  {
+    return reinterpret_cast<const unsigned char*>(vtk_obj)-reinterpret_cast<const unsigned char*>(qt_obj)+vtk_event;
+  }
+
   bool StrictTypeCheck;
   bool AllBlocked;
   bool ObserveDeletion;
+
+  /// An associative container to speed up findConnection.
+  /// No need to iterate through all the existing connections and check if it is
+  /// equal with the searched one.
+  /// All the connections are present in the index (to allow quick decision that
+  /// a connection does not exist), but a lazy deletion method is used (items
+  /// not necessarily removed from the index immediately when a connection is deleted).
+  mutable ConnectionIndexType ConnectionIndex;
 };
 
 //-----------------------------------------------------------------------------
@@ -142,6 +163,34 @@ ctkVTKObjectEventsObserverPrivate::findConnection(
   vtkObject* vtk_obj, unsigned long vtk_event,
   const QObject* qt_obj, const char* qt_slot)const
 {
+  // Linear search for connections is prohibitively slow when observing many objects
+  // (because connection->isEqual is slow)
+  Q_Q(const ctkVTKObjectEventsObserver);
+
+  if(vtk_obj != NULL && qt_slot != NULL &&
+     qt_obj != NULL && vtk_event != vtkCommand::NoEvent)
+    {
+    // All information is specified, so we can use the index to find the connection
+    unsigned long hash=generateConnectionIndexHash(vtk_obj, vtk_event, qt_obj);
+    ConnectionIndexType::iterator connectionIt = this->ConnectionIndex.find(hash);
+    while (connectionIt != this->ConnectionIndex.end() && connectionIt.key() == hash)
+      {
+      ctkVTKConnection* connection=connectionIt.value();
+      if (!q->children().contains(connection))
+        {
+        // connection has been deleted, so remove it from the index
+        connectionIt=this->ConnectionIndex.erase(connectionIt);
+        continue;
+        }
+      if (connection->isEqual(vtk_obj, vtk_event, qt_obj, qt_slot))
+        {
+        return connection;
+        }
+      ++connectionIt;
+      }
+    return 0;
+    }
+
   foreach (ctkVTKConnection* connection, this->connections())
     {
     if (connection->isEqual(vtk_obj, vtk_event, qt_obj, qt_slot))
@@ -149,6 +198,7 @@ ctkVTKObjectEventsObserverPrivate::findConnection(
       return connection;
       }
     }
+
   return 0;
 }
 
@@ -158,26 +208,29 @@ ctkVTKObjectEventsObserverPrivate::findConnections(
   vtkObject* vtk_obj, unsigned long vtk_event,
   const QObject* qt_obj, const char* qt_slot)const
 {
-  bool all_info = true;
-  if(vtk_obj == NULL || qt_slot == NULL ||
-     qt_obj == NULL || vtk_event == vtkCommand::NoEvent)
+  QList<ctkVTKConnection*> foundConnections;
+
+  if(vtk_obj != NULL && qt_slot != NULL &&
+     qt_obj != NULL && vtk_event != vtkCommand::NoEvent)
     {
-    all_info = false;
+    // All information is specified, so we can use the index to find the connection
+    ctkVTKConnection* connection=findConnection(vtk_obj, vtk_event, qt_obj, qt_slot);
+    if (connection)
+      {
+      foundConnections.append(connection);
+      }
+    return foundConnections;
     }
 
-  QList<ctkVTKConnection*> foundConnections;
   // Loop through all connection
   foreach (ctkVTKConnection* connection, this->connections())
     {
     if (connection->isEqual(vtk_obj, vtk_event, qt_obj, qt_slot))
       {
       foundConnections.append(connection);
-      if (all_info)
-        {
-        break;
-        }
       }
     }
+
   return foundConnections;
 }
 
@@ -313,6 +366,8 @@ QString ctkVTKObjectEventsObserver::addConnection(vtkObject* vtk_obj, unsigned l
 
   // Instantiate a new connection, set its parameters and add it to the list
   ctkVTKConnection * connection = ctkVTKConnectionFactory::instance()->createConnection(this);
+  d->ConnectionIndex.insert(ctkVTKObjectEventsObserverPrivate::generateConnectionIndexHash(vtk_obj, vtk_event, qt_obj), connection);
+
   connection->observeDeletion(d->ObserveDeletion);
   connection->setup(vtk_obj, vtk_event, qt_obj, qt_slot, priority, connectionType);
 
@@ -398,6 +453,26 @@ int ctkVTKObjectEventsObserver::removeConnection(vtkObject* vtk_obj, unsigned lo
     {
     delete connection;
     }
+
+  // Only remove shadow connections (connections in the index without a corresponding actual connection)
+  // from the index if the index size grew too big (shadow elements ratio >50% and minimum 100)
+  if (static_cast<int>(d->ConnectionIndex.size())>100+children().count()*2)
+  {
+    for (ctkVTKObjectEventsObserverPrivate::ConnectionIndexType::iterator connectionIt=d->ConnectionIndex.begin();
+      connectionIt!=d->ConnectionIndex.end();
+      /*upon deletion the increment is done already, so don't increment here*/)
+    {
+      ctkVTKConnection* connection=connectionIt.value();
+      if (!children().contains(connection))
+        {
+        // connection has been deleted, so remove it from the index
+        connectionIt=d->ConnectionIndex.erase(connectionIt);
+        continue;
+        }
+      ++connectionIt;
+    }
+  }
+
   return connections.count();
 }
 
@@ -414,3 +489,4 @@ bool ctkVTKObjectEventsObserver::containsConnection(vtkObject* vtk_obj, unsigned
   Q_D(const ctkVTKObjectEventsObserver);
   return (d->findConnection(vtk_obj, vtk_event, qt_obj, qt_slot) != 0);
 }
+

+ 1 - 1
Libs/Widgets/Testing/Cpp/CMakeLists.txt

@@ -320,7 +320,7 @@ SIMPLE_TEST( ctkWorkflowWidgetTest2 )
 # Add Tests expecting CTKData to be set
 #
 if(EXISTS "${CTKData_DIR}")
-  set(baseline_relative_location "Libs/Widgets") 
+  set(baseline_relative_location "Libs/Widgets")
   SIMPLE_TEST_WITH_DATA( ctkCrosshairLabelTest2 ${baseline_relative_location})
 endif()
 

+ 1 - 1
Plugins/org.commontk.eventadmin/CMakeLists.txt

@@ -109,7 +109,7 @@ set(PLUGIN_resources
 )
 
 set(PLUGIN_CACHED_RESOURCEFILES
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Plugins/org.commontk.eventbus/CMakeLists.txt

@@ -48,7 +48,7 @@ set(PLUGIN_MOC_SRCS
   )
 
 set(PLUGIN_UI_FORMS
- 
+
   )
 
 set(PLUGIN_resources

+ 2 - 2
Plugins/org.commontk.plugingenerator.core/CMakeLists.txt

@@ -23,11 +23,11 @@ set(PLUGIN_MOC_SRCS
 )
 
 set(PLUGIN_UI_FORMS
-  
+
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Plugins/org.commontk.plugingenerator.ui/CMakeLists.txt

@@ -20,7 +20,7 @@ set(PLUGIN_UI_FORMS
 )
 
 set(PLUGIN_resources
-  
+
 )
 
 ctkFunctionGetTargetLibraries(PLUGIN_target_libraries)

+ 1 - 1
Utilities/DGraph/CMakeLists.txt

@@ -53,4 +53,4 @@ add_executable(${PROJECT_NAME}
   ${CTK_SOURCE_DIR}/Libs/Core/ctkDependencyGraph.h
   ${CTK_SOURCE_DIR}/Libs/Core/ctkDependencyGraph.cpp)
 
-  
+