当前位置: 首页>>代码示例>>C#>>正文


C# Viewport2D.GetUnusedCoordinate方法代码示例

本文整理汇总了C#中Sledge.UI.Viewport2D.GetUnusedCoordinate方法的典型用法代码示例。如果您正苦于以下问题:C# Viewport2D.GetUnusedCoordinate方法的具体用法?C# Viewport2D.GetUnusedCoordinate怎么用?C# Viewport2D.GetUnusedCoordinate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sledge.UI.Viewport2D的用法示例。


在下文中一共展示了Viewport2D.GetUnusedCoordinate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LeftMouseDownToDraw

 protected override void LeftMouseDownToDraw(Viewport2D viewport, ViewportEvent e)
 {
     base.LeftMouseDownToDraw(viewport, e);
     if (_lastBox == null) return;
     State.BoxStart += viewport.GetUnusedCoordinate(_lastBox.Start);
     State.BoxEnd += viewport.GetUnusedCoordinate(_lastBox.End);
     _updatePreview = true;
 }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:8,代码来源:BrushTool.cs

示例2: SelectionTest

        private MapObject SelectionTest(Viewport2D viewport, ViewportEvent e)
        {
            // Create a box to represent the click, with a tolerance level
            var unused = viewport.GetUnusedCoordinate(new Coordinate(100000, 100000, 100000));
            var tolerance = 4 / viewport.Zoom; // Selection tolerance of four pixels
            var used = viewport.Expand(new Coordinate(tolerance, tolerance, 0));
            var add = used + unused;
            var click = viewport.Expand(viewport.ScreenToWorld(e.X, viewport.Height - e.Y));
            var box = new Box(click - add, click + add);

            var centerHandles = Sledge.Settings.Select.DrawCenterHandles;
            var centerOnly = Sledge.Settings.Select.ClickSelectByCenterHandlesOnly;
            // Get the first element that intersects with the box, selecting or deselecting as needed
            return Document.Map.WorldSpawn.GetAllNodesIntersecting2DLineTest(box, centerHandles, centerOnly).FirstOrDefault();
        }
开发者ID:074769,项目名称:sledge,代码行数:15,代码来源:SelectTool.cs

示例3: Render2D

        protected override void Render2D(Viewport2D vp)
        {
            base.Render2D(vp);

            if (_currentTool != null) _currentTool.Render2D(vp);

            // Render out the solid previews
            GL.Color3(Color.Pink);
            Matrix.Push();
            var matrix = vp.GetModelViewMatrix();
            GL.MultMatrix(ref matrix);
            MapObjectRenderer.DrawWireframe(_copies.Keys.SelectMany(x => x.Faces), true);
            Matrix.Pop();

            // Draw in order by the unused coordinate (the up axis for this viewport)
            var ordered = (from point in Points
                           let unused = vp.GetUnusedCoordinate(point.Coordinate)
                           orderby point.IsSelected, unused.X + unused.Y + unused.Z
                           select point).ToList();
            // Render out the point handles
            var z = (double) vp.Zoom;
            GL.Begin(BeginMode.Quads);
            foreach (var point in ordered)
            {
                var c = vp.Flatten(point.Coordinate);
                GL.Color3(Color.Black);
                GLX.Square(new Vector2d(c.DX, c.DY), 4, z, true);
                GL.Color3(point.GetColour());
                GLX.Square(new Vector2d(c.DX, c.DY), 3, z, true);
            }
            GL.End();
        }
开发者ID:074769,项目名称:sledge,代码行数:32,代码来源:VMTool.cs

示例4: GetVerticesAtPoint

        /// <summary>
        /// Get the VM points at the provided coordinate, ordered from top to bottom (for the supplied viewport).
        /// </summary>
        /// <param name="x">The X coordinate</param>
        /// <param name="y">The Y coordinate</param>
        /// <param name="viewport">The viewport</param>
        /// <returns>The points ordered from top to bottom, or an empty set if no points were found</returns>
        public List<VMPoint> GetVerticesAtPoint(int x, int y, Viewport2D viewport)
        {
            var p = viewport.ScreenToWorld(x, y);
            var d = 5 / viewport.Zoom; // Tolerance value = 5 pixels

            // Order by the unused coordinate in the view (which is the up axis) descending to get the "closest" point
            return (from point in Points
                    let c = viewport.Flatten(point.Coordinate)
                    where p.X >= c.X - d && p.X <= c.X + d && p.Y >= c.Y - d && p.Y <= c.Y + d
                    let unused = viewport.GetUnusedCoordinate(point.Coordinate)
                    orderby unused.X + unused.Y + unused.Z descending
                    select point).ToList();
        }
开发者ID:074769,项目名称:sledge,代码行数:20,代码来源:VMTool.cs

示例5: SnapBoxCoordinatesIfNeeded

        private Tuple<Coordinate, Coordinate> SnapBoxCoordinatesIfNeeded(Viewport2D viewport, Coordinate start, Coordinate end)
        {
            if (State.Action == BoxAction.Resizing && State.Handle == ResizeHandle.Center)
            {
                // Pick the corner to snap
                var ms = State.MoveStart;
                var pts = viewport.Flatten(State.PreTransformBoxStart);
                var pte = viewport.Flatten(State.PreTransformBoxEnd);
                var ss = SnapIfNeeded(start);
                var se = SnapIfNeeded(end);
                var middle = (pts + pte) / 2;
                var delta = ss - start;
                if (ms.Y > middle.Y)
                {
                    // Top
                    delta.Y = se.Y - end.Y;
                }
                if (ms.X > middle.X)
                {
                    // Right
                    delta.X = se.X - end.X;
                }
                start += delta;
                end += delta;
            }

            var cstart = viewport.Expand(start) + viewport.GetUnusedCoordinate(State.BoxStart);
            var cend = viewport.Expand(end) + viewport.GetUnusedCoordinate(State.BoxEnd);
            return Tuple.Create(cstart, cend);
        }
开发者ID:KonstantinUb,项目名称:sledge,代码行数:30,代码来源:BaseBoxTool.cs

示例6: GetResizedBoxCoordinates

        protected Tuple<Coordinate, Coordinate> GetResizedBoxCoordinates(Viewport2D viewport, ViewportEvent e)
        {
            if (State.Action != BoxAction.Resizing && State.Action != BoxAction.Drawing) return Tuple.Create(State.BoxStart, State.BoxEnd);
            var now = SnapIfNeeded(viewport.ScreenToWorld(e.X, viewport.Height - e.Y));
            var cstart = viewport.Flatten(State.BoxStart);
            var cend = viewport.Flatten(State.BoxEnd);

            // Proportional scaling
            var ostart = viewport.Flatten(State.PreTransformBoxStart ?? Coordinate.Zero);
            var oend = viewport.Flatten(State.PreTransformBoxEnd ?? Coordinate.Zero);
            var owidth = oend.X - ostart.X;
            var oheight = oend.Y - ostart.Y;
            var proportional = KeyboardState.Ctrl && State.Action == BoxAction.Resizing && owidth != 0 && oheight != 0;

            switch (State.Handle)
            {
                case ResizeHandle.TopLeft:
                    cstart.X = now.X;
                    cend.Y = now.Y;
                    break;
                case ResizeHandle.Top:
                    cend.Y = now.Y;
                    break;
                case ResizeHandle.TopRight:
                    cend.X = now.X;
                    cend.Y = now.Y;
                    break;
                case ResizeHandle.Left:
                    cstart.X = now.X;
                    break;
                case ResizeHandle.Center:
                    var cdiff = cend - cstart;
                    var distance = GetResizeDistance(viewport, e);
                    if (distance == null) cstart = viewport.Flatten(State.PreTransformBoxStart) + now - SnapIfNeeded(State.MoveStart);
                    else cstart = viewport.Flatten(State.PreTransformBoxStart) + distance;
                    cend = cstart + cdiff;
                    break;
                case ResizeHandle.Right:
                    cend.X = now.X;
                    break;
                case ResizeHandle.BottomLeft:
                    cstart.X = now.X;
                    cstart.Y = now.Y;
                    break;
                case ResizeHandle.Bottom:
                    cstart.Y = now.Y;
                    break;
                case ResizeHandle.BottomRight:
                    cend.X = now.X;
                    cstart.Y = now.Y;
                    break;
                default:
                    throw new ArgumentOutOfRangeException();
            }
            if (proportional)
            {
                var nwidth = cend.X - cstart.X;
                var nheight = cend.Y - cstart.Y;
                var mult = Math.Max(nwidth / owidth, nheight / oheight);
                var pwidth = owidth * mult;
                var pheight = oheight * mult;
                var wdiff = pwidth - nwidth;
                var hdiff = pheight - nheight;
                switch (State.Handle)
                {
                    case ResizeHandle.TopLeft:
                        cstart.X -= wdiff;
                        cend.Y += hdiff;
                        break;
                    case ResizeHandle.TopRight:
                        cend.X += wdiff;
                        cend.Y += hdiff;
                        break;
                    case ResizeHandle.BottomLeft:
                        cstart.X -= wdiff;
                        cstart.Y -= hdiff;
                        break;
                    case ResizeHandle.BottomRight:
                        cend.X += wdiff;
                        cstart.Y -= hdiff;
                        break;
                }
            }
            cstart = viewport.Expand(cstart) + viewport.GetUnusedCoordinate(State.BoxStart);
            cend = viewport.Expand(cend) + viewport.GetUnusedCoordinate(State.BoxEnd);
            return Tuple.Create(cstart, cend);
        }
开发者ID:silky,项目名称:sledge,代码行数:87,代码来源:BaseBoxTool.cs


注:本文中的Sledge.UI.Viewport2D.GetUnusedCoordinate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。