// // - Methods - // /// <summary> /// Check if the supplied values are equal to the content of this object. /// </summary> /// <param name="values">Values to compare with.</param> /// <returns>Boolean indicating if the Values are equal.</returns> public override bool EqualTo(Values values) { // Start Interface logging. // InterfaceLogging.Start(this, values); bool equalTo = true; if (values is InvalidValues) { InvalidValues attributeToCompareWith = values as InvalidValues; // InterfaceLogging.WriteError("Comparing the values of two non-existing attributes with tag sequence " + this.TagSequence + " and " + attributeToCompareWith.TagSequence + "\r\nReturning true."); equalTo = true; } else if (values is ValidValues) { ValidValues validValues = values as ValidValues; // InterfaceLogging.WriteError("Comparing the value of a non-existing sttribute with tag " + this.TagSequence + " with valid values from attribute with tag " + validValues.TagSequence + ".\r\nReturning false."); equalTo = false; } else { // InterfaceLogging.WriteError("This type of Values descendant object not expected. Returning false."); equalTo = false; } // End Interface logging. // InterfaceLogging.End(equalTo); return(equalTo); }
private static void SetSimpleAttribute(AttributeSet attributeSet, SetParameterGroup setParameterGroup) { ArrayList attributeValuesAsStrings = new ArrayList(); bool validStringValues = true; foreach (Object parameter in setParameterGroup.values) { if (parameter is ValidValues) { ValidValues validValues = parameter as ValidValues; for (int valueIndex = 1; valueIndex <= validValues.Count; valueIndex++) { attributeValuesAsStrings.Add(validValues.GetString(valueIndex)); } } else if (parameter is InvalidValues) { InvalidValues invalidValues = parameter as InvalidValues; // InterfaceLogging.WriteError("Setting an attribute with tag " + setParameterGroup.tagAsString + " fails because one of the supplied values is from a non-existing attribute with tag " + invalidValues.TagSequence); validStringValues = false; break; } else { attributeValuesAsStrings.Add(parameter.ToString()); } } if (validStringValues) { ValidAttribute validAttribute = new ValidAttribute(setParameterGroup.tagAsUInt32, setParameterGroup.vR, attributeValuesAsStrings.ToArray()); attributeSet.Set(validAttribute); } }
public Values GetAttributeValues(int index) { Values theValues = null; Attribute attribute = GetAttribute(index); if (attribute == null) { // InterfaceLogging.WriteError("Attribute does not exist."); // Temporary. theValues = new InvalidValues("0x00000000"); } else { if (attribute is SimpleAttribute) { SimpleAttribute simpleAttribute = attribute as SimpleAttribute; theValues = simpleAttribute.GetValues(); } else if (attribute is PixelDataAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for pixel data attributes in the High Level Interface./r/nReturning single empty string"); // Temporary. theValues = new ValidValues("0x00000000", ""); } else if (attribute is SequenceAttribute) { // InterfaceLogging.WriteError("Attribute with tag sequence " + tagSequence + " is a sequence attribute."); // Temporary. theValues = new InvalidValues("0x00000000"); } else if (attribute is UnknownAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for attributes with VR Unknown in the High Level Interface./r/nReturning single empty string"); // Temporary. theValues = new ValidValues("0x00000000", ""); } else { DvtkHighLevelInterfaceException.Throw("Not expecting this type of attribute in the code"); } } // End Interface logging. // InterfaceLogging.End(theValues); return(theValues); }
/// <summary> /// Check if the supplied values are equal to the content of this object. /// </summary> /// <param name="values">Values to compare with.</param> /// <returns>Boolean indicating if the Values are equal.</returns> public override bool EqualTo(Values values) { // Start Interface logging. // InterfaceLogging.Start(this, values); bool equalTo = true; if (values is InvalidValues) { InvalidValues invalidValues = values as InvalidValues; // InterfaceLogging.WriteError("the values to compare with are from a non-existing attribute with tag sequence" + invalidValues.TagSequence + ".\r\nReturning false."); equalTo = false; } else if (values is ValidValues) { ValidValues validValues = values as ValidValues; if (Count == validValues.Count) { for (int index = 1; index <= Count; index++) { if (GetString(index) != validValues.GetString(index)) { equalTo = false; break; } } } else { equalTo = false; } } else { // InterfaceLogging.WriteError("This type of Values descendant object not expected.\r\n Returning false."); equalTo = false; } // End Interface logging. // InterfaceLogging.End(equalTo); return(equalTo); }
// // - Methods - // /// <summary> /// Get the values from this attribute. /// </summary> /// <returns>The values.</returns> public ValidValues GetValues() { ValidValues validValues = null; switch (dvtkDataAttribute.ValueRepresentation) { case VR.AE: // Application Entity DvtkData.Dimse.ApplicationEntity theApplicationEntity = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ApplicationEntity; validValues = new ValidValues(this.tagSequence, theApplicationEntity.Values); break; case VR.AS: // Age String DvtkData.Dimse.AgeString theAgeString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.AgeString; validValues = new ValidValues(this.tagSequence, theAgeString.Values); break; case VR.AT: // Attribute Tag DvtkData.Dimse.AttributeTag theAttributeTag = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.AttributeTag; validValues = new ValidValues(this.tagSequence, theAttributeTag.Values); break; case VR.CS: // Code String DvtkData.Dimse.CodeString theCodeString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.CodeString; validValues = new ValidValues(this.tagSequence, theCodeString.Values); break; case VR.DA: // Date DvtkData.Dimse.Date theDate = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.Date; validValues = new ValidValues(this.tagSequence, theDate.Values); break; case VR.DS: // Decimal String DvtkData.Dimse.DecimalString theDecimalString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.DecimalString; validValues = new ValidValues(this.tagSequence, theDecimalString.Values); break; case VR.DT: // Date Time DvtkData.Dimse.DateTime theDateTime = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.DateTime; validValues = new ValidValues(this.tagSequence, theDateTime.Values); break; case VR.FD: // Floating Point Double DvtkData.Dimse.FloatingPointDouble theFloatingPointDouble = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.FloatingPointDouble; validValues = new ValidValues(this.tagSequence, theFloatingPointDouble.Values); break; case VR.FL: // Floating Point Single DvtkData.Dimse.FloatingPointSingle theFloatingPointSingle = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.FloatingPointSingle; validValues = new ValidValues(this.tagSequence, theFloatingPointSingle.Values); break; case VR.IS: // Integer String DvtkData.Dimse.IntegerString theIntegerString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.IntegerString; validValues = new ValidValues(this.tagSequence, theIntegerString.Values); break; case VR.LO: // Long String DvtkData.Dimse.LongString theLongString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.LongString; validValues = new ValidValues(this.tagSequence, theLongString.Values); break; case VR.LT: // Long Text DvtkData.Dimse.LongText theLongText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.LongText; validValues = new ValidValues(this.tagSequence, theLongText.Value); break; case VR.PN: // Person Name DvtkData.Dimse.PersonName thePersonName = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.PersonName; validValues = new ValidValues(this.tagSequence, thePersonName.Values); break; case VR.SH: // Short String DvtkData.Dimse.ShortString theShortString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ShortString; validValues = new ValidValues(this.tagSequence, theShortString.Values); break; case VR.SL: // Signed Long DvtkData.Dimse.SignedLong theSignedLong = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.SignedLong; validValues = new ValidValues(this.tagSequence, theSignedLong.Values); break; case VR.SS: // Signed Short DvtkData.Dimse.SignedShort theSignedShort = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.SignedShort; validValues = new ValidValues(this.tagSequence, theSignedShort.Values); break; case VR.ST: // Short Text DvtkData.Dimse.ShortText theShortText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ShortText; validValues = new ValidValues(this.tagSequence, theShortText.Value); break; case VR.TM: // Time DvtkData.Dimse.Time theTime = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.Time; validValues = new ValidValues(this.tagSequence, theTime.Values); break; case VR.UI: // Unique Identifier (UID) DvtkData.Dimse.UniqueIdentifier theUniqueIdentifier = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UniqueIdentifier; validValues = new ValidValues(this.tagSequence, theUniqueIdentifier.Values); break; case VR.UL: // Unsigned Long DvtkData.Dimse.UnsignedLong theUnsignedLong = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnsignedLong; validValues = new ValidValues(this.tagSequence, theUnsignedLong.Values); break; case VR.US: // Unsigned Short DvtkData.Dimse.UnsignedShort theUnsignedShort = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnsignedShort; validValues = new ValidValues(this.tagSequence, theUnsignedShort.Values); break; case VR.UT: // Unlimited Text DvtkData.Dimse.UnlimitedText theUnlimitedText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnlimitedText; validValues = new ValidValues(this.tagSequence, theUnlimitedText.Value); break; default: DvtkHighLevelInterfaceException.Throw("VR " + dvtkDataAttribute.ValueRepresentation.ToString() + " is not handled by class SimpleAttribute."); break; } return(validValues); }
// // - Methods - // /// <summary> /// Get the values from this attribute. /// </summary> /// <returns>The values.</returns> public ValidValues GetValues() { ValidValues validValues = null; switch(dvtkDataAttribute.ValueRepresentation) { case VR.AE: // Application Entity DvtkData.Dimse.ApplicationEntity theApplicationEntity = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ApplicationEntity; validValues = new ValidValues(this.tagSequence, theApplicationEntity.Values); break; case VR.AS: // Age String DvtkData.Dimse.AgeString theAgeString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.AgeString; validValues = new ValidValues(this.tagSequence, theAgeString.Values); break; case VR.AT: // Attribute Tag DvtkData.Dimse.AttributeTag theAttributeTag = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.AttributeTag; validValues = new ValidValues(this.tagSequence, theAttributeTag.Values); break; case VR.CS: // Code String DvtkData.Dimse.CodeString theCodeString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.CodeString; validValues = new ValidValues(this.tagSequence, theCodeString.Values); break; case VR.DA: // Date DvtkData.Dimse.Date theDate = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.Date; validValues = new ValidValues(this.tagSequence, theDate.Values); break; case VR.DS: // Decimal String DvtkData.Dimse.DecimalString theDecimalString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.DecimalString; validValues = new ValidValues(this.tagSequence, theDecimalString.Values); break; case VR.DT: // Date Time DvtkData.Dimse.DateTime theDateTime = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.DateTime; validValues = new ValidValues(this.tagSequence, theDateTime.Values); break; case VR.FD: // Floating Point Double DvtkData.Dimse.FloatingPointDouble theFloatingPointDouble = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.FloatingPointDouble; validValues = new ValidValues(this.tagSequence, theFloatingPointDouble.Values); break; case VR.FL: // Floating Point Single DvtkData.Dimse.FloatingPointSingle theFloatingPointSingle = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.FloatingPointSingle; validValues = new ValidValues(this.tagSequence, theFloatingPointSingle.Values); break; case VR.IS: // Integer String DvtkData.Dimse.IntegerString theIntegerString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.IntegerString; validValues = new ValidValues(this.tagSequence, theIntegerString.Values); break; case VR.LO: // Long String DvtkData.Dimse.LongString theLongString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.LongString; validValues = new ValidValues(this.tagSequence, theLongString.Values); break; case VR.LT: // Long Text DvtkData.Dimse.LongText theLongText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.LongText; validValues = new ValidValues(this.tagSequence, theLongText.Value); break; case VR.PN: // Person Name DvtkData.Dimse.PersonName thePersonName = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.PersonName; validValues = new ValidValues(this.tagSequence, thePersonName.Values); break; case VR.SH: // Short String DvtkData.Dimse.ShortString theShortString = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ShortString; validValues = new ValidValues(this.tagSequence, theShortString.Values); break; case VR.SL: // Signed Long DvtkData.Dimse.SignedLong theSignedLong = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.SignedLong; validValues = new ValidValues(this.tagSequence, theSignedLong.Values); break; case VR.SS: // Signed Short DvtkData.Dimse.SignedShort theSignedShort = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.SignedShort; validValues = new ValidValues(this.tagSequence, theSignedShort.Values); break; case VR.ST: // Short Text DvtkData.Dimse.ShortText theShortText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.ShortText; validValues = new ValidValues(this.tagSequence, theShortText.Value); break; case VR.TM: // Time DvtkData.Dimse.Time theTime = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.Time; validValues = new ValidValues(this.tagSequence, theTime.Values); break; case VR.UI: // Unique Identifier (UID) DvtkData.Dimse.UniqueIdentifier theUniqueIdentifier = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UniqueIdentifier; validValues = new ValidValues(this.tagSequence, theUniqueIdentifier.Values); break; case VR.UL: // Unsigned Long DvtkData.Dimse.UnsignedLong theUnsignedLong = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnsignedLong; validValues = new ValidValues(this.tagSequence, theUnsignedLong.Values); break; case VR.US: // Unsigned Short DvtkData.Dimse.UnsignedShort theUnsignedShort = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnsignedShort; validValues = new ValidValues(this.tagSequence, theUnsignedShort.Values); break; case VR.UT: // Unlimited Text DvtkData.Dimse.UnlimitedText theUnlimitedText = this.dvtkDataAttribute.DicomValue as DvtkData.Dimse.UnlimitedText; validValues = new ValidValues(this.tagSequence, theUnlimitedText.Value); break; default: DvtkHighLevelInterfaceException.Throw("VR " + dvtkDataAttribute.ValueRepresentation.ToString() + " is not handled by class SimpleAttribute."); break; } return(validValues); }
/// <summary> /// Get the values for an attribute. /// </summary> /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/').</param> /// <returns>The values.</returns> public Values GetAttributeValues(String tagSequence) { // Start Interface logging. // InterfaceLogging.Start(this, tagSequence); Values theValues = null; Attribute attribute = GetAttribute(tagSequence); if (attribute == null) { // InterfaceLogging.WriteError("Attribute does not exist."); theValues = new InvalidValues(tagSequence); } else { if (attribute is SimpleAttribute) { SimpleAttribute simpleAttribute = attribute as SimpleAttribute; theValues = simpleAttribute.GetValues(); } else if (attribute is PixelDataAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for pixel data attributes in the High Level Interface./r/nReturning single empty string"); theValues = new ValidValues(tagSequence, ""); } else if (attribute is SequenceAttribute) { // InterfaceLogging.WriteError("Attribute with tag sequence " + tagSequence + " is a sequence attribute."); theValues = new InvalidValues(tagSequence); } else if (attribute is UnknownAttribute) { // InterfaceLogging.WriteWarning("Getting values not implemented for attributes with VR Unknown in the High Level Interface./r/nReturning single empty string"); theValues = new ValidValues(tagSequence, ""); } else { DvtkHighLevelInterfaceException.Throw("Not expecting this type of attribute in the code"); } } // End Interface logging. // InterfaceLogging.End(theValues); return theValues; }