Skip to content

Commit

Permalink
ENH: Add results checks to the visual dicom browser
Browse files Browse the repository at this point in the history
  • Loading branch information
Punzo committed Oct 18, 2023
1 parent b1b9de9 commit 2650bc4
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Libs/DICOM/Core/ctkDICOMQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ ctkDICOMQueryPrivate::ctkDICOMQueryPrivate()
this->Canceled = false;
this->MaximumPatientsQuery = 2;

this->SCU.setACSETimeout(3);
this->SCU.setConnectionTimeout(3);
this->SCU.setACSETimeout(10);
this->SCU.setConnectionTimeout(10);
}

//------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion Libs/DICOM/Core/ctkDICOMQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CTK_DICOM_CORE_EXPORT ctkDICOMQuery : public QObject
/// 0 by default.
void setPort(int port);
int port() const;
/// connection timeout, default 3 sec.
/// connection timeout, default 10 sec.
void setConnectionTimeout(const int timeout);
int connectionTimeout() const;
/// maximum number of responses allowed in one query
Expand Down
25 changes: 15 additions & 10 deletions Libs/DICOM/Core/ctkDICOMTaskPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,21 +1160,22 @@ void ctkDICOMTaskPool::onTaskStarted()
if (queryTask)
{
logger.debug(d->loggerQueryReport(queryTask, "started"));
emit this->taskStarted("Query");
}

ctkDICOMRetrieveTask* retrieveTask = qobject_cast<ctkDICOMRetrieveTask*>(this->sender());
if (retrieveTask)
{
logger.debug(d->loggerRetrieveReport(retrieveTask, "started"));
emit this->taskStarted("Retrieve");
}

ctkDICOMStorageListenerTask* listenerTask = qobject_cast<ctkDICOMStorageListenerTask*>(this->sender());
if (listenerTask)
{
logger.debug(d->loggerListenerReport(listenerTask, "started"));
emit this->taskStarted("Listener");
}

emit this->taskStarted(task);
}

//----------------------------------------------------------------------------
Expand All @@ -1200,6 +1201,7 @@ void ctkDICOMTaskPool::onTaskFinished()
{
emit this->progressTaskDetail(nullptr);
}
emit this->taskFinished("Query");
}

ctkDICOMRetrieveTask* retrieveTask = qobject_cast<ctkDICOMRetrieveTask*>(this->sender());
Expand Down Expand Up @@ -1268,15 +1270,15 @@ void ctkDICOMTaskPool::onTaskFinished()
// no results from the retrieve
emit this->progressTaskDetail(nullptr);
}
emit this->taskFinished("Retrieve");
}

ctkDICOMStorageListenerTask* listenerTask = qobject_cast<ctkDICOMStorageListenerTask*>(this->sender());
if (listenerTask)
{
logger.debug(d->loggerListenerReport(listenerTask, "finished"));
emit this->taskFinished("Listener");
}

emit this->taskFinished(task);
}

//----------------------------------------------------------------------------
Expand All @@ -1294,6 +1296,7 @@ void ctkDICOMTaskPool::onTaskCanceled()
if (queryTask)
{
logger.debug(d->loggerQueryReport(queryTask, "canceled"));
emit this->taskCanceled("Query");

QString taskUID = queryTask->taskUID();
if (queryTask->numberOfRetry() < d->MaximumNumberOfRetry && !queryTask->isStopped())
Expand All @@ -1312,8 +1315,8 @@ void ctkDICOMTaskPool::onTaskCanceled()
}
else if (!queryTask->isStopped())
{
logger.debug(d->loggerQueryReport(queryTask, "failed"));
emit this->progressTaskDetail(nullptr);
logger.error(d->loggerQueryReport(queryTask, "failed"));
emit this->taskFailed("Query");
}

this->deleteTask(taskUID);
Expand All @@ -1323,6 +1326,7 @@ void ctkDICOMTaskPool::onTaskCanceled()
if (retrieveTask)
{
logger.debug(d->loggerRetrieveReport(retrieveTask, "canceled"));
emit this->taskCanceled("Retrieve");

QString taskUID = retrieveTask->taskUID();
if (retrieveTask->numberOfRetry() < d->MaximumNumberOfRetry && !retrieveTask->isStopped())
Expand All @@ -1341,7 +1345,8 @@ void ctkDICOMTaskPool::onTaskCanceled()
}
else if (!retrieveTask->isStopped())
{
logger.debug(d->loggerRetrieveReport(retrieveTask, "failed"));
logger.error(d->loggerRetrieveReport(retrieveTask, "failed"));
emit this->taskFailed("Retrieve");
}

this->deleteTask(taskUID);
Expand All @@ -1351,6 +1356,7 @@ void ctkDICOMTaskPool::onTaskCanceled()
if (listenerTask)
{
logger.debug(d->loggerListenerReport(listenerTask, "canceled"));
emit this->taskCanceled("Listener");

QString taskUID = listenerTask->taskUID();
if (listenerTask->numberOfRetry() < d->MaximumNumberOfRetry && !listenerTask->isStopped())
Expand All @@ -1367,13 +1373,12 @@ void ctkDICOMTaskPool::onTaskCanceled()
}
else if (!listenerTask->isStopped())
{
logger.debug(d->loggerListenerReport(listenerTask, "failed"));
logger.error(d->loggerListenerReport(listenerTask, "failed"));
emit this->taskFailed("Listener");
}

this->deleteTask(taskUID);
}

emit this->taskCanceled(task);
}

//----------------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions Libs/DICOM/Core/ctkDICOMTaskPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ class CTK_DICOM_CORE_EXPORT ctkDICOMTaskPool : public ctkAbstractTaskPool
Q_SIGNALS:
void progressTaskDetail(ctkDICOMTaskResults*);
void progressBarTaskDetail(ctkDICOMTaskResults*);
void taskStarted(ctkAbstractTask* task);
void taskFinished(ctkAbstractTask* task);
void taskCanceled(ctkAbstractTask* task);
void taskStarted(QString taskType);
void taskFinished(QString taskType);
void taskCanceled(QString taskType);
void taskFailed(QString taskType);

public Q_SLOTS:
void onTaskStarted();
Expand Down
2 changes: 1 addition & 1 deletion Libs/DICOM/Widgets/Resources/UI/Icons/query.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion Libs/DICOM/Widgets/Resources/UI/Icons/restore.svg

This file was deleted.

2 changes: 1 addition & 1 deletion Libs/DICOM/Widgets/Resources/UI/Icons/wait.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions Libs/DICOM/Widgets/Resources/UI/ctkDICOMWidget.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<file>Icons/import.svg</file>
<file>Icons/loaded.svg</file>
<file>Icons/patient.svg</file>
<file>Icons/query.svg</file>
<file>Icons/visible.svg</file>
<file>Icons/warning.svg</file>
<file>Icons/load.svg</file>
Expand All @@ -15,8 +14,8 @@
<file>Icons/more_vert.svg</file>
<file>Icons/add.svg</file>
<file>Icons/dns.svg</file>
<file>Icons/restore.svg</file>
<file>Icons/save.svg</file>
<file>Icons/query.svg</file>
<file>Icons/wait.svg</file>
</qresource>
</RCC>
12 changes: 6 additions & 6 deletions Libs/DICOM/Widgets/ctkDICOMServerNodeWidget2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ void ctkDICOMServerNodeWidget2Private::disconnectTaskPool()
return;
}

ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskStarted(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskStarted(QString)),
q, SLOT(updateGUIState()));
ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskFinished(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskFinished(QString)),
q, SLOT(updateGUIState()));
ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskCanceled(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::disconnect(this->TaskPool.data(), SIGNAL(taskCanceled(QString)),
q, SLOT(updateGUIState()));
}

Expand All @@ -316,11 +316,11 @@ void ctkDICOMServerNodeWidget2Private::connectTaskPool()
return;
}

ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskStarted(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskStarted(QString)),
q, SLOT(updateGUIState()));
ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskFinished(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskFinished(QString)),
q, SLOT(updateGUIState()));
ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskCanceled(ctkAbstractTask*)),
ctkDICOMServerNodeWidget2::connect(this->TaskPool.data(), SIGNAL(taskCanceled(QString)),
q, SLOT(updateGUIState()));
}

Expand Down
39 changes: 38 additions & 1 deletion Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ void ctkDICOMVisualBrowserWidgetPrivate::disconnectTaskPool()

ctkDICOMVisualBrowserWidget::disconnect(this->TaskPool.data(), SIGNAL(progressTaskDetail(ctkDICOMTaskResults*)),
q, SLOT(updateGUIFromTaskPool(ctkDICOMTaskResults*)));
ctkDICOMVisualBrowserWidget::disconnect(this->TaskPool.data(), SIGNAL(taskFailed(QString)),
q, SLOT(onTaskFailed(QString)));
ctkDICOMVisualBrowserWidget::disconnect(this->TaskPool->indexer(), SIGNAL(progress(int)), q, SLOT(onIndexingProgress(int)));
ctkDICOMVisualBrowserWidget::disconnect(this->TaskPool->indexer(), SIGNAL(progressStep(QString)),q, SLOT(onIndexingProgressStep(QString)));
ctkDICOMVisualBrowserWidget::disconnect(this->TaskPool->indexer(), SIGNAL(progressDetail(QString)), q, SLOT(onIndexingProgressDetail(QString)));
Expand All @@ -409,6 +411,8 @@ void ctkDICOMVisualBrowserWidgetPrivate::connectTaskPool()

ctkDICOMVisualBrowserWidget::connect(this->TaskPool.data(), SIGNAL(progressTaskDetail(ctkDICOMTaskResults*)),
q, SLOT(updateGUIFromTaskPool(ctkDICOMTaskResults*)));
ctkDICOMVisualBrowserWidget::connect(this->TaskPool.data(), SIGNAL(taskFailed(QString)),
q, SLOT(onTaskFailed(QString)));
ctkDICOMVisualBrowserWidget::connect(this->TaskPool->indexer(), SIGNAL(progress(int)), q, SLOT(onIndexingProgress(int)));
ctkDICOMVisualBrowserWidget::connect(this->TaskPool->indexer(), SIGNAL(progressStep(QString)),q, SLOT(onIndexingProgressStep(QString)));
ctkDICOMVisualBrowserWidget::connect(this->TaskPool->indexer(), SIGNAL(progressDetail(QString)), q, SLOT(onIndexingProgressDetail(QString)));
Expand Down Expand Up @@ -2192,10 +2196,40 @@ void ctkDICOMVisualBrowserWidget::updateGUIFromTaskPool(ctkDICOMTaskResults *tas
return;
}

if (taskResults->datasets().count() == 0)
{
QString infoString = tr("The query provided no results. Please refine your filters.");
ctkMessageBox infoMessageBox(this);
infoMessageBox.setText(infoString);
infoMessageBox.setIcon(QMessageBox::Information);
infoMessageBox.setDontShowAgainSettingsKey("VisualDICOMBrowser/DontConfirmInfoReport");
infoMessageBox.exec();
}

d->createPatients();
d->TaskPool->deleteTask(taskResults->taskUID());
}

//------------------------------------------------------------------------------
void ctkDICOMVisualBrowserWidget::onTaskFailed(QString taskType)
{
Q_D(ctkDICOMVisualBrowserWidget);
if (taskType == "Query")
{
d->updateFiltersWarnings();
d->ProgressFrame->hide();
d->QueryPatientPushButton->setIcon(QIcon(":/Icons/query.svg"));
}

QString warningString = tr("%1 task failed to fetch the data."
"\n\n For more information please open the error report console. \n").arg(taskType);
ctkMessageBox warningMessageBox(this);
warningMessageBox.setText(warningString);
warningMessageBox.setIcon(QMessageBox::Warning);
warningMessageBox.setDontShowAgainSettingsKey("VisualDICOMBrowser/DontConfirmWarningReport");
warningMessageBox.exec();
}

//------------------------------------------------------------------------------
void ctkDICOMVisualBrowserWidget::onPatientItemChanged(int index)
{
Expand Down Expand Up @@ -2754,6 +2788,9 @@ void ctkDICOMVisualBrowserWidget::onStop(bool stopPersistentTasks)

QApplication::setOverrideCursor(QCursor(Qt::BusyCursor));
d->TaskPool->stopAllTasks(stopPersistentTasks);
d->updateFiltersWarnings();
d->ProgressFrame->hide();
d->QueryPatientPushButton->setIcon(QIcon(":/Icons/query.svg"));
QApplication::restoreOverrideCursor();
}

Expand Down Expand Up @@ -2824,7 +2861,7 @@ bool ctkDICOMVisualBrowserWidget::confirmDeleteSelectedUIDs(QStringList uids)

confirmDeleteDialog.addButton(tr("Delete"), QMessageBox::AcceptRole);
confirmDeleteDialog.addButton(tr("Cancel"), QMessageBox::RejectRole);
confirmDeleteDialog.setDontShowAgainSettingsKey("MainWindow/DontConfirmDeleteSelected");
confirmDeleteDialog.setDontShowAgainSettingsKey("VisualDICOMBrowser/DontConfirmDeleteSelected");

int response = confirmDeleteDialog.exec();

Expand Down
1 change: 1 addition & 0 deletions Libs/DICOM/Widgets/ctkDICOMVisualBrowserWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public Q_SLOTS:
void onFilteringDateComboBoxChanged(int);
void onQueryPatient();
void updateGUIFromTaskPool(ctkDICOMTaskResults*);
void onTaskFailed(QString);
void onPatientItemChanged(int);
void onClose();
void onLoad();
Expand Down

0 comments on commit 2650bc4

Please sign in to comment.