MeVisLab Toolbox Reference
ml::DicomModifySequence Class Reference

A concrete class derived from DicomModifyBase which allows the modification of ordinary, non-private, non-sequence DICOM tags in a (cloned) DICOM tree. More...

#include <mlDicomModifySequence.h>

Inheritance diagram for ml::DicomModifySequence:
ml::DicomModifyBase

Public Types

enum  ModificationModes {
  DoNotModify = 0 , AddEmptyIfItDoesNotExist , RemoveTag , MakeEmptyIfItExists ,
  MakeEmptyIfItExistsOtherwiseAddEmpty , ResizeToNumEntriesIfItExists , AppendNumEntriesIfItExists , InsertOneEntryAtIfItExists ,
  RemoveAllButFirstEntryIfItExists
}
 Available modes for tag modifications. More...
 
enum  { NumModificationModes = RemoveAllButFirstEntryIfItExists+1 }
 Defines the number of available modification modes. More...
 

Public Member Functions

 DicomModifySequence (DCMTree::TagId tagId=DCMTree::TagId(), const std::string &modStrVal="", ModificationModes modMode=DoNotModify)
 Constructor setting TagId, ModificationStringValue, and ModificationMode.
 
void setModificationMode (ModificationModes modMode)
 Sets how the tag with given id and modification value shall be modified.
 
ModificationModes getModificationMode () const
 Returns the currently set modification mode.
 
void setModificationParameters (DCMTree::TagId tagId, const std::string &modStrVal, ModificationModes modMode)
 Calls setTagId(tagId), setModificationStringValue(modStrVal), and setModificationMode(modMode)

 
std::string applyModifications (DCMTree::TreePtr dcmTree, const FieldContainer *treeInfos=nullptr) override
 Apply a change to dcmTree according to the currently selected _modificationMode.
 
- Public Member Functions inherited from ml::DicomModifyBase
 DicomModifyBase (DCMTree::TagId tagId=DCMTree::TagId(), const std::string &modStrVal="")
 Constructor setting the tag ID and the string value for modifications.
 
virtual ~DicomModifyBase ()
 Virtual destructor.
 
void setTagId (DCMTree::TagId tagId)
 Set the id of the tag to be modified.
 
void setTagId (const std::string &tagIdStr)
 Set the id (as std::string) of the tag to be modified; invalid ids will cause an ML_ERROR_PRINT, empty strings shall be ignored by specification and will set an id (0000,0000).
 
DCMTree::TagId getTagId () const
 Returns the id of the tag to be modified (might be temporarily overridden be a "modificationTagIdReplacement" field in treeInfos parameter of applyModifications()).
 
void setModificationStringValue (const std::string &modStrVal)
 Set the string value to be used for the tag modification if not overridden by a treeInfos-"modificationStringValueReplacement" entry as described in applyModifications.
 
const std::string & getModificationStringValue () const
 Returns the string which is used to manipulate tag value(s) (might be temporarily overridden by a "modificationStringValueReplacement" field in treeInfos parameter of applyModifications()).
 
bool getModificationStringValueAsMLInt (MLint &retVal) const
 If the modificationStringValue() can be interpreted as an integer value then true is returned and the string is converted to that integer and returned in retVal; otherwise false is returned and retVal is left unchanged.
 
void setTagIdAndModificationStringValue (DCMTree::TagId tagId, const std::string &modStrVal)
 Calls setTagId(tagId) and setModificationStringValue(modStrVal).
 
bool tagExists (DCMTree::TreePtr dcmTree) const
 
DCMTree::TagPtr getTagIfItExists (DCMTree::TreePtr dcmTree, std::string *errStr=nullptr) const
 
DCMTree::TagPtr addTag (DCMTree::TreePtr dcmTree, std::string *errStr=nullptr, bool setValue=true, bool splitValue=false) const
 Add the tag with ID getTagId() to tree dcmTree and value _modificationStringValue; requires a valid non nullptr dcmTree.
 
void removeTag (DCMTree::TreePtr dcmTree) const
 Remove the tag with the ID getTagId() if it exists, otherwise do nothing; (if dcmTree member is nullptr the call is ignored).
 
void setTagValue (DCMTree::TreePtr dcmTree, std::string *errStr=nullptr, const DICOMTagTools::ValueModifyModes modMode=DICOMTagTools::Replace, bool splitValue=false) const
 Sets the value of tag with getTagId() in dcmTree with new value _modificationStringValue.
 

Static Public Attributes

static const char *const ModificationModesStrings [NumModificationModes]
 String versions for ModificationModes.
 

Detailed Description

A concrete class derived from DicomModifyBase which allows the modification of ordinary, non-private, non-sequence DICOM tags in a (cloned) DICOM tree.


Definition at line 25 of file mlDicomModifySequence.h.

Member Enumeration Documentation

◆ anonymous enum

Defines the number of available modification modes.

Enumerator
NumModificationModes 

Definition at line 43 of file mlDicomModifySequence.h.

◆ ModificationModes

Available modes for tag modifications.

Enumerator
DoNotModify 

The tag is not modified at all.

AddEmptyIfItDoesNotExist 

If the tag does not exist then an empty one with zero sequence entries is added.

RemoveTag 

If the tag exist then it is removed.

MakeEmptyIfItExists 

If the tag exists then all sequence entries are removed, but the tag itself is left.

MakeEmptyIfItExistsOtherwiseAddEmpty 

If the tag exists the all sequence entries after the first one are removed.

ResizeToNumEntriesIfItExists 

If the tag exists the number entries is set to the value given by modStrVal.

AppendNumEntriesIfItExists 

If the tag exists then a number of entries given by modStrVal is appended to the end.

InsertOneEntryAtIfItExists 

If the tag exists then all sequence entries are removed, otherwise a sequence tag with no sequence entries is added.

RemoveAllButFirstEntryIfItExists 

If the tag exists an entry is inserted at before position given by modStrVal.

Definition at line 29 of file mlDicomModifySequence.h.

Constructor & Destructor Documentation

◆ DicomModifySequence()

ml::DicomModifySequence::DicomModifySequence ( DCMTree::TagId tagId = DCMTree::TagId(),
const std::string & modStrVal = "",
ModificationModes modMode = DoNotModify )

Constructor setting TagId, ModificationStringValue, and ModificationMode.

Member Function Documentation

◆ applyModifications()

std::string ml::DicomModifySequence::applyModifications ( DCMTree::TreePtr dcmTree,
const FieldContainer * treeInfos = nullptr )
overridevirtual

Apply a change to dcmTree according to the currently selected _modificationMode.

Parameters
dcmTreeThe DICOM tree to be modified.
treeInfosA FieldContainer which - if not nullptr - can contain additional user defined information fields about dcmTree.
Returns
An empty string on success, otherwise a cumulative descriptive string of all problems.

Reimplemented from ml::DicomModifyBase.

◆ getModificationMode()

ModificationModes ml::DicomModifySequence::getModificationMode ( ) const

Returns the currently set modification mode.

◆ setModificationMode()

void ml::DicomModifySequence::setModificationMode ( ModificationModes modMode)

Sets how the tag with given id and modification value shall be modified.

◆ setModificationParameters()

void ml::DicomModifySequence::setModificationParameters ( DCMTree::TagId tagId,
const std::string & modStrVal,
ModificationModes modMode )

Calls setTagId(tagId), setModificationStringValue(modStrVal), and setModificationMode(modMode)

Member Data Documentation

◆ ModificationModesStrings

const char* const ml::DicomModifySequence::ModificationModesStrings[NumModificationModes]
static

String versions for ModificationModes.

Definition at line 46 of file mlDicomModifySequence.h.


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