]> Creatis software - creaImageIO.git/blob - appli/TestWxGimmickDialog/main.cxx
8f5f0c8b31cf5a68c073f6654e7076237f6b9586
[creaImageIO.git] / appli / TestWxGimmickDialog / main.cxx
1 #include <creaImageIOSystem.h>
2 #include <creaWx.h>
3 #include <creaImageIOWxGimmickDialog.h>
4 #include <creaVtkBasicSlicer.h>
5
6 class myApp : public wxApp
7 {
8 public:
9   bool OnInit( );
10   int  OnExit() { return true; }
11 };
12
13 IMPLEMENT_APP(myApp);
14
15 CREA_WXMAIN_WITH_CONSOLE
16
17 bool myApp::OnInit( )
18 {        
19   wxApp::OnInit();
20 #ifdef __WXGTK__
21   //See http://www.wxwindows.org/faqgtk.htm#locale
22   setlocale(LC_NUMERIC, "C");
23 #endif
24    wxInitAllImageHandlers();
25
26    int image_type = GIMMICK_3D_IMAGE_SELECTION;
27    int threads = 1;
28
29    creaImageIO::WxGimmickDialog w(0,
30                                   -1,
31                                   _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
32                                   wxDefaultPosition,
33                                   wxSize(1200,800),
34                                   image_type,
35                                   threads);
36    w.ShowModal();
37    
38    if (w.GetReturnCode() == wxID_OK)
39      {
40
41        std::cout << "$$$$ main : user clicked 'OK' $$$$"<<std::endl;
42        std::cout << "$$$$ selected files : "<<std::endl;
43        std::vector<std::string> s;
44        w.GetSelectedFiles(s);
45        std::vector<std::string>::iterator i;
46        for (i=s.begin();i!=s.end();++i) 
47          {
48            std::cout << *i << std::endl;
49          }
50        std::cout << "$$$$ "<<std::endl;
51
52        std::vector<vtkImageData*> images;
53        w.GetSelectedImages(images);
54        crea::VtkBasicSlicer(images.front());
55        images.front()->Delete();
56    
57      }
58    else if (w.GetReturnCode() == wxID_CANCEL)
59      {
60        std::cout << "$$$$ main : user clicked 'CANCEL' $$$$"<<std::endl;
61      }
62    else 
63      {
64         std::cout << "$$$$ main : dialog ended without return code ! $$$$"
65                   <<std::endl;
66       
67      }
68   
69    //   std::cout << "$$$$ main : deleting dialog"<<std::endl;
70    //   delete w;
71    std::cout << "$$$$$$$$$$$$$$$$$$$$ main ended "<<std::endl;
72    return false;
73 }
74
75