fw4spl
TagValueInstanceRemoveConfigurableSplitter.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/splitter/TagValueInstanceRemoveConfigurableSplitter.hpp"
8 #include "fwDicomIOFilterQt/widget/QTagSelectorWidget.hpp"
9 
10 #include <fwDicomIOFilter/registry/macros.hpp>
11 
12 #include <QApplication>
13 #include <QDialog>
14 #include <QDialogButtonBox>
15 #include <QHBoxLayout>
16 #include <QLineEdit>
17 #include <QPushButton>
18 #include <QVBoxLayout>
19 #include <QWidget>
20 
21 #include <dcmtk/dcmdata/dcdeftag.h>
22 
24 
25 namespace fwDicomIOFilterQt
26 {
27 namespace splitter
28 {
29 
31  "Tag value instance remove configurable splitter";
33  "Remove instances if a tag has a certain value.";
34 
35 //-----------------------------------------------------------------------------
36 
39  ::fwDicomIOFilter::splitter::TagValueInstanceRemoveSplitter(key)
40 {
41 }
42 
43 //-----------------------------------------------------------------------------
44 
46 {
47 }
48 
49 //-----------------------------------------------------------------------------
50 
52 {
54 }
55 
56 //-----------------------------------------------------------------------------
57 
59 {
60 
62 }
63 
64 //-----------------------------------------------------------------------------
65 
67 {
68  return true;
69 }
70 
71 //-----------------------------------------------------------------------------
72 
74 {
75  return true;
76 }
77 
78 //-----------------------------------------------------------------------------
79 
81 {
82  QDialog* dialog = new QDialog(qApp->activeWindow());
83  dialog->setWindowTitle(QString("Configure"));
84  QVBoxLayout* mainLayout = new QVBoxLayout();
85  dialog->setLayout(mainLayout);
86  dialog->setMinimumWidth(500);
87 
88  // Create tag selectors
90  new ::fwDicomIOFilterQt::widget::QTagSelectorWidget();
91  tagSelector->setTagValue(m_tag);
92  mainLayout->addWidget(tagSelector);
93 
94  // Create tag value field
95  QWidget* tagValueWidget = new QWidget();
96  mainLayout->addWidget(tagValueWidget);
97  QHBoxLayout* tagValueLayout = new QHBoxLayout();
98  tagValueWidget->setLayout(tagValueLayout);
99  tagValueLayout->addWidget(new QLabel("<b>Value:</b> "));
100  QLineEdit* tagValuelineEdit = new QLineEdit(m_tagValue.c_str());
101  tagValueLayout->addWidget(tagValuelineEdit, 1);
102  tagValueLayout->setContentsMargins(QMargins(0,0,0,0));
103 
104  // Create buttons
105  QDialogButtonBox* buttonBox = new QDialogButtonBox(dialog);
106  mainLayout->addWidget(buttonBox);
107  QPushButton* okButton = buttonBox->addButton(QDialogButtonBox::Ok);
108  QPushButton* cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
109 
110  QObject::connect(okButton, SIGNAL(clicked(void)), dialog, SLOT(accept(void)));
111  QObject::connect(cancelButton, SIGNAL(clicked(void)), dialog, SLOT(reject(void)));
112 
113 
114  int result = dialog->exec();
115  if(result == QDialog::Accepted)
116  {
117  m_tag = tagSelector->getTag();
118  m_tagValue = tagValuelineEdit->text().toStdString();
119  }
120 }
121 
122 } // namespace splitter
123 } // namespace fwDicomIOFilterQt
FWDICOMIOFILTERQT_API TagValueInstanceRemoveConfigurableSplitter(::fwDicomIOFilter::IFilter::Key key)
Constructor.
Widget used to select a dicom tag.
virtual FWDICOMIOFILTERQT_API std::string getDescription() const override
Return the description of the filter.
virtual FWDICOMIOFILTERQT_API bool isConfigurationRequired() const override
Return true if a configuration is required.
virtual FWDICOMIOFILTERQT_API std::string getName() const override
Return the name of the filter.
fwDicomIOFilter contains filters used to pre-process images before reading.
void setTagValue(const DcmTagKey &tag)
Set tag.
virtual FWDICOMIOFILTERQT_API bool isConfigurableWithGUI() const override
Return true if the filter is configurable using GUI.
Key class used to restrict access to Filter construction. See http://www.drdobbs.com/184402053.
virtual FWDICOMIOFILTERQT_API void configureWithGUI() override
Configure the filter using GUI dialog.
static FWDICOMIOFILTERQT_API const std::string s_FILTER_DESCRIPTION
Filter description.
fwDicomIOFilterQt contains filters used to pre-process images before reading.
std::string m_tagValue
Tag value used to determine if an instance must be removed.