]> Creatis software - creaImageIO.git/blob - appli/TestWxSimpleView/main.cxx
Feature #1764
[creaImageIO.git] / appli / TestWxSimpleView / main.cxx
1 /*
2         # ---------------------------------------------------------------------
3         #
4         # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5         #                        pour la Santé)
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
9         #
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.
16         #
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
21         #  liability. 
22         #
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         # ------------------------------------------------------------------------
26 */
27 #include <creaImageIOSystem.h>
28 #include <creaWx.h>
29 #include <creaImageIOWxISimpleDlg.h>
30 #include <creaImageIOWxISimpleDlg.hpp>
31 #include <itkImageBase.h>
32 #include <creaVtkBasicSlicer.h>
33
34 #define ITK_DIM_TO_TEST 4
35
36 // Just to test the selection of file(s), directory or from creaImageIO database.
37 class myApp : public wxApp
38 {
39 public:
40   bool OnInit( );
41   int  OnExit() { return true; }
42 };
43
44 IMPLEMENT_APP(myApp);
45
46 CREA_WXMAIN_WITH_CONSOLE
47
48 bool myApp::OnInit( )
49 {
50   wxApp::OnInit();
51 #ifdef __WXGTK__
52   //See http://www.wxwindows.org/faqgtk.htm#locale
53   setlocale(LC_NUMERIC, "C");
54 #endif
55    wxInitAllImageHandlers();
56    std::vector <vtkImageData*> vtktest;
57    std::vector<std::string> exts;
58    vtkImageData* im = vtkImageData::New();
59   if(ITK_DIM_TO_TEST == 3)
60    {
61    
62            typedef itk::Image<short, ITK_DIM_TO_TEST >  ImageType;
63            creaImageIO::WxISimpleDlg<ImageType> x(0);
64            // files extension to take in count
65        exts.push_back(".hdr");
66        x.setExts(exts);
67        x.ShowModal();
68            // get itkImage vector
69            std::vector <ImageType::Pointer> test = x.getImagesSelected();
70            // convert 3D itk to 3D vtk
71            x.split3Din3Dvtk();
72            vtktest = x.getVtkImagesSelected();
73           if(vtktest.size() >0)
74           {
75                 crea::VtkBasicSlicer(vtktest.front());
76           }
77   }
78   else if (ITK_DIM_TO_TEST == 4)
79   {
80           typedef itk::Image<short, ITK_DIM_TO_TEST >  ImageType;
81       creaImageIO::WxISimpleDlg<ImageType> x(0);
82           x.ShowModal();
83           // get itkImage vector
84           std::vector <ImageType::Pointer> test = x.getImagesSelected();
85           // convert 4D itk to 3D vtk  with a directory to create tempory vtk files.
86       x.split4Din3Dvtk("d:/temp2");
87           // get vtkImageData* vector
88           vtktest = x.getVtkImagesSelected();
89           if(vtktest.size() >0)
90           {
91                 crea::VtkBasicSlicer(vtktest.front());
92           }
93         }
94    
95   else{}
96
97  
98   
99    return false;
100 }
101
102