1 /*=========================================================================
4 Module: $RCSfile: gdcmDictEntry.cxx,v $
6 Date: $Date: 2005/02/02 15:07:41 $
7 Version: $Revision: 1.45 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
19 #include "gdcmDictEntry.h"
20 #include "gdcmDebug.h"
23 #include <iomanip> // for std::ios::left, ...
28 //-----------------------------------------------------------------------------
29 // Constructor / Destructor
32 * @param group DICOM-Group Number
33 * @param elem DICOM-Element Number
34 * @param vr Value Representation
35 * @param vm Value Mutlplicity
36 * @param name description of the element
39 DictEntry::DictEntry(uint16_t group, uint16_t elem,
49 Key = TranslateToKey(group, elem);
52 //-----------------------------------------------------------------------------
55 * \brief If-and only if-the V(alue) R(epresentation)
56 * \ is unset then overwrite it.
57 * @param vr New V(alue) R(epresentation) to be set.
59 void DictEntry::SetVR(TagName const &vr)
67 gdcmErrorMacro( "Overwriting VR might compromise a dictionary");
72 * \brief If-and only if-the V(alue) M(ultiplicity)
73 * \ is unset then overwrite it.
74 * @param vm New V(alue) M(ultiplicity) to be set.
76 void DictEntry::SetVM(TagName const &vm)
84 gdcmErrorMacro( "Overwriting VM might compromise a dictionary");
89 * \brief concatenates 2 uint16_t (supposed to be a Dicom group number
90 * and a Dicom element number)
91 * @param group the Dicom group number used to build the tag
92 * @param elem the Dicom element number used to build the tag
93 * @return the built tag
95 TagKey DictEntry::TranslateToKey(uint16_t group, uint16_t elem)
97 return Util::Format("%04x|%04x", group, elem);
100 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
106 //-----------------------------------------------------------------------------
109 * \brief Prints an entry of the Dicom DictionaryEntry
110 * @param os ostream we want to print in
111 * @param indent Indentation string to be prepended during printing
113 void DictEntry::Print(std::ostream &os, std::string const & )
116 std::ostringstream s;
122 s << DictEntry::TranslateToKey(GetGroup(),GetElement());
123 s << " [" << vr << "] ";
127 s.setf(std::ios::left);
128 s << std::setw(66-GetName().length()) << " ";
131 s << "[" << GetName()<< "]";
132 os << s.str() << std::endl;
135 //-----------------------------------------------------------------------------
136 } // end namespace gdcm