private void graphControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { double x, y, y2; int i; ZedGraph.GraphPane pane = graphControl.GraphPane; pane.ReverseTransform(new PointF(e.Y, e.X), out x, out y, out y2); i = (int)Math.Round(x) - 1; if (i >= 0 && i < pane.XAxis.TextLabels.Length) { string s = string.Format("Comments\nReceived from {0}: {1}\nGiven to {0}: {2}", pane.XAxis.TextLabels[i], pane.CurveList[0].Y[i], pane.CurveList[1].Y[i]); if (toolTipText != s) { toolTipText = s; toolTip.SetToolTip(graphControl, s); } } }
public void DrawsequencingGraph(GlycanStructure argStructure) { zedSequence.GraphPane.GraphObjList.Clear(); zedSequence.GraphPane.Legend.IsVisible = false; List <String> tmp = argStructure.Root.GetSequencingMapList(); if (tmp.Count == 0) { return; } float Xmin = Convert.ToSingle(tmp[0].Split('-')[0]); float Xmax = Convert.ToSingle(tmp[tmp.Count - 1].Split('-')[2]); if (Xmax == 0.0f) { Xmax = scan.MSPeaks[scan.MSPeaks.Count - 1].MonoMass; } double YMax = 0.0; ZedGraph.PointPairList pplPeak = new ZedGraph.PointPairList(); for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { if (GS.FilteredPeaks[i].Intensity > YMax) { YMax = GS.FilteredPeaks[i].Intensity; } } } for (int i = 0; i < GS.FilteredPeaks.Count; i++) { if (GS.FilteredPeaks[i].Mass >= Xmin + 10.0f && GS.FilteredPeaks[i].Mass <= Xmax + 10.0f) { pplPeak.Add(GS.FilteredPeaks[i].Mass, GS.FilteredPeaks[i].Intensity / YMax * 100.0f); } } ZedGraph.GraphPane Pane = zedSequence.GraphPane; Pane.XAxis.MajorTic.IsInside = false; Pane.XAxis.MinorTic.IsInside = false; Pane.CurveList.Clear(); Pane.AddStick("Peaks", pplPeak, Color.Red); //Pane.XAxis.Scale.Min = Xmin - 10; //Pane.XAxis.Scale.Max = Xmax + 10; Pane.Title.Text = "No. " + txtScanNo.Text + "; Y1 m/z:" + argStructure.Y1.Mass.ToString("0.000");//+ " Structure:" + Convert.ToString(dgView.Rows[e.RowIndex].Cells[0].Value); Pane.AxisChange(); double YLevel = YMax; double outX, outY, outY2, diff; Pane.ReverseTransform(new Point(100, 100), out outX, out outY); Pane.ReverseTransform(new Point(100, 110), out outX, out outY2); diff = outY - outY2; GlycanTreeNode GT = argStructure.Root;//GS.GlycanTrees[e.RowIndex]; //Peak Interval //List<string> SeqList = new List<string>(); //for (int i = 0; i < GT.GetSequencingMapList().Count; i++) //{ // //Split the string // string[] strArray = GT.GetSequencingMapList()[i].Split('-'); // ZedGraph.TextObj TxtObg = new ZedGraph.TextObj(); // TxtObg.Text = strArray[1]; // double Start = Convert.ToDouble(strArray[0]); // double End = Convert.ToDouble(strArray[2]); // System.Drawing.Drawing2D.DashStyle LineStyle = DashStyle.Solid; // if (Start == 0) // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // else // { // if (strArray[1] == "HexNAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // Start = End - GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // } // if (End == 0) // { // if (strArray[1] == "HexNAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.HexNAc, GT.Charge); // } // else if (strArray[1] == "DeHex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.DeHex, GT.Charge); // } // else if (strArray[1] == "Hex") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.Hex, GT.Charge); // } // else if (strArray[1] == "NeuAc") // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuAc, GT.Charge); // } // else // { // End = Start + GlycanMass.GetGlycanMasswithCharge(Glycan.Type.NeuGc, GT.Charge); // } // TxtObg.Text = TxtObg.Text + "?"; // LineStyle = DashStyle.Dash; // } // //Determine the Y level // int Ylevel = 0; // if (SeqList.Count == 0) // { // SeqList.Add(Start.ToString() + "," + End.ToString() + ",0"); // } // else // { // for (int j = i - 1; j >= 0; j--) // { // double PreStart = Convert.ToDouble(SeqList[j].Split(',')[0]); // double PreEnd = Convert.ToDouble(SeqList[j].Split(',')[1]); // int Prelevel = Convert.ToInt32(SeqList[j].Split(',')[2]); // if ((PreStart <= Start && Start <= PreEnd)) // { // if (Math.Abs(PreEnd - Start) <= 10.0) // { // Ylevel = Prelevel; // break; // } // else // { // Ylevel = Prelevel + 1; // break; // } // } // } // SeqList.Add(Start.ToString() + "," + End.ToString() + "," + Ylevel.ToString()); // } // TxtObg.FontSpec.Size = TxtObg.FontSpec.Size * 0.8f; // YLevel = YMax + diff * Ylevel; // ZedGraph.LineObj Lne = new ZedGraph.LineObj(Start, YLevel + diff, Start, YLevel - diff); //Left V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(End, YLevel + diff, End, YLevel - diff); //Right V Line // Pane.GraphObjList.Add(Lne); // Lne = new ZedGraph.LineObj(Start, YLevel, End, YLevel); //Add Line // Lne.Line.Style = LineStyle; // Pane.GraphObjList.Add(Lne); // //ZedGraph.ArrowObj arr= new ZedGraph.ArrowObj(Start, YLevel, End, YLevel); // //arr.IsArrowHead = true; // //arr.Line.Style = LineStyle; // //Pane.GraphObjList.Add(arr); // TxtObg.Location = new ZedGraph.Location(((Start + End) / 2), (double)YLevel, ZedGraph.CoordType.AxisXYScale); // TxtObg.FontSpec.Border.IsVisible = false; // TxtObg.Location.AlignH = ZedGraph.AlignH.Center; // TxtObg.Location.AlignV = ZedGraph.AlignV.Center; // Pane.GraphObjList.Insert(0, TxtObg); //} /////Annotation GlycansDrawer GDraw; double previousX2 = 0; List <GlycanTreeNode> Fragements = argStructure.Root.FetchAllGlycanNode(); Fragements.Sort(delegate(GlycanTreeNode T1, GlycanTreeNode T2) { return(Comparer <float> .Default.Compare(T1.IDMass, T2.IDMass)); }); foreach (GlycanTreeNode FGS in Fragements) { string Exp = argStructure.GetIUPACfromParentToNodeID(FGS.NodeID); //Queue<string> tmpQue = new Queue<string>(); //for (int i = 0; i < Exp.Length; i++) //{ // int NodeID = 0; // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0].Substring(1)); // } // else // { // NodeID = Convert.ToInt32(Exp[i].Split(',')[0]); // } // if (NodeID > FGS.NodeID) // { // if (Exp[i].StartsWith("(") || Exp[i].StartsWith(")")) // { // tmpQue.Enqueue(Exp[i].Substring(0, 1)); // // } // } // else // { // tmpQue.Enqueue(Exp[i]); // } //} //string IUPAC = ""; //do //{ // string tmp =tmpQue.Dequeue(); // if(tmp == "(" && tmpQue.Peek() == ")" ) // { // } //}while(tmpQue.Count!=0) string tmpIUPAC = argStructure.GetSequqncedIUPACwNodeID(FGS.NodeID); GDraw = new GlycansDrawer(tmpIUPAC); float glycopeptideMZ = FGS.IDMass; if (double.IsNaN(glycopeptideMZ)) { continue; } Image imgStructure = RotateImage(GDraw.GetImage(), 270); double PositionX = glycopeptideMZ; if (previousX2 >= PositionX) { PositionX = previousX2 + 20; } ZedGraph.ImageObj glycan = new ZedGraph.ImageObj(imgStructure, PositionX, 130, imgStructure.Width * 0.3f, imgStructure.Height * 0.3f); glycan.IsScaled = true; glycan.Location.AlignV = ZedGraph.AlignV.Bottom; Pane.GraphObjList.Add(glycan); ZedGraph.TextObj txtGlycanMz = new ZedGraph.TextObj(glycopeptideMZ.ToString("0.000"), 100, 140); txtGlycanMz.Location.X = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1 + (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 - Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X1) / 2; txtGlycanMz.FontSpec.Size = txtGlycanMz.FontSpec.Size * 0.5f; txtGlycanMz.FontSpec.Border.IsVisible = false; Pane.GraphObjList.Add(txtGlycanMz); if (Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2 > Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2) { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.X2; } else { previousX2 = Pane.GraphObjList[Pane.GraphObjList.Count - 2].Location.X2; } } Pane.AxisChange(); Pane.YAxis.Scale.Max = 145; Pane.XAxis.Scale.Min = Convert.ToInt32(argStructure.Y1.Mass - 100); Pane.XAxis.Scale.Max = pplPeak[pplPeak.Count - 1].X + 100; //////////// //Glycan Structure on the Right Top Header //////////// GDraw = new GlycansDrawer(argStructure.IUPACString, false); Image imgStruc = GDraw.GetImage(); ZedGraph.ImageObj fullStructure = new ZedGraph.ImageObj(imgStruc, 0.01f, 0.01f, imgStruc.Width, imgStruc.Height); fullStructure.IsScaled = false; Pane.GraphObjList.Add(fullStructure); Pane.GraphObjList[Pane.GraphObjList.Count - 1].Location.CoordinateFrame = ZedGraph.CoordType.PaneFraction; zedSequence.AxisChange(); zedSequence.Refresh(); }