]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
811f6a3b74dfd22a6b52d7e7c26b8bea1bd840bc
[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
33 //EED
34 //   int output_dim = NATIVE;
35    int output_dim = _3D;
36
37    int threads = 1;
38
39    creaImageIO::WxGimmickReaderDialog w(
40                     0,
41                    -1, 
42                                    "localdatabase_Descriptor.dscp",
43                                    "Local Database",
44                    _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
45                    wxDefaultPosition,
46                    wxSize(810,750),
47                    min_dim,
48                    max_dim,
49                    output_dim,
50                    threads);
51    w.ShowModal();
52
53    if (w.GetReturnCode() == wxID_OK)
54      {
55        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
56        std::cout << "$$$$ selected files : "<<std::endl;
57        //Puts filenames
58        std::vector<std::string> s;
59        w.GetSelectedFiles(s);
60        std::vector<std::string>::iterator i;
61        for (i=s.begin();i!=s.end();++i) 
62          {
63            std::cout << *i << std::endl;
64          }
65        std::cout << "$$$$ "<<std::endl;
66
67        //Puts images
68        std::vector<vtkImageData*> images;
69        w.GetSelectedImages(images,output_dim);
70        std::cout<<images.size()<<std::endl;
71
72        crea::VtkBasicSlicer(images.front());
73        images.front()->Delete();
74        w.OnExit();
75
76      }
77    else if (w.GetReturnCode() == wxID_CANCEL)
78      {
79        w.OnExit();
80        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
81      }
82    else 
83      {
84        w.OnExit();
85        std::cout << "$$$$ main : dialog ended without return code ! $$$$"
86                  <<std::endl;    
87      }
88
89    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
90    //   delete w;
91    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
92    return false;
93 }
94
95