Esempio n. 1
0
        private void HighlightGraphs(double x, double z)
        {
            if (_doesShowHover)
            {
                for (int i = 0; i < zedGraphControl1.MasterPane.PaneList.Count; i++)
                {
                    GraphPane gp = zedGraphControl1.MasterPane.PaneList[i];
                    if (_htBoxes.Contains(gp.Title.Text))
                    {
                        BoxObj boxForLabel = (BoxObj)_htBoxes[gp.Title];
                        gp.GraphObjList.Clear();

                        boxForLabel = new BoxObj(x, gp.YAxis.Scale.Max, z, gp.YAxis.Scale.Max - gp.YAxis.Scale.Min, Color.Black, Color.PapayaWhip);
                        boxForLabel.Location.CoordinateFrame = CoordType.AxisXYScale;
                        boxForLabel.Border.Style             = System.Drawing.Drawing2D.DashStyle.DashDot;

                        //// place the box behind the axis items, so the grid is drawn on top of it
                        boxForLabel.ZOrder = ZOrder.F_BehindGrid;
                        _htBoxes[gp.Title] = boxForLabel;
                        gp.GraphObjList.Add(boxForLabel);
                    }
                }
                zedGraphControl1.AxisChange();
                this.Refresh();
            }
        }
Esempio n. 2
0
        private void DrawSegment(int x1, int y1, int x2, int y2)
        {
            GraphPane pane = zedGraphControl1.GraphPane;

            Point2D[] points;

            points = currentAlgo.GetArrayPresentation(new Segment(x1, y1, x2, y2));

            if (points == null || points.Length == 0)
            {
                return;
            }

            foreach (Point2D p in points)
            {
                BoxObj pixel = new BoxObj(p.X, p.Y + 1, 1, 1, Color.Black, Color.Gray);
                pixel.ZOrder = ZOrder.E_BehindCurves;
                pane.GraphObjList.Add(pixel);
            }

            PointPairList list = new PointPairList();

            list.Add(x1, y1);
            list.Add(x2, y2);

            pane.AddCurve("", list, Color.Blue, SymbolType.Circle);

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
Esempio n. 3
0
        private void DrawGraph()
        {
            var pane = zedGraphControl1.GraphPane;

            pane.GraphObjList.Clear();
            //var list = new PointPairList();
            int maxx = 0, maxy = 0;

            foreach (var point in DataList)
            {
                maxx = Math.Max(maxx, point.X);
                maxy = Math.Max(maxy, point.Y);

                BoxObj boxObj = new BoxObj(point.X - 0.5, point.Y + 0.5, 1, 1, Color.Blue, Color.Blue);
                boxObj.IsVisible = true;
                boxObj.Location.CoordinateFrame = CoordType.AxisXYScale;
                boxObj.ZOrder = ZOrder.A_InFront;
                pane.GraphObjList.Add(boxObj);
            }

            pane.YAxis.Scale.Max = 100; //* maxy+10;
            pane.XAxis.Scale.Max = 100; // maxx+10;

            zedGraphControl1.AxisChange();
            zedGraphControl1.Invalidate();
        }
Esempio n. 4
0
        private void AddRegion(double x1, double x2, Color lightBlue)
        {
            BoxObj box = new BoxObj(x1, 0, x2 - x1, 80, Color.LightGreen, Color.LightGreen);

            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            box.IsVisible = true;
            box.ZOrder    = ZOrder.A_InFront;//.D_BehindAxis;//.E_BehindAxis;
            zedGraphControl1.GraphPane.GraphObjList.Add(box);
        }
Esempio n. 5
0
        private void LoadCustomerQueueGraph()
        {
            // For Customers Queue Graph ..
            CustomerQueueGraphPanel.Invalidate();
            CustomerQueueGraphPanel.GraphPane.CurveList.Clear();
            CustomerQueueGraphPanel.GraphPane.GraphObjList.Clear();

            // -- Begin Plotting ..

            List <double> xDataCustomerQueueGraph = new List <double>();
            List <double> yDataCustomerQueueGraph = new List <double>();

            int MaxGraphValueQueueGraph = QueuingSystem.queueArray.Length;

            GraphPane CustomerQueueGraphPane = CustomerQueueGraphPanel.GraphPane;

            // Set the Titles
            CustomerQueueGraphPane.Title.Text       = "Customers Queue Graph";
            CustomerQueueGraphPane.XAxis.Title.Text = "Hours";
            CustomerQueueGraphPane.YAxis.Title.Text = "Numbers Of Customers";

            CustomerQueueGraphPane.XAxis.Scale.Min = 0;
            CustomerQueueGraphPane.YAxis.Scale.Min = 0;

            CustomerQueueGraphPane.XAxis.Scale.Max = MaxGraphValueQueueGraph;

            // Getting the maximum value for the queue size ..
            CustomerQueueGraphPane.YAxis.Scale.Max = Convert.ToInt32(Program.simulationTableForm.maxQueueLengthTextBox.Text);

            CustomerQueueGraphPane.YAxis.Scale.MajorStep = 1;

            CustomerQueueGraphPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            CustomerQueueGraphPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));

            int UnitSize = 1;

            for (int i = 0; i < QueuingSystem.queueArray.Length; i++)
            {
                if (QueuingSystem.queueArray[i] != 0)
                {
                    BoxObj box = new BoxObj(i, (int)QueuingSystem.queueArray[i], UnitSize, (int)QueuingSystem.queueArray[i], Color.Empty, Color.Red);
                    box.IsVisible = true;
                    box.Location.CoordinateFrame = CoordType.AxisXYScale;
                    box.ZOrder = ZOrder.A_InFront;
                    CustomerQueueGraphPanel.GraphPane.GraphObjList.Add(box);
                }
            }

            // Tell ZedGraph to refigure the
            // axes since the data have changed

            CustomerQueueGraphPane.AxisChange();
            CustomerQueueGraphPanel.Invalidate();
            // -- End Plotting
        }
        public GraphPane CreateGraph()
        {
            var myPane = new GraphPane(new RectangleF(0, 0, 1024, 768), Title, XTitle, YTitle);

            // Set the title and axis labels
            myPane.Title.IsVisible           = false;
            myPane.Legend.IsVisible          = false;
            myPane.YAxis.Title.IsVisible     = true;
            myPane.XAxis.Title.IsVisible     = true;
            myPane.XAxis.Scale.IsReverse     = Reverse;
            myPane.XAxis.Scale.Min           = -90;
            myPane.XAxis.Scale.Max           = -40;
            myPane.YAxis.Scale.Min           = 0;
            myPane.YAxis.Scale.Max           = 1;
            myPane.YAxis.Scale.MajorStep     = 0.25;
            myPane.YAxis.Scale.MinorStep     = 0.05;
            myPane.YAxis.Scale.Format        = "f2";
            myPane.YAxis.Scale.MajorStepAuto = false;
            myPane.YAxis.Scale.MinorStepAuto = false;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.PenWidth  = 3f;
            myPane.YAxis.MajorGrid.DashOn    = 7f;
            myPane.YAxis.MajorGrid.DashOff   = 7f;
            myPane.YAxis.MinorGrid.PenWidth  = 2f;

            myPane.Fill             = new Fill(Color.White);
            myPane.Border.IsVisible = false;

            myPane.Chart.Fill = new Fill(Color.White);

            foreach (var boxData in Boxes)
            {
                // Draw a box item to highlight a value range
                var box = new BoxObj(0, boxData.Top, 1, boxData.Top - boxData.Bottom)
                {
                    Fill   = boxData.Fill,
                    ZOrder = ZOrder.E_BehindCurves,
                    IsClippedToChartRect = true,
                    Location             = { CoordinateFrame = CoordType.XChartFractionYScale }
                };
                myPane.GraphObjList.Add(box);
            }
            myPane.GraphObjList.AddRange(TextObjs);

            var list  = new ClippedPointList(XAxis, YAxis, 0, DroppedPackages ? XAxis.Length - 1 : XAxis.Length);
            var curve = new LineItem("", list, Color.Black, SymbolType.None, 3f);

            myPane.CurveList.Add(curve);

            myPane.AxisChange();
            return(myPane);
        }
Esempio n. 7
0
        /*  Create Coggan's MHR and Power Zones for Line Graph based on HRMObject
         *   Draw band box at 105% of value 11% of HRMObject height downwards
         */
        public void createZonesForLineGraph(ZedGraphControl zgc, string type, double value)
        {
            GraphPane pane = zgc.GraphPane;

            if (type == "Heart Rate")
            {
                // Lactate Threshold 95-105%
                BoxObj box1 = new BoxObj(0, 1.05 * value, int.MaxValue, 0.11 * value, Color.Empty, Color.Empty);
                box1.Fill   = new Fill(Color.White, Color.Red, 45.0F);
                box1.ZOrder = ZOrder.F_BehindGrid;
                box1.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box1);

                // Tempo 84-94%
                BoxObj box2 = new BoxObj(0, 0.94 * value, int.MaxValue, 0.11 * value, Color.Empty, Color.Empty);
                box2.Fill   = new Fill(Color.White, Color.Yellow, 45.0F);
                box2.ZOrder = ZOrder.F_BehindGrid;
                box2.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box2);

                // Endurance 69-83%
                BoxObj box3 = new BoxObj(0, 0.83 * value, int.MaxValue, 0.15 * value, Color.Empty, Color.Empty);
                box3.Fill   = new Fill(Color.White, Color.LightGreen, 45.0F);
                box3.ZOrder = ZOrder.F_BehindGrid;
                box3.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box3);
            }

            else if (type == "Power")
            {
                // Lactate Threshold 91-105%
                BoxObj box1 = new BoxObj(0, 1.05 * value, int.MaxValue, 0.15 * value, Color.Empty, Color.Empty);
                box1.Fill   = new Fill(Color.White, Color.Red, 45.0F);
                box1.ZOrder = ZOrder.F_BehindGrid;
                box1.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box1);

                // Tempo 76-90%
                BoxObj box2 = new BoxObj(0, 0.90 * value, int.MaxValue, 0.15 * value, Color.Empty, Color.Empty);
                box2.Fill   = new Fill(Color.White, Color.Yellow, 45.0F);
                box2.ZOrder = ZOrder.F_BehindGrid;
                box2.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box2);

                // Endurance 56-75%
                BoxObj box3 = new BoxObj(0, 0.75 * value, int.MaxValue, 0.20 * value, Color.Empty, Color.Empty);
                box3.Fill   = new Fill(Color.White, Color.LightGreen, 45.0F);
                box3.ZOrder = ZOrder.F_BehindGrid;
                box3.IsClippedToChartRect = true;
                pane.GraphObjList.Add(box3);
            }
        }
 private void checkGaps(GraphObj current, GraphObj next)
 {
     if (current.Location.X2 < next.Location.X1)
     {
         double gapWidth = next.Location.X1 - current.Location.X2;
         BoxObj gapBox1  = new BoxObj(current.Location.X2, Math.Floor(current.Location.Y), gapWidth, 1, _gapColor, _gapColor)
         {
             IsClippedToChartRect = true
         };
         zgIsolationGraph.GraphPane.GraphObjList.Add(gapBox1);
         _gapBoxes.Add(gapBox1);
     }
 }
 private void checkOverlaps(GraphObj current, GraphObj next)
 {
     if (current.Location.X2 > next.Location.X1)
     {
         double overlapWidth = current.Location.X2 - next.Location.X1;
         BoxObj overlapBox1  = new BoxObj(next.Location.X1, Math.Floor(current.Location.Y), overlapWidth, 1, _overlapColor, _overlapColor)
         {
             IsClippedToChartRect = true
         };
         zgIsolationGraph.GraphPane.GraphObjList.Add(overlapBox1);
         _overlapBoxes.Add(overlapBox1);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// Using ZedGraph, create a stripchart
        /// More info on Zedgraph can be found at: http://zedgraph.sourceforge.net/index.html
        /// </summary>
        void CreateStripChart()
        {
            // This is to remove all plots
            graph_.GraphPane.CurveList.Clear();

            // GraphPane object holds one or more Curve objects (or plots)
            GraphPane myPane = graph_.GraphPane;

            // Draw a box item to highlight the valid range
            BoxObj box = new BoxObj(0, 512, 30, 512, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));

            box.Fill = new Fill(Color.FromArgb(200, Color.LightGreen),
                                Color.FromArgb(200, Color.LightGreen), 45.0F);
            // Use the BehindGrid zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.F_BehindGrid;
            myPane.GraphObjList.Add(box);

            //Lables
            myPane.XAxis.Title.Text = "Time (s)";
            myPane.YAxis.Title.Text = "Output (511 = Full Scale Range)";

            myPane.Title.IsVisible  = false;
            myPane.Legend.IsVisible = true;

            //Set scale
            myPane.XAxis.Scale.Max = 20; //Show 30s of data
            myPane.XAxis.Scale.Min = -10;

            //Set scale
            myPane.YAxis.Scale.Max = 768; //Valid range
            myPane.YAxis.Scale.Min = -255;


            // Set font sizes
            myPane.XAxis.Title.FontSpec.Size = 10;
            myPane.YAxis.Title.FontSpec.Size = 10;
            myPane.XAxis.Scale.FontSpec.Size = 7;
            myPane.YAxis.Scale.FontSpec.Size = 7;

            //Make grid visible
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;

            // Refeshes the plot.
            graph_.AxisChange();
            graph_.Invalidate();
            graph_.Refresh();
        }
Esempio n. 11
0
        private void IDs_SelectedIndexChanged(object sender, EventArgs e)
        {
            ServerBusyChartPanel.GraphPane.CurveList.Clear();
            ServerBusyChartPanel.GraphPane.GraphObjList.Clear();

            // -- Begin Plotting ..
            List <double> xData = new List <double>();
            List <double> yData = new List <double>();

            DataGridView data = Program.simulationTableForm.outputDataGrid;

            int MaxGraphValue = Convert.ToInt32(Program.simulationTableForm.outputDataGrid.Rows[Program.simulationTableForm.outputDataGrid.Rows.Count - 1].Cells[8].Value);

            GraphPane myPane = ServerBusyChartPanel.GraphPane;

            // Set the Titles
            myPane.Title.Text       = "Server Busy Time for Server #" + IDs.Items[IDs.SelectedIndex].ToString();
            myPane.XAxis.Title.Text = "Busy Time In Hours";
            myPane.YAxis.Title.Text = "Occurrence";

            myPane.XAxis.Scale.Min = 0;
            myPane.YAxis.Scale.Min = 0;

            myPane.XAxis.Scale.Max = MaxGraphValue;
            myPane.YAxis.Scale.Max = MaxGraphValue;

            ServerBusyChartPanel.ZoomOut(myPane);

            myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 90F);
            myPane.Fill       = new Fill(Color.FromArgb(250, 250, 255));

            for (int i = 0; i < data.Rows.Count; i++)
            {
                if (data.Rows[i].Cells[4].Value.ToString() == IDs.Items[IDs.SelectedIndex].ToString())
                {
                    int begin = Convert.ToInt32(data.Rows[i].Cells[5].Value), end = Convert.ToInt32(data.Rows[i].Cells[8].Value);

                    BoxObj box = new BoxObj(begin, MaxGraphValue / 4, end - begin, MaxGraphValue / 4, Color.Empty, Color.Red);
                    box.IsVisible = true;
                    box.Location.CoordinateFrame = CoordType.AxisXYScale;
                    box.ZOrder = ZOrder.A_InFront;
                    ServerBusyChartPanel.GraphPane.GraphObjList.Add(box);
                }
            }

            ServerBusyChartPanel.AxisChange();
            ServerBusyChartPanel.Invalidate();
            // -- End Plotting
        }
Esempio n. 12
0
        private void sensorRange_SelectedIndexChanged(object sender, EventArgs e)
        {
            double tempFactor = 0;

            try
            {
                tempFactor = Convert.ToDouble(sensorRange.SelectedItem);
            }
            catch
            {
                tempFactor = 0;
            }
            if (tempFactor == NBtoForceFactor)
            {
                return;
            }
            NBtoForceFactor = tempFactor;
            double greenBoxMax = 0;

            if (NBtoForceFactor != 0)
            {
                graph_.GraphPane.YAxis.Title.Text = "Force (N)";
                graph_.GraphPane.YAxis.Scale.Max  = 1.5 * NBtoForceFactor; //Valid range
                graph_.GraphPane.YAxis.Scale.Min  = -0.5 * NBtoForceFactor;
                greenBoxMax = NBtoForceFactor;
            }
            else
            {
                graph_.GraphPane.YAxis.Title.Text = "Output (511 = Full Scale Range)";
                graph_.GraphPane.YAxis.Scale.Max  = 768; //Valid range
                graph_.GraphPane.YAxis.Scale.Min  = -255;
                greenBoxMax = 512;
            }
            BoxObj b = (BoxObj)graph_.GraphPane.GraphObjList[0];

            b.Location.X      = 0;
            b.Location.Y      = Math.Min(graph_.GraphPane.YAxis.Scale.Max, greenBoxMax);
            b.Location.Height = Math.Min(graph_.GraphPane.YAxis.Scale.Max - graph_.GraphPane.YAxis.Scale.Min, greenBoxMax);
            graph_.GraphPane.XAxis.Scale.Max = 30;
            graph_.GraphPane.XAxis.Scale.Min = 0;
            USBdevices[0].setTimestamp(0);
            USBdevices[0].removeAllFrame();
            USBdevices[0].singleTact.resetTimeStamp();
            graph_.GraphPane.CurveList[0].Clear();
            graph_.AxisChange();
            graph_.Invalidate();
            graph_.Refresh();
        }
Esempio n. 13
0
        public DisplayForm(SortedDictionary <LinearInterval, double> data, string title, string xName, string yName)
        {
            InitializeComponent();
            //Вывод таблицы
            SetupDataSource <LinearInterval, double>(data, xName, yName);
            setupForm(title, xName, yName);
            //Вывод графика
            var    pane = graph.GraphPane;
            double maxY = 0;
            //Находим интервалы
            var intervals = new double[data.Count];
            var height    = new double[data.Count];
            var xi        = new double[data.Count];

            int i = 0;

            foreach (var x in data)
            {
                intervals[i] = x.Key.Length;
                height[i]    = x.Value / intervals[i];
                xi[i]        = x.Key.LeftBorder;
                i++;
            }

            //Находим высоту
            //Рисуем гистограмму
            for (i = 0; i < height.Length; i++)
            {
                var box = new BoxObj((float)xi[i], (float)height[i], (float)intervals[i], (float)height[i], Color.Black, Color.FromArgb(255, 39, 174, 96));

                pane.GraphObjList.Add(box);
                if (height[i] > maxY)
                {
                    maxY = height[i];
                }
            }

            //Настраиваем масштаб
            pane.XAxis.Scale.Min = 0;
            pane.XAxis.Scale.Max = data.Last().Key.RightBorder *1.1;
            pane.YAxis.Scale.Min = 0;
            pane.YAxis.Scale.Max = maxY * 1.1;

            graph.AxisChange();
            graph.Invalidate();
        }
        /// <summary>
        /// Строит диаграмму для интервального ряда
        /// </summary>
        /// <param name="intervalFreq">Интервальный ряд</param>
        public void Plot(Dictionary <Range, double> data, Color color)
        {
            //Вывод графика
            var    pane = graph.GraphPane;
            double maxY = 0;

            //Находим интервалы
            var intervals = new double[data.Count];
            var height    = new double[data.Count];
            var xi        = new double[data.Count];

            //МЕГАКОСТЫЛь. Зря я использовал Dictionary
            int i = 0;

            foreach (var x in data)
            {
                intervals[i] = x.Key.Length;
                height[i]    = x.Value / intervals[i];
                xi[i]        = x.Key.Left;
                i++;
            }

            //Рисуем гистограмму
            for (i = 0; i < height.Length; i++)
            {
                var box = new BoxObj((float)xi[i], (float)height[i], (float)intervals[i], (float)height[i], Color.Black, color);

                pane.GraphObjList.Add(box);
                if (height[i] > maxY)
                {
                    maxY = height[i];
                }
            }



            //Настраиваем масштаб
            pane.XAxis.Scale.Min = data.First().Key.Left;
            pane.XAxis.Scale.Max = data.Last().Key.Right;
            pane.YAxis.Scale.Min = 0;
            pane.YAxis.Scale.Max = maxY * 1.1;

            graph.AxisChange();
            graph.Invalidate();
        }
Esempio n. 15
0
        private void AddOriginalPeakAnnotation(ChromPeak bestPeak, GraphObjList annotations, GraphPane graphPane)
        {
            var start  = ScaleRetentionTime(bestPeak.StartTime);
            var end    = ScaleRetentionTime(bestPeak.EndTime);
            var width  = end.DisplayTime - start.DisplayTime;
            var height = graphPane.YAxis.Scale.Max;
            var originalPeakShadingBox = new BoxObj(start.DisplayTime, graphPane.YAxis.Scale.Max, width, height)
            {
                Fill   = new Fill(Color.FromArgb(30, COLOR_ORIGINAL_PEAK_SHADE)),
                ZOrder = ZOrder.F_BehindGrid,
                Border = new Border {
                    IsVisible = false
                },
                IsClippedToChartRect = true,
                Tag = new GraphObjTag(this, GraphObjType.original_peak_shading, start, end)
            };

            annotations.Add(originalPeakShadingBox);
        }
        /// <summary>
        /// Initialize graph renderer on the background thread.
        /// </summary>
        private void BackgroundInitialize()
        {
            // The template pane is a blank graph that will be cloned to create a graph for each imported file.
            _templatePane = new GraphPane();
            _templatePane.Chart.Border.IsVisible = false;
            _templatePane.Chart.Fill.IsVisible   = false;
            _templatePane.Chart.Fill             = new Fill(_backgroundGradientColor1, _backgroundGradientColor2, 45.0f);
            _templatePane.Border.IsVisible       = false;
            _templatePane.Title.IsVisible        = true;

            _templatePane.XAxis.Title.Text          = Resources.AsyncChromatogramsGraph_AsyncChromatogramsGraph_Retention_Time;
            _templatePane.XAxis.MinorTic.IsOpposite = false;
            _templatePane.XAxis.MajorTic.IsOpposite = false;
            _templatePane.XAxis.Scale.Min           = 0.0;
            _templatePane.XAxis.Scale.Max           = X_AXIS_START;

            _templatePane.YAxis.Title.Text          = Resources.AsyncChromatogramsGraph_AsyncChromatogramsGraph_Intensity;
            _templatePane.YAxis.MinorTic.IsOpposite = false;
            _templatePane.YAxis.MajorTic.IsOpposite = false;
            _templatePane.YAxis.Scale.Min           = 0.0;
            _templatePane.YAxis.Scale.Max           = Y_AXIS_START;

            GraphHelper.FormatGraphPane(_templatePane);

            _canceledBox = new BoxObj(0, 0, 1, 1, _dimColor, _dimColor)
            {
                Location = { CoordinateFrame = CoordType.ChartFraction },
                ZOrder   = ZOrder.D_BehindAxis
            };
            _canceledText = new TextObj(Resources.AsyncChromatogramsGraph2_AsyncChromatogramsGraph2_Canceled, 0.5, 0.5)
            {
                FontSpec = new FontSpec("Arial", 24, Color.Gray, true, false, false)    // Not L10N
                {
                    Border = new Border {
                        IsVisible = false
                    },
                    Fill = new Fill()
                },
                Location = { AlignH = AlignH.Center, AlignV = AlignV.Center, CoordinateFrame = CoordType.ChartFraction },
                ZOrder   = ZOrder.A_InFront
            };
        }
        private void AddUnfinishedLine(GraphPane graphPane, float?currentTime)
        {
            if (IsCanceled)
            {
                graphPane.GraphObjList.Add(_canceledBox);
                graphPane.GraphObjList.Add(_canceledText);
            }
            else if (graphPane.YAxis.Scale.Max > graphPane.YAxis.Scale.Min &&
                     currentTime.HasValue && currentTime.Value < graphPane.XAxis.Scale.Max * 0.95)
            {
                var unfinishedBox = new BoxObj(
                    currentTime.Value,
                    graphPane.YAxis.Scale.Max,
                    graphPane.XAxis.Scale.Max - currentTime.Value,
                    graphPane.YAxis.Scale.Max - graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder   = ZOrder.F_BehindGrid
                };

                var unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    currentTime.Value,
                    graphPane.YAxis.Scale.Max,
                    currentTime.Value,
                    graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line     = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder   = ZOrder.D_BehindAxis
                };

                graphPane.GraphObjList.Add(unfinishedBox);
                graphPane.GraphObjList.Add(unfinishedLine);
            }
            else
            {
                graphPane.GraphObjList.Clear();
            }
        }
        /// <summary>
        /// Update vertical line the marks current import time for progressively loaded files.
        /// </summary>
        private void UpdateProgressLine(double time)
        {
            // Remove old progressive loading indicators.
            if (_unfinishedBox != null)
            {
                _graphPane.GraphObjList.Remove(_unfinishedBox);
                _graphPane.GraphObjList.Remove(_unfinishedLine);
                _unfinishedBox = null;
            }

            // If we're still loading, create a white rectangle which blocks the fill background, indicating data yet to be loaded.
            if (time < _status.Transitions.MaxRetentionTime)
            {
                _graphPane.Chart.Fill = new Fill(_backgroundGradientColor1, _backgroundGradientColor2, 45.0f);
                _unfinishedBox        = new BoxObj(
                    time,
                    _graphPane.YAxis.Scale.Max,
                    _graphPane.XAxis.Scale.Max - time,
                    _graphPane.YAxis.Scale.Max - _graphPane.YAxis.Scale.Min,
                    Color.White, Color.White)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    ZOrder   = ZOrder.F_BehindGrid
                };
                _graphPane.GraphObjList.Add(_unfinishedBox);

                // Place a vertical line after the last loaded data.
                _unfinishedLine = new LineObj(
                    _unfinishedLineColor,
                    time,
                    _graphPane.YAxis.Scale.Max,
                    time,
                    _graphPane.YAxis.Scale.Min)
                {
                    Location = { CoordinateFrame = CoordType.AxisXYScale },
                    Line     = { Width = PROGRESS_LINE_WIDTH },
                    ZOrder   = ZOrder.D_BehindAxis
                };
                _graphPane.GraphObjList.Add(_unfinishedLine);
            }
        }
Esempio n. 19
0
        private void GetZones(Tuple <MyPoint[], MyPoint[]> data, ZedGraphControl zedGraphControl)
        {
            var sign        = -1;
            var areas       = new List <Area>();
            var currentArea = new Area()
            {
                MinX = data.Item1[0].X,
                Type = AreaType.Negative
            };

            areas.Add(currentArea);
            for (int i = 0; i < data.Item1.Length; i++)
            {
                var maxD        = data.Item1[i].Y;
                var dn          = data.Item2[i].Y;
                var currentSign = Math.Sign(dn - maxD);
                if (sign != currentSign)
                {
                    currentArea.MaxX = data.Item1[i].X;
                    currentArea      = new Area()
                    {
                        MinX = data.Item1[i].X,
                        Type = currentSign > 0 ? AreaType.Positive : AreaType.Negative
                    };
                    areas.Add(currentArea);
                    sign = currentSign;
                }
            }
            currentArea.MaxX = data.Item1[data.Item1.Length - 1].X;

            foreach (var area in areas)
            {
                BoxObj box = new BoxObj(area.MinX, zedGraphControl.GraphPane.YAxis.Scale.Max, area.MaxX - area.MinX, zedGraphControl.GraphPane.YAxis.Scale.Max, Color.Empty, area.Type == AreaType.Positive ? Color.LightGreen : Color.IndianRed);
                box.Location.CoordinateFrame = CoordType.AxisXYScale;
                box.Location.AlignH          = AlignH.Left;
                box.Location.AlignV          = AlignV.Top;
                box.ZOrder = ZOrder.E_BehindCurves;
                zedGraphControl.GraphPane.GraphObjList.Add(box);
            }
        }
Esempio n. 20
0
        public void UpdateSelection()
        {
            if (!ShowSelection)
            {
                if (!zedGraphControl1.GraphPane.GraphObjList.Any())
                {
                    return;
                }
            }
            var    selectedPath      = SkylineWindow.SelectedPath;
            string selectedReplicate = null;

            if (SkylineWindow.SelectedResultsIndex >= 0)
            {
                selectedReplicate = SkylineWindow.DocumentUI.MeasuredResults
                                    ?.Chromatograms[SkylineWindow.SelectedResultsIndex].Name;
            }

            zedGraphControl1.GraphPane.GraphObjList.Clear();
            if (ShowSelection)
            {
                var selectedPoints = GraphResults.Points.Where(p =>
                                                               Equals(p.IdentityPath, selectedPath) && Equals(p.ReplicateName, selectedReplicate)).ToList();
                foreach (var selectedPoint in selectedPoints)
                {
                    var pointPair = MakePointPair(selectedPoint);
                    var graphObj  = new BoxObj(pointPair.X - .5, pointPair.Y + .5, 1, 1, Color.Black, Color.Transparent)
                    {
                        IsClippedToChartRect = true,
                        ZOrder = ZOrder.D_BehindAxis,
                    };
                    zedGraphControl1.GraphPane.GraphObjList.Add(graphObj);
                }
            }
            zedGraphControl1.Invalidate();
        }
Esempio n. 21
0
        /// <summary>
        /// 图形描绘
        /// </summary>
        public override void DrawGraph()
        {
            #region 图形所需数据
            //线条数组[线条数] [每条线的刻度值]
            double[][] lines;
            //X轴刻度
            double[] xAixsScale;
            //线条标注
            string[] labels;
            //X轴刻度标注
            string[] xAxisScaleLabels;

            if (base.XAxisScaleRefrence == DataTableStruct.Rows)
            {
                xAixsScale       = new double[base.DataSource.Rows.Count];
                xAxisScaleLabels = new string[base.DataSource.Rows.Count];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //要绘制的线条数为数据列数
                lines = new double[base.ShowValueColumns.Length][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    labels[i] = base.ShowValueColumns[i].ColumnName;
                }


                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.DataSource.Rows.Count; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[j][base.ShowValueColumns[i].ColumnField]);
                        }
                    }
                }
            }
            else
            {
                xAixsScale       = new double[base.ShowValueColumns.Length];
                xAxisScaleLabels = new string[base.ShowValueColumns.Length];
                for (int i = 0; i < base.ShowValueColumns.Length; i++)
                {
                    xAixsScale[i]       = i;
                    xAxisScaleLabels[i] = base.ShowValueColumns[i].ColumnName;
                }
                //要绘制的线条数为数据集的纪录数
                lines = new double[base.DataSource.Rows.Count][];
                //线条标注
                labels = new string[lines.Length];
                for (int i = 0; i < base.DataSource.Rows.Count; i++)
                {
                    labels[i] = base.DataSource.Rows[i][base.CNNameColumn].ToString();
                }
                //填充每条线的数据值
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = new double[xAixsScale.Length];
                    for (int j = 0; j < base.ShowValueColumns.Length; j++)
                    {
                        if (Convert.IsDBNull(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]))
                        {
                            lines[i][j] = 0;
                        }
                        else
                        {
                            lines[i][j] = Convert.ToDouble(base.DataSource.Rows[i][base.ShowValueColumns[j].ColumnField]);
                        }
                    }
                }
            }

            int maxXaisxScale = xAixsScale.Length;

            //Console.Beep();

            #endregion

            #region 显示图形
            base.GraphContainer.Controls.Clear();

            ZedGraph.ZedGraphControl grphTx = new ZedGraph.ZedGraphControl();

            grphTx.IsEnableHZoom     = false;
            grphTx.IsEnableVZoom     = false;
            grphTx.IsEnableWheelZoom = false;
            grphTx.Dock = System.Windows.Forms.DockStyle.Fill;


            ZedGraph.GraphPane myPane = grphTx.GraphPane;
            myPane.Title.Text       = base.GraphTitle;
            myPane.XAxis.Title.Text = base.XAxisTitle;
            myPane.YAxis.Title.Text = base.YAxisTitle;

            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);
            //线条显示
            for (int i = 0; i < lines.Length; i++)
            {
                Color color;
                if (base.Colors == null)
                {
                    color = GetColor();
                }
                else
                {
                    color = base.Colors[i];
                }

                ZedGraph.LineItem myCurve = myPane.AddCurve(labels[i], xAixsScale, lines[i], color);

                myCurve.Symbol.Fill = new Fill(Color.White);
            }

            //X轴属性
            myPane.XAxis.Scale.Min            = 0;                //X轴刻度起始值
            myPane.XAxis.Scale.Max            = maxXaisxScale;    //X轴刻度最大值
            myPane.XAxis.Scale.TextLabels     = xAxisScaleLabels; //x轴刻度中文标注
            myPane.XAxis.Type                 = AxisType.Text;    //类型
            myPane.XAxis.Scale.FontSpec.Angle = 90;               //文字方向
            myPane.XAxis.Scale.FontSpec.Size = 11F;               //文字大小

            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;


            BoxObj box = new BoxObj(0, 100, 1, 30, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));
            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);

            box.ZOrder = ZOrder.E_BehindCurves;

            box.IsClippedToChartRect = true;

            box.Location.CoordinateFrame = CoordType.XChartFractionYScale;
            myPane.GraphObjList.Add(box);

            TextObj text = new TextObj("", 0.95f, 85, CoordType.AxisXYScale,
                                       AlignH.Right, AlignV.Center);
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold           = true;
            text.FontSpec.IsItalic         = true;
            text.Location.CoordinateFrame  = CoordType.XChartFractionYScale;
            text.IsClippedToChartRect      = true;

            myPane.GraphObjList.Add(text);

            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);

            grphTx.AxisChange();

            base.GraphContainer.Controls.Add(grphTx);
            #endregion
        }
Esempio n. 22
0
        public DiaIsolationWindowsGraphForm(List <IsolationWindow> isolationWindows, bool usesMargins, object deconv, int windowsPerScan)
        {
            InitializeComponent();
            Icon = Resources.Skyline;
            if (isolationWindows.Count == 0)
            {
                return;
            }

            bool overlap = Equals(deconv, EditIsolationSchemeDlg.DeconvolutionMethod.MSX_OVERLAP) ||
                           Equals(deconv, EditIsolationSchemeDlg.DeconvolutionMethod.OVERLAP) ||
                           Equals(deconv, EditIsolationSchemeDlg.DeconvolutionMethod.FAST_OVERLAP);


            //Setup Graph
            zgIsolationGraph.GraphPane.Title.Text                       = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_Measurement_Windows;
            zgIsolationGraph.GraphPane.XAxis.Title.Text                 = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_m_z;
            zgIsolationGraph.GraphPane.YAxis.Title.Text                 = Resources.DiaIsolationWindowsGraphForm_DiaIsolationWindowsGraphForm_Cycle;
            zgIsolationGraph.GraphPane.IsFontsScaled                    = false;
            zgIsolationGraph.GraphPane.YAxis.Scale.IsReverse            = true;
            zgIsolationGraph.GraphPane.YAxisList[0].MajorTic.IsOpposite = false;
            zgIsolationGraph.GraphPane.YAxisList[0].MinorTic.IsOpposite = false;
            zgIsolationGraph.GraphPane.XAxis.MajorTic.IsOpposite        = false;
            zgIsolationGraph.GraphPane.XAxis.MinorTic.IsOpposite        = false;
            zgIsolationGraph.MasterPane.Border.IsVisible                = false;
            zgIsolationGraph.GraphPane.YAxis.MajorGrid.IsZeroLine       = false;
            zgIsolationGraph.GraphPane.Border.IsVisible                 = false;
            zgIsolationGraph.GraphPane.Chart.Border.IsVisible           = false;
            zgIsolationGraph.IsZoomOnMouseCenter = true;

            //Draw Lines and rectangles
            _windows      = new List <BoxObj>(20);
            _leftMargins  = new List <BoxObj>(20);
            _rightMargins = new List <BoxObj>(20);
            _smallesMz    = Double.MaxValue;
            _largestMz    = 0;
            var isolationWindowArray = isolationWindows.ToArray();  // ReSharper
            int windowCount          = isolationWindowArray.Length;

            for (int cycle = 0; cycle < TOTAL_CYCLES_SHOWN; cycle++)
            {
                int firstIndex = overlap && cycle % 2 == 1 ? windowCount / 2 : 0;
                int stopIndex  = overlap && cycle % 2 == 0 ? windowCount / 2 : windowCount;
                for (int i = firstIndex; i < stopIndex; i++)
                {
                    IsolationWindow window       = isolationWindowArray[i];
                    double          windowY      = cycle + (double)(i - firstIndex) / (stopIndex - firstIndex);
                    double          windowX      = window.Start;
                    double          windowWidth  = window.End - window.Start;
                    double          windowHeight = 1.0 / (stopIndex - firstIndex);
                    BoxObj          windowBox    = new BoxObj(windowX, windowY, windowWidth, windowHeight, _windowColor, _windowColor)
                    {
                        IsClippedToChartRect = true
                    };
                    zgIsolationGraph.GraphPane.GraphObjList.Add(windowBox);
                    _windows.Add(windowBox);
                    if (usesMargins)
                    {
                        double marginLeftX     = windowX - window.StartMargin ?? 0;
                        double marginLeftWidth = window.StartMargin ?? 0;
                        BoxObj marginLeftBox   = new BoxObj(marginLeftX, windowY, marginLeftWidth, windowHeight, _marginColor, _marginColor)
                        {
                            IsClippedToChartRect = true
                        };
                        zgIsolationGraph.GraphPane.GraphObjList.Add(marginLeftBox);
                        _leftMargins.Add(marginLeftBox);

                        double marginRightX     = windowX + windowWidth;
                        double marginRightWidth = window.EndMargin ?? window.StartMargin ?? 0;
                        BoxObj marginRightBox   = new BoxObj(marginRightX, windowY, marginRightWidth, windowHeight, _marginColor, _marginColor)
                        {
                            IsClippedToChartRect = true
                        };
                        zgIsolationGraph.GraphPane.GraphObjList.Add(marginRightBox);
                        _rightMargins.Add(marginRightBox);
                        _largestMz = Math.Max(marginRightX + marginRightWidth, _largestMz);
                        _smallesMz = Math.Min(marginLeftX, _smallesMz);
                    }
                    _largestMz = Math.Max(_largestMz, windowX + windowWidth);
                    _smallesMz = Math.Min(_smallesMz, windowX);
                }
            }

            _overlapRayBoxes = overlap ? new List <BoxObj>() : null;
            _gapBoxes        = new List <BoxObj>();
            _overlapBoxes    = new List <BoxObj>();


            for (int cycle = 0; cycle < TOTAL_CYCLES_SHOWN; cycle++)
            {
                int currentCycleStart;
                int currentCycleCount;
                int nextCycleStart;
                int nextCycleCount;
                if (overlap)
                {
                    currentCycleStart = cycle * windowCount / 2;
                    currentCycleCount = windowCount / 2;
                    nextCycleStart    = currentCycleStart + currentCycleCount;
                    nextCycleCount    = windowCount / 2;
                }
                else
                {
                    currentCycleStart = cycle * windowCount;
                    currentCycleCount = windowCount;
                    nextCycleStart    = currentCycleStart + windowCount;
                    nextCycleCount    = windowCount;
                }
                List <BoxObj> currentCycleWindows =
                    _windows.GetRange(currentCycleStart, currentCycleCount).OrderBy(o => Location.X).ToList();
                List <BoxObj> nextCycleWindows = cycle < TOTAL_CYCLES_SHOWN - 1
                    ? _windows.GetRange(nextCycleStart, nextCycleCount).OrderBy(o => Location.X).ToList()
                    : null;

                for (int i = 0; i < currentCycleWindows.Count; i++)
                {
                    BoxObj currentCycleCurrentBox = currentCycleWindows.ElementAt(i);
                    BoxObj currentCycleNextBox    = i < currentCycleWindows.Count - 1 ? currentCycleWindows.ElementAt(i + 1) : null;

                    if (currentCycleNextBox != null)
                    {
                        checkGaps(currentCycleCurrentBox, currentCycleNextBox);
                        checkOverlaps(currentCycleCurrentBox, currentCycleNextBox);
                    }

                    if (overlap && i % 2 == 0 && nextCycleWindows != null)
                    {
                        int    leftBoxIndex      = cycle % 2 == 0 ? i : i - 1;
                        BoxObj nextCycleLeftBox  = leftBoxIndex >= 0 ? nextCycleWindows.ElementAt(leftBoxIndex) : null;
                        int    rightBoxIndex     = cycle % 2 == 0 ? i + 1 : i;
                        BoxObj nextCycleRightBox = rightBoxIndex < nextCycleWindows.Count
                            ? nextCycleWindows.ElementAt(rightBoxIndex)
                            : null;
                        BoxObj rayBoxLeft  = null;
                        BoxObj rayBoxRight = null;
                        if (nextCycleLeftBox != null)
                        {
                            rayBoxLeft = GetOverLapRay(currentCycleCurrentBox, nextCycleLeftBox);
                            if (rayBoxLeft != null)
                            {
                                zgIsolationGraph.GraphPane.GraphObjList.Add(rayBoxLeft);
                                _overlapRayBoxes.Add(rayBoxLeft);
                            }
                        }
                        if (nextCycleRightBox != null)
                        {
                            rayBoxRight = GetOverLapRay(currentCycleCurrentBox, nextCycleRightBox);
                            if (rayBoxRight != null)
                            {
                                zgIsolationGraph.GraphPane.GraphObjList.Add(rayBoxRight);
                                _overlapRayBoxes.Add(rayBoxRight);
                            }
                        }
                        if (rayBoxLeft != null && rayBoxRight == null)
                        {
                            rayBoxLeft.Location.X1    = currentCycleCurrentBox.Location.X1;
                            rayBoxLeft.Location.Width = currentCycleCurrentBox.Location.Width;
                        }
                        else if (rayBoxRight != null && rayBoxLeft == null)
                        {
                            rayBoxRight.Location.X1    = currentCycleCurrentBox.Location.X1;
                            rayBoxRight.Location.Width = currentCycleCurrentBox.Location.Width;
                        }
                    }
                }
            }

            zgIsolationGraph.GraphPane.XAxis.Scale.Min = _smallesMz;
            zgIsolationGraph.GraphPane.XAxis.Scale.Max = _largestMz;
            zgIsolationGraph.GraphPane.YAxis.Scale.Min = Y_SCALE_MIN;
            zgIsolationGraph.GraphPane.YAxis.Scale.Max = Y_SCALE_MAX;
            zgIsolationGraph.AxisChange();
            zgIsolationGraph.Invalidate();

            //Setup check boxes and color labels
            if (usesMargins)
            {
                cbMargin.Checked = true;
            }
            else
            {
                cbMargin.Hide();
                labelMarginColor.Hide();
                int width = cbMargin.Width;
                cbShowOverlapRays.Left       -= width;
                labelOverlapColor.Left       -= width;
                cbShowOverlapsSingle.Left    -= width;
                labelSingleOverlapColor.Left -= width;
                cbShowGaps.Left    -= width;
                labelGapColor.Left -= width;
            }
            cbShowGaps.Checked           = true;
            cbShowOverlapsSingle.Checked = true;
            if (overlap)
            {
                cbShowOverlapRays.Checked = true;
                labelOverlapColor.Visible = true;
            }
            else
            {
                cbShowOverlapRays.Hide();
                labelOverlapColor.Hide();
            }
            labelMarginColor.BackColor        = _marginColor;
            labelWindowColor.BackColor        = _windowColor;
            labelGapColor.BackColor           = _gapColor;
            labelSingleOverlapColor.BackColor = _overlapColor;
            labelOverlapColor.BackColor       = _overlapRayColor;
        }
Esempio n. 23
0
 /// <summary>
 /// Add the <see cref="ZedGraphWebGraphObj" /> objects defined in the webcontrol to
 /// the <see cref="GraphPane" /> as <see cref="GraphObj" /> objects.
 /// </summary>
 /// <param name="g">The <see cref="Graphics" /> instance of interest.</param>
 /// <param name="pane">The <see cref="GraphPane" /> object to receive the
 /// <see cref="GraphObj" /> objects.</param>
 protected void AddWebGraphItems(IGraphics g, GraphPane pane)
 {
     try
     {
         ZedGraphWebGraphObj draw;
         for (int i = 0; i < GraphObjList.Count; i++)
         {
             draw = GraphObjList[i];
             if (draw is ZedGraphWebTextObj)
             {
                 var item = (ZedGraphWebTextObj) draw;
                 var x = new TextObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebArrowObj)
             {
                 var item = (ZedGraphWebArrowObj) draw;
                 var x = new ArrowObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebImageObj)
             {
                 var item = (ZedGraphWebImageObj) draw;
                 var x = new ImageObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebBoxObj)
             {
                 var item = (ZedGraphWebBoxObj) draw;
                 var x = new BoxObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
             else if (draw is ZedGraphWebEllipseObj)
             {
                 var item = (ZedGraphWebEllipseObj) draw;
                 var x = new EllipseObj();
                 item.CopyTo(x);
                 pane.GraphObjList.Add(x);
             }
         }
     }
     catch (Exception ex)
     {
         Log.Debug("Exception thrown at AddWebGraphItems: " + ex.Message, ex);
     }
 }
Esempio n. 24
0
        public ComboDemo() : base("A demo that combines bar charts with line graphs, curve filling, text items, etc.",
                                  "Combo Demo", DemoType.General, DemoType.Line)
        {
            GraphPane myPane = base.GraphPane;

            // Set the titles and axis labels
            myPane.Title.Text       = "Wacky Widget Company\nProduction Report";
            myPane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            myPane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            // Use green, with circle symbols
            curve            = myPane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F);
            // Make it a smooth line
            curve.Line.IsSmooth      = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            // Use a red color with triangle symbols
            curve            = myPane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F);
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4  = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4  = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 };
            BarItem  bar = myPane.AddBar("Wheezy", x4, y4, Color.SteelBlue);

            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown);

            // Fourth curve is a bar
            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 };
            bar = myPane.AddBar("Curly", x2, y2, Color.RoyalBlue);
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue);

            // Fill the pane background with a gradient
            myPane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245),
                                         Color.FromArgb(255, 255, 190), 90F);


            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            myPane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            myPane.BarSettings.Type = BarType.Stack;

            // Enable the X and Y axis grids
            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;

            // Manually set the scale maximums according to user preference
            myPane.XAxis.Scale.Max = 1200;
            myPane.YAxis.Scale.Max = 120;

            // Add a text item to decorate the graph
            TextObj text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F);

            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH          = AlignH.Center;
            text.Location.AlignV          = AlignV.Bottom;
            text.FontSpec.Fill            = new Fill(Color.White, Color.PowderBlue, 45F);
            text.FontSpec.StringAlignment = StringAlignment.Near;
            myPane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);

            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            myPane.GraphObjList.Add(arrow);

            // Add a another text item to to point out a graph feature
            text = new TextObj("Upgrade", 700F, 50.0F);
            // rotate the text 90 degrees
            text.FontSpec.Angle = 90;
            // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            // Disable the border and background fill options for the text
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            myPane.GraphObjList.Add(arrow);

            // Add a text "Confidential" stamp to the graph
            text = new TextObj("Confidential", 0.85F, -0.03F);
            // use AxisFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.ChartFraction;
            // rotate the text 15 degrees
            text.FontSpec.Angle = 15.0F;
            // Text will be red, bold, and 16 point
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold    = true;
            text.FontSpec.Size      = 16;
            // Disable the border and background fill options for the text
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible   = false;
            // Align the text such the the Left-Bottom corner is at the specified coordinates
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            myPane.GraphObjList.Add(text);

            // Add a BoxObj to show a colored band behind the graph data
            BoxObj box = new BoxObj(0, 110, 1200, 10,
                                    Color.Empty, Color.FromArgb(225, 245, 225));

            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            // Align the left-top of the box to (0, 110)
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            // place the box behind the axis items, so the grid is drawn on top of it
            box.ZOrder = ZOrder.F_BehindGrid;
            myPane.GraphObjList.Add(box);

            // Add some text inside the above box to indicate "Peak Range"
            TextObj myText = new TextObj("Peak Range", 1170, 105);

            myText.Location.CoordinateFrame  = CoordType.AxisXYScale;
            myText.Location.AlignH           = AlignH.Right;
            myText.Location.AlignV           = AlignV.Center;
            myText.FontSpec.IsItalic         = true;
            myText.FontSpec.IsBold           = false;
            myText.FontSpec.Fill.IsVisible   = false;
            myText.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(myText);

            base.ZedGraphControl.AxisChange();
        }
Esempio n. 25
0
        private void button3_Click(object sender, EventArgs e)
        {
            GraphPane myPane = zg1.GraphPane;

            // Set the title and axis labels
            myPane.Title.Text       = "Line Graph with Band Demo";
            myPane.XAxis.Title.Text = "Sequence";
            myPane.YAxis.Title.Text = "Temperature, C";

            // Enter some random data values
            double[] y  = { 100, 115, 75, 22, 98, 40, 10 };
            double[] y2 = { 90, 100, 95, 35, 80, 35, 35 };
            double[] y3 = { 80, 110, 65, 15, 54, 67, 18 };
            double[] x  = { 100, 200, 300, 400, 500, 600, 700 };

            // Fill the axis background with a color gradient
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245), Color.FromArgb(255, 255, 190), 90F);

            // Generate a red curve with "Curve 1" in the legend
            LineItem myCurve = myPane.AddCurve("Curve 1", x, y, Color.Red);

            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Generate a blue curve with "Curve 2" in the legend
            myCurve = myPane.AddCurve("Curve 2", x, y2, Color.Blue);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Generate a green curve with "Curve 3" in the legend
            myCurve = myPane.AddCurve("Curve 3", x, y3, Color.Green);
            // Make the symbols opaque by filling them with white
            myCurve.Symbol.Fill = new Fill(Color.White);

            // Manually set the x axis range
            myPane.XAxis.Scale.Min = 0;
            myPane.XAxis.Scale.Max = 800;
            // Display the Y axis grid lines
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MinorGrid.IsVisible = true;

            // Draw a box item to highlight a value range
            BoxObj box = new BoxObj(0, 100, 800, 30, Color.Empty,
                                    Color.FromArgb(150, Color.LightGreen));

            box.Fill = new Fill(Color.White, Color.FromArgb(200, Color.LightGreen), 45.0F);
            // Use the BehindAxis zorder to draw the highlight beneath the grid lines
            box.ZOrder = ZOrder.E_BehindAxis;
            myPane.GraphObjList.Add(box);

            // Add a text item to label the highlighted range
            TextObj text = new TextObj("Optimal\nRange", 750, 85, CoordType.AxisXYScale,
                                       AlignH.Right, AlignV.Center);

            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.IsBold           = true;
            text.FontSpec.IsItalic         = true;
            myPane.GraphObjList.Add(text);
            zg1.AxisChange();
        }
Esempio n. 26
0
        private void Form1_Load(object sender, EventArgs e)
        {
            memGraphics.CreateDoubleBuffer(this.CreateGraphics(),
                                           this.ClientRectangle.Width, this.ClientRectangle.Height);

            myPane = new GraphPane(new Rectangle(10, 10, 10, 10),
                                   "Wacky Widget Company\nProduction Report",
                                   "Time, Days\n(Since Plant Construction Startup)",
                                   "Widget Production\n(units/hour)");
            SetSize();

            double[] x = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y = { 20, 10, 50, 25, 35, 75, 90, 40, 33, 50 };
            LineItem curve;

            curve                    = myPane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle);
            curve.Line.Width         = 1.5F;
            curve.Line.Fill          = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F);
            curve.Line.IsSmooth      = true;
            curve.Line.SmoothTension = 0.6F;
            curve.Symbol.Fill        = new Fill(Color.White);
            curve.Symbol.Size        = 10;

            double[] x3 = { 150, 250, 400, 520, 780, 940 };
            double[] y3 = { 5.2, 49.0, 33.8, 88.57, 99.9, 36.8 };
            curve            = myPane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle);
            curve.Line.Width = 1.5F;
            //curve.Line.IsSmooth = true;
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Line.Fill   = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F);
            curve.Symbol.Size = 10;

            double[] x4  = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y4  = { 30, 45, 53, 60, 75, 83, 84, 79, 71, 57 };
            BarItem  bar = myPane.AddBar("Wheezy", x4, y4, Color.SteelBlue);

            bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown);
            myPane.BarSettings.ClusterScaleWidth = 100;
            myPane.BarSettings.Type = BarType.Stack;

            double[] x2 = { 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 };
            double[] y2 = { 10, 15, 17, 20, 25, 27, 29, 26, 24, 18 };
            bar          = myPane.AddBar("Curly", x2, y2, Color.RoyalBlue);
            bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue);
            myPane.BarSettings.ClusterScaleWidth = 100;

            myPane.Fill       = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            myPane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245),
                                         Color.FromArgb(255, 255, 190), 90F);

            myPane.XAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.MajorGrid.IsVisible = true;
            myPane.YAxis.Scale.Max           = 120;

            TextObj text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F);

            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill   = new Fill(Color.White, Color.PowderBlue, 45F);
            myPane.GraphObjList.Add(text);

            ArrowObj arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);

            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            myPane.GraphObjList.Add(arrow);

            text = new TextObj("Upgrade", 700F, 50.0F);
            text.FontSpec.Angle            = 90;
            text.FontSpec.FontColor        = Color.Black;
            text.Location.AlignH           = AlignH.Right;
            text.Location.AlignV           = AlignV.Center;
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(text);

            arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.PenWidth = 2.0F;
            myPane.GraphObjList.Add(arrow);

            text = new TextObj("Confidential", 0.85F, -0.03F);
            text.Location.CoordinateFrame = CoordType.ChartFraction;

            text.FontSpec.Angle            = 15.0F;
            text.FontSpec.FontColor        = Color.Red;
            text.FontSpec.IsBold           = true;
            text.FontSpec.Size             = 16;
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Border.Color     = Color.Red;
            text.FontSpec.Fill.IsVisible   = false;

            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            myPane.GraphObjList.Add(text);

            BoxObj box = new BoxObj(0, 110, 1200, 10,
                                    Color.Empty, Color.FromArgb(225, 245, 225));

            box.Location.CoordinateFrame = CoordType.AxisXYScale;

            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            box.ZOrder          = ZOrder.E_BehindAxis;
            myPane.GraphObjList.Add(box);

            text = new TextObj("Peak Range", 1170, 105);
            text.Location.CoordinateFrame  = CoordType.AxisXYScale;
            text.Location.AlignH           = AlignH.Right;
            text.Location.AlignV           = AlignV.Center;
            text.FontSpec.IsItalic         = true;
            text.FontSpec.IsBold           = false;
            text.FontSpec.Fill.IsVisible   = false;
            text.FontSpec.Border.IsVisible = false;
            myPane.GraphObjList.Add(text);

            myPane.AxisChange(this.CreateGraphics());
        }
Esempio n. 27
0
        public override void AddAnnotations(MSGraphPane graphPane, Graphics g,
                                            MSPointList pointList, GraphObjList annotations)
        {
            if (Chromatogram == null)
            {
                return;
            }


            // Calculate maximum y for potential retention time indicators
            PointF ptTop = new PointF(0, graphPane.Chart.Rect.Top);

            if (GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                if (RetentionMsMs != null)
                {
                    foreach (double retentionTime in RetentionMsMs)
                    {
                        Color color = COLOR_MSMSID_TIME;
                        if (SelectedRetentionMsMs.HasValue && Equals((float)retentionTime, (float)SelectedRetentionMsMs))
                        {
                            color = ColorSelected;
                        }
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop,
                                                   Resources.ChromGraphItem_AddAnnotations_ID, GraphObjType.ms_ms_id, color,
                                                   ScaleRetentionTime(retentionTime));
                    }
                }
                if (MidasRetentionMsMs != null)
                {
                    foreach (var retentionTime in MidasRetentionMsMs)
                    {
                        var color = SelectedRetentionMsMs.HasValue && Equals((float)retentionTime, (float)SelectedRetentionMsMs)
                            ? ColorSelected
                            : COLOR_MSMSID_TIME;
                        AddRetentionTimeAnnotation(graphPane, g, annotations, ptTop, string.Empty, GraphObjType.midas_spectrum, color, ScaleRetentionTime(retentionTime));
                    }
                }
                if (AlignedRetentionMsMs != null)
                {
                    foreach (var time in AlignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line       = new LineObj(COLOR_ALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                                     scaledTime.DisplayTime, 1)
                        {
                            ZOrder               = ZOrder.F_BehindGrid,
                            Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.aligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
                if (UnalignedRetentionMsMs != null)
                {
                    foreach (var time in UnalignedRetentionMsMs)
                    {
                        var scaledTime = ScaleRetentionTime(time);
                        var line       = new LineObj(COLOR_UNALIGNED_MSMSID_TIME, scaledTime.DisplayTime, 0,
                                                     scaledTime.DisplayTime, 1)
                        {
                            ZOrder               = ZOrder.F_BehindGrid,
                            Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                            IsClippedToChartRect = true,
                            Tag = new GraphObjTag(this, GraphObjType.unaligned_ms_id, scaledTime),
                        };
                        annotations.Add(line);
                    }
                }
            }

            // Draw retention time indicator, if set
            if (RetentionPrediction.HasValue)
            {
                double time = RetentionPrediction.Value;

                // Create temporary label to calculate positions
                if (GraphChromatogram.ShowRT != ShowRTChrom.none)
                {
                    AddRetentionTimeAnnotation(graphPane,
                                               g,
                                               annotations,
                                               ptTop,
                                               Resources.ChromGraphItem_AddAnnotations_Predicted,
                                               GraphObjType.predicted_rt_window,
                                               COLOR_RETENTION_TIME,
                                               ScaleRetentionTime(time));
                }

                // Draw background for retention time window
                if (RetentionWindow > 0)
                {
                    double x1  = ScaleRetentionTime(time - RetentionWindow / 2).DisplayTime;
                    double x2  = ScaleRetentionTime(time + RetentionWindow / 2).DisplayTime;
                    BoxObj box = new BoxObj(x1, 0, x2 - x1, 1,
                                            COLOR_RETENTION_WINDOW, COLOR_RETENTION_WINDOW)
                    {
                        Location             = { CoordinateFrame = CoordType.XScaleYChartFraction },
                        IsClippedToChartRect = true,
                        ZOrder = ZOrder.F_BehindGrid
                    };
                    annotations.Add(box);
                }
            }

            if (RetentionExplicit != null && GraphChromatogram.ShowRT != ShowRTChrom.none)
            {
                // Create temporary label to calculate positions
                AddRetentionTimeAnnotation(graphPane,
                                           g,
                                           annotations,
                                           ptTop,
                                           Resources.ChromGraphItem_AddAnnotations_Explicit,
                                           GraphObjType.predicted_rt_window,
                                           COLOR_RETENTION_TIME,
                                           ScaleRetentionTime(RetentionExplicit.RetentionTime));
            }

            for (int i = 0, len = Chromatogram.NumPeaks; i < len; i++)
            {
                if (_arrayLabelIndexes[i] == -1)
                {
                    continue;
                }

                double maxIntensity = _intensities[_arrayLabelIndexes[i]];

                // Show peak extent indicators, if they are far enough apart
                ChromPeak peak = Chromatogram.GetPeak(i);
                AddPeakBoundaries(graphPane, annotations, false,
                                  ScaleRetentionTime(peak.StartTime), ScaleRetentionTime(peak.EndTime), maxIntensity);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Create an ion mobility heat map graph.
        /// </summary>
        private void CreateIonMobilityHeatmap()
        {
            GraphPane.YAxis.Title.Text = IonMobilityFilter.IonMobilityUnitsL10NString(_msDataFileScanHelper.IonMobilityUnits);
            graphControl.IsEnableVZoom = graphControl.IsEnableVPan = true;

            if (_heatMapData == null)
            {
                var points = new List <Point3D>(5000);
                foreach (var scan in _msDataFileScanHelper.MsDataSpectra)
                {
                    if (!scan.IonMobility.HasValue && scan.IonMobilities == null)
                    {
                        continue;
                    }
                    for (int j = 0; j < scan.Mzs.Length; j++)
                    {
                        double mobilityValue = scan.IonMobilities != null
                            ? scan.IonMobilities[j]
                            : scan.IonMobility.Mobility.Value;

                        points.Add(new Point3D(scan.Mzs[j], mobilityValue, scan.Intensities[j]));
                    }
                }
                _heatMapData = new HeatMapData(points);
            }

            double minDrift;
            double maxDrift;

            _msDataFileScanHelper.GetIonMobilityRange(out minDrift, out maxDrift, _msDataFileScanHelper.Source);  // There may be a different drift time filter for products in Waters

            if (minDrift > 0 && maxDrift < double.MaxValue)
            {
                // Add gray shaded box behind heat points.
                var driftTimeBox = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.Transparent,
                    Color.FromArgb(50, Color.Gray))
                {
                    Location             = { CoordinateFrame = CoordType.XChartFractionYScale },
                    ZOrder               = ZOrder.F_BehindGrid,
                    IsClippedToChartRect = true,
                };
                GraphPane.GraphObjList.Add(driftTimeBox);

                // Add outline in front of heat points, so you can tell where the limits are in a dense graph.
                var driftTimeOutline = new BoxObj(
                    0.0,
                    maxDrift,
                    1.0,
                    maxDrift - minDrift,
                    Color.FromArgb(50, Color.DarkViolet),
                    Color.Transparent)
                {
                    Location             = { CoordinateFrame = CoordType.XChartFractionYScale },
                    ZOrder               = ZOrder.C_BehindChartBorder,
                    IsClippedToChartRect = true,
                    Border               = new Border(Color.FromArgb(100, Color.DarkViolet), 2)
                };
                GraphPane.GraphObjList.Add(driftTimeOutline);
            }

            if (!Settings.Default.FilterIonMobilityFullScan)
            {
                minDrift = 0;
                maxDrift = double.MaxValue;
            }
            var heatMapGraphPane = (HeatMapGraphPane)GraphPane;

            heatMapGraphPane.SetPoints(_heatMapData, minDrift, maxDrift);
        }
Esempio n. 29
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 hasIonMobilityDimension = _msDataFileScanHelper.MsDataSpectra.Length > 1 ||
                                           _msDataFileScanHelper.MsDataSpectra.First().IonMobilities != null;
            bool useHeatMap = hasIonMobilityDimension && !Settings.Default.SumScansFullScan;

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

            if (hasIonMobilityDimension)
            {
                // Is there actually any drift time filtering available?
                double minIonMobility, maxIonMobility;
                _msDataFileScanHelper.GetIonMobilityRange(out minIonMobility, out maxIonMobility, ChromSource.unknown); // Get range of IM values for all products and precursors
                if ((minIonMobility == double.MinValue) && (maxIonMobility == 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
                CreateIonMobilityHeatmap();
            }
            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);
            if (Settings.Default.ShowFullScanNumber && _msDataFileScanHelper.MsDataSpectra.Any())
            {
                if (_msDataFileScanHelper.MsDataSpectra.Length > 1) // For ion mobility, show the overall range
                {
                    GraphPane.Title.Text = TextUtil.SpaceSeparate(GraphPane.Title.Text,
                                                                  Resources.GraphFullScan_CreateGraph_IM_Scan_Range_, _msDataFileScanHelper.MsDataSpectra[0].Id, @"-", _msDataFileScanHelper.MsDataSpectra.Last().Id);
                }
                else
                {
                    GraphPane.Title.Text = TextUtil.SpaceSeparate(GraphPane.Title.Text,
                                                                  Resources.GraphFullScan_CreateGraph_Scan_Number_, _msDataFileScanHelper.MsDataSpectra[0].Id);
                }
            }

            FireSelectedScanChanged(retentionTime);
        }
Esempio n. 30
0
 /// <summary>
 /// Copy the properties of this <see cref="ZedGraphWebBoxObj"/> to the specified
 /// <see cref="ZedGraph.BoxObj"/> object.
 /// </summary>
 /// <param name="item">The destination <see cref="ZedGraph.BoxObj"/> object</param>
 internal void CopyTo( BoxObj item )
 {
     base.CopyTo( item );
     this.Border.CopyTo( item.Border );
     this.Fill.CopyTo( item.Fill );
 }
Esempio n. 31
0
        private void DrawGraph()
        {
            GraphPane pane = zedGraph.GraphPane;

            pane.CurveList.Clear();

            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            pane.YAxis.MajorGrid.IsZeroLine = false;

            // Создаем список точек
            RadarPointList points = new RadarPointList();


            // Т.к. в списке будет 4 точки, то и окружность будет разбиваться на 4 части
            // Обход точек будет осуществляться против часовой стрелки
            points.Clockwise = false;

            // Первая точка - сверху над началом координат. Расстояние до центра = 1
            points.Add(1, 1);

            // Вторая точка - слева от начала координат.  Расстояние до центра = 2
            points.Add(2, 1);

            // Третья точка - снизу под началом координат.  Расстояние до центра = 3
            points.Add(3, 1);

            // Четвертая точка - справа от начала координат.  Расстояние до центра = 4
            points.Add(4, 1);


            // Добавляем кривую по этим четырем точкам
            LineItem myCurve = pane.AddCurve("", points, Color.Black, SymbolType.None);


            // Для наглядности нарисуем расстояния от начала координат до каждой из точек
            ArrowObj arrow1 = new ArrowObj(0, 0, 0, 1);

            pane.GraphObjList.Add(arrow1);

            ArrowObj arrow2 = new ArrowObj(0, 0, -2, 0);

            pane.GraphObjList.Add(arrow2);

            ArrowObj arrow3 = new ArrowObj(0, 0, 0, -3);

            pane.GraphObjList.Add(arrow3);

            ArrowObj arrow4 = new ArrowObj(0, 0, 4, 0);

            pane.GraphObjList.Add(arrow4);

            // Отметим начало координат черным квадратиком
            BoxObj box = new BoxObj(-0.05, 0.05, 0.1, 0.1, Color.Black, Color.Black);

            pane.GraphObjList.Add(box);

            zedGraph.AxisChange();

            zedGraph.Invalidate();
        }
Esempio n. 32
0
        public void ShowData(string label, Color c, double[] t, double[] s)
        {
            Analyzer.RunningCount Counter = new Analyzer.RunningCount(AnalysisMetric.Invalid);
            for (int i = 0; i < s.Length; i++)
            {
                Counter.Add(s[i]);
            }

            mZedGraphControl.GraphPane.AddCurve(label, t, s, c, SymbolType.None);

            using (Graphics g = mZedGraphControl.CreateGraphics())
            {   //scale the XY axis appropriately
                mZedGraphControl.GraphPane.XAxis.Scale.PickScale(mZedGraphControl.GraphPane, g, mZedGraphControl.GraphPane.CalcScaleFactor());
                mZedGraphControl.GraphPane.YAxis.Scale.PickScale(mZedGraphControl.GraphPane, g, mZedGraphControl.GraphPane.CalcScaleFactor());
            }

            //refresh the scaling so we can use it later...
            mZedGraphControl.AxisChange();
            mZedGraphControl.Refresh();

            //draw a box for the first standard deviation
            BoxObj StdBox = new BoxObj(
                mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.Mean + Counter.StdDev,
                mZedGraphControl.GraphPane.XAxis.Scale.Max - mZedGraphControl.GraphPane.XAxis.Scale.Min,
                2 * Counter.StdDev,
                Color.Empty,
                Color.FromArgb(150, Color.LightGreen));

            StdBox.IsClippedToChartRect = true;
            StdBox.ZOrder = ZOrder.E_BehindCurves;

            mZedGraphControl.GraphPane.GraphObjList.Add(StdBox);    //add the box

            //draw a box for the second standard deviation
            StdBox = new BoxObj(
                mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.Mean + 2 * Counter.StdDev,
                mZedGraphControl.GraphPane.XAxis.Scale.Max - mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.StdDev,
                Color.Empty,
                Color.FromArgb(150, Color.LightBlue));
            StdBox.IsClippedToChartRect = true;
            StdBox.ZOrder = ZOrder.E_BehindCurves;

            mZedGraphControl.GraphPane.GraphObjList.Add(StdBox);    //add the box

            //draw a box for the second standard deviation
            StdBox = new BoxObj(
                mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.Mean - Counter.StdDev,
                mZedGraphControl.GraphPane.XAxis.Scale.Max - mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.StdDev,
                Color.Empty,
                Color.FromArgb(150, Color.LightBlue));
            StdBox.IsClippedToChartRect = true;
            StdBox.ZOrder = ZOrder.E_BehindCurves;

            mZedGraphControl.GraphPane.GraphObjList.Add(StdBox);    //add the box

            //draw a line for the mean value
            LineObj MeanLine = new LineObj(
                mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.Mean,
                mZedGraphControl.GraphPane.XAxis.Scale.Max,
                Counter.Mean);

            MeanLine.Line.Style           = System.Drawing.Drawing2D.DashStyle.Dash;
            MeanLine.IsClippedToChartRect = true;

            mZedGraphControl.GraphPane.GraphObjList.Add(MeanLine);  //add the line

            //draw a label for the mean value
            TextObj MeanLabel = new TextObj(
                "Mean",
                mZedGraphControl.GraphPane.XAxis.Scale.Min,
                Counter.Mean,
                CoordType.AxisXYScale,
                AlignH.Left,
                AlignV.Bottom);

            MeanLabel.FontSpec.Fill.IsVisible   = false;
            MeanLabel.FontSpec.Border.IsVisible = false;
            MeanLabel.FontSpec.IsBold           = true;
            MeanLabel.FontSpec.IsItalic         = true;

            mZedGraphControl.GraphPane.GraphObjList.Add(MeanLabel); //add the label


            mZedGraphControl.AxisChange();
            mZedGraphControl.Refresh();
        }
Esempio n. 33
0
        /// <summary>
        /// Renders the demo graph with one call.
        /// </summary>
        /// <param name="g">A <see cref="Graphics"/> object for which the drawing will be done.</param>
        /// <param name="pane">A reference to the <see cref="GraphPane"/></param>
        public static void RenderDemo(IGraphics g, GraphPane pane)
        {
            // Set the titles and axis labels
            pane.Title.Text = "Wacky Widget Company\nProduction Report";
            pane.XAxis.Title.Text = "Time, Days\n(Since Plant Construction Startup)";
            pane.YAxis.Title.Text = "Widget Production\n(units/hour)";

            LineItem curve;

            // Set up curve "Larry"
            double[] x = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y = {20, 10, 50, 25, 35, 75, 90, 40, 33, 50};
            // Use green, with circle symbols
            curve = pane.AddCurve("Larry", x, y, Color.Green, SymbolType.Circle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with a white-green gradient
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(60, 190, 50), 90F);
            // Make it a smooth line
            curve.Line.IsSmooth = true;
            curve.Line.SmoothTension = 0.6F;
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Second curve is "moe"
            double[] x3 = {150, 250, 400, 520, 780, 940};
            double[] y3 = {5.2, 49.0, 33.8, 88.57, 99.9, 36.8};
            // Use a red color with triangle symbols
            curve = pane.AddCurve("Moe", x3, y3, Color.FromArgb(200, 55, 135), SymbolType.Triangle);
            curve.Line.Width = 1.5F;
            // Fill the area under the curve with semi-transparent pink using the alpha value
            curve.Line.Fill = new Fill(Color.White, Color.FromArgb(160, 230, 145, 205), 90F);
            // Fill the symbols with white
            curve.Symbol.Fill = new Fill(Color.White);
            curve.Symbol.Size = 10;

            // Third Curve is a bar, called "Wheezy"
            double[] x4 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y4 = {30, 45, 53, 60, 75, 83, 84, 79, 71, 57};
            BarItem bar = pane.AddBar("Wheezy", x4, y4, Color.SteelBlue);
            // Fill the bars with a RosyBrown-White-RosyBrown gradient
            bar.Bar.Fill = new Fill(Color.RosyBrown, Color.White, Color.RosyBrown);

            // Fourth curve is a bar
            double[] x2 = {100, 200, 300, 400, 500, 600, 700, 800, 900, 1000};
            double[] y2 = {10, 15, 17, 20, 25, 27, 29, 26, 24, 18};
            bar = pane.AddBar("Curly", x2, y2, Color.RoyalBlue);
            // Fill the bars with a RoyalBlue-White-RoyalBlue gradient
            bar.Bar.Fill = new Fill(Color.RoyalBlue, Color.White, Color.RoyalBlue);

            // Fill the pane background with a gradient
            pane.Fill = new Fill(Color.WhiteSmoke, Color.Lavender, 0F);
            // Fill the axis background with a gradient
            pane.Chart.Fill = new Fill(Color.FromArgb(255, 255, 245),
                                       Color.FromArgb(255, 255, 190), 90F);

            // Make each cluster 100 user scale units wide.  This is needed because the X Axis
            // type is Linear rather than Text or Ordinal
            pane.BarSettings.ClusterScaleWidth = 100;
            // Bars are stacked
            pane.BarSettings.Type = BarType.Stack;

            // Enable the X and Y axis grids
            pane.XAxis.MajorGrid.IsVisible = true;
            pane.YAxis.MajorGrid.IsVisible = true;

            // Manually set the scale maximums according to user preference
            pane.XAxis.Scale.Max = 1200;
            pane.YAxis.Scale.Max = 120;

            // Add a text item to decorate the graph
            var text = new TextObj("First Prod\n21-Oct-93", 175F, 80.0F);
            // Align the text such that the Bottom-Center is at (175, 80) in user scale coordinates
            text.Location.AlignH = AlignH.Center;
            text.Location.AlignV = AlignV.Bottom;
            text.FontSpec.Fill = new Fill(Color.White, Color.PowderBlue, 45F);
            text.FontSpec.StringAlignment = StringAlignment.Near;
            pane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            var arrow = new ArrowObj(Color.Black, 12F, 175F, 77F, 100F, 45F);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            pane.GraphObjList.Add(arrow);

            // Add a another text item to to point out a graph feature
            text = new TextObj("Upgrade", 700F, 50.0F);
            // rotate the text 90 degrees
            text.FontSpec.Angle = 90;
            // Align the text such that the Right-Center is at (700, 50) in user scale coordinates
            text.Location.AlignH = AlignH.Right;
            text.Location.AlignV = AlignV.Center;
            // Disable the border and background fill options for the text
            text.FontSpec.Fill.IsVisible = false;
            text.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add(text);

            // Add an arrow pointer for the above text item
            arrow = new ArrowObj(Color.Black, 15, 700, 53, 700, 80);
            arrow.Location.CoordinateFrame = CoordType.AxisXYScale;
            arrow.Line.Width = 2.0F;
            pane.GraphObjList.Add(arrow);

            // Add a text "Confidential" stamp to the graph
            text = new TextObj("Confidential", 0.85F, -0.03F);
            // use ChartFraction coordinates so the text is placed relative to the ChartRect
            text.Location.CoordinateFrame = CoordType.ChartFraction;
            // rotate the text 15 degrees
            text.FontSpec.Angle = 15.0F;
            // Text will be red, bold, and 16 point
            text.FontSpec.FontColor = Color.Red;
            text.FontSpec.IsBold = true;
            text.FontSpec.Size = 16;
            // Disable the border and background fill options for the text
            text.FontSpec.Border.IsVisible = false;
            text.FontSpec.Fill.IsVisible = false;
            // Align the text such the the Left-Bottom corner is at the specified coordinates
            text.Location.AlignH = AlignH.Left;
            text.Location.AlignV = AlignV.Bottom;
            pane.GraphObjList.Add(text);

            // Add a BoxObj to show a colored band behind the graph data
            var box = new BoxObj(0, 110, 1200, 10,
                                 Color.Empty, Color.FromArgb(225, 245, 225));
            box.Location.CoordinateFrame = CoordType.AxisXYScale;
            // Align the left-top of the box to (0, 110)
            box.Location.AlignH = AlignH.Left;
            box.Location.AlignV = AlignV.Top;
            // place the box behind the axis items, so the grid is drawn on top of it
            box.ZOrder = ZOrder.D_BehindAxis;
            pane.GraphObjList.Add(box);

            // Add some text inside the above box to indicate "Peak Range"
            var myText = new TextObj("Peak Range", 1170, 105);
            myText.Location.CoordinateFrame = CoordType.AxisXYScale;
            myText.Location.AlignH = AlignH.Right;
            myText.Location.AlignV = AlignV.Center;
            myText.FontSpec.IsItalic = true;
            myText.FontSpec.IsBold = false;
            myText.FontSpec.Fill.IsVisible = false;
            myText.FontSpec.Border.IsVisible = false;
            pane.GraphObjList.Add(myText);

            pane.AxisChange(g);
        }