iRoCS Toolbox  1.1.0
HDF5SelectionDialog.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * This file belongs to the iRoCS Toolbox.
4  *
5  * Copyright (C) 2015 Thorsten Falk
6  *
7  * Image Analysis Lab, University of Freiburg, Germany
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  **************************************************************************/
24 
25 #ifndef HDF5SELECTIONDIALOG_HH
26 #define HDF5SELECTIONDIALOG_HH
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.hh>
30 #endif
31 
32 #include <QtGui/QDialog>
33 #include <QtGui/QTreeWidget>
34 
35 #include "ChannelSpecs.hh"
36 
38 
39 class QTreeWidgetItem;
40 
41 class MultiChannelModel;
42 
43 class HDF5TreeWidget : public QTreeWidget
44 {
45 
46  Q_OBJECT
47 
48 public:
49 
51 
52  HDF5TreeWidget(QWidget *parent = NULL);
53  HDF5TreeWidget(std::string const &fileName, QWidget *parent = NULL);
55 
56  void setFileName(std::string const &fileName);
57  std::string const &fileName() const;
58 
59  bool isValid() const;
60  QString const &errorString() const;
61 
62  void setSelectable(ItemType type, bool enable = true);
63  void setSelectable(ChannelSpecs::ChannelTypes types, bool enable = true);
64 
65  std::string absoluteItemPath(QTreeWidgetItem const *item) const;
66 
67 public slots:
68 
69  void adjustColumnWidths();
70 
71 private:
72 
73  void _createGroupItem(
74  QTreeWidgetItem *item, BlitzH5File const &inFile,
75  std::string const &groupName);
76  void _createDatasetItem(
77  QTreeWidgetItem *item, BlitzH5File const &inFile,
78  std::string const &dsName);
79  void _addH5Objects(QTreeWidgetItem* group, const BlitzH5File& inFile);
80  void _generateTree();
81 
82  std::string _fileName;
83  std::map<QTreeWidgetItem*, ItemType> _itemTypes;
84  std::map<QTreeWidgetItem*, ChannelSpecs::ChannelType> _itemChannelTypes;
85  bool _valid;
86  QString _errorString;
87 
88 };
89 
90 class HDF5ColorMapSelectionDialog : public QDialog
91 {
92 
93  Q_OBJECT
94 
95 public:
96 
97  static std::string selectColorMap(
98  QString const &filename, QWidget *parent = NULL);
99 
100 private:
101 
102  HDF5ColorMapSelectionDialog(QString const &fileName, QWidget *parent);
104 
105  std::string selectedItem() const;
106 
107 private:
108 
109  QString _filename;
110  HDF5TreeWidget* p_h5TreeWidget;
111 
112 };
113 
114 class HDF5SelectionDialog : public QDialog
115 {
116 
117  Q_OBJECT
118 
119 public:
120 
121  static std::vector<std::string> selectObjects(
122  const QString& filename, MultiChannelModel *model = NULL,
123  QWidget* parent = NULL, ChannelSpecs::ChannelTypes types =
125 
126  static std::string selectObject(
127  const QString& filename, MultiChannelModel *model = NULL,
128  QWidget* parent = NULL, ChannelSpecs::ChannelTypes types =
130 
131 private:
132 
134  const QString& fileName, MultiChannelModel *model,
135  QWidget *parent, ChannelSpecs::ChannelTypes types);
137 
138  std::vector<std::string> selectedItems() const;
139 
140 private:
141 
142  MultiChannelModel *p_model;
143  QString _filename;
144  HDF5TreeWidget* p_h5TreeWidget;
145  ChannelSpecs::ChannelTypes _channelTypes;
146 
147 };
148 
149 #endif
HDF5TreeWidget(QWidget *parent=NULL)
QString const & errorString() const
void setFileName(std::string const &fileName)
Lightweight alternative to libBlitzHDF5 providing its basic functionality.
void adjustColumnWidths()
bool isValid() const
std::string const & fileName() const
void setSelectable(ItemType type, bool enable=true)
std::string absoluteItemPath(QTreeWidgetItem const *item) const
static ChannelTypes const Any
Definition: ChannelSpecs.hh:70