ctkDICOMQueryRetrieveMain.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Isomics Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // Qt includes
  15. #include <QApplication>
  16. #include <QTreeView>
  17. #include <QSettings>
  18. #include <QDir>
  19. // CTK Core
  20. #include <ctkDICOMDatabase.h>
  21. // CTK widget includes
  22. #include <ctkDICOMQueryRetrieveWidget.h>
  23. // Logger
  24. #include "ctkLogger.h"
  25. #include "dcmtk/oflog/oflog.h"
  26. // STD includes
  27. #include <iostream>
  28. int main(int argc, char** argv)
  29. {
  30. ctkLogger::configure();
  31. // Set the DCMTK log level to debug
  32. dcmtk::log4cplus::Logger rootLogger = dcmtk::log4cplus::Logger::getRoot();
  33. rootLogger.setLogLevel(dcmtk::log4cplus::DEBUG_LOG_LEVEL);
  34. QApplication app(argc, argv);
  35. app.setOrganizationName("commontk");
  36. app.setOrganizationDomain("commontk.org");
  37. app.setApplicationName("ctkDICOMQueryRetrieve");
  38. QSettings settings;
  39. QString databaseDirectory;
  40. // set up the database
  41. if (argc > 1)
  42. {
  43. QString directory(argv[1]);
  44. settings.setValue("DatabaseDirectory", directory);
  45. settings.sync();
  46. }
  47. if ( settings.value("DatabaseDirectory", "") == "" )
  48. {
  49. databaseDirectory = QString("./ctkDICOM-Database");
  50. std::cerr << "No DatabaseDirectory on command line or in settings. Using \"" << databaseDirectory.toLatin1().data() << "\".\n";
  51. } else
  52. {
  53. databaseDirectory = settings.value("DatabaseDirectory", "").toString();
  54. }
  55. QDir qdir(databaseDirectory);
  56. if ( !qdir.exists(databaseDirectory) )
  57. {
  58. if ( !qdir.mkpath(databaseDirectory) )
  59. {
  60. std::cerr << "Could not create database directory \"" << databaseDirectory.toLatin1().data() << "\".\n";
  61. return EXIT_FAILURE;
  62. }
  63. }
  64. QString databaseFileName = databaseDirectory + QString("/ctkDICOM.sql");
  65. QSharedPointer<ctkDICOMDatabase> dicomDatabase = QSharedPointer<ctkDICOMDatabase> (new ctkDICOMDatabase);
  66. dicomDatabase->openDatabase(databaseFileName);
  67. ctkDICOMQueryRetrieveWidget queryRetrieve;
  68. queryRetrieve.setRetrieveDatabase(dicomDatabase);
  69. queryRetrieve.show();
  70. queryRetrieve.raise();
  71. return app.exec();
  72. }