2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #ifndef __creaImageWxAnySimpleDlg_h_INCLUDED__
30 #define __creaImageWxAnySimpleDlg_h_INCLUDED__
32 #include "creaImageIOSimpleView.h"
34 #include <itkImageFileReader.h>
35 #include <boost/any.hpp>
37 #include "itkImageToVTKImageFilter.h"
45 /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
46 //EED class __declspec(dllexport) WxAnySimpleDlg : public wxDialog
47 class CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
51 WxAnySimpleDlg( wxWindow *parent,
52 wxString i_title =_T(""),
53 const std::string i_namedescp = "localdatabase_Descriptor.dscp",
54 const std::string i_namedb = "Local Database"
59 void setExts(std::vector<std::string>);
60 /// Callback to read file(s)
61 void OnReadFile(wxCommandEvent& event);
63 /// Callback to read directory, no recursive
64 void OnReadDirectory(wxCommandEvent &event);
66 /// Callback to select from creaImageIO database
67 void OnReadGimmick(wxCommandEvent &event);
69 /// return a vtkImageData vector of selected images, if available
70 std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
72 wxString getInfoImage();
74 void set(bool i_dicom){m_dicom= i_dicom;}
75 std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
77 // return the size of readed images
78 std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
80 // return the type of readed images
81 std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
83 // get an Image on wanted type
85 // strange compile error, commented out on Fred's advice // JPR
86 template <typename TImage>
87 typename TImage::Pointer getImage(boost::any i_AnyImage)
89 typedef itk::Image<TImage> ImageOut;
90 typename ImageOut::Pointer img = ImageOut::New();
91 img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
96 // get the images on itk type defined by user
97 template <typename TImage>
98 std::vector<typename TImage::Pointer> getTemplatedImagesSelected()
100 std::vector<typename TImage::Pointer> imgs;
101 std::vector<boost::any>::iterator it = m_AnyImages.begin();
102 for(; it != m_AnyImages.end(); it++)
104 imgs.push_back(boost::any_cast<TImage*> (*it));
109 template <class TImage>
110 void split3Din3Dvtk(TImage* i_Img)
112 typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
113 typename ConnectorType::Pointer connector = ConnectorType::New();
114 connector->SetInput(i_Img);
115 connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
117 vtkImageData *im = vtkImageData::New();
118 im->ShallowCopy(connector->GetOutput());
120 m_Vresults.push_back(im);
124 template <typename TImage>
125 void split4Din3Dvtk(TImage* i_Img);
130 // strange compile error with gcc 4.5.1-4 //JPR
131 std::vector</*const*/ size_t> m_AnyDims; //comment out const JPR
132 std::vector</*const*/ std::type_info *> m_AnyType; //comment out const JPR
133 std::vector<boost::any> m_AnyImages; //comment out const JPR
134 std::vector<std::string> m_exts;
135 std::string namedescp;
142 /// interface to read data
144 void readImg(const std::string &i_name);
145 void readDicomImg(const std::vector<std::string> &i_names);
146 std::vector <vtkImageData*> m_Vresults;
148 const size_t getNumberOfDimensions(const std::string &i_name);
149 const std::type_info & getType(const std::string &i_name);
153 }// namespace creaImageIO
154 #endif //__creaImageWxAnySimpleDlg_h_INCLUDED__