/// <summary> /// Convenience method to create a common polygonal, interactive region of interest. /// </summary> /// <returns>A new interactive region of interest graphic.</returns> public static RoiGraphic CreatePolygon() { RoiGraphic roiGraphic = new RoiGraphic(new PolygonControlGraphic(true, new MoveControlGraphic(new PolylineGraphic(true)))); roiGraphic.State = roiGraphic.CreateInactiveState(); return(roiGraphic); }
/// <summary> /// Invokes an interactive edit box on the name of the graphic, allowing the user to assign a name to the <see cref="RoiGraphic"/>. /// </summary> public void Rename() { RoiGraphic parent = this.ParentGraphic; if (parent == null) { return; } this.CoordinateSystem = CoordinateSystem.Destination; try { EditBox editBox = new EditBox(parent.Name ?? string.Empty); editBox.Location = Point.Round(base.TextGraphic.Location); editBox.Size = Size.Round(base.TextGraphic.BoundingBox.Size); editBox.FontName = base.TextGraphic.Font; editBox.FontSize = base.TextGraphic.SizeInPoints; editBox.Multiline = false; editBox.ValueAccepted += OnEditBoxAccepted; editBox.ValueCancelled += OnEditBoxCancelled; base.ParentPresentationImage.Tile.EditBox = editBox; } finally { this.ResetCoordinateSystem(); } }
/// <summary> /// Convenience method to create a common rectangular, interactive region of interest. /// </summary> /// <returns>A new interactive region of interest graphic.</returns> public static RoiGraphic CreateRectangle() { RoiGraphic roiGraphic = new RoiGraphic(new BoundableResizeControlGraphic(new BoundableStretchControlGraphic(new MoveControlGraphic(new RectanglePrimitive())))); roiGraphic.State = roiGraphic.CreateInactiveState(); return(roiGraphic); }
private void ToggleShowAnalysis() { this.ShowAnalysis = !_showAnalysis; RoiGraphic parent = this.ParentGraphic; if (parent != null) { if (_showAnalysis) { parent.Refresh(); } else { parent.Draw(); } } }
private void OnEditBoxAccepted(object sender, EventArgs e) { EditBox editBox = (EditBox)sender; editBox.ValueAccepted -= OnEditBoxAccepted; editBox.ValueCancelled -= OnEditBoxCancelled; if (base.ParentPresentationImage != null) { base.ParentPresentationImage.Tile.EditBox = null; } RoiGraphic parent = base.ParentGraphic as RoiGraphic; if (parent != null) { parent.Name = editBox.Value; this.Update(); this.Draw(); } }
/// <summary> /// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout. /// </summary> /// <param name="roi">A particular region of interest information object to use when computing statistics.</param> /// <param name="mode">A value indicating whether or not the current region of interest is in the state of changing, and therefore whether or not analyzers should skip expensive computations.</param> public void Update(Roi roi, RoiAnalysisMode mode) { if (this.ImageViewer == null) { return; } StringBuilder builder = new StringBuilder(); RoiGraphic parent = this.ParentGraphic; if (parent != null && !string.IsNullOrEmpty(parent.Name)) { builder.AppendLine(parent.Name); } if (_showAnalysis && _roiAnalyzers.Count > 0 && roi != null) { try { foreach (IRoiAnalyzer analyzer in _roiAnalyzers) { if (analyzer.SupportsRoi(roi)) { var analysis = analyzer.Analyze(roi, mode); if (analysis != null) { builder.AppendLine(analysis.SerializedAsString()); } } } } catch (Exception e) { Platform.Log(LogLevel.Error, e); builder.AppendLine(SR.MessageRoiAnalysisError); } } base.Text = builder.ToString().Trim(); }
/// <summary> /// Cloning constructor. /// </summary> /// <param name="source">The source object from which to clone.</param> /// <param name="context">The cloning context object.</param> protected RoiGraphic(RoiGraphic source, ICloningContext context) : base(source, context) { context.CloneFields(source, this); }
/// <summary> /// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout immediately. /// </summary> /// <param name="mode">A value indicating whether or not the current region of interest is in the state of changing, and therefore whether or not analyzers should skip expensive computations.</param> public void Update(RoiAnalysisMode mode) { RoiGraphic roiGraphic = this.ParentGraphic; this.Update(roiGraphic.GetRoi(), mode); }
/// <summary> /// Forces the callout to update, allowing all the analyzers to recompute and update the text content of the callout immediately. /// </summary> public void Update() { RoiGraphic roiGraphic = this.ParentGraphic; this.Update(roiGraphic.GetRoi(), RoiAnalysisMode.Normal); }