forked from commontk/CTK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: add ability to delete individual series, studies, patients
Add to the browser Remove button the information that it will delete all selected series, studies, patients. Add support for right click custom context menus in the patient, study, series tables. Translate the local points to global ones in terms of the table view and signal right clicked with the global position so that the browser can position the context menu appropriately. Add the context menu to the DICOM browser to allow deleting at just one level, with number of items selected information, and a confirmation message box with descriptive information that can be set to not be shown again. Added a test for the DICOM browser, with the ability to open it in interactive mode to test the right clicks. Add query wrappers for the DICOM database to get the patient name as well as descriptions for series and study. They will return empty strings on failure. Use the new queries to give more meaningful information on the right click pop up menu in the DICOM browser. Added a test for the new DICOM database accessors. Slicer bug: http://www.na-mic.org/Bug/view.php?id=3792 When Slicer makes a custom DICOM browser, it moves the table views directly into the new window, extracting them from the DICOM table. With this change, the table view takes care of mapping the point to global, the table manager propagates the signal as a table specific XRightClicked signal, and the browser responds to it with a table specific context menu. Slicer Issue #3792
- Loading branch information
Nicole Aucoin
committed
Sep 15, 2015
1 parent
0f2e0be
commit ea653d2
Showing
13 changed files
with
561 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
/*========================================================================= | ||
Library: CTK | ||
Copyright (c) Kitware Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
// Qt includes | ||
#include <QCoreApplication> | ||
#include <QDir> | ||
|
||
// ctkDICOMCore includes | ||
#include "ctkDICOMDatabase.h" | ||
|
||
// STD includes | ||
#include <iostream> | ||
#include <cstdlib> | ||
|
||
|
||
int ctkDICOMDatabaseTest6( int argc, char * argv [] ) | ||
{ | ||
QCoreApplication app(argc, argv); | ||
|
||
if (argc < 2) | ||
{ | ||
std::cerr << "ctkDICOMDatabaseTest6: missing dicom filePath argument"; | ||
std::cerr << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
QString dicomFilePath(argv[1]); | ||
|
||
ctkDICOMDatabase database; | ||
QDir databaseDirectory = QDir::temp(); | ||
databaseDirectory.remove("ctkDICOMDatabase.sql"); | ||
databaseDirectory.remove("ctkDICOMTagCache.sql"); | ||
|
||
QFileInfo databaseFile(databaseDirectory, QString("database.test")); | ||
database.openDatabase(databaseFile.absoluteFilePath()); | ||
|
||
bool res = database.initializeDatabase(); | ||
|
||
if (!res) | ||
{ | ||
std::cerr << "ctkDICOMDatabase::initializeDatabase() failed." << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// | ||
// Basic test: | ||
// - insert the file specified on the command line | ||
// - ask for name and descriptions and compare to known results | ||
// | ||
QString instanceUID("1.2.840.113619.2.135.3596.6358736.4843.1115808177.83"); | ||
|
||
|
||
// | ||
// Test the pre load values feature of the database | ||
// | ||
|
||
QString preInsertDescription = database.descriptionForSeries(instanceUID); | ||
if (!preInsertDescription.isEmpty()) | ||
{ | ||
std::cerr | ||
<< "ctkDICOMDatabase: db should return empty string for unknown " | ||
<< " instance series description, instead got: " | ||
<< preInsertDescription.toStdString() << std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
database.insert(dicomFilePath, false, false); | ||
|
||
QString filePath = database.fileForInstance(instanceUID); | ||
std::cerr << "Instance file " << filePath.toStdString() << std::endl; | ||
|
||
// check for descriptions | ||
QHash<QString,QString> descriptions (database.descriptionsForFile(filePath)); | ||
std::cout << "\tPatient Name: " | ||
<< descriptions["PatientsName"].toStdString() | ||
<< "\n\tStudy Desciption: " | ||
<< descriptions["StudyDescription"].toStdString() | ||
<< "\n\tSeries Desciption: " | ||
<< descriptions["SeriesDescription"].toStdString() | ||
<< std::endl; | ||
|
||
// check for known series description | ||
QString knownSeriesDescription("3D Cor T1 FAST IR-prepped GRE"); | ||
|
||
QString seriesUID = database.seriesForFile(filePath); | ||
QString seriesDescription = database.descriptionForSeries(seriesUID); | ||
|
||
if (seriesDescription != knownSeriesDescription) | ||
{ | ||
std::cerr << "ctkDICOMDatabase: database should return series description of '" | ||
<< knownSeriesDescription.toStdString() | ||
<< "', instead returned '" << seriesDescription.toStdString() | ||
<< "'\n\tinstanceUID = " | ||
<< instanceUID.toStdString() | ||
<< "\n\tseriesUID = " | ||
<< seriesUID.toStdString() | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// get the study and patient uids | ||
QString patientUID, studyUID; | ||
studyUID = database.studyForSeries(seriesUID); | ||
patientUID = database.patientForStudy(studyUID); | ||
|
||
// check for empty study description | ||
QString studyDescription = database.descriptionForStudy(studyUID); | ||
|
||
if (!studyDescription.isEmpty()) | ||
{ | ||
std::cerr << "ctkDICOMDatabase: database should return empty study" | ||
<< " description for studyUID of " | ||
<< studyUID.toStdString() << ", instead returned '" | ||
<< studyDescription.toStdString() << "'" | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
// check for known patient name | ||
QString knownPatientName("Facial Expression"); | ||
QString patientName = database.nameForPatient(patientUID); | ||
if (patientName != knownPatientName) | ||
{ | ||
std::cerr << "ctkDICOMDatabase: database should return known patient name '" | ||
<< knownPatientName.toStdString() | ||
<< "' for patient UID of " | ||
<< patientUID.toStdString() << ", instead returned '" | ||
<< patientName.toStdString() << "'" | ||
<< std::endl; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
database.closeDatabase(); | ||
|
||
std::cerr << "Database is in " << databaseDirectory.path().toStdString() << std::endl; | ||
|
||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/*========================================================================= | ||
Library: CTK | ||
Copyright (c) Kitware Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0.txt | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
=========================================================================*/ | ||
|
||
// Qt includes | ||
#include <QApplication> | ||
#include <QDir> | ||
#include <QTimer> | ||
|
||
// ctk includes | ||
#include "ctkUtils.h" | ||
|
||
// ctkDICOMCore includes | ||
#include "ctkDICOMDatabase.h" | ||
|
||
// ctkDICOMWidget includes | ||
#include "ctkDICOMBrowser.h" | ||
|
||
// STD includes | ||
#include <iostream> | ||
|
||
int ctkDICOMBrowserTest1( int argc, char * argv [] ) | ||
{ | ||
QApplication app(argc, argv); | ||
|
||
qDebug() << "argc = " << argc; | ||
for (int i = 0; i < argc; ++i) | ||
{ | ||
qDebug() << "\t" << argv[i]; | ||
} | ||
|
||
QFileInfo tempFileInfo(QDir::tempPath() + QString("/ctkDICOMBrowserTest1-db")); | ||
QString dbDir = tempFileInfo.absoluteFilePath(); | ||
qDebug() << "\n\nUsing directory: " << dbDir; | ||
if (tempFileInfo.exists()) | ||
{ | ||
qDebug() << "\n\nRemoving directory: " << dbDir; | ||
ctk::removeDirRecursively(dbDir); | ||
} | ||
qDebug() << "\n\nMaking directory: " << dbDir; | ||
QDir dir(dbDir); | ||
dir.mkdir(dbDir); | ||
|
||
ctkDICOMBrowser browser; | ||
browser.setDatabaseDirectory(dbDir); | ||
|
||
browser.show(); | ||
|
||
browser.setDisplayImportSummary(false); | ||
qDebug() << "Importing directory " << argv[1]; | ||
|
||
// make sure copy/link dialog doesn't pop up, always copy on import | ||
QSettings settings; | ||
QString settingsString = settings.value("MainWindow/DontConfirmCopyOnImport").toString(); | ||
settings.setValue("MainWindow/DontConfirmCopyOnImport", QString("0")); | ||
|
||
browser.onImportDirectory(argv[1]); | ||
|
||
// reset to the original copy/import setting | ||
settings.setValue("MainWindow/DontConfirmCopyOnImport", settingsString); | ||
|
||
if (browser.patientsAddedDuringImport() != 1 | ||
|| browser.studiesAddedDuringImport() != 1 | ||
|| browser.seriesAddedDuringImport() != 1 | ||
|| browser.instancesAddedDuringImport() != 100) | ||
{ | ||
qDebug() << "\n\nDirectory did not import as expected!\n\n"; | ||
return EXIT_FAILURE; | ||
} | ||
|
||
qDebug() << "\n\nAdded to database directory: " << dbDir; | ||
|
||
if (argc <= 2 || QString(argv[argc - 1]) != "-I") | ||
{ | ||
QTimer::singleShot(200, &app, SLOT(quit())); | ||
} | ||
|
||
|
||
|
||
return app.exec(); | ||
} |
Oops, something went wrong.