]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxAnySimpleDlg.h
34120242304f7ac5c03ae765b79e7330acf44600
[creaImageIO.git] / src / creaImageIOWxAnySimpleDlg.h
1
2 #include "creaImageIOSimpleView.h"
3 #include <creaWx.h>
4 #include <itkImageFileReader.h>
5 #include <boost/any.hpp>
6 #include <typeinfo>
7 namespace creaImageIO
8 {
9  /**
10  * \ingroup View
11  */
12
13     /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
14 //EED    class  __declspec(dllexport) WxAnySimpleDlg : public wxDialog
15     class  CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
16     {
17     public:
18          /// Ctor
19            WxAnySimpleDlg( wxWindow *parent,  
20                wxString i_title =_T(""),
21                const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
22                const std::string i_namedb    = "Local Database"
23            );
24
25            ~WxAnySimpleDlg(){};
26
27            void setExts(std::vector<std::string>);
28            /// Callback to read file(s)
29            void OnReadFile(wxCommandEvent& event);
30
31           /// Callback to read directory, no recursive
32            void OnReadDirectory(wxCommandEvent &event);
33           
34           /// Callback to select from creaImageIO database
35            void OnReadGimmick(wxCommandEvent &event);
36
37            /// return a vtkImageData vector of selected images, if available
38            std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
39
40            wxString getInfoImage();
41
42            void set(bool i_dicom){m_dicom= i_dicom;}
43            std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
44         
45            // return the size of readed images
46            std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
47
48            // return the type of readed images
49            std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
50
51            // get an Image on wanted type
52            /*
53            // strange compile error, commented out on Fred's advice // JPR
54            template <typename TImage> 
55            typename TImage::Pointer getImage(boost::any i_AnyImage)
56            {
57               typedef itk::Image<TImage> ImageOut;
58               typename ImageOut::Pointer img = ImageOut::New();
59               img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
60               return img;
61            }
62            */
63
64          // get the images on itk type defined by user
65           template <typename TImage> 
66           std::vector<typename TImage::Pointer>  getTemplatedImagesSelected()
67           {
68              std::vector<typename TImage::Pointer> imgs;
69              std::vector<boost::any>::iterator it = m_AnyImages.begin();
70              for(; it != m_AnyImages.end(); it++)
71              {
72                  imgs.push_back(boost::any_cast<TImage*> (*it));
73              }
74              return imgs;
75           }
76           bool AllSameType();
77     private:
78
79         // strange compile error with gcc 4.5.1-4 //JPR        
80         std::vector</*const*/ size_t>           m_AnyDims;   //comment out const JPR
81         std::vector</*const*/ std::type_info *> m_AnyType;   //comment out const JPR
82         std::vector<boost::any>                 m_AnyImages; //comment out const JPR
83         std::vector<std::string> m_exts;
84         std::string namedescp; 
85         std::string namedb;
86         wxString infoimage;
87         std::string m_dir;
88         template <class TImage> 
89         void split3Din3Dvtk(TImage* i_Img);
90
91         template <typename TImage> 
92         void split4Din3Dvtk(TImage* i_Img);
93
94         bool m_dicom;
95         /// interface to read data
96         SimpleView m_view;
97         void readImg(const std::string &i_name);
98         void readDicomImg(const std::vector<std::string> &i_names);
99         std::vector <vtkImageData*> m_Vresults;
100          
101         const size_t getNumberOfDimensions(const std::string &i_name);
102         const std::type_info & getType(const std::string &i_name);
103     };
104
105 }