SMILX  1.01
milxQtFile.h
1 /*=========================================================================
2  The Software is copyright (c) Commonwealth Scientific and Industrial Research Organisation (CSIRO)
3  ABN 41 687 119 230.
4  All rights reserved.
5 
6  Licensed under the CSIRO BSD 3-Clause License
7  You may not use this file except in compliance with the License.
8  You may obtain a copy of the License in the file LICENSE.md or at
9 
10  https://stash.csiro.au/projects/SMILI/repos/smili/browse/license.txt
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 =========================================================================*/
18 #ifndef MILXQTFILE
19 #define MILXQTFILE
20 
21 #include <QFile>
22 #include <QPointer>
23 //VTK
24 #include <vtkSmartPointer.h>
25 #include <vtkPolyData.h>
26 #include <vtkPolyDataCollection.h>
27 #include <vtkImageData.h>
28 #include <vtkCommand.h>
29 #include <vtkEventQtSlotConnect.h>
30 
31 #include "milxQtImage.h"
32 #include "milxQtModel.h"
33 
34 #include "milxFile.h"
35 
60 class MILXQT_EXPORT milxQtFile : public QFile
61 {
62  Q_OBJECT
63 
64 public:
69  milxQtFile(QObject *theParent = 0);
74  virtual ~milxQtFile();
75 
79  virtual inline const char * GetNameOfClass() const
80  {
81  return "milxQtFile";
82  }
83 
84 public slots:
91  QString supportedImageFormats();
98  bool is8BitFormat(const QString filename, bool &errorEncountered);
105  bool is32BitFormat(const QString filename, bool &errorEncountered);
112  bool isFieldFormat(const QString filename, bool &errorEncountered);
122  bool openImage(const QString filename, vtkImageData* data);
129  bool openImage(const QString filename, milxQtImage* data);
136  bool openImageSeries(milxQtImage* data, QString directoryPath = "");
137 
145  bool saveImage(const QString filename, vtkImageData* data);
152  bool saveImage(const QString filename, milxQtImage* data);
153 
162  bool openModel(const QString filename, vtkPolyData* data);
169  bool openModel(const QString filename, milxQtModel* data);
178  bool openModelCollection(vtkPolyDataCollection* collection, QStringList &filenames);
179  inline bool openModelCollection(vtkPolyDataCollection* collection)
180  {
181  QStringList tmpList;
182  return openModelCollection(collection, tmpList); //List is discarded
183  }
190  bool saveModel(const QString filename, vtkPolyData* data, const bool binary = false);
197  bool saveModel(const QString filename, milxQtModel* data, const bool binary = false);
204  bool saveScalarsOfModel(const QString filename, milxQtModel* data);
205 
207  inline std::vector< std::string > convertQStringList(const QStringList filenames)
208  {
209  std::vector< std::string > names;
210  foreach(QString name, filenames)
211  names.push_back(name.toStdString());
212 
213  return names;
214  }
215 
216  inline QString getPixelType()
217  {
218  return dataPixelType;
219  }
220  inline QString getComponentType()
221  {
222  return dataComponentType;
223  }
224  inline size_t getNumberOfDimensions()
225  {
226  return dataDimensions;
227  }
228  inline size_t getNumberOfComponents()
229  {
230  return dataComponents;
231  }
232 
233  void linkProgressEventOf(vtkObject * obj);
234  inline void updateQtEvents()
235  {
236  qApp->processEvents();
237  }
238 
239 protected:
240  QString name;
241  QString dataPixelType;
243  size_t dataComponents;
244  size_t dataDimensions;
245 
246  //Observer for the Qt event loop
247  itkEventQtObserver::Pointer observeProgress;
248 
249  vtkSmartPointer<vtkEventQtSlotConnect> Connector;
250 
251 private:
252 
253 };
254 
255 #endif // MILXQTFILE
QString dataComponentType
Component type of image read.
Definition: milxQtFile.h:242
size_t dataDimensions
Dimensions of image read.
Definition: milxQtFile.h:244
virtual const char * GetNameOfClass() const
ITK interfacing member for exceptions.
Definition: milxQtFile.h:79
This class represents the MILX Qt Image Display object using VTK.
Definition: milxQtImage.h:118
This class represents the MILX Qt File I/O object using VTK/ITK/Qt.
Definition: milxQtFile.h:60
This class represents the MILX Qt Model/Mesh Display object using VTK.
Definition: milxQtModel.h:115
#define MILXQT_EXPORT
Define Windows DLL importing.
Definition: milxQtAliases.h:80
QString dataPixelType
pixel type of image read
Definition: milxQtFile.h:241
vtkSmartPointer< vtkEventQtSlotConnect > Connector
VTK Events to slots convertor.
Definition: milxQtFile.h:249
std::vector< std::string > convertQStringList(const QStringList filenames)
Convert an QStringList to a vector of STL strings.
Definition: milxQtFile.h:207
size_t dataComponents
Components of vector of image read.
Definition: milxQtFile.h:243
QString name
Name of the last opened file.
Definition: milxQtFile.h:240