]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
Typo
[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    creaImageIO::SetGimmickMessageLevel(5);
28    creaImageIO::SetGimmickDebugMessageLevel(0);
29
30    int min_dim = GIMMICK_2D_IMAGE_SELECTION;
31    int max_dim = GIMMICK_3D_IMAGE_SELECTION;
32    int output_dim = NATIVE;
33    int threads = 1;
34
35    creaImageIO::WxGimmickReaderDialog w(
36                     0,
37                    -1,
38                    _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
39                    wxDefaultPosition,
40                    wxSize(810,750),
41                    min_dim,
42                    max_dim,
43                    output_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        //Puts filenames
52        std::vector<std::string> s;
53        w.GetSelectedFiles(s);
54        std::vector<std::string>::iterator i;
55        for (i=s.begin();i!=s.end();++i) 
56          {
57            std::cout << *i << std::endl;
58          }
59        std::cout << "$$$$ "<<std::endl;
60
61        //Puts images
62        std::vector<vtkImageData*> images;
63        w.GetSelectedImages(images,output_dim);
64        std::cout<<images.size()<<std::endl;
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    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
84    //   delete w;
85    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
86    return false;
87 }
88
89