CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
ctkDICOMItem.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Library: CTK
4 
5  Copyright (c) Mint Medical GmbH
6 
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0.txt
12 
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18 
19 =========================================================================*/
20 
21 #ifndef __ctkDICOMItem_h
22 #define __ctkDICOMItem_h
23 
24 #include "ctkDICOMCoreExport.h"
25 
26 #include "ctkDICOMPersonName.h"
27 
28 #include <dcmtk/dcmdata/dcdatset.h> // DCMTK DcmDataset
29 
30 #include <QtCore>
31 
32 class DcmDataDictionary;
33 
34 
35 class ctkDICOMItemPrivate;
36 
63 
65 
66 class CTK_DICOM_CORE_EXPORT ctkDICOMItem
67 {
68 public:
69  typedef QObject Superclass;
75  ctkDICOMItem(bool strictErrorHandling = false);
76  virtual ~ctkDICOMItem();
77 
83 
85  virtual void InitializeFromItem(DcmItem* dataset, bool takeOwnership = false);
86 
90  virtual void InitializeFromFile(const QString& filename,
91  const E_TransferSyntax readXfer = EXS_Unknown,
92  const E_GrpLenEncoding groupLength = EGL_noChange,
93  const Uint32 maxReadLength = DCM_MaxReadLength,
94  const E_FileReadMode readMode = ERM_autoDetect);
95 
96 
97 
101  bool SaveToFile(const QString& filePath) const;
102 
103 
109  void Serialize();
110 
115  void Deserialize();
116 
117 
122  void MarkForInitialization();
123 
124 
126  bool IsInitialized() const;
127 
131  void EnsureDcmDataSetIsInitialized() const;
132 
133 
142  bool CopyElement( DcmDataset* dataset, const DcmTagKey& tag, int type );
143 
151  QString Decode(const DcmTag& tag, const OFString& raw) const;
152 
157  OFString Encode(const DcmTag& tag, const QString& qstring) const;
158 
162  OFCondition findAndGetElement(const DcmTag& tag, DcmElement*& element, const OFBool searchIntoSub=OFFalse) const; // DCMTK is not const-correct
163 
167  OFCondition findAndGetOFString(const DcmTag& tag, OFString& value, const unsigned long pos = 0, const OFBool searchIntoSub=OFFalse) const; // DCMTK is not const-correct
168 
169  static bool CheckCondition(const OFCondition&);
170 
174  QString GetAllElementValuesAsString( const DcmTag& tag ) const;
175  QString GetElementAsString( const DcmTag& tag, unsigned long pos = 0 ) const;
176  QStringList GetElementAsStringList( const DcmTag& tag ) const;
177  ctkDICOMPersonName GetElementAsPersonName( const DcmTag& tag, unsigned long pos = 0 ) const;
178  ctkDICOMPersonNameList GetElementAsPersonNameList( const DcmTag& tag ) const;
179  QDate GetElementAsDate( const DcmTag& tag, unsigned long pos = 0 ) const;
180  QTime GetElementAsTime( const DcmTag& tag, unsigned long pos = 0 ) const;
181  double GetElementAsDouble( const DcmTag& tag, unsigned long pos = 0 ) const; // type DS
182  long GetElementAsInteger( const DcmTag& tag, unsigned long pos = 0 ) const; // type IS
183  int GetElementAsSignedShort( const DcmTag& tag, unsigned long pos = 0 ) const; // type SS
184  int GetElementAsUnsignedShort( const DcmTag& tag, unsigned long pos = 0 ) const; // type US
185 
189  QDateTime GetElementAsDateTime( const DcmTag& tag, unsigned long pos = 0 ) const;
190 
191 
195  bool SetElementAsString( const DcmTag& tag, QString string );
196  bool SetElementAsStringList( const DcmTag& tag, QStringList stringList ); //> Currently not implemented
197  bool SetElementAsPersonName( const DcmTag& tag, ctkDICOMPersonName personName );
198  bool SetElementAsPersonNameList( const DcmTag& tag, ctkDICOMPersonNameList personNameList ); //> Currently not implemented
199  bool SetElementAsDate( const DcmTag& tag, QDate date );
200  bool SetElementAsTime( const DcmTag& tag, QTime time );
201  bool SetElementAsDateTime( const DcmTag& tag, QDateTime dateTime );
202  bool SetElementAsInteger( const DcmTag& tag, long value, unsigned long pos = 0 ); // type IS
203  bool SetElementAsSignedShort( const DcmTag& tag, int value, unsigned long pos = 0 ); // type SS
204  bool SetElementAsUnsignedShort( const DcmTag& tag, int value, unsigned long pos = 0 ); // type US
205 
206 
208  QString GetStudyInstanceUID() const;
209  QString GetSeriesInstanceUID() const;
210  QString GetSOPInstanceUID() const;
211 
215  static QString TranslateDefinedTermPatientPosition( const QString& dt );
216 
220  static QString TranslateDefinedTermModality( const QString& dt );
221 
225  static QString TagKey( const DcmTag& tag );
226 
230  static QString TagDescription( const DcmTag& tag );
231 
235  static QString TagVR( const DcmTag& tag );
236 
237 protected:
238 
245  virtual QString GetStoredSerialization();
246 
253  virtual void SetStoredSerialization(QString serializedDataset);
254 
255  QScopedPointer<ctkDICOMItemPrivate> d_ptr;
256 
257  DcmItem& GetDcmItem() const;
258 
259 private:
260  Q_DECLARE_PRIVATE(ctkDICOMItem);
261 };
262 
263 #endif
264 
ctkDICOMItem
ctkDICOMItem ctkDICOMItem
Definition: ctkDICOMItem.h:62
ctkDICOMPersonName.h
ctkDICOMPersonName
A person's name as modelled in DICOM.
Definition: ctkDICOMPersonName.h:39
ctkDICOMItem::Superclass
QObject Superclass
Definition: ctkDICOMItem.h:69
QList
Definition: ctkCmdLineModuleBackend.h:30
ctkDICOMItem
Definition: ctkDICOMItem.h:66
ctkWrapPythonQt.type
type
Definition: ctkWrapPythonQt.py:214
ctkDICOMItem::d_ptr
QScopedPointer< ctkDICOMItemPrivate > d_ptr
Definition: ctkDICOMItem.h:255