ctkDICOMModelObjectTest1.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. // CTK Core
  19. #include "ctkDICOMModelObject.h"
  20. // Qt includes
  21. #include <QApplication>
  22. #include <QFileDialog>
  23. #include <QString>
  24. #include <QTreeView>
  25. #include <QHeaderView>
  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", ".",
  38. "DCM (*)"
  39. );
  40. if( fileName.size() == 0 )
  41. {
  42. return EXIT_SUCCESS;
  43. }
  44. }
  45. ctkDICOMModelObject dcmInfoModel;
  46. dcmInfoModel.setFile(fileName);
  47. QTreeView *viewer = new QTreeView();
  48. viewer->setModel( &dcmInfoModel);
  49. viewer->expandAll();
  50. viewer->resizeColumnToContents(1);
  51. viewer->resizeColumnToContents(2);
  52. viewer->header()->setResizeMode( QHeaderView::Stretch);
  53. viewer->show();
  54. viewer->raise();
  55. return app.exec();
  56. }