using System; using System.Drawing; using ClearCanvas.Common; using ClearCanvas.Desktop; using ClearCanvas.Desktop.Actions; using ClearCanvas.ImageViewer; using ClearCanvas.ImageViewer.BaseTools; using ClearCanvas.ImageViewer.Graphics; using ClearCanvas.ImageViewer.PresentationStates.Dicom; using Nullstack.ClearCanvas.ImageViewerTools.Overlays; namespace Nullstack.ClearCanvas.ImageViewerTools { [MenuAction("scram", "global-menus/mnDebug/mnImageViewer/mnHideOddOverlayGroups", "Scram")] [MenuAction("chess", "global-menus/mnDebug/mnImageViewer/mnDrawChessOverlayPattern", "Chess")] [MenuAction("chessshutter", "global-menus/mnDebug/mnImageViewer/mnDrawChessShutter", "ChessShutter")] [ExtensionOf(typeof (ImageViewerToolExtensionPoint))] internal class OverlayTool : ImageViewerTool { public void Scram() { DicomGraphicsPlane dgp = DicomGraphicsPlane.GetDicomGraphicsPlane((IDicomPresentationImage) base.SelectedPresentationImage, false); if (dgp == null) return; try { foreach (OverlayPlaneGraphic overlay in dgp.ImageOverlays) { if (overlay.Index%2 == 0) dgp.ImageOverlays.ActivateAsLayer(overlay, "OVERLAY #" + overlay.Index); else dgp.ImageOverlays.Deactivate(overlay); } dgp.Draw(); } catch (Exception ex) { ExceptionHandler.Report(ex, base.Context.DesktopWindow); } } public void ChessShutter() { IImageGraphicProvider iigp = base.SelectedPresentationImage as IImageGraphicProvider; if (iigp == null) return; DicomGraphicsPlane dgp = DicomGraphicsPlane.GetDicomGraphicsPlane((IDicomPresentationImage) base.SelectedPresentationImage, false); if (dgp == null) return; try { OverlayPlaneGraphic userOverlay = new CheckerboardTestPattern().CreatePattern(new Size(iigp.ImageGraphic.Columns, iigp.ImageGraphic.Rows)); userOverlay.Color = null; userOverlay.GrayPresentationValue = 0;// 32767; dgp.UserOverlays.Add(userOverlay); dgp.UserOverlays.ActivateAsShutter(userOverlay); dgp.Draw(); } catch (Exception ex) { ExceptionHandler.Report(ex, base.Context.DesktopWindow); } } public void Chess() { IImageGraphicProvider iigp = base.SelectedPresentationImage as IImageGraphicProvider; if (iigp == null) return; DicomGraphicsPlane dgp = DicomGraphicsPlane.GetDicomGraphicsPlane((IDicomPresentationImage) base.SelectedPresentationImage, false); if (dgp == null) return; try { OverlayPlaneGraphic userOverlay = new CheckerboardTestPattern().CreatePattern(new Size(iigp.ImageGraphic.Columns, iigp.ImageGraphic.Rows)); dgp.UserOverlays.Add(userOverlay); dgp.UserOverlays.ActivateAsLayer(userOverlay, "TESTPATTERN"); dgp.Draw(); } catch (Exception ex) { ExceptionHandler.Report(ex, base.Context.DesktopWindow); } } } }