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