private LineBlock CreateSpanEquipmentBlock(double extraHeightTop = 0) { var nodeEquipmentBlock = new LineBlock() { MinWidth = _initialMinWidth, ExtraHeightTop = extraHeightTop, IsVisible = true, Style = "NodeContainer", Margin = _nodeContainerBlockMargin, DrawingOrder = 100, VerticalContentAlignment = GetContainerVerticalAlignment() }; nodeEquipmentBlock.SetReference(_nodeContainerViewModel.NodeContainer.Id, "NodeContainer"); AffixConduits(nodeEquipmentBlock); ConnectEnds(nodeEquipmentBlock); nodeEquipmentBlock.SetSideCenterAlignment(BlockSideEnum.North); nodeEquipmentBlock.SetSideCenterAlignment(BlockSideEnum.South); return(nodeEquipmentBlock); }
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); }
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 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); }