]> Creatis software - clitk.git/blob - vv/vvImageWriter.h
Force update of display extents to fix linked navigation bug + move propagation out...
[clitk.git] / vv / vvImageWriter.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://oncora1.lyon.fnclcc.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ======================================================================-====*/
18 #ifndef vvImageWriter_H
19 #define vvImageWriter_H
20 #include <string>
21
22 // ITK includes
23 #include "itkImage.h"
24 #include "itkCommand.h"
25 #include "vvImage.h"
26
27 class vvImageWriter {
28
29 public:
30   // constructor
31   vvImageWriter();
32   ~vvImageWriter();
33
34   void SetOutputFileName(std::string filename);
35   void SetObserver(itk::Command::Pointer o) {
36     mUseAnObserver = true;
37     mObserver = o;
38   }
39   void DisableObserver() {
40     mUseAnObserver = false;
41   }
42
43   void SetInput(vvImage::Pointer image) {
44     mImage = image;
45   }
46
47   std::string GetLastError() {
48     return mLastError;
49   }
50
51   //====================================================================
52   // Main function
53   void Update() {
54     Update(mImage->GetNumberOfDimensions(),mImage->GetScalarTypeAsITKString());
55   }
56   void Update(int dim, std::string OutputPixelType);
57
58 protected:
59   //====================================================================
60   std::string mOutputFilename;
61   itk::Command::Pointer mObserver;
62
63   std::string mLastError;
64   bool mUseAnObserver;
65
66   //====================================================================
67   template<unsigned int VImageDimension>
68   void UpdateWithDim(std::string OutputPixelType);
69
70   //====================================================================
71   template<class OutputPixelType, unsigned int VImageDimension>
72   void UpdateWithDimAndOutputPixelType();
73
74 private:
75   vvImage::Pointer mImage;
76
77 }; // end class vvImageWriter
78
79 #endif /* end #define vvImageWriter_H */