Exemple #1
0
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Add a row containing the result of comparing the two supplied attributes.
        /// </summary>
        /// <param name="attribute1">Attribute 1.</param>
        /// <param name="attribute2">Attribute 2.</param>
        /// <param name="level">-</param>
        private void AddAttributesComparison(ValidAttribute attribute1, ValidAttribute attribute2, int level)
        {
            table.NewRow();

            //
            // Fill in the general tag information.
            //

            ValidAttribute attribute = null;

            if (attribute1 != null)
            {
                attribute = attribute1;
            }
            else
            {
                attribute = attribute2;
            }

            String name = "-";

            if ((attribute.Name != "") && !(attribute.Name.StartsWith(" : private mapped to")))
            {
                name = "\"" + attribute.Name + "\"";
            }

            SetCellOK(this.columnIndexTag, attribute.TagSequence.DicomNotation, true);
            SetCellOK(this.columnIndexName, name, true);

            //
            // Fill in the information for the two attributes.
            //

            bool areEqual = true;

            areEqual = AddAttributeInformation(attribute1, attribute2, true);
            AddAttributeInformation(attribute2, attribute1, false);

            //
            // Find out if at least one of the attributes is a sequence attribute.
            //

            bool containsAtLeastOneSequenceAttribute = false;

            if (attribute1 != null)
            {
                if (attribute1.VR == VR.SQ)
                {
                    containsAtLeastOneSequenceAttribute = true;
                }
            }

            if (attribute2 != null)
            {
                if (attribute2.VR == VR.SQ)
                {
                    containsAtLeastOneSequenceAttribute = true;
                }
            }

            //
            // If at least one attribute is a sequence attribute, do a comparison of the content.
            // If the other attribute is null or is not a sequence attribute, use an
            // empty sequence attribute instead.
            //

            if (containsAtLeastOneSequenceAttribute)
            {
                Attribute sequenceAttribute1 = ConvertToSequenceAttribute(attribute1);
                Attribute sequenceAttribute2 = ConvertToSequenceAttribute(attribute2);

                AddSequenceAttributesContentComparison(sequenceAttribute1, sequenceAttribute2, level);
            }

            //
            // Update the differences count.
            //

            if (!areEqual)
            {
                this.differencesCount++;
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a deep copy of this instance.
        /// </summary>
        /// <param name="parentAttributeSetToCloneTo">
        /// The AttributeSet the new cloned Attribute wil become part of.
        /// </param>
        /// <returns>The created deep copy of this instance.</returns>
        internal override Attribute Clone(AttributeSet parentAttributeSetToCloneTo)
        {
            //
            // Clone the attribute without values.
            //

            TagSequence newTagSequence = parentAttributeSetToCloneTo.TagSequence.Clone();

            Tag lastTagCurrentAttribute = TagSequence.Tags[TagSequence.Tags.Count - 1] as Tag;
            newTagSequence.Add(lastTagCurrentAttribute);

            ValidAttribute cloneAttribute = new ValidAttribute(newTagSequence, new DvtkData.Dimse.Attribute(lastTagCurrentAttribute.AsUInt32, (DvtkData.Dimse.VR)this.VR), parentAttributeSetToCloneTo);

            //
            // Add the values or items to the cloned attribute.
            //

            Values currentValues = this.Values;
            Values cloneValues = cloneAttribute.Values;

            if (currentValues.IsImplementedWithCollection)
            {
                Object[] collectionAsArray = new Object[currentValues.CollectionImplementation.Count];

                currentValues.CollectionImplementation.CopyTo(collectionAsArray, 0);

                cloneValues.Add(collectionAsArray);
            }
            else if (currentValues.IsImplementedWithString)
            {
                cloneValues.Add(currentValues.StringImplementation);
            }
            else if ((currentValues.Attribute.VR == VR.OB) || (currentValues.Attribute.VR == VR.OF) || (currentValues.Attribute.VR == VR.OW))
            {
                cloneValues.Add(currentValues);
            }
            else if (this.VR == VR.UN)
            {
                cloneValues.ByteArrayImplementation = currentValues.ByteArrayImplementation;
            }
            else if (this.VR == VR.SQ)
            {
                for (int index = 1; index <= this.ItemCount; index++)
                {
                    // The AddItem will take care that the item is cloned.
                    cloneAttribute.AddItem(this.GetItem(index));
                }
            }
            else
            {
                // Do nothing.
            }

            //
            // Set the Name of the attribute.
            //

            cloneAttribute.Name = Name;

            return(cloneAttribute);
        }
Exemple #3
0
        //
        // - Methods -
        //
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Add attribute information for one attribute in the current row.
        /// </summary>
        /// <param name="sourceAttribute">The attribute for which the information needs to be displayed.</param>
        /// <param name="referenceAttribute">The attribute to compare with.</param>
        /// <param name="isFromFirstAttributeSet">Indicates if the attribute is from the first attribute set.</param>
        /// <returns>Indicates if an compare error was encountered.</returns>
        private bool AddAttributeInformation(ValidAttribute sourceAttribute, ValidAttribute referenceAttribute, bool isFromFirstAttributeSet)
        {
            bool areEqual = true;
            int columnIndexPresent = 0;
            int columnIndexVR = 0;
            int columnIndexValues = 0;

            if (isFromFirstAttributeSet)
            {
                columnIndexPresent = this.columnIndexPresent1;
                columnIndexVR = this.columnIndexVr1;
                columnIndexValues = this.columnIndexValues1;
            }
            else
            {
                columnIndexPresent = this.columnIndexPresent2;
                columnIndexVR = this.columnIndexVr2;
                columnIndexValues = this.columnIndexValues2;
            }

            if (sourceAttribute == null)
                // source attribute is not present, reference attribute is.
            {
                SetCellError(columnIndexPresent, "-", true);
                SetCellNotApplicable(columnIndexVR, this.displayVR);
                SetCellNotApplicable(columnIndexValues, true);
                areEqual = false;
            }
            else
                // Source attribute is present.
            {
                if (referenceAttribute == null)
                    // Source attribute is present, reference attribute is not.
                {
                    SetCellError(columnIndexPresent, "+", true);
                    SetCellOK(columnIndexVR, sourceAttribute.VR.ToString(), this.displayVR);
                    SetCellOK(columnIndexValues, sourceAttribute.Values.ToString(), true);
                    areEqual = false;
                }
                else
                    // Source attribute and reference attribute are both present.
                {
                    SetCellOK(columnIndexPresent, "+", true);

                    if (sourceAttribute.VR == referenceAttribute.VR)
                    {
                        SetCellOK(columnIndexVR, sourceAttribute.VR.ToString(), this.displayVR);
                    }
                    else
                    {
                        SetCellError(columnIndexVR, sourceAttribute.VR.ToString(), this.displayVR);
                        areEqual = false;
                    }

                    if (sourceAttribute.Values.Equals(referenceAttribute.Values))
                    {
                        SetCellOK(columnIndexValues, sourceAttribute.Values.ToString(), true);
                    }
                    else
                    {
                        SetCellError(columnIndexValues, sourceAttribute.Values.ToString(), true);
                        areEqual = false;
                    }
                }
            }

            return(areEqual);
        }