ctkDICOMBrowser.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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(QString databaseDirectory READ databaseDirectory WRITE setDatabaseDirectory)
  49. Q_PROPERTY(int patientsAddedDuringImport READ patientsAddedDuringImport)
  50. Q_PROPERTY(int studiesAddedDuringImport READ studiesAddedDuringImport)
  51. Q_PROPERTY(int seriesAddedDuringImport READ seriesAddedDuringImport)
  52. Q_PROPERTY(int instancesAddedDuringImport READ instancesAddedDuringImport)
  53. Q_PROPERTY(QStringList tagsToPrecache READ tagsToPrecache WRITE setTagsToPrecache)
  54. Q_PROPERTY(bool displayImportSummary READ displayImportSummary WRITE setDisplayImportSummary)
  55. Q_PROPERTY(ctkDICOMBrowser::ImportDirectoryMode ImportDirectoryMode READ importDirectoryMode WRITE setImportDirectoryMode)
  56. public:
  57. typedef ctkDICOMBrowser Self;
  58. typedef QWidget Superclass;
  59. explicit ctkDICOMBrowser(QWidget* parent=0);
  60. virtual ~ctkDICOMBrowser();
  61. /// Directory being used to store the dicom database
  62. QString databaseDirectory() const;
  63. /// Return settings key used to store the directory.
  64. Q_INVOKABLE static QString databaseDirectorySettingsKey();
  65. /// See ctkDICOMDatabase for description - these accessors
  66. /// delegate to the corresponding routines of the internal
  67. /// instance of the database.
  68. /// @see ctkDICOMDatabase
  69. void setTagsToPrecache(const QStringList tags);
  70. const QStringList tagsToPrecache();
  71. /// Updates schema of loaded database to match the one
  72. /// coded by the current version of ctkDICOMDatabase.
  73. /// Also provides a dialog box for progress
  74. Q_INVOKABLE void updateDatabaseSchemaIfNeeded();
  75. Q_INVOKABLE ctkDICOMDatabase* database();
  76. Q_INVOKABLE ctkDICOMTableManager* dicomTableManager();
  77. /// Option to show or not import summary dialog.
  78. /// Since the summary dialog is modal, we give the option
  79. /// of disabling it for batch modes or testing.
  80. void setDisplayImportSummary(bool);
  81. bool displayImportSummary();
  82. /// Accessors to status of last directory import operation
  83. int patientsAddedDuringImport();
  84. int studiesAddedDuringImport();
  85. int seriesAddedDuringImport();
  86. int instancesAddedDuringImport();
  87. enum ImportDirectoryMode
  88. {
  89. ImportDirectoryCopy = 0,
  90. ImportDirectoryAddLink
  91. };
  92. /// \brief Get value of ImportDirectoryMode settings.
  93. ///
  94. /// \sa setImportDirectoryMode(ctkDICOMBrowser::ImportDirectoryMode)
  95. ctkDICOMBrowser::ImportDirectoryMode importDirectoryMode()const;
  96. /// \brief Return instance of import dialog.
  97. ///
  98. /// \internal
  99. Q_INVOKABLE ctkFileDialog* importDialog()const;
  100. public Q_SLOTS:
  101. /// \brief Set value of ImportDirectoryMode settings.
  102. ///
  103. /// Setting the value will update the comboBox found at the bottom
  104. /// of the import dialog.
  105. ///
  106. /// \sa importDirectoryMode()
  107. void setImportDirectoryMode(ctkDICOMBrowser::ImportDirectoryMode mode);
  108. void setDatabaseDirectory(const QString& directory);
  109. void onFileIndexed(const QString& filePath);
  110. /// \brief Pop-up file dialog allowing to select and import one or multiple
  111. /// DICOM directories.
  112. ///
  113. /// The dialog is extented with two additional controls:
  114. ///
  115. /// * **ImportDirectoryMode** combox: Allow user to select "Add Link" or "Copy" mode.
  116. /// Associated settings is stored using key `DICOM/ImportDirectoryMode`.
  117. void openImportDialog();
  118. void openExportDialog();
  119. void openQueryDialog();
  120. void onRemoveAction();
  121. void onRepairAction();
  122. void onTablesDensityComboBox(QString);
  123. /// \brief Import directories
  124. ///
  125. /// This can be used to externally trigger an import (i.e. for testing or to support drag-and-drop)
  126. ///
  127. /// By default, \a mode is ImportDirectoryMode::ImportDirectoryAddLink is set.
  128. ///
  129. /// \sa importDirectory(QString directory, int mode)
  130. void importDirectories(QStringList directories, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  131. /// \brief Import a directory
  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::ImportDirectoryAddLink is set.
  136. void importDirectory(QString directory, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  137. /// \deprecated importDirectory() should be used
  138. void onImportDirectory(QString directory, ctkDICOMBrowser::ImportDirectoryMode mode = ImportDirectoryAddLink);
  139. /// slots to capture status updates from the database during an
  140. /// import operation
  141. void onPatientAdded(int, QString, QString, QString);
  142. void onStudyAdded(QString);
  143. void onSeriesAdded(QString);
  144. void onInstanceAdded(QString);
  145. Q_SIGNALS:
  146. /// Emited when directory is changed
  147. void databaseDirectoryChanged(const QString&);
  148. /// Emited when query/retrieve operation has happened
  149. void queryRetrieveFinished();
  150. /// Emited when the directory import operation has completed
  151. void directoryImported();
  152. protected:
  153. QScopedPointer<ctkDICOMBrowserPrivate> d_ptr;
  154. /// Confirm with the user that they wish to delete the selected uids.
  155. /// Add information about the selected UIDs to a message box, checks
  156. /// for patient name, series description, study description, if all
  157. /// empty, uses the UID.
  158. /// Returns true if the user confirms the delete, false otherwise.
  159. /// Remembers if the user doesn't want to show the confirmation again.
  160. bool confirmDeleteSelectedUIDs(QStringList uids);
  161. protected Q_SLOTS:
  162. /// \brief Import directories
  163. ///
  164. /// This is used when user selected one or multiple
  165. /// directories from the Import Dialog.
  166. ///
  167. /// \sa importDirectories(QString directory, int mode)
  168. void onImportDirectoriesSelected(QStringList directories);
  169. void onImportDirectoryComboBoxCurrentIndexChanged(int index);
  170. void onModelSelected(const QItemSelection&, const QItemSelection&);
  171. /// Called when a right mouse click is made in the patients table
  172. void onPatientsRightClicked(const QPoint &point);
  173. /// Called when a right mouse click is made in the studies table
  174. void onStudiesRightClicked(const QPoint &point);
  175. /// Called when a right mouse click is made in the series table
  176. void onSeriesRightClicked(const QPoint &point);
  177. /// Called to export the series associated with the selected UIDs
  178. /// \sa exportSelectedStudies, exportSelectedPatients
  179. void exportSelectedSeries(QString dirPath, QStringList uids);
  180. /// Called to export the studies associated with the selected UIDs
  181. /// \sa exportSelectedSeries, exportSelectedPatients
  182. void exportSelectedStudies(QString dirPath, QStringList uids);
  183. /// Called to export the patients associated with the selected UIDs
  184. /// \sa exportSelectedStudies, exportSelectedSeries
  185. void exportSelectedPatients(QString dirPath, QStringList uids);
  186. /// To be called when dialog finishes
  187. void onQueryRetrieveFinished();
  188. private:
  189. Q_DECLARE_PRIVATE(ctkDICOMBrowser);
  190. Q_DISABLE_COPY(ctkDICOMBrowser);
  191. };
  192. Q_DECLARE_METATYPE(ctkDICOMBrowser::ImportDirectoryMode)
  193. #endif