Exemple #1
0
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Compare two attributeSets by putting the compare results in a Table.
        /// </summary>
        /// <param name="tableDescription">The description of the complete table (put in the first table header).</param>
        /// <param name="attributeSet1">The first AttributeSet.</param>
        /// <param name="attributeSet1Description">Description of the first AttributeSet (put in the second table header).</param>
        /// <param name="attributeSet2">The second AttributeSet.</param>
        /// <param name="attributeSet2Description">Description of the second AttributeSet (put in the second table header).</param>
        /// <returns>The result of comparing the two AttributeSets.</returns>
        public Table CompareAttributeSets(String tableDescription, AttributeSet attributeSet1, String attributeSet1Description, AttributeSet attributeSet2, String attributeSet2Description)
        {
            // Start with a new empty table.
            this.table            = null;
            this.differencesCount = 0;

            // To be able to compare correctly, we first make sure the attributes in both attributesets are ascending.
            attributeSet1.MakeAscending(true);
            attributeSet2.MakeAscending(true);

            // Set the correct column indices, headers and pixel widths.
            columnIndexTag  = 1;
            columnIndexName = 2;

            if (this.displayVR)
            {
                this.table = new Table(8);

                columnIndexPresent1 = 3;
                columnIndexVr1      = 4;
                columnIndexValues1  = 5;
                columnIndexPresent2 = 6;
                columnIndexVr2      = 7;
                columnIndexValues2  = 8;

                // Set the headers of the table.
                this.table.AddHeader(tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription);
                this.table.AddHeader("Attribute Info", "Attribute Info", attributeSet1Description, attributeSet1Description, attributeSet1Description, attributeSet2Description, attributeSet2Description, attributeSet2Description);
                this.table.AddHeader("Tag", "Name", "Pr", "VR", "Values", "Pr", "VR", "Values");

                // If the caller of this methods wants to display the table as HTML, then these are already good
                // default values for the widths of the columns.
                this.table.SetColumnPixelWidths(PIXEL_WIDTH_TAG, PIXEL_WIDTH_NAME, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VR, PIXEL_WIDTH_VALUES, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VR, PIXEL_WIDTH_VALUES);
            }
            else
            {
                this.table = new Table(6);

                columnIndexPresent1 = 3;
                columnIndexValues1  = 4;
                columnIndexPresent2 = 5;
                columnIndexValues2  = 6;

                // Set the headers of the table.
                this.table.AddHeader(tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription);
                this.table.AddHeader("Attribute Info", "Attribute Info", attributeSet1Description, attributeSet1Description, attributeSet2Description, attributeSet2Description);
                this.table.AddHeader("Tag", "Name", "Pr", "Values", "Pr", "Values");

                // If the caller of this methods wants to display the table as HTML, then these are already good
                // default values for the widths of the columns.
                this.table.SetColumnPixelWidths(PIXEL_WIDTH_TAG, PIXEL_WIDTH_NAME, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VALUES, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VALUES);
            }

            // Do the actual comparison.
            AddAttributeSetsComparison(attributeSet1, attributeSet2, 0);

            return(this.table);
        }
Exemple #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="tagSequence">The tag sequence of the attribute.</param>
        /// <param name="dvtkDataAttribute">The encapsulated DvtkData attribute.</param>
        /// <param name="parentAttributeSet">The AttributeSet this instance is part of.</param>
        public ValidAttribute(TagSequence tagSequence, DvtkData.Dimse.Attribute dvtkDataAttribute, AttributeSet parentAttributeSet)
        {
            // Sanity check.
            if (dvtkDataAttribute == null)
            {
                throw new ArgumentException("Internal error: dvtkDataAttribute may not be null.");
            }

            // Sanity check.
            if (parentAttributeSet == null)
            {
                throw new ArgumentException("Internal error: parentAttributeSet may not be null.");
            }

            TagSequence             = tagSequence;
            this.dvtkDataAttribute  = dvtkDataAttribute;
            this.parentAttributeSet = parentAttributeSet;
        }
Exemple #3
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 abstract Attribute Clone(AttributeSet parentAttributeSetToCloneTo);
Exemple #4
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)
        {
            InvalidAttribute cloneInvalidAttribute = new InvalidAttribute();

            return(cloneInvalidAttribute);
        }
Exemple #5
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 #6
0
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Add the results of comparing the two AttributeSets (possibly within multiple nested Sequence Attributes)
        /// to the the already filled table.
        /// </summary>
        /// <param name="attributeSet1">The first AttributeSet.</param>
        /// <param name="attributeSet2">The second AttributeSet.</param>
        /// <param name="level">-</param>
        private void AddAttributeSetsComparison(AttributeSet attributeSet1, AttributeSet attributeSet2, int level)
        {
            //
            // Iterate through all attributes of both AttributeSets at the same time.
            //

            int index1 = 0;
            int index2 = 0;

            while ((index1 < attributeSet1.Count) || (index2 < attributeSet2.Count))
            {
                if (index1 >= attributeSet1.Count)
                // No more attributes left in attributeSet1.
                {
                    ValidAttribute validAttribute2 = attributeSet2[index2] as ValidAttribute;

                    AddAttributesComparison(null, validAttribute2, level);

                    index2++;
                }
                else if (index2 >= attributeSet2.Count)
                // No more attributes left in attributeSet2.
                {
                    ValidAttribute validAttribute1 = attributeSet1[index1] as ValidAttribute;

                    AddAttributesComparison(validAttribute1, null, level);

                    index1++;
                }
                else
                // Still attributes left in both AttributeSets.
                {
                    ValidAttribute validAttribute1 = attributeSet1[index1] as ValidAttribute;
                    ValidAttribute validAttribute2 = attributeSet2[index2] as ValidAttribute;

                    Tag lastTag1 = validAttribute1.TagSequence[validAttribute1.TagSequence.Tags.Count - 1] as Tag;
                    Tag lastTag2 = validAttribute2.TagSequence[validAttribute2.TagSequence.Tags.Count - 1] as Tag;

                    if (lastTag1.AsUInt32 < lastTag2.AsUInt32)
                    // Attribute not present in AttributeSet2.
                    {
                        AddAttributesComparison(validAttribute1, null, level);

                        index1++;
                    }
                    else if (lastTag1.AsUInt32 > lastTag2.AsUInt32)
                    // Attribute not present in AttributeSet1.
                    {
                        AddAttributesComparison(null, validAttribute2, level);

                        index2++;
                    }
                    else
                    // Attribute exists in both AttributeSets.
                    {
                        AddAttributesComparison(validAttribute1, validAttribute2, level);

                        index1++;
                        index2++;
                    }
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Add the results of comparing the two AttributeSets (possibly within multiple nested Sequence Attributes)
        /// to the the already filled table.
        /// </summary>
        /// <param name="attributeSet1">The first AttributeSet.</param>
        /// <param name="attributeSet2">The second AttributeSet.</param> 
        /// <param name="level">-</param>  
        private void AddAttributeSetsComparison(AttributeSet attributeSet1, AttributeSet attributeSet2, int level)
        {
            //
            // Iterate through all attributes of both AttributeSets at the same time.
            //

            int index1 = 0;
            int index2 = 0;

            while ((index1 < attributeSet1.Count) || (index2 < attributeSet2.Count))
            {
                if (index1 >= attributeSet1.Count)
                    // No more attributes left in attributeSet1.
                {
                    ValidAttribute validAttribute2 = attributeSet2[index2] as ValidAttribute;

                    AddAttributesComparison(null, validAttribute2, level);

                    index2++;
                }
                else if (index2 >= attributeSet2.Count)
                    // No more attributes left in attributeSet2.
                {
                    ValidAttribute validAttribute1 = attributeSet1[index1] as ValidAttribute;

                    AddAttributesComparison(validAttribute1, null, level);

                    index1++;
                }
                else
                    // Still attributes left in both AttributeSets.
                {
                    ValidAttribute validAttribute1 = attributeSet1[index1] as ValidAttribute;
                    ValidAttribute validAttribute2 = attributeSet2[index2] as ValidAttribute;

                    Tag lastTag1 = validAttribute1.TagSequence[validAttribute1.TagSequence.Tags.Count - 1] as Tag;
                    Tag lastTag2 = validAttribute2.TagSequence[validAttribute2.TagSequence.Tags.Count - 1] as Tag;

                    if (lastTag1.AsUInt32 < lastTag2.AsUInt32)
                        // Attribute not present in AttributeSet2.
                    {
                        AddAttributesComparison(validAttribute1, null, level);

                        index1++;
                    }
                    else if (lastTag1.AsUInt32 > lastTag2.AsUInt32)
                        // Attribute not present in AttributeSet1.
                    {
                        AddAttributesComparison(null, validAttribute2, level);

                        index2++;
                    }
                    else
                        // Attribute exists in both AttributeSets.
                    {
                        AddAttributesComparison(validAttribute1, validAttribute2, level);

                        index1++;
                        index2++;
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// Obsolete class, use the classes in the namespace DvtkHighLevelInterface.Common.Compare instead.
        /// <br></br>
        /// Compare two attributeSets by putting the compare results in a Table.
        /// </summary>
        /// <param name="tableDescription">The description of the complete table (put in the first table header).</param>
        /// <param name="attributeSet1">The first AttributeSet.</param>
        /// <param name="attributeSet1Description">Description of the first AttributeSet (put in the second table header).</param>
        /// <param name="attributeSet2">The second AttributeSet.</param>
        /// <param name="attributeSet2Description">Description of the second AttributeSet (put in the second table header).</param>
        /// <returns>The result of comparing the two AttributeSets.</returns>
        public Table CompareAttributeSets(String tableDescription, AttributeSet attributeSet1, String attributeSet1Description, AttributeSet attributeSet2, String attributeSet2Description)
        {
            // Start with a new empty table.
            this.table = null;
            this.differencesCount = 0;

            // To be able to compare correctly, we first make sure the attributes in both attributesets are ascending.
            attributeSet1.MakeAscending(true);
            attributeSet2.MakeAscending(true);

            // Set the correct column indices, headers and pixel widths.
            columnIndexTag = 1;
            columnIndexName = 2;

            if (this.displayVR)
            {
                this.table = new Table(8);

                columnIndexPresent1 = 3;
                columnIndexVr1 = 4;
                columnIndexValues1 = 5;
                columnIndexPresent2 = 6;
                columnIndexVr2 = 7;
                columnIndexValues2 = 8;

                // Set the headers of the table.
                this.table.AddHeader(tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription);
                this.table.AddHeader("Attribute Info", "Attribute Info", attributeSet1Description, attributeSet1Description, attributeSet1Description, attributeSet2Description, attributeSet2Description, attributeSet2Description);
                this.table.AddHeader("Tag", "Name", "Pr", "VR", "Values", "Pr", "VR", "Values");

                // If the caller of this methods wants to display the table as HTML, then these are already good
                // default values for the widths of the columns.
                this.table.SetColumnPixelWidths(PIXEL_WIDTH_TAG, PIXEL_WIDTH_NAME, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VR, PIXEL_WIDTH_VALUES, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VR, PIXEL_WIDTH_VALUES);
            }
            else
            {
                this.table = new Table(6);

                columnIndexPresent1 = 3;
                columnIndexValues1 = 4;
                columnIndexPresent2 = 5;
                columnIndexValues2 = 6;

                // Set the headers of the table.
                this.table.AddHeader(tableDescription, tableDescription, tableDescription, tableDescription, tableDescription, tableDescription);
                this.table.AddHeader("Attribute Info", "Attribute Info", attributeSet1Description, attributeSet1Description, attributeSet2Description, attributeSet2Description);
                this.table.AddHeader("Tag", "Name", "Pr", "Values", "Pr", "Values");

                // If the caller of this methods wants to display the table as HTML, then these are already good
                // default values for the widths of the columns.
                this.table.SetColumnPixelWidths(PIXEL_WIDTH_TAG, PIXEL_WIDTH_NAME, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VALUES, PIXEL_WIDTH_PRESENT, PIXEL_WIDTH_VALUES);
            }

            // Do the actual comparison.
            AddAttributeSetsComparison(attributeSet1, attributeSet2, 0);

            return(this.table);
        }