private void btnRecalcular_Click(object sender, EventArgs e) { List <double> lstQ = new List <double>(); List <double> lsth = new List <double>(); double n = (double)numRugosidade.Value; double S = (double)numInclinacao.Value; double[] x = lstProfile.Keys.ToArray(); double[] y = lstProfile.Values.ToArray(); double hMax = y[0], hMin = y[0]; for (int k = 0; k < y.Length; k++) { hMax = Math.Max(hMax, y[k]); hMin = Math.Min(hMin, y[k]); } List <double> lstH = new List <double>(); double curH = hMin; double hStep = (hMax - hMin) / NDIVSCURVAQ; while (curH < hMax) { double[] sols = AreaPerimeter.Solve(lstProfile, curH); if ((sols.Length & 1) == 0) { double[] start = new double[sols.Length >> 1]; double[] stop = new double[sols.Length >> 1]; for (int k = 0; k < start.Length; k++) { start[k] = sols[(k << 1)]; stop[k] = sols[1 + (k << 1)]; } double a, p; a = AreaPerimeter.GetArea(lstProfile, curH, start, stop, out p); lsth.Add(curH); lstQ.Add(Manning(a, p, S, n)); } curH += hStep; } //Graphs zedCurvaVazao.GraphPane.CurveList.Clear(); zedCurvaVazao.GraphPane.AddCurve("", lstQ.ToArray(), lsth.ToArray(), Color.Black, ZedGraph.SymbolType.None); zedCurvaVazao.AxisChange(); zedCurvaVazao.Refresh(); }
private void DesenhaPerfil() { zedPerfil.GraphPane.CurveList.Clear(); zedPerfil.GraphPane.GraphObjList.Clear(); double h = (double)numH.Value; double[] sols = AreaPerimeter.Solve(lstProfile, h); if (sols.Length % 2 == 0) { double[] start = new double[sols.Length >> 1]; double[] stop = new double[sols.Length >> 1]; double totalLength = 0; for (int k = 0; k < sols.Length; k += 2) { start[k >> 1] = sols[k]; stop[k >> 1] = sols[k + 1]; totalLength += sols[k + 1] - sols[k]; double[] xx = new double[] { sols[k], sols[k + 1] }; double[] yy = new double[] { h, h }; //ZedGraph.LineItem li3 = zedPerfil.GraphPane.AddCurve(k == 0 ? "Nível de água" : "", xx, yy, Color.LightBlue, ZedGraph.SymbolType.None); ZedGraph.LineItem li3 = zedPerfil.GraphPane.AddCurve(k == 0 ? "Water level" : "", xx, yy, Color.LightBlue, ZedGraph.SymbolType.None); li3.Line.Width = 3; } double p2; double area = AreaPerimeter.GetArea(lstProfile, h, start, stop, out p2); lblArea.Text = Math.Round(area, 3).ToString(); lblPerim.Text = Math.Round(p2, 3).ToString(); lblSurfLen.Text = Math.Round(totalLength, 3).ToString(); } #region Graficos double[] x = lstProfile.Keys.ToArray(); double[] y = lstProfile.Values.ToArray(); ZedGraph.LineItem li = zedPerfil.GraphPane.AddCurve("", x, y, Color.SandyBrown); li.Line.Width = 3; double[] xNivel = new double[] { 10, 20 }; double[] yNivel = new double[] { -1, -1 }; //ZedGraph.LineItem li2 = zedPerfil.GraphPane.AddCurve("", xNivel, yNivel, Color.LightBlue); //, ZedGraph.SymbolType.None); //li2.Line.Fill = new ZedGraph.Fill(Color.Blue, Color.Blue, 45F); List <ZedGraph.PointD> lstPt = new List <ZedGraph.PointD>(); lstPt.Add(new ZedGraph.PointD(2, -1)); lstPt.Add(new ZedGraph.PointD(8, -1)); lstPt.Add(new ZedGraph.PointD(9, -3)); lstPt.Add(new ZedGraph.PointD(0, -3.5)); ZedGraph.PolyObj pObj = new ZedGraph.PolyObj(lstPt.ToArray(), Color.LightBlue, Color.Blue, Color.Blue); //zedPerfil.GraphPane.GraphObjList.Add(pObj); zedPerfil.AxisChange(); zedPerfil.Refresh(); #endregion }