Exemple #1
0
        void RouteEdgeWithLabel(IntEdge intEdge, Label label)
        {
            //we allow here for the edge to cross its own label
            Node             sourceNode    = routing.IntGraph.Nodes[intEdge.Source];
            Node             targetNode    = routing.IntGraph.Nodes[intEdge.Target];
            var              sourcePort    = new FloatingPort(sourceNode.BoundaryCurve, sourceNode.Center);
            var              targetPort    = new FloatingPort(targetNode.BoundaryCurve, targetNode.Center);
            ICurve           labelObstacle = labelsToLabelObstacles[label];
            var              labelPort     = new FloatingPort(labelObstacle, label.Center);
            SmoothedPolyline poly0;

            interactiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(sourcePort, labelPort, true, out poly0);
            SmoothedPolyline poly1;

            interactiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(labelPort, targetPort, true, out poly1);
            Site site = poly1.HeadSite.Next;

            Site lastSite = poly0.LastSite;

            lastSite.Next = site;
            site.Previous = lastSite;
            var eg = intEdge.Edge.EdgeGeometry;

            eg.SetSmoothedPolylineAndCurve(poly0);
            Arrowheads.TrimSplineAndCalculateArrowheads(eg, intEdge.Edge.Source.BoundaryCurve,
                                                        intEdge.Edge.Target.BoundaryCurve, eg.Curve, false,
                                                        settings.EdgeRoutingSettings.KeepOriginalSpline);
        }
        void RouteEdgeWithNoLabel(PolyIntEdge intEdge)
        {
            Node             sourceNode = routing.IntGraph.Nodes[intEdge.Source];
            Node             targetNode = routing.IntGraph.Nodes[intEdge.Target];
            var              sourcePort = new FloatingPort(sourceNode.BoundaryCurve, sourceNode.Center);
            var              targetPort = new FloatingPort(targetNode.BoundaryCurve, targetNode.Center);
            var              eg         = intEdge.Edge.EdgeGeometry;
            SmoothedPolyline sp;

            eg.Curve = interactiveEdgeRouter.RouteSplineFromPortToPortWhenTheWholeGraphIsReady(sourcePort, targetPort, true, out sp);
            Arrowheads.TrimSplineAndCalculateArrowheads(eg, intEdge.Edge.Source.BoundaryCurve,
                                                        intEdge.Edge.Target.BoundaryCurve, eg.Curve, false);
            intEdge.Edge.EdgeGeometry = eg;
        }
Exemple #3
0
        protected FloatingPort MakeAbsoluteObstaclePort(Shape obstacle, Point location)
        {
            Validate.IsNotNull(obstacle, "Obstacle should not be null");

            // For absolute obstacle ports, we don't associate a shape if we are using freeports.
            // This gives test coverage of the case of a freeport/waypoint covered by an unrelated obstacle.
            if (this.UseFreePortsForObstaclePorts)
            {
                return(new FloatingPort(null, location));
            }
            var port = new FloatingPort(obstacle.BoundaryCurve, location);

            obstacle.Ports.Insert(port);
            return(port);
        }
Exemple #4
0
        private void ReadPorts()
        {
            Match m;

            this.VerifyIsNextLine(RectFileStrings.BeginPorts);

            // Get to the first line for consistency with the lookahead for multiPort offsets and/or any
            // PortEntries, which will end up reading the following line.
            this.NextLine();

            for (;;)
            {
                if (!(m = ParseOrDone(RectFileStrings.ParsePort, RectFileStrings.EndPorts)).Success)
                {
                    break;
                }

                bool isMultiPort = IsString(m.Groups["type"].ToString(), RectFileStrings.Multi);
                bool isRelative  = IsString(m.Groups["type"].ToString(), RectFileStrings.Relative);
                var  x           = double.Parse(m.Groups["X"].ToString());
                var  y           = double.Parse(m.Groups["Y"].ToString());
                var  portId      = int.Parse(m.Groups["portId"].ToString());
                var  shapeId     = int.Parse(m.Groups["shapeId"].ToString());
                Validate.IsFalse(idToPortMap.ContainsKey(portId), "PortId already exists");
                var   location = new Point(x, y);
                Shape shape    = GetShapeFromId(shapeId, isMultiPort || isRelative);
                Port  port;
                if (isMultiPort)
                {
                    // 'location' was actually the active offset of the multiPort.  Recreate it and reset the
                    // closest-location and verify the active offset index is the same.  This may fail if there
                    // are two identical offsets in the offset list, in which case fix the test setup.
                    int activeOffsetIndex;
                    var offsets   = ReadMultiPortOffsets(out activeOffsetIndex);
                    var multiPort = new MultiLocationFloatingPort(() => shape.BoundaryCurve, () => shape.BoundingBox.Center, offsets);
                    multiPort.SetClosestLocation(multiPort.CenterDelegate() + location);
                    Validate.AreEqual(multiPort.ActiveOffsetIndex, activeOffsetIndex, CurrentLineError("ActiveOffsetIndex is not as expected"));
                    port = multiPort;
                }
                else
                {
                    if (isRelative)
                    {
                        // The location in the ParsePort line is the offset for the relative port.
                        port = new RelativeFloatingPort(() => shape.BoundaryCurve, () => shape.BoundingBox.Center, location);
                    }
                    else
                    {
                        Validate.IsTrue(IsString(m.Groups["type"].ToString(), RectFileStrings.Floating), CurrentLineError("Unknown port type"));
                        port = new FloatingPort((null == shape) ? null : shape.BoundaryCurve, location);
                    }
                    this.NextLine();    // Since we didn't read multiPort offsets
                }
                idToPortMap.Add(portId, port);
                if (null != shape)
                {
                    if (!this.UseFreePortsForObstaclePorts)
                    {
                        shape.Ports.Insert(port);
                    }
                    else
                    {
                        FreeRelativePortToShapeMap[port] = shape;
                    }
                }
                ReadPortEntries(port);
            }
        }