浏览代码

Added ctkDICOMHost

Ivo Wolf 13 年之前
父节点
当前提交
105fd985aa

+ 40 - 0
Applications/ctkDICOMHost/CMakeLists.txt

@@ -0,0 +1,40 @@
+PROJECT(ctkDICOMHost)
+
+#
+# See CTK/CMake/ctkMacroBuildApp.cmake for details
+#
+  
+# Source files
+SET(KIT_SRCS
+  ctkDICOMHostMain.cpp
+  )
+
+# Headers that should run through moc
+SET(KIT_MOC_SRCS
+  )
+
+# UI files
+SET(KIT_UI_FORMS
+)
+
+# Resources
+SET(KIT_resources
+)
+
+# Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkFunctionGetTargetLibraries(KIT_target_libraries)
+
+ctkMacroBuildApp(
+  NAME ${PROJECT_NAME}
+  SRCS ${KIT_SRCS}
+  MOC_SRCS ${KIT_MOC_SRCS}
+  UI_FORMS ${KIT_UI_FORMS}
+  TARGET_LIBRARIES ${KIT_target_libraries}
+  RESOURCES ${KIT_resources}
+  )
+
+# Testing
+IF(BUILD_TESTING)
+  ADD_SUBDIRECTORY(Testing)
+ENDIF(BUILD_TESTING)

+ 1 - 0
Applications/ctkDICOMHost/Testing/CMakeLists.txt

@@ -0,0 +1 @@
+ADD_SUBDIRECTORY(Cpp)

+ 30 - 0
Applications/ctkDICOMHost/Testing/Cpp/CMakeLists.txt

@@ -0,0 +1,30 @@
+SET(KIT ${PROJECT_NAME})
+
+CREATE_TEST_SOURCELIST(Tests ${KIT}CppTests.cpp
+  ctkDICOMHostTest1.cpp
+  )
+
+SET (TestsToRun ${Tests})
+REMOVE (TestsToRun ${KIT}CppTests.cpp)
+
+# Target libraries - See CMake/ctkFunctionGetTargetLibraries.cmake
+# The following macro will read the target libraries from the file 'target_libraries.cmake'
+ctkFunctionGetTargetLibraries(KIT_target_libraries)
+
+ADD_EXECUTABLE(${KIT}CppTests ${Tests})
+TARGET_LINK_LIBRARIES(${KIT}CppTests ${KIT_target_libraries})
+
+SET( KIT_TESTS ${CPP_TEST_PATH}/${KIT}CppTests)
+IF(WIN32)
+  SET(KIT_TESTS ${CPP_TEST_PATH}/${CMAKE_BUILD_TYPE}/${KIT}CppTests)
+ENDIF(WIN32)
+
+MACRO( SIMPLE_TEST  TESTNAME )
+  ADD_TEST( ${TESTNAME} ${KIT_TESTS} ${TESTNAME} )
+  SET_PROPERTY(TEST ${TESTNAME} PROPERTY LABELS ${PROJECT_NAME})
+ENDMACRO( SIMPLE_TEST  )
+
+#
+# Add Tests
+#
+SIMPLE_TEST(ctkDICOMTest1)

+ 51 - 0
Applications/ctkDICOMHost/Testing/Cpp/ctkDICOMHostTest1.cpp

@@ -0,0 +1,51 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Kitware Inc.
+
+  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.txt
+
+  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.
+
+=========================================================================*/
+
+// Qt includes
+#include <QCoreApplication>
+#include <QProcess>
+
+// STD includes
+#include <cstdlib>
+#include <iostream>
+
+int ctkDICOMTest1(int argc, char * argv [])
+{
+  QCoreApplication app(argc, argv);
+  QString command = QString("ctkDICOM");
+  QProcess process;
+  process.start(command);
+  bool res = process.waitForStarted();
+  if (!res)
+    {
+    std::cerr << '\"' << qPrintable(command) << '\"'
+              << " didn't start correctly" << std::endl;
+    return res ? EXIT_SUCCESS : EXIT_FAILURE;
+    }
+  process.kill();
+  res = process.waitForFinished();
+  if (!res)
+    {
+    std::cerr << '\"' << qPrintable(command) << '\"'
+              << " failed to terminate" << std::endl;
+    return res ? EXIT_SUCCESS : EXIT_FAILURE;
+    }
+  return res ? EXIT_SUCCESS : EXIT_FAILURE;
+}

+ 15 - 0
Applications/ctkDICOMHost/Testing/Cpp/target_libraries.cmake

@@ -0,0 +1,15 @@
+#
+# See CMake/ctkFunctionGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK application.
+# 
+
+SET(target_libraries
+  )
+
+## Query / Retrieve Testing
+if(CTK_APP_ctkDICOMQuery AND CTK_APP_ctkDICOMRetrieve)
+  LIST(APPEND target_libraries 
+    CTKDICOMCore
+    )
+endif()

+ 89 - 0
Applications/ctkDICOMHost/ctkDICOMHostMain.cpp

@@ -0,0 +1,89 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) Isomics Inc.
+
+  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.txt
+
+  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.
+
+=========================================================================*/
+
+// Qt includes
+#include <QApplication>
+#include <QTreeView>
+#include <QSettings>
+#include <QDir>
+#include <QResource>
+
+// CTK widget includes
+#include <ctkDICOMAppWidget.h>
+
+// ctkDICOMCore includes
+#include "ctkDICOMDatabase.h"
+#include "ctkDICOMModel.h"
+
+// Logger
+#include "ctkLogger.h"
+
+// STD includes
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+  ctkLogger::configure();
+  QApplication app(argc, argv);
+
+  app.setOrganizationName("commontk");
+  app.setOrganizationDomain("commontk.org");
+  app.setApplicationName("ctkDICOM");
+
+  // set up Qt resource files
+  QResource::registerResource("./Resources/ctkDICOM.qrc");
+
+  QSettings settings;
+  QString databaseDirectory;
+
+  // set up the database 
+  if (argc > 1)
+  {
+    QString directory(argv[1]);
+    settings.setValue("DatabaseDirectory", directory);
+    settings.sync();
+  }
+
+  if ( settings.value("DatabaseDirectory", "") == "" )
+  {
+    databaseDirectory = QString("./ctkDICOM-Database");
+    std::cerr << "No DatabaseDirectory on command line or in settings.  Using \"" << databaseDirectory.toLatin1().data() << "\".\n";
+  } else
+  {
+    databaseDirectory = settings.value("DatabaseDirectory", "").toString();
+  }
+
+  QDir qdir(databaseDirectory);
+  if ( !qdir.exists(databaseDirectory) ) 
+  {
+    if ( !qdir.mkpath(databaseDirectory) )
+    {
+      std::cerr << "Could not create database directory \"" << databaseDirectory.toLatin1().data() << "\".\n";
+      return EXIT_FAILURE;
+    }
+  }
+
+  ctkDICOMAppWidget DICOMApp;
+
+  DICOMApp.setDatabaseDirectory(databaseDirectory);
+  DICOMApp.show();
+
+  return app.exec();
+}

+ 9 - 0
Applications/ctkDICOMHost/target_libraries.cmake

@@ -0,0 +1,9 @@
+#
+# See CMake/ctkFunctionGetTargetLibraries.cmake
+# 
+# This file should list the libraries required to build the current CTK application.
+# 
+
+SET(target_libraries
+  CTKDICOMWidgets
+  )

+ 1 - 0
CMakeLists.txt

@@ -391,6 +391,7 @@ SET(CTK_PLUGINS
 SET(CTK_APPLICATIONS
   ctkCLIPluginExplorer:OFF
   ctkDICOM:OFF
+  ctkDICOMHost:OFF
   ctkDICOMIndexer:OFF
   ctkDICOMDemoSCU:OFF
   ctkDICOMQuery:OFF