ctkDICOMMain.cpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 Kitware 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.commontk.org/LICENSE
  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. // CTK widget includes
  18. #include <ctkDICOMQueryRetrieveWidget.h>
  19. // ctkDICOMCore includes
  20. #include "ctkDICOM.h"
  21. #include "ctkDICOMModel.h"
  22. // Logger
  23. #include "ctkLogger.h"
  24. // STD includes
  25. #include <iostream>
  26. int main(int argc, char** argv)
  27. {
  28. ctkLogger::configure();
  29. QApplication app(argc, argv);
  30. // set up the database
  31. const char *datbaseFileName = "/tmp/test.db";
  32. const char *datbaseScriptFileName = "/Users/pieper/ctk/latest/CTK/Libs/DICOM/Core/Resources/dicom-sample.sql";
  33. if (argc > 1)
  34. {
  35. datbaseFileName = argv[1];
  36. }
  37. if (argc > 2)
  38. {
  39. datbaseScriptFileName = argv[2];
  40. }
  41. ctkDICOM myCTK;
  42. try { myCTK.openDatabase( datbaseFileName ); }
  43. catch (std::exception e)
  44. {
  45. std::cerr << "Database error:" << qPrintable(myCTK.GetLastError());
  46. myCTK.closeDatabase();
  47. return EXIT_FAILURE;
  48. }
  49. try { myCTK.initializeDatabase(datbaseScriptFileName); }
  50. catch (std::exception e)
  51. {
  52. std::cerr << "Error when initializing the data base: " << datbaseScriptFileName
  53. << " error: " << myCTK.GetLastError().toStdString();
  54. return EXIT_FAILURE;
  55. }
  56. ctkDICOMModel model;
  57. model.setDatabase(myCTK.database());
  58. ctkDICOMQueryRetrieveWidget queryRetrieve;
  59. QTreeView *treeView = queryRetrieve.findChild<QTreeView *>("treeView");
  60. if (!treeView)
  61. {
  62. std::cerr << "Could not access tree view from QueryRetrieve widget\n";
  63. return EXIT_FAILURE;
  64. }
  65. treeView->setModel(&model);
  66. queryRetrieve.show();
  67. queryRetrieve.raise();
  68. return app.exec();
  69. }