public CircleWindow() { viewModel = new PlotWindowModel(CanonicalDomain.Circular); DataContext = viewModel; InitializeComponent(); Settings.PlotGeomParams.hVertical = 0.5; Settings.PlotGeomParamsConstant.hVertical = 0.5; #if !HELP_FOR_GROUP_LEADER w = new Hydrodynamics_Sources.Potential(1, 0, 1, 0, new Hydrodynamics_Sources.Conformal_Maps.IdentityTransform()); s = new Hydrodynamics_Sources.CircleStreamLinesBuilder(w, viewModel); #endif mapsList.SelectionChanged += MapsList_SelectionChanged; #if !HELP_FOR_GROUP_LEADER mapsList.Items.Add("Тождественное отображение"); mapsList.Items.Add("Обтекание пластины"); mapsList.Items.Add("Профиль Жуковского"); #else mapsList.Items.Add("Help"); #endif mapsList.SelectedIndex = 0; viewModel.PlotModel.MouseMove += PlotModel_MouseMove; viewModel.PlotModel.MouseDown += PlotModel_MouseDown; plot.Controller = new PlotController(); plot.Controller.UnbindMouseDown(OxyMouseButton.Left); }
public ZoneWindow() { viewModel = new PlotWindowModel(CanonicalDomain.Zone); DataContext = viewModel; InitializeComponent(); Settings.PlotGeomParams.hVertical = 2 * Math.PI / 16.0; Settings.PlotGeomParamsConstant.hVertical = Settings.PlotGeomParams.hVertical; w = new Hydrodynamics_Sources.Potential(1, 0, 0, 0, new Hydrodynamics_Sources.Conformal_Maps.IdentityTransform()); s = new Hydrodynamics_Sources.HalfPlaneAndZoneStreamLinesBuilder(w, viewModel, CanonicalDomain.Zone); mapsList.SelectionChanged += MapsList_SelectionChanged; mapsList.Items.Add("Тождественное\nотображение"); mapsList.Items.Add("Плоскость с двумя\nотброшенными лучами"); mapsList.Items.Add("Диффузор"); mapsList.SelectedIndex = 0; viewModel.PlotModel.MouseMove += PlotModel_MouseMove; viewModel.PlotModel.MouseDown += PlotModel_MouseDown; plot.Controller = new PlotController(); plot.Controller.UnbindMouseDown(OxyMouseButton.Left); }
public HalfPlane() { viewModel = new PlotWindowModel(CanonicalDomain.HalfPlane); DataContext = viewModel; InitializeComponent(); Settings.PlotGeomParams.hVertical = 0.5; Settings.PlotGeomParamsConstant.hVertical = 0.5; w = new Hydrodynamics_Sources.Potential(1, 0, 0, 0, new Hydrodynamics_Sources.Conformal_Maps.IdentityTransform()); s = new Hydrodynamics_Sources.HalfPlaneAndZoneStreamLinesBuilder(w, viewModel, CanonicalDomain.HalfPlane); mapsList.SelectionChanged += MapsList_SelectionChanged; mapsList.Items.Add("Тождественное\nотображение"); mapsList.Items.Add("Треугольник 1"); mapsList.Items.Add("Полуплоскость с\nвыброшенным\nотрезком"); mapsList.Items.Add("Треугольник 2"); mapsList.Items.Add("Треугольник 3"); mapsList.Items.Add("Четырёхугольник 1"); mapsList.Items.Add("Полуплоскость с\nвыброшенным\nравнобедренным\nтреугольником"); mapsList.Items.Add("Треугольник 4"); mapsList.SelectedIndex = 0; viewModel.PlotModel.MouseMove += PlotModel_MouseMove; viewModel.PlotModel.MouseDown += PlotModel_MouseDown; plot.Controller = new PlotController(); plot.Controller.UnbindMouseDown(OxyMouseButton.Left); }
private void MapsList_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (mapsList.SelectedIndex) { #if !HELP_FOR_GROUP_LEADER case 0: w.f = new Hydrodynamics_Sources.Conformal_Maps.IdentityTransform(); break; case 1: w.f = new Hydrodynamics_Sources.Conformal_Maps.Plate(); break; case 2: w.f = new Hydrodynamics_Sources.Conformal_Maps.JoukowskiAirfoil(0, 0.05); break; #else case 0: Settings.PlotGeomParams.MRKh = 0.005; Settings.PlotGeomParams.hVertical = 0.05; wHelp = new Hydrodynamics_Sources.PotentialHelp(1, 1); s = new Hydrodynamics_Sources.StreamLinesBuilderForGroupLeader(wHelp, viewModel); break; #endif } Mouse.OverrideCursor = Cursors.Wait; ChangeParamsConfiguration(); s.Rebuild(); Mouse.OverrideCursor = Cursors.Arrow; PlotRefresh(); }
/// <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; } }