fw4spl
QTagSelectorWidget.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2016.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwDicomIOFilterQt/widget/QTagSelectorWidget.hpp"
8 
9 #include <fwCore/spyLog.hpp>
10 #include <fwDcmtkTools/Dictionary.hpp>
11 
12 #include <QHBoxLayout>
13 #include <QVBoxLayout>
14 
15 #include <dcmtk/dcmdata/dctag.h>
16 
17 namespace fwDicomIOFilterQt
18 {
19 namespace widget
20 {
21 
22 
23 //-----------------------------------------------------------------------------
24 
25 QTagSelectorWidget::QTagSelectorWidget(QWidget* parent) : QWidget(parent)
26 {
27  // Load dictionary
29 
30  // Create main layout
31  QVBoxLayout* mainLayout = new QVBoxLayout();
32  this->setLayout(mainLayout);
33  mainLayout->setContentsMargins(QMargins(0,0,0,0));
34 
35  // Add tag label
36  m_tagNameLabel = new QLabel("<b>Tag name :</b> ");
37  mainLayout->addWidget(m_tagNameLabel);
38 
39  // Create bottom widget
40  QWidget* bottomWidget = new QWidget();
41  mainLayout->addWidget(bottomWidget);
42  QHBoxLayout* bottomLayout = new QHBoxLayout();
43  bottomWidget->setLayout(bottomLayout);
44  bottomLayout->setContentsMargins(QMargins(0,0,0,0));
45 
46  // Spin box
47  m_groupSpinBox = new ::fwDicomIOFilterQt::widget::QHexSpinBox();
48  m_elementSpinBox = new ::fwDicomIOFilterQt::widget::QHexSpinBox();
49 
50  bottomLayout->addWidget(new QLabel("<b>Group :</b>"));
51  bottomLayout->addWidget(m_groupSpinBox, 1);
52  bottomLayout->addWidget(new QLabel("<b>Element :</b>"));
53  bottomLayout->addWidget(m_elementSpinBox, 1);
54 
55  // Update current name
56  this->updateTagName();
57 
58  // Connect signals/slots
59  QObject::connect(m_groupSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateTagName(int)));
60  QObject::connect(m_elementSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateTagName(int)));
61 }
62 
63 //-----------------------------------------------------------------------------
64 
66 {
67  // Disconnect signales/slots
68  QObject::disconnect(m_groupSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateTagName(int)));
69  QObject::disconnect(m_elementSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateTagName(int)));
70 }
71 
72 //-----------------------------------------------------------------------------
73 
75 {
76  DcmTag tag(m_groupSpinBox->value(), m_elementSpinBox->value());
77  std::string text = "<b>Tag name :</b> " + std::string(tag.getTagName());
78  m_tagNameLabel->setText(text.c_str());
79 }
80 
81 //-----------------------------------------------------------------------------
82 
83 void QTagSelectorWidget::setTagValue(const DcmTagKey& tag)
84 {
85  m_groupSpinBox->setValue(tag.getGroup());
86  m_elementSpinBox->setValue(tag.getElement());
87  this->updateTagName();
88 }
89 
90 //-----------------------------------------------------------------------------
91 
93 {
94  return DcmTagKey(m_groupSpinBox->value(), m_elementSpinBox->value());
95 }
96 
97 
98 } // namespace widget
99 } // namespace fwDicomIOFilterQt
QPointer< QLabel > m_tagNameLabel
tag name label
static FWDCMTKTOOLS_API void loadDictionary()
Load the DICOM dictionary.
Definition: Dictionary.cpp:25
void updateTagName(int value=0)
Update tag name when selected tag changes.
void setTagValue(const DcmTagKey &tag)
Set tag.
QTagSelectorWidget(QWidget *parent=0)
Constructor.
This file defines SpyLog macros. These macros are used to log messages to a file or to the console du...
QPointer< ::fwDicomIOFilterQt::widget::QHexSpinBox > m_groupSpinBox
Group spin box.
fwDicomIOFilterQt contains filters used to pre-process images before reading.
QPointer< ::fwDicomIOFilterQt::widget::QHexSpinBox > m_elementSpinBox
Tag spin box.