fw4spl
TagValueConfigurableSplitter.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/TagValueConfigurableSplitter.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 <QPushButton>
16 #include <QVBoxLayout>
17 #include <QWidget>
18 
19 #include <dcmtk/dcmdata/dcdeftag.h>
20 
21 fwDicomIOFilterRegisterMacro( ::fwDicomIOFilterQt::splitter::TagValueConfigurableSplitter );
22 
23 namespace fwDicomIOFilterQt
24 {
25 namespace splitter
26 {
27 
28 const std::string TagValueConfigurableSplitter::s_FILTER_NAME = "Tag value configurable splitter";
30  "Split instances using a tag value.";
31 
32 //-----------------------------------------------------------------------------
33 
35  ::fwDicomIOFilter::splitter::TagValueSplitter(key)
36 {
37 }
38 
39 //-----------------------------------------------------------------------------
40 
42 {
43 }
44 
45 //-----------------------------------------------------------------------------
46 
48 {
50 }
51 
52 //-----------------------------------------------------------------------------
53 
55 {
56 
58 }
59 
60 //-----------------------------------------------------------------------------
61 
63 {
64  return true;
65 }
66 
67 //-----------------------------------------------------------------------------
68 
70 {
71  return true;
72 }
73 
74 //-----------------------------------------------------------------------------
75 
77 {
78  QDialog* dialog = new QDialog(qApp->activeWindow());
79  dialog->setWindowTitle(QString("Configure"));
80  QVBoxLayout* mainLayout = new QVBoxLayout();
81  dialog->setLayout(mainLayout);
82  dialog->setMinimumWidth(500);
83 
84  // Create tag selectors
86  new ::fwDicomIOFilterQt::widget::QTagSelectorWidget();
87  tagSelector->setTagValue(m_tag);
88  mainLayout->addWidget(tagSelector);
89 
90  // Create buttons
91  QDialogButtonBox* buttonBox = new QDialogButtonBox(dialog);
92  mainLayout->addWidget(buttonBox);
93  QPushButton* okButton = buttonBox->addButton(QDialogButtonBox::Ok);
94  QPushButton* cancelButton = buttonBox->addButton(QDialogButtonBox::Cancel);
95 
96  QObject::connect(okButton, SIGNAL(clicked(void)), dialog, SLOT(accept(void)));
97  QObject::connect(cancelButton, SIGNAL(clicked(void)), dialog, SLOT(reject(void)));
98 
99 
100  int result = dialog->exec();
101  if(result == QDialog::Accepted)
102  {
103  m_tag = tagSelector->getTag();
104  }
105 }
106 
107 } // namespace splitter
108 } // namespace fwDicomIOFilterQt
virtual FWDICOMIOFILTERQT_API void configureWithGUI() override
Configure the filter using GUI dialog.
Widget used to select a dicom tag.
fwDicomIOFilter contains filters used to pre-process images before reading.
virtual FWDICOMIOFILTERQT_API bool isConfigurationRequired() const override
Return true if a configuration is required.
virtual FWDICOMIOFILTERQT_API std::string getDescription() const override
Return the description of the filter.
void setTagValue(const DcmTagKey &tag)
Set tag.
virtual FWDICOMIOFILTERQT_API std::string getName() const override
Return the name of the filter.
virtual FWDICOMIOFILTERQT_API ~TagValueConfigurableSplitter()
Destructor.
Key class used to restrict access to Filter construction. See http://www.drdobbs.com/184402053.
static FWDICOMIOFILTERQT_API const std::string s_FILTER_NAME
Filter name.
virtual FWDICOMIOFILTERQT_API bool isConfigurableWithGUI() const override
Return true if the filter is configurable using GUI.
FWDICOMIOFILTERQT_API TagValueConfigurableSplitter(::fwDicomIOFilter::IFilter::Key key)
Constructor.
DcmTagKey m_tag
Tag used to sort instances.
fwDicomIOFilterQt contains filters used to pre-process images before reading.
static FWDICOMIOFILTERQT_API const std::string s_FILTER_DESCRIPTION
Filter description.