Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
QmitkSegmentationPreferencePage.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 (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include <QLabel>
16 #include <QPushButton>
17 #include <QFormLayout>
18 #include <QCheckBox>
19 #include <QGroupBox>
20 #include <QRadioButton>
21 #include <QMessageBox>
22 #include <QDoubleSpinBox>
23 
25 #include <berryPlatform.h>
26 
28 : m_MainControl(nullptr)
29 , m_Initializing(false)
30 {
31 
32 }
33 
35 {
36 
37 }
38 
40 {
41 
42 }
43 
45 {
46  m_Initializing = true;
48 
49  m_SegmentationPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.views.segmentation");
50 
51  m_MainControl = new QWidget(parent);
52 
53  auto formLayout = new QFormLayout;
54  formLayout->setHorizontalSpacing(8);
55  formLayout->setVerticalSpacing(24);
56 
57  m_SlimViewCheckBox = new QCheckBox("Hide tool button texts and increase icon size", m_MainControl);
58  formLayout->addRow("Slim view", m_SlimViewCheckBox);
59 
60  auto displayOptionsLayout = new QVBoxLayout;
61  m_RadioOutline = new QRadioButton( "Draw as outline", m_MainControl);
62  displayOptionsLayout->addWidget( m_RadioOutline );
63  m_RadioOverlay = new QRadioButton( "Draw as transparent overlay", m_MainControl);
64  displayOptionsLayout->addWidget( m_RadioOverlay );
65  formLayout->addRow( "2D display", displayOptionsLayout );
66 
67  m_VolumeRenderingCheckBox = new QCheckBox( "Show as volume rendering", m_MainControl );
68  formLayout->addRow( "3D display", m_VolumeRenderingCheckBox );
69  connect( m_VolumeRenderingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnVolumeRenderingCheckboxChecked(int)) );
70 
71  auto surfaceLayout = new QFormLayout;
72  surfaceLayout->setSpacing(8);
73 
74  m_SmoothingCheckBox = new QCheckBox("Use image spacing as smoothing value hint", m_MainControl);
75  surfaceLayout->addRow(m_SmoothingCheckBox);
76  connect(m_SmoothingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnSmoothingCheckboxChecked(int)));
77 
78  m_SmoothingSpinBox = new QDoubleSpinBox(m_MainControl);
79  m_SmoothingSpinBox->setMinimum(0.0);
80  m_SmoothingSpinBox->setSingleStep(0.5);
81  m_SmoothingSpinBox->setValue(1.0);
82  m_SmoothingSpinBox->setToolTip("The Smoothing value is used as variance for a gaussian blur.");
83  surfaceLayout->addRow("Smoothing value (mm)", m_SmoothingSpinBox);
84 
85  m_DecimationSpinBox = new QDoubleSpinBox(m_MainControl);
86  m_DecimationSpinBox->setMinimum(0.0);
87  m_DecimationSpinBox->setMaximum(0.99);
88  m_DecimationSpinBox->setSingleStep(0.1);
89  m_DecimationSpinBox->setValue(0.5);
90  m_DecimationSpinBox->setToolTip("Valid range is [0, 1). High values increase decimation, especially when very close to 1. A value of 0 disables decimation.");
91  surfaceLayout->addRow("Decimation rate", m_DecimationSpinBox);
92 
93  m_ClosingSpinBox = new QDoubleSpinBox(m_MainControl);
94  m_ClosingSpinBox->setMinimum(0.0);
95  m_ClosingSpinBox->setMaximum(1.0);
96  m_ClosingSpinBox->setSingleStep(0.1);
97  m_ClosingSpinBox->setValue(0.0);
98  m_ClosingSpinBox->setToolTip("Valid range is [0, 1]. Higher values increase closing. A value of 0 disables closing.");
99  surfaceLayout->addRow("Closing Ratio", m_ClosingSpinBox);
100 
101  m_SelectionModeCheckBox = new QCheckBox("Enable auto-selection mode", m_MainControl);
102  m_SelectionModeCheckBox->setToolTip("If checked the segmentation plugin ensures that only one segmentation and the according greyvalue image are visible at one time.");
103  formLayout->addRow("Data node selection mode",m_SelectionModeCheckBox);
104 
105  formLayout->addRow("Smoothed surface creation", surfaceLayout);
106 
107  m_MainControl->setLayout(formLayout);
108  this->Update();
109  m_Initializing = false;
110 }
111 
113 {
114  return m_MainControl;
115 }
116 
118 {
119  m_SegmentationPreferencesNode->PutBool("slim view", m_SlimViewCheckBox->isChecked());
120  m_SegmentationPreferencesNode->PutBool("draw outline", m_RadioOutline->isChecked());
121  m_SegmentationPreferencesNode->PutBool("volume rendering", m_VolumeRenderingCheckBox->isChecked());
122  m_SegmentationPreferencesNode->PutBool("smoothing hint", m_SmoothingCheckBox->isChecked());
123  m_SegmentationPreferencesNode->PutDouble("smoothing value", m_SmoothingSpinBox->value());
124  m_SegmentationPreferencesNode->PutDouble("decimation rate", m_DecimationSpinBox->value());
125  m_SegmentationPreferencesNode->PutDouble("closing ratio", m_ClosingSpinBox->value());
126  m_SegmentationPreferencesNode->PutBool("auto selection", m_SelectionModeCheckBox->isChecked());
127  return true;
128 }
129 
131 {
132 
133 }
134 
136 {
137  //m_EnableSingleEditing->setChecked(m_SegmentationPreferencesNode->GetBool("Single click property editing", true));
138 
139  m_SlimViewCheckBox->setChecked(m_SegmentationPreferencesNode->GetBool("slim view", false));
140 
141  if (m_SegmentationPreferencesNode->GetBool("draw outline", true) )
142  {
143  m_RadioOutline->setChecked( true );
144  }
145  else
146  {
147  m_RadioOverlay->setChecked( true );
148  }
149 
150  m_VolumeRenderingCheckBox->setChecked( m_SegmentationPreferencesNode->GetBool("volume rendering", false) );
151 
152  if (m_SegmentationPreferencesNode->GetBool("smoothing hint", true))
153  {
154  m_SmoothingCheckBox->setChecked(true);
155  m_SmoothingSpinBox->setDisabled(true);
156  }
157  else
158  {
159  m_SmoothingCheckBox->setChecked(false);
160  m_SmoothingSpinBox->setEnabled(true);
161  }
162 
163  m_SelectionModeCheckBox->setChecked( m_SegmentationPreferencesNode->GetBool("auto selection", true) );
164 
165  m_SmoothingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("smoothing value", 1.0));
166  m_DecimationSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("decimation rate", 0.5));
167  m_ClosingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("closing ratio", 0.0));
168 }
169 
171 {
172  if (m_Initializing) return;
173 
174  if ( state != Qt::Unchecked )
175  {
176  QMessageBox::information(nullptr,
177  "Memory warning",
178  "Turning on volume rendering of segmentations will make the application more memory intensive (and potentially prone to crashes).\n\n"
179  "If you encounter out-of-memory problems, try turning off volume rendering again.");
180  }
181 }
182 
184 {
185  if (state != Qt::Unchecked)
186  m_SmoothingSpinBox->setDisabled(true);
187  else
188  m_SmoothingSpinBox->setEnabled(true);
189 }
void CreateQtControl(QWidget *widget) override
void Init(berry::IWorkbench::Pointer workbench) override
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
berry::IPreferences::Pointer m_SegmentationPreferencesNode
static IPreferencesService * GetPreferencesService()