]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
Clean Up Code and Added min dimension check
[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(9);
29    creaImageIO::SetGimmickDebugMessageLevel(9);
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(1200,800),
42                                         min_dim,
43                                         max_dim,
44                                         threads);
45    w.ShowModal();
46    
47    if (w.GetReturnCode() == wxID_OK)
48      {
49        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
50        std::cout << "$$$$ selected files : "<<std::endl;
51        std::vector<std::string> s;
52        w.GetSelectedFiles(s);
53        std::vector<std::string>::iterator i;
54        for (i=s.begin();i!=s.end();++i) 
55          {
56            std::cout << *i << std::endl;
57          }
58        std::cout << "$$$$ "<<std::endl;
59
60        std::vector<vtkImageData*> images;
61        w.GetSelectedImages(images,3);
62        crea::VtkBasicSlicer(images.front());
63        images.front()->Delete();
64
65      }
66    else if (w.GetReturnCode() == wxID_CANCEL)
67      {
68        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
69      }
70    else 
71      {
72         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
73                   <<std::endl;
74       
75      }
76
77    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
78    //   delete w;
79    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
80    return false;
81 }
82
83