ctkDICOMObjectModelTest1.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*==========================================================================
  2. Library: CTK
  3. Copyright (c) University of Sheffield
  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
  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. // STD includes
  15. #include <iostream>
  16. #include <algorithm>
  17. #include <limits>
  18. // Qt includes
  19. #include <QApplication>
  20. #include <QFileDialog>
  21. #include <QHeaderView>
  22. #include <QString>
  23. #include <QTreeView>
  24. // CTK Core
  25. #include "ctkDICOMObjectModel.h"
  26. int main(int argv, char** argc)
  27. {
  28. QApplication app(argv, argc);
  29. QString fileName;
  30. if( QApplication::argc() > 1)
  31. {
  32. fileName = QApplication::argv()[1];
  33. }
  34. else
  35. {
  36. fileName = QFileDialog::getOpenFileName( 0,
  37. "Choose an image file", ".","DCM (*)" );
  38. if( fileName.size() == 0 )
  39. {
  40. return EXIT_SUCCESS;
  41. }
  42. }
  43. ctkDICOMObjectModel dcmInfoModel;
  44. dcmInfoModel.setFile(fileName);
  45. QTreeView *viewer = new QTreeView();
  46. viewer->setModel( &dcmInfoModel);
  47. viewer->expandAll();
  48. viewer->resizeColumnToContents(1);
  49. viewer->resizeColumnToContents(2);
  50. viewer->header()->setResizeMode( QHeaderView::Stretch);
  51. viewer->show();
  52. viewer->raise();
  53. return app.exec();
  54. }