示例#1
0
        private double[] f_绘制性能曲线(XYGraph 曲线控件, string 需要进行绘制的曲线ID, Grid 表格控件, string 采集样本_流量数据列名, string 采集样本_Y轴数据列名, int 拟合次数, int 分割点数)
        {
            List <double> 曲线X坐标集合 = new List <double>();
            List <double> 曲线Y坐标集合 = new List <double>();

            double[]      方程常量组;
            List <double> 拟合曲线X坐标集合;
            List <double> 拟合曲线Y坐标集合;

            for (int i = 0; i < 表格控件.ExportBandView.RowCount; i++)
            {
                double X = Convert.ToSingle(((DataRowView)表格控件.ExportBandView.GetRow(i))[采集样本_流量数据列名]);
                double Y = Convert.ToSingle(((DataRowView)表格控件.ExportBandView.GetRow(i))[采集样本_Y轴数据列名]);
                曲线X坐标集合.Add(X);
                曲线Y坐标集合.Add(Y);
            }
            if (曲线X坐标集合.Count == 0)
            {
                return(null);
            }
            辅助库.CurveFitting.f_曲线拟合(曲线X坐标集合.ToArray(), 曲线Y坐标集合.ToArray(), 拟合次数, 分割点数, out 拟合曲线X坐标集合, out 拟合曲线Y坐标集合, out 方程常量组);
            //_曲线拟合.f_曲线拟合(曲线X坐标集合, 曲线Y坐标集合, 4,1000 ,out 拟合曲线X坐标集合, out 拟合曲线Y坐标集合);
            for (int j = 0; j < 曲线控件.Graph.Plots.Count; j++)
            {
                if (曲线控件.Graph.Plots[j].Tag.ToString().Equals(需要进行绘制的曲线ID))
                {
                    曲线控件.Graph.Plots[j].PlotXY(拟合曲线X坐标集合.ToArray(), 拟合曲线Y坐标集合.ToArray());
                }
            }
            return(方程常量组);
        }
 public TLUControl()
 {
     InitializeComponent();
     XYgraph = new XYGraph(XY_Panel.Width, XY_Panel.Height, 10);
     tlu     = new TLUmodel(1.5, 1, new Data(80, -100), 5000, this);
     error.Hide();
     XY_Line_Panel.Hide();
 }
示例#3
0
 private void 显示曲线(XYGraph 曲线控件, string 曲线ID)
 {
     /*    for (int j = 0; j < 曲线控件.Graph.Plots.Count; j++)
      *  {
      *      if (曲线控件.Graph.Plots[j].Tag.ToString().Equals(曲线ID) ||
      *          曲线控件.Graph.Plots[j].Tag.ToString().Equals(曲线ID+"汽蚀余量"))
      *      {
      *          曲线控件.Graph.Plots[j].Visible = true;
      *      }
      *      else
      *      {
      *          曲线控件.Graph.Plots[j].Visible = false;
      *      }
      *  }*/
 }
示例#4
0
        /// <summary>
        /// The function for adding data from a list of objects to a graph
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inData">List of objects containing the data to be graphed</param>
        /// <param name="X">The Func<T, double> that returns the x-coordinate from an object in the list</param>
        /// <param name="Y">The Func<T, double> that returns the y-coordinate from an object in the list</param>
        /// <param name="lineColor">The line color</param>
        /// <param name="name">The name of the data as displayed in the graph</param>
        /// <param name="drawLabel">This boolean determines if the name of the line is displayed</param>
        /// <param name="drawCarets">This boolean determines of carets are displayed on the line points</param>
        public int AddData <T>(List <T> inData, Func <T, double> X, Func <T, double> Y, Color lineColor, string name, bool drawLabel, bool drawCarets)
        {
            XYGraph graph = new XYGraph();

            if (inData == null || inData.Count == 0)
            {
                return(-1);
            }
            graph.nrpoints = inData.Count;
            graph.data     = null;
            graph.intdata  = null;
            GC.Collect();

            graph.data = new double[graph.nrpoints, 2];
            int index = 0;

            foreach (var D in inData)
            {
                graph.data[index, 0]   = X(D);
                graph.data[index++, 1] = Convert(Y(D));
            }
            graph.name = name;

            //allocate space for the int data buffer
            graph.intdata = new int[2 * graph.nrpoints];

            img.Source = wb;

            SolidColorBrush brush = new SolidColorBrush(lineColor);

            graph.drawlabel = drawLabel;

            graph.color = lineColor;

            graph.legendText.Text       = name + " ";
            graph.legendText.Foreground = brush;

            graph.draw_caret = drawCarets;

            AllGraphs.Add(graph);
            return(AllGraphs.Count);
        }
示例#5
0
        private void f_绘制影子性能曲线(XYGraph 曲线控件, string 需要进行绘制的曲线ID, Grid 表格控件, string 采集样本_流量数据列名, string 采集样本_Y轴数据列名)
        {
            List <double> 曲线X坐标对集合 = new List <double>();
            List <double> 曲线Y坐标对集合 = new List <double>();

            for (int i = 0; i < 表格控件.ExportBandView.RowCount; i++)
            {
                double X = Convert.ToSingle(((DataRowView)表格控件.ExportBandView.GetRow(i))[采集样本_流量数据列名]);
                double Y = Convert.ToSingle(((DataRowView)表格控件.ExportBandView.GetRow(i))[采集样本_Y轴数据列名]);
                曲线X坐标对集合.Add(X);
                曲线Y坐标对集合.Add(Y);
            }

            for (int j = 0; j < 曲线控件.Graph.Plots.Count; j++)
            {
                if (曲线控件.Graph.Plots[j].Tag.ToString().Equals(需要进行绘制的曲线ID))
                {
                    曲线控件.Graph.Plots[j].PlotXY(曲线X坐标对集合.ToArray(), 曲线Y坐标对集合.ToArray());
                }
            }
        }
示例#6
0
        /// <summary>
        /// Add a graph to the collection using an array as the data source
        /// </summary>
        /// <param name="XYdata">double[,] array containing the data</param>
        /// <param name="nrPoints">Number of points used in the dataset</param>
        /// <param name="lineColor">Line color as System.Windows.Media.Color</param>
        /// <param name="name">Name string of the graph</param>
        /// <param name="drawLabel">Indicate whether this graph gets a label in the legend</param>
        /// <param name="drawCarets">Draw carets</param>
        /// <returns></returns>
        public int Add(double[,] XYdata, int nrPoints, Color lineColor, string name, bool drawLabel, bool drawCarets)
        {
            XYGraph graph = new XYGraph();

            if (XYdata != null)
            {
                graph.data = XYdata;
            }
            else
            {
                return(-1);
            }
            int dim1 = XYdata.GetLength(0);

            graph.nrpoints = dim1;
            if (nrPoints <= dim1 && nrPoints > 0)
            {
                graph.nrpoints = nrPoints;                                   //prevent the user from entering an incorrect number of points
            }
            graph.name = name;

            //allocate space for the int data buffer
            graph.intdata = new int[2 * graph.nrpoints];

            img.Source = wb;

            SolidColorBrush brush = new SolidColorBrush(lineColor);

            graph.drawlabel = drawLabel;

            graph.color = lineColor;

            graph.legendText.Text       = name + " ";
            graph.legendText.Foreground = brush;

            graph.draw_caret = drawCarets;

            AllGraphs.Add(graph);
            return(AllGraphs.Count);
        }
示例#7
0
        private void f_绘制临界点(XYGraph 曲线控件, string 需要进行绘制的曲线ID, string 采集样本_Y轴数据列名)
        {
            List <double> 曲线X坐标对集合 = new List <double>();
            List <double> 曲线Y坐标对集合 = new List <double>();

            曲线控件.汽蚀余量X轴 = 0;
            曲线控件.汽蚀余量Y轴 = 0;

            DataTable datatable汽蚀试验批次 = 数据库操作类.GetTable("汽蚀试验批次");

            foreach (DataRow dr in datatable汽蚀试验批次.Rows)
            {
                if (需要进行绘制的曲线ID.Equals(Convert.ToString(dr["批次编号"])))
                {
                    double 汽蚀余量 = Convert.ToDouble(dr["汽蚀余量"]);
                    double Y    = Convert.ToDouble(dr[采集样本_Y轴数据列名]);
                    曲线X坐标对集合.Add(汽蚀余量);
                    曲线Y坐标对集合.Add(Y);
                }
            }

            曲线控件.f_设置临界值(需要进行绘制的曲线ID, 曲线X坐标对集合, 曲线Y坐标对集合);
        }
示例#8
0
        private void f_绘制采集曲线(XYGraph 曲线控件, string 需要进行绘制的曲线ID, Grid 表格控件, string 采集样本_Y轴数据列名)
        {
            List <double> 曲线X坐标对集合 = new List <double>();
            List <double> 曲线Y坐标对集合 = new List <double>();

            曲线控件.汽蚀余量X轴 = 0;
            曲线控件.汽蚀余量Y轴 = 0;

            DataTable datatable汽蚀试验 = 数据库操作类.GetTableBySql("select * from 汽蚀试验 ORDER by 汽蚀余量 DESC");

            foreach (DataRow dr in datatable汽蚀试验.Rows)
            {
                if (需要进行绘制的曲线ID.Equals(Convert.ToString(dr["批次编号"])))
                {
                    double n流量   = Convert.ToDouble(dr["流量"]);
                    double n温度   = Convert.ToDouble(dr["温度"]);
                    double n进口表压 = Convert.ToDouble(dr["进口压力"]);
                    double 汽蚀余量  = Convert.ToDouble(dr["汽蚀余量"]);
                    double Y     = Convert.ToDouble(dr[采集样本_Y轴数据列名]);
                    曲线X坐标对集合.Add(汽蚀余量);
                    曲线Y坐标对集合.Add(Y);
                }
            }

            //显示曲线(曲线控件, 需要进行绘制的曲线ID);
            for (int j = 0; j < 曲线控件.Graph.Plots.Count; j++)
            {
                if ((曲线控件.Graph.Plots[j].Tag.ToString().Equals(需要进行绘制的曲线ID)) &&
                    ((曲线X坐标对集合.Count > 0) && (曲线Y坐标对集合.Count > 0)))
                {
                    曲线控件.Graph.Plots[j].Visible = true;
                    曲线控件.Graph.Plots[j].PlotXY(曲线X坐标对集合.ToArray(), 曲线Y坐标对集合.ToArray());
                    //曲线控件.f_设置汽蚀余量(需要进行绘制的曲线ID, 曲线汽蚀余量, 曲线X坐标对集合, 曲线Y坐标对集合);
                    f_绘制临界点(曲线控件, 需要进行绘制的曲线ID, 采集样本_Y轴数据列名);
                }
            }
        }
示例#9
0
 private void SetGraphXAxisRange(XYGraph graph, double start, double end)
 {
     graph.Invoke(new SetGraphXAxisRangeDelegate(SetGraphXAxisRangeHelper),
                  new Object[] { graph, start, end });
 }
示例#10
0
 private void SetGraphXAxisRangeHelper(XYGraph graph, double start, double end)
 {
     graph.XAxes[0].Range = new Range(start, end);
 }
示例#11
0
 private void SetGraphXAxisRangeHelper(XYGraph graph, double start, double end)
 {
     graph.XAxes[0].Range = new Range(start, end);
 }
示例#12
0
 private void SetGraphXAxisRange(XYGraph graph, double start, double end)
 {
     graph.Invoke(new SetGraphXAxisRangeDelegate(SetGraphXAxisRangeHelper),
         new Object[] { graph, start, end });
 }