public double AddCablePassThroughBlock(DiagramBuilder builder, double offsetY, double minWith) { ////////////////////////////////////////////////////////// /// label block /// LineBlock cableBlock = new LineBlock(30, offsetY, LineBlockTypeEnum.Simple); cableBlock.MinWidth = minWith; // Add vest ports AddBigConduitPort(cableBlock, BlockSideEnum.Vest, 2, null, 20); // Add east ports AddBigConduitPort(cableBlock, BlockSideEnum.East, 2, null, 20); // Connect west and east terminals cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "72", "CableOutsideWell"); cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "72", "CableOutsideWell"); cableBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(cableBlock); ////////////////////////////////////////////////////////// /// label block LineBlock labelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); labelBlock.MinWidth = 30; // Add vest port AddBigConduitPort(labelBlock, BlockSideEnum.Vest, 2); // Add east port AddBigConduitPort(labelBlock, BlockSideEnum.East, 2); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "FP-0101", "CableOutsideWell"); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "FP-0101", "CableOutsideWell"); labelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(labelBlock); return(cableBlock.DesiredSize.Height); }
public void LineBlockWithLabeledLinesTest() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // Vest var vestPort1 = new BlockPort(BlockSideEnum.West) { IsVisible = false }; lineBlock.AddPort(vestPort1); AddTerminalsToPort(vestPort1, 3); // East var eastPort1 = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort1); AddTerminalsToPort(eastPort1, 3); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // Act lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count.Should().Be(1); diagram.DiagramObjects.First().Geometry.IsValid.Should().BeTrue(); diagram.DiagramObjects.First().Geometry.Length.Should().Be(0.03); diagram.DiagramObjects.First().Label.Should().Be("This is a label text"); diagram.DiagramObjects.First().Style.Should().Be("This should be a polyline"); }
public double AddMultiConduitPassThroughBlock(DiagramBuilder builder, double minWith, double offsetY, int nTerminals) { ////////////////////////////////////////////////////////// /// label block /// LineBlock conduitBlock = new LineBlock(30, offsetY, LineBlockTypeEnum.Simple); conduitBlock.MinWidth = minWith; // Add vest ports AddMultiConduitPort(conduitBlock, BlockSideEnum.Vest, nTerminals, "Orange", -1, -1, 10); // Add east ports AddMultiConduitPort(conduitBlock, BlockSideEnum.East, nTerminals, "Orange", -1, -1, 10); // Connect ports conduitBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 1, null, "MultiConduitOrange"); // Connect west and east terminals for (int i = 0; i < nTerminals; i++) { conduitBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, i + 1, BlockSideEnum.East, 1, i + 1, null, "InnerConduit" + MockupHelper.GetColorStringFromConduitNumber(i + 1), LineShapeTypeEnum.Polygon); } conduitBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitBlock); ////////////////////////////////////////////////////////// /// label block LineBlock labelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); labelBlock.MinWidth = 30; // Add vest port AddBigConduitPort(labelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(labelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "PF-4200", "LabelMediumText"); labelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(labelBlock); return(conduitBlock.DesiredSize.Height); }
public void SouthEastPostDrawingTest_ShouldSucceed() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // East var eastPort = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort); AddTerminalsToPort(eastPort, 4); // South var southPort = new BlockPort(BlockSideEnum.South) { IsVisible = false }; lineBlock.AddPort(southPort); AddTerminalsToPort(southPort, 4); // East South connections lineBlock.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Polygon); lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } }
public void LabelTest2() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20 }; // Vest var vestPort1 = new BlockPort(BlockSideEnum.West); lineBlock.AddPort(vestPort1); AddTerminalsToPort(vestPort1, 3); var vestPort2 = new BlockPort(BlockSideEnum.West); lineBlock.AddPort(vestPort2); AddTerminalsToPort(vestPort2, 3); // East var eastPort1 = new BlockPort(BlockSideEnum.East); lineBlock.AddPort(eastPort1); AddTerminalsToPort(eastPort1, 3); var eastPort2 = new BlockPort(BlockSideEnum.East); lineBlock.AddPort(eastPort2); AddTerminalsToPort(eastPort2, 3); // North var northPort1 = new BlockPort(BlockSideEnum.North); lineBlock.AddPort(northPort1); AddTerminalsToPort(northPort1, 3); var northPort2 = new BlockPort(BlockSideEnum.North); lineBlock.AddPort(northPort2); AddTerminalsToPort(northPort2, 3); lineBlock.SetSideCenterAlignment(BlockSideEnum.North); // South var southPort1 = new BlockPort(BlockSideEnum.South, "SouthPortStyle1", "SouthPortLabel1"); lineBlock.AddPort(southPort1); AddTerminalsToPort(southPort1, 3); var southPort2 = new BlockPort(BlockSideEnum.South, "SouthPortStyle2", "SouthPortLabel2"); lineBlock.AddPort(southPort2); AddTerminalsToPort(southPort2, 3); //lineBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 2); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.North, 2, 1, "Hest", "Cable", LineShapeTypeEnum.Polygon); var diagramObjects = lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } }
public void AllDirectionsTerminalLineDrawingTest_ShouldSucceed() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // Vest var vestPort = new BlockPort(BlockSideEnum.West) { IsVisible = false }; lineBlock.AddPort(vestPort); AddTerminalsToPort(vestPort, 4); // North var northPort = new BlockPort(BlockSideEnum.North) { IsVisible = false }; lineBlock.AddPort(northPort); AddTerminalsToPort(northPort, 4); // East var eastPort = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort); AddTerminalsToPort(eastPort, 4); // South var southPort = new BlockPort(BlockSideEnum.South) { IsVisible = false }; lineBlock.AddPort(southPort); AddTerminalsToPort(southPort, 4); // West connections lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.North, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 2, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 3, BlockSideEnum.South, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // North connections lineBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.East, 1, 2, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 2, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // East connections lineBlock.AddTerminalConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.South, 1, 3, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // Act lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count(d => d.Style == "This should be a polyline").Should().Be(6); }
public Diagram Build() { DiagramBuilder builder = new DiagramBuilder(); double offsetY = 0; offsetY += AddCablePassThroughBlock(builder, offsetY, 300); AddMultiConduitPassThroughBlock(builder, 300, offsetY, 10); Diagram diagram = builder.CreateDiagram(); return(diagram); LineBlock junctionBlock = new LineBlock(30, 0); junctionBlock.MinWidth = 300; // Add first vest port with 5 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 10, "Orange"); // Add second vest port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 7, "Orange"); // Add fist east port with 10 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 10, "Orange"); // Add second east port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 7, "Orange"); // Add north big conduit port 1 with 3 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 3, "Red"); // Add north big conduit port 2 with 5 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 5, "Red"); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.North, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); /* * * // Feeder calbe from central office * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.North, 1, 1, "192", "CableInsideWell"); * * // Transit feeder cable to other flex points * junctionBlock.AddConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.North, 1, 2, "96", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 10, BlockSideEnum.North, 1, 3, "96", "CableInsideWell"); * * // Sp connections * junctionBlock.AddConnection(BlockSideEnum.East, 1, 1, BlockSideEnum.North, 2, 2, "24", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 2, BlockSideEnum.North, 2, 3, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.North, 2, 4, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 4, BlockSideEnum.North, 2, 5, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.North, 2, 1, "48", "CableInsideWell"); * */ builder.ContentObjects.Add(junctionBlock); junctionBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well north label block LineBlock wellNorthLabelBlock = new LineBlock(30, junctionBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthLabelBlock.MinHeight = 30; // Add north port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 3); // Add north port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 5); // Add south port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 3); // Add south port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 5); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 1, BlockSideEnum.South, 1, 1, "GSS 1 (1-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.South, 1, 2, "GSS 1 (1-8)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 3, "GSS 1 (9-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 1, BlockSideEnum.South, 2, 1, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 2, BlockSideEnum.South, 2, 2, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 3, BlockSideEnum.South, 2, 3, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 4, BlockSideEnum.South, 2, 4, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 5, BlockSideEnum.South, 2, 5, "GPS 2 & 3", "CableOutsideWell"); builder.ContentObjects.Add(wellNorthLabelBlock); wellNorthLabelBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well vest label block LineBlock wellVestLabelBlock = new LineBlock(0, 0, LineBlockTypeEnum.Simple); wellVestLabelBlock.MinWidth = 30; // Add vest port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 5); // Add vest port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 7); // Add east port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 5); // Add east port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 7); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "PF-4200", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.East, 2, 2, "SP-5420", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.East, 2, 5, "CO-1010", "CableOutsideWell"); wellVestLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellVestLabelBlock); ////////////////////////////////////////////////////////// /// east label block LineBlock wellEastLabelBlock = new LineBlock(junctionBlock.DesiredSize.Width + 30, 0, LineBlockTypeEnum.Simple); wellEastLabelBlock.MinWidth = 30; wellEastLabelBlock.MinHeight = junctionBlock.DesiredSize.Height; // Add vest port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.Vest, 10); // Add east port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.East, 10); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "SP-5010", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "SP-5011", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 3, BlockSideEnum.East, 1, 3, "SP-5013", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "SP-6002", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 10, BlockSideEnum.East, 1, 10, "FP-4203", "CableOutsideWell"); wellEastLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellEastLabelBlock); ////////////////////////////////////////////////////////// /// well north corner 1 LineBlock wellNorthCorner1 = new LineBlock(30, junctionBlock.DesiredSize.Height + wellNorthLabelBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthCorner1.MinHeight = 20; // Add south port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.South, 3); // Add east port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.East, 3, null, 1, 1); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 2, BlockSideEnum.East, 1, 2, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 3, BlockSideEnum.East, 1, 3, "", "CableOutsideWell"); // Set margin on east side to 0 wellNorthCorner1.SetSideMargin(BlockSideEnum.East, 0); //builder.ContentObjects.Add(wellNorthCorner1); Diagram sdiagram = builder.CreateDiagram(); return(diagram); }
private LineBlock CreateConduitPassThroughBlock() { // Create outer conduits var rootSpanInfo = _spanEquipmentViewModel.RootSpanDiagramInfo("OuterConduit"); var spanEquipmentBlock = new LineBlock() { MinWidth = _spanEquipmentAreaWidth, IsVisible = _spanEquipmentViewModel.IsSingleSpan ? false : true, Style = rootSpanInfo.StyleName, Margin = _spanEquipmentViewModel.IsSingleSpan ? 0 : _spanEquipmentBlockMargin, DrawingOrder = 400 }; spanEquipmentBlock.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); // Create inner conduits var innerSpanData = _spanEquipmentViewModel.GetInnerSpanDiagramInfos("InnerConduit"); var fromPort = _spanEquipmentViewModel.IsSingleSpan ? new BlockPort(BlockSideEnum.West, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 } : new BlockPort(BlockSideEnum.West) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(fromPort); var toPort = _spanEquipmentViewModel.IsSingleSpan ? new BlockPort(BlockSideEnum.East, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 } : new BlockPort(BlockSideEnum.East) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(toPort); int terminalNo = 1; var orderedinnerSpanData = innerSpanData.OrderBy(i => (1000 - i.Position)); bool innerSpansFound = false; foreach (var spanInfo in orderedinnerSpanData) { var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(spanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(spanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(spanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(spanInfo.OutgoingSegmentId, "SpanSegment"); var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, null, spanInfo.StyleName, LineShapeTypeEnum.Polygon); terminalConnection.DrawingOrder = 510; terminalConnection.SetReference(spanInfo.IngoingSegmentId, "SpanSegment"); // Add eventually cable running through inner conduit if (_spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(spanInfo.SegmentId)) { var cableId = _spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations[spanInfo.SegmentId].First(); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(cableId); var cableTerminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); cableTerminalConnection.DrawingOrder = 600; cableTerminalConnection.SetReference(cableId, "SpanSegment"); } terminalNo++; innerSpansFound = true; } if (!innerSpansFound) { var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(rootSpanInfo.OutgoingSegmentId, "SpanSegment"); // If a single conduit if (_spanEquipmentViewModel.IsSingleSpan) { var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, null, rootSpanInfo.StyleName, LineShapeTypeEnum.Polygon); terminalConnection.DrawingOrder = 510; terminalConnection.SetReference(rootSpanInfo.SegmentId, "SpanSegment"); // Add eventually cable running through inner conduit if (_spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(rootSpanInfo.SegmentId)) { var cableId = _spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations[rootSpanInfo.SegmentId].First(); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(cableId); var cableTerminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); cableTerminalConnection.DrawingOrder = 600; cableTerminalConnection.SetReference(cableId, "SpanSegment"); } } terminalNo++; } return(spanEquipmentBlock); }
public double AddCablePassThroughBlock(DiagramBuilder builder, List <SegmentWithRouteNodeRelationInfo> cableSegmentRels, double offsetY, double minBlockWidth) { double labelSectionWidth = 40; double sideMargin = 20; double portMargin = 20; int nCables = cableSegmentRels.Count; ////////////////////////////////////////////////////////// /// cable block /// LineBlock cableBlock = new LineBlock(labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); cableBlock.MinWidth = minBlockWidth; // Add vest ports AddBigConduitPort(cableBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east ports AddBigConduitPort(cableBlock, BlockSideEnum.East, nCables, null, portMargin); ////////////////////////////////////////////////////////// /// left label block LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nCables, null, portMargin); ////////////////////////////////////////////////////////// /// right label block LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nCables, null, portMargin); int terminalNo = 1; foreach (var cableRel in cableSegmentRels) { var cable = (FiberCableInfo)cableRel.Segment.Line; var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(cableRel.Segment); // Create cable var termianlCableMid = cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, "" + cable.Children.Count, "CableOutsideWell"); termianlCableMid.SetReference(cableRel.Segment.Id, "FiberCableSegment"); // Create left label var terminalCableLeft = leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, lineInfo.StartRouteNode.Name, "CableOutsideWell"); terminalCableLeft.SetReference(cableRel.Segment.Id, "FiberCableSegment"); // Create right label var terminalCableRight = rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, lineInfo.EndRouteNode.Name, "CableOutsideWell"); terminalCableRight.SetReference(cableRel.Segment.Id, "FiberCableSegment"); terminalNo++; } cableBlock.SetSideMargin(sideMargin); cableBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(cableBlock); leftLabelBlock.SetSideMargin(sideMargin); leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); rightLabelBlock.SetSideMargin(sideMargin); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(cableBlock.DesiredSize.Height); }
private LineBlock CreateCableOutsideConduitPassThroughBlock() { // Create outer conduits var rootSpanInfo = _spanEquipmentViewModel.RootSpanDiagramInfo("OuterConduit"); var spanEquipmentBlock = new LineBlock() { MinWidth = _spanEquipmentAreaWidth, IsVisible = false, Style = rootSpanInfo.StyleName, Margin = _spanEquipmentViewModel.IsSingleSpan ? 0 : _spanEquipmentBlockMargin, DrawingOrder = 400 }; spanEquipmentBlock.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var fromPort = new BlockPort(BlockSideEnum.West, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(fromPort); var toPort = new BlockPort(BlockSideEnum.East, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(toPort); int terminalNo = 1; var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(rootSpanInfo.OutgoingSegmentId, "SpanSegment"); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(_spanEquipmentViewModel.SpanEquipment.Id); var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); terminalConnection.DrawingOrder = 600; terminalConnection.SetReference(rootSpanInfo.SegmentId, "SpanSegment"); return(spanEquipmentBlock); }
public double AddMultiConduitPassThroughBlock(DiagramBuilder builder, ConduitSegmentInfo conduitSegmentInfo, double minBlockWidth, double offsetY) { double labelSectionWidth = 40; double sideMargin = 20; ////////////////////////////////////////////////////////// /// conduit block /// LineBlock conduitBlock = new LineBlock(labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); conduitBlock.MinWidth = minBlockWidth; var nTerminals = conduitSegmentInfo.Children.Count; var color = conduitSegmentInfo.Conduit.Color.ToString(); // Add vest ports AddMultiConduitPort(conduitBlock, BlockSideEnum.Vest, nTerminals, color, -1, -1, 10); // Add east ports AddMultiConduitPort(conduitBlock, BlockSideEnum.East, nTerminals, color, -1, -1, 10); // Connect ports var portConnection = conduitBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 1, null, "MultiConduit" + color); portConnection.SetReference(conduitSegmentInfo.ConduitId, "Conduit"); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var terminalConnection = conduitBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, null, "InnerConduit" + child.Conduit.Color.ToString(), LineShapeTypeEnum.Polygon); terminalConnection.SetReference(child.Conduit.Id, "SingleConduit"); } conduitBlock.SetSideMargin(sideMargin); conduitBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitBlock); ////////////////////////////////////////////////////////// /// left label block LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(conduitSegmentInfo); leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, lineInfo.StartRouteNode.Name, "LabelMediumText"); } leftLabelBlock.SetSideMargin(sideMargin); leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); ////////////////////////////////////////////////////////// /// right label block LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(conduitSegmentInfo); var terminalConnection = rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, lineInfo.EndRouteNode.Name, "LabelMediumText"); } rightLabelBlock.SetSideMargin(sideMargin); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(conduitBlock.DesiredSize.Height); }
public Diagram Build(Guid nodeId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IFiberNetworkQueryService fiberNetworkService, IConduitClosureRepository conduitClosureRepository) { _routeNetworkQueryService = routeNetworkQueryService; _conduitNetworkQueryService = conduitNetworkEqueryService; _traversalHelper = new TraversalHelper(_routeNetworkQueryService); DiagramBuilder builder = new DiagramBuilder(); double minWidth = 300; double offsetY = 0; ConduitClosureInfo conduitClosureInfo = null; if (conduitClosureRepository.CheckIfRouteNodeContainsConduitClosure(nodeId)) { conduitClosureInfo = conduitClosureRepository.GetConduitClosureInfoByRouteNodeId(nodeId); } // Add cables passing through var cableSegmentRels = fiberNetworkService.GetLineSegmentsRelatedToPointOfInterest(nodeId); offsetY += AddCablePassThroughBlock(builder, cableSegmentRels, offsetY, 300); // Add multi conduit passing through var conduitSegmentRels = conduitNetworkEqueryService.GetConduitSegmentsRelatedToPointOfInterest(nodeId); foreach (var conduitSegmentRel in conduitSegmentRels) { // pass by multi conduit if (conduitSegmentRel.RelationType == SegmentRelationTypeEnum.PassThrough && conduitSegmentRel.Segment.Line.LineKind == LineKindEnum.MultiConduit) { // check if outside conduit closure if (conduitClosureInfo != null && conduitClosureInfo.Sides.Exists(s => s.Ports.Exists(p => p.MultiConduitId == conduitSegmentRel.Segment.Line.Id))) { } else { offsetY += AddMultiConduitPassThroughBlock(builder, (ConduitSegmentInfo)conduitSegmentRel.Segment, minWidth, offsetY); } } } // Add conduit closure offsetY += 20; if (conduitClosureInfo != null) { offsetY += AddConduitClosureBlock(builder, conduitClosureInfo, minWidth, offsetY); } Diagram diagram = builder.CreateDiagram(); return(diagram); LineBlock junctionBlock = new LineBlock(30, 0); junctionBlock.MinWidth = 300; // Add first vest port with 5 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 10, "Orange"); // Add second vest port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 7, "Orange"); // Add fist east port with 10 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 10, "Orange"); // Add second east port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 7, "Orange"); // Add north big conduit port 1 with 3 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 3, "Red"); // Add north big conduit port 2 with 5 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 5, "Red"); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.North, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); /* * * // Feeder calbe from central office * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.North, 1, 1, "192", "CableInsideWell"); * * // Transit feeder cable to other flex points * junctionBlock.AddConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.North, 1, 2, "96", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 10, BlockSideEnum.North, 1, 3, "96", "CableInsideWell"); * * // Sp connections * junctionBlock.AddConnection(BlockSideEnum.East, 1, 1, BlockSideEnum.North, 2, 2, "24", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 2, BlockSideEnum.North, 2, 3, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.North, 2, 4, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 4, BlockSideEnum.North, 2, 5, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.North, 2, 1, "48", "CableInsideWell"); * */ builder.ContentObjects.Add(junctionBlock); junctionBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well north label block LineBlock wellNorthLabelBlock = new LineBlock(30, junctionBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthLabelBlock.MinHeight = 30; // Add north port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 3); // Add north port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 5); // Add south port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 3); // Add south port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 5); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 1, BlockSideEnum.South, 1, 1, "GSS 1 (1-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.South, 1, 2, "GSS 1 (1-8)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 3, "GSS 1 (9-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 1, BlockSideEnum.South, 2, 1, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 2, BlockSideEnum.South, 2, 2, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 3, BlockSideEnum.South, 2, 3, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 4, BlockSideEnum.South, 2, 4, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 5, BlockSideEnum.South, 2, 5, "GPS 2 & 3", "CableOutsideWell"); builder.ContentObjects.Add(wellNorthLabelBlock); wellNorthLabelBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well vest label block LineBlock wellVestLabelBlock = new LineBlock(0, 0, LineBlockTypeEnum.Simple); wellVestLabelBlock.MinWidth = 30; // Add vest port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 5); // Add vest port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 7); // Add east port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 5); // Add east port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 7); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "PF-4200", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.East, 2, 2, "SP-5420", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.East, 2, 5, "CO-1010", "CableOutsideWell"); wellVestLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellVestLabelBlock); ////////////////////////////////////////////////////////// /// east label block LineBlock wellEastLabelBlock = new LineBlock(junctionBlock.DesiredSize.Width + 30, 0, LineBlockTypeEnum.Simple); wellEastLabelBlock.MinWidth = 30; wellEastLabelBlock.MinHeight = junctionBlock.DesiredSize.Height; // Add vest port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.Vest, 10); // Add east port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.East, 10); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "SP-5010", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "SP-5011", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 3, BlockSideEnum.East, 1, 3, "SP-5013", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "SP-6002", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 10, BlockSideEnum.East, 1, 10, "FP-4203", "CableOutsideWell"); wellEastLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellEastLabelBlock); ////////////////////////////////////////////////////////// /// well north corner 1 LineBlock wellNorthCorner1 = new LineBlock(30, junctionBlock.DesiredSize.Height + wellNorthLabelBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthCorner1.MinHeight = 20; // Add south port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.South, 3); // Add east port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.East, 3, null, 1, 1); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 2, BlockSideEnum.East, 1, 2, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 3, BlockSideEnum.East, 1, 3, "", "CableOutsideWell"); // Set margin on east side to 0 wellNorthCorner1.SetSideMargin(BlockSideEnum.East, 0); //builder.ContentObjects.Add(wellNorthCorner1); Diagram sdiagram = builder.CreateDiagram(); return(diagram); }
public double AddConduitClosureBlock(DiagramBuilder builder, ConduitClosureInfo conduitClosureInfo, double minBlockWidth, double offsetY) { double labelSectionWidth = 40; double sideMargin = 20; LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; ////////////////////////////////////////////////////////// /// conduit closure block /// LineBlock conduitClosureBlock = new LineBlock(labelSectionWidth, offsetY); conduitClosureBlock.SetReference(conduitClosureInfo.Id, "ConduitClosure"); conduitClosureBlock.MinWidth = minBlockWidth; conduitClosureBlock.MinHeight = 100; conduitClosureBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitClosureBlock); Dictionary <BlockPort, ConduitClosurePortInfo> blockPortToConduitClosurePort = new Dictionary <BlockPort, ConduitClosurePortInfo>(); // Add ports foreach (var side in conduitClosureInfo.Sides) { foreach (var conduitClosurePort in side.Ports) { var nTerminals = conduitClosurePort.Terminals.Count; var blockPort = AddMultiConduitPort(conduitClosureBlock, Convert(side.Position), conduitClosurePort.Terminals, conduitClosurePort.MultiConduitSegment.Conduit.Color.ToString(), -1, -1, 10); blockPort.SetReference(conduitClosurePort.MultiConduitSegment.Id, "MultiConduitSegment"); blockPortToConduitClosurePort.Add(blockPort, conduitClosurePort); // Add left label blocks if (side.Position == ConduitClosureInfoSide.Left) { // Add left west label port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add left east label port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); foreach (var terminal in conduitClosurePort.Terminals) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(terminal.LineSegment); leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, blockPort.Index, terminal.Position, BlockSideEnum.East, blockPort.Index, terminal.Position, lineInfo.StartRouteNode.Name, "LabelMediumText"); } } // Add right label block if (side.Position == ConduitClosureInfoSide.Right) { // Add right west label port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add right east label port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); foreach (var terminal in conduitClosurePort.Terminals) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(terminal.LineSegment); rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, blockPort.Index, terminal.Position, BlockSideEnum.East, blockPort.Index, terminal.Position, lineInfo.EndRouteNode.Name, "LabelMediumText"); } } } } conduitClosureBlock.SetSideCenterAllignment(BlockSideEnum.North, true); // Connect ports foreach (var portEntry in blockPortToConduitClosurePort) { var blockPort = portEntry.Key; var conduitClosurePort = portEntry.Value; if ((blockPort.Side == BlockSideEnum.Vest || blockPort.Side == BlockSideEnum.North) && conduitClosurePort.ConnectionKind == ConduitClosureInternalConnectionKindEnum.PassThrough) { var portConnection = conduitClosureBlock.AddPortConnection(blockPort.Side, blockPort.Index, Convert(conduitClosurePort.ConnectedToSide), conduitClosurePort.ConnectedToPort, null, "MultiConduit" + conduitClosurePort.MultiConduitSegment.Conduit.Color.ToString()); portConnection.SetReference(conduitClosurePort.MultiConduitSegment.ConduitId, "Conduit"); } } // Connect terminals HashSet <ConduitClosureTerminalInfo> terminalAlreadyProcessed = new HashSet <ConduitClosureTerminalInfo>(); foreach (var portEntry in blockPortToConduitClosurePort) { var blockPort = portEntry.Key; var conduitClosurePort = portEntry.Value; foreach (var terminal in conduitClosurePort.Terminals) { if (!terminalAlreadyProcessed.Contains(terminal)) { terminalAlreadyProcessed.Add(terminal); if (terminal.ConnectionKind == ConduitClosureInternalConnectionKindEnum.PassThrough || terminal.ConnectionKind == ConduitClosureInternalConnectionKindEnum.Connected) { string color = "Red"; if (terminal.LineSegment is ConduitSegmentInfo) { var conduitSegmentInfo = terminal.LineSegment as ConduitSegmentInfo; color = conduitSegmentInfo.Conduit.Color.ToString(); } var terminalConnection = conduitClosureBlock.AddTerminalConnection(blockPort.Side, blockPort.Index, terminal.Position, Convert(terminal.ConnectedToSide), terminal.ConnectedToPort, terminal.ConnectedToTerminal, null, "InnerConduit" + color, LineShapeTypeEnum.Polygon); terminalConnection.SetReference(terminal.LineId, "InnerConduit"); // make sure we don't connect the other way too var connectedToTerminal = conduitClosureInfo.Sides.Find(s => s.Position == terminal.ConnectedToSide).Ports.Find(p => p.Position == terminal.ConnectedToPort).Terminals.Find(t => t.Position == terminal.ConnectedToTerminal); terminalAlreadyProcessed.Add(connectedToTerminal); } } } } // Add label blocks leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(conduitClosureBlock.DesiredSize.Height); }
private void ConnectEnds(LineBlock nodeContainerBlock) { System.Diagnostics.Debug.WriteLine($"***ConnectEnds***"); HashSet <BlockPortTerminal> conduitEndTerminalAlreadyConnected = new HashSet <BlockPortTerminal>(); HashSet <Guid> cableAlreadyConnected = new HashSet <Guid>(); foreach (var terminalEndList in _terminalEndsByTerminalId.Values) { foreach (var terminalEnd in terminalEndList) { if (!conduitEndTerminalAlreadyConnected.Contains(terminalEnd.DiagramTerminal)) { // If connected conduit ends if (terminalEnd.TerminalId != Guid.Empty && _terminalEndsByTerminalId[terminalEnd.TerminalId].Any(th => th.DiagramTerminal != terminalEnd.DiagramTerminal)) { var otherDiagramTerminal = _terminalEndsByTerminalId[terminalEnd.TerminalId].First(th => th.DiagramTerminal != terminalEnd.DiagramTerminal); if (!conduitEndTerminalAlreadyConnected.Contains(otherDiagramTerminal.DiagramTerminal)) { System.Diagnostics.Debug.WriteLine($"Will connect conduit ends segmentId: {terminalEnd.SpanSegment.Id} to segmentId: {otherDiagramTerminal.SpanSegment.Id}"); // Conduit connection var terminalConnection = nodeContainerBlock.AddTerminalConnection( fromSide: terminalEnd.DiagramTerminal.Port.Side, fromPortIndex: terminalEnd.DiagramTerminal.Port.Index, fromTerminalIndex: terminalEnd.DiagramTerminal.Index, toSide: otherDiagramTerminal.DiagramTerminal.Port.Side, toPortIndex: otherDiagramTerminal.DiagramTerminal.Port.Index, toTerminalIndex: otherDiagramTerminal.DiagramTerminal.Index, label: null, style: terminalEnd.Style, lineShapeType: LineShapeTypeEnum.Polygon ); terminalConnection.DrawingOrder = 550; // This to make to show branched-out spans on top if (terminalEnd.DiagramTerminal.Port.Side != otherDiagramTerminal.DiagramTerminal.Port.Side) { terminalConnection.DrawingOrder = 560; } terminalConnection.SetReference(terminalEnd.SpanSegment.Id, "SpanSegment"); conduitEndTerminalAlreadyConnected.Add(terminalEnd.DiagramTerminal); conduitEndTerminalAlreadyConnected.Add(otherDiagramTerminal.DiagramTerminal); // Add eventually cable running through inner conduit if (_nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(terminalEnd.SpanSegment.Id)) { var cableId = _nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations[terminalEnd.SpanSegment.Id].First(); var fiberCableLineLabel = _nodeContainerViewModel.Data.GetCableEquipmentLineLabel(cableId); System.Diagnostics.Debug.WriteLine($" Will connect cable: {cableId} {fiberCableLineLabel} through conduit connection"); var cableTerminalConnection = nodeContainerBlock.AddTerminalConnection( fromSide: terminalEnd.DiagramTerminal.Port.Side, fromPortIndex: terminalEnd.DiagramTerminal.Port.Index, fromTerminalIndex: terminalEnd.DiagramTerminal.Index, toSide: otherDiagramTerminal.DiagramTerminal.Port.Side, toPortIndex: otherDiagramTerminal.DiagramTerminal.Port.Index, toTerminalIndex: otherDiagramTerminal.DiagramTerminal.Index, label: fiberCableLineLabel, style: "FiberCable", lineShapeType: LineShapeTypeEnum.Line ); cableTerminalConnection.SetReference(cableId, "SpanSegment"); cableTerminalConnection.DrawingOrder = 600; } } } // Not connected conduit ends else { var test = _nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations; // Add eventually cable running through inner conduit if (_nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(terminalEnd.SpanSegment.Id)) { // Check if cable is running from one port to another var cableIds = _nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations[terminalEnd.SpanSegment.Id]; foreach (var cableId in cableIds) { var cableLineLabel = _nodeContainerViewModel.Data.GetCableEquipmentLineLabel(cableId); System.Diagnostics.Debug.WriteLine($"Not connected conduits ends. Try connecting cable: {cableId} {cableLineLabel} terminalEnd: {terminalEnd.TerminalId} terminalEnd segment id: {terminalEnd.SpanSegment.Id} port-to-port"); // Only connect if cable goes through two span segments and terminal end it not the fake one (where terminal id equal the cable id) if (_nodeContainerViewModel.Data.CableToConduitSegmentParentRelations[cableId].Count == 2 && cableId != terminalEnd.TerminalId) { // get other segment id var otherEndSegmentId = _nodeContainerViewModel.Data.CableToConduitSegmentParentRelations[cableId].First(r => r != terminalEnd.SpanSegment.Id); TerminalEndHolder otherDiagramTerminal = null; if (_terminalEndsByTerminalId.ContainsKey(Guid.Empty) && _terminalEndsByTerminalId[Guid.Empty].Exists(s => s.SpanSegment.Id == otherEndSegmentId)) { otherDiagramTerminal = _terminalEndsByTerminalId[Guid.Empty].First(s => s.SpanSegment.Id == otherEndSegmentId); } else if (_terminalEndsByTerminalId.ContainsKey(cableId)) { otherDiagramTerminal = _terminalEndsByTerminalId[cableId].First(s => s.SpanSegment.Id == otherEndSegmentId); } foreach (var cableIdConnected in cableAlreadyConnected) { System.Diagnostics.Debug.WriteLine($" Already connected cable: {cableIdConnected}"); } if (otherDiagramTerminal != null && !cableAlreadyConnected.Contains(cableId)) { System.Diagnostics.Debug.WriteLine($" Will connect cable: {cableId} {cableLineLabel} port-to-port"); cableAlreadyConnected.Add(cableId); var cableTerminalConnection = nodeContainerBlock.AddTerminalConnection( fromSide: terminalEnd.DiagramTerminal.Port.Side, fromPortIndex: terminalEnd.DiagramTerminal.Port.Index, fromTerminalIndex: terminalEnd.DiagramTerminal.Index, toSide: otherDiagramTerminal.DiagramTerminal.Port.Side, toPortIndex: otherDiagramTerminal.DiagramTerminal.Port.Index, toTerminalIndex: otherDiagramTerminal.DiagramTerminal.Index, label: cableLineLabel, style: "FiberCable", lineShapeType: LineShapeTypeEnum.Line ); cableTerminalConnection.SetReference(cableId, "SpanSegment"); cableTerminalConnection.DrawingOrder = 600; } } else { var segmentIds = _nodeContainerViewModel.Data.CableToConduitSegmentParentRelations[cableId]; // Only make half-connection if the cable is not running between two parent span segments if (segmentIds.Count == 1) { System.Diagnostics.Debug.WriteLine($"Will connect cable: {cableId} half connection. Number of segment relations: {segmentIds.Count}"); var cableTerminalConnection = nodeContainerBlock.AddTerminalHalfConnection( fromSide: terminalEnd.DiagramTerminal.Port.Side, fromPortIndex: terminalEnd.DiagramTerminal.Port.Index, fromTerminalIndex: terminalEnd.DiagramTerminal.Index, label: cableLineLabel, style: "FiberCable", 50 ); cableTerminalConnection.SetReference(cableId, "SpanSegment"); cableTerminalConnection.DrawingOrder = 600; } } } } } } } } }
private void AffixPassThroughConduit(LineBlock nodeContainerBlock, SpanEquipmentViewModel viewModel) { var spanDiagramInfo = viewModel.RootSpanDiagramInfo("OuterConduit"); BlockSideEnum fromSide = viewModel.BlockSideWhereSpanEquipmentShouldBeAffixed(); BlockSideEnum toSide = viewModel.OppositeBlockSideWhereSpanEquipmentShouldBeAffixed(); bool portsVisible = true; // If cut we want to draw the port polygons, because otherwise the outer conduit cannot be seen on the diagram (due to missing connection between the two sides) if (spanDiagramInfo.IsPassThrough) { portsVisible = false; } // Create outer conduit as port var fromPort = new BlockPort(fromSide) { IsVisible = portsVisible, Margin = _portMargin, Style = spanDiagramInfo.StyleName, PointStyle = fromSide.ToString() + "TerminalLabel", PointLabel = viewModel.GetConduitEquipmentLabel() }; fromPort.DrawingOrder = 420; fromPort.SetReference(viewModel.RootSpanDiagramInfo("OuterConduit").IngoingSegmentId, "SpanSegment"); nodeContainerBlock.AddPort(fromPort); var toPort = new BlockPort(toSide) { IsVisible = portsVisible, Margin = _portMargin, Style = spanDiagramInfo.StyleName, PointStyle = toSide.ToString() + "TerminalLabel", PointLabel = viewModel.GetConduitEquipmentLabel() }; toPort.DrawingOrder = 420; toPort.SetReference(viewModel.RootSpanDiagramInfo("OuterConduit").OutgoingSegmentId, "SpanSegment"); nodeContainerBlock.AddPort(toPort); if (spanDiagramInfo.IsPassThrough) { var portConnection = nodeContainerBlock.AddPortConnection(fromSide, fromPort.Index, toSide, toPort.Index, null, spanDiagramInfo.StyleName); portConnection.SetReference(spanDiagramInfo.SegmentId, "SpanSegment"); portConnection.DrawingOrder = 410; } List <SpanDiagramInfo> innerSpanData = viewModel.GetInnerSpanDiagramInfos("InnerConduit"); bool innerSpansFound = false; int terminalNo = 1; if (innerSpanData.Count == 6) { } foreach (var innerSpan in innerSpanData) { TerminalShapeTypeEnum terminalShapeType = TerminalShapeTypeEnum.Point; // If cut we want to draw the terminal polygon, because otherwise the conduit cannot be seen on the diagram (due to missing connection between the two sides) if (!innerSpan.IsPassThrough) { terminalShapeType = TerminalShapeTypeEnum.PointAndPolygon; } string fromNodeName = "NA"; string toNodeName = "NA"; if (innerSpan.IsPassThrough) { fromNodeName = viewModel.GetIngoingRouteNodeName(innerSpan.SegmentId); toNodeName = viewModel.GetOutgoingRouteNodeName(innerSpan.SegmentId); } else { fromNodeName = viewModel.GetIngoingRouteNodeName(innerSpan.IngoingSpanSegment.Id); toNodeName = viewModel.GetOutgoingRouteNodeName(innerSpan.OutgoingSpanSegment.Id); } var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = terminalShapeType, PointStyle = fromSide.ToString() + "TerminalLabel", PointLabel = fromNodeName, PolygonStyle = innerSpan.StyleName }; fromTerminal.SetReference(innerSpan.IngoingSegmentId, "SpanSegment"); fromTerminal.DrawingOrder = 620; var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = terminalShapeType, PointStyle = toSide.ToString() + "TerminalLabel", PointLabel = toNodeName, PolygonStyle = innerSpan.StyleName }; toTerminal.SetReference(innerSpan.OutgoingSegmentId, "SpanSegment"); toTerminal.DrawingOrder = 620; // Connect the two sides, if the inner conduit is not cut / passing through if (innerSpan.IsPassThrough) { var terminalConnection = nodeContainerBlock.AddTerminalConnection(fromSide, fromPort.Index, terminalNo, toSide, toPort.Index, terminalNo, null, innerSpan.StyleName, LineShapeTypeEnum.Polygon); terminalConnection.SetReference(innerSpan.IngoingSegmentId, "SpanSegment"); terminalConnection.DrawingOrder = 510; // Add eventually cable running through inner conduit if (_nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(innerSpan.IngoingSegmentId)) { var cableId = _nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations[innerSpan.IngoingSegmentId].First(); var fiberCableLineLabel = _nodeContainerViewModel.Data.GetCableEquipmentLineLabel(cableId); var cableTerminalConnection = nodeContainerBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); cableTerminalConnection.DrawingOrder = 600; cableTerminalConnection.SetReference(cableId, "SpanSegment"); } } else { // Add from terminal / ingoing segment to ends AddToTerminalEnds(innerSpan.IngoingTerminalId, innerSpan.IngoingSpanSegment, fromTerminal, innerSpan.StyleName); // Add to terminal / outgoing segment to ends AddToTerminalEnds(innerSpan.OutgoingTerminalId, innerSpan.OutgoingSpanSegment, toTerminal, innerSpan.StyleName); } terminalNo++; innerSpansFound = true; } // Create fake inner terminals used to display where the empty multi conduit is heading if (!innerSpansFound) { var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = fromSide.ToString() + "TerminalLabel", PointLabel = viewModel.GetIngoingRouteNodeName(spanDiagramInfo.IngoingSegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(spanDiagramInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = toSide.ToString() + "TerminalLabel", PointLabel = viewModel.GetOutgoingRouteNodeName(spanDiagramInfo.IngoingSegmentId), DrawingOrder = 520 }; toTerminal.SetReference(spanDiagramInfo.OutgoingSegmentId, "SpanSegment"); terminalNo++; } }