ctkDICOMQueryRetrieveMain.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. #include <ctkDICOMUtil.h>
  22. // CTK widget includes
  23. #include <ctkDICOMQueryRetrieveWidget.h>
  24. // Logger
  25. #include "ctkLogger.h"
  26. #include "dcmtk/oflog/oflog.h"
  27. // STD includes
  28. #include <iostream>
  29. int main(int argc, char** argv)
  30. {
  31. // Set the DCMTK log level to debug
  32. ctk::setDICOMLogLevel(ctkErrorLogLevel::Debug);
  33. QApplication app(argc, argv);
  34. app.setOrganizationName("commontk");
  35. app.setOrganizationDomain("commontk.org");
  36. app.setApplicationName("ctkDICOMQueryRetrieve");
  37. QSettings settings;
  38. QString databaseDirectory;
  39. // set up the database
  40. if (argc > 1)
  41. {
  42. QString directory(argv[1]);
  43. settings.setValue("DatabaseDirectory", directory);
  44. settings.sync();
  45. }
  46. if ( settings.value("DatabaseDirectory", "") == "" )
  47. {
  48. databaseDirectory = QString("./ctkDICOM-Database");
  49. std::cerr << "No DatabaseDirectory on command line or in settings. Using \"" << databaseDirectory.toLatin1().data() << "\".\n";
  50. } else
  51. {
  52. databaseDirectory = settings.value("DatabaseDirectory", "").toString();
  53. }
  54. QDir qdir(databaseDirectory);
  55. if ( !qdir.exists(databaseDirectory) )
  56. {
  57. if ( !qdir.mkpath(databaseDirectory) )
  58. {
  59. std::cerr << "Could not create database directory \"" << databaseDirectory.toLatin1().data() << "\".\n";
  60. return EXIT_FAILURE;
  61. }
  62. }
  63. QString databaseFileName = databaseDirectory + QString("/ctkDICOM.sql");
  64. QSharedPointer<ctkDICOMDatabase> dicomDatabase = QSharedPointer<ctkDICOMDatabase> (new ctkDICOMDatabase);
  65. dicomDatabase->openDatabase(databaseFileName);
  66. ctkDICOMQueryRetrieveWidget queryRetrieve;
  67. queryRetrieve.setRetrieveDatabase(dicomDatabase);
  68. queryRetrieve.show();
  69. queryRetrieve.raise();
  70. return app.exec();
  71. }