Example #1
0
        /// <summary>
        /// Create the heat map or single scan graph.
        /// </summary>
        private void CreateGraph()
        {
            if (_msDataFileScanHelper.MsDataSpectra == null)
            {
                return;
            }

            GraphPane.CurveList.Clear();
            GraphPane.GraphObjList.Clear();

            bool hasDriftDimension = _msDataFileScanHelper.MsDataSpectra.Length > 1;
            bool useHeatMap        = hasDriftDimension && !Settings.Default.SumScansFullScan;

            filterBtn.Visible          = spectrumBtn.Visible = hasDriftDimension;
            graphControl.IsEnableVPan  = graphControl.IsEnableVZoom = useHeatMap;
            GraphPane.Legend.IsVisible = useHeatMap;

            if (hasDriftDimension)
            {
                // Is there actually any drift time filtering available?
                double minDriftTime, maxDriftTime;
                _msDataFileScanHelper.GetDriftRange(out minDriftTime, out maxDriftTime, ChromSource.unknown); // Get range of drift times for all products and precursors
                if ((minDriftTime == double.MinValue) && (maxDriftTime == double.MaxValue))
                {
                    filterBtn.Visible = false;
                    filterBtn.Checked = false;
                }
            }

            if (useHeatMap)
            {
                ZoomYAxis(); // Call this again now that cues are there to indicate need for drift scale
                CreateDriftTimeHeatmap();
            }
            else
            {
                CreateSingleScan();
            }

            // Add extraction boxes.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                {
                    continue;
                }
                var color1        = Blend(transition.Color, Color.White, 0.60);
                var color2        = Blend(transition.Color, Color.White, 0.95);
                var extractionBox = new BoxObj(
                    transition.ProductMz - transition.ExtractionWidth.Value / 2,
                    0.0,
                    transition.ExtractionWidth.Value,
                    1.0,
                    Color.Transparent,
                    transition.Color,
                    Color.White)
                {
                    Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                    ZOrder               = ZOrder.F_BehindGrid,
                    Fill                 = new Fill(color1, color2, 90),
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(extractionBox);
            }

            // Add labels.
            for (int i = 0; i < _msDataFileScanHelper.ScanProvider.Transitions.Length; i++)
            {
                var transition = _msDataFileScanHelper.ScanProvider.Transitions[i];
                if (transition.Source != _msDataFileScanHelper.Source)
                {
                    continue;
                }
                var label = new TextObj(transition.Name, transition.ProductMz, 0.02, CoordType.XScaleYChartFraction, AlignH.Center, AlignV.Top)
                {
                    ZOrder = ZOrder.D_BehindAxis,
                    IsClippedToChartRect = true,
                    Tag = i
                };
                label.FontSpec.Border.IsVisible = false;
                label.FontSpec.FontColor        = Blend(transition.Color, Color.Black, 0.30);
                label.FontSpec.IsBold           = true;
                label.FontSpec.Fill             = new Fill(Color.FromArgb(180, Color.White));
                GraphPane.GraphObjList.Add(label);
            }

            double retentionTime = _msDataFileScanHelper.MsDataSpectra[0].RetentionTime ?? _msDataFileScanHelper.ScanProvider.Times[_msDataFileScanHelper.ScanIndex];

            GraphPane.Title.Text = string.Format(Resources.GraphFullScan_CreateGraph__0_____1_F2__min_, _msDataFileScanHelper.FileName, retentionTime);

            FireSelectedScanChanged(retentionTime);
        }