예제 #1
0
            private static PointPair CreatePointPair(int iGroup,
                                                     ICollection <double> listTimes,
                                                     IEnumerable <double> listStarts,
                                                     IEnumerable <double> listEnds,
                                                     IEnumerable <double> listFwhms,
                                                     ref double maxY,
                                                     ref double minY)
            {
                if (listTimes.Count == 0)
                {
                    return(RTPointPairMissing(iGroup));
                }

                var statTimes  = new Statistics(listTimes);
                var statStarts = new Statistics(listStarts);
                var statEnds   = new Statistics(listEnds);
                var statFwhms  = new Statistics(listFwhms);

                double endY   = statEnds.Mean();
                double startY = statStarts.Mean();

                var pointPair = HiLowMiddleErrorBarItem.MakePointPair(iGroup,
                                                                      endY, startY, statTimes.Mean(), statFwhms.Mean());

                maxY = Math.Max(maxY, endY);
                minY = Math.Min(minY, startY);

                return(pointPair);
            }
예제 #2
0
        private CurveItem CreateMultiSelectBarItem(string label, PointPairList pointPairList, Color color)
        {
            for (var index = 0; index < pointPairList.Count; index++)
            {
                PointPair pp     = pointPairList[index];
                var       middle = pp.Y - (pp.Y - pp.LowValue) / 2;
                if (!double.IsNaN(middle))
                {
                    pp.Tag = new MiddleErrorTag(middle, 0);
                }
            }

            var curveItem = new HiLowMiddleErrorBarItem(label, pointPairList, color, color);

            BarSettings.Type = BarType.SortedOverlay;
            return(curveItem);
        }
예제 #3
0
        public override void UpdateGraph(bool selectionChanged)
        {
            Clear();

            TransitionGroupDocNode selectedGroup   = null;
            PeptideGroupDocNode    selectedProtein = null;
            var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode;

            if (selectedTreeNode != null)
            {
                if (selectedTreeNode is TransitionTreeNode)
                {
                    selectedGroup = (TransitionGroupDocNode)selectedTreeNode.SrmParent.Model;
                }
                else if (selectedTreeNode is TransitionGroupTreeNode)
                {
                    selectedGroup = (TransitionGroupDocNode)selectedTreeNode.Model;
                }
                else
                {
                    var node = selectedTreeNode as PeptideTreeNode;
                    if (node != null)
                    {
                        var nodePep = node.DocNode;
                        selectedGroup = nodePep.TransitionGroups.FirstOrDefault();
                    }
                }
                var proteinTreeNode = selectedTreeNode.GetNodeOfType <PeptideGroupTreeNode>();
                if (proteinTreeNode != null)
                {
                    selectedProtein = proteinTreeNode.DocNode;
                }
            }

            SrmDocument document    = GraphSummary.DocumentUIContainer.DocumentUI;
            var         displayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode);

            _graphData = CreateGraphData(document, selectedProtein, selectedGroup, displayType);

            int iColor      = 0;
            int colorOffset = 0;

            if (selectedGroup != null && displayType == DisplayTypeChrom.products)
            {
                // If we are only displaying product ions, we want to use an offset in the colors array
                // so that we do not re-use colors that would be used for any precursor ions.
                colorOffset =
                    GraphChromatogram.GetDisplayTransitions(selectedGroup, DisplayTypeChrom.precursors).Count();
            }

            foreach (var pointPairList in _graphData.PointPairLists)
            {
                Color color = displayType == DisplayTypeChrom.total
                    ? COLORS_GROUPS[iColor++ % COLORS_GROUPS.Count]
                    : COLORS_TRANSITION[(iColor++ + colorOffset) % COLORS_TRANSITION.Count];

                BarItem curveItem;
                if (HiLowMiddleErrorBarItem.IsHiLoMiddleErrorList(pointPairList))
                {
                    curveItem = new HiLowMiddleErrorBarItem(string.Empty, pointPairList, color, Color.Black);
                }
                else
                {
                    curveItem = new MeanErrorBarItem(string.Empty, pointPairList, color, Color.Black);
                }

                curveItem.Bar.Border.IsVisible = false;
                curveItem.Bar.Fill.Brush       = new SolidBrush(color);
                CurveList.Add(curveItem);
            }

            if (ShowSelection && SelectedIndex != -1)
            {
                double yValue = _graphData.SelectedMaxY;
                double yMin   = _graphData.SelectedMinY;
                double height = yValue - yMin;
                GraphObjList.Add(new BoxObj(SelectedIndex + .5, yValue, 0.99,
                                            height, Color.Black, Color.Empty)
                {
                    IsClippedToChartRect = true,
                });
            }

            UpdateAxes();
        }
예제 #4
0
        public override void UpdateGraph(bool selectionChanged)
        {
            SrmDocument document         = GraphSummary.DocumentUIContainer.DocumentUI;
            var         results          = document.Settings.MeasuredResults;
            bool        resultsAvailable = results != null;

            Clear();
            if (!resultsAvailable)
            {
                Title.Text = Resources.RTReplicateGraphPane_UpdateGraph_No_results_available;
                EmptyGraph(document);
                return;
            }

            var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode ??
                                   GraphSummary.StateProvider.SelectedNodes.OfType <SrmTreeNode>().FirstOrDefault();

            if (selectedTreeNode == null || document.FindNode(selectedTreeNode.Path) == null)
            {
                EmptyGraph(document);
                return;
            }

            Title.Text = null;

            DisplayTypeChrom displayType  = GraphChromatogram.GetDisplayType(document, selectedTreeNode);
            DocNode          selectedNode = selectedTreeNode.Model;
            IdentityPath     selectedPath = selectedTreeNode.Path;
            DocNode          parentNode   = selectedNode;
            IdentityPath     parentPath   = selectedTreeNode.Path;

            // If the selected tree node is a transition, then its siblings are displayed.
            if (selectedTreeNode is TransitionTreeNode)
            {
                if (displayType != DisplayTypeChrom.single)
                {
                    SrmTreeNode parentTreeNode = selectedTreeNode.SrmParent;
                    parentNode   = parentTreeNode.Model;
                    selectedPath = parentTreeNode.Path;
                }
            }
            // If the selected node is a peptide with one child, then show the children,
            // unless chromatogram display type is total
            else if (selectedTreeNode is PeptideTreeNode)
            {
                var children = ((DocNodeParent)selectedNode).Children;
                if (children.Count == 1 && displayType != DisplayTypeChrom.total)
                {
                    selectedNode = parentNode = children[0];
                    selectedPath = new IdentityPath(parentPath, children[0].Id);
                }
            }
            else if (!(selectedTreeNode is PeptideGroupTreeNode) && !(selectedTreeNode is TransitionGroupTreeNode))
            {
                Title.Text      = Resources.RTReplicateGraphPane_UpdateGraph_Select_a_peptide_to_see_the_retention_time_graph;
                CanShowRTLegend = false;
                return;
            }

            // If a precursor is going to be displayed with display type single
            if (parentNode is TransitionGroupDocNode && displayType == DisplayTypeChrom.single)
            {
                // If no optimization data, then show all the transitions
                if (!results.Chromatograms.Contains(chrom => chrom.OptimizationFunction != null))
                {
                    displayType = DisplayTypeChrom.all;
                }
            }
            var rtTransformOp = GraphSummary.StateProvider.GetRetentionTimeTransformOperation();
            var rtValue       = RTPeptideGraphPane.RTValue;

            GraphValues.ReplicateGroupOp replicateGroupOp;
            if (rtValue == RTPeptideValue.All)
            {
                replicateGroupOp = GraphValues.ReplicateGroupOp.FromCurrentSettings(document.Settings, GraphValues.AggregateOp.MEAN);
            }
            else
            {
                replicateGroupOp = GraphValues.ReplicateGroupOp.FromCurrentSettings(document.Settings);
            }
            var retentionTimeValue = new GraphValues.RetentionTimeTransform(rtValue, rtTransformOp, replicateGroupOp.AggregateOp);

            YAxis.Title.Text = retentionTimeValue.GetAxisTitle();

            var peptidePaths = GetSelectedPeptides().GetUniquePeptidePaths().ToList();

            // if PeptideGroupTreeNode is selected but has only one child isMultiSelect should still be true
            IsMultiSelect = peptidePaths.Count > 1 ||
                            (peptidePaths.Count == 1 &&
                             GraphSummary.StateProvider.SelectedNodes.FirstOrDefault() is PeptideGroupTreeNode);

            GraphData graphData = new RTGraphData(document,
                                                  IsMultiSelect
                ? peptidePaths
                : new[] { selectedPath }.AsEnumerable(), displayType, retentionTimeValue, replicateGroupOp);

            CanShowRTLegend = graphData.DocNodes.Count != 0;
            InitFromData(graphData);

            int    selectedReplicateIndex = SelectedIndex;
            double minRetentionTime = double.MaxValue;
            double maxRetentionTime = -double.MaxValue;
            int    iColor = 0, iCharge = -1;
            var    charge = Adduct.EMPTY;
            int    countLabelTypes        = document.Settings.PeptideSettings.Modifications.CountLabelTypes;
            int    colorOffset            = 0;
            var    transitionGroupDocNode = parentNode as TransitionGroupDocNode;

            if (transitionGroupDocNode != null && displayType == DisplayTypeChrom.products)
            {
                // If we are only displaying product ions, we want to use an offset in the colors array
                // so that we do not re-use colors that would be used for any precursor ions.
                colorOffset =
                    GraphChromatogram.GetDisplayTransitions(transitionGroupDocNode, DisplayTypeChrom.precursors).Count();
            }
            for (int i = 0; i < graphData.DocNodes.Count; i++)
            {
                var docNode        = graphData.DocNodes[i];
                var identityPath   = graphData.DocNodePaths[i];
                var pointPairLists = graphData.PointPairLists[i];
                int numSteps       = pointPairLists.Count / 2;
                for (int iStep = 0; iStep < pointPairLists.Count; iStep++)
                {
                    int   step          = iStep - numSteps;
                    var   pointPairList = pointPairLists[iStep];
                    Color color;
                    var   isSelected = false;
                    var   nodeGroup  = docNode as TransitionGroupDocNode;
                    if (IsMultiSelect)
                    {
                        var peptides = peptidePaths.Select(path => document.FindNode(path))
                                       .Cast <PeptideDocNode>().ToArray();
                        var peptideDocNode = peptides.FirstOrDefault(
                            peptide => 0 <= peptide.FindNodeIndex(docNode.Id));
                        if (peptideDocNode == null)
                        {
                            continue;
                        }
                        color = GraphSummary.StateProvider.GetPeptideGraphInfo(peptideDocNode).Color;
                        if (identityPath.Equals(selectedTreeNode.Path) && step == 0)
                        {
                            color      = ChromGraphItem.ColorSelected;
                            isSelected = true;
                        }
                    }
                    else if (parentNode is PeptideDocNode)
                    {
                        // Resharper code inspection v9.0 on TC gets this one wrong
                        // ReSharper disable ExpressionIsAlwaysNull
                        int iColorGroup = GetColorIndex(nodeGroup, countLabelTypes, ref charge, ref iCharge);
                        // ReSharper restore ExpressionIsAlwaysNull
                        color = COLORS_GROUPS[iColorGroup % COLORS_GROUPS.Count];
                    }
                    else if (displayType == DisplayTypeChrom.total)
                    {
                        color = COLORS_GROUPS[iColor % COLORS_GROUPS.Count];
                    }
                    else if (ReferenceEquals(docNode, selectedNode) && step == 0)
                    {
                        color      = ChromGraphItem.ColorSelected;
                        isSelected = true;
                    }
                    else
                    {
                        color = COLORS_TRANSITION[(iColor + colorOffset) % COLORS_TRANSITION.Count];
                    }
                    iColor++;

                    string label = graphData.DocNodeLabels[i];
                    if (step != 0)
                    {
                        label = string.Format(Resources.RTReplicateGraphPane_UpdateGraph_Step__0__, step);
                    }

                    CurveItem curveItem;
                    if (IsMultiSelect)
                    {
                        if (rtValue != RTPeptideValue.All)
                        {
                            curveItem = CreateLineItem(label, pointPairList, color);
                        }
                        else
                        {
                            curveItem = CreateMultiSelectBarItem(label, pointPairList, color);
                        }
                    }
                    else if (HiLowMiddleErrorBarItem.IsHiLoMiddleErrorList(pointPairList))
                    {
                        curveItem        = new HiLowMiddleErrorBarItem(label, pointPairList, color, Color.Black);
                        BarSettings.Type = BarType.Cluster;
                    }
                    else if (rtValue == RTPeptideValue.All)
                    {
                        curveItem        = new MeanErrorBarItem(label, pointPairList, color, Color.Black);
                        BarSettings.Type = BarType.Cluster;
                    }
                    else
                    {
                        curveItem = CreateLineItem(label, pointPairList, color);
                    }

                    if (curveItem != null)
                    {
                        curveItem.Tag = identityPath;

                        var barItem = curveItem as BarItem;
                        if (barItem != null)
                        {
                            barItem.Bar.Border.IsVisible = false;
                            barItem.Bar.Fill.Brush       = GetBrushForNode(docNode, color);
                            if (!isSelected)
                            {
                                barItem.SortedOverlayPriority = 1;
                            }
                        }
                        CurveList.Add(curveItem);

                        if (selectedReplicateIndex != -1 && selectedReplicateIndex < pointPairList.Count)
                        {
                            PointPair pointPair = pointPairList[selectedReplicateIndex];
                            if (!pointPair.IsInvalid)
                            {
                                minRetentionTime = Math.Min(minRetentionTime, pointPair.Z);
                                maxRetentionTime = Math.Max(maxRetentionTime, pointPair.Y);
                            }
                        }
                    }
                }
            }
            // Draw a box around the currently selected replicate
            if (ShowSelection && minRetentionTime != double.MaxValue)
            {
                AddSelection(selectedReplicateIndex, maxRetentionTime, minRetentionTime);
            }
            // Reset the scale when the parent node changes
            if (_parentNode == null || !ReferenceEquals(_parentNode.Id, parentNode.Id))
            {
                XAxis.Scale.MaxAuto = XAxis.Scale.MinAuto = true;
                YAxis.Scale.MaxAuto = YAxis.Scale.MinAuto = true;
            }
            _parentNode      = parentNode;
            Legend.IsVisible = !IsMultiSelect && Settings.Default.ShowRetentionTimesLegend;
            GraphSummary.GraphControl.Invalidate();
            AxisChange();
        }
예제 #5
0
            private PointPair CalculatePointPair <TChromInfoData>(int iResult, IEnumerable <TChromInfoData> chromInfoDatas, Func <TChromInfoData, RetentionTimeValues?> getRetentionTimeValues)
                where TChromInfoData : ChromInfoData
            {
                var startTimes     = new List <double>();
                var endTimes       = new List <double>();
                var retentionTimes = new List <double>();
                var fwhms          = new List <double>();

                foreach (var chromInfoData in chromInfoDatas)
                {
                    var retentionTimeValues = getRetentionTimeValues(chromInfoData).GetValueOrDefault();
                    IRegressionFunction regressionFunction = null;
                    if (null != RetentionTimeTransform.RtTransformOp)
                    {
                        RetentionTimeTransform.RtTransformOp.TryGetRegressionFunction(chromInfoData.ChromFileInfo.FileId, out regressionFunction);
                    }
                    if (regressionFunction == null)
                    {
                        startTimes.Add(retentionTimeValues.StartRetentionTime);
                        endTimes.Add(retentionTimeValues.EndRetentionTime);
                        retentionTimes.Add(retentionTimeValues.RetentionTime);
                        fwhms.Add(retentionTimeValues.Fwhm ?? 0);
                    }
                    else
                    {
                        startTimes.Add(regressionFunction.GetY(retentionTimeValues.StartRetentionTime));
                        endTimes.Add(regressionFunction.GetY(retentionTimeValues.EndRetentionTime));
                        retentionTimes.Add(regressionFunction.GetY(retentionTimeValues.RetentionTime));
                        if (retentionTimeValues.Fwhm.HasValue)
                        {
                            fwhms.Add(regressionFunction.GetY(retentionTimeValues.RetentionTime +
                                                              retentionTimeValues.Fwhm.Value / 2)
                                      -
                                      regressionFunction.GetY(retentionTimeValues.RetentionTime -
                                                              retentionTimeValues.Fwhm.Value / 2));
                        }
                        else
                        {
                            fwhms.Add(0);
                        }
                    }
                }
                if (RTPeptideValue.All == RTPeptideGraphPane.RTValue)
                {
                    var point = HiLowMiddleErrorBarItem.MakePointPair(iResult,
                                                                      new Statistics(endTimes).Mean(),
                                                                      new Statistics(startTimes).Mean(),
                                                                      new Statistics(retentionTimes).Mean(),
                                                                      new Statistics(fwhms).Mean());
                    return(point.IsInvalid ? PointPairMissing(iResult) : point);
                }
                IEnumerable <double> values;

                switch (RTPeptideGraphPane.RTValue)
                {
                case RTPeptideValue.FWB:
                    values = startTimes.Select((startTime, index) => endTimes[index] - startTime);
                    break;

                case RTPeptideValue.FWHM:
                    values = fwhms;
                    break;

                default:
                    values = retentionTimes;
                    break;
                }
                return(RetentionTimeTransform.AggregateOp.MakeBarValue(iResult, values));
            }
예제 #6
0
 public static PointPair RTPointPairMissing(int xValue)
 {
     return(HiLowMiddleErrorBarItem.MakePointPair(xValue,
                                                  PointPairBase.Missing, PointPairBase.Missing, PointPairBase.Missing, 0));
 }
예제 #7
0
        public override void UpdateGraph(bool checkData)
        {
            SrmDocument document         = GraphSummary.DocumentUIContainer.DocumentUI;
            var         results          = document.Settings.MeasuredResults;
            bool        resultsAvailable = results != null;

            Clear();
            if (!resultsAvailable)
            {
                Title.Text = Resources.RTReplicateGraphPane_UpdateGraph_No_results_available;
                EmptyGraph(document);
                return;
            }
            var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode;

            if (selectedTreeNode == null || document.FindNode(selectedTreeNode.Path) == null)
            {
                EmptyGraph(document);
                return;
            }

            Title.Text = null;

            DisplayTypeChrom displayType  = GraphChromatogram.GetDisplayType(document, selectedTreeNode);
            DocNode          selectedNode = selectedTreeNode.Model;
            DocNode          parentNode   = selectedNode;
            IdentityPath     identityPath = selectedTreeNode.Path;

            // If the selected tree node is a transition, then its siblings are displayed.
            if (selectedTreeNode is TransitionTreeNode)
            {
                if (displayType != DisplayTypeChrom.single)
                {
                    SrmTreeNode parentTreeNode = selectedTreeNode.SrmParent;
                    parentNode   = parentTreeNode.Model;
                    identityPath = parentTreeNode.Path;
                }
            }
            // If the selected node is a peptide with one child, then show the children,
            // unless chromatogram display type is total
            else if (selectedTreeNode is PeptideTreeNode)
            {
                var children = ((DocNodeParent)selectedNode).Children;
                if (children.Count == 1 && displayType != DisplayTypeChrom.total)
                {
                    selectedNode = parentNode = children[0];
                    identityPath = new IdentityPath(identityPath, parentNode.Id);
                }
            }
            else if (!(selectedTreeNode is TransitionGroupTreeNode))
            {
                Title.Text      = Resources.RTReplicateGraphPane_UpdateGraph_Select_a_peptide_to_see_the_retention_time_graph;
                CanShowRTLegend = false;
                return;
            }

            // If a precursor is going to be displayed with display type single
            if (parentNode is TransitionGroupDocNode && displayType == DisplayTypeChrom.single)
            {
                // If no optimization data, then show all the transitions
                if (!results.Chromatograms.Contains(chrom => chrom.OptimizationFunction != null))
                {
                    displayType = DisplayTypeChrom.all;
                }
            }
            var rtTransformOp = GraphSummary.StateProvider.GetRetentionTimeTransformOperation();
            var rtValue       = RTPeptideGraphPane.RTValue;

            GraphValues.ReplicateGroupOp replicateGroupOp;
            if (rtValue == RTPeptideValue.All)
            {
                replicateGroupOp = GraphValues.ReplicateGroupOp.FromCurrentSettings(document.Settings, GraphValues.AggregateOp.MEAN);
            }
            else
            {
                replicateGroupOp = GraphValues.ReplicateGroupOp.FromCurrentSettings(document.Settings);
            }
            var retentionTimeValue = new GraphValues.RetentionTimeTransform(rtValue, rtTransformOp, replicateGroupOp.AggregateOp);

            YAxis.Title.Text = retentionTimeValue.GetAxisTitle();
            GraphData graphData = new RTGraphData(document, parentNode, displayType, retentionTimeValue, replicateGroupOp);

            CanShowRTLegend = graphData.DocNodes.Count != 0;
            InitFromData(graphData);

            int    selectedReplicateIndex = SelectedIndex;
            double minRetentionTime = double.MaxValue;
            double maxRetentionTime = -double.MaxValue;
            int    iColor = 0, iCharge = -1;
            int?   charge = null;
            int    countLabelTypes        = document.Settings.PeptideSettings.Modifications.CountLabelTypes;
            int    colorOffset            = 0;
            var    transitionGroupDocNode = parentNode as TransitionGroupDocNode;

            if (transitionGroupDocNode != null && displayType == DisplayTypeChrom.products)
            {
                // If we are only displaying product ions, we want to use an offset in the colors array
                // so that we do not re-use colors that would be used for any precursor ions.
                colorOffset =
                    GraphChromatogram.GetDisplayTransitions(transitionGroupDocNode, DisplayTypeChrom.precursors).Count();
            }
            for (int i = 0; i < graphData.DocNodes.Count; i++)
            {
                var docNode        = graphData.DocNodes[i];
                var pointPairLists = graphData.PointPairLists[i];
                int numSteps       = pointPairLists.Count / 2;
                for (int iStep = 0; iStep < pointPairLists.Count; iStep++)
                {
                    int   step          = iStep - numSteps;
                    var   pointPairList = pointPairLists[iStep];
                    Color color;
                    var   nodeGroup = docNode as TransitionGroupDocNode;
                    if (parentNode is PeptideDocNode)
                    {
                        // Resharper code inspection v9.0 on TC gets this one wrong
                        // ReSharper disable ExpressionIsAlwaysNull
                        int iColorGroup = GetColorIndex(nodeGroup, countLabelTypes, ref charge, ref iCharge);
                        // ReSharper restore ExpressionIsAlwaysNull
                        color = COLORS_GROUPS[iColorGroup % COLORS_GROUPS.Length];
                    }
                    else if (displayType == DisplayTypeChrom.total)
                    {
                        color = COLORS_GROUPS[iColor % COLORS_GROUPS.Length];
                    }
                    else if (docNode.Equals(selectedNode) && step == 0)
                    {
                        color = ChromGraphItem.ColorSelected;
                    }
                    else
                    {
                        color = COLORS_TRANSITION[(iColor + colorOffset) % COLORS_TRANSITION.Length];
                    }
                    iColor++;

                    string label = graphData.DocNodeLabels[i];
                    if (step != 0)
                    {
                        label = string.Format(Resources.RTReplicateGraphPane_UpdateGraph_Step__0__, step);
                    }
                    BarItem curveItem;
                    if (HiLowMiddleErrorBarItem.IsHiLoMiddleErrorList(pointPairList))
                    {
                        curveItem = new HiLowMiddleErrorBarItem(label, pointPairList, color, Color.Black);
                    }
                    else
                    {
                        curveItem = new MeanErrorBarItem(label, pointPairList, color, Color.Black);
                    }
                    if (selectedReplicateIndex != -1 && selectedReplicateIndex < pointPairList.Count)
                    {
                        PointPair pointPair = pointPairList[selectedReplicateIndex];
                        if (!pointPair.IsInvalid)
                        {
                            minRetentionTime = Math.Min(minRetentionTime, pointPair.Z);
                            maxRetentionTime = Math.Max(maxRetentionTime, pointPair.Y);
                        }
                    }
                    curveItem.Bar.Border.IsVisible = false;
                    curveItem.Bar.Fill.Brush       = new SolidBrush(color);
                    curveItem.Tag = new IdentityPath(identityPath, docNode.Id);
                    CurveList.Add(curveItem);
                }
            }
            // Draw a box around the currently selected replicate
            if (ShowSelection && minRetentionTime != double.MaxValue)
            {
                GraphObjList.Add(new BoxObj(selectedReplicateIndex + .5, maxRetentionTime, 1,
                                            maxRetentionTime - minRetentionTime, Color.Black, Color.Empty)
                {
                    IsClippedToChartRect = true,
                });
            }
            // Reset the scale when the parent node changes
            if (_parentNode == null || !ReferenceEquals(_parentNode.Id, parentNode.Id))
            {
                XAxis.Scale.MaxAuto = XAxis.Scale.MinAuto = true;
                YAxis.Scale.MaxAuto = YAxis.Scale.MinAuto = true;
            }
            _parentNode      = parentNode;
            Legend.IsVisible = Settings.Default.ShowRetentionTimesLegend;
            AxisChange();
        }
        public override void UpdateGraph(bool checkData)
        {
            Clear();

            TransitionGroupDocNode selectedGroup = null;
            PeptideGroupDocNode selectedProtein = null;
            var selectedTreeNode = GraphSummary.StateProvider.SelectedNode as SrmTreeNode;
            if (selectedTreeNode != null)
            {
                if (selectedTreeNode is TransitionTreeNode)
                    selectedGroup = (TransitionGroupDocNode)selectedTreeNode.SrmParent.Model;
                else if (selectedTreeNode is TransitionGroupTreeNode)
                    selectedGroup = (TransitionGroupDocNode)selectedTreeNode.Model;
                else
                {
                    var node = selectedTreeNode as PeptideTreeNode;
                    if (node != null)
                    {
                        var nodePep = node.DocNode;
                        selectedGroup = nodePep.TransitionGroups.FirstOrDefault();
                    }
                }
                var proteinTreeNode = selectedTreeNode.GetNodeOfType<PeptideGroupTreeNode>();
                if (proteinTreeNode != null)
                    selectedProtein = proteinTreeNode.DocNode;
            }

            SrmDocument document = GraphSummary.DocumentUIContainer.DocumentUI;
            var displayType = GraphChromatogram.GetDisplayType(document, selectedTreeNode);

            _graphData = CreateGraphData(document, selectedProtein, selectedGroup, displayType);

            int iColor = 0;
            int colorOffset = 0;
            if(selectedGroup != null && displayType == DisplayTypeChrom.products)
            {
                // If we are only displaying product ions, we want to use an offset in the colors array
                // so that we do not re-use colors that would be used for any precursor ions.
                colorOffset =
                   GraphChromatogram.GetDisplayTransitions(selectedGroup, DisplayTypeChrom.precursors).Count();
            }

            foreach (var pointPairList in _graphData.PointPairLists)
            {
                Color color = displayType == DisplayTypeChrom.total
                    ? COLORS_GROUPS[iColor++ % COLORS_GROUPS.Length]
                    : COLORS_TRANSITION[(iColor++ + colorOffset)% COLORS_TRANSITION.Length];

                BarItem curveItem;
                if (HiLowMiddleErrorBarItem.IsHiLoMiddleErrorList(pointPairList))
                    curveItem = new HiLowMiddleErrorBarItem(string.Empty, pointPairList, color, Color.Black);
                else
                    curveItem = new MeanErrorBarItem(string.Empty, pointPairList, color, Color.Black);

                curveItem.Bar.Border.IsVisible = false;
                curveItem.Bar.Fill.Brush = new SolidBrush(color);
                CurveList.Add(curveItem);
            }

            if (ShowSelection && SelectedIndex != -1)
            {
                double yValue = _graphData.SelectedMaxY;
                double yMin = _graphData.SelectedMinY;
                GraphObjList.Add(new BoxObj(SelectedIndex + .5, yValue, 0.99,
                                            yValue - yMin, Color.Black, Color.Empty)
                {
                    IsClippedToChartRect = true,
                });
            }

            UpdateAxes();
        }