コード例 #1
0
        /// <summary>
        /// Deserializes the specified overlay activation module.
        /// </summary>
        /// <remarks>
        /// This method must be called after <see cref="DeserializeOverlayPlane">the overlay planes have been deserialized</see>.
        /// </remarks>
        /// <param name="overlayActivationModule"></param>
        /// <param name="image"></param>
        protected void DeserializeOverlayActivation(OverlayActivationModuleIod overlayActivationModule, T image)
        {
            if (!_overlayPlanesDeserialized)
            {
                throw new InvalidOperationException("Overlay planes must be deserialized first.");
            }

            DicomGraphicsPlane dicomGraphicsPlane = DicomGraphicsPlane.GetDicomGraphicsPlane(image, true);

            for (int n = 0; n < 16; n++)
            {
                if (overlayActivationModule.HasOverlayActivationLayer(n))
                {
                    string targetLayer = overlayActivationModule[n].OverlayActivationLayer ?? string.Empty;
                    if (dicomGraphicsPlane.PresentationOverlays.Contains(n))
                    {
                        if (string.IsNullOrEmpty(targetLayer))
                        {
                            dicomGraphicsPlane.PresentationOverlays.Deactivate(n);
                        }
                        else
                        {
                            dicomGraphicsPlane.PresentationOverlays.ActivateAsLayer(n, targetLayer);
                        }
                        dicomGraphicsPlane.ImageOverlays.Deactivate(n);
                    }
                    else if (dicomGraphicsPlane.ImageOverlays.Contains(n))
                    {
                        if (string.IsNullOrEmpty(targetLayer))
                        {
                            dicomGraphicsPlane.ImageOverlays.Deactivate(n);
                        }
                        else
                        {
                            dicomGraphicsPlane.ImageOverlays.ActivateAsLayer(n, targetLayer);
                        }
                    }
                }
                else
                {
                    // if the module is missing entirely, then the presentation state is poorly encoded.
                    // for patient safety reasons, we override the DICOM stipulation that only one of
                    // these two should be shown and show both instead.
                    dicomGraphicsPlane.PresentationOverlays.ActivateAsLayer(n, "OVERLAY");
                    dicomGraphicsPlane.ImageOverlays.ActivateAsLayer(n, "OVERLAY");
                }
            }
        }
コード例 #2
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);
             }
         }
     }
 }