3
* $Id: abrir.cpp 3643 2011-04-01 13:41:45Z tovar $
6
* Copyright 2008-10 MetaEmotion S.L. All rights reserved.
7
* http://ginkgo-cadx.com
9
* This file is licensed under LGPL v3 license.
10
* See License.txt for details
14
#include <wx/filename.h>
15
#include <wx/imaglist.h>
19
#include <wx/busyinfo.h>
20
#include <wx/filedlg.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"
30
#include <api/internacionalizacion.h>
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>
45
#define ICONO_ESTUDIO 0
47
#define ICONO_HOMBRE 2
50
#define SIZE_ICONOS 16
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
60
////////////////////////////////////////////////////
61
////////////DIALOGO DICOMDIR////////////////////////
62
////////////////////////////////////////////////////
64
class DialogoDicomDir: public DialogoDicomDirBase
67
DialogoDicomDir(wxWindow* pParent, std::string pathDicomDir): DialogoDicomDirBase(pParent)
69
wxString pathWx = FROMPATH(pathDicomDir);
70
if (wxFile::Exists(pathWx)){
71
wxFileName file(pathWx);
74
if(GIL::DICOM::ControladorImportacionPACS::Instance()->LeerDicomDir(pathDicomDir,&modelo) && modelo.ListaPacientes().size()!=0) {
75
m_pDICOMDIRResultPanel->SetModel(modelo);
78
wxMessageBox(_("Select a valid DICOMDIR file"), _("Info"),
79
wxOK | wxICON_INFORMATION, this);
87
void OnEndClick(wxCommandEvent &)
89
//adquirimos desde dicomdir
90
std::list<std::string> listaPaths = m_pDICOMDIRResultPanel->GetSelectedPaths();
92
if(listaPaths.size() == 0) {
93
wxMessageBox(_("Select dicom dir files you want to acquire"), _("Info"),
94
wxOK | wxICON_INFORMATION, this);
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);
108
////////////////////////////////////////////////////
119
void Abrir::AbrirFichero(wxWindow* pParent)
121
wxConfigBase * config = wxConfigBase::Get();
122
//se actualiza el fichero de configuracion
123
config->SetPath(wxT("/GinkgoCore/Adquisicion"));
125
wxString pathDefecto;
126
config->Read(wxT("PathDefecto"),&pathDefecto,wxT(""));
127
if(!wxDirExists(pathDefecto)){
128
pathDefecto = wxEmptyString;
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);
134
wxFileDialog fileDialog(pParent,_("Open..."),pathDefecto,wxEmptyString,wxT("*"), wxFD_OPEN | wxFD_MULTIPLE);
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)
144
wxString wxPath = fileDialog.GetDirectory() + wxFileName::GetPathSeparator() + (*it);
145
listaPaths.push_back(std::string(TOPATH(wxPath)));
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)) {
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);
162
//dialogo de adquisicion a traves de dicomdir...
163
DialogoDicomDir dicomDirDialog(pParent,listaPaths.front());
164
dicomDirDialog.ShowModal();
167
//se actualiza el fichero de configuracion
168
config->SetPath(wxT("/GinkgoCore/Adquisicion"));
169
config->Write(wxT("PathDefecto"),fileDialog.GetDirectory());
175
void Abrir::AbrirDirectorio(wxWindow* pParent)
177
wxConfigBase * config = wxConfigBase::Get();
178
//se actualiza el fichero de configuracion
179
config->SetPath(wxT("/GinkgoCore/Adquisicion"));
181
wxString pathDefecto;
182
config->Read(wxT("PathDefecto"),&pathDefecto,wxT(""));
183
if(!wxDirExists(pathDefecto)){
184
pathDefecto = wxEmptyString;
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);
195
//se actualiza el fichero de configuracion
196
config->SetPath(wxT("/GinkgoCore/Adquisicion"));
197
config->Write(wxT("PathDefecto"),dd.GetPath());