NorMIT-nav  22.09
An IGT application
cxImageDataContainer.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 #ifndef CXIMAGEDATACONTAINER_H
12 #define CXIMAGEDATACONTAINER_H
13 
14 #include "cxResourceExport.h"
15 
16 #include "vtkForwardDeclarations.h"
17 #include "cxForwardDeclarations.h"
18 #include <vector>
19 
20 namespace cx
21 {
22 
34 class cxResource_EXPORT CachedImageData
35 {
36 public:
40  explicit CachedImageData(QString filename, vtkImageDataPtr image = NULL);
41  ~CachedImageData();
45  QString getFilename() { return mFilename; }
46  vtkImageDataPtr getImage(FileManagerServicePtr filemanager);
51  bool purge();
52 
53 private:
54  QString mFilename;
55  vtkImageDataPtr mImageData;
56 };
57 typedef boost::shared_ptr<CachedImageData> CachedImageDataPtr;
58 
65 class cxResource_EXPORT ImageDataContainer
66 {
67 public:
68  virtual ~ImageDataContainer() {}
69  virtual vtkImageDataPtr get(unsigned index) = 0;
70  virtual unsigned size() const = 0;
71  bool empty() const { return this->size()==0; }
72  virtual bool purge(unsigned index) { return false; }
73  virtual void purgeAll();
74 };
75 typedef boost::shared_ptr<ImageDataContainer> ImageDataContainerPtr;
76 
83 class cxResource_EXPORT CachedImageDataContainer : public ImageDataContainer
84 {
85 public:
87  CachedImageDataContainer(QString baseFilename, int size, FileManagerServicePtr filemanagerservice);
88  CachedImageDataContainer(std::vector<QString> frames, FileManagerServicePtr filemanagerservice);
89 // CachedImageDataContainer(std::vector<CachedImageDataPtr> frames);
90  virtual ~CachedImageDataContainer();
91  virtual vtkImageDataPtr get(unsigned index);
92  virtual QString getFilename(unsigned index);
93  virtual unsigned size() const;
94  virtual bool purge(unsigned index) { return mImages[index]->purge(); }
99  void setDeleteFilesOnRelease(bool on) { mDeleteFilesOnRelease = on; }
100  void append(QString filename);
101 private:
102  std::vector<CachedImageDataPtr> mImages;
103  bool mDeleteFilesOnRelease;
104  FileManagerServicePtr mFileManagerService;
106 };
107 typedef boost::shared_ptr<CachedImageDataContainer> CachedImageDataContainerPtr;
108 
114 class cxResource_EXPORT SplitFramesContainer : public ImageDataContainer
115 {
116 public:
119  virtual vtkImageDataPtr get(unsigned index);
120  virtual unsigned size() const;
121 private:
122  std::vector<vtkImageDataPtr> mImages;
123  vtkImageDataPtr mOptionalWholeBase;
124 };
125 
132 class cxResource_EXPORT FramesDataContainer : public ImageDataContainer
133 {
134 public:
135  FramesDataContainer(std::vector<vtkImageDataPtr> images);
136  virtual ~FramesDataContainer() {}
137  virtual vtkImageDataPtr get(unsigned index);
138  virtual unsigned size() const;
139 private:
140  std::vector<vtkImageDataPtr> mImages;
141 };
142 
143 
148 } // namespace cx
149 
150 
151 
152 #endif // CXIMAGEDATACONTAINER_H
cx::CachedImageDataContainer::setDeleteFilesOnRelease
void setDeleteFilesOnRelease(bool on)
Definition: cxImageDataContainer.h:99
cx::CachedImageData::getFilename
QString getFilename()
Definition: cxImageDataContainer.h:45
cx::CachedImageDataPtr
boost::shared_ptr< CachedImageData > CachedImageDataPtr
Definition: cxImageDataContainer.h:57
cx
Namespace for all CustusX production code.
Definition: cx_dev_group_definitions.h:13
cxForwardDeclarations.h
cx::CachedImageData
Definition: cxImageDataContainer.h:34
vtkImageDataPtr
vtkSmartPointer< class vtkImageData > vtkImageDataPtr
Definition: cxVideoConnectionWidget.h:30
cx::ImageDataContainer
Definition: cxImageDataContainer.h:65
cx::ImageDataContainer::empty
bool empty() const
Definition: cxImageDataContainer.h:71
cx::FileManagerServicePtr
boost::shared_ptr< class FileManagerService > FileManagerServicePtr
Definition: cxLogicManager.h:31
cx::CachedImageDataContainer::purge
virtual bool purge(unsigned index)
Definition: cxImageDataContainer.h:94
cx::CachedImageDataContainer
Definition: cxImageDataContainer.h:83
cx::ImageDataContainer::purge
virtual bool purge(unsigned index)
Definition: cxImageDataContainer.h:72
vtkForwardDeclarations.h
cx::SplitFramesContainer
Definition: cxImageDataContainer.h:114
cx::ImageDataContainerPtr
boost::shared_ptr< class ImageDataContainer > ImageDataContainerPtr
Definition: cxUSFrameData.h:24
cx::CachedImageDataContainerPtr
boost::shared_ptr< class CachedImageDataContainer > CachedImageDataContainerPtr
Definition: cxSavingVideoRecorder.h:27
cx::ImageDataContainer::~ImageDataContainer
virtual ~ImageDataContainer()
Definition: cxImageDataContainer.h:68
cx::SplitFramesContainer::~SplitFramesContainer
virtual ~SplitFramesContainer()
Definition: cxImageDataContainer.h:118
cx::FramesDataContainer
Definition: cxImageDataContainer.h:132
cx::FramesDataContainer::~FramesDataContainer
virtual ~FramesDataContainer()
Definition: cxImageDataContainer.h:136