private void paramBox2_TextChanged(object sender, TextChangedEventArgs e) { if (w.f is Hydrodynamics_Sources.Conformal_Maps.EjectedRays) { angleSlider.ValueChanged -= angleSlider_ValueChanged; try { Mouse.OverrideCursor = Cursors.Wait; double tmp = Convert.ToDouble(TemporaryString(2)); if (tmp >= 90 && tmp <= 180) { (w.f as Hydrodynamics_Sources.Conformal_Maps.EjectedRays).a = tmp / 180.0; s.Rebuild(); PlotRefresh(); angleSlider.Value = tmp; } else { throw new FormatException(); } } catch { return; } finally { angleSlider.ValueChanged += angleSlider_ValueChanged; Mouse.OverrideCursor = Cursors.Arrow; } } if (w.f is Hydrodynamics_Sources.Conformal_Maps.Diffusor) { try { Mouse.OverrideCursor = Cursors.Wait; float tmp = Convert.ToSingle(TemporaryString(2)); if (tmp >= 0 && tmp <= 90) { Hydrodynamics_Sources.Conformal_Maps.Diffusor d = w.f as Hydrodynamics_Sources.Conformal_Maps.Diffusor; d.AngleDegrees = tmp; s.Rebuild(); PlotRefresh(); } else { throw new FormatException(); } } catch { return; } finally { Mouse.OverrideCursor = Cursors.Arrow; } } }
/// <summary> /// Метод, выполняющий рисование границы области /// </summary> /// <param name="s">Ссылка на объект, производный от абстрактного класса StreamLinesBuilder</param> public void DrawBorder(Hydrodynamics_Sources.StreamLinesBuilder s) { switch (s.Domain) { case CanonicalDomain.HalfPlane: switch (s.W.f.ToString()) { case "Porebrick": double h = (s.W.f as Hydrodynamics_Sources.Conformal_Maps.Porebrick).H; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(0, 0)); BorderPolyBottom.Points.Add(new DataPoint(0, h)); BorderPolyBottom.Points.Add(new DataPoint(6, h)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "IdentityTransform": BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "EjectedSegment": Hydrodynamics_Sources.Conformal_Maps.EjectedSegment tmp = s.W.f as Hydrodynamics_Sources.Conformal_Maps.EjectedSegment; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(tmp.X - PolygonLineHalfWidth, 0)); BorderPolyBottom.Points.Add(new DataPoint(tmp.X - PolygonLineHalfWidth, tmp.Y)); BorderPolyBottom.Points.Add(new DataPoint(tmp.X + PolygonLineHalfWidth, tmp.Y)); BorderPolyBottom.Points.Add(new DataPoint(tmp.X + PolygonLineHalfWidth, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "Number81": Hydrodynamics_Sources.Conformal_Maps.Number81 n = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Number81; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(-PolygonLineHalfWidth, 0)); BorderPolyBottom.Points.Add(new DataPoint(-PolygonLineHalfWidth, n.h)); BorderPolyBottom.Points.Add(new DataPoint(PolygonLineHalfWidth, n.h)); BorderPolyBottom.Points.Add(new DataPoint(PolygonLineHalfWidth, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "Number79": Hydrodynamics_Sources.Conformal_Maps.Number79 nn = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Number79; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, nn.h + 1)); BorderPolyBottom.Points.Add(new DataPoint(-6, nn.h + 6)); BorderPolyBottom.Points.Add(new DataPoint(6, nn.h + 6)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(0, -1)); BorderPolyBottom.Points.Add(new DataPoint(0, 1)); BorderPolyBottom.Points.Add(new DataPoint(6, 1)); BorderPolyBottom.Points.Add(new DataPoint(6, nn.h + 1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "Number89": Hydrodynamics_Sources.Conformal_Maps.Number89 ne = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Number89; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(-PolygonLineHalfWidth, 0)); BorderPolyBottom.Points.Add(new DataPoint(-PolygonLineHalfWidth, ne.h1)); BorderPolyBottom.Points.Add(new DataPoint(PolygonLineHalfWidth, ne.h1)); BorderPolyBottom.Points.Add(new DataPoint(PolygonLineHalfWidth, ne.h2)); BorderPolyBottom.Points.Add(new DataPoint(6, ne.h2)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "Triangle": Hydrodynamics_Sources.Conformal_Maps.Triangle nt = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Triangle; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, 0)); BorderPolyBottom.Points.Add(new DataPoint(-nt.A / 2.0, 0)); BorderPolyBottom.Points.Add(new DataPoint(0, nt.h)); BorderPolyBottom.Points.Add(new DataPoint(nt.A / 2.0, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, 0)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.Points.Add(new DataPoint(-6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "Number85": Hydrodynamics_Sources.Conformal_Maps.Number85 nc = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Number85; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(6, 0)); BorderPolyBottom.Points.Add(new DataPoint(-6 + PolygonLineHalfWidth, 0)); BorderPolyBottom.Points.Add(new DataPoint(-6 + PolygonLineHalfWidth, nc.H - PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(0, nc.H - PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(0, nc.H + PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(-6 - PolygonLineHalfWidth, nc.H + PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(-6 - PolygonLineHalfWidth, -1)); BorderPolyBottom.Points.Add(new DataPoint(6, -1)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; } BorderBottom.MouseDown += (sender, e) => { IsMouseClickedInPolygon = true; }; break; case CanonicalDomain.Zone: switch (s.W.f.ToString()) { case "IdentityTransform": BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, -Math.PI)); BorderPolyBottom.Points.Add(new DataPoint(6, -Math.PI)); BorderPolyBottom.Points.Add(new DataPoint(6, -6)); BorderPolyBottom.Points.Add(new DataPoint(-6, -6)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; BorderTop = new PolygonAnnotation(); BorderPolyTop.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyTop.Points.Add(new DataPoint(-6, Math.PI)); BorderPolyTop.Points.Add(new DataPoint(6, Math.PI)); BorderPolyTop.Points.Add(new DataPoint(6, 6)); BorderPolyTop.Points.Add(new DataPoint(-6, 6)); BorderPolyTop.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyTop.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); PlotModel.Annotations.Add(BorderPolyTop); break; case "EjectedRays": Hydrodynamics_Sources.Conformal_Maps.EjectedRays tmp = s.W.f as Hydrodynamics_Sources.Conformal_Maps.EjectedRays; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(tmp.l * Cos(tmp.Angle) - PolygonLineHalfWidth, tmp.l * Sin(tmp.Angle))); BorderPolyBottom.Points.Add(new DataPoint(tmp.l * Cos(tmp.Angle) + PolygonLineHalfWidth, tmp.l * Sin(tmp.Angle))); BorderPolyBottom.Points.Add(new DataPoint(100 * tmp.l * Cos(tmp.Angle) + PolygonLineHalfWidth, 100 * tmp.l * Sin(tmp.Angle))); BorderPolyBottom.Points.Add(new DataPoint(100 * tmp.l * Cos(tmp.Angle) - PolygonLineHalfWidth, 100 * tmp.l * Sin(tmp.Angle))); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; BorderTop = new PolygonAnnotation(); BorderPolyTop.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyTop.Points.Add(new DataPoint(tmp.l * Cos(tmp.Angle) - PolygonLineHalfWidth, -tmp.l * Sin(tmp.Angle))); BorderPolyTop.Points.Add(new DataPoint(tmp.l * Cos(tmp.Angle) + PolygonLineHalfWidth, -tmp.l * Sin(tmp.Angle))); BorderPolyTop.Points.Add(new DataPoint(100 * tmp.l * Cos(tmp.Angle) + PolygonLineHalfWidth, -100 * tmp.l * Sin(tmp.Angle))); BorderPolyTop.Points.Add(new DataPoint(100 * tmp.l * Cos(tmp.Angle) - PolygonLineHalfWidth, -100 * tmp.l * Sin(tmp.Angle))); BorderPolyTop.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyTop.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); PlotModel.Annotations.Add(BorderPolyTop); break; case "Diffusor": Hydrodynamics_Sources.Conformal_Maps.Diffusor db = s.W.f as Hydrodynamics_Sources.Conformal_Maps.Diffusor; if (db.AngleDegrees == 90) { BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, -db.H)); BorderPolyBottom.Points.Add(new DataPoint(0, -db.H)); BorderPolyBottom.Points.Add(new DataPoint(0, -5)); BorderPolyBottom.Points.Add(new DataPoint(-6, -5)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; BorderTop = new PolygonAnnotation(); BorderPolyTop.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyTop.Points.Add(new DataPoint(-6, db.H)); BorderPolyTop.Points.Add(new DataPoint(0, db.H)); BorderPolyTop.Points.Add(new DataPoint(0, 5)); BorderPolyTop.Points.Add(new DataPoint(-6, 5)); BorderPolyTop.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyTop.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); PlotModel.Annotations.Add(BorderPolyTop); } else { double angle = db.AngleDegrees * Math.PI / 180; BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-6, -db.H)); BorderPolyBottom.Points.Add(new DataPoint(0, -db.H)); BorderPolyBottom.Points.Add(new DataPoint(20, -db.H - 20 * Math.Tan(angle))); BorderPolyBottom.Points.Add(new DataPoint(-6, -5)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; BorderTop = new PolygonAnnotation(); BorderPolyTop.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyTop.Points.Add(new DataPoint(-6, db.H)); BorderPolyTop.Points.Add(new DataPoint(0, db.H)); BorderPolyTop.Points.Add(new DataPoint(20, db.H + 20 * Math.Tan(angle))); BorderPolyTop.Points.Add(new DataPoint(-6, 5)); BorderPolyTop.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyTop.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); PlotModel.Annotations.Add(BorderPolyTop); } break; } BorderBottom.MouseDown += (sender, e) => { IsMouseClickedInPolygon = true; }; BorderTop.MouseDown += (sender, e) => { IsMouseClickedInPolygon = true; }; break; case CanonicalDomain.Circular: switch (s.W.f.ToString()) { case "IdentityTransform": BorderBottom = new EllipseAnnotation(); EllipseBorder.Fill = Settings.PlotVisualParams.BorderFillColor; EllipseBorder.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; EllipseBorder.Stroke = Settings.PlotVisualParams.BorderStrokeColor; EllipseBorder.X = 0; EllipseBorder.Y = 0; EllipseBorder.Width = s.W.R * 2.0; EllipseBorder.Height = s.W.R * 2.0; PlotModel.Annotations.Add(EllipseBorder); break; case "Plate": BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; BorderPolyBottom.Points.Add(new DataPoint(-s.W.R, PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(s.W.R, PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(s.W.R, -PolygonLineHalfWidth)); BorderPolyBottom.Points.Add(new DataPoint(-s.W.R, -PolygonLineHalfWidth)); BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; case "JoukowskiAirfoil": BorderBottom = new PolygonAnnotation(); BorderPolyBottom.Fill = Settings.PlotVisualParams.BorderFillColor; for (double theta = 0; theta < 2 * Math.PI; theta += 0.001) { BorderPolyBottom.Points.Add(s.W.f.z(s.W.R * Exp(Complex.I * theta))); } BorderPolyBottom.StrokeThickness = Settings.PlotVisualParams.BorderStrokeThickness; BorderPolyBottom.Stroke = Settings.PlotVisualParams.BorderStrokeColor; PlotModel.Annotations.Add(BorderPolyBottom); break; } BorderBottom.MouseDown += (sender, e) => { IsMouseClickedInPolygon = true; }; break; } }