ctkDICOM.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. // STD includes
  23. #include <iostream>
  24. int main(int argc, char** argv)
  25. {
  26. QApplication app(argc, argv);
  27. // set up the database
  28. const char *datbaseFileName = "/tmp/test.db";
  29. const char *datbaseScriptFileName = "/home/nolden/CTK/Libs/DICOM/Core/Resources/dicom-sample.sql";
  30. if (argc > 1)
  31. {
  32. datbaseFileName = argv[1];
  33. }
  34. if (argc > 2)
  35. {
  36. datbaseScriptFileName = argv[2];
  37. }
  38. ctkDICOM myCTK;
  39. if (!myCTK.openDatabase( datbaseFileName ))
  40. {
  41. std::cerr << "Error when opening the data base file: " << datbaseFileName
  42. << " error: " << myCTK.GetLastError().toStdString();
  43. return EXIT_FAILURE;
  44. }
  45. if (!myCTK.initializeDatabase(datbaseScriptFileName))
  46. {
  47. std::cerr << "Error when initializing the data base: " << datbaseScriptFileName
  48. << " error: " << myCTK.GetLastError().toStdString();
  49. return EXIT_FAILURE;
  50. }
  51. ctkDICOMModel model;
  52. model.setDatabase(myCTK.database());
  53. ctkDICOMQueryRetrieveWidget queryRetrieve;
  54. QTreeView *treeView = queryRetrieve.findChild<QTreeView *>("treeView");
  55. if (!treeView)
  56. {
  57. std::cerr << "Could not access tree view from QueryRetrieve widget\n";
  58. return EXIT_FAILURE;
  59. }
  60. treeView->setModel(&model);
  61. queryRetrieve.show();
  62. return app.exec();
  63. }