ctkDICOMTableManager.cpp 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. #include <QSplitter>
  24. class ctkDICOMTableManagerPrivate
  25. {
  26. Q_DECLARE_PUBLIC(ctkDICOMTableManager)
  27. protected:
  28. ctkDICOMTableManager* const q_ptr;
  29. public:
  30. ctkDICOMTableManagerPrivate(ctkDICOMTableManager& obj);
  31. ~ctkDICOMTableManagerPrivate();
  32. QVBoxLayout* layout;
  33. QBoxLayout* layoutTables;
  34. QPushButton* changeLayoutButton;
  35. QSplitter* tableSplitter;
  36. ctkDICOMTableView* patientsTable;
  37. ctkDICOMTableView* studiesTable;
  38. ctkDICOMTableView* seriesTable;
  39. void init();
  40. void setCTKDICOMDatabase(QSharedPointer<ctkDICOMDatabase> db);
  41. };
  42. ctkDICOMTableManagerPrivate::ctkDICOMTableManagerPrivate(ctkDICOMTableManager &obj)
  43. : q_ptr(&obj)
  44. {
  45. }
  46. ctkDICOMTableManagerPrivate::~ctkDICOMTableManagerPrivate()
  47. {
  48. }
  49. void ctkDICOMTableManagerPrivate::init()
  50. {
  51. //setup UI
  52. Q_Q(ctkDICOMTableManager);
  53. this->layout = new QVBoxLayout();
  54. this->layoutTables = new QBoxLayout(QBoxLayout::LeftToRight);
  55. this->patientsTable = new ctkDICOMTableView(q, "Patients");
  56. this->studiesTable = new ctkDICOMTableView(q, "Studies");
  57. this->studiesTable->setQueryForeignKey("PatientsUID");
  58. this->seriesTable = new ctkDICOMTableView(q, "Series");
  59. this->seriesTable->setQueryForeignKey("StudyInstanceUID");
  60. QObject::connect(this->patientsTable, SIGNAL(signalSelectionChanged(QStringList)),
  61. this->studiesTable, SLOT(onUpdateQuery(QStringList)));
  62. QObject::connect(this->studiesTable, SIGNAL(signalSelectionChanged(QStringList)),
  63. this->seriesTable, SLOT(onUpdateQuery(QStringList)));
  64. QObject::connect(this->patientsTable, SIGNAL(signalFilterChanged(const QStringList&)),
  65. this->studiesTable, SLOT(onUpdateQuery(const QStringList&)));
  66. QObject::connect(this->studiesTable, SIGNAL(signalFilterChanged(const QStringList&)),
  67. this->seriesTable, SLOT(onUpdateQuery(const QStringList&)));
  68. QObject::connect(this->studiesTable, SIGNAL(signalQueryChanged(QStringList)),
  69. this->seriesTable, SLOT(onUpdateQuery(const QStringList&)));
  70. //TODO Set the right sizepolicy
  71. this->patientsTable->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
  72. this->studiesTable->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
  73. this->seriesTable->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);
  74. tableSplitter = new QSplitter();
  75. tableSplitter->setChildrenCollapsible(false);
  76. // tableSplitter->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
  77. tableSplitter->addWidget(this->patientsTable);
  78. tableSplitter->addWidget(this->studiesTable);
  79. tableSplitter->addWidget(this->seriesTable);
  80. QHBoxLayout* buttonLayout = new QHBoxLayout();
  81. this->changeLayoutButton = new QPushButton();
  82. this->changeLayoutButton->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);
  83. QPixmap icon(":/Icons/vertical.png");
  84. this->changeLayoutButton->setIcon(icon);
  85. QObject::connect(this->changeLayoutButton, SIGNAL(clicked()), q, SLOT(onChangeLayoutPushed()));
  86. buttonLayout->addWidget(this->changeLayoutButton);
  87. QSpacerItem* spacer = new QSpacerItem(20,20,QSizePolicy::Expanding,QSizePolicy::Fixed);
  88. buttonLayout->addItem(spacer);
  89. this->layout->addLayout(buttonLayout);
  90. this->layout->addWidget(this->tableSplitter);
  91. q->setLayout(layout);
  92. }
  93. void ctkDICOMTableManagerPrivate::setCTKDICOMDatabase(QSharedPointer<ctkDICOMDatabase> db)
  94. {
  95. this->patientsTable->setCTKDicomDataBase(db);
  96. this->studiesTable->setCTKDicomDataBase(db);
  97. this->seriesTable->setCTKDicomDataBase(db);
  98. }
  99. //----------------------------------------------------------------------------
  100. // ctkDICOMTableManager methods
  101. //----------------------------------------------------------------------------
  102. ctkDICOMTableManager::ctkDICOMTableManager(QWidget *parent)
  103. :Superclass(parent)
  104. , d_ptr(new ctkDICOMTableManagerPrivate(*this))
  105. {
  106. Q_D(ctkDICOMTableManager);
  107. d->init();
  108. }
  109. ctkDICOMTableManager::ctkDICOMTableManager(QSharedPointer<ctkDICOMDatabase> db, QWidget *parent)
  110. : Superclass(parent)
  111. , d_ptr(new ctkDICOMTableManagerPrivate(*this))
  112. {
  113. Q_D(ctkDICOMTableManager);
  114. d->init();
  115. d->setCTKDICOMDatabase(db);
  116. }
  117. ctkDICOMTableManager::~ctkDICOMTableManager()
  118. {
  119. }
  120. void ctkDICOMTableManager::onChangeLayoutPushed()
  121. {
  122. Q_D(ctkDICOMTableManager);
  123. if(d->tableSplitter->orientation() == Qt::Vertical)
  124. {
  125. QPixmap icon(":/Icons/vertical.png");
  126. d->changeLayoutButton->setIcon(icon);
  127. d->tableSplitter->setOrientation(Qt::Horizontal);
  128. }
  129. else
  130. {
  131. QPixmap icon(":/Icons/horizontal.png");
  132. d->changeLayoutButton->setIcon(icon);
  133. d->tableSplitter->setOrientation(Qt::Vertical);
  134. }
  135. }
  136. void ctkDICOMTableManager::changeTableLayout(QBoxLayout::Direction direction)
  137. {
  138. Q_D(ctkDICOMTableManager);
  139. d->layoutTables->removeWidget(d->patientsTable);
  140. d->layoutTables->removeWidget(d->studiesTable);
  141. d->layoutTables->removeWidget(d->seriesTable);
  142. delete d->layoutTables;
  143. d->layoutTables = new QBoxLayout(direction);
  144. d->layoutTables->addWidget(d->patientsTable);
  145. d->layoutTables->addWidget(d->studiesTable);
  146. d->layoutTables->addWidget(d->seriesTable);
  147. d->layout->addLayout(d->layoutTables);
  148. }
  149. void ctkDICOMTableManager::setCTKDICOMDatabase(QSharedPointer<ctkDICOMDatabase> db)
  150. {
  151. Q_D(ctkDICOMTableManager);
  152. d->setCTKDICOMDatabase(db);
  153. }