Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
QmitkMultiLabelSegmentationPreferencePage.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;
47  berry::IPreferencesService* prefService
49 
50  m_SegmentationPreferencesNode = prefService->GetSystemPreferences()->Node("/org.mitk.views.multilabelsegmentation");
51 
52  m_MainControl = new QWidget(parent);
53 
54  QVBoxLayout* displayOptionsLayout = new QVBoxLayout;
55  m_RadioOutline = new QRadioButton( "Draw as outline", m_MainControl);
56  displayOptionsLayout->addWidget( m_RadioOutline );
57  m_RadioOverlay = new QRadioButton( "Draw as transparent overlay", m_MainControl);
58  displayOptionsLayout->addWidget( m_RadioOverlay );
59 
60  QFormLayout *formLayout = new QFormLayout;
61  formLayout->setHorizontalSpacing(8);
62  formLayout->setVerticalSpacing(24);
63  formLayout->addRow( "2D display", displayOptionsLayout );
64 
65  m_VolumeRenderingCheckBox = new QCheckBox( "Show as volume rendering", m_MainControl );
66  formLayout->addRow( "3D display", m_VolumeRenderingCheckBox );
67  connect( m_VolumeRenderingCheckBox, SIGNAL(stateChanged(int)), this, SLOT(OnVolumeRenderingCheckboxChecked(int)) );
68 
69  QFormLayout* surfaceLayout = new QFormLayout;
70  surfaceLayout->setSpacing(8);
71 
72  m_SmoothingSpinBox = new QDoubleSpinBox(m_MainControl);
73  m_SmoothingSpinBox->setMinimum(0.0);
74  m_SmoothingSpinBox->setSingleStep(0.5);
75  m_SmoothingSpinBox->setValue(0.1);
76  m_SmoothingSpinBox->setToolTip("The Smoothing value is used as Sigma for a gaussian blur.");
77  surfaceLayout->addRow("Smoothing value (mm)", m_SmoothingSpinBox);
78 
79  m_DecimationSpinBox = new QDoubleSpinBox(m_MainControl);
80  m_DecimationSpinBox->setMinimum(0.0);
81  m_DecimationSpinBox->setMaximum(0.99);
82  m_DecimationSpinBox->setSingleStep(0.1);
83  m_DecimationSpinBox->setValue(0.5);
84  m_DecimationSpinBox->setToolTip("Valid range is [0, 1). High values increase decimation, especially when very close to 1. A value of 0 disables decimation.");
85  surfaceLayout->addRow("Decimation rate", m_DecimationSpinBox);
86 
87  m_SelectionModeCheckBox = new QCheckBox("Enable auto-selection mode", m_MainControl);
88  m_SelectionModeCheckBox->setToolTip("If checked the segmentation plugin ensures that only one segmentation and the according greyvalue image are visible at one time.");
89  formLayout->addRow("Data node selection mode",m_SelectionModeCheckBox);
90 
91  formLayout->addRow("Smoothed surface creation", surfaceLayout);
92 
93  m_MainControl->setLayout(formLayout);
94  this->Update();
95  m_Initializing = false;
96 }
97 
99 {
100  return m_MainControl;
101 }
102 
104 {
105  m_SegmentationPreferencesNode->PutBool("draw outline", m_RadioOutline->isChecked());
106  m_SegmentationPreferencesNode->PutBool("volume rendering", m_VolumeRenderingCheckBox->isChecked());
107  m_SegmentationPreferencesNode->PutDouble("smoothing value", m_SmoothingSpinBox->value());
108  m_SegmentationPreferencesNode->PutDouble("decimation rate", m_DecimationSpinBox->value());
109  m_SegmentationPreferencesNode->PutBool("auto selection", m_SelectionModeCheckBox->isChecked());
110  return true;
111 }
112 
114 {
115 
116 }
117 
119 {
120  //m_EnableSingleEditing->setChecked(m_SegmentationPreferencesNode->GetBool("Single click property editing", true));
121  if (m_SegmentationPreferencesNode->GetBool("draw outline", true) )
122  {
123  m_RadioOutline->setChecked( true );
124  }
125  else
126  {
127  m_RadioOverlay->setChecked( true );
128  }
129 
130  m_VolumeRenderingCheckBox->setChecked( m_SegmentationPreferencesNode->GetBool("volume rendering", false) );
131 
132  if (m_SegmentationPreferencesNode->GetBool("smoothing hint", true))
133  {
134  m_SmoothingSpinBox->setDisabled(true);
135  }
136  else
137  {
138  m_SmoothingSpinBox->setEnabled(true);
139  }
140 
141  m_SelectionModeCheckBox->setChecked( m_SegmentationPreferencesNode->GetBool("auto selection", false) );
142 
143  m_SmoothingSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("smoothing value", 0.1));
144  m_DecimationSpinBox->setValue(m_SegmentationPreferencesNode->GetDouble("decimation rate", 0.5));
145 }
146 
148 {
149  if (m_Initializing) return;
150 
151  if ( state != Qt::Unchecked )
152  {
153  QMessageBox::information(nullptr,
154  "Memory warning",
155  "Turning on volume rendering of segmentations will make the application more memory intensive (and potentially prone to crashes).\n\n"
156  "If you encounter out-of-memory problems, try turning off volume rendering again.");
157  }
158 }
159 
161 {
162  if (state != Qt::Unchecked)
163  m_SmoothingSpinBox->setDisabled(true);
164  else
165  m_SmoothingSpinBox->setEnabled(true);
166 }
void Init(berry::IWorkbench::Pointer workbench) override
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
static IPreferencesService * GetPreferencesService()