public AsynchronousPriorStudyLoader(IImageViewer imageViewer, IPriorStudyFinder priorStudyFinder) { _imageViewer = imageViewer; _singleStudyLoaders = new List <SingleStudyLoader>(); _priorStudyFinder = priorStudyFinder ?? PriorStudyFinder.Null; _priorStudyFinder.SetImageViewer(_imageViewer); }
// Forces re-draw of displayed images if they have AIMGraphic private static void UpdateDisplayedImages(string loginName) { foreach (DesktopWindow desktopWindow in Application.DesktopWindows) { foreach (Workspace workspace in desktopWindow.Workspaces) { IImageViewer imageViewer = ImageViewerComponent.GetAsImageViewer(workspace); if (imageViewer != null) { foreach (ImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes) { foreach (Tile tile in imageBox.Tiles) { IOverlayGraphicsProvider graphicsProvider = tile.PresentationImage as IOverlayGraphicsProvider; if (graphicsProvider != null) { foreach (IGraphic graphic in graphicsProvider.OverlayGraphics) { AimGraphic aimGraphic = graphic as AimGraphic; if (aimGraphic != null && (string.IsNullOrEmpty(loginName) || string.Equals(loginName, aimGraphic.UserLoginName, StringComparison.InvariantCultureIgnoreCase))) { tile.PresentationImage.Draw(); break; } } } } } } } } }
internal static void OnViewerClosed(IImageViewer viewer) { KeyImageInformation info = GetKeyImageInformation(viewer); KeyImageInformation.Remove(viewer); if (info != null) { using (info) { try { var publisher = new KeyImagePublisher(info); publisher.Publish(); } catch (Exception e) { //Should never happen because KeyImagePublisher.Publish doesn't throw exceptions. ExceptionHandler.Report(e, Application.ActiveDesktopWindow); } } } ManageActivityMonitorConnection(); }
public ViewerFrameEnumerator(IImageViewer viewer, int selectedWeight, int unselectedWeight, int imageWindow, Predicate <Frame> canFetchFrame) { _viewer = viewer; _selectedWeight = selectedWeight; _unselectedWeight = unselectedWeight; _imageWindow = imageWindow; _framesToProcess = new Queue <Frame>(); _canFetchFrame = canFetchFrame; _viewer.PhysicalWorkspace.ImageBoxes.ItemAdded += OnImageBoxAdded; _viewer.PhysicalWorkspace.ImageBoxes.ItemRemoved += OnImageBoxRemoved; _viewer.PhysicalWorkspace.ImageBoxes.ItemChanging += OnImageBoxChanging; _viewer.PhysicalWorkspace.ImageBoxes.ItemChanged += OnImageBoxChanged; _viewer.EventBroker.ImageBoxSelected += OnImageBoxSelected; _viewer.EventBroker.DisplaySetChanged += OnDisplaySetChanged; _imageBoxStrategies = new Dictionary <IImageBox, ImageBoxFrameSelectionStrategy>(); foreach (IImageBox imageBox in _viewer.PhysicalWorkspace.ImageBoxes) { _imageBoxStrategies[imageBox] = new ImageBoxFrameSelectionStrategy(imageBox, _imageWindow, _canFetchFrame, OnImageBoxDataChanged); } _selectedImageBox = _viewer.SelectedImageBox; }
public GetViewerInfoResult GetViewerInfo(GetViewerInfoRequest request) { if (request == null) { string message = "The get viewer info request cannot be null."; Platform.Log(LogLevel.Debug, message); throw new FaultException(message); } if (request.Viewer == null || request.Viewer.Identifier.Equals(Guid.Empty)) { string message = "A valid viewer id must be specified."; Platform.Log(LogLevel.Debug, message); throw new FaultException(message); } IImageViewer viewer = ViewerAutomationTool.GetViewer(request.Viewer.Identifier); if (viewer == null) { string message = String.Format("The specified viewer ({0}) was not found, " + "likely because it has already been closed by the user.", request.Viewer.Identifier); Platform.Log(LogLevel.Debug, message); throw new FaultException <ViewerNotFoundFault>(new ViewerNotFoundFault(message), _viewerNotFoundReason); } GetViewerInfoResult result = new GetViewerInfoResult(); result.AdditionalStudyInstanceUids = GetAdditionalStudyInstanceUids(viewer); return(result); }
/// <summary> /// Loads tag data for the study in the specified workspace. /// </summary> /// <param name="workspace"></param> private void LoadData(Workspace workspace) { IImageViewer viewer = workspace == null ? null : ImageViewerComponent.GetAsImageViewer(workspace); if (viewer != null) { // for simplicity, assume only one patient and study in the workspace Patient patient = CollectionUtils.FirstElement(viewer.StudyTree.Patients.Values); _activeStudy = CollectionUtils.FirstElement(patient.Studies.Values); // load the tags for the active study, remembering the original value so we know if any changes are made _originalTags = _tags = MakeTagsString(_database.GetTagsForStudy(_activeStudy.StudyInstanceUID)); if (!_searchEnabled) { FindSimilar(); } } else { Clear(); } NotifyPropertyChanged("Tags"); NotifyPropertyChanged("UpdateEnabled"); }
private void SetImageViewer(Workspace workspace) { IImageViewer viewer = CastToImageViewer(workspace); if (viewer != _viewer) { if (_viewer != null) { _viewer.EventBroker.PresentationImageSelected -= OnPresentationImageSelected; _viewer.EventBroker.TileSelected -= OnTileSelected; } _viewer = viewer; if (_viewer != null) { _viewer.EventBroker.PresentationImageSelected += OnPresentationImageSelected; _viewer.EventBroker.TileSelected += OnTileSelected; UpdateImageProperties(viewer.SelectedPresentationImage); } else { UpdateImageProperties(null); } } }
private void SetActiveViewer(IImageViewer viewer) { if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected -= OnImageBoxSelected; _activeViewer.EventBroker.DisplaySetSelected -= OnDisplaySetSelected; } _activeViewer = viewer; IDisplaySet displaySet = null; if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected += OnImageBoxSelected; _activeViewer.EventBroker.DisplaySetSelected += OnDisplaySetSelected; if (_activeViewer.SelectedImageBox != null) { displaySet = _activeViewer.SelectedImageBox.DisplaySet; } } CurrentDisplaySet = displaySet; }
internal ActiveImageViewerChangedEventArgs( IImageViewer activatedImageViewer, IImageViewer deactivatedImageViewer) { _activatedImageViewer = activatedImageViewer; _deactivatedImageViewer = deactivatedImageViewer; }
private void SetImageViewer(Workspace workspace) { var viewer = CastToImageViewer(workspace); if (viewer == _activeViewer) { return; } if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected -= OnImageBoxSelected; _activeViewer.EventBroker.GraphicSelectionChanged -= OnGraphicSelectionChanged; _activeViewer.EventBroker.TileSelected -= OnTileSelected; } _activeViewer = viewer; if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected += OnImageBoxSelected; _activeViewer.EventBroker.GraphicSelectionChanged += OnGraphicSelectionChanged; _activeViewer.EventBroker.TileSelected += OnTileSelected; } // Update selected graphic SetSelectedGraphic(_activeViewer == null || _activeViewer.SelectedPresentationImage == null ? null : _activeViewer.SelectedPresentationImage.SelectedGraphic); IsImageViewerActive = _activeViewer != null; }
public void ApplyLayout(IImageViewer viewer, AppliedWorkspace layout) { if (layout.DisplaySets.Count != layout.WorkspaceLayout.Rows * layout.WorkspaceLayout.Columns) { throw new ArgumentException(string.Format(SR.MessageAmountOfImageBoxesMismatch, layout.DisplaySets.Count, layout.WorkspaceLayout.Rows, layout.WorkspaceLayout.Columns, layout.WorkspaceLayout.Name)); } IPhysicalWorkspace workspace = viewer.PhysicalWorkspace; workspace.SetImageBoxGrid(layout.WorkspaceLayout.Rows, layout.WorkspaceLayout.Columns); var imageBoxIndex = 0; foreach (var displaySetLayout in layout.DisplaySets) { var imageBox = workspace.ImageBoxes[imageBoxIndex]; imageBox.SetTileGrid( displaySetLayout.Item1.TileRows, displaySetLayout.Item1.TileColumns); if (null != displaySetLayout.Item2) { imageBox.DisplaySet = displaySetLayout.Item2.CreateFreshCopy(); } else { imageBox.DisplaySet = null; } imageBoxIndex++; } }
private void SetImageViewer(Workspace workspace) { var viewer = CastToImageViewer(workspace); if (viewer == _activeViewer) { return; } if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected -= OnImageBoxSelected; _activeViewer.EventBroker.TileSelected -= OnTileSelected; _activeViewer.EventBroker.GraphicSelectionChanged -= OnGraphicSelectionChanged; _activeViewer.EventBroker.PresentationImageSelected -= OnPresentationImageSelected; } _activeViewer = viewer; if (_activeViewer != null) { _activeViewer.EventBroker.ImageBoxSelected += OnImageBoxSelected; _activeViewer.EventBroker.TileSelected += OnTileSelected; _activeViewer.EventBroker.GraphicSelectionChanged += OnGraphicSelectionChanged; _activeViewer.EventBroker.PresentationImageSelected += OnPresentationImageSelected; } SetInitialSelections(); }
internal static void OnViewerClosed(IImageViewer viewer) { var info = GetKeyImageClipboard(viewer); KeyImageClipboards.Remove(viewer); if (info != null) { try { info.Publish(); } catch (Exception e) { //Should never happen because KeyImagePublisher.Publish doesn't throw exceptions. ExceptionHandler.Report(e, Application.ActiveDesktopWindow); } finally { info.Dispose(); } } ManageActivityMonitorConnection(); }
internal ActiveImageViewerChangedEventArgs( IImageViewer activatedImageViewer, IImageViewer deactivatedImageViewer) { _activatedImageViewer = activatedImageViewer; _deactivatedImageViewer = deactivatedImageViewer; }
// Returns currently displayed annotations' colors and associated user names private static Dictionary <string, Color> GetDisplayedUsersAndMarkupColors() { Dictionary <string, Color> displayedUserColors = new Dictionary <string, Color>(); IImageViewer imageViewer = ImageViewerComponent.GetAsImageViewer(Application.ActiveDesktopWindow.ActiveWorkspace); if (imageViewer != null) { foreach (ImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes) { foreach (Tile tile in imageBox.Tiles) { IOverlayGraphicsProvider graphicsProvider = tile.PresentationImage as IOverlayGraphicsProvider; if (graphicsProvider != null) { foreach (IGraphic graphic in graphicsProvider.OverlayGraphics) { AimGraphic aimGraphic = graphic as AimGraphic; if (aimGraphic != null) // && String.Equals(loginName, aimGraphic.UserLoginName, StringComparison.InvariantCultureIgnoreCase)) { if (!displayedUserColors.ContainsKey(aimGraphic.UserLoginName)) { displayedUserColors[aimGraphic.UserLoginName] = aimGraphic.Color; } } } } } } } return(displayedUserColors); }
public static bool StartAimAnnotationTool(IImageViewer currentImageViewer) { if (currentImageViewer == null) { return(false); } var actionPath = new ActionPath(BUTTON_ACTION_PATH, new ResourceResolver(typeof(AimAnnotationTool), true)); IActionSet actionSet = currentImageViewer.ExportedActions.Select(action => action.Path.LocalizedPath == actionPath.LocalizedPath); if (actionSet != null) { foreach (IAction action in actionSet) { ClickAction clickAction = action as ClickAction; if (clickAction != null) { clickAction.Click(); return(true); } } } return(false); }
public static void SetTileLayout(IImageViewer imageViewer, int rows, int columns) { Platform.CheckForNullReference(imageViewer, "imageViewer"); Platform.CheckArgumentRange(rows, 1, LayoutSettings.MaximumTileRows, "rows"); Platform.CheckArgumentRange(columns, 1, LayoutSettings.MaximumTileColumns, "columns"); IImageBox imageBox = imageViewer.PhysicalWorkspace.SelectedImageBox; if (imageBox == null || imageBox.ParentPhysicalWorkspace.Locked) { return; } var memorableCommand = new MemorableUndoableCommand(imageBox) { BeginState = imageBox.CreateMemento() }; int index = imageBox.TopLeftPresentationImageIndex; imageBox.SetTileGrid(rows, columns); imageBox.TopLeftPresentationImageIndex = index; imageBox.Draw(); imageBox.SelectDefaultTile(); memorableCommand.EndState = imageBox.CreateMemento(); var historyCommand = new DrawableUndoableCommand(imageBox) { Name = SR.CommandLayoutTiles }; historyCommand.Enqueue(memorableCommand); imageViewer.CommandHistory.AddCommand(historyCommand); }
internal PhysicalWorkspace(IImageViewer imageViewer) { Platform.CheckForNullReference(imageViewer, "imageViewer"); _imageViewer = imageViewer; this.ImageBoxes.ItemAdded += OnImageBoxAdded; this.ImageBoxes.ItemRemoved += OnImageBoxRemoved; }
internal PhysicalWorkspace(IImageViewer imageViewer) { Platform.CheckForNullReference(imageViewer, "imageViewer"); _imageViewer = imageViewer; this.ImageBoxes.ItemAdded += OnImageBoxAdded; this.ImageBoxes.ItemRemoved += OnImageBoxRemoved; }
public void Init(IImageViewer imageViewer) { this.imageViewer = imageViewer; model = new Model(); imageViewer.PossibleFileFormatList = model.PossibleFileFormatList; AttachImageViewer(); AttchModel(); }
internal static IEnumerable <ISegGraphic> GetAllSegmentationGraphicsFromSeg(IImageViewer imageViewer, Seg seg) { var graphics = new List <ISegGraphic>(); graphics.AddRange(seg.SegGraphics); graphics.AddRange(GetSegmentationImageGraphicsFromSeg(imageViewer, seg)); return(graphics); }
void IPrefetchingStrategy.Stop() { if (_imageViewer != null) { Stop(); _imageViewer = null; } }
public OpenStudiesResult OpenStudies(OpenStudiesRequest request) { if (request == null) { string message = "The open studies request cannot be null."; Platform.Log(LogLevel.Debug, message); throw new FaultException(message); } if (request.StudiesToOpen == null || request.StudiesToOpen.Count == 0) { string message = "At least one study must be specified."; Platform.Log(LogLevel.Debug, message); throw new FaultException(message); } OpenStudiesResult result = new OpenStudiesResult(); bool activateIfOpen = request.ActivateIfAlreadyOpen ?? true; try { string primaryStudyInstanceUid = request.StudiesToOpen[0].StudyInstanceUid; IImageViewer viewer = null; if (activateIfOpen) { Workspace workspace = GetViewerWorkspace(primaryStudyInstanceUid); if (workspace != null) { viewer = ImageViewerComponent.GetAsImageViewer(workspace); workspace.Activate(); } } if (viewer == null) { viewer = LaunchViewer(request, primaryStudyInstanceUid); } Guid?viewerId = ViewerAutomationTool.GetViewerId(viewer); if (viewerId == null) { throw new FaultException("Failed to retrieve the id of the specified viewer."); } result.Viewer = new Viewer(viewerId.Value, GetPrimaryStudyIdentifier(viewer)); return(result); } catch (FaultException) { throw; } catch (Exception e) { string message = "An unexpected error has occurred while attempting to open the study(s)."; Platform.Log(LogLevel.Error, e, message); throw new FaultException(message); } }
internal override void SetImageViewer(IImageViewer imageViewer) { base.SetImageViewer(imageViewer); foreach (Graphic3D graphic in _graphicCollection3D) { graphic.SetImageViewer(imageViewer); } }
internal static void OnViewerOpened(IImageViewer viewer) { if (!KeyImageInformation.ContainsKey(viewer)) { KeyImageInformation[viewer] = new KeyImageInformation(); } ManageActivityMonitorConnection(); }
/// <summary> /// Implementation of <see cref="IDisposable"/>. /// </summary> protected virtual void Dispose(bool disposing) { if (disposing && _imageViewer != null) { _imageViewer.EventBroker.StudyLoaded -= OnPriorStudyLoaded; _imageViewer.EventBroker.StudyLoadFailed -= OnPriorStudyLoadFailed; _imageViewer = null; } }
internal static bool IsExploded(IImageViewer viewer) { if (Tools.ContainsKey(viewer)) { return(Tools[viewer].Checked); } return(false); }
/// <summary> /// Performs given operation on the images in the given Image Viewer /// </summary> /// <param name="imageViewer">reference to <code>IImageViewer</code> that the operation has to be performed on</param> /// <param name="stopOnFirstMatch">when <code>true</code>, will return after the first successful predicate operation.</param> /// <param name="predicate">Operation to execute on each <code>IPresentationImage</code></param> /// <param name="displayedImagesOnly">when<code>true</code>, will only operated on visible <code>DisplaySet</code>s</param> /// <returns><code>true</code> if at least one of predicate run succeeded and <code>false</code> - if all failed</returns> public static bool ImageViewerImageOperation(IImageViewer imageViewer, bool stopOnFirstMatch, Func <IPresentationImage, bool> predicate, bool displayedImagesOnly) { if (imageViewer == null) { throw new ArgumentNullException("imageViewer"); } if (predicate == null) { throw new ArgumentNullException("predicate"); } bool predicateWorked = false; // Go through displayed images first foreach (IImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes) { if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0) { continue; } foreach (var presentationImage in imageBox.DisplaySet.PresentationImages) { predicateWorked |= predicate(presentationImage); if (predicateWorked && stopOnFirstMatch) { return(true); } } } if (!displayedImagesOnly) { // Go through other available images foreach (IImageSet imageSet in imageViewer.LogicalWorkspace.ImageSets) { foreach (IDisplaySet displaySet in imageSet.DisplaySets) { if (displaySet.PresentationImages.Count == 0) { continue; } foreach (var presentationImage in displaySet.PresentationImages) { predicateWorked |= predicate(presentationImage); if (predicateWorked && stopOnFirstMatch) { return(true); } } } } } return(predicateWorked); }
internal override void SetImageViewer(IImageViewer imageViewer) { base.SetImageViewer(imageViewer); foreach (Graphic graphic in this.Graphics) { graphic.SetImageViewer(imageViewer); } }
internal static void OnViewerOpened(IImageViewer viewer) { if (!KeyImageClipboards.ContainsKey(viewer)) { KeyImageClipboards[viewer] = new KeyImageClipboard(viewer.StudyTree); } ManageActivityMonitorConnection(); }
private SingleStudyLoader(SynchronizationContext uiThreadContext, IImageViewer viewer) { Platform.CheckForNullReference(uiThreadContext, "uiThreadContext"); IsValidPrior = false; _uiThreadContext = uiThreadContext; _viewer = viewer; LoadOnlineOnly = false; }
public IPresentationImage GetSelectedPI() { IPresentationImage selectedPresentationImage = null; if (this._window.ActiveWorkspace.Component is IImageViewer) { IImageViewer component = (IImageViewer)this._window.ActiveWorkspace.Component; selectedPresentationImage = component.SelectedPresentationImage; } return selectedPresentationImage; }
public static void Create(IDesktopWindow desktopWindow, IImageViewer viewer) { IDisplaySet selectedDisplaySet = viewer.SelectedImageBox.DisplaySet; string name = String.Format("{0} - Dynamic TE", selectedDisplaySet.Name); IDisplaySet t2DisplaySet = new DisplaySet(name, ""); double currentSliceLocation = 0.0; BackgroundTask task = new BackgroundTask( delegate(IBackgroundTaskContext context) { int i = 0; foreach (IPresentationImage image in selectedDisplaySet.PresentationImages) { IImageSopProvider imageSopProvider = image as IImageSopProvider; if (imageSopProvider == null) continue; ImageSop imageSop = imageSopProvider.ImageSop; Frame frame = imageSopProvider.Frame; if (frame.SliceLocation != currentSliceLocation) { currentSliceLocation = frame.SliceLocation; try { DynamicTePresentationImage t2Image = CreateT2Image(imageSop, frame); t2DisplaySet.PresentationImages.Add(t2Image); } catch (Exception e) { Platform.Log(LogLevel.Error, e); desktopWindow.ShowMessageBox("Unable to create T2 series. Please check the log for details.", MessageBoxActions.Ok); break; } } string message = String.Format("Processing {0} of {1} images", i, selectedDisplaySet.PresentationImages.Count); i++; BackgroundTaskProgress progress = new BackgroundTaskProgress(i, selectedDisplaySet.PresentationImages.Count, message); context.ReportProgress(progress); } }, false); ProgressDialog.Show(task, desktopWindow, true, ProgressBarStyle.Blocks); viewer.LogicalWorkspace.ImageSets[0].DisplaySets.Add(t2DisplaySet); }
void IPrefetchingStrategy.Start(IImageViewer imageViewer) { Platform.CheckForNullReference(imageViewer, "imageViewer"); //Only start if we haven't already been started. if (_imageViewer == null) { _imageViewer = imageViewer; Start(); } }
public override void Initialize() { base.Initialize(); this.Context.DesktopWindow.Workspaces.ItemActivationChanged += OnWorkspaceActivationChanged; _viewer = base.ImageViewer; lock(_syncLock) { _tools.Add(this); } }
private void CreateObjects() { _viewer = new ImageViewerComponent(); _imageBox = new ImageBox(); _tile1 = new Tile(); _tile2 = new Tile(); _imageSet = new ImageSet(); _displaySet = new DisplaySet(); _image1 = new TestPresentationImage(); _image2 = new TestPresentationImage(); }
/// <summary> /// Performs given operation on the images in the given Image Viewer /// </summary> /// <param name="imageViewer">reference to <code>IImageViewer</code> that the operation has to be performed on</param> /// <param name="stopOnFirstMatch">when <code>true</code>, will return after the first successful predicate operation.</param> /// <param name="predicate">Operation to execute on each <code>IPresentationImage</code></param> /// <param name="displayedImagesOnly">when<code>true</code>, will only operated on visible <code>DisplaySet</code>s</param> /// <returns><code>true</code> if at least one of predicate run succeeded and <code>false</code> - if all failed</returns> public static bool ImageViewerImageOperation(IImageViewer imageViewer, bool stopOnFirstMatch, Func<IPresentationImage, bool> predicate, bool displayedImagesOnly) { if (imageViewer == null) throw new ArgumentNullException("imageViewer"); if (predicate == null) throw new ArgumentNullException("predicate"); bool predicateWorked = false; // Go through displayed images first foreach (IImageBox imageBox in imageViewer.PhysicalWorkspace.ImageBoxes) { if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0) continue; foreach (var presentationImage in imageBox.DisplaySet.PresentationImages) { predicateWorked |= predicate(presentationImage); if (predicateWorked && stopOnFirstMatch) return true; } } if (!displayedImagesOnly) { // Go through other available images foreach (IImageSet imageSet in imageViewer.LogicalWorkspace.ImageSets) { foreach (IDisplaySet displaySet in imageSet.DisplaySets) { if (displaySet.PresentationImages.Count == 0) continue; foreach (var presentationImage in displaySet.PresentationImages) { predicateWorked |= predicate(presentationImage); if (predicateWorked && stopOnFirstMatch) return true; } } } } return predicateWorked; }
public TestTree() { _viewer = new ImageViewerComponent(); _imageBox1 = new ImageBox(); _imageBox2 = new ImageBox(); _tile1 = new Tile(); _tile2 = new Tile(); _tile3 = new Tile(); _tile4 = new Tile(); _imageSet1 = new ImageSet(); _displaySet1 = new DisplaySet(); _displaySet2 = new DisplaySet(); _image1 = new TestPresentationImage(); _image2 = new TestPresentationImage(); _image3 = new TestPresentationImage(); _image4 = new TestPresentationImage(); _viewer.PhysicalWorkspace.ImageBoxes.Add(_imageBox1); _viewer.PhysicalWorkspace.ImageBoxes.Add(_imageBox2); _imageBox1.Tiles.Add(_tile1); _imageBox1.Tiles.Add(_tile2); _imageBox2.Tiles.Add(_tile3); _imageBox2.Tiles.Add(_tile4); _viewer.LogicalWorkspace.ImageSets.Add(_imageSet1); _imageSet1.DisplaySets.Add(_displaySet1); _imageSet1.DisplaySets.Add(_displaySet2); _displaySet1.PresentationImages.Add(_image1); _displaySet1.PresentationImages.Add(_image2); _displaySet2.PresentationImages.Add(_image3); _displaySet2.PresentationImages.Add(_image4); _imageBox1.DisplaySet = _displaySet1; _imageBox2.DisplaySet = _displaySet2; }
public static bool StartAimAnnotationTool(IImageViewer currentImageViewer) { if (currentImageViewer == null) return false; var actionPath = new ActionPath(BUTTON_ACTION_PATH, new ResourceResolver(typeof(AimAnnotationTool), true)); IActionSet actionSet = currentImageViewer.ExportedActions.Select(action => action.Path.LocalizedPath == actionPath.LocalizedPath); if (actionSet != null) { foreach (IAction action in actionSet) { ClickAction clickAction = action as ClickAction; if (clickAction != null) { clickAction.Click(); return true; } } } return false; }
internal static void OnViewerOpened(IImageViewer viewer) { if (!_keyImageInformation.ContainsKey(viewer)) _keyImageInformation[viewer] = new KeyImageInformation(); ManageActivityMonitorConnection(); }
internal static KeyImageInformation GetKeyImageInformation(IImageViewer viewer) { if (!PermissionsHelper.IsInRole(AuthorityTokens.KeyImages)) throw new PolicyException(SR.ExceptionViewKeyImagePermissionDenied); if (viewer != null) return _keyImageInformation[viewer]; else return null; }
internal static bool IsExploded(IImageViewer viewer) { var proxy = viewer.ExtensionData[typeof(ExtensionDataProxy)] as ExtensionDataProxy; return proxy != null && proxy.Tool.Checked; }
public TestToolContext(IImageViewer viewer) { Viewer = viewer; }
internal static void AssignDisplaySetToImageBox(IImageViewer viewer, IDisplaySet displaySet) { AssignDisplaySetToImageBox(viewer.SelectedImageBox, displaySet); }
private static bool AnySopsLoaded(IImageViewer imageViewer) { foreach (Patient patient in imageViewer.StudyTree.Patients) { foreach (Study study in patient.Studies) { foreach (Series series in study.Series) { foreach (Sop sop in series.Sops) { return true; } } } } return false; }
/// <summary> /// Find requested image in the ImageViewer and makes it selected. Will load a series if it's not loaded. /// </summary> /// <param name="imageViewer">ImageViewer that hosts the requested image</param> /// <param name="sopInstanceUid">SOP Instance UID of the image</param> /// <param name="frameNumber">image frame number (1 - first image)</param> /// <returns>Returns requested image or <code>null</code> if the image is not found.</returns> public static IPresentationImage SelectImage(IImageViewer imageViewer, string sopInstanceUid, int frameNumber) { // Search displayed images first foreach (var imageBox in imageViewer.PhysicalWorkspace.ImageBoxes) { if (imageBox.DisplaySet == null || imageBox.DisplaySet.PresentationImages == null || imageBox.DisplaySet.PresentationImages.Count == 0) continue; var presentationImage = imageBox.DisplaySet.PresentationImages.Cast<IImageSopProvider>().FirstOrDefault( pi => pi.ImageSop.SopInstanceUid == sopInstanceUid && pi.Frame.FrameNumber == frameNumber) as IPresentationImage; if (presentationImage == null) continue; try { // Unselect selected in a different image box if (!imageBox.Selected) UnselectCurrentGraphics(imageViewer.PhysicalWorkspace.SelectedImageBox); imageBox.TopLeftPresentationImage = presentationImage; imageBox.Tiles[0].Select(); imageBox.Draw(); return presentationImage; } catch (Exception ex) { ExceptionHandler.Report(ex, imageViewer.DesktopWindow); } } // Search other available images foreach (var imageSet in imageViewer.LogicalWorkspace.ImageSets) { foreach (var displaySet in imageSet.DisplaySets) { var presentationImage = displaySet.PresentationImages.Cast<IImageSopProvider>().FirstOrDefault( pi => pi.ImageSop.SopInstanceUid == sopInstanceUid && pi.Frame.FrameNumber == frameNumber) as IPresentationImage; if (presentationImage == null) continue; try { var targetImageBox = imageViewer.PhysicalWorkspace.SelectedImageBox ?? (imageViewer.PhysicalWorkspace.ImageBoxes.Count > 0 ? imageViewer.PhysicalWorkspace.ImageBoxes[0] : null); if (targetImageBox == null) { imageViewer.DesktopWindow.ShowMessageBox("Failed to find available display", MessageBoxActions.Ok); Platform.Log(LogLevel.Error, "Failed to locate a target ImageBox to display selected image."); return null; } var targetDisplaySet = displaySet.CreateFreshCopy(); var targetPresentationImage = targetDisplaySet.PresentationImages.Cast<IImageSopProvider>().FirstOrDefault( pi => pi.ImageSop.SopInstanceUid == sopInstanceUid && pi.Frame.FrameNumber == frameNumber) as IPresentationImage; if (targetPresentationImage == null) { imageViewer.DesktopWindow.ShowMessageBox("Failed to find required image", MessageBoxActions.Ok); Platform.Log(LogLevel.Error, "Failed to locate a target PresentationImage in a new DisplaySet."); return null; } // Unselect selected in a different image box if (!targetImageBox.Selected) UnselectCurrentGraphics(imageViewer.PhysicalWorkspace.SelectedImageBox); targetImageBox.DisplaySet = targetDisplaySet; targetImageBox.TopLeftPresentationImage = targetPresentationImage; targetImageBox.Tiles[0].Select(); targetImageBox.Draw(); return targetPresentationImage; } catch (Exception ex) { ExceptionHandler.Report(ex, imageViewer.DesktopWindow); } } } return null; }
private static List<string> GetAdditionalStudyInstanceUids(IImageViewer viewer) { List<string> studyInstanceUids = new List<string>(); foreach (Patient patient in viewer.StudyTree.Patients) { foreach (Study study in patient.Studies) { studyInstanceUids.Add(study.StudyInstanceUid); } } if (studyInstanceUids.Count > 0) studyInstanceUids.RemoveAt(0); return studyInstanceUids; }
private static StudyRootStudyIdentifier GetPrimaryStudyIdentifier(IImageViewer viewer) { // TODO CR (Oct 12): Add support for patient reconciliation (after we move that concept into viewer common) return viewer.StudyTree.Patients.SelectMany(p => p.Studies).Select(s => new StudyRootStudyIdentifier(s.GetIdentifier())).FirstOrDefault(); }
private static string GetPrimaryStudyInstanceUid(IImageViewer viewer) { foreach (Patient patient in viewer.StudyTree.Patients) { foreach (Study study in patient.Studies) { return study.StudyInstanceUid; } } return null; }
/// <summary> /// As long as the primary study is loaded, even partially, we continue opening the viewer and /// just report the loading errors to the user. If other studies failed to load, we still just /// open the viewer and report to the user. /// </summary> private static void HandleLoadStudiesException(Exception e, string primaryStudyInstanceUid, IImageViewer viewer) { if (GetPrimaryStudyInstanceUid(viewer) == primaryStudyInstanceUid) return; //the primary study was at least partiallly loaded. if (e is NotFoundLoadStudyException) throw new FaultException<StudyNotFoundFault>(new StudyNotFoundFault(), "The study was not found."); if (e is NearlineLoadStudyException) throw new FaultException<StudyNearlineFault>(new StudyNearlineFault { IsStudyBeingRestored = ((NearlineLoadStudyException)e).IsStudyBeingRestored }, "The study is nearline."); if (e is OfflineLoadStudyException) throw new FaultException<StudyOfflineFault>(new StudyOfflineFault(), "The study is offline."); if (e is InUseLoadStudyException) throw new FaultException<StudyInUseFault>(new StudyInUseFault(), "The study is in use."); if (e is StudyLoaderNotFoundException) { const string reason = "The study cannot be loaded directly from the specified server/location."; throw new FaultException<OpenStudiesFault>(new OpenStudiesFault { FailureDescription = reason }, reason); } throw new FaultException<OpenStudiesFault>(new OpenStudiesFault(), "The primary study could not be loaded."); }
public LocalSopLoader(IImageViewer viewer) { _viewer = viewer; }
public ToolModalityBehaviorHelper(IImageViewer imageViewer) { _imageViewer = imageViewer; }
void IPrefetchingStrategy.Stop() { if(_imageViewer != null) { Stop(); _imageViewer = null; } }
internal static void OnViewerClosed(IImageViewer viewer) { KeyImageInformation info = GetKeyImageInformation(viewer); _keyImageInformation.Remove(viewer); if (info != null) { using(info) { try { var publisher = new KeyImagePublisher(info); publisher.Publish(); } catch (Exception e) { //Should never happen because KeyImagePublisher.Publish doesn't throw exceptions. ExceptionHandler.Report(e, Application.ActiveDesktopWindow); } } } ManageActivityMonitorConnection(); }
void IViewerSetupHelper.SetImageViewer(IImageViewer viewer) { ImageViewer = viewer; }
private static Workspace GetViewerWorkspace(IImageViewer viewer) { foreach (Workspace workspace in GetViewerWorkspaces()) { IImageViewer workspaceViewer = ImageViewerComponent.GetAsImageViewer(workspace); if (viewer == workspaceViewer) return workspace; } return null; }
/// <summary> /// Performs given operation on the images in the given Image Viewer /// </summary> /// <param name="imageViewer">reference to <code>IImageViewer</code> that the operation has to be performed on</param> /// <param name="stopOnFirstMatch">when <code>true</code>, will return after the first successful predicate operation.</param> /// <param name="predicate">Operation to execute on each <code>IPresentationImage</code></param> /// <returns><code>true</code> if at least one of predicate runs succeeded and <code>false</code> - if all failed</returns> public static bool ImageViewerImageOperation(IImageViewer imageViewer, bool stopOnFirstMatch, Func<IPresentationImage, bool> predicate) { return ImageViewerImageOperation(imageViewer, stopOnFirstMatch, predicate, false); }
internal virtual void SetImageViewer(IImageViewer imageViewer) { _parentImageViewer = imageViewer; }
internal static List<IGraphic> PopulateImageViewerWithSavedMarkup(List<IMarkup> markupList, IImageViewer imageViewer) { var graphics = new List<IGraphic>(); foreach (var markup in markupList) { foreach (var box in imageViewer.PhysicalWorkspace.ImageBoxes) { if (box.DisplaySet == null) continue; var imageSop = box.DisplaySet.PresentationImages.Cast<IImageSopProvider>().FirstOrDefault( pi => pi.ImageSop.SopInstanceUid == markup.PresentationImageUid && pi.Frame.FrameNumber == markup.FrameNumber); var selectedPresentationImage = imageSop as IPresentationImage; if (selectedPresentationImage == null) continue; var graphicsProvider = selectedPresentationImage as IOverlayGraphicsProvider; if (graphicsProvider != null) { if (markup is MarkupEllipse) { var markupEllipse = (MarkupEllipse)markup; var ellipsePrimitive = new EllipsePrimitive(); var roiGraphic = new RoiGraphic(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic( new MoveControlGraphic(ellipsePrimitive)))); var boundableGraphic = roiGraphic.Subject as BoundableGraphic; markup.GraphicHashcode = roiGraphic.GetHashCode(); graphics.Add(roiGraphic); graphicsProvider.OverlayGraphics.Add(roiGraphic); if (boundableGraphic != null) { roiGraphic.Suspend(); // prevent callout location calculation until all points are set roiGraphic.Name = markup.Name; ellipsePrimitive.BottomRight = markupEllipse.BottomRight; ellipsePrimitive.TopLeft = markupEllipse.TopLeft; roiGraphic.State = roiGraphic.CreateInactiveState(); roiGraphic.Resume(true); // Force callout location calculation roiGraphic.Callout.TextLocation = markupEllipse.CalloutLocation; } } else if (markup is MarkupPolygonal) { var markupPolygon = (MarkupPolygonal)markup; var polyline = new PolylineGraphic(true); foreach (var point in markupPolygon.Vertices) polyline.Points.Add(point); var roiGraphic = new RoiGraphic(new PolygonControlGraphic(true, new MoveControlGraphic(polyline))); markup.GraphicHashcode = roiGraphic.GetHashCode(); graphics.Add(roiGraphic); graphicsProvider.OverlayGraphics.Add(roiGraphic); //if (boundableGraphic != null) { roiGraphic.Suspend(); // prevent callout location calculation until all points are set roiGraphic.Name = markup.Name; roiGraphic.State = roiGraphic.CreateInactiveState(); roiGraphic.Resume(true); // Force callout location calculation roiGraphic.Callout.TextLocation = markupPolygon.CalloutLocation; } } else if (markup is MarkupRectangle) { var markupRectangle = (MarkupRectangle)markup; var rectanglePrimitive = new RectanglePrimitive(); var roiGraphic = new RoiGraphic(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic( new MoveControlGraphic(rectanglePrimitive)))); var boundableGraphic = roiGraphic.Subject as BoundableGraphic; markup.GraphicHashcode = roiGraphic.GetHashCode(); graphics.Add(roiGraphic); graphicsProvider.OverlayGraphics.Add(roiGraphic); if (boundableGraphic != null) { roiGraphic.Suspend(); // prevent callout location calculation until all points are set roiGraphic.Name = markup.Name; rectanglePrimitive.BottomRight = markupRectangle.BottomRight; rectanglePrimitive.TopLeft = markupRectangle.TopLeft; roiGraphic.State = roiGraphic.CreateInactiveState(); roiGraphic.Resume(true); // Force callout location calculation roiGraphic.Callout.TextLocation = markupRectangle.CalloutLocation; } } else if (markup is MarkupProtractor) { var markupProtractor = (MarkupProtractor)markup; var protractorGraphic = new ProtractorGraphic(); foreach (var point in markupProtractor.Points) protractorGraphic.Points.Add(point); var roiGraphic = new RoiGraphic(new VerticesControlGraphic(new MoveControlGraphic(protractorGraphic))); markup.GraphicHashcode = roiGraphic.GetHashCode(); graphics.Add(roiGraphic); graphicsProvider.OverlayGraphics.Add(roiGraphic); roiGraphic.Suspend(); // prevent callout location calculation until all points are set roiGraphic.Name = markup.Name; roiGraphic.State = roiGraphic.CreateInactiveState(); roiGraphic.Resume(true); // Force callout location calculation roiGraphic.Callout.TextLocation = markupProtractor.CalloutLocation; } else if (markup is MarkupLinear) { var markupLinear = (MarkupLinear)markup; var polylineGraphic = new PolylineGraphic(); foreach (var point in markupLinear.Vertices) polylineGraphic.Points.Add(point); var roiGraphic = new RoiGraphic(new VerticesControlGraphic(new MoveControlGraphic(polylineGraphic))); markup.GraphicHashcode = roiGraphic.GetHashCode(); graphics.Add(roiGraphic); graphicsProvider.OverlayGraphics.Add(roiGraphic); roiGraphic.Suspend(); // prevent callout location calculation until all points are set roiGraphic.Name = markup.Name; roiGraphic.State = roiGraphic.CreateInactiveState(); roiGraphic.Resume(true); // Force callout location calculation roiGraphic.Callout.TextLocation = markupLinear.CalloutLocation; } else if (markup is MarkupPoint) { var markupPoint = (MarkupPoint)markup; IGraphic calloutGraphic; if (markupPoint.UseCrosshair) { calloutGraphic = new UserCrosshairCalloutGraphic { AnchorPoint = markupPoint.Point, TextLocation = markupPoint.CalloutLocation, Text = markupPoint.CalloutText, ShowShaft = !String.IsNullOrEmpty(markupPoint.CalloutText), LineStyle = LineStyle.Dot }; } else { calloutGraphic = new UserCalloutGraphic { AnchorPoint = markupPoint.Point, TextLocation = markupPoint.CalloutLocation, Text = markupPoint.CalloutText, ShowArrowhead = true, LineStyle = LineStyle.Solid }; } var statefulGraphic = new StandardStatefulGraphic(calloutGraphic); statefulGraphic.State = statefulGraphic.CreateInactiveState(); var contextGraphic = new ContextMenuControlGraphic(typeof(ClearCanvas.ImageViewer.Tools.Standard.TextCalloutTool).FullName, "basicgraphic-menu", null, statefulGraphic); contextGraphic.Actions = new ToolSet(new GraphicToolExtensionPoint(), new GraphicToolContext(contextGraphic)).Actions; //if (markupPoint.Name != "RemoveForCalloutPlacement") { markup.GraphicHashcode = contextGraphic.GetHashCode(); graphics.Add(contextGraphic); graphicsProvider.OverlayGraphics.Add(contextGraphic); //selectedPresentationImage.Draw(); } } } box.TopLeftPresentationImage = selectedPresentationImage; box.Tiles[0].Select(); box.Draw(); break; } } return graphics; }
internal override void SetImageViewer(IImageViewer imageViewer) { base.SetImageViewer(imageViewer); foreach (Graphic graphic in this.Graphics) graphic.SetImageViewer(imageViewer); }