iRoCS Toolbox  1.1.0
HDF5DataIO.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 HDF5DATAIO_HH
26 #define HDF5DATAIO_HH
27 
28 #ifdef HAVE_CONFIG_H
29 #include <config.hh>
30 #endif
31 
32 #include <QtCore/QObject>
33 
34 #include "ColorMap.hh"
35 #include "Marker.hh"
36 
38 
40 class MultiChannelModel;
41 class ChannelSpecs;
42 class DataChannelSpecs;
43 class RGBChannelSpecs;
47 class IRoCSChannelSpecs;
49 class QTreeWidget;
50 
52 {
55  virtual ~ChannelMetaData();
56 
57 /*======================================================================*/
67 /*======================================================================*/
68  virtual void load(const std::string& h5FileName, int index);
69 
70 /*======================================================================*/
85 /*======================================================================*/
86  virtual int save(const std::string& h5FileName);
87 
88  std::string channelName;
89  std::string channelType;
90  float alpha;
91  bool visible;
92 };
93 
94 std::ostream& operator<<(std::ostream& os, const ChannelMetaData& channel);
95 
97 {
101 
102  void load(const std::string& h5FileName, int index);
103  int save(const std::string& h5FileName);
104 
105  blitz::TinyVector<double,3> color;
106  float displayMin, displayMax;
107  float gamma;
109 };
110 
111 std::ostream& operator<<(std::ostream& os, const DataChannelMetaData& channel);
112 
114 {
118 
119  void load(const std::string& h5FileName, int index);
120  int save(const std::string& h5FileName);
121 
122  float gamma;
125 };
126 
127 std::ostream& operator<<(std::ostream& os, const RGBChannelMetaData& channel);
128 
130 {
134 
135  void load(const std::string& h5FileName, int index);
136  int save(const std::string& h5FileName);
137 
139  std::vector<int> activeLabels;
140  std::map< int, blitz::TinyVector<float,3> > colorMap;
141 };
142 
143 std::ostream& operator<<(
144  std::ostream& os, const AnnotationChannelMetaData& channel);
145 
147 {
151 
152  void load(const std::string& h5FileName, int index);
153  int save(const std::string& h5FileName);
154 
156 };
157 
158 std::ostream& operator<<(
159  std::ostream& os, const VisualizationChannelMetaData& channel);
160 
162 {
166 
167  void load(const std::string& h5FileName, int index);
168  int save(const std::string& h5FileName);
169 
170  blitz::TinyVector<double,3> color;
171 };
172 
173 std::ostream& operator<<(
174  std::ostream& os, const SplineCurveChannelMetaData& channel);
175 
177 {
181 
182  void load(const std::string& h5FileName, int index);
183  int save(const std::string& h5FileName);
184 
185  blitz::TinyVector<double,3> color;
186 };
187 
188 std::ostream& operator<<(
189  std::ostream& os, const IRoCSChannelMetaData& channel);
190 
192 {
196 
197  void load(const std::string& h5FileName, int index);
198  int save(const std::string& h5FileName);
199 
200  blitz::TinyVector<double,3> color;
201 };
202 
203 std::ostream& operator<<(
204  std::ostream& os, const IRoCSSCTChannelMetaData& channel);
205 
206 class HDF5DataIO : public QObject
207 {
208 
209  Q_OBJECT
210 
211 public:
212 
213  enum DataAccessMode { Open, Save, ImportChannels, ExportChannel };
214 
215  enum RetVal { Ok, Skip, Abort, ReadError, WriteError };
216 
218  std::string const &fileName, DataAccessMode mode);
219  ~HDF5DataIO();
220 
221  RetVal run();
222 
223 private:
224 
225  // Read channel by meta data
226  RetVal readChannel(const DataChannelMetaData& metaData);
227  RetVal readChannel(const RGBChannelMetaData& metaData);
228  RetVal readChannel(const AnnotationChannelMetaData& metaData);
229  RetVal readChannel(const VisualizationChannelMetaData& metaData);
230  RetVal readChannel(const SplineCurveChannelMetaData& metaData);
231  RetVal readChannel(const IRoCSChannelMetaData& metaData);
232  RetVal readChannel(const IRoCSSCTChannelMetaData& metaData);
233 
234  template<typename DataT>
235  void writeVisualizationChannelAs(
236  VisualizationChannelSpecs *channel, std::string const &fileName);
237 
238  RetVal writeChannel(DataChannelSpecs* specs);
239  RetVal writeChannel(RGBChannelSpecs* specs);
240  RetVal writeChannel(AnnotationChannelSpecs* specs);
241  RetVal writeChannel(VisualizationChannelSpecs* specs);
242  RetVal writeChannel(SplineCurveChannelSpecs* specs);
243  RetVal writeChannel(IRoCSChannelSpecs* specs);
244  RetVal writeChannel(IRoCSSCTChannelSpecs* specs);
245 
246  MultiChannelModel* p_model;
247  std::string _fileName;
248  DataAccessMode _accessMode;
249 
250  LabellingMainWidget *p_mainWidget;
251  iRoCS::ProgressReporterQt4 *p_progress;
252 };
253 
254 #endif
std::ostream & operator<<(std::ostream &os, const ChannelMetaData &channel)
std::string channelName
Definition: HDF5DataIO.hh:88
blitz::TinyVector< double, 3 > color
Definition: HDF5DataIO.hh:105
virtual ~ChannelMetaData()
std::vector< int > activeLabels
Definition: HDF5DataIO.hh:139
blitz::TinyVector< double, 3 > color
Definition: HDF5DataIO.hh:200
std::map< int, blitz::TinyVector< float, 3 > > colorMap
Definition: HDF5DataIO.hh:140
virtual int save(const std::string &h5FileName)
Save the general metadata stored in this struct into the .labelling_qt4 group of the hdf5 file specif...
virtual void load(const std::string &h5FileName, int index)
Load the general metadata of channel with index <index> out of the .labelling_qt4 group of the hdf5 f...
std::string channelType
Definition: HDF5DataIO.hh:89
blitz::TinyVector< double, 3 > color
Definition: HDF5DataIO.hh:185
MarkerType
Marker.hh "liblabelling_qt4/Marker.hh".
Definition: Marker.hh:73
Marker::MarkerType markerType
Definition: HDF5DataIO.hh:138
blitz::TinyVector< double, 3 > color
Definition: HDF5DataIO.hh:170