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 <vtkVersionMacros.h>
33 #include "creaImageIOSimpleView.h"
35 #include <itkImageFileReader.h>
36 #include <boost/any.hpp>
38 #include "itkImageToVTKImageFilter.h"
46 /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
47 //EED class __declspec(dllexport) WxAnySimpleDlg : public wxDialog
48 class CREAIMAGEIO_EXPORT WxAnySimpleDlg : public wxDialog
52 WxAnySimpleDlg( wxWindow *parent,
53 wxString i_title =_T(""),
54 const std::string i_namedescp = "localdatabase_Descriptor.dscp",
55 const std::string i_namedb = "Local Database"
60 void setExts(std::vector<std::string>);
61 /// Callback to read file(s)
62 void OnReadFile(wxCommandEvent& event);
64 /// Callback to read directory, no recursive
65 void OnReadDirectory(wxCommandEvent &event);
67 /// Callback to select from creaImageIO database
68 void OnReadGimmick(wxCommandEvent &event);
70 /// return a vtkImageData vector of selected images, if available
71 std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
73 wxString getInfoImage();
75 void set(bool i_dicom){m_dicom= i_dicom;}
76 std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
78 // return the size of readed images
79 std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
81 // return the type of readed images
82 std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
84 // get an Image on wanted type
86 // strange compile error, commented out on Fred's advice // JPR
87 template <typename TImage>
88 typename TImage::Pointer getImage(boost::any i_AnyImage)
90 typedef itk::Image<TImage> ImageOut;
91 typename ImageOut::Pointer img = ImageOut::New();
92 img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
97 // get the images on itk type defined by user
98 template <typename TImage>
99 std::vector<typename TImage::Pointer> getTemplatedImagesSelected()
101 std::vector<typename TImage::Pointer> imgs;
102 std::vector<boost::any>::iterator it = m_AnyImages.begin();
103 for(; it != m_AnyImages.end(); it++)
105 imgs.push_back(boost::any_cast<TImage*> (*it));
110 template <class TImage>
111 void split3Din3Dvtk(TImage* i_Img)
113 typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
114 typename ConnectorType::Pointer connector = ConnectorType::New();
115 connector->SetInput(i_Img);
116 connector->GetImporter()->SetDataScalarTypeToUnsignedChar();
118 vtkImageData *im = vtkImageData::New();
119 im->ShallowCopy(connector->GetOutput());
121 //EED 2017-01-01 Migration VTK7
122 #if VTK_MAJOR_VERSION <= 5
129 m_Vresults.push_back(im);
132 template <typename TImage>
133 void split4Din3Dvtk(TImage* i_Img);
136 // strange compile error with gcc 4.5.1-4 //JPR
137 std::vector</*const*/ size_t> m_AnyDims; //comment out const JPR
138 std::vector</*const*/ std::type_info *> m_AnyType; //comment out const JPR
139 std::vector<boost::any> m_AnyImages; //comment out const JPR
140 std::vector<std::string> m_exts;
141 std::string namedescp;
147 /// interface to read data
149 void readImg(const std::string &i_name);
150 void readDicomImg(const std::vector<std::string> &i_names);
151 std::vector <vtkImageData*> m_Vresults;
153 const size_t getNumberOfDimensions(const std::string &i_name);
154 const std::type_info & getType(const std::string &i_name);
157 }// namespace creaImageIO
158 #endif //__creaImageWxAnySimpleDlg_h_INCLUDED__