コード例 #1
0
        //internal static string GetAimHtml(aim_dotnet.Annotation annotation)
        internal static string GetAimHtml(Aim3AnnotationInstance annotationInstance)
        {
            var annotation = annotationInstance == null ? null : annotationInstance.AimAnnotation;

            if (annotation == null)
            {
                return(GetEmptyHtml());
            }

            switch (annotation.AnnotationKind)
            {
            case aim_dotnet.AnnotationKind.AK_ImageAnnotation:
                return(GetImageAnnotationHtml(annotation as aim_dotnet.ImageAnnotation));

            case aim_dotnet.AnnotationKind.AK_AnnotationOfAnnotation:
                return(GetAnnotationOfAnnotationHtml(annotation as aim_dotnet.AnnotationOfAnnotation));
            }

            Platform.Log(LogLevel.Error, "Annotation Display Formatting (HTML): unknown annotation type");
            Debug.Assert(false, "Uknown Annotation Type");
            return("Unknown Annotation Type");
        }
コード例 #2
0
        public static TemplateTree.AimTemplateTree AimAnnotationToAimTemplateTree(Aim3AnnotationInstance annotationInstance, TemplateTree.AimTemplateTree template)
        {
            if (annotationInstance == null || annotationInstance.AimAnnotation == null)
                return null;

            var annotation = annotationInstance.AimAnnotation;
            if (annotation.AnatomyEntityCollection != null)
            {
                foreach (var ae in annotation.AnatomyEntityCollection)
                {
                    if (IsNullCodeSequence(ToStandardCodeSequence(ae)))
                        continue;

                    TemplateTree.AimTemplateTreeAnatomicEntityNode matchingTreeNode =
                        template.TemplateNodes.OfType<TemplateTree.AimTemplateTreeAnatomicEntityNode>().FirstOrDefault(treeAe => treeAe.Label == ae.Label);
                    if (matchingTreeNode != null)
                    {
                        TemplateTree.AimTemplateTreeAllowedTerm matchingAllowedTerm =
                            matchingTreeNode.AllowedTerms.FirstOrDefault(treeAe => ToStandardCodeSequence(treeAe).CodeValue == ae.CodeValue);
                        if (matchingAllowedTerm != null)
                        {
                            matchingAllowedTerm.Selected = true;
                        }
                        else
                            return null;

                        if (matchingTreeNode.HasConfidence && ae.AnnotatorConfidence.HasValue)
                            matchingTreeNode.ConfidenceValue = ae.AnnotatorConfidence.Value;
                    }
                    else
                        return null;

                    if (ae.AnatomicEntityCharacteristicCollection != null)
                    {
                        foreach (var aec in ae.AnatomicEntityCharacteristicCollection)
                        {
                            if (IsNullCodeSequence(ToStandardCodeSequence(aec)))
                                continue;

                            TemplateTree.AimTemplateTreeAnatomicEntityCharacteristicNode matchingAecTreeNode =
                                matchingTreeNode.AnatomicEntityCharacteristicTreeNodes.FirstOrDefault(treeAec => treeAec.Label == aec.Label);
                            if (matchingAecTreeNode != null)
                            {
                                TemplateTree.CharacteristicQuantificationAllowedTerm matchingAllowedTerm =
                                    matchingAecTreeNode.CharacteristicQuantificationAllowedTerms.FirstOrDefault(treeAec => ToStandardCodeSequence(treeAec).CodeValue == aec.CodeValue);
                                if (matchingAllowedTerm != null)
                                {
                                    matchingAllowedTerm.Selected = true;

                                    foreach (var quantification in matchingAllowedTerm.CharacteristicQuantifications)
                                    {
                                        if (ReadBackCharacteristicQuantificationFromAnnotation(aec.CharacteristicQuantificationCollection, quantification) == null)
                                            return null;
                                    }
                                }
                                else
                                    return null;

                                if (matchingAecTreeNode.HasConfidence && aec.AnnotatorConfidence.HasValue)
                                    matchingAecTreeNode.ConfidenceValue = aec.AnnotatorConfidence.Value;

                            }
                            else
                                return null;
                        }
                    }

                }
            }
            if (annotation.ImagingObservationCollection != null)
            {
                foreach (var io in annotation.ImagingObservationCollection)
                {
                    if (IsNullCodeSequence(ToStandardCodeSequence(io)))
                        continue;

                    TemplateTree.AimTemplateTreeImagingObservationNode matchingTreeNode =
                        template.TemplateNodes.OfType<TemplateTree.AimTemplateTreeImagingObservationNode>().FirstOrDefault(
                            treeIo => treeIo.Label == io.Label);
                    if (matchingTreeNode != null)
                    {
                        TemplateTree.AimTemplateTreeAllowedTerm matchingAllowedTerm =
                            matchingTreeNode.AllowedTerms.FirstOrDefault(
                                treeIo => ToStandardCodeSequence(treeIo).CodeValue == io.CodeValue);
                        if (matchingAllowedTerm != null)
                        {
                            matchingAllowedTerm.Selected = true;
                        }
                        else
                            return null;

                        if (matchingTreeNode.HasConfidence && io.AnnotatorConfidence.HasValue)
                            matchingTreeNode.ConfidenceValue = io.AnnotatorConfidence.Value;
                    }
                    else
                        return null;

                    if (io.ImagingObservationCharacteristicCollection != null)
                    {
                        foreach (var ioc in io.ImagingObservationCharacteristicCollection)
                        {
                            if (IsNullCodeSequence(ToStandardCodeSequence(ioc)))
                                continue;

                            TemplateTree.AimTemplateTreeImagingObservationCharacteristicNode matchingIocTreeNode =
                                matchingTreeNode.ImagingObservationCharacteristicTreeNodes.FirstOrDefault(
                                    treeIoc => treeIoc.Label == ioc.Label);
                            if (matchingIocTreeNode != null)
                            {
                                TemplateTree.CharacteristicQuantificationAllowedTerm matchingAllowedTerm =
                                    matchingIocTreeNode.CharacteristicQuantificationAllowedTerms.FirstOrDefault(
                                        treeIoc => ToStandardCodeSequence(treeIoc).CodeValue == ioc.CodeValue);
                                if (matchingAllowedTerm != null)
                                {
                                    matchingAllowedTerm.Selected = true;

                                    foreach (var quantification in matchingAllowedTerm.CharacteristicQuantifications)
                                    {
                                        if (ReadBackCharacteristicQuantificationFromAnnotation(ioc.CharacteristicQuantificationCollection, quantification) == null)
                                            return null;
                                    }
                                }
                                else
                                    return null;

                                if (matchingIocTreeNode.HasConfidence && ioc.AnnotatorConfidence.HasValue)
                                    matchingIocTreeNode.ConfidenceValue = ioc.AnnotatorConfidence.Value;

                            }
                            else
                                return null;
                        }
                    }
                }
            }
            if (annotation.CalculationCollection != null)
            {
                //foreach (var calc in annotation.CalculationCollection)
                //{
                //    AimTemplateTreeCalculationNode matchingTreeNode =
                //        template.TemplateNodes.OfType<AimTemplateTreeCalculationNode>().FirstOrDefault(
                //            treeCalc => treeCalc.Label == calc.Description);
                //    if (matchingTreeNode != null)
                //    {
                //        AimTemplateTreeCalculationType matchingCalculationType =
                //            matchingTreeNode.CalculationTypes.FirstOrDefault(
                //                treeCalc => ToStandardCodeSequence(treeCalc).CodeValue == calc.CodeValue);
                //        if (matchingCalculationType != null)
                //        {
                //            matchingTreeNode.SelectedCalculationType = matchingCalculationType;
                //        }
                //        else
                //            return null;

                //        //if (matchingTreeNode.HasConfidence && calc..HasValue)
                //        //    matchingTreeNode.ConfidenceValue = calc.AnnotatorConfidence.Value;
                //    }
                //    else
                //        return null;
                //}
            }
            if (annotation.InferenceCollection != null)
            {
                foreach (var inference in annotation.InferenceCollection)
                {
                    if (IsNullCodeSequence(ToStandardCodeSequence(inference)))
                        continue;

                    foreach (var inferenceNode in template.TemplateNodes.OfType<TemplateTree.AimTemplateTreeInferenceNode>())
                    {
                        TemplateTree.AimTemplateTreeAllowedTerm matchingAllowedTerm =
                            inferenceNode.AllowedTerms.FirstOrDefault(
                                term => ToStandardCodeSequence(term).CodeValue == inference.CodeValue);
                        if (matchingAllowedTerm != null)
                            matchingAllowedTerm.Selected = true;
                    }
                }
            }
            template.Markup.Clear();
            if (annotation is aim_dotnet.ImageAnnotation)
            {
                var imageAnnotation = (aim_dotnet.ImageAnnotation)annotation;
                var annotationName = string.IsNullOrEmpty(imageAnnotation.Name) ? "" : imageAnnotation.Name;

                if (imageAnnotation.GeometricShapeCollection != null)
                {
                    foreach (var geometricShape in imageAnnotation.GeometricShapeCollection)
                    {
                        var markup = ToMarkup(geometricShape, annotationName);
                        if (markup != null)
                            template.Markup.Add(markup);
                    }
                }
                if (imageAnnotation.TextAnnotationCollection != null)
                {
                    foreach (var textAnnotation in imageAnnotation.TextAnnotationCollection)
                    {
                        if (textAnnotation.ConnectorPoints != null && textAnnotation.ConnectorPoints.SpatialCoordinateCollection != null)
                        {
                            var calloutText = AimHelpers.FormatPointCalloutText(annotationName, textAnnotation.Text);
                            switch (textAnnotation.ConnectorPoints.SpatialCoordinateCollection.Count)
                            {
                                case 1:
                                    {
                                        var markup = new TemplateTree.MarkupPoint();
                                        markup.Name = annotationName;
                                        markup.IncludeInAnnotation = textAnnotation.ConnectorPoints.IsIncludeFlag;
                                        markup.Point = AimNativeConverter.AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                                        markup.CalloutText = calloutText;
                                        markup.CalloutLocation = new PointF(markup.Point.X, markup.Point.Y);
                                        SetMarkupImageReference(markup, textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                                        markup.UseCrosshair = AimSettings.Default.UseCrosshairsForTextCallouts;
                                        template.Markup.Add(markup);
                                    }
                                    break;
                                case 2:
                                    {
                                        var markup = new TemplateTree.MarkupPoint();
                                        markup.Name = annotationName;
                                        markup.IncludeInAnnotation = textAnnotation.ConnectorPoints.IsIncludeFlag;
                                        markup.Point = AimNativeConverter.AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                                        markup.CalloutText = calloutText;
                                        markup.CalloutLocation = AimNativeConverter.AsPointF(textAnnotation.ConnectorPoints.SpatialCoordinateCollection[1]);
                                        SetMarkupImageReference(markup, textAnnotation.ConnectorPoints.SpatialCoordinateCollection[0]);
                                        markup.UseCrosshair = AimSettings.Default.UseCrosshairsForTextCallouts;
                                        template.Markup.Add(markup);
                                    }
                                    break;
                                default:
                                    Platform.Log(LogLevel.Error, "TextAnnotation has [{0}] Connector Points", textAnnotation.ConnectorPoints.SpatialCoordinateCollection.Count);
                                    break;
                            }
                        }
                    }
                }
            }
            return template;
        }
コード例 #3
0
        //internal static string GetAimHtml(aim_dotnet.Annotation annotation)
        internal static string GetAimHtml(Aim3AnnotationInstance annotationInstance)
        {
            var annotation = annotationInstance == null ? null : annotationInstance.AimAnnotation;

            if (annotation == null)
                return GetEmptyHtml();

            switch (annotation.AnnotationKind)
            {
                case aim_dotnet.AnnotationKind.AK_ImageAnnotation:
                    return GetImageAnnotationHtml(annotation as aim_dotnet.ImageAnnotation);
                case aim_dotnet.AnnotationKind.AK_AnnotationOfAnnotation:
                    return GetAnnotationOfAnnotationHtml(annotation as aim_dotnet.AnnotationOfAnnotation);
            }

            Platform.Log(LogLevel.Error, "Annotation Display Formatting (HTML): unknown annotation type");
            Debug.Assert(false, "Uknown Annotation Type");
            return "Unknown Annotation Type";
        }