]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
Added functionality of timestamp and maintenance databases when using multiple sources
[creaImageIO.git] / appli / TestWxGimmickReaderDialog / main.cxx
1 #include <creaImageIOSystem.h>
2 #include <creaWx.h>
3 #include <creaImageIOWxGimmickReaderDialog.h>
4
5 #include <creaVtkBasicSlicer.h>
6
7 class myApp : public wxApp
8 {
9 public:
10   bool OnInit( );
11   int  OnExit() { return true; }
12 };
13
14 IMPLEMENT_APP(myApp);
15
16 CREA_WXMAIN_WITH_CONSOLE
17
18 bool myApp::OnInit( )
19 {        
20   wxApp::OnInit();
21 #ifdef __WXGTK__
22   //See http://www.wxwindows.org/faqgtk.htm#locale
23   setlocale(LC_NUMERIC, "C");
24 #endif
25    wxInitAllImageHandlers();
26
27    
28    creaImageIO::SetGimmickMessageLevel(5);
29    creaImageIO::SetGimmickDebugMessageLevel(0);
30    
31
32    int min_dim = GIMMICK_2D_IMAGE_SELECTION;
33    int max_dim = GIMMICK_3D_IMAGE_SELECTION;
34    int output_dim = NATIVE;
35    int threads = 1;
36
37    creaImageIO::WxGimmickReaderDialog w(0,
38                                         -1,
39                                         _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
40                                         wxDefaultPosition,
41                                         wxSize(635,750),
42                                         min_dim,
43                                         max_dim,
44                                         output_dim,
45                                         threads);
46    w.ShowModal();
47    
48    if (w.GetReturnCode() == wxID_OK)
49      {
50        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
51        std::cout << "$$$$ selected files : "<<std::endl;
52            //Puts filenames
53        std::vector<std::string> s;
54        w.GetSelectedFiles(s);
55        std::vector<std::string>::iterator i;
56        for (i=s.begin();i!=s.end();++i) 
57          {
58            std::cout << *i << std::endl;
59          }
60        std::cout << "$$$$ "<<std::endl;
61
62            //Puts images
63        std::vector<vtkImageData*> images;
64            w.GetSelectedImages(images,output_dim);
65            std::cout<<images.size()<<std::endl;
66
67            crea::VtkBasicSlicer(images.front());
68        images.front()->Delete();
69            w.OnExit();
70
71      }
72    else if (w.GetReturnCode() == wxID_CANCEL)
73      {
74            w.OnExit();
75        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
76      }
77    else 
78      {
79                  w.OnExit();
80         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
81                   <<std::endl;
82       
83      }
84
85    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
86    //   delete w;
87    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
88    return false;
89 }
90
91