private static void ShowSelection(IEnumerable <Vector2D> points)
        {
            RectangleF area = MapSet.CreateEmptyArea();

            // Make a view area from the points
            foreach (Vector2D p in points)
            {
                area = MapSet.IncreaseArea(area, p);
            }

            // Make the area square, using the largest side
            if (area.Width > area.Height)
            {
                float delta = area.Width - area.Height;
                area.Y      -= delta * 0.5f;
                area.Height += delta;
            }
            else
            {
                float delta = area.Height - area.Width;
                area.X     -= delta * 0.5f;
                area.Width += delta;
            }

            // Add padding
            area.Inflate(100f, 100f);

            // Zoom to area
            ClassicMode mode = General.Editing.Mode as ClassicMode;

            if (mode != null)
            {
                mode.CenterOnArea(area, 0.6f);
            }
        }
示例#2
0
        // Call this to zoom in on the given selection
        public virtual void ZoomToSelection(ICollection <FindReplaceObject> selection)
        {
            List <Vector2D> points = new List <Vector2D>();
            RectangleF      area   = MapSet.CreateEmptyArea();

            // Add all points to a list
            foreach (FindReplaceObject o in selection)
            {
                o.AddViewPoints(points);
            }

            // Make a view area from the points
            foreach (Vector2D p in points)
            {
                area = MapSet.IncreaseArea(area, p);
            }

            // Make the area square, using the largest side
            if (area.Width > area.Height)
            {
                float delta = area.Width - area.Height;
                area.Y      -= delta * 0.5f;
                area.Height += delta;
            }
            else
            {
                float delta = area.Height - area.Width;
                area.X     -= delta * 0.5f;
                area.Width += delta;
            }

            // Add padding
            area.Inflate(100f, 100f);

            // Zoom to area
            ClassicMode editmode = (General.Editing.Mode as ClassicMode);

            editmode.CenterOnArea(area, 0.6f);
        }
示例#3
0
        // Call this to zoom in on the given selection
        public void ZoomToObject()
        {
            List <Vector2D> points = new List <Vector2D>();
            RectangleF      area   = MapSet.CreateEmptyArea();

            // Add all points to a list
            foreach (MapElement obj in viewobjects)
            {
                if (obj is Vertex)
                {
                    points.Add((obj as Vertex).Position);
                }
                else if (obj is Linedef)
                {
                    points.Add((obj as Linedef).Start.Position);
                    points.Add((obj as Linedef).End.Position);
                }
                else if (obj is Sidedef)
                {
                    points.Add((obj as Sidedef).Line.Start.Position);
                    points.Add((obj as Sidedef).Line.End.Position);
                }
                else if (obj is Sector)
                {
                    Sector s = (obj as Sector);
                    foreach (Sidedef sd in s.Sidedefs)
                    {
                        points.Add(sd.Line.Start.Position);
                        points.Add(sd.Line.End.Position);
                    }
                }
                else if (obj is Thing)
                {
                    Thing    t = (obj as Thing);
                    Vector2D p = (Vector2D)t.Position;
                    points.Add(p);
                    points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f));
                    points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f));
                    points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f));
                    points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f));
                }
                else
                {
                    General.Fail("Unknown object given to zoom in on.");
                }
            }

            // Make a view area from the points
            foreach (Vector2D p in points)
            {
                area = MapSet.IncreaseArea(area, p);
            }

            // Make the area square, using the largest side
            if (area.Width > area.Height)
            {
                float delta = area.Width - area.Height;
                area.Y      -= delta * 0.5f;
                area.Height += delta;
            }
            else
            {
                float delta = area.Height - area.Width;
                area.X     -= delta * 0.5f;
                area.Width += delta;
            }

            // Add padding
            area.Inflate(100f, 100f);

            // Zoom to area
            ClassicMode editmode = (General.Editing.Mode as ClassicMode);

            editmode.CenterOnArea(area, 0.6f);
        }
        private static void ProcessNodeClick(TreeNode node)
        {
            if (node == null)
            {
                return;
            }

            List <Vector2D> points = new List <Vector2D>();
            RectangleF      area   = MapSet.CreateEmptyArea();

            if (node.Parent == null)
            {
                if (node.Tag is SoundEnvironment)
                {
                    SoundEnvironment se = (SoundEnvironment)node.Tag;

                    foreach (Sector s in se.Sectors)
                    {
                        foreach (Sidedef sd in s.Sidedefs)
                        {
                            points.Add(sd.Line.Start.Position);
                            points.Add(sd.Line.End.Position);
                        }
                    }
                }
                else
                {
                    // Don't zoom if the wrong nodes are selected
                    return;
                }
            }
            else
            {
                if (node.Tag is Thing)
                {
                    Thing t = (Thing)node.Tag;

                    // We don't want to be zoomed too closely, so add somepadding
                    points.Add(t.Position - 200);
                    points.Add(t.Position + 200);
                }
                else if (node.Tag is Linedef)
                {
                    Linedef ld = (Linedef)node.Tag;

                    points.Add(ld.Start.Position);
                    points.Add(ld.End.Position);
                }
                else
                {
                    // Don't zoom if the wrong nodes are selected
                    return;
                }
            }

            area = MapSet.IncreaseArea(area, points);

            // Add padding
            area.Inflate(100f, 100f);

            // Zoom to area
            ClassicMode editmode = (General.Editing.Mode as ClassicMode);

            editmode.CenterOnArea(area, 0.0f);
        }
示例#5
0
        public MapElementErrorItem(ErrorType type, MapElement target, string description) : base(type, description)
        {
            this.target = target;

            // Calculate zoom area
            List <Vector2D> points = new List <Vector2D>();
            RectangleF      area   = MapSet.CreateEmptyArea();

            // Add all points to a list
            if (target is Vertex)
            {
                points.Add((target as Vertex).Position);
                targetmodename = "VerticesMode";
            }
            else if (target is Linedef)
            {
                points.Add((target as Linedef).Start.Position);
                points.Add((target as Linedef).End.Position);
                targetmodename = "LinedefsMode";
            }
            else if (target is Sidedef)
            {
                points.Add((target as Sidedef).Line.Start.Position);
                points.Add((target as Sidedef).Line.End.Position);
                targetmodename = "LinedefsMode";
            }
            else if (target is Sector)
            {
                Sector s = (target as Sector);
                foreach (Sidedef sd in s.Sidedefs)
                {
                    points.Add(sd.Line.Start.Position);
                    points.Add(sd.Line.End.Position);
                }
                targetmodename = "SectorsMode";
            }
            else if (target is Thing)
            {
                Thing    t = (target as Thing);
                Vector2D p = t.Position;
                points.Add(p);
                points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f));
                points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f));
                points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f));
                points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f));
                targetmodename = "ThingsMode";
            }
            else
            {
                General.Fail("Unknown object given to zoom in on.");
            }

            // Make a view area from the points
            foreach (Vector2D p in points)
            {
                area = MapSet.IncreaseArea(area, p);
            }

            // Make the area square, using the largest side
            if (area.Width > area.Height)
            {
                float delta = area.Width - area.Height;
                area.Y      -= delta * 0.5f;
                area.Height += delta;
            }
            else
            {
                float delta = area.Height - area.Width;
                area.X     -= delta * 0.5f;
                area.Width += delta;
            }

            // Add padding
            area.Inflate(100f, 100f);

            // Store
            this.zoomarea = area;
        }