private void lb_Sweeps_SelectedIndexChanged(object sender, EventArgs e) { string fName = tb_Sweeps.Text + "\\"; if (lb_Sweeps.SelectedIndex > -1) { fName += lb_Sweeps.SelectedItem.ToString(); ovf2 ovf = new ovf2(fName); string itxt = tb_CompInfo.Text; string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //ovf2 mf = new ovf2(baseName + "f1-0.ovf"); this.componentNum = Convert.ToInt16(sitxt[0]); PlotRow(ovf, chart2, ovf.header.ynodes / 2); Bitmap bmp = Viz.MakeImage(ovf, componentNum); //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Image = bmp; if (mt != null) { string filename = lb_Sweeps.SelectedItem.ToString(); string fn = filename.Substring(1, filename.Length - 5); int fileN = Convert.ToInt32(fn); string fileNname = tb_colname.Text.Split(',')[0]; string fieldname = tb_colname.Text.Split(',')[1]; int index = mt.data[fileNname].IndexOf(fileN); double field = mt.data[fieldname][index]; double amp = chart1.Series[0].Points.Where(point => point.XValue == field).ToList()[0].YValues[0]; this.VA.X = field; Field.Text = field.ToString() + "(G)"; Amp.Text = amp.ToString(); } } }
public static Bitmap MakeImage(ovf2 ovfFile, int XYorZ_12or3) { int Nx = ovfFile.header.xnodes; int Ny = ovfFile.header.ynodes; Bitmap bmp = new Bitmap(Nx, Ny); Graphics g = Graphics.FromImage(bmp); SolidBrush brush = new SolidBrush(Color.Black); double[] minmax = Viz.GetMinMax(ovfFile, XYorZ_12or3); for (int i = 0; i < Nx; i++) { for (int j = 0; j < Ny; j++) { Vector vij = ovfFile.CellValue(i, j, 0); //if (vij.z < 1) //Console.WriteLine(vij.z.ToString()); brush.Color = ColorMap.BlackWhite(minmax[0], minmax[1], Component(vij, XYorZ_12or3)); //Console.WriteLine("{0}, {1}", i, Nx - 1 - j); Rectangle pxl = new Rectangle(i, Ny - 1 - j, 1, 1); g.FillRectangle(brush, pxl); } } return(bmp); }
private void chart1_MouseDown(object sender, MouseEventArgs e) { double xval = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X); Field.Text = Convert.ToString(xval); currXVal = xval; Console.WriteLine(xval); //return; if (e.Button == System.Windows.Forms.MouseButtons.Left) { string fileNname = tb_colname.Text.Split(',')[0]; string fieldname = tb_colname.Text.Split(',')[1]; double N = mt.find(fileNname, fieldname, xval); if (ActiveSim != null) { if (comboBox1.Text == "8Avg_FieldScan") { string baseName = ActiveSim.dir + "\\" + Convert.ToInt32(N).ToString() + "-"; //ovf2 m0 = new ovf2(baseName + Ni.ToString() + ".ovf"); //ovf2 mf = new ovf2(baseName + Nf.ToString() + ".ovf"); ovf2 m0 = new ovf2(baseName + "m0.ovf"); ovf2 mf; string itxt = tb_CompInfo.Text; string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //ovf2 mf = new ovf2(baseName + "f1-0.ovf"); this.componentNum = Convert.ToInt16(sitxt[0]); int tfAvg = Convert.ToInt16(sitxt[1]); if (tfAvg == 1) { mf = new ovf2(baseName + "mf.ovf"); } else { mf = new ovf2(baseName + "f1-0.ovf"); } PlotRow(mf, m0, chart2, mf.header.ynodes / 2); Bitmap bmp = GetImageDiff(mf, m0); pictureBox1.Image = bmp; } else if (comboBox1.Text == "FFT") { string filename = ActiveSim.dir + "\\f" + Convert.ToInt32(N).ToString() + ".ovf"; ovf2 m = new ovf2(filename); string itxt = tb_CompInfo.Text; string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //ovf2 mf = new ovf2(baseName + "f1-0.ovf"); this.componentNum = Convert.ToInt16(sitxt[0]); PlotRow(m, chart2, m.header.ynodes / 2); Bitmap bmp = Viz.MakeImage(m, componentNum); //pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; pictureBox1.Image = bmp; } } Console.WriteLine("N={0}, H={1}", N, (xval).ToString()); } }
private Bitmap GetImageDiff(ovf2 fileA, ovf2 fileB) { for (int i = 0; i < fileA.data.Count; i++) { Vector v1 = fileA.data[i]; Vector v2 = fileB.data[i]; Vector v = v1 - v2; fileA.data[i] = v; } Bitmap bmp = Viz.MakeImage(fileA, componentNum); return(bmp); }
private void lb_Files_SelectedIndexChanged(object sender, EventArgs e) { string fName = tb_Dir.Text + "\\"; if (lb_Files.SelectedIndex > -1) { fName += lb_Files.SelectedItem.ToString(); ovf2 ovf = new ovf2(fName); string itxt = tb_CompInfo.Text; string[] sitxt = itxt.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); //ovf2 mf = new ovf2(baseName + "f1-0.ovf"); this.componentNum = Convert.ToInt16(sitxt[0]); PlotRow(ovf, chart2, ovf.header.ynodes / 2); Bitmap bmp = Viz.MakeImage(ovf, componentNum); pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox1.Image = bmp; } }