]> Creatis software - creaImageIO.git/blob - src/creaImageIOWxSimpleDlg.cpp
4a343719f32c0a6d827918cc71a2a6cb0f0792de
[creaImageIO.git] / src / creaImageIOWxSimpleDlg.cpp
1 #include "creaImageIOWxSimpleDlg.h"
2 #include "creaImageIOWxGimmickReaderDialog.h"
3
4
5 namespace creaImageIO
6 {
7
8         ///Ctor
9          WxSimpleDlg::WxSimpleDlg(wxWindow *parent, wxString i_title)
10     : wxDialog(parent, -1,_T("DISPLAY IMAGES"), wxDefaultPosition, wxSize(230,150))
11    {
12            if(!i_title.empty())
13            {
14                         this->SetTitle(i_title);  
15            }
16            // Button to select file(s)
17            wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
18            Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadFile ); 
19
20            // Button to select directory
21            wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
22            Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadDirectory ); 
23
24            // button to select creaImageIO
25            wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
26            Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadGimmick ); 
27
28            //TO DO  Button to select Bruker directory
29         
30         Layout(); 
31         
32         }
33 //////////////////////////////////////////////////////////////////////
34 //                                                                                                                                      //
35 //////////////////////////////////////////////////////////////////////
36           void WxSimpleDlg::OnReadFile(wxCommandEvent& event)
37           {
38                   wxFileDialog* FD = new wxFileDialog( 0,  _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
39     
40                         if (FD->ShowModal()==wxID_OK)
41                         {
42                                 wxArrayString wxArray;
43                                 FD->GetPaths(wxArray);
44                                 if(wxArray.size() >0)
45                                 {
46                                         std::vector<std::string> files;
47                                         for( int i = 0; i < wxArray.GetCount(); i++)
48                                         {
49                                                 files.push_back( crea::wx2std(wxArray[i]));
50                                         }
51                                         if(!m_view.readFile(files,m_results))
52                                         {
53                                                 //TO DO WARNING MESSAGE;
54                                         }
55                                 }
56                                 else
57                                 {
58                                         // TO DO WARNING MESSAGES
59                                 }
60                         }
61                   Close();
62           }
63
64  //////////////////////////////////////////////////////////////////////
65 //                                                                                                                                      //
66 //////////////////////////////////////////////////////////////////////
67
68           void WxSimpleDlg::OnReadDirectory(wxCommandEvent &event)
69           {
70              long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
71                  wxDirDialog* FD = new wxDirDialog( 0, _T("Select the directory to display"), "", style);
72                  
73                  if (FD->ShowModal()==wxID_OK)
74                  {  
75                         if(! m_view.readDirectory(crea::wx2std(FD->GetPath()),m_results))
76                         {
77                                 //TO DO WARNING MESSAGE;
78                         }
79                  }
80                  Close();
81           }
82
83           //////////////////////////////////////////////////////////////////////
84 //                                                                                                                                      //
85 //////////////////////////////////////////////////////////////////////
86
87           void WxSimpleDlg::OnReadGimmick(wxCommandEvent &event)
88           {
89                   // Run Gimmick
90                    WxGimmickReaderDialog dlg(0,-1, "localdatabase_Descriptor.dscp",
91                                    "Local Database", _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
92                    wxDefaultPosition,
93                    wxSize(810,750),
94                    GIMMICK_2D_IMAGE_SELECTION,
95                    GIMMICK_3D_IMAGE_SELECTION,
96                    _3D,
97                                    1);
98                  dlg.ShowModal();
99                  if (dlg.GetReturnCode() == wxID_OK)
100              {
101                         dlg.GetSelectedImages(m_results,3);
102                         dlg.OnExit();
103                  }
104                  Close();
105            }
106
107
108  //////////////////////////////////////////////////////////////////////
109 // Return the results vector                                                                            //
110 //////////////////////////////////////////////////////////////////////
111           std::vector<vtkImageData*> WxSimpleDlg::getImagesSelected()
112           {
113                   return m_results;
114           }
115 }
116