private void cmdAddToPlot_Click(object sender, EventArgs e) { try { m_gdiDisplay.AutoRender = false; int i; for (i = 0; i < m_VF.Count; i++) { SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i); GDI3D.Control.Line l = new GDI3D.Control.Line( tf.Intercept.X + tf.Slope.X * (tf.MaxZ - tf.Intercept.Z), tf.Intercept.Y + tf.Slope.Y * (tf.MaxZ - tf.Intercept.Z), tf.MaxZ, tf.Intercept.X + tf.Slope.X * (tf.MinZ - tf.Intercept.Z), tf.Intercept.Y + tf.Slope.Y * (tf.MinZ - tf.Intercept.Z), tf.MinZ, m_VF, cmdTagColor.BackColor.R, cmdTagColor.BackColor.G, cmdTagColor.BackColor.B ); l.Dashed = true; l.Label = "TF " + tf.Id.ToString(); m_gdiDisplay.Add(l); } GDI3D.Control.Point p = new GDI3D.Control.Point(m_VF.X, m_VF.Y, m_VF.Z, m_VF, cmdTagColor.BackColor.R, cmdTagColor.BackColor.G, cmdTagColor.BackColor.B); p.Label = "VF " + m_FitName; m_gdiDisplay.Add(p); } catch (Exception) { }; m_gdiDisplay.AutoRender = true; m_gdiDisplay.Render(); }
public void AddTrackFit(SySal.TotalScan.VertexFit.TrackFit tf) { try { m_VF.AddTrackFit(tf); } catch (Exception x) { MessageBox.Show(x.Message, "Error adding track fit", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } UpdateFit(); }
private void UpdateFit() { m_gdiDisplay.AutoRender = false; TrackList.BeginUpdate(); try { m_TotalP.X = m_TotalP.Y = m_TotalP.Z = 0.0; TrackList.Items.Clear(); int i; for (i = 0; i < m_VF.Count; i++) { SySal.BasicTypes.Vector s = new SySal.BasicTypes.Vector(); SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i); s.Z = 1.0 / Math.Sqrt(1.0 + tf.Slope.X * tf.Slope.X + tf.Slope.Y * tf.Slope.Y); s.X = tf.Slope.X * s.Z; s.Y = tf.Slope.Y * s.Z; ListViewItem lvi = new ListViewItem(tf.Id.ToString()); lvi.Tag = tf.Id; lvi.SubItems.Add(tf.Intercept.X.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Intercept.Y.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Intercept.Z.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Slope.X.ToString("F4", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Slope.Y.ToString("F4", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Weight.ToString("F3", System.Globalization.CultureInfo.InvariantCulture)); if (tf is SySal.TotalScan.VertexFit.TrackFitWithMomentum) { double p = ((SySal.TotalScan.VertexFit.TrackFitWithMomentum)tf).P; lvi.SubItems.Add(p.ToString("F2", System.Globalization.CultureInfo.InvariantCulture)); m_TotalP.X += s.X * p; m_TotalP.Y += s.Y * p; m_TotalP.Z += s.Z * p; } else { lvi.SubItems.Add(""); } lvi.SubItems.Add(m_VF.TrackIP(tf).ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(m_VF.DisconnectedTrackIP(tf.Id).ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(Math.Min(Math.Abs(m_VF.Z - tf.MaxZ), Math.Abs(m_VF.Z - tf.MinZ)).ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); TrackList.Items.Add(lvi); } textX.Text = m_VF.X.ToString("F1", System.Globalization.CultureInfo.InvariantCulture); textY.Text = m_VF.Y.ToString("F1", System.Globalization.CultureInfo.InvariantCulture); textZ.Text = m_VF.Z.ToString("F1", System.Globalization.CultureInfo.InvariantCulture); } catch (Exception) { textX.Text = ""; textY.Text = ""; textZ.Text = ""; TrackList.Items.Clear(); int i; for (i = 0; i < m_VF.Count; i++) { SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i); ListViewItem lvi = new ListViewItem(tf.Id.ToString()); lvi.Tag = tf.Id; lvi.SubItems.Add(tf.Intercept.X.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Intercept.Y.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Intercept.Z.ToString("F1", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Slope.X.ToString("F4", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Slope.Y.ToString("F4", System.Globalization.CultureInfo.InvariantCulture)); lvi.SubItems.Add(tf.Weight.ToString("F3", System.Globalization.CultureInfo.InvariantCulture)); if (tf is SySal.TotalScan.VertexFit.TrackFitWithMomentum) { lvi.SubItems.Add(((SySal.TotalScan.VertexFit.TrackFitWithMomentum)tf).P.ToString("F2", System.Globalization.CultureInfo.InvariantCulture)); } else { lvi.SubItems.Add(""); } lvi.SubItems.Add(""); lvi.SubItems.Add(""); lvi.SubItems.Add(""); TrackList.Items.Add(lvi); } } txtPx.Text = m_TotalP.X.ToString("F2", System.Globalization.CultureInfo.InvariantCulture); txtPy.Text = m_TotalP.Y.ToString("F2", System.Globalization.CultureInfo.InvariantCulture); txtPz.Text = m_TotalP.Z.ToString("F2", System.Globalization.CultureInfo.InvariantCulture); txtP.Text = Math.Sqrt(m_TotalP.X * m_TotalP.X + m_TotalP.Y * m_TotalP.Y + m_TotalP.Z * m_TotalP.Z).ToString("F2", System.Globalization.CultureInfo.InvariantCulture); UpdatePT(); TrackList.EndUpdate(); if (m_gdiDisplay.RemoveOwned(m_VF) > 0) { cmdAddToPlot_Click(this, null); } m_gdiDisplay.AutoRender = true; m_gdiDisplay.Render(); }
private void cmdToVertex_Click(object sender, EventArgs e) { if (m_VF.Count <= 0) { return; } SySal.TotalScan.Track [] tklist = new SySal.TotalScan.Track[m_VF.Count]; int i; System.Collections.ArrayList vtxaltered = new System.Collections.ArrayList(); for (i = 0; i < tklist.Length; i++) { SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i); tklist[i] = m_V.Tracks[((SySal.TotalScan.BaseTrackIndex)tf.Id).Id]; tklist[i].SetAttribute(SySal.TotalScan.Vertex.TrackWeightAttribute, tf.Weight); bool isupstream = (tklist[i].Downstream_Z + tklist[i].Upstream_Z) > (tf.MaxZ + tf.MinZ); SySal.TotalScan.Vertex vtxa = isupstream ? tklist[i].Upstream_Vertex : tklist[i].Downstream_Vertex; if (vtxa != null) { if (vtxaltered.Contains(vtxa) == false) { vtxaltered.Add(vtxa); } vtxa.RemoveTrack(tklist[i]); } } int[] ids = new int[vtxaltered.Count]; for (i = 0; i < ids.Length; i++) { ids[i] = ((SySal.TotalScan.Vertex)vtxaltered[i]).Id; } System.Collections.ArrayList vtxremove = new System.Collections.ArrayList(); foreach (SySal.TotalScan.Vertex vtx in vtxaltered) { try { vtx.NotifyChanged(); if (vtx.AverageDistance >= 0.0) { continue; } } catch (Exception) { vtxremove.Add(vtx.Id); } } ((SySal.TotalScan.Flexi.Volume.VertexList)m_V.Vertices).Remove((int[])vtxremove.ToArray(typeof(int))); SySal.TotalScan.Flexi.Vertex nv = new SySal.TotalScan.Flexi.Vertex(((SySal.TotalScan.Flexi.Track)tklist[0]).DataSet, m_V.Vertices.Length); nv.SetId(m_V.Vertices.Length); for (i = 0; i < tklist.Length; i++) { SySal.TotalScan.VertexFit.TrackFit tf = m_VF.Track(i); if ((tklist[i].Downstream_Z + tklist[i].Upstream_Z) > (tf.MaxZ + tf.MinZ)) { nv.AddTrack(tklist[i], false); tklist[i].SetUpstreamVertex(nv); } else { nv.AddTrack(tklist[i], true); tklist[i].SetDownstreamVertex(nv); } } try { nv.NotifyChanged(); if (nv.AverageDistance >= 0.0) { ((SySal.TotalScan.Flexi.Volume.VertexList)m_V.Vertices).Insert(new SySal.TotalScan.Flexi.Vertex[1] { nv }); } } catch (Exception x) { MessageBox.Show("Can't create new vertex - check geometry/topology.", "Vertex error", MessageBoxButtons.OK, MessageBoxIcon.Error); nv.SetId(-1); } if (nv.Id >= 0) { string s = ""; if (ids.Length > 0) { s += "\r\nVertices altered: {"; for (i = 0; i < ids.Length; i++) { if (i == 0) { s += ids[i].ToString(); } else { s += ", " + ids[i].ToString(); } } s += "}"; } if (vtxremove.Count > 0) { s += "\r\nVertices removed: {"; for (i = 0; i < vtxremove.Count; i++) { if (i == 0) { s += vtxremove[i].ToString(); } else { s += ", " + vtxremove[i].ToString(); } } s += "}"; } MessageBox.Show("New vertex " + nv.Id + " created." + s + "\r\nPlease regenerate the plot to see the changes.", "Vertex created", MessageBoxButtons.OK, MessageBoxIcon.Information); } TrackBrowser.RefreshAll(); VertexBrowser.RefreshAll(); }