ctkDICOMBrowser.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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 ctkThumbnailLabel;
  22. class QMenu;
  23. class QModelIndex;
  24. class ctkDICOMDatabase;
  25. class ctkDICOMTableManager;
  26. /// \ingroup DICOM_Widgets
  27. ///
  28. /// \brief The DICOM browser widget provides an interface to organize DICOM
  29. /// data stored in a local ctkDICOMDatabase.
  30. ///
  31. /// Using a local database avoids redundant calculations and speed up subsequent
  32. /// access.
  33. ///
  34. /// Supported operations are:
  35. ///
  36. /// * Import
  37. /// * Export
  38. /// * Send
  39. /// * Query
  40. /// * Remove
  41. /// * Repair
  42. ///
  43. class CTK_DICOM_WIDGETS_EXPORT ctkDICOMBrowser : public QWidget
  44. {
  45. Q_OBJECT
  46. Q_ENUMS(ImportDirectoryMode)
  47. Q_PROPERTY(ctkDICOMDatabase* database READ database)
  48. Q_PROPERTY(QString databaseDirectory READ databaseDirectory WRITE setDatabaseDirectory)
  49. Q_PROPERTY(QStringList tagsToPrecache READ tagsToPrecache WRITE setTagsToPrecache)
  50. Q_PROPERTY(bool displayImportSummary READ displayImportSummary WRITE setDisplayImportSummary)
  51. Q_PROPERTY(ctkDICOMTableManager* dicomTableManager READ dicomTableManager)
  52. Q_PROPERTY(ctkDICOMBrowser::ImportDirectoryMode ImportDirectoryMode READ importDirectoryMode WRITE setImportDirectoryMode)
  53. Q_PROPERTY(bool SkipConfirmImportDirectory READ skipConfirmImportDirectory WRITE setSkipConfirmImportDirectory)
  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 Get SkipConfirmImportDirectory.
  95. ///
  96. /// \sa setSkipConfirmImportDirectory(bool)
  97. bool skipConfirmImportDirectory()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. /// \brief Set SkipConfirmImportDirectory.
  107. ///
  108. /// Setting the value will update the checkbox found at the bottom
  109. /// of the import dialog.
  110. ///
  111. /// \sa skipConfirmImportDirectory()
  112. void setSkipConfirmImportDirectory(bool value);
  113. void setDatabaseDirectory(const QString& directory);
  114. void onFileIndexed(const QString& filePath);
  115. /// \brief Pop-up file dialog allowing to select and import one or multiple
  116. /// DICOM directories.
  117. ///
  118. /// The dialog is extented with two additional controls:
  119. ///
  120. /// * **ImportDirectoryMode** combox: Allow user to select "Add Link" or "Copy" mode.
  121. /// Associated settings is stored using key `DICOM/ImportDirectoryMode`.
  122. ///
  123. /// * **ConfirmImportDirectory** checkbox: Allow user to skip import directory confirmation dialog.
  124. /// Associated settings is stored using key `DICOM/DontConfirmImportDirectory`.
  125. void openImportDialog();
  126. void openExportDialog();
  127. void openQueryDialog();
  128. void onRemoveAction();
  129. void onRepairAction();
  130. void onTablesDensityComboBox(QString);
  131. /// \brief Import directories
  132. ///
  133. /// This can be used to externally trigger an import (i.e. for testing or to support drag-and-drop)
  134. ///
  135. /// By default, \a mode is ImportDirectoryMode::ImportDirectoryCopy and \a confirm is true.
  136. ///
  137. /// Setting \a confirm to false will skip the confirmation dialog.
  138. ///
  139. /// \sa onImportDirectory(QString directory, int mode)
  140. void onImportDirectories(QStringList directories, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink, bool confirm = true);
  141. /// \brief Import a directory
  142. ///
  143. /// This can be used to externally trigger an import (i.e. for testing or to support drag-and-drop)
  144. ///
  145. /// By default, \a mode is ImportDirectoryMode::ImportDirectoryCopy and \a confirm is true.
  146. ///
  147. /// Setting \a confirm to false will skip the confirmation dialog.
  148. void onImportDirectory(QString directory, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink, bool confirm = true);
  149. /// slots to capture status updates from the database during an
  150. /// import operation
  151. void onPatientAdded(int, QString, QString, QString);
  152. void onStudyAdded(QString);
  153. void onSeriesAdded(QString);
  154. void onInstanceAdded(QString);
  155. Q_SIGNALS:
  156. /// Emited when directory is changed
  157. void databaseDirectoryChanged(const QString&);
  158. /// Emited when query/retrieve operation has happened
  159. void queryRetrieveFinished();
  160. /// Emited when the directory import operation has completed
  161. void directoryImported();
  162. protected:
  163. QScopedPointer<ctkDICOMBrowserPrivate> d_ptr;
  164. /// Confirm with the user that they wish to delete the selected uids.
  165. /// Add information about the selected UIDs to a message box, checks
  166. /// for patient name, series description, study description, if all
  167. /// empty, uses the UID.
  168. /// Returns true if the user confirms the delete, false otherwise.
  169. /// Remembers if the user doesn't want to show the confirmation again.
  170. bool confirmDeleteSelectedUIDs(QStringList uids);
  171. protected Q_SLOTS:
  172. /// \brief Import directories
  173. ///
  174. /// This is used when user selected one or multiple
  175. /// directories from the Import Dialog.
  176. ///
  177. /// \sa onImportDirectories(QString directory, int mode)
  178. void onImportDirectoriesSelected(QStringList directories);
  179. void onImportDirectoryComboBoxCurrentIndexChanged(int index);
  180. void onModelSelected(const QItemSelection&, const QItemSelection&);
  181. /// Called when a right mouse click is made in the patients table
  182. void onPatientsRightClicked(const QPoint &point);
  183. /// Called when a right mouse click is made in the studies table
  184. void onStudiesRightClicked(const QPoint &point);
  185. /// Called when a right mouse click is made in the series table
  186. void onSeriesRightClicked(const QPoint &point);
  187. /// Called to export the series associated with the selected UIDs
  188. /// \sa exportSelectedStudies, exportSelectedPatients
  189. void exportSelectedSeries(QString dirPath, QStringList uids);
  190. /// Called to export the studies associated with the selected UIDs
  191. /// \sa exportSelectedSeries, exportSelectedPatients
  192. void exportSelectedStudies(QString dirPath, QStringList uids);
  193. /// Called to export the patients associated with the selected UIDs
  194. /// \sa exportSelectedStudies, exportSelectedSeries
  195. void exportSelectedPatients(QString dirPath, QStringList uids);
  196. /// To be called when dialog finishes
  197. void onQueryRetrieveFinished();
  198. private:
  199. Q_DECLARE_PRIVATE(ctkDICOMBrowser);
  200. Q_DISABLE_COPY(ctkDICOMBrowser);
  201. };
  202. Q_DECLARE_METATYPE(ctkDICOMBrowser::ImportDirectoryMode)
  203. #endif