CTK 0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Loading...
Searching...
No Matches
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
32class DcmDataDictionary;
33
34
35class ctkDICOMItemPrivate;
36
62class ctkDICOMItem;
63
65
66class CTK_DICOM_CORE_EXPORT ctkDICOMItem
67{
68public:
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
116
117
123
124
126 bool IsInitialized() const;
127
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;
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
237protected:
238
245 virtual QString GetStoredSerialization();
246
253 virtual void SetStoredSerialization(QString serializedDataset);
254
255 QScopedPointer<ctkDICOMItemPrivate> d_ptr;
256
257 DcmItem& GetDcmItem() const;
258
259private:
260 Q_DECLARE_PRIVATE(ctkDICOMItem);
261};
262
263#endif
264
DcmItem & GetDcmItem() const
static QString TranslateDefinedTermModality(const QString &dt)
Get a human-readable version of modality enumerations used e.g. in DICOM series.
static QString TagKey(const DcmTag &tag)
Nicely formatted (group,element) version of a tag.
bool SetElementAsPersonNameList(const DcmTag &tag, ctkDICOMPersonNameList personNameList)
bool SetElementAsString(const DcmTag &tag, QString string)
Set-methods for for all subtypes of DcmByteString.
bool IsInitialized() const
Is this dataset initialized ?
QString GetStudyInstanceUID() const
Some convenience getter.
bool SetElementAsPersonName(const DcmTag &tag, ctkDICOMPersonName personName)
void Serialize()
Store a string representation of the object to a database field.
static QString TranslateDefinedTermPatientPosition(const QString &dt)
Get a human-readable version of patient position enumerations used e.g. in DICOM series.
OFString Encode(const DcmTag &tag, const QString &qstring) const
creates an OFString from the QtString
double GetElementAsDouble(const DcmTag &tag, unsigned long pos=0) const
void EnsureDcmDataSetIsInitialized() const
Called by all Get/Set methods to initialize DcmDataSet if needed.
OFCondition findAndGetOFString(const DcmTag &tag, OFString &value, const unsigned long pos=0, const OFBool searchIntoSub=OFFalse) const
A const-correct version of DcmDataset::findAndGetOFString.
QString GetElementAsString(const DcmTag &tag, unsigned long pos=0) const
QString Decode(const DcmTag &tag, const OFString &raw) const
creates a QString from the OFString, respecting the "specific character set" of the Dataset.
bool SetElementAsUnsignedShort(const DcmTag &tag, int value, unsigned long pos=0)
int GetElementAsUnsignedShort(const DcmTag &tag, unsigned long pos=0) const
QStringList GetElementAsStringList(const DcmTag &tag) const
void MarkForInitialization()
To be called from InitializeData, flags status as dirty.
bool SetElementAsDate(const DcmTag &tag, QDate date)
static QString TagVR(const DcmTag &tag)
Value Representation.
bool SetElementAsSignedShort(const DcmTag &tag, int value, unsigned long pos=0)
virtual void InitializeFromItem(DcmItem *dataset, bool takeOwnership=false)
For initialization from a DcmDataset in a constructor / assignment.
QScopedPointer< ctkDICOMItemPrivate > d_ptr
void Deserialize()
Restore the object from a string representation in a database field.
bool SaveToFile(const QString &filePath) const
Save dataset to file.
virtual ~ctkDICOMItem()
OFCondition findAndGetElement(const DcmTag &tag, DcmElement *&element, const OFBool searchIntoSub=OFFalse) const
A const-correct version of DcmDataset::findAndGetElement.
long GetElementAsInteger(const DcmTag &tag, unsigned long pos=0) const
bool SetElementAsInteger(const DcmTag &tag, long value, unsigned long pos=0)
bool SetElementAsTime(const DcmTag &tag, QTime time)
virtual QString GetStoredSerialization()
Callback for retrieving a serialized version of this class.
int GetElementAsSignedShort(const DcmTag &tag, unsigned long pos=0) const
QTime GetElementAsTime(const DcmTag &tag, unsigned long pos=0) const
ctkDICOMItem(bool strictErrorHandling=false)
Create an empty object. This has to be initialized by one of the InitializeFrom......
ctkDICOMPersonNameList GetElementAsPersonNameList(const DcmTag &tag) const
QString GetSOPInstanceUID() const
bool SetElementAsDateTime(const DcmTag &tag, QDateTime dateTime)
QDateTime GetElementAsDateTime(const DcmTag &tag, unsigned long pos=0) const
QString GetSeriesInstanceUID() const
ctkDICOMPersonName GetElementAsPersonName(const DcmTag &tag, unsigned long pos=0) const
bool SetElementAsStringList(const DcmTag &tag, QStringList stringList)
static bool CheckCondition(const OFCondition &)
QDate GetElementAsDate(const DcmTag &tag, unsigned long pos=0) const
static QString TagDescription(const DcmTag &tag)
Description (name) of the tag.
bool CopyElement(DcmDataset *dataset, const DcmTagKey &tag, int type)
Find element in dataset and copy it into internal DcmDataset.
virtual void SetStoredSerialization(QString serializedDataset)
Callback for storing a serialized version of this class.
QObject Superclass
QString GetAllElementValuesAsString(const DcmTag &tag) const
Get-methods for for all subtypes of DcmByteString.
virtual void InitializeFromFile(const QString &filename, const E_TransferSyntax readXfer=EXS_Unknown, const E_GrpLenEncoding groupLength=EGL_noChange, const Uint32 maxReadLength=DCM_MaxReadLength, const E_FileReadMode readMode=ERM_autoDetect)
For initialization from file in a constructor / assignment.
A person's name as modelled in DICOM.
QList< ctkDICOMPersonName > ctkDICOMPersonNameList