From 809c25ce37d81796cb7363afd3f8d042bcbb92a9 Mon Sep 17 00:00:00 2001 From: cervenansky Date: Fri, 5 Jul 2013 14:18:43 +0200 Subject: [PATCH] Dicom server connection --- vv/qt_ui/vvPacsConnection.ui | 52 +- vv/vv.cxx | 1 + vv/vvMainWindow.cxx | 8 +- vv/vvQPacsConnection.cxx | 967 ++++++++++++++++++----------------- vv/vvQPacsConnection.h | 15 +- vv/vvUtils.cxx | 44 ++ vv/vvUtils.h | 7 + 7 files changed, 581 insertions(+), 513 deletions(-) diff --git a/vv/qt_ui/vvPacsConnection.ui b/vv/qt_ui/vvPacsConnection.ui index 9e89d0b..219e1ba 100644 --- a/vv/qt_ui/vvPacsConnection.ui +++ b/vv/qt_ui/vvPacsConnection.ui @@ -350,7 +350,7 @@ - 1 + 0 @@ -538,37 +538,21 @@ - 1 + 0 Network - + - 10 - 10 - 101 - 17 - - - - HCL Neuro - - - - - - 10 + 20 40 - 70 - 17 + 191 + 22 - - conquest - @@ -588,13 +572,13 @@ OK - + 0 0 179 - 100 + 120 @@ -611,16 +595,6 @@ - - - - false - - - AE Title - - - @@ -650,6 +624,16 @@ + + + + false + + + AE Title + + + diff --git a/vv/vv.cxx b/vv/vv.cxx index 5df3415..7071a1b 100644 --- a/vv/vv.cxx +++ b/vv/vv.cxx @@ -44,6 +44,7 @@ #include #include #include +#pragma comment(lib, "ws2_32.lib") typedef enum {O_BASE,O_OVERLAY,O_FUSION,O_VF,O_CONTOUR,O_LANDMARKS} OpenModeType; typedef enum {P_NORMAL,P_SEQUENCE,P_WINDOW,P_LEVEL} ParseModeType; diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index d25228c..3509aae 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -754,10 +754,10 @@ void vvMainWindow::OpenDicom() std::vector files; //std::cout << "dicomSeriesSelector " << std::endl; - /*if (pacsconnect->exec() == QDialog::Accepted) { - files = *(pacsconnect->GetFilenames()); - LoadImages(files, vvImageReader::DICOM); - }*/ +if (pacsconnect->exec() == QDialog::Accepted) { +// files = *(pacsconnect->GetFilenames()); + // LoadImages(files, vvImageReader::DICOM); + } } diff --git a/vv/vvQPacsConnection.cxx b/vv/vvQPacsConnection.cxx index 6b880ad..8d34062 100644 --- a/vv/vvQPacsConnection.cxx +++ b/vv/vvQPacsConnection.cxx @@ -1,5 +1,3 @@ -#ifndef _VVPACSCONNECTION_CXX -#define _VVPACSCONNECTION_CXX #include "vvQPacsConnection.h" #include "gdcmCompositeNetworkFunctions.h" #include @@ -7,480 +5,513 @@ #include #include #include - - - vvQPacsConnection::vvQPacsConnection(QWidget *i_parent) - :QDialog(i_parent) - { - ui.setupUi(this); - setWindowTitle(QString::fromUtf8("PACS CONNECTION")); - createTreeView(); - ui.tabFilter->setTabText(0,QString(tr("Modality"))); - ui.tabFilter->setTabText(1,QString(tr("Date"))); - - ui. tabNetwork->setTabText(0,QString(tr("Network"))); - ui. tabNetwork->setTabText(1,QString(tr("Configuration"))); - //ui.setChecked(true); - //ui.on_check_ModAll_clicked(true); - QIcon icon; - icon.addFile("basket_download.png",QSize(),QIcon::Normal,QIcon::Off); - ui.importButton->setIcon(icon); - icon.addFile("file_upload.png",QSize(),QIcon::Normal,QIcon::Off); - // exportButton->setIcon(icon); - icon.addFile("email_forward.png",QSize(),QIcon::Normal,QIcon::Off); - icon.addFile("edit.png",QSize(),QIcon::Normal,QIcon::Off); - ui.optionsButton->setIcon(icon); - icon.addFile("bullet_info.png",QSize(),QIcon::Normal,QIcon::Off); - ui.helpButton->setIcon(icon); - update(); - } - - - void vvQPacsConnection::on_clearButton_clicked() +#include "vvPacsSettingsDialog.h" +#include "vvUtils.h" + + +vvQPacsConnection::vvQPacsConnection(QWidget *i_parent) + :QDialog(i_parent) +{ + ui.setupUi(this); + setWindowTitle(QString::fromUtf8("PACS CONNECTIONHHHH")); + createTreeView(); + ui.tabFilter->setTabText(0,QString(tr("Modality"))); + ui.tabFilter->setTabText(1,QString(tr("Date"))); + + ui. tabNetwork->setTabText(0,QString(tr("Network"))); + ui. tabNetwork->setTabText(1,QString(tr("Configuration"))); + //ui.setChecked(true); + //ui.on_check_ModAll_clicked(true); + QIcon icon; + icon.addFile("basket_download.png",QSize(),QIcon::Normal,QIcon::Off); + ui.importButton->setIcon(icon); + icon.addFile("file_upload.png",QSize(),QIcon::Normal,QIcon::Off); + // exportButton->setIcon(icon); + icon.addFile("email_forward.png",QSize(),QIcon::Normal,QIcon::Off); + icon.addFile("edit.png",QSize(),QIcon::Normal,QIcon::Off); + ui.optionsButton->setIcon(icon); + icon.addFile("bullet_info.png",QSize(),QIcon::Normal,QIcon::Off); + ui.helpButton->setIcon(icon); + connect(ui.optionsButton,SIGNAL(clicked()),this,SLOT(setNewPacs())); + ui.networkCombo->addItems(getDicomServers()); + connect(ui.networkCombo,SIGNAL(currentIndexChanged(int)),this,SLOT(connectServer(int))); + connect(ui.scanButton,SIGNAL(clicked()),this,SLOT(on_scanButton_clicked())); + update(); +} + +void vvQPacsConnection::refreshNetworks() +{ + ui.networkCombo->clear(); + ui.networkCombo->addItems(getDicomServers()); + //ui.networkCombo->show(); +} + +void vvQPacsConnection::on_clearButton_clicked() +{ + Patientmodel->removeRows(0, Patientmodel->rowCount(),QModelIndex()); + Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex()); + Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex()); + Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); +} + +void vvQPacsConnection::on_scanButton_clicked() +{ + //on_clearButton_clicked(); + manageStudiesFilter(true); + // #if defined (USE_GDCM2) + bool didItWork = gdcm::CompositeNetworkFunctions::CEcho(m_adress.c_str(), atoi(m_port.c_str()), "CREATIS", m_nickname.c_str() ); + /* tag.SetElement(8); + tag.SetGroup(8);*/ + std::vector< std::pair > keys = getKeys(); + + //std::pair pa; + //pa.first = tag; + //pa.second = ""; + ////keys.push_back(std::make_pair(tag, "")); + gdcm::EQueryLevel theLevel = gdcm::eStudy; + gdcm::ERootType theRoot = gdcm::eStudyRootType;//ePatientRootType; + //gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + + + std::vector theDataSet; + + theLevel = gdcm::ePatient; + theRoot = gdcm::ePatientRootType;//ePatientRootType; + gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,getPatientKeys("")); + + // + //theDataSet.clear(); + // gdcm::CompositeNetworkFunctions::CFind(m_adress, m_port, theQuery, theDataSet, + // "CREATIS", m_nickname); + // keys.clear(); + // keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0010), "")); + // + gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), theQuery, theDataSet, + "CREATIS", m_nickname.c_str()); + std::vector::iterator it_ds = theDataSet.begin(); + // + for(; it_ds != theDataSet.end(); it_ds++) { - Patientmodel->removeRows(0, Patientmodel->rowCount(),QModelIndex()); - Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex()); - Seriesmodel->removeRows(0, Seriesmodel->rowCount(),QModelIndex()); - Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); - } - void vvQPacsConnection::on_scanButton_clicked() - { - //on_clearButton_clicked(); - manageStudiesFilter(true); - #if defined (USE_GDCM2) - bool didItWork = gdcm::CompositeNetworkFunctions::CEcho( "127.0.0.1", 5678, - "CREATIS", "CONQUESTSRV1" ); - /* tag.SetElement(8); - tag.SetGroup(8);*/ - std::vector< std::pair > keys = getKeys(); - - //std::pair pa; - //pa.first = tag; - //pa.second = ""; - ////keys.push_back(std::make_pair(tag, "")); - gdcm::EQueryLevel theLevel = gdcm::eStudy; - gdcm::ERootType theRoot = gdcm::eStudyRootType;//ePatientRootType; - //gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); - - - std::vector theDataSet; - - theLevel = gdcm::ePatient; - theRoot = gdcm::ePatientRootType;//ePatientRootType; - gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,getPatientKeys("")); - -// -//theDataSet.clear(); -// gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, -// "CREATIS", "CONQUESTSRV1"); -// keys.clear(); -// keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0010), "")); -// - gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, - "CREATIS", "CONQUESTSRV1"); - std::vector::iterator it_ds = theDataSet.begin(); -// - for(; it_ds != theDataSet.end(); it_ds++) - { - - QList items; - const gdcm::DataSet ds = (*it_ds); - std::vector< std::pair >::iterator it_key = keys.begin(); - int ind = 0; - for(; it_key != keys.end(); it_key++, ind++) - { - gdcm::DataElement de = ds.GetDataElement((*it_key).first); - QStandardItem *item = new QStandardItem; - const gdcm::ByteValue *bv = (de).GetByteValue(); - if( !de.IsEmpty() ) - { - std::string buffer = std::string( bv->GetPointer(), bv->GetLength() ); - item->setText(tr(buffer.c_str())); - } - else - { - item->setText(tr("")); - } - if(ind ==0) - { - item->setCheckable(true); - } - items.push_back(item); - } - Patientmodel->appendRow(items); - } -// gdcm::Tag tagtest(0x0020,0x1208); -// keys.clear(); -// keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0010), "")); -//// keys.push_back(std::make_pair(tagtest, "")); -// theLevel = gdcm::ePatient; -// theRoot = gdcm::ePatientRootType;//ePatientRootType; -// theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); -// -// -//theDataSet.clear(); -// gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, -// "CREATIS", "CONQUESTSRV1"); -#endif - } - - - void vvQPacsConnection::on_importButton_clicked() - { - QModelIndex index; - QVariant elt= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); - - gdcm::EQueryLevel theLevel = gdcm::ePatient; - gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; - std::vector theDataSet; - std::vector< std::pair > keys; - - // Study Description - gdcm::Tag tagsdc(0x0010,0x0020); - keys.push_back(std::make_pair(tagsdc, elt.toString().toStdString())); - gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); - gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, "CREATIS", "CONQUESTSRV1"); - - bool didItWork = gdcm::CompositeNetworkFunctions::CMove( "127.0.0.1", 5678, theQuery, 0, - "CREATIS", "CONQUESTSRV1", "d:\\temp_pacs_import\\" ); - } - - void vvQPacsConnection::convertDataSet(std::vector i_ds, QStandardItemModel *i_model, std::vector< std::pair > keys) - { - gdcm::Tag tagdb(0x0008,0x0020); - std::vector::iterator it_ds = i_ds.begin(); - for(; it_ds != i_ds.end(); it_ds++) + QList items; + const gdcm::DataSet ds = (*it_ds); + std::vector< std::pair >::iterator it_key = keys.begin(); + int ind = 0; + for(; it_key != keys.end(); it_key++, ind++) { - QList items; - const gdcm::DataSet ds = (*it_ds); - std::vector< std::pair >::iterator it_key = keys.begin(); - int ind = 0; - for(; it_key != keys.end(); it_key++, ind++) - { - gdcm::DataElement de = ds.GetDataElement((*it_key).first); - QStandardItem *item = new QStandardItem; - const gdcm::ByteValue *bv = (de).GetByteValue(); - if( !de.IsEmpty() ) - { - std::string buffer = std::string( bv->GetPointer(), bv->GetLength() ); - /*if((*it_key).first == tagdb) - { - QDate date; - date.fromString(tr(buffer.c_str()),"yyyy'MM'd"); - item->setText(date.toString()); - } - else - {*/ - item->setText(tr(buffer.c_str())); - //} - } - else - { - item->setText(tr("")); - } - if(ind ==0) - { - item->setCheckable(true); - } - items.push_back(item); - } - i_model->appendRow(items); + gdcm::DataElement de = ds.GetDataElement((*it_key).first); + QStandardItem *item = new QStandardItem; + const gdcm::ByteValue *bv = (de).GetByteValue(); + if( !de.IsEmpty() ) + { + std::string buffer = std::string( bv->GetPointer(), bv->GetLength() ); + item->setText(tr(buffer.c_str())); + } + else + { + item->setText(tr("")); + } + if(ind ==0) + { + item->setCheckable(true); + } + items.push_back(item); } - - } - - - void vvQPacsConnection::createTreeView() - { - // Patient Tree View - Patientmodel = new QStandardItemModel(0,2,this); - QStringList Patientlist; - Patientlist.push_back(tr("PATIENT NAME")); - Patientlist.push_back(tr("PATIENT ID")); - Patientmodel->setHorizontalHeaderLabels(Patientlist); - ui.patientTreeView->setModel(Patientmodel); - ui.patientTreeView->setEnabled(true); - connect(ui.patientTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectStudies(QModelIndex))); - - // Study Tree View - Studymodel = new QStandardItemModel(0,3,this); - QStringList Studylist; - Studylist.push_back(tr("DESCRIPTION")); - Studylist.push_back(tr("DATE")); - Studylist.push_back(tr("HOUR")); - Studymodel->setHorizontalHeaderLabels(Studylist); - ui.studyTreeView->setModel(Studymodel); - connect(ui.studyTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectSeries(QModelIndex))); - - - // Series Tree View - Seriesmodel = new QStandardItemModel(0,2,this); - QStringList Serieslist; - Serieslist.push_back(tr("MODALITY")); - Serieslist.push_back(tr("DESCRIPTION")); - Serieslist.push_back(tr("no. accept.")); - Seriesmodel->setHorizontalHeaderLabels(Serieslist); - ui.seriesTreeView->setModel(Seriesmodel); - connect(ui.seriesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImages(QModelIndex))); - - // Images Tree View - Imagesmodel = new QStandardItemModel(0,1,this); - QStringList Imageslist; - Imageslist.push_back(tr("instance number")); - Imagesmodel->setHorizontalHeaderLabels(Imageslist); - ui.imagesTreeView->setModel(Imagesmodel); - - //model->setHeaderData(0, Qt::Horizontal,tr("test"),Qt::DisplayRole); - /*QFileSystemModel *filemodel = new QFileSystemModel; - filemodel->insertColumn(1); - filemodel->setHeaderData(1, Qt::Horizontal,"test",0);*/ - - } - - void vvQPacsConnection::selectStudies(const QModelIndex &index) - { - Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex()); - QVariant elt= Patientmodel->data(index.sibling(index.row(),1)); - m_patient=elt.toString().toStdString(); - manageSeriesFilter(true); - gdcm::EQueryLevel theLevel = gdcm::eStudy; - gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; - std::vector theDataSet; - std::vector< std::pair > keys; - - // Study Description - gdcm::Tag tagsd(0x0010,0x0020); - keys.push_back(std::make_pair(tagsd, m_patient)); - // 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, "")); - gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); - gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, "CREATIS", "CONQUESTSRV1"); - convertDataSet(theDataSet, Studymodel, getStudyKeys("")); - } - - - void vvQPacsConnection::selectSeries(const QModelIndex &index) - { - 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)); - - //manageImagesFilter(true); - gdcm::EQueryLevel theLevel = gdcm::eSeries; - gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; - std::vector theDataSet; - std::vector< std::pair > keys; - - //Patient Unique key - keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0020), m_patient)); - - //Study Unique Key - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000d), elt.toString().toStdString())); - - - // Modality - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); - // Description - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); - // Acceptance NUmber???? - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), elt.toString().toStdString())); - - gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); - keys.clear(); - // Modality - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); - // Description - keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); - // Acceptance NUmber???? - keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), elt.toString().toStdString())); - - - - gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, "CREATIS", "CONQUESTSRV1"); - convertDataSet(theDataSet, Seriesmodel, keys); - } - - void vvQPacsConnection::selectImages(const QModelIndex &index) - { - Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); - QVariant elt= Seriesmodel->data(index.sibling(index.row(),2)); - QVariant elt2= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); - - //manageImagesFilter(true); - gdcm::EQueryLevel theLevel = gdcm::eImage; - gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; - std::vector theDataSet; - std::vector< std::pair > keys; - - gdcm::Tag tagsd(0x0010,0x0020); - keys.push_back(std::make_pair(tagsd, m_patient)); - - gdcm::Tag tagss(0x0020,0x000e); - keys.push_back(std::make_pair(tagss, elt.toString().toStdString())); - //= getStudyKeys(elt.toString().toStdString()); - - // Study Description - gdcm::Tag tagsdc(0x0020,0x0013); - keys.push_back(std::make_pair(tagsdc, "")); - - - gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); - keys.clear(); - // Study Description - - keys.push_back(std::make_pair(tagsdc, "")); - - - gdcm::CompositeNetworkFunctions::CFind("127.0.0.1", 5678, theQuery, theDataSet, "CREATIS", "CONQUESTSRV1"); - convertDataSet(theDataSet, Seriesmodel, keys); + Patientmodel->appendRow(items); } - - - void vvQPacsConnection::manageStudiesFilter(bool i_enable) - { - ui.text_PHYS->setEnabled(i_enable); - ui.text_SDESC->setEnabled(i_enable); - ui.dateTab->setEnabled(i_enable); - - } - - void vvQPacsConnection::manageSeriesFilter(bool i_enable) + // gdcm::Tag tagtest(0x0020,0x1208); + // keys.clear(); + // keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0010), "")); + //// keys.push_back(std::make_pair(tagtest, "")); + // theLevel = gdcm::ePatient; + // theRoot = gdcm::ePatientRootType;//ePatientRootType; + // theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + // + // + //theDataSet.clear(); + // gdcm::CompositeNetworkFunctions::CFind(m_adress, m_port, theQuery, theDataSet, + // "CREATIS",m_nickname); + +} + + +void vvQPacsConnection::on_optionsButton_clicked() +{ + + vvPacsSettingsDialog *dg = new vvPacsSettingsDialog(this); + dg->show(); + + /*QModelIndex index; + QVariant elt= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); + + gdcm::EQueryLevel theLevel = gdcm::ePatient; + gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; + std::vector theDataSet; + std::vector< std::pair > keys; + + // Study Description + gdcm::Tag tagsdc(0x0010,0x0020); + keys.push_back(std::make_pair(tagsdc, elt.toString().toStdString())); + gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + gdcm::CompositeNetworkFunctions::CFind(m_adress, m_port, theQuery, theDataSet, "CREATIS", m_nickname); + + bool didItWork = gdcm::CompositeNetworkFunctions::CMove( m_adress, m_port, theQuery, 0, + "CREATIS", m_nickname,m_destination );*/ +} + +void vvQPacsConnection::convertDataSet(std::vector i_ds, QStandardItemModel *i_model, std::vector< std::pair > keys) +{ + gdcm::Tag tagdb(0x0008,0x0020); + std::vector::iterator it_ds = i_ds.begin(); + for(; it_ds != i_ds.end(); it_ds++) { - ui.modalityTab->setEnabled(i_enable); - } - - std::vector< std::pair > vvQPacsConnection::getPatientKeys(const std::string i_val) - { - std::vector< std::pair > keys; - // Patient Name - gdcm::Tag tag(0x0010,0x0010); - keys.push_back(std::make_pair(tag, "")); - - //// Patient ID - gdcm::Tag tagpid(0x0010,0x0020); - keys.push_back(std::make_pair(tagpid, i_val)); - return keys; - } - - std::vector< std::pair > vvQPacsConnection::getStudyKeys(const std::string i_val) - { - 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 Instance UID - gdcm::Tag tagsid(0x0020,0x000d); - keys.push_back(std::make_pair(tagsid, i_val)); - - return keys; + QList items; + const gdcm::DataSet ds = (*it_ds); + std::vector< std::pair >::iterator it_key = keys.begin(); + int ind = 0; + for(; it_key != keys.end(); it_key++, ind++) + { + gdcm::DataElement de = ds.GetDataElement((*it_key).first); + QStandardItem *item = new QStandardItem; + const gdcm::ByteValue *bv = (de).GetByteValue(); + if( !de.IsEmpty() ) + { + std::string buffer = std::string( bv->GetPointer(), bv->GetLength() ); + /*if((*it_key).first == tagdb) + { + QDate date; + date.fromString(tr(buffer.c_str()),"yyyy'MM'd"); + item->setText(date.toString()); + } + else + {*/ + item->setText(tr(buffer.c_str())); + //} + } + else + { + item->setText(tr("")); + } + if(ind ==0) + { + item->setCheckable(true); + } + items.push_back(item); + } + i_model->appendRow(items); } - - std::vector< std::pair > vvQPacsConnection::getSeriesKeys(const std::string i_val) +} + + +void vvQPacsConnection::createTreeView() +{ + // Patient Tree View + Patientmodel = new QStandardItemModel(0,2,this); + QStringList Patientlist; + Patientlist.push_back(tr("PATIENT NAME")); + Patientlist.push_back(tr("PATIENT ID")); + Patientmodel->setHorizontalHeaderLabels(Patientlist); + ui.patientTreeView->setModel(Patientmodel); + ui.patientTreeView->setEnabled(true); + connect(ui.patientTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectStudies(QModelIndex))); + + // Study Tree View + Studymodel = new QStandardItemModel(0,3,this); + QStringList Studylist; + Studylist.push_back(tr("DESCRIPTION")); + Studylist.push_back(tr("DATE")); + Studylist.push_back(tr("HOUR")); + Studymodel->setHorizontalHeaderLabels(Studylist); + ui.studyTreeView->setModel(Studymodel); + connect(ui.studyTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectSeries(QModelIndex))); + + + // Series Tree View + Seriesmodel = new QStandardItemModel(0,2,this); + QStringList Serieslist; + Serieslist.push_back(tr("MODALITY")); + Serieslist.push_back(tr("DESCRIPTION")); + Serieslist.push_back(tr("no. accept.")); + Seriesmodel->setHorizontalHeaderLabels(Serieslist); + ui.seriesTreeView->setModel(Seriesmodel); + connect(ui.seriesTreeView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectImages(QModelIndex))); + + // Images Tree View + Imagesmodel = new QStandardItemModel(0,1,this); + QStringList Imageslist; + Imageslist.push_back(tr("instance number")); + Imagesmodel->setHorizontalHeaderLabels(Imageslist); + ui.imagesTreeView->setModel(Imagesmodel); + + //model->setHeaderData(0, Qt::Horizontal,tr("test"),Qt::DisplayRole); + /*QFileSystemModel *filemodel = new QFileSystemModel; + filemodel->insertColumn(1); + filemodel->setHeaderData(1, Qt::Horizontal,"test",0);*/ + +} + +void vvQPacsConnection::selectStudies(const QModelIndex &index) +{ + Studymodel->removeRows(0, Studymodel->rowCount(),QModelIndex()); + QVariant elt= Patientmodel->data(index.sibling(index.row(),1)); + m_patient=elt.toString().toStdString(); + manageSeriesFilter(true); + gdcm::EQueryLevel theLevel = gdcm::eStudy; + gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; + std::vector theDataSet; + std::vector< std::pair > keys; + + // Study Description + gdcm::Tag tagsd(0x0010,0x0020); + keys.push_back(std::make_pair(tagsd, m_patient)); + // 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, "")); + gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), theQuery, theDataSet, "CREATIS", m_nickname.c_str()); + convertDataSet(theDataSet, Studymodel, getStudyKeys("")); +} + + +void vvQPacsConnection::selectSeries(const QModelIndex &index) +{ + 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)); + + //manageImagesFilter(true); + gdcm::EQueryLevel theLevel = gdcm::eSeries; + gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; + std::vector theDataSet; + std::vector< std::pair > keys; + + //Patient Unique key + keys.push_back(std::make_pair(gdcm::Tag(0x0010,0x0020), m_patient)); + + //Study Unique Key + keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000d), elt.toString().toStdString())); + + + // Modality + keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); + // Description + keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); + // Acceptance NUmber???? + keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), elt.toString().toStdString())); + + gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + keys.clear(); + // Modality + keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); + // Description + keys.push_back(std::make_pair(gdcm::Tag(0x0008,0x0060), elt.toString().toStdString())); + // Acceptance NUmber???? + keys.push_back(std::make_pair(gdcm::Tag(0x0020,0x000e), elt.toString().toStdString())); + + + + gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), theQuery, theDataSet, "CREATIS", m_nickname.c_str()); + convertDataSet(theDataSet, Seriesmodel, keys); +} + +void vvQPacsConnection::selectImages(const QModelIndex &index) +{ + Imagesmodel->removeRows(0, Imagesmodel->rowCount(),QModelIndex()); + QVariant elt= Seriesmodel->data(index.sibling(index.row(),2)); + QVariant elt2= Patientmodel->data(index.sibling(ui.patientTreeView->selectionModel()->selectedRows().first().row(),1)); + + //manageImagesFilter(true); + gdcm::EQueryLevel theLevel = gdcm::eImage; + gdcm::ERootType theRoot = gdcm::ePatientRootType;//ePatientRootType; + std::vector theDataSet; + std::vector< std::pair > keys; + + gdcm::Tag tagsd(0x0010,0x0020); + keys.push_back(std::make_pair(tagsd, m_patient)); + + gdcm::Tag tagss(0x0020,0x000e); + keys.push_back(std::make_pair(tagss, elt.toString().toStdString())); + //= getStudyKeys(elt.toString().toStdString()); + + // Study Description + gdcm::Tag tagsdc(0x0020,0x0013); + keys.push_back(std::make_pair(tagsdc, "")); + + + gdcm::SmartPointer theQuery = gdcm::CompositeNetworkFunctions::ConstructQuery(theRoot, theLevel ,keys); + keys.clear(); + // Study Description + + keys.push_back(std::make_pair(tagsdc, "")); + + + gdcm::CompositeNetworkFunctions::CFind(m_adress.c_str(), atoi(m_port.c_str()), theQuery, theDataSet, "CREATIS", m_nickname.c_str()); + convertDataSet(theDataSet, Seriesmodel, keys); +} + + +void vvQPacsConnection::manageStudiesFilter(bool i_enable) +{ + ui.text_PHYS->setEnabled(i_enable); + ui.text_SDESC->setEnabled(i_enable); + ui.dateTab->setEnabled(i_enable); + +} + +void vvQPacsConnection::manageSeriesFilter(bool i_enable) +{ + ui.modalityTab->setEnabled(i_enable); +} + +std::vector< std::pair > vvQPacsConnection::getPatientKeys(const std::string i_val) +{ + std::vector< std::pair > keys; + // Patient Name + gdcm::Tag tag(0x0010,0x0010); + keys.push_back(std::make_pair(tag, "")); + + //// Patient ID + gdcm::Tag tagpid(0x0010,0x0020); + keys.push_back(std::make_pair(tagpid, i_val)); + return keys; +} + +std::vector< std::pair > vvQPacsConnection::getStudyKeys(const std::string i_val) +{ + 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 Instance UID + gdcm::Tag tagsid(0x0020,0x000d); + keys.push_back(std::make_pair(tagsid, i_val)); + + return keys; +} + + +std::vector< std::pair > vvQPacsConnection::getSeriesKeys(const std::string i_val) +{ + std::vector< std::pair > keys; + // Modality + gdcm::Tag tagsm(0x0008,0x0060); + keys.push_back(std::make_pair(tagsm, "")); + // Study date + gdcm::Tag tagdb(0x0008,0x103e); + keys.push_back(std::make_pair(tagdb, "")); + // Study Hour + gdcm::Tag tagsdh(0x0020,0x000e); + keys.push_back(std::make_pair(tagsdh, "")); + // Study Instance UID + gdcm::Tag tagsid(0x0020,0x1209); + keys.push_back(std::make_pair(tagsid, i_val)); + + return keys; +} +std::vector< std::pair > vvQPacsConnection::getKeys() +{ + std::vector< std::pair > keys; + // Patient Name + gdcm::Tag tag(0x0010,0x0010); + keys.push_back(std::make_pair(tag, "")); + + //// Patient ID + gdcm::Tag tagpid(0x0010,0x0020); + keys.push_back(std::make_pair(tagpid, "")); + + // Modality + gdcm::Tag tagmod(0x0008,0x0061); + keys.push_back(std::make_pair(tagmod, "")); + + // date of birth + gdcm::Tag tagdb(0x0010,0x0030); + keys.push_back(std::make_pair(tagdb, "")); + + // Study Date + gdcm::Tag tagsd(0x0020,0x000D); + keys.push_back(std::make_pair(tagsd, "")); + + //// Study Time + //gdcm::Tag tagst(8,30); + //keys.push_back(std::make_pair(tagst, "")); + + //// Study Description + //gdcm::Tag tagsdc(8,1030); + //keys.push_back(std::make_pair(tagsdc, "")); + + //// Accession n° + //gdcm::Tag tagacc(8,50); + //keys.push_back(std::make_pair(tagacc, "")); + + return keys; +} + +void vvQPacsConnection::on_check_ModAll_clicked(bool state) +{ + ui.check_MR->setEnabled(!state); + ui.check_CR->setEnabled(!state); + ui.check_OT->setEnabled(!state); + ui.check_RF->setEnabled(!state); + ui.check_SC->setEnabled(!state); + ui.check_CT->setEnabled(!state); + ui.check_US->setEnabled(!state); + ui.check_NM->setEnabled(!state); + ui.check_DR->setEnabled(!state); + ui.check_US->setEnabled(!state); + ui.check_NM->setEnabled(!state); + ui.check_DR->setEnabled(!state); + ui.check_SR->setEnabled(!state); + ui.check_XA->setEnabled(!state); + ui.check_MG->setEnabled(!state); + if(state) { - std::vector< std::pair > keys; - // Modality - gdcm::Tag tagsm(0x0008,0x0060); - keys.push_back(std::make_pair(tagsm, "")); - // Study date - gdcm::Tag tagdb(0x0008,0x103e); - keys.push_back(std::make_pair(tagdb, "")); - // Study Hour - gdcm::Tag tagsdh(0x0020,0x000e); - keys.push_back(std::make_pair(tagsdh, "")); - // Study Instance UID - gdcm::Tag tagsid(0x0020,0x1209); - keys.push_back(std::make_pair(tagsid, i_val)); - - return keys; + ui.check_MR->setChecked(state); + ui.check_CR->setChecked(state); + ui.check_OT->setChecked(state); + ui.check_RF->setChecked(state); + ui.check_SC->setChecked(state); + ui.check_CT->setChecked(state); + ui.check_US->setChecked(state); + ui.check_NM->setChecked(state); + ui.check_DR->setChecked(state); + ui.check_US->setChecked(state); + ui.check_NM->setChecked(state); + ui.check_DR->setChecked(state); + ui.check_SR->setChecked(state); + ui.check_XA->setChecked(state); + ui.check_MG->setChecked(state); } - std::vector< std::pair > vvQPacsConnection::getKeys() - { - std::vector< std::pair > keys; - // Patient Name - gdcm::Tag tag(0x0010,0x0010); - keys.push_back(std::make_pair(tag, "")); - - //// Patient ID - gdcm::Tag tagpid(0x0010,0x0020); - keys.push_back(std::make_pair(tagpid, "")); - - // Modality - gdcm::Tag tagmod(0x0008,0x0061); - keys.push_back(std::make_pair(tagmod, "")); - - // date of birth - gdcm::Tag tagdb(0x0010,0x0030); - keys.push_back(std::make_pair(tagdb, "")); - - // Study Date - gdcm::Tag tagsd(0x0020,0x000D); - keys.push_back(std::make_pair(tagsd, "")); - - //// Study Time - //gdcm::Tag tagst(8,30); - //keys.push_back(std::make_pair(tagst, "")); - - //// Study Description - //gdcm::Tag tagsdc(8,1030); - //keys.push_back(std::make_pair(tagsdc, "")); - - //// Accession n° - //gdcm::Tag tagacc(8,50); - //keys.push_back(std::make_pair(tagacc, "")); - return keys; - } - - void vvQPacsConnection::on_check_ModAll_clicked(bool state) - { - ui.check_MR->setEnabled(!state); - ui.check_CR->setEnabled(!state); - ui.check_OT->setEnabled(!state); - ui.check_RF->setEnabled(!state); - ui.check_SC->setEnabled(!state); - ui.check_CT->setEnabled(!state); - ui.check_US->setEnabled(!state); - ui.check_NM->setEnabled(!state); - ui.check_DR->setEnabled(!state); - ui.check_US->setEnabled(!state); - ui.check_NM->setEnabled(!state); - ui.check_DR->setEnabled(!state); - ui.check_SR->setEnabled(!state); - ui.check_XA->setEnabled(!state); - ui.check_MG->setEnabled(!state); - if(state) - { - ui.check_MR->setChecked(state); - ui.check_CR->setChecked(state); - ui.check_OT->setChecked(state); - ui.check_RF->setChecked(state); - ui.check_SC->setChecked(state); - ui.check_CT->setChecked(state); - ui.check_US->setChecked(state); - ui.check_NM->setChecked(state); - ui.check_DR->setChecked(state); - ui.check_US->setChecked(state); - ui.check_NM->setChecked(state); - ui.check_DR->setChecked(state); - ui.check_SR->setChecked(state); - ui.check_XA->setChecked(state); - ui.check_MG->setChecked(state); - } - - } -#endif \ No newline at end of file +} + +void vvQPacsConnection::connectServer(int index) +{ + std::map < std::string, std:: string> values = getDicomServer(ui.networkCombo->currentText()); + m_port = values["PORT"]; + m_aetitle = values["AETITLE"]; + m_adress= values["ADRESS"]; + m_nickname = values["nickname"]; + ui.AdressEdit->setText(QString(m_adress.c_str())); + ui.AETitleEdit->setText(QString(m_aetitle.c_str())); + ui.NameEdit->setText(QString(m_nickname.c_str())); + ui.PortEdit->setText(QString(m_port.c_str())); +} + +void vvQPacsConnection::setNewPacs() +{ + int i; + i =0; +} diff --git a/vv/vvQPacsConnection.h b/vv/vvQPacsConnection.h index f94818d..c95088e 100644 --- a/vv/vvQPacsConnection.h +++ b/vv/vvQPacsConnection.h @@ -21,8 +21,8 @@ vvQPacsConnection(QWidget *parent=0); ~vvQPacsConnection(){} - ///Queries the PACS - //void OnQueryPACS(wxCommandEvent& event); + void refreshNetworks(); + public slots: void selectStudies(const QModelIndex &index); void selectSeries(const QModelIndex &index); @@ -30,9 +30,9 @@ public slots: private slots: void on_scanButton_clicked(); void on_clearButton_clicked(); - void on_importButton_clicked(); + void on_optionsButton_clicked(); void on_check_ModAll_clicked(bool state); - + void connectServer(int index); private : Ui::vvPacsConnection ui; @@ -43,6 +43,7 @@ public slots: std::vector< std::pair > getImageKeys(const std::string i_val); void manageStudiesFilter(bool i_enable); void createTreeView(); + void setNewPacs(); QStandardItemModel *Patientmodel; QStandardItemModel *Studymodel; QStandardItemModel *Seriesmodel; @@ -53,11 +54,11 @@ public slots: std::string m_study; std::string m_series; - std::string m_ip; + std::string m_port; std::string m_aetitle; std::string m_adress; - std::string m_name; - //wxDialog* dialog; + std::string m_nickname; + }; // class vvQPacsConnection //===================================================================== diff --git a/vv/vvUtils.cxx b/vv/vvUtils.cxx index 3ef9cc6..2dc0a96 100644 --- a/vv/vvUtils.cxx +++ b/vv/vvUtils.cxx @@ -48,6 +48,50 @@ FileListType GetRecentlyOpenedImages() return result; } +/// Add new Dicom Server +void AddDicomServer(std::string nickname, std::string aetitle, std::string adress, std::string port) +{ + QSettings settings(getVVSettingsPath(), getSettingsOptionFormat()); + settings.beginGroup(QString::fromStdString("DICOMSERVER")); + settings.beginWriteArray(QString::fromStdString(nickname)); + settings.setValue("nickname",QString::fromStdString(nickname)); + settings.setValue("AETITLE",QString::fromStdString(aetitle)); + settings.setValue("ADRESS",QString::fromStdString(adress)); + settings.setValue("PORT",QString::fromStdString(port)); + settings.endGroup(); +} + + +//std::map > getDicomServers() +QStringList getDicomServers() +{ + + QStringList list; + QSettings settings(getVVSettingsPath(), getSettingsOptionFormat()); + settings.beginGroup(QString::fromStdString("DICOMSERVER")); + QStringList keys = settings.allKeys(); + for(int i =0; i < keys.size(); i++) + { + QString val = keys.at(i); + if (val.contains("nickname")) + list.push_back(settings.value(val).toString()); + } + return list; +} + +std::map getDicomServer(QString nickname) +{ + std::map< std::string, std::string >results; + QSettings settings(getVVSettingsPath(), getSettingsOptionFormat()); + settings.beginGroup(QString::fromStdString("DICOMSERVER")); + settings.beginReadArray(nickname); + QStringList keys = settings.childKeys(); + for (int i = 0; i getDicomServer(QString nickname); #endif -- 2.46.1