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