2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
28 #include "creaImageIOWxSimpleDlg.h"
36 WxSimpleDlg::WxSimpleDlg(wxWindow *parent,
38 const std::string i_namedescp ,
39 const std::string i_namedb)
40 : wxDialog(parent, -1,_T("SELECT IMAGE(S)"), wxDefaultPosition, wxSize(500,300))
42 namedescp = i_namedescp;
47 this->SetTitle(i_title);
49 // Button to select file(s)
50 wxButton *fileBut = new wxButton(this, -1,_T("Select a single file"), wxPoint(10,10) );
51 Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadFile );
53 // Button to select directory
54 wxButton *directoryBut = new wxButton(this, -1,_T("Select all the files in a directory"), wxPoint(10,50) );
55 Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadDirectory );
57 // button to select creaImageIO
58 wxButton *gimmickBut = new wxButton(this, -1,_T("Select thru Dicom browser"), wxPoint(10,90) );
59 Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxSimpleDlg::OnReadGimmick );
61 /// \TODO Button to select Bruker directory
66 //////////////////////////////////////////////////////////////////////
68 //////////////////////////////////////////////////////////////////////
69 void WxSimpleDlg::OnReadFile(wxCommandEvent& event)
72 //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0
73 #if wxMAJOR_VERSION <= 2
74 wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
76 wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxFD_OPEN |wxFD_MULTIPLE, wxDefaultPosition);
79 resultShowModal = fileDlg->ShowModal();
80 if ( resultShowModal==wxID_OK )
82 wxArrayString wxArray;
83 fileDlg->GetPaths(wxArray);
87 infoimage = wxArray[0];
88 infoimageSource = _T("FILE(s)");
89 std::vector<std::string> files;
90 for( int i = 0; i < wxArray.GetCount(); i++)
92 files.push_back( crea::wx2std(wxArray[i]));
94 if( !m_view.readFile(files , m_attrDicomTags , m_resultsDicomAtr , m_results) )
96 //TO DO WARNING MESSAGE;
99 // TO DO WARNING MESSAGES
102 SetReturnCode( resultShowModal );
104 EndModal( resultShowModal );
107 //////////////////////////////////////////////////////////////////////
109 //////////////////////////////////////////////////////////////////////
111 void WxSimpleDlg::OnReadDirectory(wxCommandEvent &event)
114 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
115 wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
117 resultShowModal = dirDlg->ShowModal();
118 if ( resultShowModal==wxID_OK )
121 infoimage = dirDlg->GetPath();
122 infoimageSource = _T("DIRECTORY");
123 if(! m_view.readDirectory(crea::wx2std(dirDlg->GetPath()) , m_attrDicomTags , m_resultsDicomAtr , m_results))
125 //TO DO WARNING MESSAGE;
128 SetReturnCode( resultShowModal );
130 EndModal( resultShowModal );
133 //////////////////////////////////////////////////////////////////////
135 //////////////////////////////////////////////////////////////////////
137 void WxSimpleDlg::OnReadGimmick(wxCommandEvent &event)
140 WxGimmickReaderDialog dlg(0,-1,
143 _T("Select image(s) - Gimmick! (c)"),
146 GIMMICK_2D_IMAGE_SELECTION,
147 GIMMICK_3D_IMAGE_SELECTION,
151 if (dlg.GetReturnCode() == wxID_OK)
154 std::vector<creaImageIO::OutStrGimmick> outStrGimmick;
155 std::vector<std::string> outFileNames;
156 dlg.getSelected(outStrGimmick, m_attrDicomTags, outFileNames,true,"");
158 int size=(int)outStrGimmick.size();
162 for (ii=0;ii<size;ii++)
164 m_results.push_back(outStrGimmick[ii].img);
165 m_resultsDicomAtr.push_back( outStrGimmick[ii].infos );
168 // for (ii=0;ii<size;ii++)
170 // m_resultsInfo.push_back(outStrGimmick[ii]);
174 infoimage = _T("EED Missing info <void> ???");
175 infoimageSource = _T("GIMMICK");
178 SetReturnCode( dlg.GetReturnCode() );
179 EndModal( dlg.GetReturnCode() );
182 //-----------------------------------------------------------------------------
183 wxString WxSimpleDlg::getInfoImage()
188 //-----------------------------------------------------------------------------
189 wxString WxSimpleDlg::getInfoImageSource()
191 return infoimageSource;
194 //////////////////////////////////////////////////////////////////////
195 // Return the results vector //
196 //////////////////////////////////////////////////////////////////////
197 std::vector<vtkImageData*> WxSimpleDlg::getImagesSelected()
202 //-----------------------------------------------------------------------------
203 std::vector< std::map<std::string, std::string> > WxSimpleDlg::getDicomInfoImagesSelected()
205 return m_resultsDicomAtr;
208 //-----------------------------------------------------------------------------
209 void WxSimpleDlg::SetAttrDicomTags( std::vector<std::string> attr )
211 m_attrDicomTags=attr;
215 //-----------------------------------------------------------------------------
216 vtkImageData* WxSimpleDlg::getVolumeSelected()
218 return m_view.getVolumeSelected( getImagesSelected() );
221 } // namespace creaImageIO