ctkDICOMTableManager.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 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.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. // ctk includes
  15. #include "ctkDICOMTableManager.h"
  16. #include "ctkDICOMTableView.h"
  17. // Qt includes
  18. #include <QHBoxLayout>
  19. #include <QVBoxLayout>
  20. #include <QRadioButton>
  21. #include <QButtonGroup>
  22. #include <QPushButton>
  23. class ctkDICOMTableManagerPrivate
  24. {
  25. Q_DECLARE_PUBLIC(ctkDICOMTableManager)
  26. protected:
  27. ctkDICOMTableManager* const q_ptr;
  28. public:
  29. ctkDICOMTableManagerPrivate(ctkDICOMTableManager& obj);
  30. ~ctkDICOMTableManagerPrivate();
  31. QVBoxLayout* layout;
  32. QBoxLayout* layoutTables;
  33. ctkDICOMTableView* patientsTable;
  34. ctkDICOMTableView* studiesTable;
  35. ctkDICOMTableView* seriesTable;
  36. void init();
  37. };
  38. ctkDICOMTableManagerPrivate::ctkDICOMTableManagerPrivate(ctkDICOMTableManager &obj)
  39. : q_ptr(&obj)
  40. {
  41. }
  42. ctkDICOMTableManagerPrivate::~ctkDICOMTableManagerPrivate()
  43. {
  44. }
  45. void ctkDICOMTableManagerPrivate::init()
  46. {
  47. //setup UI
  48. Q_Q(ctkDICOMTableManager);
  49. this->layout = new QVBoxLayout();
  50. this->layoutTables = new QBoxLayout(QBoxLayout::LeftToRight);
  51. this->patientsTable = new ctkDICOMTableView();
  52. this->studiesTable = new ctkDICOMTableView();
  53. this->seriesTable = new ctkDICOMTableView();
  54. this->layoutTables->addWidget(patientsTable);
  55. this->layoutTables->addWidget(studiesTable);
  56. this->layoutTables->addWidget(seriesTable);
  57. QPushButton* changeLayoutButton = new QPushButton("Change Layout");
  58. QObject::connect(changeLayoutButton, SIGNAL(clicked()), q, SLOT(onChangeLayoutPushed()));
  59. this->layout->addWidget(changeLayoutButton);
  60. this->layout->addLayout(this->layoutTables);
  61. q->setLayout(layout);
  62. }
  63. //----------------------------------------------------------------------------
  64. // ctkDICOMTableManager methods
  65. //----------------------------------------------------------------------------
  66. ctkDICOMTableManager::ctkDICOMTableManager(QWidget *parent)
  67. :Superclass(parent)
  68. , d_ptr(new ctkDICOMTableManagerPrivate(*this))
  69. {
  70. Q_D(ctkDICOMTableManager);
  71. d->init();
  72. }
  73. ctkDICOMTableManager::~ctkDICOMTableManager()
  74. {
  75. }
  76. void ctkDICOMTableManager::onChangeLayoutPushed()
  77. {
  78. Q_D(ctkDICOMTableManager);
  79. if (d->layoutTables->direction() == QBoxLayout::TopToBottom)
  80. {
  81. this->changeTableLayout(QBoxLayout::LeftToRight);
  82. }
  83. else
  84. {
  85. this->changeTableLayout(QBoxLayout::TopToBottom);
  86. }
  87. }
  88. void ctkDICOMTableManager::changeTableLayout(QBoxLayout::Direction direction)
  89. {
  90. Q_D(ctkDICOMTableManager);
  91. d->layoutTables->removeWidget(d->patientsTable);
  92. d->layoutTables->removeWidget(d->studiesTable);
  93. d->layoutTables->removeWidget(d->seriesTable);
  94. delete d->layoutTables;
  95. d->layoutTables = new QBoxLayout(direction);
  96. d->layoutTables->addWidget(d->patientsTable);
  97. d->layoutTables->addWidget(d->studiesTable);
  98. d->layoutTables->addWidget(d->seriesTable);
  99. d->layout->addLayout(d->layoutTables);
  100. }