Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkBinaryThresholdULToolGUI.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 
19 
20 #include <qlabel.h>
21 #include <qlayout.h>
22 #include <qpushbutton.h>
23 #include <qslider.h>
24 
26 
28 {
29  // create the visible widgets
30  QBoxLayout *mainLayout = new QVBoxLayout(this);
31 
32  QLabel *label = new QLabel("Threshold :", this);
33  QFont f = label->font();
34  f.setBold(false);
35  label->setFont(f);
36  mainLayout->addWidget(label);
37 
38  QBoxLayout *layout = new QHBoxLayout();
39 
40  m_DoubleThresholdSlider = new ctkRangeWidget();
41  connect(
42  m_DoubleThresholdSlider, SIGNAL(valuesChanged(double, double)), this, SLOT(OnThresholdsChanged(double, double)));
43  layout->addWidget(m_DoubleThresholdSlider);
44  mainLayout->addLayout(layout);
45  m_DoubleThresholdSlider->setSingleStep(0.01);
46 
47  QPushButton *okButton = new QPushButton("Confirm Segmentation", this);
48  connect(okButton, SIGNAL(clicked()), this, SLOT(OnAcceptThresholdPreview()));
49  okButton->setFont(f);
50  mainLayout->addWidget(okButton);
51 
52  connect(this, SIGNAL(NewToolAssociated(mitk::Tool *)), this, SLOT(OnNewToolAssociated(mitk::Tool *)));
53 }
54 
56 {
57  // !!!
58  if (m_BinaryThresholdULTool.IsNotNull())
59  {
60  m_BinaryThresholdULTool->IntervalBordersChanged -=
63  m_BinaryThresholdULTool->ThresholdingValuesChanged -=
66  }
67 }
68 
70 {
71  if (m_BinaryThresholdULTool.IsNotNull())
72  {
73  m_BinaryThresholdULTool->IntervalBordersChanged -=
76  m_BinaryThresholdULTool->ThresholdingValuesChanged -=
79  }
80 
82 
83  if (m_BinaryThresholdULTool.IsNotNull())
84  {
85  m_BinaryThresholdULTool->IntervalBordersChanged +=
88  m_BinaryThresholdULTool->ThresholdingValuesChanged +=
91  }
92 }
93 
95 {
97  QString segName = QString::fromStdString(m_BinaryThresholdULTool->GetCurrentSegmentationName());
98 
99  dialog.SetSegmentationName(segName);
100  int result = dialog.exec();
101 
102  switch (result)
103  {
105  m_BinaryThresholdULTool->SetOverwriteExistingSegmentation(false);
106  break;
108  m_BinaryThresholdULTool->SetOverwriteExistingSegmentation(true);
109  break;
111  return;
112  }
113 
114  if (m_BinaryThresholdULTool.IsNotNull())
115  {
116  m_BinaryThresholdULTool->AcceptCurrentThresholdValue();
117  }
118 }
119 
120 void QmitkBinaryThresholdULToolGUI::OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat)
121 {
122  if (!isFloat)
123  {
124  m_DoubleThresholdSlider->setRange(int(lower), int(upper));
125  m_DoubleThresholdSlider->setSingleStep(1);
126  m_DoubleThresholdSlider->setDecimals(0);
127  }
128  else
129  {
130  m_DoubleThresholdSlider->setRange(lower, upper);
131  }
132 }
133 
135 {
136  m_DoubleThresholdSlider->setValues(lower, upper);
137 }
138 
140 {
141  m_BinaryThresholdULTool->SetThresholdValues(min, max);
142 }
void OnThresholdsChanged(double min, double max)
MITK_TOOL_GUI_MACRO(, QmitkPixelManipulationToolGUI,"")
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:92
double ScalarType
void OnThresholdingValuesChanged(mitk::ScalarType lower, mitk::ScalarType upper)
GUI for mitk::BinaryThresholdTool.
mitk::BinaryThresholdULTool::Pointer m_BinaryThresholdULTool
Base class for GUIs belonging to mitk::Tool classes.
Definition: QmitkToolGUI.h:36
static T max(T x, T y)
Definition: svm.cpp:70
void OnThresholdingIntervalBordersChanged(double lower, double upper, bool isFloat)
static T min(T x, T y)
Definition: svm.cpp:67
Calculates the segmented volumes for binary images.
#define MITKSEGMENTATIONUI_EXPORT