ctkDICOMDatabase.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010
  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.commontk.org/LICENSE
  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 __ctkDICOMDatabase_h
  15. #define __ctkDICOMDatabase_h
  16. // Qt includes
  17. #include <QObject>
  18. #include <QStringList>
  19. #include <QSqlDatabase>
  20. #include "ctkDICOMCoreExport.h"
  21. class ctkDICOMDatabasePrivate;
  22. class DcmDataset;
  23. class ctkDICOMAbstractThumbnailGenerator;
  24. class CTK_DICOM_CORE_EXPORT ctkDICOMDatabase : public QObject
  25. {
  26. Q_OBJECT
  27. public:
  28. explicit ctkDICOMDatabase(QObject *parent = 0);
  29. explicit ctkDICOMDatabase(QString databaseFile);
  30. virtual ~ctkDICOMDatabase();
  31. const QSqlDatabase& database() const;
  32. const QString lastError() const;
  33. const QString databaseFilename() const;
  34. const QString databaseDirectory() const;
  35. bool isInMemory() const;
  36. ///
  37. /// set thumbnail generator object
  38. void setThumbnailGenerator(ctkDICOMAbstractThumbnailGenerator* generator);
  39. ///
  40. /// get thumbnail genrator object
  41. ctkDICOMAbstractThumbnailGenerator* thumbnailGenerator();
  42. ///
  43. /// open the SQLite database in @param databaseFile . If the file does not
  44. /// exist, a new database is created and initialized with the
  45. /// default schema
  46. ///
  47. /// @param databaseFile TODO
  48. /// @param connectionName TODO
  49. Q_INVOKABLE virtual void openDatabase(const QString databaseFile, const QString& connectionName = "DICOM-DB" );
  50. ///
  51. /// close the database. It must not be used afterwards.
  52. Q_INVOKABLE void closeDatabase();
  53. ///
  54. /// delete all data and reinitialize the database.
  55. Q_INVOKABLE bool initializeDatabase(const char* schemaFile = ":/dicom/dicom-schema.sql");
  56. ///
  57. /// \brief database accessors
  58. Q_INVOKABLE QStringList studiesForPatient (QString patientUID);
  59. Q_INVOKABLE QStringList seriesForStudy (QString studyUID);
  60. Q_INVOKABLE QStringList filesForSeries (QString seriesUID);
  61. ///
  62. /// \brief load the header from a file and allow access to elements
  63. Q_INVOKABLE void loadInstanceHeader (QString sopInstanceUID);
  64. Q_INVOKABLE void loadFileHeader (QString fileName);
  65. Q_INVOKABLE QStringList headerKeys ();
  66. Q_INVOKABLE QString headerValue (QString key);
  67. /**
  68. * Will create an entry in the appropriate tables for this dataset.
  69. */
  70. // void insert ( DcmDataset* dataset, QString filename );
  71. /**
  72. * Insert into the database if not already exsting.
  73. */
  74. void insert ( DcmDataset *dataset, bool storeFile = true, bool generateThumbnail = true);
  75. /***
  76. * Helper method: get the path that should be used to store this image.
  77. */
  78. QString pathForDataset( DcmDataset *dataset);
  79. signals:
  80. void databaseChanged();
  81. protected:
  82. QScopedPointer<ctkDICOMDatabasePrivate> d_ptr;
  83. private:
  84. Q_DECLARE_PRIVATE(ctkDICOMDatabase);
  85. Q_DISABLE_COPY(ctkDICOMDatabase);
  86. };
  87. #endif