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