PlantSchemeWindow: Expand graph

This commit is contained in:
2026-07-12 22:26:08 +02:00
parent a3a0504c11
commit 791ee7b804
12 changed files with 129 additions and 25 deletions
+12 -2
View File
@@ -10,10 +10,12 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
public Pipe CreatePipe(INode start, INode end) {
public Pipe CreatePipe(INode start, INode end, bool verticalFirst = false) {
Nodes.Add(start);
Nodes.Add(end);
var p = new Pipe(start, end);
var p = new Pipe(start, end, verticalFirst);
start.Outputs.Add(p);
end.Inputs.Add(p);
Edges.Add(p);
return p;
}
@@ -27,5 +29,13 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
}
}
public void Update(double x, double y) {
foreach (var e in Edges) {
e.Update(x, y);
}
foreach (var n in Nodes) {
n.Update(x, y);
}
}
}
}
@@ -8,6 +8,7 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool Orientation { get; }
public void Draw(Canvas canvas);
public bool Update(double x, double y);
}
}
@@ -6,8 +6,11 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterX { get; }
public double CenterY { get; }
public string Label { get; }
public ISet<IEdge> Inputs { get; }
public ISet<IEdge> Outputs { get; }
public void Draw(Canvas canvas);
public bool Update(double x, double y);
}
}
+4
View File
@@ -56,5 +56,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
canvas.Children.Add(a2);
canvas.Children.Add(b2);
}
public bool Update(double x, double y) {
return false;
}
}
}
@@ -9,9 +9,15 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterY { get; set; }
public string Label { get; } = "";
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public PipeJoin(double x, double y) {
CenterX = x;
CenterY = y;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
@@ -24,5 +30,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
e.SetValue(Canvas.TopProperty, CenterY - 9);
canvas.Children.Add(e);
}
public bool Update(double x, double y) {
return false;
}
}
}
+10
View File
@@ -7,14 +7,24 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterY { get; set; }
public string Label { get; set; }
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
public Pump(string label, double x, double y) {
CenterX = x;
CenterY = y;
Label = label;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
}
public bool Update(double x, double y) {
return false;
}
}
}
+9
View File
@@ -9,6 +9,9 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool IsFull => CallbackIsFull();
public bool IsFilled => CallbackIsFilled();
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
protected Func<bool> CallbackIsFilled;
protected Func<bool> CallbackIsFull;
@@ -18,10 +21,16 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
Label = label;
CallbackIsFilled = cbFilled;
CallbackIsFull = cbFull;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
}
public bool Update(double x, double y) {
return false;
}
}
}
@@ -7,6 +7,8 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public double CenterY { get; set; }
public string Label { get; set; }
public bool IsFilled => CallbackIsFilled();
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
protected Func<bool> CallbackIsFilled;
@@ -15,10 +17,16 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
CenterY = y;
Label = label;
CallbackIsFilled = cbFilled;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
}
public bool Update(double x, double y) {
return false;
}
}
}
+16 -4
View File
@@ -11,29 +11,41 @@ namespace PamhagenSysCtrl.Helpers.Pipeline {
public bool IsOpen => CallbackIsOpen();
public bool WantOpen => CallbackWantOpen();
public ISet<IEdge> Inputs { get; init; }
public ISet<IEdge> Outputs { get; init; }
protected Func<bool> CallbackIsOpen;
protected Func<bool> CallbackWantOpen;
private Ellipse Me;
public Valve(string label, double x, double y, Func<bool> cbOpen, Func<bool> cbWant) {
CenterX = x;
CenterY = y;
Label = label;
CallbackIsOpen = cbOpen;
CallbackWantOpen = cbWant;
Inputs = new HashSet<IEdge>();
Outputs = new HashSet<IEdge>();
}
public void Draw(Canvas canvas) {
var e = new Ellipse() {
Me = new Ellipse() {
Height = 20,
Width = 20,
Fill = Brushes.Gray,
Stroke = Brushes.Black,
StrokeThickness = 2,
};
e.SetValue(Canvas.LeftProperty, CenterX - 10);
e.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(e);
Me.SetValue(Canvas.LeftProperty, CenterX - 10);
Me.SetValue(Canvas.TopProperty, CenterY - 10);
canvas.Children.Add(Me);
}
public bool Update(double x, double y) {
var hover = Math.Sqrt(Math.Pow(CenterX - x, 2) + Math.Pow(CenterY - y, 2)) <= 10;
Me.Fill = hover ? Brushes.LightGray : Brushes.Gray;
return hover;
}
}
}