コード例 #1
0
            public void ActivateAsLayer(int index, string layerId)
            {
                OverlayPlaneGraphic overlay = _overlays[index];

                if (overlay != null)
                {
                    if (overlay.ParentGraphic is ShutterCollection)
                    {
                        ShutterCollection shutterCollection = (ShutterCollection)overlay.ParentGraphic;
                        shutterCollection.Deactivate(overlay);
                        shutterCollection.Graphics.Remove(overlay);
                    }

                    ILayer layer = _owner.Layers[layerId];
                    if (overlay.ParentGraphic is CompositeGraphic && overlay.ParentGraphic != layer)
                    {
                        ((CompositeGraphic)overlay.ParentGraphic).Graphics.Remove(overlay);
                    }
                    if (overlay.ParentGraphic == null)
                    {
                        layer.Graphics.Add(overlay);
                    }
                    overlay.Visible = true;
                }
            }
コード例 #2
0
 public string GetLayer(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
     if (overlay.ParentGraphic is ILayer && overlay.ParentGraphic.ParentGraphic == _owner.Layers)
     {
         return(((ILayer)overlay.ParentGraphic).Id);
     }
     return(null);
 }
コード例 #3
0
 public void Add(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(CanAdd(overlay), "Overlay is already part of a different collection.");
     if (overlay.ParentGraphic == null)
     {
         _owner.Layers.InactiveLayer.Graphics.Add(overlay);
     }
     _overlays.Add(overlay);
 }
コード例 #4
0
            public void Deactivate(int index)
            {
                OverlayPlaneGraphic overlay = _overlays[index];

                if (overlay != null)
                {
                    if (overlay.ParentGraphic == _owner.Shutters)
                    {
                        _owner.Shutters.Deactivate(overlay);
                    }
                    if (overlay.ParentGraphic is LayerGraphic && _owner._layers.Graphics.Contains(overlay.ParentGraphic))
                    {
                        ActivateAsLayer(index, string.Empty);
                    }
                }
            }
コード例 #5
0
            public void Deactivate(int index)
            {
                Platform.CheckArgumentRange(index, 0, 15, "index");
                OverlayPlaneGraphic overlay = _overlays[index];

                if (overlay != null)
                {
                    if (overlay.ParentGraphic == _owner.Shutters)
                    {
                        _owner.Shutters.Deactivate(overlay);
                    }
                    if (overlay.ParentGraphic is LayerGraphic && _owner._layers.Graphics.Contains(overlay.ParentGraphic))
                    {
                        this.ActivateAsLayer(index, string.Empty);
                    }
                }
            }
コード例 #6
0
 protected void SerializeBitmapDisplayShutter(BitmapDisplayShutterModuleIod bitmapDisplayShutterModule, IOverlayMapping overlayMapping, DicomPresentationImageCollection <T> images)
 {
     // Doesn't support multiframe or whatever case it is when we get more than one image serialized to one state
     for (int n = 0; n < 16; n++)
     {
         OverlayPlaneGraphic overlay = overlayMapping[n];
         if (overlay != null)
         {
             if (overlay.ParentGraphic is IDicomGraphicsPlaneShutters)
             {
                 bitmapDisplayShutterModule.ShutterShape                        = ShutterShape.Bitmap;
                 bitmapDisplayShutterModule.ShutterOverlayGroupIndex            = n;
                 bitmapDisplayShutterModule.ShutterPresentationValue            = overlay.GrayPresentationValue;
                 bitmapDisplayShutterModule.ShutterPresentationColorCielabValue = null;
                 break;                         // there can only be one
             }
         }
     }
 }
コード例 #7
0
 protected void SerializeOverlayActivation(OverlayActivationModuleIod overlayActivationModule, IOverlayMapping overlayMapping, DicomPresentationImageCollection <T> images)
 {
     // Doesn't support multiframe or whatever case it is when we get more than one image serialized to one state
     for (int n = 0; n < 16; n++)
     {
         OverlayPlaneGraphic overlay = overlayMapping[n];
         if (overlay != null)
         {
             if (overlay.ParentGraphic is ILayer)
             {
                 overlayActivationModule[n].OverlayActivationLayer = ((ILayer)overlay.ParentGraphic).Id;
             }
             else
             {
                 overlayActivationModule.Delete(n);
             }
         }
     }
 }
コード例 #8
0
            public void ActivateAsShutter(int index)
            {
                OverlayPlaneGraphic overlay = _overlays[index];

                if (overlay != null)
                {
                    if (overlay.ParentGraphic is CompositeGraphic && overlay.ParentGraphic != _owner.Shutters)
                    {
                        ((CompositeGraphic)overlay.ParentGraphic).Graphics.Remove(overlay);
                    }
                    if (overlay.ParentGraphic == null)
                    {
                        _owner.Shutters.Add(overlay);
                    }
                    _owner.Shutters.Activate(overlay);
                }
                else
                {
                    _owner.Shutters.DeactivateAll();
                }
            }
コード例 #9
0
            private bool CanAdd(OverlayPlaneGraphic overlay)
            {
                if (overlay.ParentGraphic == null)
                {
                    // The overlay has no current parent
                    return(true);
                }

                if (overlay.ParentGraphic is LayerGraphic)
                {
                    // The owning DicomGraphicsPlane should be the parent of the LayerCollection that is the parent of the LayerGraphic
                    return(overlay.ParentGraphic.ParentGraphic is LayerCollection && overlay.ParentGraphic.ParentGraphic.ParentGraphic == _owner);
                }

                if (overlay.ParentGraphic is ShutterCollection)
                {
                    // The owning DicomGraphicsPlane should be the parent of the ShutterCollection that is the parent of the overlay
                    return(overlay.ParentGraphic.ParentGraphic == _owner);
                }

                return(false);
            }
コード例 #10
0
			public bool IsShutter(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
				return (overlay.ParentGraphic == _owner.Shutters);
			}
コード例 #11
0
 public bool IsLayer(OverlayPlaneGraphic overlay)
 {
     return(!string.IsNullOrEmpty(GetLayer(overlay)));
 }
コード例 #12
0
 public bool IsShutter(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
     return(overlay.ParentGraphic == _owner.Shutters);
 }
コード例 #13
0
			public void Remove(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
				_overlays.Remove(overlay);
			}
コード例 #14
0
			public string GetLayer(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
				if (overlay.ParentGraphic is ILayer && overlay.ParentGraphic.ParentGraphic == _owner.Layers)
					return ((ILayer) overlay.ParentGraphic).Id;
				return null;
			}
コード例 #15
0
 public void Remove(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays[overlay.Index] == overlay, "Overlay must be part of collection.");
     _overlays[overlay.Index] = null;
 }
コード例 #16
0
 public void ActivateAsShutter(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays[overlay.Index] == overlay, "Overlay must be part of collection.");
     ActivateAsShutter(overlay.Index);
 }
コード例 #17
0
			public void Deactivate(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
				Deactivate(_overlays.IndexOf(overlay));
			}
コード例 #18
0
			public void ActivateAsLayer(OverlayPlaneGraphic overlay, string layerId)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
				ActivateAsLayer(_overlays.IndexOf(overlay), layerId);
			}
コード例 #19
0
			private bool CanAdd(OverlayPlaneGraphic overlay)
			{
				if (overlay.ParentGraphic == null)
					// The overlay has no current parent
					return true;

				if (overlay.ParentGraphic is LayerGraphic)
					// The owning DicomGraphicsPlane should be the parent of the LayerCollection that is the parent of the LayerGraphic
					return (overlay.ParentGraphic.ParentGraphic is LayerCollection && overlay.ParentGraphic.ParentGraphic.ParentGraphic == _owner);

				if (overlay.ParentGraphic is ShutterCollection)
					// The owning DicomGraphicsPlane should be the parent of the ShutterCollection that is the parent of the overlay
					return (overlay.ParentGraphic.ParentGraphic == _owner);

				return false;
			}
コード例 #20
0
			public bool Contains(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				return _overlays.Contains(overlay);
			}
コード例 #21
0
 public void ActivateAsShutter(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
     ActivateAsShutter(_overlays.IndexOf(overlay));
 }
コード例 #22
0
			/// <summary>
			/// Cloning constructor.
			/// </summary>
			private ErrorOverlayPlaneGraphic(OverlayPlaneGraphic source, ICloningContext context)
				: base(source, context) {}
コード例 #23
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 private ErrorOverlayPlaneGraphic(OverlayPlaneGraphic source, ICloningContext context)
     : base(source, context)
 {
 }
コード例 #24
0
			public bool IsLayer(OverlayPlaneGraphic overlay)
			{
				return !string.IsNullOrEmpty(GetLayer(overlay));
			}
コード例 #25
0
        protected void SerializeOverlayPlane(OverlayPlaneModuleIod overlayPlaneModule, out IOverlayMapping overlayMapping, DicomPresentationImageCollection <T> images)
        {
            // Doesn't support multiframe or whatever case it is when we get more than one image serialized to one state
            List <OverlayPlaneGraphic> visibleOverlays = new List <OverlayPlaneGraphic>();

            foreach (T image in images)
            {
                DicomGraphicsPlane dicomGraphics = DicomGraphicsPlane.GetDicomGraphicsPlane(image, false);
                if (dicomGraphics != null)
                {
                    // identify visible bitmap shutter if exists
                    OverlayPlaneGraphic bitmapShutter = dicomGraphics.Shutters.ActiveShutter as OverlayPlaneGraphic;
                    if (bitmapShutter != null)
                    {
                        visibleOverlays.Add(bitmapShutter);
                    }

                    // identify any visible overlays
                    visibleOverlays.AddRange(((IEnumerable <ILayer>)dicomGraphics.Layers).Where(l => l.Visible).SelectMany(l => l.Graphics).OfType <OverlayPlaneGraphic>().Where(g => g.Visible));
                }
            }

            OverlayMapping overlayMap = new OverlayMapping();
            Queue <OverlayPlaneGraphic> overlaysToRemap = new Queue <OverlayPlaneGraphic>();

            // user and presentation state overlays are high priority items to remap
            foreach (OverlayPlaneGraphic overlay in CollectionUtils.Select(visibleOverlays, delegate(OverlayPlaneGraphic t) { return(t.Source != OverlayPlaneSource.Image); }))
            {
                overlaysToRemap.Enqueue(overlay);
            }
            foreach (OverlayPlaneGraphic overlay in CollectionUtils.Select(visibleOverlays, delegate(OverlayPlaneGraphic t) { return(t.Source == OverlayPlaneSource.Image); }))
            {
                if (overlayMap[overlay.Index] == null)
                {
                    overlayMap[overlay.Index] = overlay;
                }
                else
                {
                    overlaysToRemap.Enqueue(overlay);                     // image overlays are lower priority items to remap, since they will be included in the header anyway
                }
            }

            // seed the overlays to remap into the remaining available overlay groups
            for (int n = 0; n < 16 && overlaysToRemap.Count > 0; n++)
            {
                if (overlayMap[n] == null)
                {
                    overlayMap[n] = overlaysToRemap.Dequeue();
                }
            }

            // serialize the overlays
            for (int n = 0; n < 16; n++)
            {
                OverlayPlaneGraphic overlay = overlayMap[n];
                if (overlay != null)
                {
                    if (overlay.Source != OverlayPlaneSource.Image || overlay.Index != n)
                    {
                        // only record this overlay in the presentation state if it is being remapped to another group or is not already in the image.
                        OverlayPlane overlayIod = overlayPlaneModule[n];
                        overlayIod.OverlayData          = overlay.CreateOverlayData(overlayIod.IsBigEndianOW).Raw;
                        overlayIod.OverlayBitPosition   = 0;
                        overlayIod.OverlayBitsAllocated = 1;
                        overlayIod.OverlayColumns       = overlay.Columns;
                        overlayIod.OverlayDescription   = overlay.Description;
                        overlayIod.OverlayLabel         = overlay.Label;
                        overlayIod.OverlayOrigin        = Point.Round(overlay.Origin);
                        overlayIod.OverlayRows          = overlay.Rows;
                        overlayIod.OverlaySubtype       = overlay.Subtype;
                        overlayIod.OverlayType          = overlay.Type;
                        overlayIod.RoiArea = null;
                        overlayIod.RoiMean = null;
                        overlayIod.RoiStandardDeviation = null;
                    }
                    else
                    {
                        overlayPlaneModule.Delete(n);
                    }
                }
            }

            if (overlaysToRemap.Count > 0)
            {
                Platform.Log(LogLevel.Warn, "Attempt to serialize presentation state with more than 16 visible overlays - some information may be lost.");
            }

            overlayMapping = overlayMap;
        }
コード例 #26
0
 public void Remove(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     Platform.CheckTrue(_overlays.Contains(overlay), "Overlay must be part of collection.");
     _overlays.Remove(overlay);
 }
コード例 #27
0
 /// <summary>
 /// Cloning constructor.
 /// </summary>
 /// <param name="source">The source object from which to clone.</param>
 /// <param name="context">The cloning context object.</param>
 protected OverlayPlaneGraphic(OverlayPlaneGraphic source, ICloningContext context) : base()
 {
     context.CloneFields(source, this);
 }
コード例 #28
0
 public bool Contains(OverlayPlaneGraphic overlay)
 {
     Platform.CheckForNullReference(overlay, "overlay");
     return(_overlays.Contains(overlay));
 }
コード例 #29
0
		/// <summary>
		/// Cloning constructor.
		/// </summary>
		/// <param name="source">The source object from which to clone.</param>
		/// <param name="context">The cloning context object.</param>
		protected OverlayPlaneGraphic(OverlayPlaneGraphic source, ICloningContext context) : base()
		{
			context.CloneFields(source, this);
		}
コード例 #30
0
			public void Add(OverlayPlaneGraphic overlay)
			{
				Platform.CheckForNullReference(overlay, "overlay");
				Platform.CheckTrue(CanAdd(overlay), "Overlay is already part of a different collection.");
				if (overlay.ParentGraphic == null)
					_owner.Layers.InactiveLayer.Graphics.Add(overlay);
				_overlays.Add(overlay);
			}