MeVisLab Toolbox Reference
ml::DicomModifyOrdinary 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 <mlDicomModifyOrdinary.h>

Inheritance diagram for ml::DicomModifyOrdinary:
ml::DicomModifyBase

Public Types

enum  ModificationModes {
  DoNotModify = 0 , AddIfItDoesNotExist , RemoveTag , ReplaceOnlyIfItExists ,
  PrependOnlyIfItExists , AppendOnlyIfItExists , SetNewUIDOnlyIfItExists , ReplaceIfItExistsOtherwiseAdd ,
  PrependIfItExistsOtherwiseAdd , AppendIfItExistsOtherwiseAdd , SetNewUIDIfItExistsOtherwiseAdd , ReplaceOtherValuesOnlyIfItExists ,
  SetOtherValuesIfItExistsOtherwiseAdd
}
 Available modes for tag modifications. More...
 
enum  { NumModificationModes = SetOtherValuesIfItExistsOtherwiseAdd+1 }
 Defines the number of available modification modes. More...
 

Public Member Functions

 DicomModifyOrdinary (DCMTree::TagId tagId=DCMTree::TagId(), const std::string &modStrVal="", ModificationModes modMode=DoNotModify, bool splitMode=false)
 Constructor setting TagId, ModificationStringValue(""), splitMode(false), and ModificationMode(DoNotModify). More...
 
void setModificationMode (ModificationModes modMode)
 Sets how the tag with given id and modification value shall be modified. More...
 
ModificationModes getModificationMode () const
 Returns the currently set modification mode. More...
 
void setSplitMode (bool split)
 If true then completely set values are split at backslashes into different values. More...
 
bool getSplitMode () const
 Returns whether split mode is on. More...
 
void setOtherVR (DCMTree::Vr otherVr)
 Sets the value representation to be used for (re)created "Other" tags. More...
 
DCMTree::Vr getOtherVR () const
 Returns the currently set otherVR. More...
 
std::string applyModifications (DCMTree::TreePtr dcmTree, const FieldContainer *treeInfos=nullptr) override
 Apply a change to dcmTree according to the currently selected _modificationMode. More...
 
- 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. More...
 
virtual ~DicomModifyBase ()
 Virtual destructor. More...
 
void setTagId (DCMTree::TagId tagId)
 Set the id of the tag to be modified. More...
 
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). More...
 
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()). More...
 
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. More...
 
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()). More...
 
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. More...
 
void setTagIdAndModificationStringValue (DCMTree::TagId tagId, const std::string &modStrVal)
 Calls setTagId(tagId) and setModificationStringValue(modStrVal). More...
 
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. More...
 
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). More...
 
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. More...
 

Static Public Attributes

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

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 mlDicomModifyOrdinary.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Defines the number of available modification modes.

Enumerator
NumModificationModes 

Definition at line 53 of file mlDicomModifyOrdinary.h.

◆ ModificationModes

Available modes for tag modifications.

Enumerator
DoNotModify 

The tag is not modified at all.

AddIfItDoesNotExist 

The tag is added if it is not found in the source tree, otherwise it is left unchanged.

RemoveTag 

The is removed if found in the source tree, otherwise nothing is done.

ReplaceOnlyIfItExists 

If the tag is found then its value is replaced with the new value.

PrependOnlyIfItExists 

If the tag is found then the string is prepended after the existing tag value.

AppendOnlyIfItExists 

If the tag is found then the string is appended after the existing tag value.

SetNewUIDOnlyIfItExists 

If the tag is found then a newly created UID is set as tag value.

ReplaceIfItExistsOtherwiseAdd 

The tag value is replaced if the tag is found, otherwise a new tag with the value is added.

PrependIfItExistsOtherwiseAdd 

The value is inserted at the begin of the tag value if the tag is found, otherwise a new tag with the value is added.

AppendIfItExistsOtherwiseAdd 

The value is inserted at the end of the tag value if the tag is found, otherwise a new tag with the value is added.

SetNewUIDIfItExistsOtherwiseAdd 

The value is replaced with newly created UID if the tag is found, otherwise a new tag with a newly created UID is added.

ReplaceOtherValuesOnlyIfItExists 

If the tag is found and has VR OB, OW, OF, or OD value(s) then they are replaced by cast numeric values from the string, otherwise the nothing is set; the value representation is not changed.

SetOtherValuesIfItExistsOtherwiseAdd 

The tag is set/recreated with the given OtherVR and the values from the modification string are cast and set as values; this modes also sets the value representation.

Definition at line 29 of file mlDicomModifyOrdinary.h.

Constructor & Destructor Documentation

◆ DicomModifyOrdinary()

ml::DicomModifyOrdinary::DicomModifyOrdinary ( DCMTree::TagId  tagId = DCMTree::TagId(),
const std::string &  modStrVal = "",
ModificationModes  modMode = DoNotModify,
bool  splitMode = false 
)

Constructor setting TagId, ModificationStringValue(""), splitMode(false), and ModificationMode(DoNotModify).

Member Function Documentation

◆ applyModifications()

std::string ml::DicomModifyOrdinary::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::DicomModifyOrdinary::getModificationMode ( ) const

Returns the currently set modification mode.

◆ getOtherVR()

DCMTree::Vr ml::DicomModifyOrdinary::getOtherVR ( ) const

Returns the currently set otherVR.

◆ getSplitMode()

bool ml::DicomModifyOrdinary::getSplitMode ( ) const

Returns whether split mode is on.

◆ setModificationMode()

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

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

◆ setOtherVR()

void ml::DicomModifyOrdinary::setOtherVR ( DCMTree::Vr  otherVr)

Sets the value representation to be used for (re)created "Other" tags.

◆ setSplitMode()

void ml::DicomModifyOrdinary::setSplitMode ( bool  split)

If true then completely set values are split at backslashes into different values.

Member Data Documentation

◆ ModificationModesStrings

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

String versions for ModificationModes.

Definition at line 56 of file mlDicomModifyOrdinary.h.


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