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 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);
        }
        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);
        }
Ejemplo n.º 4
0
        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++;
            }
        }