Esempio n. 1
0
        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)
            {
                SimpleAttribute simpleAttribute = new SimpleAttribute(setParameterGroup.tagAsUInt32, setParameterGroup.vR, attributeValuesAsStrings.ToArray());
                attributeSet.Set(simpleAttribute);
            }
        }
Esempio n. 2
0
        //
        // - Methods -
        //



        /// <summary>
        /// Get the HLI Attribute, given a DvtkData attribute.
        /// </summary>
        /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/') of this attribue.</param>
        /// <param name="dvtkDataAttribute">The DvtkData attribute.</param>
        /// <returns>The HLI Attribute.</returns>
        public static Attribute GetAttribute(String tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute)
        {
            Attribute attribute = null;

            switch (dvtkDataAttribute.ValueRepresentation)
            {
            // These cases handles the "simple" attributes.
            case VR.AE:                     // Application Entity
            case VR.AS:                     // Age String
            case VR.AT:                     // Attribute Tag
            case VR.CS:                     // Code String
            case VR.DA:                     // Date
            case VR.DS:                     // Decimal String
            case VR.DT:                     // Date Time
            case VR.FL:                     // Floating Point Single
            case VR.FD:                     // Floating Point Double
            case VR.IS:                     // Integer String
            case VR.LO:                     // Long String
            case VR.LT:                     // Long Text
            case VR.PN:                     // Person Name
            case VR.SH:                     // Short String
            case VR.SL:                     // Signed Long
            case VR.SS:                     // Signed Short
            case VR.ST:                     // Short Text
            case VR.TM:                     // Time
            case VR.UI:                     // Unique Identifier (UID)
            case VR.UL:                     // Unsigned Long
            case VR.US:                     // Unsigned Short
            case VR.UT:                     // Unlimited Text
                attribute = new SimpleAttribute(tagSequence, dvtkDataAttribute);
                break;

            // These cases handles the pixel data attributes.
            case VR.OB:                     // Other Byte String
            case VR.OF:                     // Other Float String
            case VR.OW:                     // Other Word String
                attribute = new PixelDataAttribute(tagSequence, dvtkDataAttribute);
                break;

            // This case handles the sequence attributes.
            case VR.SQ:                     // Sequence of Items
                attribute = new SequenceAttribute(tagSequence, dvtkDataAttribute);
                break;

            // This case handles the unknown attributes.
            case VR.UN:                     // Unknown
                attribute = new UnknownAttribute(tagSequence, dvtkDataAttribute);
                break;

            default:
                attribute = null;
                break;
            }

            return(attribute);
        }
Esempio n. 3
0
        /// <summary>
        /// Get the Value Multiplicity of an Attribute.
        /// </summary>
        /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/').</param>
        /// <returns>The Value Multiplicity.</returns>
        public int GetAttributeVm(String tagSequence)
        {
            // Start Interface logging.
            // InterfaceLogging.Start(this, tagSequence);

            int vm = 0;

            Attribute attribute = GetAttribute(tagSequence);

            // If attribute does not exist...
            if (attribute == null)
            {
                // InterfaceLogging.WriteError("Attribute does not exist.\r\nReturning 0 as VM.");

                vm = 0;
            }
            // If attribute exists...
            else
            {
                if (attribute is SimpleAttribute)
                {
                    SimpleAttribute simpleAttribute = attribute as SimpleAttribute;

                    vm = simpleAttribute.GetValues().Count;
                }
                else if (attribute is PixelDataAttribute)
                {
                    // InterfaceLogging.WriteWarning("Determining of VM not implemented for pixel data attributes in the High Level Interface./r/nReturning 1");
                    vm = 1;
                }
                else if (attribute is SequenceAttribute)
                {
                    // InterfaceLogging.WriteWarning("Determining of VM not implemented for sequence attributes with VR in the High Level Interface./r/nReturning 1");
                    vm = 1;
                }
                else if (attribute is UnknownAttribute)
                {
                    // InterfaceLogging.WriteWarning("Determining of VM not implemented for attributes with VR Unknown in the High Level Interface./r/nReturning 1");
                    vm = 1;
                }
                else
                {
                    DvtkHighLevelInterfaceException.Throw("Not expecting this type of attribute in the code");
                }
            }

            // End Interface logging.
            // InterfaceLogging.End(vm);

            return(vm);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        //
        // - Methods -
        //
        /// <summary>
        /// Get the HLI Attribute, given a DvtkData attribute.
        /// </summary>
        /// <param name="tagSequence">The tag sequence (one or more tags seperated with an '/') of this attribue.</param>
        /// <param name="dvtkDataAttribute">The DvtkData attribute.</param>
        /// <returns>The HLI Attribute.</returns>
        public static Attribute GetAttribute(String tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute)
        {
            Attribute attribute = null;

            switch(dvtkDataAttribute.ValueRepresentation)
            {
                    // These cases handles the "simple" attributes.
                case VR.AE: // Application Entity
                case VR.AS: // Age String
                case VR.AT: // Attribute Tag
                case VR.CS: // Code String
                case VR.DA: // Date
                case VR.DS: // Decimal String
                case VR.DT: // Date Time
                case VR.FL: // Floating Point Single
                case VR.FD: // Floating Point Double
                case VR.IS: // Integer String
                case VR.LO: // Long String
                case VR.LT: // Long Text
                case VR.PN: // Person Name
                case VR.SH: // Short String
                case VR.SL: // Signed Long
                case VR.SS: // Signed Short
                case VR.ST: // Short Text
                case VR.TM: // Time
                case VR.UI: // Unique Identifier (UID)
                case VR.UL: // Unsigned Long
                case VR.US: // Unsigned Short
                case VR.UT: // Unlimited Text
                    attribute = new SimpleAttribute(tagSequence, dvtkDataAttribute);
                    break;

                    // These cases handles the pixel data attributes.
                case VR.OB: // Other Byte String
                case VR.OF: // Other Float String
                case VR.OW: // Other Word String
                    attribute = new PixelDataAttribute(tagSequence, dvtkDataAttribute);
                    break;

                    // This case handles the sequence attributes.
                case VR.SQ: // Sequence of Items
                    attribute = new SequenceAttribute(tagSequence, dvtkDataAttribute);
                    break;

                    // This case handles the unknown attributes.
                case VR.UN: // Unknown
                    attribute = new UnknownAttribute(tagSequence, dvtkDataAttribute);
                    break;

                default:
                    attribute = null;
                    break;
            }

            return attribute;
        }
Esempio n. 6
0
        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)
            {
                SimpleAttribute simpleAttribute = new SimpleAttribute(setParameterGroup.tagAsUInt32, setParameterGroup.vR, attributeValuesAsStrings.ToArray());
                attributeSet.Set(simpleAttribute);
            }
        }