private static void SetSequenceAttribute(AttributeSet attributeSet, SetParameterGroup setParameterGroup) { foreach (Object parameter in setParameterGroup.values) { // Check if all parameters are of type sequence item. if (!(parameter is SequenceItem)) { DvtkHighLevelInterfaceException.Throw("Error while setting the Sequence attribute with tag " + setParameterGroup.tagAsString + ". Only sequence items are allowed as parameters."); } } ValidAttribute sequenceAttribute = new ValidAttribute(setParameterGroup.tagAsUInt32, VR.SQ); foreach (SequenceItem sequenceItem in setParameterGroup.values) { sequenceAttribute.AddItem(sequenceItem); } attributeSet.Set(sequenceAttribute); }
public void DeleteAttribute(String tagSequence) { AttributeSet attributeSet = GetAttributeSet(tagSequence); }
/// <summary> /// Get the attribute set this attribute belongs to. /// TODO!!: merge this code with GetAttribute method. /// </summary> /// <param name="tagSequence"></param> /// <returns></returns> internal AttributeSet GetAttributeSet(String tagSequence) { Tag[] tags; Attribute attribute = null; tags = Tag.InterpretTagSequence(tagSequence); AttributeSet currentAttributeSet = this; String currentTagSequence = ""; String currentTagSequenceLastTagNoIndex = ""; foreach (Tag tag in tags) { // Set the currentTagSequence. if (currentTagSequence == "") { currentTagSequence = tag.TagAsString; currentTagSequenceLastTagNoIndex = tag.TagWithoutIndex; } else { currentTagSequence += "/" + tag.TagAsString; currentTagSequenceLastTagNoIndex = currentTagSequence + "/" + tag.TagWithoutIndex; } // Create the correct Attribute object. DvtkData.Dimse.Attribute dvtkDataAttribute = currentAttributeSet.dvtkDataAttributeSet.GetAttribute(tag.TagAsUInt32); if (dvtkDataAttribute == null) { attribute = null; break; } else { attribute = Attribute.GetAttribute(tagSequence, dvtkDataAttribute); } // If this tag contains an index, check that the attribute is a sequence attribute // and retrieve the correct attribute set from it. if (tag.ContainsIndex) { if (attribute is SequenceAttribute) { SequenceAttribute sequenceAttribute = attribute as SequenceAttribute; if (tag.Index > sequenceAttribute.ItemCount) { String errorText = "Sequence attribute with tag sequence " + currentTagSequenceLastTagNoIndex + " contains " + sequenceAttribute.ItemCount.ToString() + " items."; errorText += "\r\nThe script however is expecting it to have an item with index " + tag.Index.ToString() + "."; // InterfaceLogging.WriteError(errorText); attribute = null; break; } else { currentAttributeSet = sequenceAttribute.GetItem(tag.Index); } } else { String errorText = "Attribute with tag sequence " + currentTagSequenceLastTagNoIndex + " is not a sequence attribute."; errorText += "\r\nThe script however is expecting it because the tag sequence " + currentTagSequence + " contains an index."; // InterfaceLogging.WriteError(errorText); attribute = null; break; } } } return(currentAttributeSet); }