Exemplo n.º 1
0
        private float[,] MSpointSet3DToArray(MSPointSet3D mspointset, RegionSize PaintRegion)
        {
            RegionSize pointSetRegion = new RegionSize(mspointset.MinX, mspointset.MaxX, mspointset.MaxY, mspointset.MinY);

            float[,] Data    = new float[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            int[,] DataCount = new int[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    Data[i, j]      = -1;
                    DataCount[i, j] = 0;
                }
            }

            //foreach (MSPoint3D point3D in mspointset.Points3D)
            for (int i = 0; i < mspointset.Count; i++)
            {
                if (DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] == 0)
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] = mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
                else
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] += mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
            }
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    if (Data[i, j] != -1)
                    {
                        Data[i, j] = Data[i, j] / DataCount[i, j];
                    }
                }
            }
            return(Data);
        }
Exemplo n.º 2
0
        private float[,] MSpointSet3DToArray(MSPointSet3D mspointset, RegionSize PaintRegion)
        {
            RegionSize pointSetRegion = new RegionSize(mspointset.MinX, mspointset.MaxX, mspointset.MaxY, mspointset.MinY);

            float[,] Data = new float[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            int[,] DataCount = new int[(int)PaintRegion.Width + 1, (int)PaintRegion.Height + 1];
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    Data[i, j] = -1;
                    DataCount[i, j] = 0;
                }
            }

            //foreach (MSPoint3D point3D in mspointset.Points3D)
            for (int i = 0; i < mspointset.Count; i++)
            {
                if (DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] == 0)
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] = mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
                else
                {
                    Data[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))] += mspointset.Z(i);
                    DataCount[(int)Math.Round(CoordinateTrans.TimeToX(pointSetRegion, PaintRegion, mspointset.X(i))), (int)Math.Round(CoordinateTrans.MassToY(pointSetRegion, PaintRegion, mspointset.Y(i)))]++;
                }
            }
            for (int i = 0; i < (int)PaintRegion.Width + 1; i++)
            {
                for (int j = 0; j < (int)PaintRegion.Height + 1; j++)
                {
                    if (Data[i, j] != -1)
                    {
                        Data[i, j] = Data[i, j] / DataCount[i, j];
                    }
                }
            }
            return Data;
        }
Exemplo n.º 3
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            if (_eViewerHandler == null)
            {
                return;
            }

            if (e.Button == System.Windows.Forms.MouseButtons.Right)
            {
                if (_eViewerHandler.IsColor)
                {
                    ((ToolStripMenuItem)contextMenuStrip1.Items["tsmColor"]).Checked = true;
                }

                contextMenuStrip1.Show(pictureBox1, e.X, e.Y);
            }

            if (mouse_down)
            {
                //up Y軸座標
                if (e.X <= _eViewerHandler.Xstart && e.Y <= _eViewerHandler.Ystart && e.Y >= _eViewerHandler.Yend && e.Y != y_temp && Y_click == true)
                {
                    zoom_event = true;
                    mouse_down = false;
                    if (y_temp < e.Y)
                    {
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                    }
                    else
                    {
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                    }
                    X_min = _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder;
                    X_max = _eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder;
                }

                //up X軸座標
                if (e.X >= _eViewerHandler.Xstart && e.X <= _eViewerHandler.Xend && e.Y >= _eViewerHandler.Ystart && e.X != x_temp && X_click == true)
                {
                    //MessageBox.Show("UP X axis");
                    zoom_event = true;
                    mouse_down = false;
                    if (x_temp < e.X)
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                    }
                    else
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                    }
                    Y_min = _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder;
                    Y_max = _eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder;
                }

                //up Plot裡面
                if (e.X >= _eViewerHandler.Xstart && e.X <= _eViewerHandler.Xend && e.Y <= _eViewerHandler.Ystart && e.Y >= _eViewerHandler.Yend && e.X != x_temp && e.Y != y_temp && plot_click == true)
                {
                    //MessageBox.Show("UP plot axis");
                    zoom_event = true;
                    mouse_down = false;
                    if (x_temp < e.X && y_temp > e.Y)
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                    }
                    if (x_temp < e.X && y_temp < e.Y)
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));;
                    }
                    if (x_temp > e.X && y_temp > e.Y)
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                    }
                    if (x_temp > e.X && y_temp < e.Y)
                    {
                        X_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((e.X - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        X_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder + ((x_temp - _eViewerHandler.Xstart) * (_eViewerHandler.MyCurrentPointSet3D.MaxXwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinXwWhiteBoarder) / Math.Abs(_eViewerHandler.Xend - _eViewerHandler.Xstart)));
                        Y_min = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - e.Y) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                        Y_max = (float)(_eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder + ((_eViewerHandler.Ystart - y_temp) * (_eViewerHandler.MyCurrentPointSet3D.MaxYwWhiteBoarder - _eViewerHandler.MyCurrentPointSet3D.MinYwWhiteBoarder) / Math.Abs(_eViewerHandler.Yend - _eViewerHandler.Ystart)));
                    }
                }
                if (X_max - X_min <= 0.01 || Y_max - Y_min <= 0.5)
                {
                    zoom_event = false;
                }
                if (zoom_event && !isGetAbundance)
                {
                    _eViewerHandler.Renew_plot = true;
                    if (_eViewerHandler.IsSmoothed)
                    {
                        _eViewerHandler.SmoothingofSmoothed(X_min, X_max, Y_max, Y_min);
                    }
                    else
                    {
                        _eViewerHandler.GetSubPointSet(new RegionSize(X_min, X_max, Y_max, Y_min));
                    }
                    X_click    = false;
                    Y_click    = false;
                    plot_click = false;
                }
                else
                {
                    if (X_max - X_min >= 0.01 && Y_max - Y_min >= 0.5)
                    {
                        MSPointSet3D tmp3Dset     = _eViewerHandler.SubPointSetExtract(new RegionSize(X_min, X_max, Y_max, Y_min));
                        float        SumIntensity = 0.0f;
                        Dictionary <float, MSPointSet> Intergral = new Dictionary <float, MSPointSet>();
                        for (int i = 0; i < tmp3Dset.Count; i++)
                        {
                            float mz        = tmp3Dset.Y(i);
                            float time      = tmp3Dset.X(i);
                            float intensity = tmp3Dset.Z(i);
                            SumIntensity = SumIntensity + intensity;
                            if (!Intergral.ContainsKey(mz))
                            {
                                Intergral.Add(mz, new MSPointSet());
                            }
                            Intergral[mz].Add(time, intensity);
                        }
                        double area = 0;
                        foreach (float mzKey in Intergral.Keys)
                        {
                            if (Intergral[mzKey].Count <= 3)
                            {
                                continue;
                            }
                            Intergral[mzKey].Sort();
                            area = IntegralArea(Intergral[mzKey]);
                        }
                        MessageBox.Show("Time:" + X_min.ToString() + "~" + X_max.ToString() + "\n" +
                                        "m/z:" + Y_min.ToString() + "~" + Y_max.ToString() + "\n" +
                                        "Sum Intensity:" + SumIntensity.ToString() + "\n" +
                                        "Area:" + area.ToString());
                    }
                    X_click    = false;
                    Y_click    = false;
                    plot_click = false;
                }

                zoom_event = false;
                if (this.StatusUpdated != null)
                {
                    this.StatusUpdated(new object(), new RegionSize(X_min, X_max, Y_max, Y_min));
                }
                this.Refresh();
            }
        }