creaImageIO_lib
creaImageIO::tree::AttributeDescriptor Class Reference

Descriptor of an attribute of a node of a Tree (name, dicom group/element) More...

#include <creaImageIOTreeAttributeDescriptor.h>

Public Member Functions

 AttributeDescriptor ()
 Default ctor. More...
 
 AttributeDescriptor (const std::string &key, const std::string &name, unsigned short group, unsigned short element, unsigned int flags)
 Ctor with all explicitely. More...
 
 AttributeDescriptor (const std::string &key, const std::string &name, unsigned int flags=0)
 
 AttributeDescriptor (unsigned short group, unsigned short element, unsigned int flags=0)
 
const std::string & GetKey () const
 Returns the key of the attribute. More...
 
const std::string & GetName () const
 Returns the name of the attribute. More...
 
unsigned short GetGroup () const
 Returns the DICOM group code of the attribute. More...
 
unsigned short GetElement () const
 Returns the DICOM element code of the attribute. More...
 
unsigned int GetFlags () const
 Returns the flags of the attribute. More...
 
void CleanName (std::string &str) const
 
void DecodeType (unsigned int &type) const
 Decodes the type of attribute into the existing ones. More...
 
bool isDateEntry () const
 Determines if Attribute is a date. More...
 
bool isTimeEntry () const
 Determines if Attribute is a time. More...
 

Static Public Member Functions

static void GetDicomGroupElementFromKey (const std::string &key, unsigned short &group, unsigned short &elem)
 Extracts group and element from a key of the form "Dgroup_elem". More...
 

Static Public Attributes

static const unsigned int PRIVATE = 1
 The attribute is hidden (not visible to user) More...
 
static const unsigned int IDENTIFIER = 2
 The attribute enters in unique identifier constitution. More...
 
static const unsigned int LABEL = 4
 The attribute enters in label constitution (for printing) More...
 
static const unsigned int EDITABLE = 3
 The attribute can be edited. More...
 
static const int NUMBER =1
 The attribute is of numeric type. More...
 
static const int STRING =2
 The attribute is of string type. More...
 
static const int UNKNOWN =0
 The attribute's type is unknown. More...
 

Private Attributes

std::string mKey
 
std::string mName
 
unsigned short mGroup
 
unsigned short mElement
 
unsigned int mFlags
 

Detailed Description

Descriptor of an attribute of a node of a Tree (name, dicom group/element)

Definition at line 45 of file creaImageIOTreeAttributeDescriptor.h.

Constructor & Destructor Documentation

creaImageIO::tree::AttributeDescriptor::AttributeDescriptor ( )
inline

Default ctor.

Definition at line 67 of file creaImageIOTreeAttributeDescriptor.h.

68  : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
69  {
70  }
creaImageIO::tree::AttributeDescriptor::AttributeDescriptor ( const std::string &  key,
const std::string &  name,
unsigned short  group,
unsigned short  element,
unsigned int  flags 
)
inline

Ctor with all explicitely.

Definition at line 72 of file creaImageIOTreeAttributeDescriptor.h.

77  : mKey(key), mName(name), mGroup(group), mElement(element),
78  mFlags(flags)
79  {
80  }
creaImageIO::tree::AttributeDescriptor::AttributeDescriptor ( const std::string &  key,
const std::string &  name,
unsigned int  flags = 0 
)

Definition at line 76 of file creaImageIOTreeAttributeDescriptor.cpp.

References CleanName(), GimmickDebugMessage, and mName.

79  : mKey(key), mName(name), mGroup(0), mElement(0), mFlags(flags)
80  {
81 
83  GimmickDebugMessage(3,"AttributeDescriptor : '"<<key
84  <<"' ["<<flags<<"]"<<std::endl);
85  GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
86  }

Here is the call graph for this function:

creaImageIO::tree::AttributeDescriptor::AttributeDescriptor ( unsigned short  group,
unsigned short  element,
unsigned int  flags = 0 
)

Definition at line 94 of file creaImageIOTreeAttributeDescriptor.cpp.

References CleanName(), GimmickDebugMessage, GimmickMessage, mElement, mGroup, mKey, and mName.

97  : mGroup(group), mElement(element), mFlags(flags)
98  {
99 
100  //GDCM_NAME_SPACE::TagKey tag(group,element);
101  char ctag[12];
102  sprintf(ctag,"D%04x_%04x",group,element);
103  mKey = ctag;
104 
105  GimmickDebugMessage(3,"AttributeDescriptor : '"<<mKey
106  <<"' ["<<flags<<"]"<<std::endl);
107 
108 #if defined(USE_GDCM)
109  // Retrieve the name from gdcm dict
110  GDCM_NAME_SPACE::DictEntry* entry =
111  GDCM_NAME_SPACE::Global::GetDicts()
112  ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
113 
114  if (entry)
115  {
116  mName = entry->GetName();
117  CleanName(mName);
118  GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
119  }
120  else
121  {
122  GimmickMessage(1,"!! WARNING : tag '"<<mKey
123  <<"' is not in DICOM dictionnary ! "
124  <<"Considering it as a user attribute"
125  << std::endl);
126  mName = "UNKNOWN";
127  mGroup = mElement = 0;
128  }
129 #endif
130 
131 
132 
133 
134 #if defined(USE_GDCM2)
135  // Retrieve the name from gdcm dict
136  const gdcm::Global& g = gdcm::Global::GetInstance();
137  const gdcm::Dicts &dicts = g.GetDicts();
138  const gdcm::Dict &dict = dicts.GetPublicDict();
139  gdcm::DictEntry dictentry = dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
140 
141  mName = dictentry.GetName();
142  if(!mName.empty())
143  {
144  CleanName(mName);
145  GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
146  }
147  else
148  {
149  GimmickMessage(1,"!! WARNING : tag '"<<mKey
150  <<"' is not in DICOM dictionnary ! "
151  <<"Considering it as a user attribute"
152  << std::endl);
153  mName = "UNKNOWN";
154  mGroup = mElement = 0;
155  }
156 #endif
157 
158  }

Here is the call graph for this function:

Member Function Documentation

void creaImageIO::tree::AttributeDescriptor::CleanName ( std::string &  str) const

Cleans the name: Replace simple quote by double quotes Cut string at NULL chars

Definition at line 56 of file creaImageIOTreeAttributeDescriptor.cpp.

Referenced by AttributeDescriptor().

57  {
58  // quote must be doubled for SQL
59  // crea::Utils::Replace( str, "'", "''" );
60  boost::algorithm::replace_all(str,"'","''");
61  // Found strange strings which contained NULL char INSIDE string
62  int i,size=(int)str.size();
63  for (i=0;i<size;++i)
64  {
65  if (str[i]==0)
66  {
67  str = str.substr(0,i);
68  break;
69  }
70  }
71  }

Here is the caller graph for this function:

void creaImageIO::tree::AttributeDescriptor::DecodeType ( unsigned int &  type) const

Decodes the type of attribute into the existing ones.

Decodes the type of the attribute.

Definition at line 255 of file creaImageIOTreeAttributeDescriptor.cpp.

References GetElement(), GetGroup(), GimmickDebugMessage, mElement, and mGroup.

Referenced by creaImageIO::WxTreeView::SortLevel().

256  {
257  std::string type="";
258 #if defined(USE_GDCM)
259  // Retrieve the name from gdcm dict
260  GDCM_NAME_SPACE::DictEntry* entry =
261  GDCM_NAME_SPACE::Global::GetDicts()
262  ->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
263 
264  if (entry==0)
265  {
266  typ = 2;
267  return;
268  }
269  type = entry->GetVR().str();
270 #endif
271 #if defined(USE_GDCM2)
272  const gdcm::Global& g = gdcm::Global::GetInstance(); // sum of all knowledge !
273  const gdcm::Dicts &dicts = g.GetDicts();
274  const gdcm::Dict &dict = dicts.GetPublicDict(); // Part 6
275  gdcm::DictEntry dictentry = dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
276  type = gdcm::VR::GetVRString(dictentry.GetVR());
277 #endif
278 
279  GimmickDebugMessage(3,"VR Value is "<<type<<"!"<<std::endl);
280  if(type=="AS" ||
281  type=="DA" ||
282  type=="FL" ||
283  type=="FD" ||
284  type=="IS" ||
285  type=="SL" ||
286  type=="SS" ||
287  type=="UI" ||
288  type=="US" ||
289  type=="SH")
290  {
291  // Numerical
292  typ = 1;
293  }
294  else
295  {
296  // String
297  typ = 2;
298  }
299 
300  }

Here is the call graph for this function:

Here is the caller graph for this function:

void creaImageIO::tree::AttributeDescriptor::GetDicomGroupElementFromKey ( const std::string &  key,
unsigned short &  group,
unsigned short &  elem 
)
static

Extracts group and element from a key of the form "Dgroup_elem".

Definition at line 164 of file creaImageIOTreeAttributeDescriptor.cpp.

References GimmickDebugMessage, and GimmickMessage.

Referenced by creaImageIO::DicomImageScanner::addDirectory(), creaImageIO::DicomImageReader::ReadAttributes(), and creaImageIO::DicomImageReader::ReadAttributes2().

167  {
168  group = elem = 0;
169  if ( (key.size()==10) &&
170  (key[0] == 'D') &&
171  (key[5] == '_') )
172  {
173  sscanf(key.c_str(),"D%04hx_%04hx ",&group,&elem);
174  GimmickDebugMessage(3,"GetDicomGroupElementFromKey '"<<key<<"' : " <<group<<"|"<<elem<<std::endl);
175  }
176  else
177  {
178  GimmickMessage(5,"GetDicomGroupElementFromKey '"<<key<<"' : "
179  <<" not a DICOM key format"<<std::endl);
180  }
181  return;
182  }

Here is the caller graph for this function:

unsigned short creaImageIO::tree::AttributeDescriptor::GetElement ( ) const
inline

Returns the DICOM element code of the attribute.

Definition at line 99 of file creaImageIOTreeAttributeDescriptor.h.

References mElement.

Referenced by DecodeType(), isDateEntry(), and isTimeEntry().

99 { return mElement; }

Here is the caller graph for this function:

unsigned int creaImageIO::tree::AttributeDescriptor::GetFlags ( ) const
inline

Returns the flags of the attribute.

Definition at line 101 of file creaImageIOTreeAttributeDescriptor.h.

References mFlags.

Referenced by creaImageIO::tree::LevelDescriptor::Add().

101 { return mFlags; }

Here is the caller graph for this function:

unsigned short creaImageIO::tree::AttributeDescriptor::GetGroup ( ) const
inline

Returns the DICOM group code of the attribute.

Definition at line 97 of file creaImageIOTreeAttributeDescriptor.h.

References mGroup.

Referenced by DecodeType(), isDateEntry(), and isTimeEntry().

97 { return mGroup; }

Here is the caller graph for this function:

const std::string& creaImageIO::tree::AttributeDescriptor::GetKey ( ) const
inline

Returns the key of the attribute.

Definition at line 93 of file creaImageIOTreeAttributeDescriptor.h.

References mKey.

Referenced by creaImageIO::tree::LevelDescriptor::Add().

93 { return mKey; }

Here is the caller graph for this function:

const std::string& creaImageIO::tree::AttributeDescriptor::GetName ( ) const
inline

Returns the name of the attribute.

Definition at line 95 of file creaImageIOTreeAttributeDescriptor.h.

References mName.

95 { return mName; }
bool creaImageIO::tree::AttributeDescriptor::isDateEntry ( ) const

Determines if Attribute is a date.

test if the type is a date

Definition at line 186 of file creaImageIOTreeAttributeDescriptor.cpp.

References GetElement(), GetGroup(), mElement, and mGroup.

187  {
188 
189  bool btest = false;
190  // Retrieve the name from gdcm dict
191 #if defined(USE_GDCM)
192  GDCM_NAME_SPACE::DictEntry* entry = GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
193  if( entry != 0)
194  {
195  if( entry->GetVR().str() == "DA" )
196  {
197  btest = true;
198  }
199  }
200 #endif
201 #if defined(USE_GDCM2)
202  const gdcm::Global& g = gdcm::Global::GetInstance();
203  const gdcm::Dicts &dicts = g.GetDicts();
204  const gdcm::Dict &dict = dicts.GetPublicDict();
205  if(mGroup != 0 && mElement != 0)
206  {
207  gdcm::DictEntry dictentry = dict.GetDictEntry(gdcm::Tag(GetGroup(), GetElement()));
208  if( gdcm::VR::GetVRString(dictentry.GetVR()) == "DA")
209  {
210  btest = true;
211  }
212  }
213 #endif
214  return btest;
215  }

Here is the call graph for this function:

bool creaImageIO::tree::AttributeDescriptor::isTimeEntry ( ) const

Determines if Attribute is a time.

test if the type is a time

Definition at line 219 of file creaImageIOTreeAttributeDescriptor.cpp.

References GetElement(), GetGroup(), mElement, and mGroup.

220  {
221 
222  bool btest = false;
223 #if defined(USE_GDCM)
224  // Retrieve the name from gdcm dict
225  GDCM_NAME_SPACE::DictEntry* entry = GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
226  if( entry != 0)
227  {
228  if( entry->GetVR().str() == "TM" )
229  {
230  btest = true;
231  }
232  }
233 #endif
234 
235 #if defined(USE_GDCM2)
236  const gdcm::Global& g = gdcm::Global::GetInstance(); // sum of all knowledge !
237  const gdcm::Dicts &dicts = g.GetDicts();
238  const gdcm::Dict &dict = dicts.GetPublicDict(); // Part 6
239  if(mGroup != 0 && mElement != 0)
240  {
241  gdcm::DictEntry dictentry = dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
242  if(gdcm::VR::GetVRString(dictentry.GetVR()) == "TM")
243  {
244  btest = true;
245  }
246  }
247 #endif
248 
249  return btest;
250  }

Here is the call graph for this function:

Member Data Documentation

const unsigned int creaImageIO::tree::AttributeDescriptor::EDITABLE = 3
static

The attribute can be edited.

Definition at line 56 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by creaImageIO::WxTreeView::GetAttributes(), and creaImageIO::WxTreeView::OnEditField().

const unsigned int creaImageIO::tree::AttributeDescriptor::IDENTIFIER = 2
static

The attribute enters in unique identifier constitution.

Definition at line 52 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by creaImageIO::tree::LevelDescriptor::Add(), and creaImageIO::tree::Descriptor::CreateDefault().

const unsigned int creaImageIO::tree::AttributeDescriptor::LABEL = 4
static

The attribute enters in label constitution (for printing)

the attribute describes the node

Definition at line 54 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by creaImageIO::tree::LevelDescriptor::Add(), and creaImageIO::tree::Descriptor::CreateDefault().

unsigned short creaImageIO::tree::AttributeDescriptor::mElement
private
unsigned int creaImageIO::tree::AttributeDescriptor::mFlags
private

Definition at line 125 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by GetFlags().

unsigned short creaImageIO::tree::AttributeDescriptor::mGroup
private
std::string creaImageIO::tree::AttributeDescriptor::mKey
private

Definition at line 121 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by AttributeDescriptor(), and GetKey().

std::string creaImageIO::tree::AttributeDescriptor::mName
private

Definition at line 122 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by AttributeDescriptor(), and GetName().

const int creaImageIO::tree::AttributeDescriptor::NUMBER =1
static

The attribute is of numeric type.

Types

Definition at line 60 of file creaImageIOTreeAttributeDescriptor.h.

const unsigned int creaImageIO::tree::AttributeDescriptor::PRIVATE = 1
static

The attribute is hidden (not visible to user)

Flags The attribute is hidden (not visible to user)

Definition at line 50 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by creaImageIO::WxTreeView::CreateCtrl(), creaImageIO::SQLiteTreeHandler::DBCreate(), and creaImageIO::WxTreeView::WxTreeView().

const int creaImageIO::tree::AttributeDescriptor::STRING =2
static

The attribute is of string type.

Definition at line 62 of file creaImageIOTreeAttributeDescriptor.h.

const int creaImageIO::tree::AttributeDescriptor::UNKNOWN =0
static

The attribute's type is unknown.

Definition at line 64 of file creaImageIOTreeAttributeDescriptor.h.


The documentation for this class was generated from the following files: