diff --git a/SchematicDrawing/Graph.cs b/SchematicDrawing/Graph.cs index 05cd6421b..ad6924d77 100644 --- a/SchematicDrawing/Graph.cs +++ b/SchematicDrawing/Graph.cs @@ -9,6 +9,8 @@ namespace SchematicDrawing { public class Graph { + public bool Completed; + IList nodes; GNode startNode; int secondaryStartNodesCount; @@ -22,6 +24,7 @@ namespace SchematicDrawing startNode = null; secondaryStartNodesCount = 0; minHeap = new MinHeap(); + Completed = false; } public void Clear() @@ -29,6 +32,7 @@ namespace SchematicDrawing nodes.Clear(); startNode = null; secondaryStartNodesCount = 0; + Completed = false; } /// diff --git a/SchematicDrawing/Pipe.cs b/SchematicDrawing/Pipe.cs index 3dafd908d..68e80cc06 100644 --- a/SchematicDrawing/Pipe.cs +++ b/SchematicDrawing/Pipe.cs @@ -14,6 +14,11 @@ namespace SchematicDrawing public int EndNodeId; public Sz Sz; + public bool CoordinatesAreValid; + public int x1, y1, x2, y2; + public bool HasIntersection; + public float P; + public Pipe(IDrawingItem startItem, int startNodeId, IDrawingItem endItem, int endNodeId, Sz sz) { @@ -22,12 +27,16 @@ namespace SchematicDrawing EndItem = endItem; EndNodeId = endNodeId; Sz = sz; + CoordinatesAreValid = false; + HasIntersection = false; } public Pipe(string pipeStr, Sz sz, Dictionary name2Item) { String2Items(pipeStr, name2Item, out StartItem, out StartNodeId, out EndItem, out EndNodeId); Sz = sz; + CoordinatesAreValid = false; + HasIntersection = false; } public override string ToString() @@ -44,7 +53,7 @@ namespace SchematicDrawing /// End point X /// End point Y /// true when calculation successful - public bool GetCoordinates(out int x1, out int y1, out int x2, out int y2) + public bool GetCoordinates() { DrawingShape startDShape = DrawingShape.GetDrawingShape(StartItem); DrawingShape endDShape = DrawingShape.GetDrawingShape(EndItem); @@ -58,17 +67,16 @@ namespace SchematicDrawing y1 = StartItem.Y + startNode.Y * Const.GridSize; x2 = EndItem.X + endNode.X * Const.GridSize; y2 = EndItem.Y + endNode.Y * Const.GridSize; + CoordinatesAreValid = true; return true; } else { - x1 = y1 = x2 = y2 = 0; return false; } } - /// /// Converts pipe string to start and end items /// @@ -101,5 +109,37 @@ namespace SchematicDrawing endNid = 0; return false; } + + /// + /// Returns true when two pipes have an intersection + /// + /// Second pipe + /// true when ipes intersect + public bool CalculateIntersectionWith(Pipe pipe2) + { + if (!this.CoordinatesAreValid) GetCoordinates(); + if (!pipe2.CoordinatesAreValid) pipe2.GetCoordinates(); + + int D = (x2 - x1) * (pipe2.y2 - pipe2.y1) - (y2 - y1) * (pipe2.x2 - pipe2.x1); + float Dp = Convert.ToSingle((pipe2.x1 - x1) * (pipe2.y2 - pipe2.y1) - (pipe2.y1 - y1) * (pipe2.x2 - pipe2.x1)); + float Dq = Convert.ToSingle((x2 - x1) * (pipe2.y1 - y1) - (y2 - y1) * (pipe2.x1 - x1)); + + if (D == 0) + { + return false; /// Parallel pipes -> no intersection + } + + float Df = Convert.ToSingle(D); + float p = Dp / Df; + float q = -Dq / Df; + if (p > 0.01 && p < 0.99 && q > 0.01 && q < 0.99) + { + this.HasIntersection = true; + this.P = p; + return true; /// Pipes intersect, pipes touching by their ends are not considered + } + + return false; /// Pipes do not intersect + } } } diff --git a/SchematicDrawing/SchematicDrawingCtrl.cs b/SchematicDrawing/SchematicDrawingCtrl.cs index 51d3755f1..5998af8fd 100644 --- a/SchematicDrawing/SchematicDrawingCtrl.cs +++ b/SchematicDrawing/SchematicDrawingCtrl.cs @@ -19,7 +19,18 @@ namespace SchematicDrawing private bool supressRedraws; public bool SupressRedraws { - set { if (supressRedraws != value) { supressRedraws = value; Redraw(); } } + set + { + if (supressRedraws != value) + { + supressRedraws = value; + if (!supressRedraws) + { + JoinPipeListsEtc(); + Redraw(); + } + } + } get { return supressRedraws; } } @@ -89,12 +100,16 @@ namespace SchematicDrawing Pen[] pensDry; Pen[] pensWater; Pen[] pensVacuum; + Pen[] pensDryBackgr; + Pen[] pensWaterBackgr; + Pen[] pensVacuumBackgr; Pen[] pensHighlighted; IList pipesS; IList pipesM; IList pipesL; IList pipesXL; + IList allPipes; /// public string[] PipesS { @@ -107,24 +122,20 @@ namespace SchematicDrawing pipesS.Clear(); if (value != null) { - foreach (var p in value) + foreach (var pStr in value) { - Pipe pi = new Pipe(p, Sz.S, Name2Item); - pipesS.Add(pi); - - if (!EditMode && pi.StartItem != null && pi.StartItem.GNodes.Count > pi.StartNodeId && - pi.EndItem != null && pi.EndItem.GNodes.Count > pi.EndNodeId) - { - int x1, y1, x2, y2; - int dist = pi.GetCoordinates(out x1, out y1, out x2, out y2) ? (int)Math.Round(Math.Sqrt((double)((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))) : 1; - graph.AddEdge(pi.StartItem.GNodes[pi.StartNodeId], pi.EndItem.GNodes[pi.EndNodeId], dist); - graph.AddEdge(pi.EndItem.GNodes[pi.EndNodeId], pi.StartItem.GNodes[pi.StartNodeId], dist); - } + pipesS.Add(new Pipe(pStr, Sz.S, Name2Item)); } } - Redraw(); - } + + if (!supressRedraws) + { + JoinPipeListsEtc(); + Redraw(); + } + } } + /// public string[] PipesM { get @@ -138,24 +149,20 @@ namespace SchematicDrawing pipesM.Clear(); if (value != null) { - foreach (var p in value) + foreach (var pStr in value) { - Pipe pi = new Pipe(p, Sz.M, Name2Item); - pipesM.Add(pi); - - if (!EditMode && pi.StartItem != null && pi.StartItem.GNodes.Count > pi.StartNodeId && - pi.EndItem != null && pi.EndItem.GNodes.Count > pi.EndNodeId) - { - int x1, y1, x2, y2; - int dist = pi.GetCoordinates(out x1, out y1, out x2, out y2) ? (int)Math.Round(Math.Sqrt((double)((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))) : 1; - graph.AddEdge(pi.StartItem.GNodes[pi.StartNodeId], pi.EndItem.GNodes[pi.EndNodeId], dist); - graph.AddEdge(pi.EndItem.GNodes[pi.EndNodeId], pi.StartItem.GNodes[pi.StartNodeId], dist); - } + pipesM.Add(new Pipe(pStr, Sz.M, Name2Item)); } } - Redraw(); + + if (!supressRedraws) + { + JoinPipeListsEtc(); + Redraw(); + } } } + /// public string[] PipesL { get { @@ -167,24 +174,20 @@ namespace SchematicDrawing pipesL.Clear(); if (value != null) { - foreach (var p in value) + foreach (var pStr in value) { - Pipe pi = new Pipe(p, Sz.L, Name2Item); - pipesL.Add(pi); - - if (!EditMode && pi.StartItem != null && pi.StartItem.GNodes.Count > pi.StartNodeId && - pi.EndItem != null && pi.EndItem.GNodes.Count > pi.EndNodeId) - { - int x1, y1, x2, y2; - int dist = pi.GetCoordinates(out x1, out y1, out x2, out y2) ? (int)Math.Round(Math.Sqrt((double)((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))) : 1; - graph.AddEdge(pi.StartItem.GNodes[pi.StartNodeId], pi.EndItem.GNodes[pi.EndNodeId], dist); - graph.AddEdge(pi.EndItem.GNodes[pi.EndNodeId], pi.StartItem.GNodes[pi.StartNodeId], dist); - } + pipesL.Add(new Pipe(pStr, Sz.L, Name2Item)); } } - Redraw(); + + if (!supressRedraws) + { + JoinPipeListsEtc(); + Redraw(); + } } } + /// public string[] PipesXL { get { @@ -196,22 +199,58 @@ namespace SchematicDrawing pipesXL.Clear(); if (value != null) { - foreach (var p in value) + foreach (var pStr in value) { - Pipe pi = new Pipe(p, Sz.XL, Name2Item); - pipesXL.Add(pi); - - if (!EditMode && pi.StartItem != null && pi.StartItem.GNodes.Count > pi.StartNodeId && - pi.EndItem != null && pi.EndItem.GNodes.Count > pi.EndNodeId) - { - int x1, y1, x2, y2; - int dist = pi.GetCoordinates(out x1, out y1, out x2, out y2) ? (int)Math.Round(Math.Sqrt((double)((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)))) : 1; - graph.AddEdge(pi.StartItem.GNodes[pi.StartNodeId], pi.EndItem.GNodes[pi.EndNodeId], dist); - graph.AddEdge(pi.EndItem.GNodes[pi.EndNodeId], pi.StartItem.GNodes[pi.StartNodeId], dist); - } + pipesXL.Add(new Pipe(pStr, Sz.XL, Name2Item)); } } - Redraw(); + + if (!supressRedraws) + { + JoinPipeListsEtc(); + Redraw(); + } + } + } + + /// + /// 1. Join 4 pipe lists. + /// 2. Add graph edges in case EditMode is off. + /// 3. Determine intersections of pipes in case EditMode is off. + /// + void JoinPipeListsEtc() + { + allPipes.Clear(); + foreach (var p in pipesS) allPipes.Add(p); + foreach (var p in pipesM) allPipes.Add(p); + foreach (var p in pipesL) allPipes.Add(p); + foreach (var p in pipesXL) allPipes.Add(p); + + if ((allPipes.Count > 0) && !EditMode && !graph.Completed) + { + /// Do the following just once in non edit mode + + for (int i = 0; i < allPipes.Count; i++) + { + Pipe p = allPipes[i]; + if (p.StartItem != null && p.StartItem.GNodes.Count > p.StartNodeId && + p.EndItem != null && p.EndItem.GNodes.Count > p.EndNodeId) + { + int dist = p.GetCoordinates() ? (int)Math.Round(Math.Sqrt((double)((p.x2 - p.x1) * (p.x2 - p.x1) + (p.y2 - p.y1) * (p.y2 - p.y1)))) : 1; + graph.AddEdge(p.StartItem.GNodes[p.StartNodeId], p.EndItem.GNodes[p.EndNodeId], dist); + graph.AddEdge(p.EndItem.GNodes[p.EndNodeId], p.StartItem.GNodes[p.StartNodeId], dist); + } + } + + for (int i = 0; i < allPipes.Count; i++) + { + for (int j = i + 1; j < allPipes.Count; j++) + { + if (allPipes[i].CalculateIntersectionWith(allPipes[j])) break; + } + } + + graph.Completed = true; } } @@ -246,6 +285,9 @@ namespace SchematicDrawing Brush brushDry; Brush brushWater; Brush brushVacuum; + Brush brushDryBackgr; + Brush brushWaterBackgr; + Brush brushVacuumBackgr; Brush brushHihglighted; /// @@ -271,6 +313,7 @@ namespace SchematicDrawing public SchematicDrawingCtrl() { + SupressRedraws = true; InitializeComponent(); this.AutoScaleMode = AutoScaleMode.None; @@ -285,6 +328,7 @@ namespace SchematicDrawing pipesM = new List(); pipesL = new List(); pipesXL = new List(); + allPipes = new List(); graph = new Graph(); @@ -401,11 +445,17 @@ namespace SchematicDrawing brushDry = new SolidBrush(Color.FromArgb(255, 127, 127, 127)); brushWater = new SolidBrush(Color.FromArgb(255, 0, 162, 232)); brushVacuum = new SolidBrush(Color.FromArgb(255, 64, 255, 64)); + brushDryBackgr = new SolidBrush(Color.FromArgb(255, 80, 80, 80)); + brushWaterBackgr = new SolidBrush(Color.FromArgb(255, 0, 108, 154)); + brushVacuumBackgr = new SolidBrush(Color.FromArgb(255, 48, 196, 48)); brushHihglighted = new SolidBrush(Color.FromArgb(255, 255, 0, 0)); /// pensDry = new Pen[(int)Sz.XL + 1]; pensWater = new Pen[(int)Sz.XL + 1]; pensVacuum = new Pen[(int)Sz.XL + 1]; + pensDryBackgr = new Pen[(int)Sz.XL + 1]; + pensWaterBackgr = new Pen[(int)Sz.XL + 1]; + pensVacuumBackgr = new Pen[(int)Sz.XL + 1]; pensHighlighted = new Pen[(int)Sz.XL + 1]; /// for (Sz sz = Sz.S; sz <= Sz.XL; sz++) @@ -413,6 +463,9 @@ namespace SchematicDrawing pensDry[(int)sz] = new Pen(brushDry); pensWater[(int)sz] = new Pen(brushWater); pensVacuum[(int)sz] = new Pen(brushVacuum); + pensDryBackgr[(int)sz] = new Pen(brushDryBackgr); + pensWaterBackgr[(int)sz] = new Pen(brushWaterBackgr); + pensVacuumBackgr[(int)sz] = new Pen(brushVacuumBackgr); pensHighlighted[(int)sz] = new Pen(brushHihglighted); float width; switch (sz) @@ -429,6 +482,12 @@ namespace SchematicDrawing pensWater[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; pensVacuum[(int)sz].Width = width; pensVacuum[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; + pensDryBackgr[(int)sz].Width = width; + pensDryBackgr[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; + pensWaterBackgr[(int)sz].Width = width; + pensWaterBackgr[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; + pensVacuumBackgr[(int)sz].Width = width; + pensVacuumBackgr[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; pensHighlighted[(int)sz].Width = width; pensHighlighted[(int)sz].LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel; } @@ -456,8 +515,8 @@ namespace SchematicDrawing void SchematicDrawingCtrl_Paint(object sender, PaintEventArgs e) { /// Profiling - //stopwatch.Reset(); - //stopwatch.Start(); + stopwatch.Reset(); + stopwatch.Start(); e.Graphics.Clear(Color.White); @@ -483,19 +542,22 @@ namespace SchematicDrawing /// if (EditMode) { - /// Draw pipes without water - foreach (var pipe in pipesS) DrawPipe(e, pipe, int.MaxValue); - foreach (var pipe in pipesM) DrawPipe(e, pipe, int.MaxValue); - foreach (var pipe in pipesL) DrawPipe(e, pipe, int.MaxValue); - foreach (var pipe in pipesXL) DrawPipe(e, pipe, int.MaxValue); + /// Draw an empty pipe. Coordinates are always recalculated + for (int j = 0; j < allPipes.Count; j++) + { + Pipe pipe = allPipes[j]; + pipe.CoordinatesAreValid = false; + DrawPipe(e, pipe, int.MaxValue); + } } else { /// Draw pipes with a color determined by Dijkstra shortest path algorithm - foreach (var pipe in pipesS) DrawPipe(e, pipe, pipe.StartItem.GNodes[pipe.StartNodeId].Dist); - foreach (var pipe in pipesM) DrawPipe(e, pipe, pipe.StartItem.GNodes[pipe.StartNodeId].Dist); - foreach (var pipe in pipesL) DrawPipe(e, pipe, pipe.StartItem.GNodes[pipe.StartNodeId].Dist); - foreach (var pipe in pipesXL) DrawPipe(e, pipe, pipe.StartItem.GNodes[pipe.StartNodeId].Dist); + for (int j = 0; j < allPipes.Count; j++) + { + Pipe pipe = allPipes[j]; + DrawPipe(e, pipe, pipe.StartItem.GNodes[pipe.StartNodeId].Dist); + } } /// @@ -504,7 +566,7 @@ namespace SchematicDrawing foreach (var item in items) { DrawingShape dshape = DrawingShape.GetDrawingShape(item); - if (dshape != null && dshape.Shape != Shape.Junction && dshape.HasImg && (!Utils.IsHidden(item) || EditMode)) + if (dshape != null && dshape.Shape != Shape.Junction && dshape.HasImg && (!Utils.IsHidden(item) || (EditMode && item == selectedItem))) { Rectangle rect = DrawItem(e, item, dshape); ItemElementRectangles.Add(new ItemElementRect(item, Element.Body, rect)); @@ -656,43 +718,89 @@ namespace SchematicDrawing } /// Profiling - //stopwatch.Stop(); - //if (firstTime) - //{ - // firstTime = false; - //} - //else if (totalTimes < long.MaxValue) - //{ - // totalMs += stopwatch.ElapsedMilliseconds; - // totalTicks += stopwatch.ElapsedTicks; - // totalTimes++; - // Console.WriteLine("Average Paint duration is {0} ms = {1} ticks", totalMs / totalTimes, totalTicks / totalTimes); - //} + stopwatch.Stop(); + if (firstTime) + { + firstTime = false; + } + else if (totalTimes < long.MaxValue) + { + totalMs += stopwatch.ElapsedMilliseconds; + totalTicks += stopwatch.ElapsedTicks; + totalTimes++; + Console.WriteLine("Average Paint duration is {0} ms = {1} ticks", totalMs / totalTimes, totalTicks / totalTimes); + } } /// Profiling - //Stopwatch stopwatch = new Stopwatch(); - //bool firstTime = true; - //long totalMs = 0; - //long totalTicks = 0; - //long totalTimes = 0; + Stopwatch stopwatch = new Stopwatch(); + bool firstTime = true; + long totalMs = 0; + long totalTicks = 0; + long totalTimes = 0; /// /// Draw a pipe. /// /// PaintEventArgs - /// Pipe object + /// Pipe object /// Distance from source of water for coloring /// true = highlighted (edit mode) - void DrawPipe(PaintEventArgs e, Pipe pipe, int distance, bool highlighted = false) + void DrawPipe(PaintEventArgs e, Pipe p, int distance, bool highlighted = false) { - int x1, y1, x2, y2; - if (pipe.GetCoordinates(out x1, out y1, out x2, out y2) && (pipe.Sz >= Sz.S) && (pipe.Sz <= Sz.XL)) + if (!p.CoordinatesAreValid) p.GetCoordinates(); + + int eIx = Math.Max((int)Sz.S, Math.Min((int)Sz.XL, (int)p.Sz)); + Pen pen = (distance == int.MaxValue) ? pensDry[eIx] : (distance < Const.Vacuum) ? pensWater[eIx] : pensVacuum[eIx]; + + if (highlighted) { - int eIx = (int)pipe.Sz; - Pen pen = highlighted ? pensHighlighted[eIx] : ((distance == int.MaxValue) ? pensDry[eIx] : (distance < Const.Vacuum) ? pensWater[eIx] : pensVacuum[eIx]); - e.Graphics.DrawLine(pen, x1, y1, x2, y2); + e.Graphics.DrawLine(pensHighlighted[eIx], p.x1, p.y1, p.x2, p.y2); + } + else if (!p.HasIntersection) + { + e.Graphics.DrawLine(pen, p.x1, p.y1, p.x2, p.y2); + } + else + { + Pen pen2 = (distance == int.MaxValue) ? pensDryBackgr[eIx] : (distance < Const.Vacuum) ? pensWaterBackgr[eIx] : pensVacuumBackgr[eIx]; + + float len = (float)Math.Sqrt(Convert.ToSingle((p.x2 - p.x1) * (p.x2 - p.x1) + (p.y2 - p.y1) * (p.y2 - p.y1))); + float PP = 1.0f - p.P; + if (p.P * len < 20 && PP * len < 20) + { + /// Draw a straght line with darker color + e.Graphics.DrawLine(pen2, p.x1, p.y1, p.x2, p.y2); + } + else + { + /// Draw a line having normal color with a bow having darker color + + float vx = 17.0f * (p.x2 - p.x1) / len; /// Fixed size vector in the direction of the line + float vy = 17.0f * (p.y2 - p.y1) / len; + + float xm = p.x1 * PP + p.x2 * p.P; /// Intersection point + float ym = p.y1 * PP + p.y2 * p.P; + int x3 = Convert.ToInt32(Math.Round(xm - vx)); /// Points around the intersection point + int y3 = Convert.ToInt32(Math.Round(ym - vy)); + int x4 = Convert.ToInt32(Math.Round(xm - 2 * vy / 3)); + int y4 = Convert.ToInt32(Math.Round(ym + 2 * vx / 3)); + int x5 = Convert.ToInt32(Math.Round(xm + vx)); + int y5 = Convert.ToInt32(Math.Round(ym + vy)); + + /// Joints between straight parts of the line and the bow + DrawingShape dsh = DrawingShape.GetDrawingShape(Shape.Junction, p.Sz); + Image image = (distance == int.MaxValue) ? dsh.ImgRightOpenDry : (distance < Const.Vacuum) ? dsh.ImgRight : dsh.ImgRightVacuum; + e.Graphics.DrawImage(image, x3 - dsh.Wid / 2, y3 - dsh.Hgh / 2); + e.Graphics.DrawImage(image, x5 - dsh.Wid / 2, y5 - dsh.Hgh / 2); + + e.Graphics.DrawLine(pen2, x3, y3, x4, y4); /// Bow + e.Graphics.DrawLine(pen2, x4, y4, x5, y5); + + e.Graphics.DrawLine(pen, p.x1, p.y1, x3, y3); /// Straight parts of the line + e.Graphics.DrawLine(pen, x5, y5, p.x2, p.y2); + } } } @@ -936,15 +1044,14 @@ namespace SchematicDrawing /// Squared distance float SquaredDistanceFromLine(int x, int y, Pipe pipe) { - int xx1, yy1, xx2, yy2; - if (!pipe.GetCoordinates(out xx1, out yy1, out xx2, out yy2) || (xx1 == xx2 && yy1 == yy2)) + if (!pipe.GetCoordinates() || (pipe.x1 == pipe.x2 && pipe.y1 == pipe.y2)) { return float.MaxValue; } Vector2 X = new Vector2(Convert.ToSingle(x), Convert.ToSingle(y)); - Vector2 X1 = new Vector2(Convert.ToSingle(xx1), Convert.ToSingle(yy1)); - Vector2 X2 = new Vector2(Convert.ToSingle(xx2), Convert.ToSingle(yy2)); + Vector2 X1 = new Vector2(Convert.ToSingle(pipe.x1), Convert.ToSingle(pipe.y1)); + Vector2 X2 = new Vector2(Convert.ToSingle(pipe.x2), Convert.ToSingle(pipe.y2)); Vector2 vX = X - X1; /// |X1 X| Vector2 v12 = X2 - X1; /// |X1 X2| diff --git a/TBF/UI/Bench/EditSchDrawing/EditSchDrawingDlg.cs b/TBF/UI/Bench/EditSchDrawing/EditSchDrawingDlg.cs index 95d781360..a72282df3 100644 --- a/TBF/UI/Bench/EditSchDrawing/EditSchDrawingDlg.cs +++ b/TBF/UI/Bench/EditSchDrawing/EditSchDrawingDlg.cs @@ -644,12 +644,12 @@ namespace TBF.UI.Bench.EditSchDrawing void DeleteSelectedPipe() { - Pipe edge = drawingCtrl.GetTempPipe(); - if (edge != null) + Pipe pipe = drawingCtrl.GetTempPipe(); + if (pipe != null) { /// Delete selected pipe TBF.BenchControl.Various.Drawing.Pipes.Configuration pipesCfg = null; - switch (edge.Sz) + switch (pipe.Sz) { case Sz.S: pipesCfg = pipesScfg; break; case Sz.M: pipesCfg = pipesMcfg; break; @@ -664,7 +664,7 @@ namespace TBF.UI.Bench.EditSchDrawing int ix = -1; for (int i = 0; i < oriEdges.Length; i++) { - if (oriEdges[i] == edge.ToString()) + if (oriEdges[i] == pipe.ToString()) { ix = i; break; @@ -683,7 +683,7 @@ namespace TBF.UI.Bench.EditSchDrawing } } - switch (edge.Sz) + switch (pipe.Sz) { case Sz.S: drawingCtrl.PipesS = pipesCfg.Pipes; break; case Sz.M: drawingCtrl.PipesM = pipesCfg.Pipes; break;