]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
8be4ec45659f690fedc2e3d2b2420e72b17e7e18
[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(1);
29    creaImageIO::SetGimmickDebugMessageLevel(1);
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(600,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            
66        crea::VtkBasicSlicer(images.front());
67        images.front()->Delete();
68            w.OnExit();
69
70      }
71    else if (w.GetReturnCode() == wxID_CANCEL)
72      {
73            w.OnExit();
74        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
75      }
76    else 
77      {
78                  w.OnExit();
79         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
80                   <<std::endl;
81       
82      }
83
84    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
85    //   delete w;
86    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
87    return false;
88 }
89
90