ctkDICOMBrowser.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef __ctkDICOMBrowser_h
  15. #define __ctkDICOMBrowser_h
  16. // Qt includes
  17. #include <QItemSelection>
  18. #include <QWidget>
  19. #include "ctkDICOMWidgetsExport.h"
  20. class ctkDICOMBrowserPrivate;
  21. class ctkDICOMDatabase;
  22. class ctkDICOMTableManager;
  23. class ctkFileDialog;
  24. class ctkThumbnailLabel;
  25. class QMenu;
  26. class QModelIndex;
  27. /// \ingroup DICOM_Widgets
  28. ///
  29. /// \brief The DICOM browser widget provides an interface to organize DICOM
  30. /// data stored in a local ctkDICOMDatabase.
  31. ///
  32. /// Using a local database avoids redundant calculations and speed up subsequent
  33. /// access.
  34. ///
  35. /// Supported operations are:
  36. ///
  37. /// * Import
  38. /// * Export
  39. /// * Send
  40. /// * Query
  41. /// * Remove
  42. /// * Repair
  43. ///
  44. class CTK_DICOM_WIDGETS_EXPORT ctkDICOMBrowser : public QWidget
  45. {
  46. Q_OBJECT
  47. Q_ENUMS(ImportDirectoryMode)
  48. Q_PROPERTY(ctkDICOMDatabase* database READ database)
  49. Q_PROPERTY(QString databaseDirectory READ databaseDirectory WRITE setDatabaseDirectory)
  50. Q_PROPERTY(QStringList tagsToPrecache READ tagsToPrecache WRITE setTagsToPrecache)
  51. Q_PROPERTY(bool displayImportSummary READ displayImportSummary WRITE setDisplayImportSummary)
  52. Q_PROPERTY(ctkDICOMTableManager* dicomTableManager READ dicomTableManager)
  53. Q_PROPERTY(ctkDICOMBrowser::ImportDirectoryMode ImportDirectoryMode READ importDirectoryMode WRITE setImportDirectoryMode)
  54. public:
  55. typedef ctkDICOMBrowser Self;
  56. typedef QWidget Superclass;
  57. explicit ctkDICOMBrowser(QWidget* parent=0);
  58. virtual ~ctkDICOMBrowser();
  59. /// Directory being used to store the dicom database
  60. QString databaseDirectory() const;
  61. /// Return settings key used to store the directory.
  62. static QString databaseDirectorySettingsKey();
  63. /// See ctkDICOMDatabase for description - these accessors
  64. /// delegate to the corresponding routines of the internal
  65. /// instance of the database.
  66. /// @see ctkDICOMDatabase
  67. void setTagsToPrecache(const QStringList tags);
  68. const QStringList tagsToPrecache();
  69. /// Updates schema of loaded database to match the one
  70. /// coded by the current version of ctkDICOMDatabase.
  71. /// Also provides a dialog box for progress
  72. void updateDatabaseSchemaIfNeeded();
  73. ctkDICOMDatabase* database();
  74. ctkDICOMTableManager* dicomTableManager();
  75. /// Option to show or not import summary dialog.
  76. /// Since the summary dialog is modal, we give the option
  77. /// of disabling it for batch modes or testing.
  78. void setDisplayImportSummary(bool);
  79. bool displayImportSummary();
  80. /// Accessors to status of last directory import operation
  81. int patientsAddedDuringImport();
  82. int studiesAddedDuringImport();
  83. int seriesAddedDuringImport();
  84. int instancesAddedDuringImport();
  85. enum ImportDirectoryMode
  86. {
  87. ImportDirectoryCopy = 0,
  88. ImportDirectoryAddLink
  89. };
  90. /// \brief Get value of ImportDirectoryMode settings.
  91. ///
  92. /// \sa setImportDirectoryMode(ctkDICOMBrowser::ImportDirectoryMode)
  93. ctkDICOMBrowser::ImportDirectoryMode importDirectoryMode()const;
  94. /// \brief Return instance of import dialog.
  95. ///
  96. /// \internal
  97. Q_INVOKABLE ctkFileDialog* importDialog()const;
  98. public Q_SLOTS:
  99. /// \brief Set value of ImportDirectoryMode settings.
  100. ///
  101. /// Setting the value will update the comboBox found at the bottom
  102. /// of the import dialog.
  103. ///
  104. /// \sa importDirectoryMode()
  105. void setImportDirectoryMode(ctkDICOMBrowser::ImportDirectoryMode mode);
  106. void setDatabaseDirectory(const QString& directory);
  107. void onFileIndexed(const QString& filePath);
  108. /// \brief Pop-up file dialog allowing to select and import one or multiple
  109. /// DICOM directories.
  110. ///
  111. /// The dialog is extented with two additional controls:
  112. ///
  113. /// * **ImportDirectoryMode** combox: Allow user to select "Add Link" or "Copy" mode.
  114. /// Associated settings is stored using key `DICOM/ImportDirectoryMode`.
  115. void openImportDialog();
  116. void openExportDialog();
  117. void openQueryDialog();
  118. void onRemoveAction();
  119. void onRepairAction();
  120. void onTablesDensityComboBox(QString);
  121. /// \brief Import directories
  122. ///
  123. /// This can be used to externally trigger an import (i.e. for testing or to support drag-and-drop)
  124. ///
  125. /// By default, \a mode is ImportDirectoryMode::ImportDirectoryAddLink is set.
  126. ///
  127. /// \sa importDirectory(QString directory, int mode)
  128. void importDirectories(QStringList directories, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  129. /// \brief Import a directory
  130. ///
  131. /// This can be used to externally trigger an import (i.e. for testing or to support drag-and-drop)
  132. ///
  133. /// By default, \a mode is ImportDirectoryMode::ImportDirectoryAddLink is set.
  134. void importDirectory(QString directory, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  135. /// \deprecated importDirectory() should be used
  136. void onImportDirectory(QString directory, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  137. /// slots to capture status updates from the database during an
  138. /// import operation
  139. void onPatientAdded(int, QString, QString, QString);
  140. void onStudyAdded(QString);
  141. void onSeriesAdded(QString);
  142. void onInstanceAdded(QString);
  143. Q_SIGNALS:
  144. /// Emited when directory is changed
  145. void databaseDirectoryChanged(const QString&);
  146. /// Emited when query/retrieve operation has happened
  147. void queryRetrieveFinished();
  148. /// Emited when the directory import operation has completed
  149. void directoryImported();
  150. protected:
  151. QScopedPointer<ctkDICOMBrowserPrivate> d_ptr;
  152. /// Confirm with the user that they wish to delete the selected uids.
  153. /// Add information about the selected UIDs to a message box, checks
  154. /// for patient name, series description, study description, if all
  155. /// empty, uses the UID.
  156. /// Returns true if the user confirms the delete, false otherwise.
  157. /// Remembers if the user doesn't want to show the confirmation again.
  158. bool confirmDeleteSelectedUIDs(QStringList uids);
  159. protected Q_SLOTS:
  160. /// \brief Import directories
  161. ///
  162. /// This is used when user selected one or multiple
  163. /// directories from the Import Dialog.
  164. ///
  165. /// \sa importDirectories(QString directory, int mode)
  166. void onImportDirectoriesSelected(QStringList directories);
  167. void onImportDirectoryComboBoxCurrentIndexChanged(int index);
  168. void onModelSelected(const QItemSelection&, const QItemSelection&);
  169. /// Called when a right mouse click is made in the patients table
  170. void onPatientsRightClicked(const QPoint &point);
  171. /// Called when a right mouse click is made in the studies table
  172. void onStudiesRightClicked(const QPoint &point);
  173. /// Called when a right mouse click is made in the series table
  174. void onSeriesRightClicked(const QPoint &point);
  175. /// Called to export the series associated with the selected UIDs
  176. /// \sa exportSelectedStudies, exportSelectedPatients
  177. void exportSelectedSeries(QString dirPath, QStringList uids);
  178. /// Called to export the studies associated with the selected UIDs
  179. /// \sa exportSelectedSeries, exportSelectedPatients
  180. void exportSelectedStudies(QString dirPath, QStringList uids);
  181. /// Called to export the patients associated with the selected UIDs
  182. /// \sa exportSelectedStudies, exportSelectedSeries
  183. void exportSelectedPatients(QString dirPath, QStringList uids);
  184. /// To be called when dialog finishes
  185. void onQueryRetrieveFinished();
  186. private:
  187. Q_DECLARE_PRIVATE(ctkDICOMBrowser);
  188. Q_DISABLE_COPY(ctkDICOMBrowser);
  189. };
  190. Q_DECLARE_METATYPE(ctkDICOMBrowser::ImportDirectoryMode)
  191. #endif