creaImageIOWxAnySimpleDlg.h

Go to the documentation of this file.
00001 
00002 
00003 #ifndef __creaImageIOWxAnySimpleDlg_h_INCLUDED__
00004 #define __creaImageIOWxAnySimpleDlg_h_INCLUDED__
00005 
00006 
00007 
00008 #include "creaImageIOSimpleView.h"
00009 #include <creaWx.h>
00010 #include <itkImageFileReader.h>
00011 #include <boost/any.hpp>
00012 #include <typeinfo>
00013 namespace creaImageIO
00014 {
00019 
00020 //EED    class  __declspec(dllexport) WxAnySimpleDlg : public wxDialog
00021     class  CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
00022     {
00023     public:
00025            WxAnySimpleDlg( wxWindow *parent,  
00026                wxString i_title =_T(""),
00027                const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
00028                const std::string i_namedb    = "Local Database"
00029            );
00030 
00031            ~WxAnySimpleDlg(){};
00032 
00033            void setExts(std::vector<std::string>);
00035            void OnReadFile(wxCommandEvent& event);
00036 
00038            void OnReadDirectory(wxCommandEvent &event);
00039           
00041            void OnReadGimmick(wxCommandEvent &event);
00042 
00044            std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
00045 
00046            wxString getInfoImage();
00047 
00048            void set(bool i_dicom){m_dicom= i_dicom;}
00049            std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
00050         
00051            // return the size of readed images
00052            std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
00053 
00054            // return the type of readed images
00055            std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
00056 
00057            // get an Image on wanted type
00058            /*
00059            // strange compile error, commented out on Fred's advice // JPR
00060            template <typename TImage> 
00061            typename TImage::Pointer getImage(boost::any i_AnyImage)
00062            {
00063               typedef itk::Image<TImage> ImageOut;
00064               typename ImageOut::Pointer img = ImageOut::New();
00065               img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
00066               return img;
00067            }
00068            */
00069 
00070          // get the images on itk type defined by user
00071           template <typename TImage> 
00072           std::vector<typename TImage::Pointer>  getTemplatedImagesSelected()
00073           {
00074              std::vector<typename TImage::Pointer> imgs;
00075              std::vector<boost::any>::iterator it = m_AnyImages.begin();
00076              for(; it != m_AnyImages.end(); it++)
00077              {
00078                  imgs.push_back(boost::any_cast<TImage*> (*it));
00079              }
00080              return imgs;
00081           }
00082           bool AllSameType();
00083     private:
00084 
00085         // strange compile error with gcc 4.5.1-4 //JPR        
00086         std::vector</*const*/ size_t>           m_AnyDims;   //comment out const JPR
00087         std::vector</*const*/ std::type_info *> m_AnyType;   //comment out const JPR
00088         std::vector<boost::any>                 m_AnyImages; //comment out const JPR
00089         std::vector<std::string> m_exts;
00090         std::string namedescp; 
00091         std::string namedb;
00092         wxString infoimage;
00093         std::string m_dir;
00094         template <class TImage> 
00095         void split3Din3Dvtk(TImage* i_Img);
00096 
00097         template <typename TImage> 
00098         void split4Din3Dvtk(TImage* i_Img);
00099 
00100         bool m_dicom;
00102         SimpleView m_view;
00103         void readImg(const std::string &i_name);
00104         void readDicomImg(const std::vector<std::string> &i_names);
00105         std::vector <vtkImageData*> m_Vresults;
00106          
00107         const size_t getNumberOfDimensions(const std::string &i_name);
00108         const std::type_info & getType(const std::string &i_name);
00109     };
00110 
00111 }
00112 
00113 
00114 #endif //__creaImageIOWxAnySimpleDlg_h_INCLUDED__