2 #include "creaImageIOSimpleView.h"
4 #include <itkImageFileReader.h>
5 #include <boost/any.hpp>
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
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"
27 void setExts(std::vector<std::string>);
28 /// Callback to read file(s)
29 void OnReadFile(wxCommandEvent& event);
31 /// Callback to read directory, no recursive
32 void OnReadDirectory(wxCommandEvent &event);
34 /// Callback to select from creaImageIO database
35 void OnReadGimmick(wxCommandEvent &event);
37 /// return a vtkImageData vector of selected images, if available
38 std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
40 wxString getInfoImage();
42 void set(bool i_dicom){m_dicom= i_dicom;}
43 std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
45 // return the size of readed images
46 std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
48 // return the type of readed images
49 std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
51 // get an Image on wanted type
53 // strange compile error, commented out on Fred's advice // JPR
54 template <typename TImage>
55 typename TImage::Pointer getImage(boost::any i_AnyImage)
57 typedef itk::Image<TImage> ImageOut;
58 typename ImageOut::Pointer img = ImageOut::New();
59 img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
64 // get the images on itk type defined by user
65 template <typename TImage>
66 std::vector<typename TImage::Pointer> getTemplatedImagesSelected()
68 std::vector<typename TImage::Pointer> imgs;
69 std::vector<boost::any>::iterator it = m_AnyImages.begin();
70 for(; it != m_AnyImages.end(); it++)
72 imgs.push_back(boost::any_cast<TImage*> (*it));
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;
88 template <class TImage>
89 void split3Din3Dvtk(TImage* i_Img);
91 template <typename TImage>
92 void split4Din3Dvtk(TImage* i_Img);
95 /// interface to read data
97 void readImg(const std::string &i_name);
98 void readDicomImg(const std::vector<std::string> &i_names);
99 std::vector <vtkImageData*> m_Vresults;
101 const size_t getNumberOfDimensions(const std::string &i_name);
102 const std::type_info & getType(const std::string &i_name);