Exemplo n.º 1
0
        public LineBlockTerminalConnection AddTerminalConnection(BlockSideEnum fromSide, int fromPortIndex, int fromTerminalIndex, BlockSideEnum toSide, int toPortIndex, int toTerminalIndex, string label = null, string style = null, LineShapeTypeEnum lineShapeType = LineShapeTypeEnum.Line)
        {
            var connection = new LineBlockTerminalConnection();

            connection.Label         = label;
            connection.Style         = style;
            connection.LineShapeType = lineShapeType;
            connection.FromTerminal  = _sides[fromSide].GetPortByIndex(fromPortIndex).GetTerminalByIndex(fromTerminalIndex);

            if (connection.FromTerminal == null)
            {
                throw new Exception("Can't find from terminal side: " + fromSide.ToString() + " port: " + fromPortIndex + " terminal: " + fromTerminalIndex);
            }

            connection.ToTerminal = _sides[toSide].GetPortByIndex(toPortIndex).GetTerminalByIndex(toTerminalIndex);

            if (connection.ToTerminal == null)
            {
                throw new Exception("Can't find to terminal side: " + toSide.ToString() + " port: " + toPortIndex + " terminal: " + toTerminalIndex);
            }


            _terminalConnections.Add(connection);

            return(connection);
        }
Exemplo n.º 2
0
        private DiagramObject CreateSide(Diagram diagram, BlockSideEnum side, double x, double y, double containerWidth, double containerHeight)
        {
            Geometry lineGeometry = null;

            if (side == BlockSideEnum.West)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y, x, y + containerHeight);
            }
            else if (side == BlockSideEnum.North)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y + containerHeight, x + containerWidth, y + containerHeight);
            }
            else if (side == BlockSideEnum.East)
            {
                lineGeometry = GeometryBuilder.StraightLine(x + containerWidth, y, x + containerWidth, y + containerHeight);
            }
            else if (side == BlockSideEnum.South)
            {
                lineGeometry = GeometryBuilder.StraightLine(x, y, x + containerWidth, y);
            }

            var containerSide = new DiagramObject(diagram)
            {
                Style        = "NodeContainerSide" + side.ToString(),
                Geometry     = lineGeometry,
                DrawingOrder = 700
            };

            containerSide.SetReference(_nodeContainerViewModel.NodeContainer.Id, "NodeContainer");

            return(containerSide);
        }
Exemplo n.º 3
0
        private BlockPort CreatePortForOuterConduitEnd(SpanEquipmentViewModel viewModel, BlockSideEnum blockSide)
        {
            var routeSpanDiagramInfo = viewModel.RootSpanDiagramInfo("OuterConduit");

            var port = new BlockPort(blockSide)
            {
                IsVisible  = viewModel.IsSingleSpan ? false : true,
                Margin     = viewModel.IsSingleSpan ? _portMargin / 2 : _portMargin,
                Style      = routeSpanDiagramInfo.StyleName,
                PointStyle = blockSide.ToString() + "TerminalLabel",
                PointLabel = viewModel.GetConduitEquipmentLabel(),
            };

            port.DrawingOrder = 420;

            port.SetReference(routeSpanDiagramInfo.SegmentId, "SpanSegment");

            return(port);
        }
Exemplo 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++;
            }
        }