X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvQPacsConnection.cxx;h=4ae0d33b9981bdddc7a31e98e2f2aa0b55c16b7f;hb=b99fac059ebc47ce7b243dc9d802b23d730e7100;hp=22d5d971ddb51a878801987424a28603e1b72cc9;hpb=f4ee750a005c1406848ffdfd85a0ebcbe824bca6;p=clitk.git diff --git a/vv/vvQPacsConnection.cxx b/vv/vvQPacsConnection.cxx index 22d5d97..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 @@ -81,14 +96,14 @@ void vvQPacsConnection::on_scanButton_clicked() { m_level =gdcm::ePatient; std::vector theDataSet; - f_query = getQueryPatient(ui.patientName->toPlainText().toStdString(), ui.patientID->toPlainText().toStdString()); + f_query = mQFactory.getQueryPatient(ui.patientName->toPlainText().toStdString(), ui.patientID->toPlainText().toStdString()); bool cfindWork = gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys), theDataSet, getDicomClientAETitle().c_str() , m_nickname.c_str()); if( cfindWork) { - convertDataSet(theDataSet,Patientmodel,getPatientKeys("","")); + convertDataSet(theDataSet,Patientmodel,mQFactory.getPatientKeys("","")); } // end cfindwork } // end didItwork } @@ -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; @@ -192,72 +207,54 @@ void vvQPacsConnection::cleanTree() void vvQPacsConnection::selectStudies(const QModelIndex &index) { - + m_patient= Patientmodel->data(index.sibling(index.row(),1)).toString().toStdString(); Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex()); - QVariant elt= Patientmodel->data(index.sibling(index.row(),1)); - m_patient=elt.toString().toStdString(); + Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex()); + Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); manageSeriesFilter(true); - - std::vector theDataSet; - m_query = getQueryPatient("",m_patient); - f_query = getQueryforStudy(m_patient, false); - - - if ( gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), - gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys) - , theDataSet, getDicomClientAETitle().c_str(), m_nickname.c_str()) ) - { - convertDataSet(theDataSet, Studymodel, getQueryKeysforStudy("",true)); - } + convertDataSet( findQuery( mQFactory.getQueryforStudy(m_patient, false)) , Studymodel, mQFactory.getQueryKeysforStudy("",true)); } +void vvQPacsConnection::clearMove() +{ +} void vvQPacsConnection::selectSeries(const QModelIndex &index) { - m_level =gdcm::eSeries; - Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex()); - QVariant elt= Studymodel->data(index.sibling(index.row(),3)); - QVariant elt2= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); - - - std::vector theDataSet; - - m_query = getQueryforSeries(elt.toString().toStdString(),elt2.toString().toStdString(), false); - f_query =getQueryforSeries(elt.toString().toStdString(),elt2.toString().toStdString(), false); - if ( gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), - gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys), theDataSet, - getDicomClientAETitle().c_str(), m_nickname.c_str())) - { + m_study= Studymodel->data(index.sibling(index.row(),3)).toString().toStdString(); + Seriesmodel->removeRows(0, Seriesmodel->rowCount()); + Imagesmodel->removeRows(0, Imagesmodel->rowCount()); + convertDataSet( findQuery( mQFactory.getQueryforSeries(m_patient,m_study, false)), Seriesmodel, mQFactory.getSeriesKeys("","",true)); - convertDataSet(theDataSet, Seriesmodel, getSeriesKeys("","",true)); - } } void vvQPacsConnection::selectImages(const QModelIndex &index) { - m_level = gdcm::eImage; + m_series = Seriesmodel->data(index.sibling(index.row(),2)).toString().toStdString(); Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); - QVariant elt3= Seriesmodel->data(index.sibling(index.row(),2)); - QVariant elt2= Studymodel->data(index.sibling(ui.studyTreeView->selectionModel()->selectedRows().first().row(),3)); - QVariant elt= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); + convertDataSet( findQuery( mQFactory.getQueryforImages(m_patient,m_study, m_series, false) ), Imagesmodel, mQFactory.getQueryKeysforImages("","","",true)); + +} - //manageImagesFilter(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 theDataSet; - std::vector< std::pair > keys; - f_query =getQueryforImages(elt.toString().toStdString(),elt2.toString().toStdString(), elt3.toString().toStdString(),false); - m_query =getQueryforImages(elt.toString().toStdString(),elt2.toString().toStdString(), elt3.toString().toStdString(),false); - if( gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), - gdcm::CompositeNetworkFunctions::ConstructQuery(f_query.theRoot, f_query.theLevel ,f_query.keys), theDataSet, - getDicomClientAETitle().c_str(), m_nickname.c_str())) - { - convertDataSet(theDataSet, Imagesmodel, getQueryKeysforImages("","","",true)); - } } +std::vector vvQPacsConnection::findQuery(vvQuery i_query) +{ + std::vector theDataSet; + gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), + gdcm::CompositeNetworkFunctions::ConstructQuery(i_query.theRoot, i_query.theLevel,i_query.keys), theDataSet, + getDicomClientAETitle().c_str(), m_nickname.c_str()); + return theDataSet; +} + void vvQPacsConnection::manageStudiesFilter(bool i_enable) { ui.text_PHYS->setEnabled(i_enable); @@ -271,28 +268,6 @@ void vvQPacsConnection::manageSeriesFilter(bool i_enable) ui.modalityTab->setEnabled(i_enable); } -vvQuery vvQPacsConnection::getQueryPatient(const std::string i_patname, const std::string i_patid) -{ - vvQuery query; - query.theRoot = gdcm::ePatientRootType; - query.theLevel = gdcm::ePatient; - query.keys = getPatientKeys(i_patname, i_patid); - return query; - -} - -std::vector< std::pair > vvQPacsConnection::getPatientKeys(const std::string i_patname, const std::string i_patid) -{ - std::vector< std::pair > keys; - // Patient Name - gdcm::Tag tag(0x0010,0x0010); - keys.push_back(std::make_pair(tag, i_patname)); - - //// Patient ID - gdcm::Tag tagpid(0x0010,0x0020); - keys.push_back(std::make_pair(tagpid, i_patid)); - return keys; -} std::vector< std::pair > vvQPacsConnection::getStudyKeys(const std::string i_val) { @@ -313,36 +288,6 @@ std::vector< std::pair > vvQPacsConnection::getStudyKeys return keys; } -vvQuery vvQPacsConnection::getQueryforSeries(const std::string patient_id, const std::string series_id, bool bdisplay) -{ - vvQuery query; - query.theRoot = gdcm::ePatientRootType; - query.theLevel = gdcm::eSeries; - query.keys = getSeriesKeys(patient_id, series_id, bdisplay); - return query; -} -std::vector< std::pair > vvQPacsConnection::getSeriesKeys(const std::string patient_id, const std::string study_id, bool bdisplay) -{ - std::vector< std::pair > keys; - // Modality - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), "")); - // Study date - - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x103e),"")); -// Series Instance UID - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), "")); - - - - if(!bdisplay) - { - // Study Instance UID - gdcm::Tag tagsid(0x0020,0x1209); - keys.push_back(std::make_pair(tagsid, study_id)); - } - - return keys; -} std::vector< std::pair > vvQPacsConnection::getKeys() { std::vector< std::pair > keys; @@ -374,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, "")); @@ -434,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(m_query.theRoot, m_query.theLevel ,m_query.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; } @@ -464,74 +447,3 @@ std::vector< std::pair > vvQPacsConnection::fillMoveKeys return keys; } - -vvQuery vvQPacsConnection::getQueryforStudy(const std::string patient_id, bool bdisplay) -{ - vvQuery query; - query.keys = getQueryKeysforStudy( patient_id, bdisplay); - query.theRoot = gdcm::ePatientRootType; - query.theLevel = gdcm::eStudy; - return query; -} - -std::vector< std::pair > vvQPacsConnection::getQueryKeysforStudy(const std::string patient_id, bool bdisplay) -{ - std::vector< std::pair > keys; - - - // Study Description - gdcm::Tag tagsdc(0x0008,0x1030); - keys.push_back(std::make_pair(tagsdc, "")); - // Study date - gdcm::Tag tagdb(0x0008,0x0020); - keys.push_back(std::make_pair(tagdb, "")); - // Study Hour - gdcm::Tag tagsdh(0x0008,0x0030); - keys.push_back(std::make_pair(tagsdh, "")); - - // Study UID - gdcm::Tag tagsid(0x020,0x000d); - keys.push_back(std::make_pair(tagsid, "")); - - if (!bdisplay) - { - // Patient ID - gdcm::Tag tagsd(0x0010,0x0020); - keys.push_back(std::make_pair(tagsd, patient_id)); - } - - return keys; -} - -vvQuery vvQPacsConnection::getQueryforImages(const std::string patient_id, const std::string study_id, const std::string series_id,bool bdisplay) -{ - vvQuery query; - query.keys = getQueryKeysforImages( patient_id, study_id, series_id, bdisplay); - query.theRoot = gdcm::ePatientRootType; - query.theLevel = gdcm::eImage; - return query; -} - -std::vector< std::pair > vvQPacsConnection::getQueryKeysforImages(const std::string patient_id, const std::string study_id, const std::string series_id,bool bdisplay) -{ - - std::vector< std::pair > keys; - - if (!bdisplay) - { - //Patient UID - keys.push_back(std::make_pair(gdcm::Tag (0x0010,0x0020), patient_id)); - - //Study UID - // keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000d), study_id)); - - //Series UID - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), series_id)); - } - // Image Description - - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x0013), "")); - //SOP Instance UID - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0018), "")); - return keys; -} \ No newline at end of file