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