3
* $Id: sendhl7command.cpp 4319 2011-10-20 06:57:50Z carlos $
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
13
#include <wx/window.h>
14
#include <wx/volume.h>
15
#include <wx/msgdlg.h>
16
#include <api/globals.h>
17
#include "openremovableunit.h"
20
#include <main/controllers/controladorlog.h>
21
#include <main/controllers/pacscontroller.h>
22
#include <main/gui/open/opendialogs.h>
23
#include <main/gui/open/abrir.h>
24
#include <commands/comandoincluirhistorial.h>
25
#include <main/entorno.h>
29
OpenRemovableUnitCommand::OpenRemovableUnitCommand(OpenRemovableUnitCommandParams* pParams) : IComando(pParams)
31
m_pOpenParams = pParams;
34
void OpenRemovableUnitCommand::Execute()
37
NotificarProgreso(0.15f, _Std("Exploring drives..."));
38
wxArrayString volumes = wxFSVolume::GetVolumes(wxFS_VOL_MOUNTED|wxFS_VOL_REMOVABLE );
39
NotificarProgreso(0.75f, _Std("Exploring drives..."));
40
wxArrayString mountedVolumes;
41
for (wxArrayString::iterator it = volumes.begin(); it != volumes.end(); it++) {
44
OpenRemovableUnitCommandParams::TRemovableUnit unit;
45
unit.path = TOPATH(fs.GetName());
46
//first of all list files in path if it isn't mounted ... error
49
if (dir.Open(fs.GetName()) && dir.GetFirst(&tmp)) {
50
//second check if it includes dicomdir
51
wxString dicomDirPath = fs.GetName() + wxT("DICOMDIR");
52
unit.hasDicomDir = wxFileExists(dicomDirPath) && GIL::DICOM::PACSController::Instance()->EsDICOM(TOPATH(dicomDirPath),true,false);
54
unit.displayName = fs.GetDisplayName().ToUTF8();
55
m_pOpenParams->units.push_back(unit);
62
void OpenRemovableUnitCommand::Update()
67
if (m_pOpenParams->units.empty()) {
69
if (wxMessageBox(_("No DICOMDIR found in removable units.\nWould you like to scan other path recursively?"), _("Info"), wxOK|wxCANCEL, m_pOpenParams->m_pParent) == wxOK) {
70
GNC::GUI::Abrir::AbrirDirectorio(m_pOpenParams->m_pParent);
73
if (!OpenDicomDir()) {
78
bool OpenRemovableUnitCommand::OpenDicomDir()
80
int numberOfUnits = 0;
82
for (OpenRemovableUnitCommandParams::TListOfUnits::iterator it = m_pOpenParams->units.begin(); it != m_pOpenParams->units.end(); it++) {
83
if ((*it).hasDicomDir) {
88
if (numberOfUnits == 0) {
90
} else if (numberOfUnits == 1) {
91
//dialogo de adquisicion a traves de dicomdir...
92
LaunchOpenDicomDir(path);
94
//show dialog listing units..
100
bool OpenRemovableUnitCommand::ScanRecursively()
102
if (m_pOpenParams->units.size() == 1) {
103
wxString name = wxString::FromUTF8(m_pOpenParams->units.front().displayName.c_str());
104
wxString message = wxString::Format(_("No DICOMDIR found in removable units, would you like to scan recursively %s drive"), name.c_str());
105
if (wxMessageBox(message, _("Info"), wxOK|wxCANCEL, m_pOpenParams->m_pParent) == wxOK)
107
LaunchOpenRecursively(m_pOpenParams->units.front().path);
115
void OpenRemovableUnitCommand::SelectDrive(bool hasDicomDir)
117
GNC::GUI::SelectDrive::TListOfDrives listOfDrives;
118
for (OpenRemovableUnitCommandParams::TListOfUnits::iterator it = m_pOpenParams->units.begin(); it != m_pOpenParams->units.end(); ++it) {
119
if ((*it).hasDicomDir == hasDicomDir) {
120
listOfDrives.push_back(GNC::GUI::SelectDrive::TDrive((*it).path, (*it).displayName));
123
GNC::GUI::SelectDrive dialog(m_pOpenParams->m_pParent, listOfDrives);
125
dialog.SetMessage(_("Select drive you want to open"));
127
dialog.SetMessage(_("Ginkgo CADx has detected more than one removable units,\nbut none of them includes a DICOMDIR at root.\nSelect drive where you want to acquire recursively"));
129
if (dialog.ShowModal() == wxID_OK) {
130
std::string path = dialog.GetSelectedDrive();
132
LaunchOpenDicomDir(path);
134
LaunchOpenRecursively(path);
139
void OpenRemovableUnitCommand::LaunchOpenRecursively(const std::string& path)
141
GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams* pParams = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorialParams(path,true);
142
GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial* pCmd = new GADAPI::ComandoIncluirHistorial::ComandoIncluirHistorial(pParams);
143
GNC::Entorno::Instance()->GetControladorComandos()->ProcessAsync(_Std("Storing in the history..."),pCmd, NULL);
146
void OpenRemovableUnitCommand::LaunchOpenDicomDir(const std::string& path)
148
std::ostringstream ostr;
149
ostr << path << "DICOMDIR";
150
GNC::GUI::DialogoDicomDir dicomDirDialog(m_pOpenParams->m_pParent, ostr.str());
151
dicomDirDialog.ShowModal();