public MarkupEnterLine(Markup markup, MarkupPoint first, MarkupPoint second, Alignment firstAlignment = Alignment.Centre, Alignment secondAlignment = Alignment.Centre) : base(markup, MarkupPointPair.FromPoints(first, second, out bool invert), false) { StartAlignment = !invert ? firstAlignment : secondAlignment; EndAlignment = !invert ? secondAlignment : firstAlignment; Update(true); }
public static ObjectsMap Befor1_9(Markup markup, ObjectsMap map) { if (map == null) { map = new ObjectsMap(); } foreach (var enter in markup.Enters) { ref var segment = ref enter.GetSegment(); if (segment.Info.m_vehicleTypes.IsFlagSet(VehicleInfo.VehicleType.Plane)) { var sourceId = MarkupPoint.GetId(enter.Id, 2, MarkupPoint.PointType.Enter); var targetId = MarkupPoint.GetId(enter.Id, 3, MarkupPoint.PointType.Enter); map.AddPoint(sourceId, targetId); sourceId = MarkupPoint.GetId(enter.Id, 2, MarkupPoint.PointType.Crosswalk); targetId = MarkupPoint.GetId(enter.Id, 3, MarkupPoint.PointType.Crosswalk); map.AddPoint(sourceId, targetId); sourceId = MarkupPoint.GetId(enter.Id, 2, MarkupPoint.PointType.Normal); targetId = MarkupPoint.GetId(enter.Id, 3, MarkupPoint.PointType.Normal); map.AddPoint(sourceId, targetId); } }
public void AddPoint(ushort enter, byte source, byte target) { foreach (var pointType in Enum.GetValues(typeof(MarkupPoint.PointType)).OfType <MarkupPoint.PointType>()) { AddPoint(MarkupPoint.GetId(enter, source, pointType), MarkupPoint.GetId(enter, target, pointType)); } }
protected override IEnumerable <MarkupPoint> GetTarget(Enter enter, MarkupPoint ignore) { var allow = enter.Points.Select(i => 1).ToArray(); if (ignore != null && ignore.Enter == enter) { if ((Markup.SupportLines & MarkupLine.LineType.Stop) == 0) { yield break; } var ignoreIdx = ignore.Num - 1; var leftIdx = ignoreIdx; var rightIdx = ignoreIdx; foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Stop && l.Start.Enter == enter)) { var from = Math.Min(line.Start.Num, line.End.Num) - 1; var to = Math.Max(line.Start.Num, line.End.Num) - 1; if (from < ignore.Num - 1 && ignore.Num - 1 < to) { yield break; } allow[from] = 2; allow[to] = 2; for (var i = from + 1; i <= to - 1; i += 1) { allow[i] = 0; } if (line.ContainsPoint(ignore)) { var otherIdx = line.PointPair.GetOther(ignore).Num - 1; if (otherIdx < ignoreIdx) { leftIdx = otherIdx; } else if (otherIdx > ignoreIdx) { rightIdx = otherIdx; } } } SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1); SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1); allow[ignoreIdx] = 0; } foreach (var point in enter.Points) { if (allow[point.Num - 1] != 0) { yield return(point); } } }
private void OnPointDrag(MarkupPoint point) { var normal = point.Enter.CornerDir.Turn90(true); Line2.Intersect(point.Position.XZ(), (point.Position + point.Enter.CornerDir).XZ(), MouseWorldPosition.XZ(), (MouseWorldPosition + normal).XZ(), out float offsetChange, out _); point.Offset = (point.Offset + offsetChange * Mathf.Sin(point.Enter.CornerAndNormalAngle)).RoundToNearest(0.01f); }
protected void SetTarget(MarkupPoint ignore = null) { TargetPoints.Clear(); foreach (var enter in Tool.Markup.Enters) { TargetPoints.AddRange(GetTarget(enter, ignore)); } }
private void SetEnterTarget(Enter enter, MarkupPoint ignore) { if (ignore == null || ignore.Enter != enter) { TargetPoints.AddRange(enter.Points.Cast <MarkupPoint>()); return; } var allow = enter.Points.Select(i => 1).ToArray(); var ignoreIdx = ignore.Num - 1; var leftIdx = ignoreIdx; var rightIdx = ignoreIdx; foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Stop && l.Start.Enter == enter)) { var from = Math.Min(line.Start.Num, line.End.Num) - 1; var to = Math.Max(line.Start.Num, line.End.Num) - 1; if (from < ignore.Num - 1 && ignore.Num - 1 < to) { return; } allow[from] = 2; allow[to] = 2; for (var i = from + 1; i <= to - 1; i += 1) { allow[i] = 0; } if (line.ContainsPoint(ignore)) { var otherIdx = line.PointPair.GetOther(ignore).Num - 1; if (otherIdx < ignoreIdx) { leftIdx = otherIdx; } else if (otherIdx > ignoreIdx) { rightIdx = otherIdx; } } } SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1); SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1); allow[ignoreIdx] = 0; foreach (var point in enter.Points) { if (allow[point.Num - 1] != 0) { TargetPoints.Add(point); } } }
private void OnPointDrag(MarkupPoint point) { RaycastInput input = new RaycastInput(MouseRay, MouseRayLength); RayCast(input, out RaycastOutput output); var normal = point.Enter.CornerDir.Turn90(true); Line2.Intersect(VectorUtils.XZ(point.Position), VectorUtils.XZ(point.Position + point.Enter.CornerDir), VectorUtils.XZ(output.m_hitPos), VectorUtils.XZ(output.m_hitPos + normal), out float offsetChange, out _); point.Offset = (point.Offset + offsetChange).RoundToNearest(0.01f); }
public static void RenderPointOverlay(RenderManager.CameraInfo cameraInfo, MarkupPoint point, Color color, float width) { if (point.Type == MarkupPoint.PointType.Crosswalk) { var dir = point.Enter.CornerDir.Turn90(true) * MarkupCrosswalkPoint.Shift; var bezier = new Line3(point.Position - dir, point.Position + dir).GetBezier(); RenderBezier(cameraInfo, color, bezier, width); } else { RenderCircle(cameraInfo, color, point.Position, width); } }
public override void OnSecondaryMouseClicked() { if (IsSelectPoint) { SelectPoint = null; SetTarget(); } else { Tool.SetMarkup(null); Tool.SetMode(ToolModeType.Select); } }
public override bool OnEscape() { if (IsSelectPoint) { SelectPoint = null; SetTarget(); return(true); } else { return(false); } }
private FloatPropertyPanel AddPointProperty(MarkupPoint point) { var pointProperty = ComponentPool.Get <FloatPropertyPanel>(PropertiesPanel); pointProperty.Text = $"Point #{point.Num} offset" /*NodeMarkup.Localize.PointEditor_Offset*/; pointProperty.UseWheel = true; pointProperty.WheelStep = 0.1f; pointProperty.WheelTip = WheelTip; pointProperty.Init(); pointProperty.Value = point.Offset; pointProperty.OnValueChanged += OffsetChanged; //pointProperty.OnHover += Hover; //pointProperty.OnLeave += Leave; return(pointProperty); void OffsetChanged(float value) => point.Offset = value; void Hover() => HoverPoint = point; }
private void SetCrosswalkTarget(Enter enter, MarkupPoint ignore) { if (ignore != null && ignore.Enter != enter) { return; } var allow = enter.Crosswalks.Select(i => 1).ToArray(); var bridge = new Dictionary <MarkupPoint, int>(); foreach (var crosswalk in enter.Crosswalks) { bridge.Add(crosswalk, bridge.Count); } var isIgnore = ignore?.Enter == enter; var ignoreIdx = isIgnore ? bridge[ignore] : 0; var leftIdx = ignoreIdx; var rightIdx = ignoreIdx; foreach (var line in enter.Markup.Lines.Where(l => l.Type == MarkupLine.LineType.Crosswalk && l.Start.Enter == enter)) { var from = Math.Min(bridge[line.Start], bridge[line.End]); var to = Math.Max(bridge[line.Start], bridge[line.End]); allow[from] = 2; allow[to] = 2; for (var i = from + 1; i <= to - 1; i += 1) { allow[i] = 0; } if (isIgnore && line.ContainsPoint(ignore)) { var otherIdx = bridge[line.PointPair.GetOther(ignore)]; if (otherIdx < ignoreIdx) { leftIdx = otherIdx; } else if (otherIdx > ignoreIdx) { rightIdx = otherIdx; } } } if (isIgnore) { SetNotAllow(allow, leftIdx == ignoreIdx ? Find(allow, ignoreIdx, -1) : leftIdx, -1); SetNotAllow(allow, rightIdx == ignoreIdx ? Find(allow, ignoreIdx, 1) : rightIdx, 1); allow[ignoreIdx] = 0; } foreach (var point in bridge) { if (allow[point.Value] != 0) { TargetPoints.Add(point.Key); } } }
public override void OnPrimaryMouseClicked(Event e) { SelectPoint = HoverPoint; SetTarget(SelectPoint); }
protected override void Reset(IToolMode prevMode) { HoverPoint = null; SelectPoint = null; SetTarget(); }
protected abstract IEnumerable <MarkupPoint> GetTarget(Enter enter, MarkupPoint ignore);
protected MarkupEnterLine(Markup markup, MarkupPoint first, MarkupPoint second, Style style, Alignment firstAlignment, Alignment secondAlignment) : this(markup, MarkupPointPair.FromPoints(first, second, out bool invert), style, !invert ? firstAlignment : secondAlignment, !invert ? secondAlignment : firstAlignment) { }
public MarkupEnterLine(Markup markup, MarkupPoint first, MarkupPoint second) : base(markup, first, second, RegularLineStyle.RegularLineType.Dashed) { }
public MarkupFillerTempLine(Markup markup, MarkupPoint first, MarkupPoint second, Alignment alignment) : base(markup, first, second, null, alignment) { }
private void RenderPointOverlay(RenderManager.CameraInfo cameraInfo, MarkupPoint point) { RenderManager.OverlayEffect.DrawCircle(cameraInfo, point.Color, point.Position, 1f, -1f, 1280f, false, true); }
public static void RenderPointOverlay(RenderManager.CameraInfo cameraInfo, MarkupPoint point) => RenderPointOverlay(cameraInfo, point, point.Color, 1f);
private void SetTarget(MarkupPoint.PointType pointType = MarkupPoint.PointType.Enter, MarkupPoint ignore = null) { TargetPoints.Clear(); foreach (var enter in EditMarkup.Enters) { if ((pointType & MarkupPoint.PointType.Enter) == MarkupPoint.PointType.Enter) { SetEnterTarget(enter, ignore); } if ((pointType & MarkupPoint.PointType.Crosswalk) == MarkupPoint.PointType.Crosswalk) { SetCrosswalkTarget(enter, ignore); } } }
private void RenderNodeEnterPointsOverlay(RenderManager.CameraInfo cameraInfo, MarkupPoint ignore = null) { foreach (var enter in EditMarkup.Enters) { foreach (var point in enter.Points.Where(p => p != ignore)) { RenderPointOverlay(cameraInfo, point); } } }
public void EditPoint(MarkupPoint point) => Edit <PointsEditor, MarkupPoint>(point);
public void EditPoint(MarkupPoint point) { var editor = SelectEditor <PointsEditor>(); editor?.UpdateEditor(point); }
protected override void Reset(BaseToolMode prevMode) { DragPoint = prevMode is MakeLineToolMode makeLineMode ? makeLineMode.HoverPoint : null; }
private static IMarkup DoGraphicToIMarkup(IGraphic graphic) { if (graphic == null || graphic.ParentPresentationImage == null) return null; IMarkup markup = null; var roiGraphic = graphic as RoiGraphic; if (roiGraphic != null) { if (roiGraphic.Roi is EllipticalRoi) { var ellipse = roiGraphic.Roi as EllipticalRoi; markup = new MarkupEllipse { TopLeft = new PointF(ellipse.BoundingBox.Left, ellipse.BoundingBox.Top), BottomRight = new PointF(ellipse.BoundingBox.Right, ellipse.BoundingBox.Bottom), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is PolygonalRoi) { var polygon = roiGraphic.Roi as PolygonalRoi; markup = new MarkupPolygonal { Name = graphic.Name, Vertices = polygon.Polygon.Vertices == null ? null : new List<PointF>(polygon.Polygon.Vertices), GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is RectangularRoi) { var rectangularRoi = roiGraphic.Roi as RectangularRoi; markup = new MarkupRectangle { TopLeft = new PointF(rectangularRoi.BoundingBox.Left, rectangularRoi.BoundingBox.Top), BottomRight = new PointF(rectangularRoi.BoundingBox.Right, rectangularRoi.BoundingBox.Bottom), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is ProtractorRoi) { var protractorRoi = roiGraphic.Roi as ProtractorRoi; markup = new MarkupProtractor { TopLeft = new PointF(protractorRoi.BoundingBox.Left, protractorRoi.BoundingBox.Top), BottomRight = new PointF(protractorRoi.BoundingBox.Right, protractorRoi.BoundingBox.Bottom), Name = graphic.Name, Points = protractorRoi.Points == null ? null : new List<PointF>(protractorRoi.Points), GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is LinearRoi) { var linearRoi = roiGraphic.Roi as LinearRoi; markup = new MarkupLinear { Vertices = linearRoi.Points == null ? null : new List<PointF>(linearRoi.Points), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } if (markup != null) markup.CaptionText = roiGraphic.Roi.GetType().Name + Environment.NewLine + roiGraphic.Callout.Text; } else if (graphic is UserCalloutGraphic) { var userCalloutGraphic = graphic as UserCalloutGraphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = userCalloutGraphic.Text, CalloutText = userCalloutGraphic.Text, CalloutLocation = userCalloutGraphic.TextLocation, Point = userCalloutGraphic.AnchorPoint, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is CrosshairCalloutGraphic) { var userCalloutGraphic = graphic as CrosshairCalloutGraphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = userCalloutGraphic.Text, CalloutText = userCalloutGraphic.Text, CalloutLocation = userCalloutGraphic.TextLocation, Point = userCalloutGraphic.AnchorPoint, UseCrosshair = true, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is InvariantTextPrimitive) { var textGraphic = (InvariantTextPrimitive)graphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = textGraphic.Text, CalloutText = textGraphic.Text, CalloutLocation = textGraphic.Location, Point = textGraphic.Location, UseCrosshair = false, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is ContextMenuControlGraphic) { markup = DoGraphicToIMarkup(((ContextMenuControlGraphic)graphic).Subject); } else if (graphic is AimGraphic) { markup = DoGraphicToIMarkup(((AimGraphic)graphic).Graphic); // Fix name - not all composite graphics may have the Name set correctly if (markup != null) markup.Name = ((AimGraphic)graphic).Graphic.Name; } else if (graphic is StandardStatefulGraphic) { markup = DoGraphicToIMarkup(((StandardStatefulGraphic)graphic).Subject); } else if (graphic is SegFrameImageGraphic) { // NO-OP // TODO: implement IMarkup for this type of graphic if we ever need to have segmentation graphic in the TemplateTree } else System.Diagnostics.Debug.Assert(false, "Could not create Markup from " + graphic.GetType().Name); return markup; }
private static IMarkup DoGraphicToIMarkup(IGraphic graphic) { if (graphic == null || graphic.ParentPresentationImage == null) { return(null); } IMarkup markup = null; var roiGraphic = graphic as RoiGraphic; if (roiGraphic != null) { if (roiGraphic.Roi is EllipticalRoi) { var ellipse = roiGraphic.Roi as EllipticalRoi; markup = new MarkupEllipse { TopLeft = new PointF(ellipse.BoundingBox.Left, ellipse.BoundingBox.Top), BottomRight = new PointF(ellipse.BoundingBox.Right, ellipse.BoundingBox.Bottom), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is PolygonalRoi) { var polygon = roiGraphic.Roi as PolygonalRoi; markup = new MarkupPolygonal { Name = graphic.Name, Vertices = polygon.Polygon.Vertices == null ? null : new List <PointF>(polygon.Polygon.Vertices), GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is RectangularRoi) { var rectangularRoi = roiGraphic.Roi as RectangularRoi; markup = new MarkupRectangle { TopLeft = new PointF(rectangularRoi.BoundingBox.Left, rectangularRoi.BoundingBox.Top), BottomRight = new PointF(rectangularRoi.BoundingBox.Right, rectangularRoi.BoundingBox.Bottom), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is ProtractorRoi) { var protractorRoi = roiGraphic.Roi as ProtractorRoi; markup = new MarkupProtractor { TopLeft = new PointF(protractorRoi.BoundingBox.Left, protractorRoi.BoundingBox.Top), BottomRight = new PointF(protractorRoi.BoundingBox.Right, protractorRoi.BoundingBox.Bottom), Name = graphic.Name, Points = protractorRoi.Points == null ? null : new List <PointF>(protractorRoi.Points), GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } else if (roiGraphic.Roi is LinearRoi) { var linearRoi = roiGraphic.Roi as LinearRoi; markup = new MarkupLinear { Vertices = linearRoi.Points == null ? null : new List <PointF>(linearRoi.Points), Name = graphic.Name, GraphicHashcode = graphic.GetHashCode(), CalloutLocation = roiGraphic.Callout.TextLocation }; } if (markup != null) { markup.CaptionText = roiGraphic.Roi.GetType().Name + Environment.NewLine + roiGraphic.Callout.Text; } } else if (graphic is UserCalloutGraphic) { var userCalloutGraphic = graphic as UserCalloutGraphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = userCalloutGraphic.Text, CalloutText = userCalloutGraphic.Text, CalloutLocation = userCalloutGraphic.TextLocation, Point = userCalloutGraphic.AnchorPoint, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is CrosshairCalloutGraphic) { var userCalloutGraphic = graphic as CrosshairCalloutGraphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = userCalloutGraphic.Text, CalloutText = userCalloutGraphic.Text, CalloutLocation = userCalloutGraphic.TextLocation, Point = userCalloutGraphic.AnchorPoint, UseCrosshair = true, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is InvariantTextPrimitive) { var textGraphic = (InvariantTextPrimitive)graphic; markup = new MarkupPoint { Name = graphic.Name, CaptionText = textGraphic.Text, CalloutText = textGraphic.Text, CalloutLocation = textGraphic.Location, Point = textGraphic.Location, UseCrosshair = false, GraphicHashcode = graphic.GetHashCode() }; } else if (graphic is ContextMenuControlGraphic) { markup = DoGraphicToIMarkup(((ContextMenuControlGraphic)graphic).Subject); } else if (graphic is AimGraphic) { markup = DoGraphicToIMarkup(((AimGraphic)graphic).Graphic); // Fix name - not all composite graphics may have the Name set correctly if (markup != null) { markup.Name = ((AimGraphic)graphic).Graphic.Name; } } else if (graphic is StandardStatefulGraphic) { markup = DoGraphicToIMarkup(((StandardStatefulGraphic)graphic).Subject); } else if (graphic is SegFrameImageGraphic) { // NO-OP // TODO: implement IMarkup for this type of graphic if we ever need to have segmentation graphic in the TemplateTree } else { System.Diagnostics.Debug.Assert(false, "Could not create Markup from " + graphic.GetType().Name); } return(markup); }