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