MeVisLab Toolbox Reference
ml::DicomModifyBase Class Reference

A base class which allows the modification of DICOM tags in a (cloned) DICOM tree. More...

#include <mlDicomModifyBase.h>

Inheritance diagram for ml::DicomModifyBase:
ml::DicomModifyOrdinary ml::DicomModifyOtherTagOperations ml::DicomModifyPrivateAdd ml::DicomModifyPrivateRemove ml::DicomModifySequence

Public Member Functions

 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...
 
virtual std::string applyModifications (DCMTree::TreePtr dcmTree, const FieldContainer *treeInfos=nullptr)
 Apply a change to the given dcmTree. 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...
 

Detailed Description

A base class which allows the modification of DICOM tags in a (cloned) DICOM tree.


Definition at line 35 of file mlDicomModifyBase.h.

Constructor & Destructor Documentation

◆ DicomModifyBase()

ml::DicomModifyBase::DicomModifyBase ( DCMTree::TagId  tagId = DCMTree::TagId(),
const std::string &  modStrVal = "" 
)

Constructor setting the tag ID and the string value for modifications.

◆ ~DicomModifyBase()

virtual ml::DicomModifyBase::~DicomModifyBase ( )
virtual

Virtual destructor.

Member Function Documentation

◆ addTag()

DCMTree::TagPtr ml::DicomModifyBase::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.

Parameters
dcmTreeThe DICOM tree to which the tag shall be added.
errStrIf nullptr then potential errors will be posted as ML_PRINT_ERROR, otherwise the error description will be appended to *errStr.
setValueIf true then the value is set from the given string, otherwise no value is set.
splitValueIf true then the value is decomposed at backslashes, otherwise one value is set/added.
Returns
A null tag pointer on failure or the pointer to the created tag.

◆ applyModifications()

virtual std::string ml::DicomModifyBase::applyModifications ( DCMTree::TreePtr  dcmTree,
const FieldContainer treeInfos = nullptr 
)
virtual

Apply a change to the given dcmTree.

If this is overwritten in derived classes, this base class version should be called first, because it sets up tag values for subsequent operations.

Parameters
dcmTreeThe DICOM tree to be modified.
treeInfosA FieldContainer which - if not nullptr - can contain additional user defined information fields about dcmTree. Special field values:
  • String field with name "modificationStringValueReplacement" replaces the value returned by getModificationStringValue() until applyModifications is called the next time or it is set again with set[TagIdAnd]ModificationStringValue().
  • String field with name "modificationTagIdReplacement" replaces the value returned by getTagId() until applyModifications is called the next time or it is set again with setTagId[AndModificationStringValue]().
Returns
An empty string on success, otherwise a cumulative descriptive string of all problems.

Reimplemented in ml::DicomModifySequence, ml::DicomModifyPrivateRemove, ml::DicomModifyPrivateAdd, ml::DicomModifyOtherTagOperations, and ml::DicomModifyOrdinary.

◆ getModificationStringValue()

const std::string& ml::DicomModifyBase::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()).

◆ getModificationStringValueAsMLInt()

bool ml::DicomModifyBase::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.

The conversion is performed with bool StringConversion::readFromString(value, intVal);

◆ getTagId()

DCMTree::TagId ml::DicomModifyBase::getTagId ( ) const

Returns the id of the tag to be modified (might be temporarily overridden be a "modificationTagIdReplacement" field in treeInfos parameter of applyModifications()).

◆ getTagIfItExists()

DCMTree::TagPtr ml::DicomModifyBase::getTagIfItExists ( DCMTree::TreePtr  dcmTree,
std::string *  errStr = nullptr 
) const
Parameters
dcmTreeThe DCMTree in which the tag shall be searched; must be non nullptr.
errStrIf nullptr then potential errors will be posted as ML_PRINT_ERROR, otherwise the error description will be appended to *errStr.
Returns
the tag with currently given getTagId() if it exists, otherwise return nullptr without considering this as an error.

◆ removeTag()

void ml::DicomModifyBase::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).

Parameters
dcmTreeThe DICOM tree from which the tag shall be removed.

◆ setModificationStringValue()

void ml::DicomModifyBase::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.

◆ setTagId() [1/2]

void ml::DicomModifyBase::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).

◆ setTagId() [2/2]

void ml::DicomModifyBase::setTagId ( DCMTree::TagId  tagId)

Set the id of the tag to be modified.

◆ setTagIdAndModificationStringValue()

void ml::DicomModifyBase::setTagIdAndModificationStringValue ( DCMTree::TagId  tagId,
const std::string &  modStrVal 
)

Calls setTagId(tagId) and setModificationStringValue(modStrVal).

◆ setTagValue()

void ml::DicomModifyBase::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.

Requires a valid non nullptr dcmTree.

Parameters
dcmTreeThe DICOM tree in which the tag value shall be set.
errStrIf nullptr then potential errors will be posted as ML_PRINT_ERROR, otherwise the error description will be appended to *errStr.
splitValueIf true then the value is decomposed at backslashes, otherwise one value is set/added.
modModeThe way how the tag value shall be modified.

◆ tagExists()

bool ml::DicomModifyBase::tagExists ( DCMTree::TreePtr  dcmTree) const
Parameters
dcmTreeThe DCMTree in which the tagId shall be searched (false is returned if dcmTree is nullptr).
Returns
true if dcmTree is valid and it contains a tag with ID getTagId(), otherwise false is returned.

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