public GraphObjTag(ChromGraphItem chromGraphItem, GraphObjType graphObjType, ScaledRetentionTime start, ScaledRetentionTime end) { ChromGraphItem = chromGraphItem; GraphObjType = graphObjType; StartTime = start; EndTime = end; }
private void ZoomXAxis(double min, double max) { foreach (var graphPaneKeyItem in ListPrimaryGraphItems()) { ScaledRetentionTime scaledMin = graphPaneKeyItem.Value.ScaleRetentionTime(min); ScaledRetentionTime scaledMax = graphPaneKeyItem.Value.ScaleRetentionTime(max); var graphPane = _displayState.GetGraphPane(GraphControl, graphPaneKeyItem.Key); var axis = graphPane.XAxis; axis.Scale.Min = scaledMin.DisplayTime; axis.Scale.MinAuto = false; axis.Scale.Max = scaledMax.DisplayTime; axis.Scale.MaxAuto = false; } }
private void AddPeakRawTimes(GraphPane graphPane, ICollection <GraphObj> annotations, ScaledRetentionTime startTime, ScaledRetentionTime endTime, ChromatogramInfo info) { var hasTimes = info.RawTimes != null && info.RawTimes.Any(); // has measured points var scaledHeight = graphPane.YAxis.Scale.Max / 20; // 5% of graph pane height var rawtimes = new List <double>(); if (hasTimes) { rawtimes.AddRange(GetRawTimes(startTime, endTime, info)); if (rawtimes.Count == 0) { return; } foreach (var time in rawtimes) { LineObj stick = new LineObj(time, scaledHeight, time, 0) { IsClippedToChartRect = true, Location = { CoordinateFrame = CoordType.AxisXYScale }, ZOrder = ZOrder.A_InFront, Line = { Width = 1, Style = DashStyle.Dash, Color = ColorSelected }, Tag = new GraphObjTag(this, GraphObjType.raw_time, new ScaledRetentionTime(time)), }; annotations.Add(stick); } } var countTxt = hasTimes ? " " + rawtimes.Count : " ?"; // Not L10N var isBold = !hasTimes; // Question mark if no times exist is visually clearer if bold TextObj pointCount = new TextObj(countTxt, endTime.DisplayTime, scaledHeight) // Not L10N { FontSpec = new FontSpec(FontSpec.Family, FontSpec.Size, ColorSelected, isBold, false, false) { Border = new Border { IsVisible = false }, Fill = new Fill() }, Location = { AlignH = AlignH.Left, AlignV = AlignV.Bottom } }; annotations.Add(pointCount); }
private IEnumerable <double> GetRawTimes(ScaledRetentionTime startTime, ScaledRetentionTime endTime, ChromatogramInfo info) { double end = endTime.DisplayTime; double start = startTime.DisplayTime; var times = info.RawTimes; if (times != null) { for (int j = 0; j < times.Count; j++) { if (start > times[j]) { continue; } if (end < times[j]) { break; } yield return(times[j]); } } }
private void AddPeakBoundaries(GraphPane graphPane, ICollection <GraphObj> annotations, bool best, ScaledRetentionTime startTime, ScaledRetentionTime endTime, double maxIntensity) { // Only show boundaries for dragging when boundaries turned off if (!Settings.Default.ShowPeakBoundaries && (!best || DragInfo == null)) { return; } float xStart = graphPane.XAxis.Scale.Transform(startTime.DisplayTime); float xEnd = graphPane.XAxis.Scale.Transform(endTime.DisplayTime); // Hide boundaries, if they are too close together if (xEnd - xStart <= MIN_BOUNDARY_DISPLAY_WIDTH) { // But not if they are currently part of a drag operation. if (DragInfo == null) { return; } } // Make sure the best borders are visible if (best) { float yMax = graphPane.YAxis.Scale.Transform(maxIntensity); float yZero = graphPane.YAxis.Scale.Transform(0); if (yZero - yMax < MIN_BEST_BOUNDARY_HEIGHT) { maxIntensity = graphPane.YAxis.Scale.ReverseTransform(yZero - MIN_BEST_BOUNDARY_HEIGHT); } } // Summary graphs show only the best peak boundaries else if (_isSummary) { return; } Color colorBoundaries = (best ? COLOR_BOUNDARIES_BEST : COLOR_BOUNDARIES); GraphObjType graphObjType = best ? GraphObjType.best_peak : GraphObjType.peak; // Make sure to get maximum intensity within the peak range, // as this is not guaranteed to be the center of the peak LineObj stickStart = new LineObj(colorBoundaries, startTime.DisplayTime, maxIntensity, startTime.DisplayTime, 0) { IsClippedToChartRect = true, Location = { CoordinateFrame = CoordType.AxisXYScale }, ZOrder = ZOrder.B_BehindLegend, Line = { Width = 1, Style = DashStyle.Dash }, Tag = new GraphObjTag(this, graphObjType, startTime), }; annotations.Add(stickStart); LineObj stickEnd = new LineObj(colorBoundaries, endTime.DisplayTime, maxIntensity, endTime.DisplayTime, 0) { IsClippedToChartRect = true, Location = { CoordinateFrame = CoordType.AxisXYScale }, ZOrder = ZOrder.B_BehindLegend, Line = { Width = 1, Style = DashStyle.Dash }, Tag = new GraphObjTag(this, graphObjType, endTime), }; annotations.Add(stickEnd); }
private void AddRetentionTimeAnnotation(MSGraphPane graphPane, Graphics g, GraphObjList annotations, PointF ptTop, string title, GraphObjType graphObjType, Color color, ScaledRetentionTime retentionTime) { string label = string.Format("{0}\n{1:F01}", title, retentionTime.DisplayTime); // Not L10N FontSpec fontLabel = CreateFontSpec(color, _fontSpec.Size); SizeF sizeLabel = fontLabel.MeasureString(g, label, graphPane.CalcScaleFactor()); PointF realTopPoint = ptTop; ptTop = new PointF(0, ptTop.Y + sizeLabel.Height + 15); float chartHeightWithLabel = graphPane.Chart.Rect.Height + sizeLabel.Height + 15; double intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel; LineObj stick = new LineObj(color, retentionTime.DisplayTime, intensityChartFraction, retentionTime.DisplayTime, 1) { IsClippedToChartRect = true, Location = { CoordinateFrame = CoordType.XScaleYChartFraction }, ZOrder = ZOrder.E_BehindCurves, Line = { Width = 1 }, Tag = new GraphObjTag(this, graphObjType, retentionTime), }; annotations.Add(stick); ptTop = new PointF(0, ptTop.Y - 5); intensityChartFraction = (ptTop.Y - realTopPoint.Y) / chartHeightWithLabel; TextObj text = new TextObj(label, retentionTime.DisplayTime, intensityChartFraction, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Bottom) { IsClippedToChartRect = true, ZOrder = ZOrder.E_BehindCurves, FontSpec = CreateFontSpec(color, _fontSpec.Size), Tag = new GraphObjTag(this, graphObjType, retentionTime), }; annotations.Add(text); }
public override void AddPreCurveAnnotations(MSGraphPane graphPane, Graphics g, MSPointList pointList, GraphObjList annotations) { if (Chromatogram == null) { return; } // Give priority to showing the best peak text object above all other annotations if (DragInfo != null || (!HideBest && TransitionChromInfo != null) || CurveAnnotation != null) { // Show text and arrow for the best peak double intensityBest = 0; if (_bestPeakTimeIndex != -1) { ScaledRetentionTime timeBest = new ScaledRetentionTime(_measuredTimes[_bestPeakTimeIndex], _displayTimes[_bestPeakTimeIndex]); float xBest = graphPane.XAxis.Scale.Transform(timeBest.DisplayTime); intensityBest = _intensities[_bestPeakTimeIndex]; float yBest = graphPane.YAxis.Scale.Transform(intensityBest); if (GraphChromatogram.ShowRT != ShowRTChrom.none || DragInfo != null) { // Best peak gets its own label to avoid curve overlap detection double intensityLabel = graphPane.YAxis.Scale.ReverseTransform(yBest - 5); float? massError = Settings.Default.ShowMassError && TransitionChromInfo != null ? TransitionChromInfo.MassError : null; double dotProduct = _dotProducts != null ? _bestProduct : 0; TextObj text; if (CurveAnnotation != null) { // Darken peptide name a little so light colors stand out against the white background. var color = FontSpec.FontColor; if (!GraphInfo.IsSelected) { color = Color.FromArgb(color.R * 7 / 10, color.G * 7 / 10, color.B * 7 / 10); } var fontSpec = new FontSpec(FontSpec) { FontColor = color, Angle = 90 }; if (GraphInfo.IsSelected) { fontSpec = new FontSpec(fontSpec) { IsBold = true, Size = fontSpec.Size + 2, IsAntiAlias = true } } ; // Display peptide name label using vertical text. text = new TextObj(CurveAnnotation, timeBest.DisplayTime, intensityLabel, CoordType.AxisXYScale, AlignH.Left, AlignV.Center) { ZOrder = ZOrder.A_InFront, IsClippedToChartRect = true, FontSpec = fontSpec, Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest), }; } else { string label = FormatTimeLabel(timeBest.DisplayTime, massError, dotProduct); text = new TextObj(label, timeBest.DisplayTime, intensityLabel, CoordType.AxisXYScale, AlignH.Center, AlignV.Bottom) { ZOrder = ZOrder.A_InFront, IsClippedToChartRect = true, FontSpec = FontSpec, Tag = new GraphObjTag(this, GraphObjType.best_peak, timeBest), }; } annotations.Add(text); } // If showing multiple peptides, skip the best peak arrow indicator. if (CurveAnnotation == null) { // Show the best peak arrow indicator double timeArrow = graphPane.XAxis.Scale.ReverseTransform(xBest - 4); double intensityArrow = graphPane.YAxis.Scale.ReverseTransform(yBest - 2); ArrowObj arrow = new ArrowObj(COLOR_BEST_PEAK, 12f, timeArrow, intensityArrow, timeArrow, intensityArrow) { Location = { CoordinateFrame = CoordType.AxisXYScale }, IsArrowHead = true, IsClippedToChartRect = true, ZOrder = ZOrder.A_InFront }; annotations.Add(arrow); } } // Show the best peak boundary lines if (CurveAnnotation == null) { double startTime = 0, endTime = 0; if (DragInfo != null) { startTime = DragInfo.StartTime.MeasuredTime; endTime = DragInfo.EndTime.MeasuredTime; } else if (TransitionChromInfo != null) { var tranPeakInfo = TransitionChromInfo; startTime = tranPeakInfo.StartRetentionTime; endTime = tranPeakInfo.EndRetentionTime; } AddPeakBoundaries(graphPane, annotations, true, ScaleRetentionTime(startTime), ScaleRetentionTime(endTime), intensityBest); } if (Chromatogram.BestPeakIndex >= 0) { // Only shade peak when user modified. Otherwise, shading can be added when an entire // precursor was force integrated because of another precursor (e.g. heavy) since that // leads to an empty peak, which will not match the best peak. if (Settings.Default.ShowOriginalPeak && TransitionChromInfo != null && TransitionChromInfo.IsUserModified) { var bestPeak = Chromatogram.GetPeak(Chromatogram.BestPeakIndex); if (bestPeak.StartTime != TransitionChromInfo.StartRetentionTime || bestPeak.EndTime != TransitionChromInfo.EndRetentionTime) { AddOriginalPeakAnnotation(bestPeak, annotations, graphPane); } } } } if (_displayRawTimes.HasValue) { AddPeakRawTimes(graphPane, annotations, ScaleRetentionTime(_displayRawTimes.Value.StartBound), ScaleRetentionTime(_displayRawTimes.Value.EndBound), Chromatogram); } }
public GraphObjTag(ChromGraphItem chromGraphItem, GraphObjType graphObjType, ScaledRetentionTime retentionTime) { ChromGraphItem = chromGraphItem; GraphObjType = graphObjType; RetentionTime = retentionTime; }