public void SinROverR3D(DataSeries ds, ChartStyle cs) { cs.XMin = -8; cs.XMax = 8; cs.YMin = -8; cs.YMax = 8; cs.ZMin = -0.5f; cs.ZMax = 1; cs.XTick = 4; cs.YTick = 4; cs.ZTick = 0.5f; ds.XDataMin = cs.XMin; ds.YDataMin = cs.YMin; ds.XSpacing = 0.5f; ds.YSpacing = 0.5f; ds.XNumber = Convert.ToInt16((cs.XMax - cs.XMin) / ds.XSpacing) + 1; ds.YNumber = Convert.ToInt16((cs.YMax - cs.YMin) / ds.YSpacing) + 1; Point3[,] pts = new Point3[ds.XNumber, ds.YNumber]; for (int i = 0; i < ds.XNumber; i++) { for (int j = 0; j < ds.YNumber; j++) { float x = ds.XDataMin + i * ds.XSpacing; float y = ds.YDataMin + j * ds.YSpacing; float r = (float)Math.Sqrt(x * x + y * y) + 0.000001f; float z = (float)Math.Sin(r) / r; pts[i, j] = new Point3(x, y, z, 1); } } ds.PointArray = pts; }
public void Line3D(DataSeries ds, ChartStyle cs) { cs.XMin = -1f; cs.XMax = 1f; cs.YMin = -1f; cs.YMax = 1f; cs.ZMin = 0; cs.ZMax = 30; cs.XTick = 0.5f; cs.YTick = 0.5f; cs.ZTick = 5; ds.XDataMin = cs.XMin; ds.YDataMin = cs.YMin; ds.XSpacing = 0.3f; ds.YSpacing = 0.3f; ds.XNumber = Convert.ToInt16((cs.XMax - cs.XMin) / ds.XSpacing) + 1; ds.YNumber = Convert.ToInt16((cs.YMax - cs.YMin) / ds.YSpacing) + 1; ds.PointList.Clear(); for (int i = 0; i < 300; i++) { float t = 0.1f * i; float x = (float)Math.Exp(-t / 30) * (float)Math.Cos(t); float y = (float)Math.Exp(-t / 30) * (float)Math.Sin(t); float z = t; ds.AddPoint(new Point3(x, y, z, 1)); } }
public void AddChartStyle2D(Graphics g, ChartStyle cs3d) { Pen aPen = new Pen(Color.Black, 1f); SizeF tickFontSize = g.MeasureString("A", cs3d.TickFont); // Create vertical gridlines: float fX, fY; if (cs3d.IsYGrid == true) { aPen = new Pen(cs3d.GridStyle.LineColor, 1f); aPen.DashStyle = cs3d.GridStyle.Pattern; for (fX = cs3d.XMin + cs3d.XTick; fX < cs3d.XMax; fX += cs3d.XTick) { g.DrawLine(aPen, Point2D(new PointF(fX, cs3d.YMin), cs3d), Point2D(new PointF(fX, cs3d.YMax), cs3d)); } } // Create horizontal gridlines: if (cs3d.IsXGrid == true) { aPen = new Pen(cs3d.GridStyle.LineColor, 1f); aPen.DashStyle = cs3d.GridStyle.Pattern; for (fY = cs3d.YMin + cs3d.YTick; fY < cs3d.YMax; fY += cs3d.YTick) { g.DrawLine(aPen, Point2D(new PointF(cs3d.XMin, fY), cs3d), Point2D(new PointF(cs3d.XMax, fY), cs3d)); } } // Create the x-axis tick marks: for (fX = cs3d.XMin; fX <= cs3d.XMax; fX += cs3d.XTick) { PointF yAxisPoint = Point2D(new PointF(fX, cs3d.YMin), cs3d); g.DrawLine(Pens.Black, yAxisPoint, new PointF(yAxisPoint.X, yAxisPoint.Y - 5f)); } // Create the y-axis tick marks: for (fY = cs3d.YMin; fY <= cs3d.YMax; fY += cs3d.YTick) { PointF xAxisPoint = Point2D(new PointF(cs3d.XMin, fY), cs3d); g.DrawLine(Pens.Black, xAxisPoint, new PointF(xAxisPoint.X + 5f, xAxisPoint.Y)); } aPen.Dispose(); }
public PointF Point2D(PointF pt, ChartStyle cs3d) { PointF aPoint = new PointF(); if (pt.X < cs3d.XMin || pt.X > cs3d.XMax || pt.Y < cs3d.YMin || pt.Y > cs3d.YMax) { pt.X = Single.NaN; pt.Y = Single.NaN; } aPoint.X = (pt.X - cs3d.XMin) * form1.PlotPanel.Width / (cs3d.XMax - cs3d.XMin); aPoint.Y = form1.PlotPanel.Height - (pt.Y - cs3d.YMin) * form1.PlotPanel.Height / (cs3d.YMax - cs3d.YMin); return(aPoint); }
public Form1_jack_xu() { InitializeComponent(); this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true); this.SetStyle(ControlStyles.ResizeRedraw, true); this.BackColor = Color.White; // Subscribing to a paint eventhandler to drawingPanel: PlotPanel.Paint += new PaintEventHandler(PlotPanelPaint); cs = new ChartStyle(this); cs2d = new ChartStyle2D(this); ds = new DataSeries(); dc = new DrawChart(this); cf = new ChartFunctions(); cm = new ColorMap(); cs.GridStyle.LineColor = Color.LightGray; cs.GridStyle.Pattern = DashStyle.Dash; cs.Title = "No Title"; cs.IsColorBar = true; cs2d.ChartBackColor = Color.White; cs2d.ChartBorderColor = Color.Black; ds.LineStyle.IsVisible = false; ds.BarStyle.XLength = 0.3f; ds.BarStyle.YLength = 0.3f; ds.BarStyle.IsBarSingleColor = false; ds.BarStyle.ZOrigin = 0; dc.ChartType = DrawChart.ChartTypeEnum.Slice; //dc.IsColorMap = true; dc.IsHiddenLine = false; //dc.IsInterp = true; dc.NumberInterp = 5; dc.CMap = cm.Jet(); dc.NumberContours = 15; dc.XYZSlice = DrawChart.SliceEnum.ZSlice; dc.SliceLocation = 1; //dc.IsBarSingleColor = false; }
public void Exp4D(DataSeries ds, ChartStyle cs) { cs.XMin = -2; cs.XMax = 2; cs.YMin = -2; cs.YMax = 2; cs.ZMin = -2; cs.ZMax = 2; cs.XTick = 1; cs.YTick = 1; cs.ZTick = 1; ds.XDataMin = cs.XMin; ds.YDataMin = cs.YMin; ds.ZZDataMin = cs.ZMin; ds.XSpacing = 0.1f; ds.YSpacing = 0.1f; ds.ZSpacing = 0.1f; ds.XNumber = Convert.ToInt16((cs.XMax - cs.XMin) / ds.XSpacing) + 1; ds.YNumber = Convert.ToInt16((cs.YMax - cs.YMin) / ds.YSpacing) + 1; ds.ZNumber = Convert.ToInt16((cs.ZMax - cs.ZMin) / ds.ZSpacing) + 1; Point4[, ,] pts = new Point4[ds.XNumber, ds.YNumber, ds.ZNumber]; for (int i = 0; i < ds.XNumber; i++) { for (int j = 0; j < ds.YNumber; j++) { for (int k = 0; k < ds.ZNumber; k++) { float x = ds.XDataMin + i * ds.XSpacing; float y = ds.YDataMin + j * ds.YSpacing; float z = cs.ZMin + k * ds.ZSpacing; float v = z * (float)Math.Exp(-x * x - y * y - z * z); pts[i, j, k] = new Point4(new Point3(x, y, z, 1), v); } } } ds.Point4Array = pts; }
private void AddLabels(Graphics g, ChartStyle cs3d) { float xOffset = ChartArea.Width / 30.0f; float yOffset = ChartArea.Height / 30.0f; SizeF labelFontSize = g.MeasureString("A", cs3d.LabelFont); SizeF titleFontSize = g.MeasureString("A", cs3d.TitleFont); SizeF tickFontSize = g.MeasureString("A", cs3d.TickFont); SolidBrush aBrush = new SolidBrush(cs3d.TickColor); StringFormat sFormat = new StringFormat(); // Create the x-axis tick marks: aBrush = new SolidBrush(cs3d.TickColor); for (float fX = cs3d.XMin; fX <= cs3d.XMax; fX += cs3d.XTick) { PointF yAxisPoint = Point2D(new PointF(fX, cs3d.YMin), cs3d); sFormat.Alignment = StringAlignment.Far; SizeF sizeXTick = g.MeasureString(fX.ToString(), cs3d.TickFont); g.DrawString(fX.ToString(), cs3d.TickFont, aBrush, new PointF(yAxisPoint.X + sizeXTick.Width / 2 + form1.PlotPanel.Left, yAxisPoint.Y + 4f + form1.PlotPanel.Top), sFormat); } // Create the y-axis tick marks: for (float fY = cs3d.YMin; fY <= cs3d.YMax; fY += cs3d.YTick) { PointF xAxisPoint = Point2D(new PointF(cs3d.XMin, fY), cs3d); sFormat.Alignment = StringAlignment.Far; g.DrawString(fY.ToString(), cs3d.TickFont, aBrush, new PointF(xAxisPoint.X - 3f + form1.PlotPanel.Left, xAxisPoint.Y - tickFontSize.Height / 2 + form1.PlotPanel.Top), sFormat); } // Add horizontal axis label: aBrush = new SolidBrush(cs3d.LabelColor); SizeF stringSize = g.MeasureString(cs3d.XLabel, cs3d.LabelFont); g.DrawString(cs3d.XLabel, cs3d.LabelFont, aBrush, new Point(form1.PlotPanel.Left + form1.PlotPanel.Width / 2 - (int)stringSize.Width / 2, ChartArea.Bottom - (int)yOffset - (int)labelFontSize.Height)); // Add y-axis label: sFormat.Alignment = StringAlignment.Center; stringSize = g.MeasureString(cs3d.YLabel, cs3d.LabelFont); // Save the state of the current Graphics object GraphicsState gState = g.Save(); g.TranslateTransform(xOffset, yOffset + titleFontSize.Height + yOffset / 3 + form1.PlotPanel.Height / 2); g.RotateTransform(-90); g.DrawString(cs3d.YLabel, cs3d.LabelFont, aBrush, 0, 0, sFormat); // Restore it: g.Restore(gState); // Add title: aBrush = new SolidBrush(cs3d.TitleColor); stringSize = g.MeasureString(cs3d.Title, cs3d.TitleFont); if (cs3d.Title.ToUpper() != "NO TITLE") { g.DrawString(cs3d.Title, cs3d.TitleFont, aBrush, new Point(form1.PlotPanel.Left + form1.PlotPanel.Width / 2 - (int)stringSize.Width / 2, ChartArea.Top + (int)yOffset)); } aBrush.Dispose(); }
public void Peak3D(DataSeries ds, ChartStyle cs) { /* * * cs.XMin = -1; * cs.XMax = 1; * cs.YMin = -1; * cs.YMax = 1; * cs.ZMin = -1; * cs.ZMax = 1; * cs.XTick = 1; * cs.YTick = 1; * cs.ZTick = 1; * * //cs.XMin = -1; * //cs.XMax = 1; * //cs.YMin = -1; * //cs.YMax = 1; * //cs.ZMin = -1; * //cs.ZMax = 1; * //cs.XTick = 1; * //cs.YTick = 1; * //cs.ZTick = 1; * * ds.XDataMin = cs.XMin; * ds.YDataMin = cs.YMin; * ds.XSpacing = 1;// 0.3f; * ds.YSpacing = 1;// 0.3f; * ds.XNumber = Convert.ToInt16((cs.XMax - cs.XMin) / ds.XSpacing) + 1; * ds.YNumber = Convert.ToInt16((cs.YMax - cs.YMin) / ds.YSpacing) + 1; * * Point3[,] pts = new Point3[ds.XNumber, ds.YNumber]; * for (int i = 0; i < ds.XNumber; i++) * { * for (int j = 0; j < ds.YNumber; j++) * { * float x = ds.XDataMin + i * ds.XSpacing; * float y = ds.YDataMin + j * ds.YSpacing; * /* * double zz = 3 * Math.Pow((1 - x), 2) * Math.Exp(-x * x - * (y + 1) * (y + 1)) - 10 * (0.2 * x - Math.Pow(x, 3) - * Math.Pow(y, 5)) * Math.Exp(-x * x - y * y) - * 1 / 3 * Math.Exp(-(x + 1) * (x + 1) - y * y); */ /* * double zz = Math.Pow(x, 2) + Math.Pow(y, 2); * float z = (float)zz; * * * pts[i, j] = new Point3(x, y, z, 1); * } * } * * //==========================Contour demo code added====================// * // */ /* * * int[,] X = new int[6, 4]; * int[,] Y = new int[6, 4]; * int[,] Z = new int[6, 4]; * * cs.XMin = -4; * cs.XMax = 2; * cs.YMin = -2; * cs.YMax = 3; * //cs.ZMin = -1; * //cs.ZMax = 1; * cs.XTick = 1; * cs.YTick = 1; * // cs.ZTick = 1; * * X[0, 0] = -4; * X[1, 0] = -4; * X[2, 0] = -4; * X[3, 0] = -4; * X[4, 0] = -4; * X[5, 0] = -4; * * X[0, 1] = -2; * X[1, 1] = -2; * X[2, 1] = -2; * X[3, 1] = -2; * X[4, 1] = -2; * X[5, 1] = -2; * * X[0, 2] = 0; * X[1, 2] = 0; * X[2, 2] = 0; * X[3, 2] = 0; * X[4, 2] = 0; * X[5, 2] = 0; * * X[0, 3] = 2; * X[1, 3] = 2; * X[2, 3] = 2; * X[3, 3] = 2; * X[4, 3] = 2; * X[5, 3] = 2; * * * Y[0, 0] = -2; * Y[1, 0] = -1; * Y[2, 0] = 0; * Y[3, 0] = 1; * Y[4, 0] = 2; * Y[5, 0] = 3; * * * * Y[0, 1] = -2; * Y[1, 1] = 1; * Y[2, 1] = 0; * Y[3, 1] = 1; * Y[4, 1] = 2; * Y[5, 1] = 3; * * * Y[0, 2] = -2; * Y[1, 2] = 1; * Y[2, 2] = 0; * Y[3, 2] = 1; * Y[4, 2] = 2; * Y[5, 2] = 3; * * Y[0, 3] = -2; * Y[1, 3] = 1; * Y[2, 3] = 0; * Y[3, 3] = 1; * Y[4, 3] = 2; * Y[5, 3] = 3; * * * * Z[0, 0] = 20; * Z[1, 0] = 17; * Z[2, 0] = 16; * Z[3, 0] = 17; * Z[4, 0] = 20; * Z[5, 0] = 25; * * Z[0, 1] = 8; * Z[1, 1] = 5; * Z[2, 1] = 4; * Z[3, 1] = 5; * Z[4, 1] = 8; * Z[5, 1] = 13; * * * Z[0, 2] = 4; * Z[1, 2] = 1; * Z[2, 2] = 0; * Z[3, 2] = 1; * Z[4, 2] = 4; * Z[5, 2] = 9; * * Z[0, 3] = 8; * Z[1, 3] = 5; * Z[2, 3] = 4; * Z[3, 3] = 5; * Z[4, 3] = 8; * Z[5, 3] = 13; * * * Point3[,] pts = new Point3[4, 6]; * * for (int i = 0; i <4; i++) * { * for (int j = 0; j <6; j++) * { * //pts[i, j].X = X[i, j]; * //pts[i, j].Y = Y[i, j]; * //pts[i, j].Z = Z[i, j]; * pts[i, j] = new Point3(X[j,i], Y[j,i], Z[j,i], 1); * * } * } * */ // if (pts.Length == 0) { } //=====================End of the contour demo code==================// //==First calling the data in WFA_PH_Demo Project //WFA_PH_Demo ///* cs.XMin = 0; cs.XMax = 4000; cs.YMin = 0; cs.YMax = 100; cs.ZMin = 0; cs.ZMax = 1; cs.XTick = 500; cs.YTick = 10; cs.ZTick = 1; ds.XDataMin = cs.XMin; ds.YDataMin = cs.YMin; ds.XSpacing = 1; // 0.3f; ds.YSpacing = 1; // 0.3f; // WFA_PH_CurveDemo.Form1 f1 = new WFA_PH_CurveDemo.Form1(); // f1.PlotPHChart("Water");//This will call the function required // MessageBox.Show("We are here inside peak 3d so "); // MessageBox.Show("Read finish excel file"); // f1.DataPullFunctionForCoolProp("water");//n-Propane //ExcellDataPull ex = new ExcellDataPull(); //ex.ExcellData(); Point3[,] pts = new Point3[300, 300]; /* * for (int i = 0; i < f1.P_Value.GetLength(0); i++) * { * for (int j = 0; j <f1.P_Value.GetLength(1); j++) * { * //pts[i, j].X = X[i, j]; * //pts[i, j].Y = Y[i, j]; * //pts[i, j].Z = Z[i, j]; * pts[i, j] = new Point3((int)f1.H_Value[j,i], (int)f1.P_Value[j, i], (int)f1.T_Value[j, i], 1); * //pts[i, j] = new Point3((int)f1.H_Value[i ,j], (int)f1.P_Value[i, j], (int)f1.T_Value[i, j], 1); * //pts[i, j] = new Point3( (float)f1.P_Value[i, j], (float)ex.h_list_Value[i,j], (float)f1.T_Value[i, j], 1); * //pts[i, j] = new Point3( (float)ex.h_list_Value[i, j], (float)f1.P_Value[j, i], (float)f1.T_Value[j, i], 1); * * } * } * int lastValue =(int) f1.P_Value[299, 299]; * * * */ ds.PointArray = pts; }