Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes

creaImageIO::tree::AttributeDescriptor Class Reference
[Attributed tree management]

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

#include <creaImageIOTreeAttributeDescriptor.h>

List of all members.

Public Member Functions

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

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".

Static Public Attributes

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

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 17 of file creaImageIOTreeAttributeDescriptor.h.


Constructor & Destructor Documentation

creaImageIO::tree::AttributeDescriptor::AttributeDescriptor (  )  [inline]

Default ctor.

Definition at line 39 of file creaImageIOTreeAttributeDescriptor.h.

        : mKey(""), mName(""), mGroup(0), mElement(0), mFlags(0)
      {
      }

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 44 of file creaImageIOTreeAttributeDescriptor.h.

        : mKey(key), mName(name), mGroup(group), mElement(element), 
          mFlags(flags)
      {
      }

creaImageIO::tree::AttributeDescriptor::AttributeDescriptor ( const std::string &  key,
const std::string &  name,
unsigned int  flags = 0 
)

Definition at line 45 of file creaImageIOTreeAttributeDescriptor.cpp.

References CleanName(), GimmickDebugMessage, and mName.

      : mKey(key), mName(name), mGroup(0), mElement(0), mFlags(flags)
    {

      CleanName(mName);
      GimmickDebugMessage(3,"AttributeDescriptor : '"<<key
                          <<"' ["<<flags<<"]"<<std::endl);
      GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
    }

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 63 of file creaImageIOTreeAttributeDescriptor.cpp.

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

      : mGroup(group), mElement(element), mFlags(flags)
    {
      
      //GDCM_NAME_SPACE::TagKey tag(group,element);
      char ctag[12];
      sprintf(ctag,"D%04x_%04x",group,element);
      mKey = ctag;

      GimmickDebugMessage(3,"AttributeDescriptor : '"<<mKey
                          <<"' ["<<flags<<"]"<<std::endl);

#if defined(USE_GDCM)
      // Retrieve the name from gdcm dict
      GDCM_NAME_SPACE::DictEntry* entry =
        GDCM_NAME_SPACE::Global::GetDicts()
        ->GetDefaultPubDict()->GetEntry(mGroup,mElement);
          
      if (entry)
        {
          mName = entry->GetName();
          CleanName(mName);
          GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
        }
      else
        {
          GimmickMessage(1,"!! WARNING : tag '"<<mKey
                         <<"' is not in DICOM dictionnary ! "
                         <<"Considering it as a user attribute"
                         << std::endl);
          mName = "UNKNOWN";
          mGroup = mElement = 0;
        }
#endif


          
          
#if defined(USE_GDCM2)
      // Retrieve the name from gdcm dict
        const gdcm::Global& g = gdcm::Global::GetInstance(); 
         const gdcm::Dicts &dicts = g.GetDicts();
  const gdcm::Dict &dict = dicts.GetPublicDict();
          gdcm::DictEntry dictentry =  dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
          
      mName = dictentry.GetName();
          if(!mName.empty())
          {
                  CleanName(mName);
                  GimmickDebugMessage(3,"='"<<mName<<"'"<<std::endl);
          }
      else
          {
                GimmickMessage(1,"!! WARNING : tag '"<<mKey
                         <<"' is not in DICOM dictionnary ! "
                         <<"Considering it as a user attribute"
                         << std::endl);
                mName = "UNKNOWN";
                mGroup = mElement = 0;
                }
#endif

    }

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 25 of file creaImageIOTreeAttributeDescriptor.cpp.

Referenced by AttributeDescriptor().

    {
      // quote must be doubled for SQL
      //    crea::Utils::Replace( str, "'", "''" );
      boost::algorithm::replace_all(str,"'","''");
      // Found strange strings which contained NULL char INSIDE string 
      int i,size=str.size();
      for (i=0;i<size;++i) 
        {
          if (str[i]==0) 
            {
              str = str.substr(0,i);
              break;
            }
        }
    }

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 224 of file creaImageIOTreeAttributeDescriptor.cpp.

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

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

          {
                 std::string type=""; 
#if defined(USE_GDCM)   
                  // Retrieve the name from gdcm dict
                GDCM_NAME_SPACE::DictEntry* entry =
                GDCM_NAME_SPACE::Global::GetDicts()
                ->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());

                if (entry==0) 
                {
                        typ = 2;
                        return;
                }
                 type = entry->GetVR().str();
#endif
#if defined(USE_GDCM2)
         const gdcm::Global& g = gdcm::Global::GetInstance(); // sum of all knowledge !
         const gdcm::Dicts &dicts = g.GetDicts();
  const gdcm::Dict &dict = dicts.GetPublicDict(); // Part 6
          gdcm::DictEntry dictentry =  dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
          type = gdcm::VR::GetVRString(dictentry.GetVR());
#endif

                GimmickDebugMessage(3,"VR Value is "<<type<<"!"<<std::endl);
                if(type=="AS" ||
                type=="DA" ||
                type=="FL" ||
                type=="FD" ||
                type=="IS" ||
                type=="SL" ||
                type=="SS" ||
                type=="UI" ||
                type=="US" ||
                type=="SH")
                {
                        // Numerical 
                        typ = 1;
                }
                else
                {
                        // String
                        typ = 2;
                }
                
          }

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 133 of file creaImageIOTreeAttributeDescriptor.cpp.

References GimmickDebugMessage, and GimmickMessage.

    {
      group = elem = 0;
      if ( (key.size()==10) &&
           (key[0] == 'D') &&
           (key[5] == '_') )
          {
         sscanf(key.c_str(),"D%04hx_%04hx ",&group,&elem);  
          GimmickDebugMessage(3,"GetDicomGroupElementFromKey '"<<key<<"' : "                     <<group<<"|"<<elem<<std::endl);
        }
      else 
        { 
          GimmickMessage(5,"GetDicomGroupElementFromKey '"<<key<<"' : "
                         <<" not a DICOM key format"<<std::endl);
        }
      return;
    }

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

Returns the DICOM element code of the attribute.

Definition at line 71 of file creaImageIOTreeAttributeDescriptor.h.

References mElement.

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

{ 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 73 of file creaImageIOTreeAttributeDescriptor.h.

References mFlags.

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

{ 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 69 of file creaImageIOTreeAttributeDescriptor.h.

References mGroup.

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

{ 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 65 of file creaImageIOTreeAttributeDescriptor.h.

References mKey.

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

{ 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 67 of file creaImageIOTreeAttributeDescriptor.h.

References mName.

{ return mName; }

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

Determines if Attribute is a date.

test if the type is a date

Definition at line 155 of file creaImageIOTreeAttributeDescriptor.cpp.

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

        {
                 
                bool btest = false;
                // Retrieve the name from gdcm dict
#if defined(USE_GDCM)
                GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
                if(     entry != 0)
                {
                        if( entry->GetVR().str() == "DA" )
                        {
                                btest = true;
                        }
                }
#endif
#if defined(USE_GDCM2)
         const gdcm::Global& g = gdcm::Global::GetInstance(); 
         const gdcm::Dicts &dicts = g.GetDicts();
  const gdcm::Dict &dict = dicts.GetPublicDict();
          if(mGroup != 0 && mElement != 0)
          {
                  gdcm::DictEntry dictentry =  dict.GetDictEntry(gdcm::Tag(GetGroup(), GetElement()));
                if( gdcm::VR::GetVRString(dictentry.GetVR()) == "DA")
                {
                                btest = true;
                }
          }
#endif
                return btest;
        }

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 188 of file creaImageIOTreeAttributeDescriptor.cpp.

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

        {
                 
                bool btest = false;
#if defined(USE_GDCM)
                // Retrieve the name from gdcm dict
                GDCM_NAME_SPACE::DictEntry* entry =     GDCM_NAME_SPACE::Global::GetDicts()->GetDefaultPubDict()->GetEntry(GetGroup(),GetElement());
                if(     entry != 0)
                {
                        if( entry->GetVR().str() == "TM" )
                        {
                                btest = true;
                        }
                }
#endif

#if defined(USE_GDCM2)
         const gdcm::Global& g = gdcm::Global::GetInstance(); // sum of all knowledge !
         const gdcm::Dicts &dicts = g.GetDicts();
  const gdcm::Dict &dict = dicts.GetPublicDict(); // Part 6
          if(mGroup != 0 && mElement != 0)
          {
                gdcm::DictEntry dictentry =  dict.GetDictEntry(gdcm::Tag(mGroup, mElement));
                if(gdcm::VR::GetVRString(dictentry.GetVR()) == "TM")
                {
                                btest = true;
                }
          }
#endif

                return btest;
        }

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 28 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 24 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 26 of file creaImageIOTreeAttributeDescriptor.h.

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

Definition at line 97 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by GetFlags().

Definition at line 93 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by AttributeDescriptor(), and GetKey().

Definition at line 94 of file creaImageIOTreeAttributeDescriptor.h.

Referenced by AttributeDescriptor(), and GetName().

The attribute is of numeric type.

Types

Definition at line 32 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 22 of file creaImageIOTreeAttributeDescriptor.h.

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

The attribute is of string type.

Definition at line 34 of file creaImageIOTreeAttributeDescriptor.h.

The attribute's type is unknown.

Definition at line 36 of file creaImageIOTreeAttributeDescriptor.h.


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