VectorVisualizer Version 1.2
by Kevin Seib and Pascal Glaeser
Loading...
Searching...
No Matches
PlotForm.cs
Go to the documentation of this file.
1using System;
2using System.Drawing;
3using System.Windows.Forms;
4using ScottPlot;
5using ScottPlot.Colormaps;
6
8{
9 public partial class PlotForm : Form
10 {
11 public PlotForm(
12 double[,] data,
13 double xMin, double xMax,
14 double yMin, double yMax,
15 string? gradientText = null,
16 bool drawGradientVector = false,
17 double? px = null,
18 double? py = null)
19 {
20 InitializeComponent();
21
22 // Fenster
23 this.Text = "2D Skalarfeld Visualisierung";
24 this.Size = new Size(800, 600);
25 this.BackColor = System.Drawing.Color.FromArgb(33, 33, 33);
26
27 // Gradient-Panel vorbereiten (falls benötigt)
28 Panel? leftPanel = null;
29 if (!string.IsNullOrWhiteSpace(gradientText))
30 {
31 leftPanel = new Panel();
32 leftPanel.Dock = DockStyle.Fill;
33 leftPanel.Width = 200;
34 leftPanel.BackColor = System.Drawing.Color.FromArgb(33, 33, 33);
35
36 var gradientLabel = new System.Windows.Forms.Label();
37 gradientLabel.Text = gradientText;
38 gradientLabel.ForeColor = System.Drawing.Color.White;
39 gradientLabel.BackColor = System.Drawing.Color.FromArgb(33, 33, 33);
40 gradientLabel.AutoSize = true;
41 gradientLabel.Location = new Point(10, 20);
42 leftPanel.Controls.Add(gradientLabel);
43 }
44
45 // Plot erstellen
46 var formsPlot = new ScottPlot.WinForms.FormsPlot();
47 formsPlot.Dock = DockStyle.Fill;
48
49 var plt = formsPlot.Plot;
50 var heatmap = plt.Add.Heatmap(data);
51 plt.Title("f(x, y) als Heatmap");
52 plt.FigureBackground.Color = Colors.Black;
53 plt.DataBackground.Color = new ScottPlot.Color(33, 33, 33);
54 plt.Axes.Color(Colors.White);
55 plt.Axes.Left.Label.Text = "y";
56 plt.Axes.Bottom.Label.Text = "x";
57 plt.Axes.SetLimits(-25, 25, -25, 25);
58 heatmap.Position = new(-25, 25, -25, 25);
59
60 // Farblegende
61 heatmap.Colormap = new Turbo();
62 var bar = plt.Add.ColorBar(heatmap);
63 // Hauptlayout (Plot + Panel)
64 var mainLayout = new TableLayoutPanel();
65 mainLayout.Dock = DockStyle.Fill;
66 mainLayout.ColumnCount = 2;
67 mainLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 200));
68 mainLayout.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); // Plot
69
70 // Panel (nur falls vorhanden)
71 if (leftPanel != null)
72 mainLayout.Controls.Add(leftPanel, 0, 0);
73 else
74 mainLayout.ColumnStyles[0].Width = 0;
75
76 mainLayout.Controls.Add(formsPlot, 1, 0);
77 this.Controls.Add(mainLayout);
78
79 formsPlot.Refresh();
80 }
81
82 private void PlotForm_Load(object sender, EventArgs e)
83 {
84
85 }
86 }
87}
88
PlotForm(double[,] data, double xMin, double xMax, double yMin, double yMax, string? gradientText=null, bool drawGradientVector=false, double? px=null, double? py=null)
Definition PlotForm.cs:11