private void btnClearOverlay_Click(object sender, EventArgs e) { m_OverlayScene = null; }
private void btnLoadOverlay_Click(object sender, EventArgs e) { dlgLoadOverlay.InitialDirectory = m_DefaultDirectory; if (dlgLoadOverlay.ShowDialog() == DialogResult.OK) { System.IO.BinaryReader r = null; System.IO.FileStream fr = null; try { if (dlgLoadOverlay.FileName.ToLower().EndsWith(".x3l")) { m_OverlayScene = (GDI3D.Scene)xmlscene.Deserialize(new System.IO.StringReader(System.IO.File.ReadAllText(dlgLoadOverlay.FileName))); } else if (dlgLoadOverlay.FileName.ToLower().EndsWith(".rwd") || rx_RWD.Match(dlgLoadOverlay.FileName.ToLower()).Success) { fr = new System.IO.FileStream(dlgLoadOverlay.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read); SySal.Scanning.Plate.IO.OPERA.RawData.Fragment frag = new Scanning.Plate.IO.OPERA.RawData.Fragment(fr); fr.Close(); fr = null; GDI3D.Scene scene = new GDI3D.Scene(); int total = 0; int v; for (v = 0; v < frag.Length; v++) { total += frag[v].Top.Length + frag[v].Bottom.Length; } scene.Lines = new GDI3D.Line[2 * total]; scene.Points = new GDI3D.Point[0]; scene.OwnerSignatures = new string[total]; total = 0; for (v = 0; v < frag.Length; v++) { int i; for (i = 0; i < frag[v].Top.Length; i++) { SySal.Tracking.MIPEmulsionTrackInfo info = frag[v].Top[i].Info; info.Intercept = frag[v].Top.MapPoint(info.Intercept); info.Slope = frag[v].Top.MapVector(info.Slope); scene.OwnerSignatures[total / 2] = v + "T" + i + ": " + info.Count + " " + info.AreaSum + " " + info.Intercept.X.ToString("F1") + " " + info.Intercept.Y.ToString("F1") + " " + info.Slope.X.ToString("F4") + " " + info.Slope.Y.ToString("F4") + " " + info.Sigma.ToString("F3"); scene.Lines[total++] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, 0, info.Intercept.X + EmulThickness * info.Slope.X, info.Intercept.Y + EmulThickness * info.Slope.Y, EmulThickness, i, 224, 0, 0); scene.Lines[total++] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, 0, info.Intercept.X - BaseThickness * info.Slope.X, info.Intercept.Y - BaseThickness * info.Slope.Y, -BaseThickness, i, 0, 224, 0); } for (i = 0; i < frag[v].Bottom.Length; i++) { SySal.Tracking.MIPEmulsionTrackInfo info = frag[v].Bottom[i].Info; info.Intercept = frag[v].Bottom.MapPoint(info.Intercept); info.Slope = frag[v].Bottom.MapVector(info.Slope); scene.OwnerSignatures[total / 2] = v + "B" + i + ": " + info.Count + " " + info.AreaSum + " " + info.Intercept.X.ToString("F1") + " " + info.Intercept.Y.ToString("F1") + " " + info.Slope.X.ToString("F4") + " " + info.Slope.Y.ToString("F4") + " " + info.Sigma.ToString("F3"); scene.Lines[total++] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, -BaseThickness, info.Intercept.X - EmulThickness * info.Slope.X, info.Intercept.Y - EmulThickness * info.Slope.Y, -BaseThickness - EmulThickness, i, 0, 0, 224); scene.Lines[total++] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, -BaseThickness, info.Intercept.X + BaseThickness * info.Slope.X, info.Intercept.Y + BaseThickness * info.Slope.Y, 0, i, 0, 224, 0); } } m_OverlayScene = scene; } else if (dlgLoadOverlay.FileName.ToLower().EndsWith(".reader")) { r = new System.IO.BinaryReader(new System.IO.FileStream(dlgLoadOverlay.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read)); int total = r.ReadInt32(); GDI3D.Scene scene = new GDI3D.Scene(); scene.Lines = new GDI3D.Line[2 * total]; scene.Points = new GDI3D.Point[0]; scene.OwnerSignatures = new string[total]; r.ReadDouble(); r.ReadDouble(); r.ReadDouble(); r.ReadDouble(); int i; for (i = 0; i < total; i++) { Int64 zone = r.ReadInt64(); short side = r.ReadInt16(); int id = r.ReadInt32(); short count = r.ReadInt16(); int areasum = r.ReadInt32(); double x = r.ReadDouble(); double y = r.ReadDouble(); double z = (side == 1) ? 0 : -BaseThickness; double sx = r.ReadDouble(); double sy = r.ReadDouble(); double sigma = r.ReadDouble(); int view = r.ReadInt32(); double vx = r.ReadDouble(); double vy = r.ReadDouble(); scene.OwnerSignatures[i] = zone + " " + side + " " + id + ": " + count + " " + areasum + " " + x.ToString("F1") + " " + y.ToString("F1") + " " + sx.ToString("F4") + " " + sy.ToString("F4") + " " + sigma.ToString("F3") + " in " + view + ": " + vx.ToString("F1") + " " + vy.ToString("F1"); double dz = ((side == 1) ? EmulThickness : -EmulThickness); double dzbase = ((side == 1) ? -BaseThickness : BaseThickness); scene.Lines[2 * i] = new GDI3D.Line(x, y, z, x + dz * sx, y + dz * sy, z + dz, i, (side == 1) ? 255 : 0, 0, (side == 2) ? 255 : 0); scene.Lines[2 * i + 1] = new GDI3D.Line(x, y, z, x + dzbase * sx, y + dzbase * sy, z + dzbase, i, (side == 1) ? 255 : 0, 192, (side == 2) ? 255 : 0); } r.Close(); r = null; m_OverlayScene = scene; } else if (dlgLoadOverlay.FileName.ToLower().EndsWith(".tlg")) { SySal.DataStreams.OPERALinkedZone lzd = new DataStreams.OPERALinkedZone(dlgLoadOverlay.FileName); int total = lzd.Length; GDI3D.Scene scene = new GDI3D.Scene(); scene.Lines = new GDI3D.Line[3 * total]; scene.Points = new GDI3D.Point[0]; scene.OwnerSignatures = new string[total]; int i; for (i = 0; i < total; i++) { SySal.Tracking.MIPEmulsionTrackInfo info = lzd[i].Info; scene.OwnerSignatures[i] = i + ": " + info.Count + " " + info.AreaSum + " " + info.Intercept.X.ToString("F1") + " " + info.Intercept.Y.ToString("F1") + " " + info.Slope.X.ToString("F4") + " " + info.Slope.Y.ToString("F4") + " " + info.Sigma.ToString("F3"); scene.Lines[3 * i] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, 0, info.Intercept.X + EmulThickness * info.Slope.X, info.Intercept.Y + EmulThickness * info.Slope.Y, EmulThickness, i, 224, 0, 0); scene.Lines[3 * i + 1] = new GDI3D.Line(info.Intercept.X, info.Intercept.Y, 0, info.Intercept.X - BaseThickness * info.Slope.X, info.Intercept.Y - BaseThickness * info.Slope.Y, -BaseThickness, i, 0, 224, 0); scene.Lines[3 * i + 2] = new GDI3D.Line(info.Intercept.X - BaseThickness * info.Slope.X, info.Intercept.Y - BaseThickness * info.Slope.Y, -BaseThickness, info.Intercept.X - (BaseThickness + EmulThickness) * info.Slope.X, info.Intercept.Y - (BaseThickness + EmulThickness) * info.Slope.Y, -BaseThickness - EmulThickness, i, 0, 0, 224); } lzd.Dispose(); m_OverlayScene = scene; } else { MessageBox.Show("Unsupported format", "File error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception x) { MessageBox.Show(x.ToString(), "File error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (r != null) { r.Close(); r = null; } if (fr != null) { fr.Close(); fr = null; } m_OverlayBmp = null; } } }