Example #1
0
        public override bool TryGetPoint(byte pointNum, MarkupPoint.PointType type, out MarkupPoint point)
        {
            switch (type)
            {
            case MarkupPoint.PointType.Enter:
                return(base.TryGetPoint(pointNum, type, out point));

            case MarkupPoint.PointType.Crosswalk:
                if (CrosswalkPointsDic.TryGetValue(pointNum, out MarkupCrosswalkPoint crosswalkPoint))
                {
                    point = crosswalkPoint;
                    return(true);
                }
                break;

            case MarkupPoint.PointType.Normal:
                if (NormalPointsDic.TryGetValue(pointNum, out MarkupNormalPoint normalPoint))
                {
                    point = normalPoint;
                    return(true);
                }
                break;
            }
            point = null;
            return(false);
        }
Example #2
0
        public void FromXml(string version, XElement config, Dictionary <ObjectId, ObjectId> map = null)
        {
            if (VersionComparer.Instance.Compare(version, "1.2") < 0)
            {
                map = VersionMigration.Befor1_2(this, map);
            }

            foreach (var pointConfig in config.Elements(MarkupPoint.XmlName))
            {
                MarkupPoint.FromXml(pointConfig, this, map);
            }

            var toInit = new Dictionary <MarkupLine, XElement>();

            foreach (var lineConfig in config.Elements(MarkupLine.XmlName))
            {
                if (MarkupLine.FromXml(lineConfig, this, map, out MarkupLine line))
                {
                    LinesDictionary[line.Id] = line;
                    toInit[line]             = lineConfig;
                }
            }
            foreach (var pair in toInit)
            {
                pair.Key.FromXml(pair.Value, map);
            }

            foreach (var fillerConfig in config.Elements(MarkupFiller.XmlName))
            {
                if (MarkupFiller.FromXml(fillerConfig, this, map, out MarkupFiller filler))
                {
                    FillersList.Add(filler);
                }
            }
        }
Example #3
0
        public static bool FromId(int id, Markup markup, ObjectsMap map, out MarkupPoint point)
        {
            point = null;

            var enterId = GetEnter(id);
            var num     = GetNum(id);
            var type    = GetType(id);

            if (map.TryGetValue(new ObjectId()
            {
                Segment = enterId
            }, out ObjectId targetSegment))
            {
                enterId = targetSegment.Segment;
            }
            if (map.TryGetValue(new ObjectId()
            {
                Point = GetId(enterId, num, type)
            }, out ObjectId targetPoint))
            {
                num = GetNum(targetPoint.Point);
            }

            return(markup.TryGetEnter(enterId, out Enter enter) && enter.TryGetPoint(num, type, out point));
        }
Example #4
0
 public bool TryGetPoint(byte pointNum, out MarkupPoint point)
 {
     if (1 <= pointNum && pointNum <= PointCount)
     {
         point = PointsList[pointNum - 1];
         return(true);
     }
     else
     {
         point = null;
         return(false);
     }
 }
Example #5
0
 public virtual bool TryGetPoint(byte pointNum, MarkupPoint.PointType type, out MarkupPoint point)
 {
     if (type == MarkupPoint.PointType.Enter && EnterPointsDic.TryGetValue(pointNum, out MarkupEnterPoint enterPoint))
     {
         point = enterPoint;
         return(true);
     }
     else
     {
         point = null;
         return(false);
     }
 }
Example #6
0
 public static bool FromXml(XElement config, Markup markup, Dictionary<ObjectId, ObjectId> map, out EnterFillerVertex enterPoint)
 {
     var pointId = config.GetAttrValue<int>(MarkupPoint.XmlName);
     if (MarkupPoint.FromId(pointId, markup, map, out MarkupPoint point))
     {
         enterPoint = new EnterFillerVertex(point);
         return true;
     }
     else
     {
         enterPoint = null;
         return false;
     }
 }
Example #7
0
        public void Update(MarkupPoint point)
        {
            point.Update();

            foreach (var line in GetPointLines(point))
            {
                line.UpdateTrajectory();
            }
            foreach (var filler in GetPointFillers(point))
            {
                filler.Update();
            }

            RecalculateDashes();
        }
Example #8
0
        public static bool FromXml(XElement config, Markup markup, ObjectsMap map, out EnterPointEdge enterPoint)
        {
            var pointId = config.GetAttrValue <int>(MarkupPoint.XmlName);

            if (MarkupPoint.FromId(pointId, markup, map, out MarkupPoint point))
            {
                enterPoint = new EnterPointEdge(point);
                return(true);
            }
            else
            {
                enterPoint = null;
                return(false);
            }
        }
Example #9
0
        private ILinePartEdge GetDefaultEdge(MarkupPoint point)
        {
            if (!Settings.CutLineByCrosswalk || point.Type == MarkupPoint.PointType.Normal)
            {
                return(new EnterPointEdge(point));
            }

            var intersects = Markup.GetIntersects(this).Where(i => i.IsIntersect && i.Pair.GetOther(this) is MarkupCrosswalkLine line && line.PointPair.ContainsEnter(point.Enter)).ToArray();

            if (!intersects.Any())
            {
                return(new EnterPointEdge(point));
            }

            var intersect = intersects.Aggregate((i, j) => point == End ^ (i.FirstT > i.SecondT) ? i : j);

            return(new LinesIntersectEdge(intersect.Pair));
        }
Example #10
0
        public static bool FromXml(XElement config, Markup markup, ObjectsMap map, out EnterFillerVertexBase enterPoint)
        {
            var pointId = config.GetAttrValue <int>(MarkupPoint.XmlName);

            if (MarkupPoint.FromId(pointId, markup, map, out MarkupPoint point))
            {
                var lineId = config.GetAttrValue <ulong>(MarkupLine.XmlName);
                if (markup.TryGetLine(lineId, map, out MarkupRegularLine line))
                {
                    enterPoint = new LineEndFillerVertex(point, line);
                }
                else
                {
                    enterPoint = new EnterFillerVertex(point);
                }
                return(true);
            }
            else
            {
                enterPoint = null;
                return(false);
            }
        }
Example #11
0
        public static bool FromId(int id, Markup markup, ObjectsMap map, out MarkupPoint point)
        {
            point = null;

            var enterId = GetEnter(id);
            var num     = GetNum(id);
            var type    = GetType(id);

            switch (markup.Type)
            {
            case MarkupType.Node when map.TryGetValue(new ObjectId()
                {
                    Segment = enterId
                }, out ObjectId targetSegment):
                enterId = targetSegment.Segment;

                break;

            case MarkupType.Segment when map.TryGetValue(new ObjectId()
                {
                    Node = enterId
                }, out ObjectId targetNode):
                enterId = targetNode.Node;

                break;
            }

            if (map.TryGetValue(new ObjectId()
            {
                Point = GetId(enterId, num, type)
            }, out ObjectId targetPoint))
            {
                num = GetNum(targetPoint.Point);
            }

            return(markup.TryGetEnter(enterId, out Enter enter) && enter.TryGetPoint(num, type, out point));
        }
Example #12
0
 public IEnumerable <MarkupLine> GetPointLines(MarkupPoint point) => LinesDictionary.Values.Where(l => l.ContainsPoint(point));
Example #13
0
 protected MarkupLine(NodeMarkup markup, MarkupPoint first, MarkupPoint second, bool update = true) : this(markup, new MarkupPointPair(first, second), update)
 {
 }
Example #14
0
 public EnterSupportPoint(MarkupPoint point)
 {
     Point = point;
     Update();
 }
Example #15
0
        public static bool FromId(int id, Markup markup, Dictionary <ObjectId, ObjectId> map, out MarkupPoint point)
        {
            point = null;

            var enterId = GetEnter(id);
            var num     = GetNum(id);

            if (map != null)
            {
                if (map.TryGetValue(new ObjectId()
                {
                    Segment = enterId
                }, out ObjectId targetSegment))
                {
                    enterId = targetSegment.Segment;
                }
                if (map.TryGetValue(new ObjectId()
                {
                    Point = GetId(enterId, num)
                }, out ObjectId targetPoint))
                {
                    num = GetNum(targetPoint.Point);
                }
            }

            return(markup.TryGetEnter(enterId, out Enter enter) && enter.TryGetPoint(num, out point));
        }
Example #16
0
 static Alignment GetAlignment(MarkupRegularLine line, MarkupPoint point) => line?.GetAlignment(point) ?? Alignment.Centre;
Example #17
0
 public EnterFillerVertexBase(MarkupPoint point) : base(point)
 {
 }
Example #18
0
 public IEnumerable <MarkupFiller> GetPointFillers(MarkupPoint point) => FillersList.Where(f => f.ContainsPoint(point));
Example #19
0
 protected MarkupStraightLine(Markup markup, MarkupPoint first, MarkupPoint second, StyleType styleType) : this(markup, new MarkupPointPair(first, second), styleType)
 {
 }
Example #20
0
 public MarkupLine(Markup markup, MarkupPoint first, MarkupPoint second) : this(markup, new MarkupPointPair(first, second))
 {
 }
Example #21
0
 public bool ContainsPoint(MarkupPoint point) => PointPair.ContainPoint(point);
Example #22
0
 public bool IsStart(MarkupPoint point) => Start == point;
Example #23
0
 public bool IsEnd(MarkupPoint point) => End == point;
Example #24
0
 public Alignment GetAlignment(MarkupPoint point) => PointPair.ContainsPoint(point) && point.IsSplit ? (IsStart(point) ? Alignment : Alignment.Invert()) : Alignment.Centre;
Example #25
0
 public EnterSupportPoint(MarkupPoint point) : base(point.Position)
 {
     Point = point;
 }
Example #26
0
 public MarkupRegularLine(Markup markup, MarkupPoint first, MarkupPoint second, RegularLineStyle style = null, Alignment alignment = Alignment.Centre, bool update = true) : this(markup, MarkupPointPair.FromPoints(first, second, out bool invert), style, !invert ? alignment : alignment.Invert(), update)
 {
 }
Example #27
0
 public EnterPointEdge(MarkupPoint point) : base(point)
 {
 }
Example #28
0
 public MarkupEnterLine(Markup markup, MarkupPoint first, MarkupPoint second) : base(markup, first, second, RegularLineStyle.RegularLineType.Dashed)
 {
 }