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