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