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(230,150))
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,7) );
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,40) );
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,70) );
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 wxFileDialog* fileDlg = new wxFileDialog( 0, _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
74 resultShowModal = fileDlg->ShowModal();
75 if ( resultShowModal==wxID_OK )
77 wxArrayString wxArray;
78 fileDlg->GetPaths(wxArray);
82 infoimage=_T("FILE(s):")+wxArray[0];
83 std::vector<std::string> files;
84 for( int i = 0; i < wxArray.GetCount(); i++)
86 files.push_back( crea::wx2std(wxArray[i]));
88 if( !m_view.readFile(files , m_attrDicomTags , m_resultsDicomAtr , m_results) )
90 //TO DO WARNING MESSAGE;
93 // TO DO WARNING MESSAGES
96 SetReturnCode( resultShowModal );
98 EndModal( resultShowModal );
101 //////////////////////////////////////////////////////////////////////
103 //////////////////////////////////////////////////////////////////////
105 void WxSimpleDlg::OnReadDirectory(wxCommandEvent &event)
108 long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
109 wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
111 resultShowModal = dirDlg->ShowModal();
112 if ( resultShowModal==wxID_OK )
115 infoimage=_T("DIRECTORY:")+dirDlg->GetPath();
116 if(! m_view.readDirectory(crea::wx2std(dirDlg->GetPath()) , m_attrDicomTags , m_resultsDicomAtr , m_results))
118 //TO DO WARNING MESSAGE;
121 SetReturnCode( resultShowModal );
123 EndModal( resultShowModal );
126 //////////////////////////////////////////////////////////////////////
128 //////////////////////////////////////////////////////////////////////
130 void WxSimpleDlg::OnReadGimmick(wxCommandEvent &event)
133 WxGimmickReaderDialog dlg(0,-1,
136 _T("Select image(s) - Gimmick! (c) CREATIS-LRMN 2008"),
139 GIMMICK_2D_IMAGE_SELECTION,
140 GIMMICK_3D_IMAGE_SELECTION,
144 if (dlg.GetReturnCode() == wxID_OK)
148 std::vector<creaImageIO::OutStrGimmick> outStrGimmick;
149 dlg.getSelected(outStrGimmick, m_attrDicomTags,true,"");
152 int size=(int)outStrGimmick.size();
156 for (ii=0;ii<size;ii++)
158 m_results.push_back(outStrGimmick[ii].img);
159 m_resultsDicomAtr.push_back( outStrGimmick[ii].infos );
162 // for (ii=0;ii<size;ii++)
164 // m_resultsInfo.push_back(outStrGimmick[ii]);
170 SetReturnCode( dlg.GetReturnCode() );
171 EndModal( dlg.GetReturnCode() );
174 wxString WxSimpleDlg::getInfoImage()
179 //////////////////////////////////////////////////////////////////////
180 // Return the results vector //
181 //////////////////////////////////////////////////////////////////////
182 std::vector<vtkImageData*> WxSimpleDlg::getImagesSelected()
187 std::vector< std::map<std::string, std::string> > WxSimpleDlg::getDicomInfoImagesSelected()
189 return m_resultsDicomAtr;
192 void WxSimpleDlg::SetAttrDicomTags( std::vector<std::string> attr )
194 m_attrDicomTags=attr;