public static IDataProvider GetDataProvider(IAimAnnotationInstance annotationInstance) { if (annotationInstance == null) { return(null); } IDataProvider dataProvider = null; switch (annotationInstance.AimVersion) { case AimVersion.AimVersion3: dataProvider = new Aim3.DataProvider(((Aim3.Aim3AnnotationInstance)annotationInstance).AimAnnotation); break; case AimVersion.AimVersion4: var aim4AnnotationInstance = (Aim4.Aim4AnnotationInstance)annotationInstance; var aim4DocumentInstance = (Aim4.Aim4DocumentInstance)aim4AnnotationInstance.ParentAimDocument; dataProvider = new Aim4.DataProvider(aim4AnnotationInstance.AimAnnotationEntity, aim4DocumentInstance.Person, aim4DocumentInstance.User); break; default: Debug.Assert(false, "Cannot get converter for unknown annotation version: " + annotationInstance.AimVersion); break; } return(dataProvider); }
public AimGraphic(IGraphic graphic, IAimAnnotationInstance annotationInstance, int shapeIdentifier) : base(graphic) { _annotationInstance = annotationInstance; _shapeIdentifier = shapeIdentifier; _graphic = graphic; }
public void EditImageAnnotation(string aimUid, bool preview) { if (_activeViewer == null) { return; } // Find Annotation IAimAnnotationInstance annotationToShow = AvailableAnnotations.FirstOrDefault(annotation => annotation.UniqueIdentifier == aimUid); if (annotationToShow == null) { _activeViewer.DesktopWindow.ShowMessageBox("Could not locate annotation (UID = " + aimUid + ").", MessageBoxActions.Ok); return; } // Don't try to restore saved template - we'll be overwriting it anyway bool oldRestoreTreeFlag = AimSettings.Default.RestoreSavedAimTemplateTree; AimSettings.Default.RestoreSavedAimTemplateTree = false; AimAnnotationTool.StartAimAnnotationTool(_activeViewer); // Restore the setting AimSettings.Default.RestoreSavedAimTemplateTree = oldRestoreTreeFlag; AimSettings.Default.Save(); if (AimAnnotationComponent.GetActiveComponent() != null) { var component = AimAnnotationComponent.GetActiveComponent(); component.Preview = preview; component.LoadAimTemplateTreeFromAnnotation(annotationToShow); // will open the image as well } }
public AimTemplateTree AimAnnotationToTemplateTree(IAimAnnotationInstance aimAnnotation, AimTemplateTree startingTree) { if (aimAnnotation == null) { return(null); } switch (aimAnnotation.AimVersion) { case AimVersion.AimVersion3: return(Aim3.AimTemplateConverter.AimAnnotationToAimTemplateTree((Aim3.Aim3AnnotationInstance)aimAnnotation, startingTree)); case AimVersion.AimVersion4: return(Aim4.AimTemplateConverter.AimAnnotationToAimTemplateTree((Aim4.Aim4AnnotationInstance)aimAnnotation, startingTree)); default: Debug.Assert(false, "AimManager.AimAnnotationToTemplateTree: Unexpected AIM version"); break; } return(null); }
public string GetAimAnnotationHtml(IAimAnnotationInstance aimAnnotationInstance) { if (aimAnnotationInstance == null) { return(null); } switch (aimAnnotationInstance.AimVersion) { case AimVersion.AimVersion3: return(Aim3.AimHtmlFormatter.GetAimHtml((Aim3.Aim3AnnotationInstance)aimAnnotationInstance)); case AimVersion.AimVersion4: return(Aim4.AimHtmlFormatter.GetAimHtml((Aim4.Aim4AnnotationInstance)aimAnnotationInstance)); default: Debug.Assert(false, "AimManager.GetAimAnnotationHtml: Unexpected AIM version"); break; } return(null); }
public void ShowImageWithAnnotation(string aimUid) { if (_activeViewer == null) { return; } // Find Annotation IAimAnnotationInstance annotationToShow = AvailableAnnotations.FirstOrDefault(annotation => annotation.UniqueIdentifier == aimUid); if (annotationToShow == null) { _activeViewer.DesktopWindow.ShowMessageBox("Could not locate annotation (UID = " + aimUid + ").", MessageBoxActions.Ok); return; } string studyInstanceUid; string seriesInstanceUid; string sopInstanceUid = null; int frameNumber = 1; if (annotationToShow is IAimImageAnnotationInstace) { var imageAnnotationToShow = (IAimImageAnnotationInstace)annotationToShow; studyInstanceUid = imageAnnotationToShow.ImageStudyUid; seriesInstanceUid = imageAnnotationToShow.ImageSeriesUid; sopInstanceUid = imageAnnotationToShow.FirstImageSopInstanceUid; frameNumber = imageAnnotationToShow.FirstFrameNumber; } else { studyInstanceUid = annotationToShow.ParentAimDocument.StudyInstanceUid; seriesInstanceUid = annotationToShow.ParentAimDocument.SeriesInstanceUid; } if (studyInstanceUid == null || seriesInstanceUid == null) { _activeViewer.DesktopWindow.ShowMessageBox("Error reading image information (annotation UID = " + aimUid + ").", MessageBoxActions.Ok); return; } // Search displayed images first foreach (IImageBox imageBox in _activeViewer.PhysicalWorkspace.ImageBoxes) { if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0) { continue; } IImageSopProvider imageSopProvider = imageBox.DisplaySet.PresentationImages[0] as IImageSopProvider; if (imageSopProvider == null) { continue; } if (imageSopProvider.ImageSop.StudyInstanceUid == studyInstanceUid && imageSopProvider.ImageSop.SeriesInstanceUid == seriesInstanceUid) { foreach (IPresentationImage presentationImage in imageBox.DisplaySet.PresentationImages) { imageSopProvider = presentationImage as IImageSopProvider; if (imageSopProvider == null) { continue; } // Note: will select the first image if there is no SOP Instance UID if (sopInstanceUid == null || (imageSopProvider.ImageSop.SopInstanceUid == sopInstanceUid && imageSopProvider.Frame.FrameNumber == frameNumber)) { try { // Unselect selected in a different image box if (!imageBox.Selected) { UnselectCurrentGraphics(_activeViewer.PhysicalWorkspace.SelectedImageBox); } imageBox.TopLeftPresentationImage = presentationImage; imageBox.Tiles[0].Select(); SelectAimGraphic(presentationImage, aimUid); imageBox.Draw(); return; } catch (Exception ex) { ExceptionHandler.Report(ex, _desktopWindow); } } } } } // Search other available images foreach (IImageSet imageSet in _activeViewer.LogicalWorkspace.ImageSets) { foreach (IDisplaySet displaySet in imageSet.DisplaySets) { if (displaySet.PresentationImages.Count > 0) { IImageSopProvider imageSopProvider = displaySet.PresentationImages[0] as IImageSopProvider; if (imageSopProvider == null) { continue; } if (imageSopProvider.ImageSop.StudyInstanceUid == studyInstanceUid && imageSopProvider.ImageSop.SeriesInstanceUid == seriesInstanceUid) { foreach (IPresentationImage presentationImage in displaySet.PresentationImages) { imageSopProvider = presentationImage as IImageSopProvider; if (imageSopProvider == null) { continue; } // Note: will select the first image if there is no SOP Instance UID if (sopInstanceUid == null || (imageSopProvider.ImageSop.SopInstanceUid == sopInstanceUid && imageSopProvider.Frame.FrameNumber == frameNumber)) { try { IImageBox targetImageBox = _activeViewer.PhysicalWorkspace.SelectedImageBox ?? (_activeViewer.PhysicalWorkspace.ImageBoxes.Count > 0 ? _activeViewer.PhysicalWorkspace.ImageBoxes[0] : null); if (targetImageBox == null) { _activeViewer.DesktopWindow.ShowMessageBox("Failed to find available display", MessageBoxActions.Ok); Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ")."); return; } IDisplaySet targetDisplaySet = displaySet.CreateFreshCopy(); IPresentationImage targetPresentationImage = FindRequiredImage(targetDisplaySet.PresentationImages, studyInstanceUid, seriesInstanceUid, sopInstanceUid, frameNumber); if (targetPresentationImage == null) { _activeViewer.DesktopWindow.ShowMessageBox("Failed to find required image", MessageBoxActions.Ok); Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display requested annotation (aimUID=" + aimUid + ")."); return; } // Unselect selected in a different image box if (!targetImageBox.Selected) { UnselectCurrentGraphics(_activeViewer.PhysicalWorkspace.SelectedImageBox); } targetImageBox.DisplaySet = targetDisplaySet; targetImageBox.TopLeftPresentationImage = targetPresentationImage; targetImageBox.Tiles[0].Select(); SelectAimGraphic(targetPresentationImage, aimUid); targetImageBox.Draw(); return; } catch (Exception ex) { ExceptionHandler.Report(ex, _desktopWindow); } } } } } } } }