~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/main/gui/open/abrir.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
Import upstream version 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  
 
3
 *  $Id: abrir.cpp 3643 2011-04-01 13:41:45Z tovar $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 *
 
13
 */
 
14
#include <wx/filename.h>
 
15
#include <wx/imaglist.h>
 
16
#include <wx/file.h>
 
17
#include <wx/dnd.h>
 
18
#include <wx/dir.h>
 
19
#include <wx/busyinfo.h>
 
20
#include <wx/filedlg.h>
 
21
#include <wx/menu.h>
 
22
#include <wx/dirdlg.h>
 
23
#include <wx/confbase.h>
 
24
#include <wx/msgdlg.h>
 
25
#include <wx/treelistctrl/treelistctrl.h>
 
26
#include "dialogodicomdirbase.h"
 
27
 
 
28
#include "abrir.h"
 
29
 
 
30
#include <api/internacionalizacion.h>
 
31
 
 
32
#include <vector>
 
33
#include <sstream>
 
34
 
 
35
#include <main/entorno.h>
 
36
#include <main/controllers/controladorextensiones.h>
 
37
#include <main/controllers/controladorcomandos.h>
 
38
#include <main/controllers/controladorimportacionpacs.h>
 
39
#include <main/gui/dicombrowsercomponent.h>
 
40
#include <commands/comandoincluirhistorial.h>
 
41
#include <api/imodelodicom.h>
 
42
#include <resources/ginkgoresourcemanager.h>
 
43
#include <api/icontextoestudio.h>
 
44
 
 
45
#define ICONO_ESTUDIO 0
 
46
#define ICONO_SERIE 1
 
47
#define ICONO_HOMBRE 2
 
48
#define ICONO_MUJER 3
 
49
#define ICONO_OTRO 4
 
50
#define SIZE_ICONOS 16
 
51
 
 
52
#define COLUMNA_DCMDIR_FECHA 2
 
53
#define COLUMNA_DCMDIR_MODALIDAD 1
 
54
#define COLUMNA_DCMDIR_MEDICO 3
 
55
#define COLUMNA_DCMDIR_ACCNUMBER 4
 
56
#define COLUMNA_DCMDIR_UID 5
 
57
 
 
58
namespace GNC {
 
59
        namespace GUI {
 
60
                ////////////////////////////////////////////////////
 
61
                ////////////DIALOGO DICOMDIR////////////////////////
 
62
                ////////////////////////////////////////////////////
 
63
 
 
64
                class DialogoDicomDir: public DialogoDicomDirBase
 
65
                {
 
66
                public:
 
67
                        DialogoDicomDir(wxWindow* pParent, std::string pathDicomDir): DialogoDicomDirBase(pParent)
 
68
                        {
 
69
                                wxString pathWx = FROMPATH(pathDicomDir);
 
70
                                if (wxFile::Exists(pathWx)){
 
71
                                        wxFileName file(pathWx);
 
72
                                        IModeloDicom modelo;
 
73
 
 
74
                                        if(GIL::DICOM::ControladorImportacionPACS::Instance()->LeerDicomDir(pathDicomDir,&modelo) && modelo.ListaPacientes().size()!=0) {
 
75
                                                m_pDICOMDIRResultPanel->SetModel(modelo);
 
76
                                        }
 
77
                                } else {
 
78
                                        wxMessageBox(_("Select a valid DICOMDIR file"), _("Info"),
 
79
                                                                         wxOK | wxICON_INFORMATION, this);
 
80
                                }
 
81
                        }
 
82
 
 
83
                        ~DialogoDicomDir()
 
84
                        {
 
85
                        }
 
86
 
 
87
                        void OnEndClick(wxCommandEvent &)
 
88
                        {
 
89
                                //adquirimos desde dicomdir
 
90
                                std::list<std::string> listaPaths = m_pDICOMDIRResultPanel->GetSelectedPaths();
 
91
 
 
92
                                if(listaPaths.size() == 0) {
 
93
                                        wxMessageBox(_("Select dicom dir files you want to acquire"), _("Info"),
 
94
                                                                         wxOK | wxICON_INFORMATION, this);
 
95
                                        return;
 
96
                                } else {
 
97
                                        //se lanza el comando de incluir en el historial
 
98
                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(listaPaths);
 
99
                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
 
100
                                        GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
 
101
 
 
102
                                        Close();
 
103
                                }
 
104
                        }
 
105
 
 
106
                protected:
 
107
                };
 
108
                ////////////////////////////////////////////////////
 
109
 
 
110
                Abrir::Abrir()
 
111
                {
 
112
                }
 
113
 
 
114
                Abrir::~Abrir()
 
115
                {
 
116
 
 
117
                }
 
118
 
 
119
                void Abrir::AbrirFichero(wxWindow* pParent)
 
120
                {
 
121
                        wxConfigBase * config = wxConfigBase::Get();
 
122
                        //se actualiza el fichero de configuracion
 
123
                        config->SetPath(wxT("/GinkgoCore/Adquisicion"));
 
124
 
 
125
                        wxString pathDefecto;
 
126
                        config->Read(wxT("PathDefecto"),&pathDefecto,wxT(""));
 
127
                        if(!wxDirExists(pathDefecto)){
 
128
                                pathDefecto = wxEmptyString;
 
129
                        }
 
130
                        //se muestra un di�logo de abrir fichero, si abre un fichero mira a ver si es dicomdir, si abre un directorio lo explora en profundidad
 
131
                        #if defined(_WINDOWS)
 
132
                        wxFileDialog fileDialog(NULL,_("Open..."),pathDefecto,wxEmptyString,wxT("*.*"), wxFD_OPEN | wxFD_MULTIPLE);
 
133
                        #else
 
134
                        wxFileDialog fileDialog(pParent,_("Open..."),pathDefecto,wxEmptyString,wxT("*"), wxFD_OPEN | wxFD_MULTIPLE);
 
135
                        #endif
 
136
                        fileDialog.SetDirectory(pathDefecto);
 
137
                        int response = fileDialog.ShowModal();
 
138
                        if (response == wxID_OK) {
 
139
                                wxArrayString ficherosWx;
 
140
                                fileDialog.GetFilenames(ficherosWx);
 
141
                                std::list<std::string> listaPaths;
 
142
                                for(wxArrayString::iterator it = ficherosWx.begin(); it != ficherosWx.end(); ++it)
 
143
                                {
 
144
                                        wxString wxPath = fileDialog.GetDirectory() + wxFileName::GetPathSeparator() + (*it);
 
145
                                        listaPaths.push_back(std::string(TOPATH(wxPath)));
 
146
                                }
 
147
 
 
148
                                //si alguno de los ficheros es un dicomdir se pasa a tratarlos de una forma especial, si son ficheros normales, se lanza el comando
 
149
                                bool esDicomDir = false;
 
150
                                if (listaPaths.size() == 1 && GIL::DICOM::ControladorImportacionPACS::Instance()->EsDICOM(listaPaths.front(),true,false)) {
 
151
                                        esDicomDir = true;
 
152
                                }
 
153
 
 
154
                                if (!esDicomDir) {
 
155
                                        //se lanza el comando de incluir en el historial
 
156
                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(listaPaths);
 
157
                                        //pParams->m_informar = false;
 
158
                                        //pParams->m_abrirDespuesDeCargar = true;
 
159
                                        GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
 
160
                                        GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
 
161
                                } else {
 
162
                                        //dialogo de adquisicion a traves de dicomdir...
 
163
                                        DialogoDicomDir dicomDirDialog(pParent,listaPaths.front());
 
164
                                        dicomDirDialog.ShowModal();
 
165
                                }
 
166
 
 
167
                                //se actualiza el fichero de configuracion
 
168
                                config->SetPath(wxT("/GinkgoCore/Adquisicion"));
 
169
                                config->Write(wxT("PathDefecto"),fileDialog.GetDirectory());
 
170
                                config->Flush();
 
171
                        }
 
172
                }
 
173
 
 
174
                //abrir directorio
 
175
                void Abrir::AbrirDirectorio(wxWindow* pParent)
 
176
                {
 
177
                        wxConfigBase * config = wxConfigBase::Get();
 
178
                        //se actualiza el fichero de configuracion
 
179
                        config->SetPath(wxT("/GinkgoCore/Adquisicion"));
 
180
 
 
181
                        wxString pathDefecto;
 
182
                        config->Read(wxT("PathDefecto"),&pathDefecto,wxT(""));
 
183
                        if(!wxDirExists(pathDefecto)){
 
184
                                pathDefecto = wxEmptyString;
 
185
                        }
 
186
                        wxDirDialog dd( pParent, _("Choose a directory"), pathDefecto, 0, wxDefaultPosition );
 
187
                        int response = dd.ShowModal();
 
188
                        if (response == wxID_OK) {
 
189
                                std::string stdPath(TOPATH(dd.GetPath()));
 
190
                                //se lanza el comando de incluir en el historial
 
191
                                GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(stdPath,true);
 
192
                                GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
 
193
                                GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
 
194
 
 
195
                                //se actualiza el fichero de configuracion
 
196
                                config->SetPath(wxT("/GinkgoCore/Adquisicion"));
 
197
                                config->Write(wxT("PathDefecto"),dd.GetPath());
 
198
                                config->Flush();
 
199
                        }
 
200
                }
 
201
        }
 
202
 
 
203
}