Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public GraphObjTag(ChromGraphItem chromGraphItem, GraphObjType graphObjType, ScaledRetentionTime retentionTime)
 {
     ChromGraphItem = chromGraphItem;
     GraphObjType = graphObjType;
     RetentionTime = retentionTime;
 }
Esempio n. 3
0
        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);
                }
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        /// <summary>
        /// Indicates a peak has been picked at a specified retention time
        /// for a specific replicate of a specific <see cref="TransitionGroupDocNode"/>.
        /// </summary>
        /// <param name="nodeGroup">The transition group for which the peak was picked</param>
        /// <param name="nodeTran">The transition no which the time was chosen</param>
        /// <param name="peakTime">The retention time at which the peak was picked</param>
        public void FirePickedPeak(TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTran, ScaledRetentionTime peakTime)
        {
            if (PickedPeak != null)
            {
                var filePath = FilePath;
                if (filePath == null)
                    return;

                int iGroup = _nodeGroups.IndexOfReference(nodeGroup);
                var e = new PickedPeakEventArgs(_groupPaths[iGroup],
                                                nodeTran != null ? nodeTran.Id : null,
                                                _nameChromatogramSet,
                                                filePath,
                                                peakTime);
                PickedPeak(this, e);
            }
        }
Esempio n. 6
0
 public void FirePickedSpectrum(ScaledRetentionTime retentionTime)
 {
     if (PickedSpectrum != null)
         PickedSpectrum(this, new PickedSpectrumEventArgs(new SpectrumIdentifier(FilePath, retentionTime.MeasuredTime)));
 }
Esempio n. 7
0
 public PickedPeakEventArgs(IdentityPath groupPath, Identity transitionId,
     string nameSet, MsDataFileUri filePath, ScaledRetentionTime retentionTime)
     : base(groupPath, nameSet, filePath)
 {
     TransitionId = transitionId;
     RetentionTime = retentionTime;
 }
Esempio n. 8
0
 private PeakBoundsDragInfo StartDrag(GraphPane graphPane, ChromGraphItem graphItem, PointF pt,
     ScaledRetentionTime time, bool bothBoundaries)
 {
     var tranPeakInfo = graphItem.TransitionChromInfo;
     var startTime = time;
     var endTime = time;
     if (tranPeakInfo == null)
         bothBoundaries = true;
     else
     {
         startTime = graphItem.ScaleRetentionTime(tranPeakInfo.StartRetentionTime);
         endTime = graphItem.ScaleRetentionTime(tranPeakInfo.EndRetentionTime);
     }
     bool draggingEnd = Math.Abs(time.DisplayTime - startTime.DisplayTime) > Math.Abs(time.DisplayTime - endTime.DisplayTime);
     ScaledRetentionTime anchorTime, caretTime;
     if (bothBoundaries)
         anchorTime = caretTime = time;
     else if (draggingEnd)
     {
         anchorTime = startTime;
         caretTime = endTime;
     }
     else
     {
         anchorTime = endTime;
         caretTime = startTime;
     }
     var retentionMsMs = RetentionMsMs;
     bool alignedTimes = false;
     if (retentionMsMs == null)
     {
         retentionMsMs = AlignedRetentionMsMs;
         alignedTimes = true;
     }
     var dragType = (draggingEnd ? PeakBoundsChangeType.end : PeakBoundsChangeType.start);
     var changeType = bothBoundaries ? PeakBoundsChangeType.both : dragType;
     var peakBoundDragInfo = new PeakBoundsDragInfo(graphPane, graphItem, retentionMsMs, alignedTimes,
                                                    pt, dragType, changeType)
                                 {
                                     AnchorTime = anchorTime,
                                     CaretTime = caretTime
                                 };
     return (graphItem.DragInfo = peakBoundDragInfo);
 }
Esempio n. 9
0
 private ScaledRetentionTime GetRetentionTimeOfZeroOptStep(ChromGraphItem graphItem, ScaledRetentionTime peakTime)
 {
     if (graphItem.OptimizationStep == 0)
     {
         return peakTime;
     }
     ChromGraphItem mainGraphItem = GraphItems.FirstOrDefault(item =>
         0 == item.OptimizationStep
         && ReferenceEquals(item.TransitionNode, graphItem.TransitionNode)
         && ReferenceEquals(item.TransitionGroupNode, graphItem.TransitionGroupNode));
     if (mainGraphItem == null)
     {
         return ScaledRetentionTime.ZERO;
     }
     int iPeak = graphItem.Chromatogram.IndexOfPeak(peakTime.MeasuredTime);
     ChromPeak mainPeak = mainGraphItem.Chromatogram.GetPeak(iPeak);
     return mainGraphItem.ScaleRetentionTime(mainPeak.RetentionTime);
 }
Esempio n. 10
0
        private ChromGraphItem FindMaxPeakItem(GraphPane graphPane, ScaledRetentionTime startTime, ScaledRetentionTime endTime)
        {
            double maxInten = 0;
            ChromGraphItem maxItem = null;

            foreach (ChromGraphItem graphItemCurr in GetGraphItems(graphPane))
            {
                double inten = graphItemCurr.GetMaxIntensity(startTime.MeasuredTime, endTime.MeasuredTime);
                if (inten > maxInten)
                {
                    maxInten = inten;
                    maxItem = graphItemCurr;
                }
            }

            return maxItem;
        }
Esempio n. 11
0
 public ChangedPeakBoundsEventArgs(IdentityPath groupPath,
     Transition transition,
     string nameSet,
     MsDataFileUri filePath,
     ScaledRetentionTime startTime,
     ScaledRetentionTime endTime,
     PeakIdentification identified,
     PeakBoundsChangeType changeType)
     : base(groupPath, nameSet, filePath)
 {
     Transition = transition;
     StartTime = startTime;
     EndTime = endTime;
     Identified = identified;
     ChangeType = changeType;
 }