]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickReaderDialog/main.cxx
Implemented calls from/to the interface to several methods.
[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 threads = 1;
35
36    creaImageIO::WxGimmickReaderDialog w(0,
37                                         -1,
38                                         _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
39                                         wxDefaultPosition,
40                                         wxSize(1200,800),
41                                         min_dim,
42                                         max_dim,
43                                         threads);
44    w.ShowModal();
45    
46    if (w.GetReturnCode() == wxID_OK)
47      {
48        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
49        std::cout << "$$$$ selected files : "<<std::endl;
50        std::vector<std::string> s;
51        w.GetSelectedFiles(s);
52        std::vector<std::string>::iterator i;
53        for (i=s.begin();i!=s.end();++i) 
54          {
55            std::cout << *i << std::endl;
56          }
57        std::cout << "$$$$ "<<std::endl;
58
59        std::vector<vtkImageData*> images;
60        w.GetSelectedImages(images,3);
61        crea::VtkBasicSlicer(images.front());
62        images.front()->Delete();
63
64      }
65    else if (w.GetReturnCode() == wxID_CANCEL)
66      {
67        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
68      }
69    else 
70      {
71         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
72                   <<std::endl;
73       
74      }
75
76    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
77    //   delete w;
78    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
79    return false;
80 }
81
82