/// <summary> /// Draws the graph to the form /// </summary> /// <param name="o"></param> /// <param name="e"></param> public void PaintGraph(object o, PaintEventArgs e) { Graphics g = e.Graphics; // Create a new graph with topLeft at (40,40) and size 600x400 myPane = new ZedGraph.GraphPane(new Rectangle(this.Location.X, this.Location.Y + 210, 450, 325), "Allele Frequency\n", "Generations", "Frequency of A"); myPane.XAxis.Max = 100; //this.generation.Value; myPane.XAxis.Min = 0; myPane.YAxis.Max = 1; myPane.YAxis.Min = 0; ZedGraph.LineItem myCurve = myPane.AddCurve("1", list1, Color.Red, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve2 = myPane.AddCurve("2", list2, Color.Blue, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve3 = myPane.AddCurve("3", list3, Color.LimeGreen, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve4 = myPane.AddCurve("4", list4, Color.Black, ZedGraph.SymbolType.None); myPane.AxisChange(this.CreateGraphics()); myPane.Draw(e.Graphics); }
/* triple wave building codesnippet * * int length = (int)(SampleRate * BlockAlign * duration); * byte[] buffer = new byte[length]; * * double A = frequency * 2 * Math.PI / (double)SampleRate; * for (int i = 0; i < length; i++) * { * if (i > 1) buffer[i] = (byte)(2 * Math.Cos(A) * buffer[i - 1] - buffer[i - 2]); * else if (i > 0) buffer[i] = (byte)(2 * Math.Cos(A) * buffer[i - 1] - (Math.Cos(A))); * else buffer[i] = (byte)(2 * Math.Cos(A) * Math.Cos(A) - Math.Cos(2 * A)); * } * * public double CalculateGoertzel(byte[] sample, double frequency, int samplerate) * { * double Skn, Skn1, Skn2; * Skn = Skn1 = Skn2 = 0; * for (int i = 0; i < sample.Length; i++) * { * Skn2 = Skn1; * Skn1 = Skn; * Skn = 2 * Math.Cos(2 * Math.PI * frequency / samplerate) * Skn1 - Skn2 + sample[i]; * } * * double WNk = Math.Exp(-2 * Math.PI * frequency / samplerate); * * return 20 * Math.Log10(Math.Abs((Skn - WNk * Skn1))); * } * * public int TestGoertzel(int frequency, byte[] sample, int samplerate) * { * int stepsize = frequency / 5; * Dictionary<int, double> res = new Dictionary<int, double>(); * for (int i = 0; i < 10; i++) * { * int freq = stepsize * i; * res.Add(freq, CalculateGoertzel(sample, freq, samplerate)); * } * } */ private void BuildDiagram(ZedGraph.ZedGraphControl zg, byte[] _data) { ZedGraph.GraphPane myPane = zg.GraphPane; ZedGraph.LineItem curve = null; if (myPane.CurveList.Count >= 1) { curve = myPane.CurveList[0] as ZedGraph.LineItem; curve.Clear(); } else { curve = new ZedGraph.LineItem("SPS"); } // Make sure that the curvelist has at least one curve for (int i = 0; i < _data.Length; i++) { curve.AddPoint(i, _data[i]); } ZedGraph.IPointList list = curve.Points as ZedGraph.IPointList; if (myPane.CurveList.Count == 0) { myPane.AddCurve("Wave", list, Color.DimGray, ZedGraph.SymbolType.None); } zg.AxisChange(); zg.Invalidate(); }
public MainForm() { InitializeComponent(); pane = zedGraphControl1.GraphPane; pane.Title.Text = "Kaggle (RMSE)"; pane.XAxis.Title.Text = "Iterations"; pane.YAxis.Title.Text = "RMSE"; zedTrain = new ZedGraph.PointPairList(); zedTest = new ZedGraph.PointPairList(); pane.AddCurve("train", zedTrain, Color.Green); pane.AddCurve("test", zedTest, Color.Red); }
public MainForm() { InitializeComponent(); pane = zedGraphControl1.GraphPane; pane.Title.Text = "Kaggle (RMSE)"; pane.XAxis.Title.Text = "Iterations"; pane.YAxis.Title.Text = "RMSE"; zedTrain = new ZedGraph.PointPairList(); zedTest = new ZedGraph.PointPairList(); pane.AddCurve("train", zedTrain, Color.Green); pane.AddCurve("test", zedTest, Color.Red); }
void Draw(ref ZedGraph.PointPairList f_list, double xmax = 1.0) // построение графиков { if (countCurves == 15) { graph.GraphPane.CurveList.Clear(); countCurves = 0; } string name; if (countCurves % 2 == 0) { name = "exact" + (countCurves / 2).ToString(); } else { name = "num" + (countCurves / 2).ToString(); } ZedGraph.GraphPane panel = graph.GraphPane; ZedGraph.LineItem Curve = panel.AddCurve(name, f_list, colors[countCurves], ZedGraph.SymbolType.None); if (countCurves == 0) { panel.XAxis.Min = -0.1; panel.XAxis.Max = xmax + 0.1; panel.YAxis.Min = -1; } countCurves++; graph.AxisChange(); graph.Invalidate(); }
private void график3ToolStripMenuItem_Click(object sender, EventArgs e) { ZedGraph.GraphPane graphPane = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs = new ZedGraph.PointPairList(); graphPane.CurveList.Clear(); graphPane.Title.Text = "График 3"; for (double x = 0; x <= 1; x += 0.01) { if (x >= 0 && x < 0.07) { pointPairs.Add(x, 0.95); } else if (x >= 0.07 && x < 0.13) { pointPairs.Add(x, -30 * Math.Pow(x - 0.068, 2) + 0.95); } else if (x >= 0.13 && x <= 1) { pointPairs.Add(x, 2 / (100 * x - 10) + 0.05); } else { MessageBox.Show($"Missing {x}"); } } ZedGraph.LineItem lineItemResult = graphPane.AddCurve("График 3", pointPairs, Color.Red, ZedGraph.SymbolType.None); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
void Draw(ref ZedGraph.PointPairList f_list, string name, Color clr, double xmax = 1.0) // построение графиков { ZedGraph.GraphPane panel = zedGraph.GraphPane; ZedGraph.LineItem Curve = panel.AddCurve(name, f_list, clr, ZedGraph.SymbolType.None); panel.XAxis.Min = -0.1; panel.XAxis.Max = xmax + 0.1; panel.YAxis.Min = -1; zedGraph.AxisChange(); zedGraph.Invalidate(); }
private void BuildSubPerDateGraph() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsShowPointValues = true; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.MintCream, Color.FromArgb(245, 250, 210), -90); pane.Chart.Fill = new ZedGraph.Fill(Color.Snow, Color.FromArgb(245, 250, 230), 90); pane.Title.Text = "Submission and Accepted over Time"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Navy; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.FontSpec.Size = 12; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; pane.XAxis.Title.Text = "Date-Time"; pane.XAxis.Title.FontSpec.Family = "Courier New"; pane.XAxis.Title.FontSpec.FontColor = Color.Maroon; pane.XAxis.Title.FontSpec.IsBold = false; pane.XAxis.Type = ZedGraph.AxisType.Date; pane.YAxis.Title.Text = "Submissions"; pane.YAxis.Title.FontSpec.Family = "Courier New"; pane.YAxis.Title.FontSpec.FontColor = Color.Navy; pane.YAxis.Title.FontSpec.IsBold = false; // Generate a red curve var a = pane.AddCurve("Submissions / Time", _subOverTime, Color.DarkGoldenrod, ZedGraph.SymbolType.VDash); var b = pane.AddCurve("Accepted / Time", _acOverTime, Color.Navy, ZedGraph.SymbolType.VDash); a.Symbol.Size = 2; b.Symbol.Size = 2; pane.AxisChange(); this.subPerDateTab.Controls.Clear(); this.subPerDateTab.Controls.Add(zg1); }
void updateGraph(Item useritem) { var sitems = mvv.Glassmodels.Where(o => o.Name.ToLower().StartsWith(useritem.Name.ToLower())); sitems.ForEach(o => { o.MBE = (useritem.Ottv - o.Ottv) / useritem.Ottv; }); mvv.ImgSource = null; var ch = new ZedGraph.GraphPane(); // zedGraphControl1.GraphPane; ch.Title.Text = $"OTTV Analysis"; ch.XAxis.Title.Text = "Glass Types Proposal"; ch.YAxis.Title.Text = "MBE impact"; ch.Y2Axis.IsVisible = false; ch.X2Axis.IsVisible = false; ch.XAxis.Scale.MinAuto = false; ch.XAxis.Scale.Max = sitems.Count() + 1; ch.XAxis.Scale.MajorStepAuto = false; ch.XAxis.Scale.MajorStep = 1; ch.XAxis.Scale.Min = 0; ch.XAxis.Scale.MinorStepAuto = false; ch.XAxis.Scale.MinorStep = 0.1; ch.XAxis.MinorTic.Size = 0; ch.XAxis.MajorTic.Size = 0; ch.YAxis.Scale.Format = "00.00"; ch.YAxis.MinorTic.Size = 0; ch.YAxis.MajorGrid.Color = System.Drawing.Color.DimGray; ch.YAxis.MajorGrid.PenWidth = 1; ch.YAxis.MajorGrid.DashOn = 6; ch.YAxis.MajorGrid.IsVisible = true; var bar = ch.AddCurve("MBE Value", null, sitems.Select(o => o.MBE).Cast <double>().ToArray(), System.Drawing.Color.DarkBlue); //bar.c.Fill.Type = ZedGraph.FillType.Solid; bar.Line.Width = 5f; bar.Line.IsSmooth = false; ch.XAxis.Scale.TextLabels = sitems.Select(o => o.Name).ToArray(); ch.XAxis.Type = ZedGraph.AxisType.Text; ch.XAxis.Scale.FontSpec.Angle = 90; ch.AxisChange(); mvv.ImgSource = Utility.IO.ImageIO.ConvertFromImage(ch.GetImage((int)Width, (int)Height, 150, true)); }
private void testToolStripMenuItem_Click(object sender, EventArgs e) { ZedGraph.GraphPane graphPane1 = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs = new ZedGraph.PointPairList(); pointPairs.Add(0.5, 0); pointPairs.Add(0.5, Function1(0.5)); pointPairs.Add(0, Function1(0.5)); ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve("Альтернатива 1", pointPairs, Color.Blue, ZedGraph.SymbolType.None); zedGraphControl1.Invalidate(); }
private void SaveFromConsoleApplication() { // simulate plotting from a console application var pane = new ZedGraph.GraphPane(); var curve1 = pane.AddCurve( label: "demo", x: new double[] { 1, 2, 3, 4, 5 }, y: new double[] { 1, 4, 9, 16, 25 }, color: Color.Blue); curve1.Line.IsAntiAlias = true; pane.AxisChange(); Bitmap bmp = pane.GetImage(400, 300, dpi: 100, isAntiAlias: true); bmp.Save("zedgraph-console-quickstart.png", ImageFormat.Png); }
private void button1_Click(object sender, EventArgs e) { double x0 = Double.Parse(textBox1.Text);//Начальное значение x double y0 = Double.Parse(textBox2.Text);//конечное значение x int n = Int32.Parse(textBox3.Text);//количество шагов //double _h = Double.Parse(textBox4.Text); double k1, k2, k3, k4, l1, l2, l3, l4, _h = 0.02, y1, y2, x1, x2; zedGraphControl1.MasterPane.PaneList.Clear(); ZedGraph.GraphPane pane = new ZedGraph.GraphPane(); pane.CurveList.Clear(); ZedGraph.PointPairList list = new ZedGraph.PointPairList(); do { y0 = y0 + _h; k1 = _h * fvx(y0, x0); l1 = _h * fvy(y0, x0); k2 = _h * fvx(y0 + l1 / 2, x0 + k1 / 2); l2 = _h * fvy(y0 + l1 / 2, x0 + k1 / 2); x1 = x0 + (k1 + k2) / 2; y1 = y0 + (l1 + l2) / 2; x0 = x1; y0 = y1; listBox1.Items.Add(x1); listBox1.Items.Add(y1); list.Add(x1, y1); //i++; //printf("\n %lf", x1); //printf("\n %lf", y1); } while (y0 > 0.02); // ((y0 > -0.00001));//(x1 <= n); ZedGraph.LineItem MyCurve = pane.AddCurve("func", list, Color.Blue); zedGraphControl1.MasterPane.Add(pane); using (Graphics g = CreateGraphics()) { zedGraphControl1.MasterPane.SetLayout(g, ZedGraph.PaneLayout.ExplicitCol12); } zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
private void button1_Click(object sender, EventArgs e) { double x0 = Double.Parse(textBox1.Text); //Начальное значение x double y0 = Double.Parse(textBox2.Text); //конечное значение x int n = Int32.Parse(textBox3.Text); //количество шагов //double _h = Double.Parse(textBox4.Text); double k1, k2, k3, k4, l1, l2, l3, l4, _h = 0.02, y1, y2, x1, x2; zedGraphControl1.MasterPane.PaneList.Clear(); ZedGraph.GraphPane pane = new ZedGraph.GraphPane(); pane.CurveList.Clear(); ZedGraph.PointPairList list = new ZedGraph.PointPairList(); do { y0 = y0 + _h; k1 = _h * fvx(y0, x0); l1 = _h * fvy(y0, x0); k2 = _h * fvx(y0 + l1 / 2, x0 + k1 / 2); l2 = _h * fvy(y0 + l1 / 2, x0 + k1 / 2); x1 = x0 + (k1 + k2) / 2; y1 = y0 + (l1 + l2) / 2; x0 = x1; y0 = y1; listBox1.Items.Add(x1); listBox1.Items.Add(y1); list.Add(x1, y1); //i++; //printf("\n %lf", x1); //printf("\n %lf", y1); }while (y0 > 0.02); // ((y0 > -0.00001));//(x1 <= n); ZedGraph.LineItem MyCurve = pane.AddCurve("func", list, Color.Blue); zedGraphControl1.MasterPane.Add(pane); using (Graphics g = CreateGraphics()) { zedGraphControl1.MasterPane.SetLayout(g, ZedGraph.PaneLayout.ExplicitCol12); } zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
private void BuildRankCloud() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsShowPointValues = true; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.Azure, Color.FromArgb(230, 220, 250), 90); pane.Chart.Fill = new ZedGraph.Fill(Color.FromArgb(225, 220, 245), Color.LightCyan, -90); pane.Title.Text = "Rank Cloud"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Maroon; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.IsVisible = false; pane.XAxis.Title.Text = "Ranks"; pane.XAxis.Title.FontSpec.Family = "Courier New"; pane.XAxis.Title.FontSpec.FontColor = Color.Maroon; pane.XAxis.Title.FontSpec.IsBold = false; pane.YAxis.Title.Text = "Problems"; pane.YAxis.Title.FontSpec.Family = "Courier New"; pane.YAxis.Title.FontSpec.FontColor = Color.Navy; pane.YAxis.Title.FontSpec.IsBold = false; pane.YAxis.Type = ZedGraph.AxisType.Linear; ZedGraph.LineItem curve = pane.AddCurve("Ranks", _RankCount, Color.Black, ZedGraph.SymbolType.Circle); curve.Symbol.Fill = new ZedGraph.Fill(Color.LightCyan, Color.DarkTurquoise); curve.Symbol.Border.IsVisible = true; curve.Symbol.Size = 5; curve.Line.IsVisible = false; pane.AxisChange(); this.rankCloudTab.Controls.Clear(); this.rankCloudTab.Controls.Add(zg1); }
private void calculation() { if (_Station == null || Sensor == null) { zedGraphControl1.GraphPane.CurveList.Clear(); zedGraphControl2.GraphPane.CurveList.Clear(); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); if (_Station == null) { userControl_RingLaserOrientation1.SiteLocation = null; } if (Sensor == null) { userControl_RingLaserOrientation1.NormalVector = null; } return; } myPane1.CurveList.Clear(); myPane2.CurveList.Clear(); richTextBox1.Clear(); richTextBox1.Text = "Location : " + StationName + Environment.NewLine; richTextBox1.Text += " Longitude [°] : " + _Station.Location.Longitude.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine; richTextBox1.Text += " Latitude [°] : " + _Station.Location.Latitude.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine + Environment.NewLine; richTextBox1.Text += "Instrument : " + Sensor.Name + Environment.NewLine; richTextBox1.Text += " Azimuth [°]: " + Sensor.Azimut.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine; richTextBox1.Text += " Dip [°]: " + Sensor.Dip.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine; richTextBox1.Text += " Side length [m]: " + Sensor.RingLaser.SideLength.ToString("0.000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine; richTextBox1.Text += " Shape : " + Sensor.RingLaser.Shape.ToString() + Environment.NewLine; richTextBox1.Text += " Lambda [Hz]: " + Sensor.RingLaser.Lambda.ToString("0.0000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine + Environment.NewLine; richTextBox1.Text += "Calculations :" + Environment.NewLine; // ------------------------------------------------------------------------------------------------- RingLaserPrediction rlg = new RingLaserPrediction() { SiteLocation = new RingLaserPrediction.Location(_Station.Name, _Station.Location.Longitude, _Station.Location.Latitude, _Station.Location.Height), SideLength = Sensor.RingLaser.SideLength, Lambda = (Sensor.RingLaser.Lambda * 1e-9), }; userControl_RingLaserOrientation1.NormalVector = new UserControl_RingLaserOrientation.Vector_AzimuthDip(Sensor.Azimut, Sensor.Dip); if (radioButtonTriangular.Checked) { rlg.ScaleFactor = rlg.ScaleFactorTriangle(); } else if (radioButtonSquared.Checked) { rlg.ScaleFactor = rlg.ScaleFactorSquare(); } richTextBox1.Text += " Scale factor : " + rlg.ScaleFactor.ToString("0.000000", PreAnalyseExtended.Constants.NumberFormatEN) + Environment.NewLine; /* ************************************************************ * **** Test calculation / validation for "G" ***************** * Steps: * 1. Definition of the orientation in local Coordinate System. * x = to South direction * y = to East direction * z = opposite to g-vector, parallel to Earth radius * Loop over the azimuth: * 2. Transformation from sperical to cartesian coordinates. * 3. Rotation of the local coordinate system around z-axis * (vertical-axis) adjusting the local orientation against * North. * 4. Rotation of the local coordinate system around y-axis * with the co-latutude of the location into the global * system. * 5. Rotation of the glogal system to the right latitude of * the location. * 6. Calculation of the nominal Sagnac-frequency of the * triangular ring, using the given parameter. * ************************************************************/ // Definition of the orientation of "G" within the local coordinate system, normal vector parallel to z-axis RingLaserPrediction.Coordinate_Sperical RL_LocalOrientationSperical = new RingLaserPrediction.Coordinate_Sperical() { R = 1, Theta = RingLaserPrediction.RAD(90.0 - Sensor.Dip), Phi = RingLaserPrediction.RAD(Sensor.Azimut + 180.0), }; // Conversion from sperical to cartesien coordinates RingLaserPrediction.Coordinate_Cartesian RL_LocalOrientationCartesien = rlg.CoordinateTransformation_SphericalToCartesion(RL_LocalOrientationSperical); if (checkBoxRotateAroundVertical.Checked && checkBoxRotateAroundVertical.Enabled) { string tmp = Environment.NewLine; tmp += " Lobal orientation" + Environment.NewLine; tmp += " of normal " + Environment.NewLine; tmp += "Alpha Latitude Longitude Sagnac-frequency" + Environment.NewLine; tmp += " [°] [°] [°] [Hz]" + Environment.NewLine; ZedGraph.PointPairList calcsSagnac = new ZedGraph.PointPairList(); ZedGraph.PointPairList calcsCoords = new ZedGraph.PointPairList(); for (double alpha = 0; alpha < 360.0; alpha++) { // Locale Rotation arround the vertical for azimuth of rings RingLaserPrediction.Coordinate_Cartesian RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_LocalOrientationCartesien, RingLaserPrediction.RAD(alpha), RingLaserPrediction.RotationAround.Z); // Rotation around co-latitude RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(90.0 - rlg.SiteLocation.Latitude), RingLaserPrediction.RotationAround.Y); // Rotation around longitude - Not nesseccary, but well for proofing RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(-rlg.SiteLocation.Longitude), RingLaserPrediction.RotationAround.Z); // Conversion from cartesien to sperical coordinates RingLaserPrediction.Coordinate_Sperical RL_GlobalOrientationSperical = rlg.CoordinateTransformation_CartesionToSpherical(RL_GlobalOrientationCartesien); // Calculation of Sagnac-frequency of "G": 'Scale factor' * 'Earth rotation' * Cos('co-latitude of normal vector within the global coordinate system') double Sagnac = (rlg.ScaleFactor * RingLaserPrediction.EarthRotationIERS * Math.Abs(Math.Cos(RingLaserPrediction.RAD(90.0) - RL_GlobalOrientationSperical.Theta))); // Output tmp += String.Format(PreAnalyseExtended.Constants.NumberFormatEN, "{0,5:0} {1,10:0.0000} {2,10:0.0000} {3,17:0.000}" + Environment.NewLine, alpha, RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi), RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta), Sagnac); calcsSagnac.Add(alpha, Sagnac); calcsCoords.Add(RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi), RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta)); } ZedGraph.LineItem myCurve1 = myPane1.AddCurve(null, calcsSagnac, Color.Red, ZedGraph.SymbolType.None); ZedGraph.LineItem myCurve2 = myPane2.AddCurve("Coordinate path of normal vector", calcsCoords, Color.Red, ZedGraph.SymbolType.Diamond); myCurve2.Line.IsVisible = false; calcsCoords = new ZedGraph.PointPairList(); if (rlg.SiteLocation.Longitude > 0) { calcsCoords.Add(rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude); } else { calcsCoords.Add(360 + rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude); } myCurve2 = myPane2.AddCurve("Site location", calcsCoords, Color.Blue, ZedGraph.SymbolType.XCross); myCurve2.Line.IsVisible = false; richTextBox1.Text += tmp; } else { // Rotation around co-latitude RingLaserPrediction.Coordinate_Cartesian RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_LocalOrientationCartesien, RingLaserPrediction.RAD(90.0 - rlg.SiteLocation.Latitude), RingLaserPrediction.RotationAround.Y); // Rotation around longitude - Not nesseccary, but well for proofing RL_GlobalOrientationCartesien = rlg.CoordinateRotation(RL_GlobalOrientationCartesien, RingLaserPrediction.RAD(-rlg.SiteLocation.Longitude), RingLaserPrediction.RotationAround.Z); // Conversion from cartesien to sperical coordinates RingLaserPrediction.Coordinate_Sperical RL_GlobalOrientationSperical = rlg.CoordinateTransformation_CartesionToSpherical(RL_GlobalOrientationCartesien); // Calculation of Sagnac-frewquency of "G": 'Scale factor' * 'Earth rotation' * Cos('co-latitude of normal vector within the global coordinate system') double Sagnac = (rlg.ScaleFactor * RingLaserPrediction.EarthRotationIERS * Math.Abs(Math.Cos(RingLaserPrediction.RAD(90.0) - RL_GlobalOrientationSperical.Theta))); // Output richTextBox1.Text += String.Format(PreAnalyseExtended.Constants.NumberFormatEN, " Global orientation of ring laser normal: " + Environment.NewLine + " Longitude: {1,7:0.0000}" + Environment.NewLine + " Latitude : {0,7:0.0000}" + Environment.NewLine, RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Theta), RingLaserPrediction.DEG(RL_GlobalOrientationSperical.Phi)); richTextBox1.Text += String.Format(PreAnalyseExtended.Constants.NumberFormatEN, "Nominal Sagnac-frequency [Hz]: {0,10:0.000}", Sagnac) + Environment.NewLine; ZedGraph.LineItem myCurve2 = myPane2.AddCurve("Coordinate path of normal vector", null, Color.Red, ZedGraph.SymbolType.Diamond); myCurve2.Line.IsVisible = false; ZedGraph.PointPairList calcsCoords = new ZedGraph.PointPairList(); if (rlg.SiteLocation.Longitude > 0) { calcsCoords.Add(rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude); } else { calcsCoords.Add(360 + rlg.SiteLocation.Longitude, rlg.SiteLocation.Latitude); } myCurve2 = myPane2.AddCurve("Site location", calcsCoords, Color.Blue, ZedGraph.SymbolType.XCross); myCurve2.Line.IsVisible = false; } // Calculate the Axis Scale Ranges zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); }
public void DrawGraphs() { ZedGraph.GraphPane graphPane1 = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs1 = new ZedGraph.PointPairList(); graphPane1.CurveList.Clear(); graphPane1.Title.Text = "График 1"; for (double x = 0; x <= 1; x += 0.01) { pointPairs1.Add(x, Function1(x)); } ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve("График 1", pointPairs1, Color.Red, ZedGraph.SymbolType.None); graphPane1.XAxis.Scale.Min = 0; graphPane1.XAxis.Scale.Max = 1; graphPane1.YAxis.Scale.Min = 0; graphPane1.YAxis.Scale.Max = 1; zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); ZedGraph.GraphPane graphPane2 = zedGraphControl2.GraphPane; ZedGraph.PointPairList pointPairs2 = new ZedGraph.PointPairList(); graphPane2.CurveList.Clear(); graphPane2.Title.Text = "График 2"; for (double x = 0; x <= 1; x += 0.01) { pointPairs2.Add(x, Function2(x)); } ZedGraph.LineItem lineItemResult2 = graphPane2.AddCurve("График 2", pointPairs2, Color.Red, ZedGraph.SymbolType.None); graphPane2.XAxis.Scale.Min = 0; graphPane2.XAxis.Scale.Max = 1; graphPane2.YAxis.Scale.Min = 0; graphPane2.YAxis.Scale.Max = 1; zedGraphControl2.AxisChange(); zedGraphControl2.Invalidate(); ZedGraph.GraphPane graphPane3 = zedGraphControl3.GraphPane; ZedGraph.PointPairList pointPairs3 = new ZedGraph.PointPairList(); graphPane3.CurveList.Clear(); graphPane3.Title.Text = "График 3"; for (double x = 0; x <= 1; x += 0.01) { pointPairs3.Add(x, Function3(x)); } ZedGraph.LineItem lineItemResult3 = graphPane3.AddCurve("График 3", pointPairs3, Color.Red, ZedGraph.SymbolType.None); graphPane3.XAxis.Scale.Min = 0; graphPane3.XAxis.Scale.Max = 1; graphPane3.YAxis.Scale.Min = 0; graphPane3.YAxis.Scale.Max = 1; zedGraphControl3.AxisChange(); zedGraphControl3.Invalidate(); }
private void LoadGraph() { if (lineProductionDatas.Count <= 0) { MessageBox.Show("Unable to load data from server.", "Line efficiency daily graph", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var bufferList = new List <ArticleProductionData>(); var pane = new ZedGraph.GraphPane(); pane.Title.Text = "EFF con " + Line + " (" + Department + ")"; pane.YAxis.Title.Text = "EFF %"; pane.XAxis.Title.Text = Month.ToString() + "/" + Year.ToString(); pane.XAxis.MajorTic.IsAllTics = true; pane.XAxis.Scale.MajorStep = 1; pane.XAxis.Scale.Min = 1; pane.XAxis.Scale.Max = 31; pane.Fill = new ZedGraph.Fill(Brushes.WhiteSmoke); ZedGraph.PointPairList list = new ZedGraph.PointPairList(); foreach (var lineProduction in lineProductionDatas) { var workEff = Math.Round((lineProduction.Qty / lineProduction.Producibili) * 100.0, 1); list.Add(lineProduction.Datex.Day, workEff); } pane.GraphObjList.Clear(); zedGraph.GraphPane.CurveList.Clear(); var curve = new ZedGraph.LineItem("EFF %", list, Color.SteelBlue, ZedGraph.SymbolType.Circle); curve.Line.IsVisible = true; curve.Symbol.Fill.Color = Color.SteelBlue; curve.Symbol.Fill.Type = ZedGraph.FillType.Solid; curve.Symbol.Size = 10; curve.Line.Width = 4; curve.Symbol.IsAntiAlias = true; curve.Line.IsSmooth = false; curve.Line.IsAntiAlias = true; curve.Line.Fill = new ZedGraph.Fill(Color.White, Color.LightSkyBlue, -45F); curve.Symbol.Size = 8.0F; curve.Symbol.Fill = new ZedGraph.Fill(Color.White); curve.Line.Width = 2.0F; pane.XAxis.MajorTic.IsBetweenLabels = true; pane.Chart.Fill = new ZedGraph.Fill(Color.White, Color.FromArgb(250, 250, 250), 90F); pane.Fill = new ZedGraph.Fill(Color.FromArgb(250, 250, 250)); zedGraph.GraphPane = pane; pane.Legend.IsVisible = false; ZedGraph.PointPairList articleRangeList = new ZedGraph.PointPairList(); ZedGraph.LineItem articleVertCurve = new ZedGraph.LineItem(""); for (var i = 0; i <= curve.Points.Count - 1; i++) { ZedGraph.PointPair pt = curve.Points[i]; ZedGraph.TextObj text = new ZedGraph.TextObj(pt.Y.ToString("f1"), pt.X, pt.Y, ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center); text.ZOrder = ZedGraph.ZOrder.D_BehindAxis; text.FontSpec.Border.IsVisible = false; text.FontSpec.Fill.IsVisible = false; text.FontSpec.Angle = 90; pane.GraphObjList.Add(text); var art = articleProductions.LastOrDefault(x => x.Day == pt.X); var buf = bufferList.FirstOrDefault(x => x.Article == art.Article || x.Day == art.Day); if (art != null && buf == null) { bufferList.Add(art); ZedGraph.TextObj textArt = new ZedGraph.TextObj(art.Article, pt.X + 0.2f, pane.YAxis.Scale.Min + pt.Y / 2, ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center); textArt.ZOrder = ZedGraph.ZOrder.D_BehindAxis; textArt.FontSpec.Border.IsVisible = false; textArt.FontSpec.Fill.IsVisible = false; textArt.FontSpec.Size = 9; textArt.FontSpec.FontColor = Color.Black; var lastArt = articleProductions.LastOrDefault(x => x.Day == pt.X - 1); var nextArt = articleProductions.FirstOrDefault(x => x.Day == pt.X + 2); if (lastArt != null && lastArt.Article != art.Article || nextArt != null && nextArt.Article != art.Article) { textArt.FontSpec.Angle = 90; } else { textArt.FontSpec.Angle = 0; } pane.GraphObjList.Add(textArt); articleRangeList = new ZedGraph.PointPairList(); articleRangeList.Add(pt.X, pt.Y); articleRangeList.Add(pt.X, pane.YAxis.Scale.Min); var ac = new ZedGraph.LineItem(art.Article); ac.Line.Style = System.Drawing.Drawing2D.DashStyle.Dot; ac = pane.AddCurve(art.Article, articleRangeList, Color.Orange, ZedGraph.SymbolType.None); } } zedGraph.GraphPane.CurveList.Add(curve); zedGraph.AxisChange(); zedGraph.Refresh(); zedGraph.IsShowPointValues = true; zedGraph.PointValueFormat = "0"; zedGraph.Invalidate(); }
public void Calculate(string str) { Random random = new Random(); //----------------------------------------ЗАПОЛНЕНИЕ МАТРИЦ #region ЗАПОЛНЕНИЕ МАТРИЦ KritAlts = new List <double[, ]>(); if (str == "example") { KritAlts.Add(new double[, ] { { 1, 3, 2 }, { 0.33, 1, 0.33 }, { 0.5, 3, 1 } }); KritAlts.Add(new double[, ] { { 1, 0.25, 6 }, { 4, 1, 5 }, { 0.16, 0.2, 1 } }); KritAlts.Add(new double[, ] { { 1, 0.33, 2 }, { 3, 1, 5 }, { 0.5, 0.2, 1 } }); KritCompares = new double[, ] { { 1, 2, 3 }, { 0.5, 1, 4 }, { 0.33, 0.25, 1 } }; } else { double[,] krits = new double[AltsCount, AltsCount]; for (int count = 0; count < AltsCount; count++) { krits = new double[AltsCount, AltsCount]; for (int i = 0; i < AltsCount; i++) { for (int j = 0; j < AltsCount; j++) { if (i == j) { krits[i, j] = 1; } else if (i < j) { int ch = random.Next(2); if (ch == 0) { krits[i, j] = random.Next(1, 6); } else { krits[i, j] = random.NextDouble(); } } else { krits[i, j] = 1 / krits[j, i]; } } } KritAlts.Add(krits); } KritCompares = new double[KritsCount, KritsCount]; for (int i = 0; i < KritsCount; i++) { for (int j = 0; j < KritsCount; j++) { if (i == j) { KritCompares[i, j] = 1; } else if (i < j) { int ch = random.Next(2); if (ch == 0) { KritCompares[i, j] = random.Next(1, 6); } else { KritCompares[i, j] = random.NextDouble(); } } else { KritCompares[i, j] = 1 / KritCompares[j, i]; } } } } #region Вывод матриц foreach (double[,] d in KritAlts) { string strn = "Сравнение алтернатив по критериям\r\n"; for (int i = 0; i < d.GetLength(0); i++) { for (int j = 0; j < d.GetLength(1); j++) { strn += $"{d[i, j]:0.00}\t"; } strn += "\r\n"; } MessageBox.Show(strn); } string strnK = "Сравнение критериев\r\n"; for (int i = 0; i < KritCompares.GetLength(0); i++) { for (int j = 0; j < KritCompares.GetLength(1); j++) { strnK += $"{KritCompares[i, j]:0.00}\t"; } strnK += "\r\n"; } MessageBox.Show(strnK); #endregion #endregion //---------------------------------РАСЧЁТ МАТРИЦ #region АСЧЁТ МАТРИЦ KritNormals = new List <double[]>(); foreach (double[,] d in KritAlts) { double Sum = 0; double[] sums = new double[d.GetLength(0)]; for (int i = 0; i < d.GetLength(0); i++) { double rowSum = 0; for (int j = 0; j < d.GetLength(1); j++) { rowSum += d[i, j]; } sums[i] = rowSum; Sum += rowSum; } for (int i = 0; i < sums.Length; i++) { sums[i] /= Sum; } KritNormals.Add(sums); #region Вывод нормированных критериев string ts1 = $"Общая сумма: {Sum:0.00}\r\n"; foreach (double db in sums) { ts1 += $"{db:0.00}\t"; } MessageBox.Show(ts1); #endregion } double sumsWeights = 0; KritWeigths = new double[KritsCount]; for (int i = 0; i < KritCompares.GetLength(0); i++) { double Sum = 0; for (int j = 0; j < KritCompares.GetLength(1); j++) { Sum += KritCompares[i, j]; } KritWeigths[i] = Sum; sumsWeights += Sum; } for (int i = 0; i < KritWeigths.Length; i++) { KritWeigths[i] /= sumsWeights; } #region Вывод весов string ts2 = $"Веса критериев, общая сумма: {sumsWeights:0.00}\r\n"; foreach (double d in KritWeigths) { ts2 += $"{d:0.00}\t"; } MessageBox.Show(ts2); #endregion #endregion //----------------------------------РАСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ И ЦЕН #region АСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ И ЦЕН Functions = new double[AltsCount]; MessageBox.Show("РАСЧЁТ ФУНКЦИЙ ПОЛЕЗНОСТИ"); for (int i = 0; i < AltsCount; i++) { double sum = 0; for (int normals = 0; normals < KritNormals.Count; normals++) { double res = KritNormals[normals][i] * KritWeigths[normals]; sum += res; MessageBox.Show($"RES: {res:0.00}; FIRST: {KritNormals[normals][i]:0.00}; SECOND: {KritWeigths[normals]:0.00}"); } Functions[i] = sum; MessageBox.Show($"Альтернатива {i + 1} : {sum:0.000}"); } if (str == "example") { Prices = new int[] { 10000, 15000, 8000 }; } else { Prices = new int[AltsCount]; for (int i = 0; i < AltsCount; i++) { Prices[i] = random.Next(5000, 20000); } } #region Вывод цен string ts3 = "Цены\r\n"; foreach (int i in Prices) { ts3 += $"{i}\t"; } ts3 += $"\r\nОбщая сумма: {Prices.Sum():0.00}"; MessageBox.Show(ts3); #endregion #endregion PricesNorm = new double[AltsCount]; for (int i = 0; i < AltsCount; i++) { double PricesSum = Prices.Sum(); double pr = Prices[i]; PricesNorm[i] = pr / PricesSum; MessageBox.Show($"Нормаль цены {i + 1} : {PricesNorm[i]:0.000}"); } Alters = new List <Alternatives>(); risks = new List <Risks>(); for (int i = 0; i < AltsCount; i++) { double cmpr = Functions[i] / PricesNorm[i]; Alters.Add(new Alternatives() { Compare = cmpr, Name = $"Альтернатива {i + 1}" }); double rk = Function1(PricesNorm[i]) + Function2(PricesNorm[i]) + Function3(PricesNorm[i]); risks.Add(new Risks() { Compare = rk, Name = $"Альтернатива {i + 1}" }); ZedGraph.GraphPane graphPane1 = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs = new ZedGraph.PointPairList(); pointPairs.Add(PricesNorm[i], 0); pointPairs.Add(PricesNorm[i], Function1(PricesNorm[i])); pointPairs.Add(0, Function1(PricesNorm[i])); ZedGraph.LineItem lineItemResult1 = graphPane1.AddCurve($"Альтернатива {i + 1}", pointPairs, Color.Blue, ZedGraph.SymbolType.None); zedGraphControl1.Invalidate(); ZedGraph.GraphPane graphPane2 = zedGraphControl2.GraphPane; ZedGraph.PointPairList pointPairs2 = new ZedGraph.PointPairList(); pointPairs2.Add(PricesNorm[i], 0); pointPairs2.Add(PricesNorm[i], Function2(PricesNorm[i])); pointPairs2.Add(0, Function2(PricesNorm[i])); ZedGraph.LineItem lineItemResult2 = graphPane2.AddCurve($"Альтернатива {i + 1}", pointPairs2, Color.Green, ZedGraph.SymbolType.None); zedGraphControl2.Invalidate(); ZedGraph.GraphPane graphPane3 = zedGraphControl3.GraphPane; ZedGraph.PointPairList pointPairs3 = new ZedGraph.PointPairList(); pointPairs3.Add(PricesNorm[i], 0); pointPairs3.Add(PricesNorm[i], Function3(PricesNorm[i])); pointPairs3.Add(0, Function3(PricesNorm[i])); ZedGraph.LineItem lineItemResult3 = graphPane3.AddCurve($"Альтернатива {i + 1}", pointPairs3, Color.Purple, ZedGraph.SymbolType.None); zedGraphControl3.Invalidate(); } Alters.Sort(delegate(Alternatives a1, Alternatives a2) { if (a1.Compare > a2.Compare) { return(-1); } else if (a1.Compare < a2.Compare) { return(1); } else { return(0); } }); risks.Sort(delegate(Risks a1, Risks a2) { if (a1.Compare > a2.Compare) { return(-1); } else if (a1.Compare < a2.Compare) { return(1); } else { return(0); } }); string answer = "Ответ:\r\n"; foreach (Alternatives al in Alters) { answer += al.ToString() + "\r\n"; } answer += "\r\n"; foreach (Risks r in risks) { answer += r.ToString() + "\r\n"; } MessageBox.Show(answer); }
private void ПосчитатьсвоиТочкиToolStripMenuItem_Click(object sender, EventArgs e) { CountPoints countPoints = new CountPoints(); countPoints.ShowDialog(); if (countPoints.Ready) { ZedGraph.GraphPane graphPaneStart = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairsStart = new ZedGraph.PointPairList(); graphPaneStart.CurveList.Clear(); graphPaneStart.Title.Text = "Заданные значениия"; double xSum = 0d; double ySum = 0d; double xySum = 0d; double xSqSum = 0d; for (int i = 0; i < countPoints.Count; i++) { AddingPoint addingPoint = new AddingPoint(); addingPoint.ShowDialog(); if (addingPoint.Drop) { MessageBox.Show("Ввод данных прерван!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (addingPoint.Ready) { double x = addingPoint.X; double y = addingPoint.Y; pointPairsStart.Add(x, y); xSum += x; ySum += y; xySum += x * y; xSqSum += x * x; if (first) { first = false; min = max = x; minY = maxY = y; } else { if (x < min) { min = x; } if (x > max) { max = x; } if (y < minY) { minY = y; } if (y > maxY) { maxY = y; } } } } double a = (pointPairsStart.Count * xySum - xSum * ySum) / (pointPairsStart.Count * xSqSum - xSum * xSum); double b = (ySum - a * xSum) / pointPairsStart.Count; koefaTB.Text = a.ToString("0.0######"); koefbTB.Text = b.ToString("0.0#"); ZedGraph.GraphPane graphPaneResult = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairsResult = new ZedGraph.PointPairList(); graphPaneResult.XAxis.Scale.Min = min; graphPaneResult.XAxis.Scale.Max = max; if (min > 0) { min = 0; graphPaneResult.XAxis.Scale.Min = 0; } if (minY > 0) { minY = 0; graphPaneResult.YAxis.Scale.Min = 0; } for (double x = min; x <= max; x++) { pointPairsResult.Add(x, a * x + b); } if (max > maxY) { graphPaneResult.XAxis.Scale.Max = max; graphPaneResult.YAxis.Scale.Max = max; } else { graphPaneResult.XAxis.Scale.Max = maxY; graphPaneResult.YAxis.Scale.Max = maxY; } if (min < minY) { graphPaneResult.XAxis.Scale.Min = min; graphPaneResult.YAxis.Scale.Min = min; } else { graphPaneResult.XAxis.Scale.Min = minY; graphPaneResult.YAxis.Scale.Min = minY; } this.Size = new Size(568, 702); ZedGraph.LineItem lineItemResult = graphPaneResult.AddCurve("Линейная аппроксимация", pointPairsResult, Color.Red, ZedGraph.SymbolType.None); ZedGraph.LineItem lineItemStart = graphPaneStart.AddCurve("Заданные значения", pointPairsStart, Color.Blue, ZedGraph.SymbolType.None); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); } }
void Draw() { if (minTB.Text != "") { try { xmin = Convert.ToDouble(minTB.Text); } catch { MessageBox.Show("Задан неверный формат числа для минимума!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); minTB.Text = ""; return; } } if (maxTB.Text != "") { try { xmax = Convert.ToDouble(maxTB.Text); } catch { MessageBox.Show("Задан неверный формат числа для максимума!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); maxTB.Text = ""; return; } } if (stepTB.Text != "") { try { step = Convert.ToDouble(stepTB.Text); } catch { MessageBox.Show("Задан неверный формат числа для шага!", "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); stepTB.Text = ""; return; } } ZedGraph.GraphPane graphPane2 = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs2 = new ZedGraph.PointPairList(); graphPane2.CurveList.Clear(); graphPane2.Title.Text = "Случайные значениия"; double xSum = 0d; double ySum = 0d; double xySum = 0d; double xSqSum = 0d; for (double x = xmin; x <= xmax; x += step) { double y = Random.NextDouble() + Random.Next(0, 10); pointPairs2.Add(x, y); xSum += x; ySum += y; xySum += x * y; xSqSum += x * x; } ZedGraph.LineItem lineItem2 = graphPane2.AddCurve("Случайные значения", pointPairs2, Color.Red, ZedGraph.SymbolType.None); double a = (pointPairs2.Count * xySum - xSum * ySum) / (pointPairs2.Count * xSqSum - xSum * xSum); double b = (ySum - a * xSum) / pointPairs2.Count; koefaTB.Text = a.ToString("0.0######"); koefbTB.Text = b.ToString("0.00"); ZedGraph.GraphPane graphPane3 = zedGraphControl1.GraphPane; ZedGraph.PointPairList pointPairs3 = new ZedGraph.PointPairList(); for (double x = xmin; x <= xmax; x++) { pointPairs3.Add(x, a * x + b); } ZedGraph.LineItem lineItem3 = graphPane3.AddCurve("Линейная аппроксимация", pointPairs3, Color.Purple, ZedGraph.SymbolType.None); zedGraphControl1.AxisChange(); zedGraphControl1.Invalidate(); }
public void Add(string name, double[] dataAr, double[] indexAr) { ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; pane.AddCurve(name, indexAr, dataAr, Color.Black, ZedGraph.SymbolType.None); }
private void showData(int dataIndex, bool isOverlay) { SeemsScan scan = dataSource.CurrentScanHeaders[dataIndex]; ZedGraph.GraphPane pane = zedGraphControl1.GraphPane; if (isOverlay && pane.CurveList.Count > overlayColors.Length) { MessageBox.Show("SeeMS only supports up to " + overlayColors.Length + " simultaneous overlays.", "Too many overlays", MessageBoxButtons.OK, MessageBoxIcon.Stop); } // set form title if (!isOverlay) { Text = String.Format("{0} - {1}", System.IO.Path.GetFileName(dataSource.CurrentFilepath), scan.Id); } else { Text += "," + scan.Id; } if (!isOverlay) { pane.CurveList.Clear(); } if (shownScan != null && scan.IsMassSpectrum != shownScan.IsMassSpectrum) { zedGraphControl1.RestoreScale(pane); zedGraphControl1.ZoomOutAll(pane); } bool isScaleAuto = !pane.IsZoomed; //pane.GraphObjList.Clear(); SeemsPointList pointList = scan.PointList; if (pointList.FullCount == 0) { // the header does not have the data points, assume it is a mass spectrum pane.YAxis.Title.Text = "Intensity"; pane.XAxis.Title.Text = "m/z"; bool doCentroid = SeemsMdiParent.CentroidMenuItem.Enabled && SeemsMdiParent.CentroidMenuItem.Checked; dataSource.InstrumentInterface.setCentroiding(doCentroid, doCentroid, SeemsMdiParent.UseVendorCentroidMenuItem.Checked); SeemsScan scanWithData = new SeemsScan(dataSource.InstrumentInterface.getScan(scan.Scan.ScanNumber)); pointList = scanWithData.PointList; int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } if (doCentroid || scanWithData.Scan.IsCentroided) { ZedGraph.StickItem stick = pane.AddStick(scan.Id, pointList, Color.Gray); stick.Symbol.IsVisible = false; stick.Line.Width = 1; } else { pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } } else { // the header has the data points, assume it is a chromatogram int bins = (int)pane.CalcChartRect(zedGraphControl1.CreateGraphics()).Width; if (isScaleAuto) { pointList.SetScale(bins, pointList[0].X, pointList[pointList.Count - 1].X); } else { pointList.SetScale(bins, pane.XAxis.Scale.Min, pane.XAxis.Scale.Max); } pane.YAxis.Title.Text = "Total Intensity"; pane.XAxis.Title.Text = "Retention Time (in seconds)"; pane.AddCurve(scan.Id, pointList, Color.Gray, ZedGraph.SymbolType.None); } pane.AxisChange(); if (isOverlay) { pane.Legend.IsVisible = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; for (int i = 0; i < pane.CurveList.Count; ++i) { pane.CurveList[i].Color = overlayColors[i]; } } else { pane.Legend.IsVisible = false; } SetDataLabelsVisible(true); shownScan = scan; zedGraphControl1.Refresh(); //zedGraphControl1.Focus(); }