X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvQPacsConnection.cxx;h=4ae0d33b9981bdddc7a31e98e2f2aa0b55c16b7f;hb=81fa2ccb7f96adb3df3f01182f9ec67cd181f859;hp=ff768af6414ac32c4460f10d7aa97921ca375989;hpb=0f73e36c9f3ba0d458dbcf68af9236399a7d3657;p=clitk.git diff --git a/vv/vvQPacsConnection.cxx b/vv/vvQPacsConnection.cxx index ff768af..4ae0d33 100644 --- a/vv/vvQPacsConnection.cxx +++ b/vv/vvQPacsConnection.cxx @@ -7,14 +7,16 @@ #include #include "vvPacsSettingsDialog.h" #include "vvUtils.h" - +#include +#include +#include vvQPacsConnection::vvQPacsConnection(QWidget *i_parent) :QDialog(i_parent) { ui.setupUi(this); - setWindowTitle(QString::fromUtf8("PACS CONNECTIONHHHH")); + setWindowTitle(QString::fromUtf8("PACS CONNECTION")); createTreeView(); ui.tabFilter->setTabText(0,QString(tr("Modality"))); ui.tabFilter->setTabText(1,QString(tr("Date"))); @@ -29,10 +31,18 @@ vvQPacsConnection::vvQPacsConnection(QWidget *i_parent) connect(ui.networkCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(chooseServer(int))); connect(ui.removeNetworkButton,SIGNAL(clicked()),this,SLOT(removeServer())); connect(ui.NetworkButton,SIGNAL(clicked()),this,SLOT(modifyServer())); + connect(ui.exitButton,SIGNAL(clicked()),this,SLOT(close())); update(); } +// Exit window +bool vvQPacsConnection::close() +{ + QApplication::restoreOverrideCursor(); + return QWidget::close(); +} + // remote a Dicom Server in VV settings void vvQPacsConnection::removeServer() { @@ -45,8 +55,13 @@ void vvQPacsConnection::removeServer() // modify a Dicom Server in VV settings void vvQPacsConnection::modifyServer() { + int indexCombo = ui.networkCombo->currentIndex(); + removeDicomServer(m_nickname); AddDicomServer(ui.NameEdit->text().toStdString(),ui.AETitleEdit->text().toStdString(),ui.AdressEdit->text().toStdString(),ui.PortEdit->text().toStdString()); - removeServer(); + ui.networkCombo->clear(); + ui.networkCombo->addItem(QString()); + ui.networkCombo->addItems(getDicomServers()); + ui.networkCombo->setCurrentIndex(indexCombo); } // refresh the list of Dicom Servers available from VV settings @@ -169,7 +184,7 @@ void vvQPacsConnection::createTreeView() Seriesmodel->setHorizontalHeaderLabels(Serieslist); ui.seriesTreeView->setModel(Seriesmodel); connect(ui.seriesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImages(QModelIndex))); - + connect(ui.imagesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImage(QModelIndex))); // Images Tree View Imagesmodel = new QStandardItemModel(0,1,this); QStringList Imageslist; @@ -182,10 +197,10 @@ void vvQPacsConnection::createTreeView() // clean the different model Trees void vvQPacsConnection::cleanTree() { - Patientmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex()); - Studymodel->removeRows(0,Patientmodel->rowCount(),QModelIndex()); - Seriesmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex()); - Imagesmodel->removeRows(0,Patientmodel->rowCount(),QModelIndex()); + Patientmodel->removeRows(0,Patientmodel->rowCount()); + Studymodel->removeRows(0,Patientmodel->rowCount()); + Seriesmodel->removeRows(0,Patientmodel->rowCount()); + Imagesmodel->removeRows(0,Patientmodel->rowCount()); } @@ -197,19 +212,20 @@ void vvQPacsConnection::selectStudies(const QModelIndex &index) Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex()); Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); manageSeriesFilter(true); - m_query = mQFactory.getQueryPatient("",m_patient); convertDataSet( findQuery( mQFactory.getQueryforStudy(m_patient, false)) , Studymodel, mQFactory.getQueryKeysforStudy("",true)); } +void vvQPacsConnection::clearMove() +{ +} void vvQPacsConnection::selectSeries(const QModelIndex &index) { m_study= Studymodel->data(index.sibling(index.row(),3)).toString().toStdString(); Seriesmodel->removeRows(0, Seriesmodel->rowCount()); Imagesmodel->removeRows(0, Imagesmodel->rowCount()); - m_query = mQFactory.getQueryforSeries(m_patient,m_study, false); convertDataSet( findQuery( mQFactory.getQueryforSeries(m_patient,m_study, false)), Seriesmodel, mQFactory.getSeriesKeys("","",true)); } @@ -218,11 +234,17 @@ void vvQPacsConnection::selectImages(const QModelIndex &index) { m_series = Seriesmodel->data(index.sibling(index.row(),2)).toString().toStdString(); Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); - m_query = mQFactory.getQueryforImages(m_patient,m_study, m_series, false); convertDataSet( findQuery( mQFactory.getQueryforImages(m_patient,m_study, m_series, false) ), Imagesmodel, mQFactory.getQueryKeysforImages("","","",true)); } +void vvQPacsConnection::selectImage(const QModelIndex &index) +{ + std::string _image = Imagesmodel->data(index.sibling(index.row(),1)).toString().toStdString(); + mQFactory.setQueryforImage(m_patient,m_study, m_series, _image); + +} + std::vector vvQPacsConnection::findQuery(vvQuery i_query) { @@ -297,7 +319,7 @@ std::vector< std::pair > vvQPacsConnection::getKeys() //gdcm::Tag tagsdc(8,1030); //keys.push_back(std::make_pair(tagsdc, "")); - //// Accession n° + //// Accession //gdcm::Tag tagacc(8,50); //keys.push_back(std::make_pair(tagacc, "")); @@ -357,21 +379,59 @@ void vvQPacsConnection::chooseServer(int index) void vvQPacsConnection::on_importButton_clicked() { - + setCursor(QCursor(Qt::WaitCursor)); + QString path = QString::fromStdString(getCMoveDirectory()); + QDir dirpath (path); + if (dirpath.exists()) + { + QFileInfoList list = dirpath.entryInfoList( QDir::Files); + QFileInfoList::iterator it_file = dirpath.entryInfoList( QDir::Files).begin(); + for(int i = 0; i < list.length() ; i++) + { + QFile::remove(list.at(i).filePath()); + } + } + else + { + dirpath.mkdir(path); + } bool didItWork = gdcm::CompositeNetworkFunctions::CMove(m_adress.c_str(),atoi(m_port.c_str()), - gdcm::CompositeNetworkFunctions::ConstructQuery(mQFactory.getMoveQuery().theRoot, mQFactory.getMoveQuery().theLevel ,mQFactory.getMoveQuery().keys,true), - getDicomClientPort(), getDicomClientAETitle().c_str(), m_aetitle.c_str(),"D:\\move" ); + gdcm::CompositeNetworkFunctions::ConstructQuery(mQFactory.getMoveQuery().theRoot, mQFactory.getMoveQuery().theLevel ,mQFactory.getMoveQuery().keys, gdcm::eMove), + getDicomClientPort(), getDicomClientAETitle().c_str(), m_aetitle.c_str(), path.toStdString().c_str() ); gdcm::Directory theDir; - theDir.Load("D:\\move"); - m_files = theDir.GetFilenames(); + theDir.Load(path.toStdString().c_str()); + //m_files = theDir.GetFilenames(); + + typedef itk::GDCMSeriesFileNames NamesGeneratorType; + NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New(); + nameGenerator->SetUseSeriesDetails(true); + + //ds gerer recursive moi-meme pour progress ... + nameGenerator->SetInputDirectory(path.toStdString()); + + // insert in table + typedef std::vector SeriesIdContainer; + const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs(); + std::map* > mListOfSeriesFilenames; + + + m_fileseries.clear(); + + for (unsigned int i=0; iGetFileNames(seriesUID[i])); + } + accept(); + setCursor(QCursor(Qt::ArrowCursor)); } -std::vector vvQPacsConnection::getFileNames() + + +std::vector vvQPacsConnection::getFileNames(int i_series) { std::vector filenames; - gdcm::Directory::FilenamesType::iterator it = m_files.begin(); - for (;it != m_files.end(); it++) + gdcm::Directory::FilenamesType::iterator it = m_fileseries[i_series].begin(); + for (;it != m_fileseries[i_series].end(); it++) filenames.push_back(it->c_str()); return filenames; }