ctkDICOMIndexer.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 __ctkDICOMIndexer_h
  15. #define __ctkDICOMIndexer_h
  16. // Qt includes
  17. #include <QObject>
  18. #include <QSqlDatabase>
  19. #include "ctkDICOMCoreExport.h"
  20. #include "ctkDICOMDatabase.h"
  21. class ctkDICOMIndexerPrivate;
  22. class ctkDICOMAbstractThumbnailGenerator;
  23. /**
  24. \brief Indexes DICOM images located in local directory into an Sql database
  25. */
  26. class CTK_DICOM_CORE_EXPORT ctkDICOMIndexer : public QObject
  27. {
  28. Q_OBJECT
  29. public:
  30. explicit ctkDICOMIndexer(QObject *parent = 0);
  31. virtual ~ctkDICOMIndexer();
  32. /**
  33. \brief Adds directory to database and optionally copies files to
  34. destinationDirectory.
  35. Scan the directory using Dcmtk and populate the database with all the
  36. DICOM images accordingly.
  37. */
  38. Q_INVOKABLE void addDirectory(ctkDICOMDatabase& database, const QString& directoryName,
  39. const QString& destinationDirectoryName = "",
  40. bool createHierarchy = true, bool createThumbnails = true);
  41. /**
  42. \brief Adds a file to database and optionally copies the file to
  43. destinationDirectory.
  44. Scan the file using Dcmtk and populate the database with all the
  45. DICOM fields accordingly.
  46. */
  47. Q_INVOKABLE void addFile(ctkDICOMDatabase& database, const QString& filePath,
  48. const QString& destinationDirectoryName = "",
  49. bool createHierarchy = true, bool createThumbnails = true);
  50. Q_INVOKABLE void refreshDatabase(ctkDICOMDatabase& database, const QString& directoryName);
  51. /**
  52. \brief runs a query and prints debug output of status
  53. */
  54. bool loggedExec(QSqlQuery& query);
  55. bool loggedExec(QSqlQuery& query, const QString& queryString);
  56. ///
  57. /// set thumbnail generator object
  58. void setThumbnailGenerator(ctkDICOMAbstractThumbnailGenerator* generator);
  59. ///
  60. /// get thumbnail genrator object
  61. ctkDICOMAbstractThumbnailGenerator* thumbnailGenerator();
  62. signals:
  63. void foundFilesToIndex(int);
  64. void indexingFileNumber(int);
  65. void indexingFilePath(QString);
  66. protected:
  67. QScopedPointer<ctkDICOMIndexerPrivate> d_ptr;
  68. private:
  69. Q_DECLARE_PRIVATE(ctkDICOMIndexer);
  70. Q_DISABLE_COPY(ctkDICOMIndexer);
  71. };
  72. #endif