Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
QmitkPaintbrushToolGUI.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 
13 #include "QmitkPaintbrushToolGUI.h"
14 
16 
17 #include <qlabel.h>
18 #include <qlayout.h>
19 #include <qpainter.h>
20 #include <qpushbutton.h>
21 #include <qslider.h>
22 
24 {
25  // create the visible widgets
26  QBoxLayout *layout = new QHBoxLayout(this);
27  this->setContentsMargins(0, 0, 0, 0);
28 
29  QLabel *label = new QLabel("Size ", this);
30  QFont f = label->font();
31  f.setBold(false);
32  label->setFont(f);
33  layout->addWidget(label);
34 
35  m_SizeLabel = new QLabel(" 10", this);
36  f = m_SizeLabel->font();
37  f.setBold(false);
38  m_SizeLabel->setFont(f);
39  layout->addWidget(m_SizeLabel);
40 
41  // m_Slider = new QSlider( 1, 50, 1, 10, Qt::Horizontal, this );
42  m_Slider = new QSlider(Qt::Horizontal, this);
43  m_Slider->setMinimum(1);
44  m_Slider->setMaximum(50);
45  m_Slider->setPageStep(1);
46  m_Slider->setValue(10);
47  connect(m_Slider, SIGNAL(valueChanged(int)), this, SLOT(OnSliderValueChanged(int)));
48  layout->addWidget(m_Slider);
49 
50  /*
51  m_Frame = new QFrame( this );
52  m_Frame->setMinimumSize( QSize(50, 50) );
53  m_Frame->setFrameStyle( QFrame::Box || QFrame::Plain );
54  m_Frame->show();
55  layout->addWidget( m_Frame );
56  */
57 
58  connect(this, SIGNAL(NewToolAssociated(mitk::Tool *)), this, SLOT(OnNewToolAssociated(mitk::Tool *)));
59 }
60 
62 {
63  // !!!
64  if (m_PaintbrushTool.IsNotNull())
65  {
66  m_PaintbrushTool->SizeChanged -=
68  }
69 }
70 
72 {
73  if (m_PaintbrushTool.IsNotNull())
74  {
75  m_PaintbrushTool->SizeChanged -=
77  }
78 
79  m_PaintbrushTool = dynamic_cast<mitk::PaintbrushTool *>(tool);
80 
81  if (m_PaintbrushTool.IsNotNull())
82  {
83  m_PaintbrushTool->SizeChanged +=
85  }
86 }
87 
89 {
90  if (m_PaintbrushTool.IsNotNull())
91  {
92  m_PaintbrushTool->SetSize(value);
93  }
94 
96 }
97 
99 {
100  m_SizeLabel->setText(QString("%1 ").arg(size));
101 
102  /* nice, but useless. scale does not correspond to the image in a render window, so this is more or less useless */
103  /*
104  QPainter p( m_Frame );
105 
106  p.eraseRect( m_Frame->rect() );
107 
108  int width = size;
109  int height = size;
110  int x = m_Frame->width() / 2 - width / 2;
111  int y = m_Frame->height() / 2 - height / 2;
112  p.drawEllipse( x, y, width, height );
113  */
114 }
115 
117 {
118  m_Slider->setValue(current);
119 }
Paintbrush tool for InteractiveSegmentation.
Base class of all tools used by mitk::ToolManager.
Definition: mitkTool.h:86
void NewToolAssociated(mitk::Tool *)
mitk::PaintbrushTool::Pointer m_PaintbrushTool
void OnNewToolAssociated(mitk::Tool *)
Base class for GUIs belonging to mitk::Tool classes.
Definition: QmitkToolGUI.h:32