Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkXnatExperimentWidget.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological rmatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
18 
19 #include <ctkXnatExperiment.h>
20 
21 #include <QCompleter>
22 
23 QmitkXnatExperimentWidget::QmitkXnatExperimentWidget(QWidget *parent) : QWidget(parent)
24 {
25  m_Mode = INFO;
26  Init();
27 }
28 
29 QmitkXnatExperimentWidget::QmitkXnatExperimentWidget(Mode mode, QWidget *parent) : QWidget(parent), m_Mode(mode)
30 {
31  Init();
32 }
33 
35 {
36 }
37 
38 void QmitkXnatExperimentWidget::Init()
39 {
40  // Create GUI widgets from the Qt Designer's .ui file
41  m_Controls.setupUi(this);
42 
43  if (m_Mode == Mode::INFO)
44  {
45  // make not needed row invisible
46  m_Controls.labelLabel->setText("ID:");
47  m_Controls.mandatoryLabel->setVisible(false);
48  }
49  if (m_Mode == Mode::CREATE)
50  {
51  // change modality to xsiType
52  m_Controls.modalityLabel->setText("Type*:");
53 
54  // create list of all experiment session types
55  QStringList xsiTypeList;
56  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_CR_SESSION;
57  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_CT_SESSION;
58  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_DX_SESSION;
59  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_DX3DCRANIOFACIAL_SESSION;
60  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_ECG_SESSION;
61  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_EEG_SESSION;
62  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_EPS_SESSION;
63  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_ES_SESSION;
64  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_ESV_SESSION;
65  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_GM_SESSION;
66  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_GMV_SESSION;
67  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_HD_SESSION;
68  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_IO_SESSION;
69  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_MEG_SESSION;
70  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_MG_SESSION;
71  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_MR_SESSION;
72  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_OP_SESSION;
73  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_OPT_SESSION;
74  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_OTHER_DICOM_SESSION;
75  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_PET_SESSION;
76  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_RF_SESSION;
77  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_RT_SESSION;
78  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_SM_SESSION;
79  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_US_SESSION;
80  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_XA_SESSION;
81  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_XA3D_SESSION;
82  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_XC_SESSION;
83  xsiTypeList << ctkXnatDefaultSchemaTypes::XSI_XCV_SESSION;
84 
85  // create completer for experiment sessions
86  QCompleter *completer = new QCompleter(xsiTypeList, this);
87  m_Controls.modalityLineEdit->setCompleter(completer);
88  m_Controls.modalityLineEdit->setPlaceholderText("Start with \"xnat::\"");
89  }
90 }
91 
92 void QmitkXnatExperimentWidget::SetExperiment(ctkXnatExperiment *experiment)
93 {
94  m_Experiment = experiment;
95 
96  // Set the UI labels
97  if (m_Experiment->parent())
98  {
99  m_Controls.breadcrumbLabel->setText("Project:" + m_Experiment->parent()->parent()->property("name") +
100  " > Subject:" + m_Experiment->parent()->property("label"));
101  }
102  m_Controls.labelLineEdit->setText(m_Experiment->property("label"));
103  m_Controls.modalityLineEdit->setText(m_Experiment->property("modality"));
104  m_Controls.dateLineEdit->setText(m_Experiment->property("date"));
105  m_Controls.timeLineEdit->setText(m_Experiment->property("time"));
106  m_Controls.scannerLineEdit->setText(m_Experiment->property("scanner"));
107 }
108 
110 {
111  if (m_Mode == Mode::CREATE)
112  {
113  if (!m_Controls.labelLineEdit->text().isEmpty())
114  {
115  m_Experiment->setProperty("label", m_Controls.labelLineEdit->text());
116  }
117  if (!m_Controls.modalityLineEdit->text().isEmpty())
118  {
119  m_Experiment->setProperty("xsiType", m_Controls.modalityLineEdit->text());
120  }
121  if (!m_Controls.dateLineEdit->text().isEmpty())
122  {
123  m_Experiment->setProperty("date", m_Controls.dateLineEdit->text());
124  }
125  if (!m_Controls.timeLineEdit->text().isEmpty())
126  {
127  m_Experiment->setProperty("time", m_Controls.dateLineEdit->text());
128  }
129  if (!m_Controls.scannerLineEdit->text().isEmpty())
130  {
131  m_Experiment->setProperty("scanner", m_Controls.scannerLineEdit->text());
132  }
133  }
134 
135  return m_Experiment;
136 }
void SetExperiment(ctkXnatExperiment *experiment)
Ui::QmitkXnatExperimentWidgetControls m_Controls
QmitkXnatExperimentWidget(QWidget *parent=nullptr)
ctkXnatExperiment * GetExperiment() const