コード例 #1
0
        // ====================================================================
        //
        //  Read and display annotation back
        //
        // ====================================================================
        public static bool ReadGraphicsFromAnnotation(aim_dotnet.Annotation annotation, IPresentationImage presentationImage)
        {
            var hasNewRoiGraphic = false;

            var graphicsProvider = presentationImage as IOverlayGraphicsProvider;
            var currentImageSOP = presentationImage as IImageSopProvider;
            if (graphicsProvider == null || currentImageSOP == null)
                return false;

            if (annotation is aim_dotnet.ImageAnnotation)
            {
                var imgAnnotation = annotation as aim_dotnet.ImageAnnotation;
                if (imgAnnotation.GeometricShapeCollection != null)
                {
                    foreach (var geoShape in imgAnnotation.GeometricShapeCollection)
                    {
                        if (GetImageSOPInstanceUID(geoShape) != currentImageSOP.ImageSop.SopInstanceUid)
                            continue;

                        var isAlreadyDisplayed = false;
                        foreach (var graphic in graphicsProvider.OverlayGraphics)
                        {
                            var aimGraphic = graphic as AimGraphic;
                            isAlreadyDisplayed = aimGraphic != null && aimGraphic.AimAnnotation.UniqueIdentifier == imgAnnotation.UniqueIdentifier &&
                                                 aimGraphic.ShapeIdentifier == geoShape.ShapeIdetifier;
                            if (isAlreadyDisplayed)
                                break;
                        }
                        if (isAlreadyDisplayed)
                            continue;

                        var geoGraphic = GeoShapeToGraphic(geoShape, string.IsNullOrEmpty(imgAnnotation.Name) ? string.Empty : imgAnnotation.Name);
                        if (geoGraphic != null)
                        {
                            var aimGraphic = new AimGraphic(geoGraphic, imgAnnotation, geoShape.ShapeIdetifier);
                            aimGraphic.Color = AimSettings.Default.GetAimGraphicColorForUser(aimGraphic.UserLoginName);
                            graphicsProvider.OverlayGraphics.Add(aimGraphic);
                        }

                        hasNewRoiGraphic |= geoGraphic != null;
                    }
                }
                if (imgAnnotation.TextAnnotationCollection != null)
                {
                    foreach (var textAnnotation in imgAnnotation.TextAnnotationCollection)
                    {
                        if (textAnnotation.ConnectorPoints == null)
                            continue;
                        if (GetImageSOPInstanceUID(textAnnotation.ConnectorPoints) != currentImageSOP.ImageSop.SopInstanceUid)
                            continue;

                        var isAlreadyDisplayed = false;
                        foreach (var graphic in graphicsProvider.OverlayGraphics)
                        {
                            var aimGraphic = graphic as AimGraphic;
                            isAlreadyDisplayed = aimGraphic != null && aimGraphic.AimAnnotation.UniqueIdentifier == imgAnnotation.UniqueIdentifier &&
                                                 aimGraphic.ShapeIdentifier == textAnnotation.ConnectorPoints.ShapeIdetifier;
                            if (isAlreadyDisplayed)
                                break;
                        }
                        if (isAlreadyDisplayed)
                            continue;

                        var textGraphic = TextAnnotationToGraphic(textAnnotation, string.IsNullOrEmpty(imgAnnotation.Name) ? string.Empty : imgAnnotation.Name);
                        if (textGraphic != null)
                        {
                            var aimGraphic = new AimGraphic(textGraphic, imgAnnotation, textAnnotation.ConnectorPoints.ShapeIdetifier);
                            aimGraphic.Color = Color.SlateBlue;
                            graphicsProvider.OverlayGraphics.Add(aimGraphic);
                        }
                        hasNewRoiGraphic |= textGraphic != null;
                    }
                }
            }

            return hasNewRoiGraphic;
        }
コード例 #2
0
		// ====================================================================
		//
		//  Read and display annotation back
		//
		// ====================================================================

		public static bool ReadGraphicsFromAnnotation(aim_dotnet.Annotation annotation, IPresentationImage presentationImage)
		{
			bool hasNewRoiGraphic = false;

			IOverlayGraphicsProvider graphicsProvider = presentationImage as IOverlayGraphicsProvider;
			//IApplicationGraphicsProvider graphicsProvider = presentationImage as IApplicationGraphicsProvider;
			IImageSopProvider currentImageSOP = presentationImage as IImageSopProvider;
			if (graphicsProvider == null || currentImageSOP == null)
				return false;

			if (annotation is aim_dotnet.ImageAnnotation)
			{
				aim_dotnet.ImageAnnotation imgAnnotation = annotation as aim_dotnet.ImageAnnotation;
				if (imgAnnotation.GeometricShapeCollection != null)
				{
					foreach (aim_dotnet.IGeometricShape geoShape in imgAnnotation.GeometricShapeCollection)
					{
						// Check if the image is the one on which the annotation was originally drawn
						if (GetImageSOPInstanceUID(geoShape) != currentImageSOP.ImageSop.SopInstanceUid)
							break;

						// Prevent from adding the same annotation again
						bool isAlreadyDisplayed = false;
						foreach (IGraphic graphic in graphicsProvider.OverlayGraphics)
						{
							AimGraphic aimGraphic = graphic as AimGraphic;
							isAlreadyDisplayed = aimGraphic != null && aimGraphic.AimAnnotation.UniqueIdentifier == imgAnnotation.UniqueIdentifier &&
							                     aimGraphic.ShapeIdentifier == geoShape.ShapeIdetifier;
							if (isAlreadyDisplayed)
								break;
						}
						if (isAlreadyDisplayed)
							continue;

						//hasNewRoiGraphic = AddRoiGraphic(geoShape, graphicsProvider) || hasNewRoiGraphic;
						RoiGraphic roiGraphic = GeoShapeToRoiGraphic(geoShape);
						if (roiGraphic != null)
						{
							AimGraphic aimGraphic = new AimGraphic(roiGraphic, imgAnnotation, geoShape.ShapeIdetifier);
							if (!String.IsNullOrEmpty(imgAnnotation.Name))
								roiGraphic.Name = imgAnnotation.Name;
							aimGraphic.Color = Color.SlateBlue;
							graphicsProvider.OverlayGraphics.Add(aimGraphic);
						}

						hasNewRoiGraphic |= roiGraphic == null;
					}
				}
			}

			return hasNewRoiGraphic;
		}
コード例 #3
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="aimGraphic">The source object from which to clone.</param>
 /// <param name="context">The cloning context object.</param>
 protected AimGraphic(AimGraphic aimGraphic, ICloningContext context) : base(aimGraphic.DecoratedGraphic)
 {
     context.CloneFields(aimGraphic, this);
 }
コード例 #4
0
		protected AimGraphic(AimGraphic aimGraphic, ICloningContext context): base(aimGraphic.DecoratedGraphic)
		{
			context.CloneFields(aimGraphic, this);
		}