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
        private BlockMap <BlockEntry> CreateBlockmap(bool ignorecontrolsectors)
        {
            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area = MapSet.IncreaseArea(area, new Vector2D(outerleft, outertop));
            area = MapSet.IncreaseArea(area, new Vector2D(outerright, outerbottom));
            area = AlignAreaToGrid(area);

            BlockMap <BlockEntry> blockmap = new BlockMap <BlockEntry>(area, (int)gridsize);

            if (ignorecontrolsectors)
            {
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    // Managed control sectors have the custom UDMF field "user_managed_3d_floor" set to true
                    // So if the field is NOT set, add the sector to the blockmap
                    if (s.Fields.GetValue("user_managed_3d_floor", false) == false)
                    {
                        blockmap.AddSector(s);
                    }
                }
            }
            else
            {
                blockmap.AddSectorsSet(General.Map.Map.Sectors);
            }

            return(blockmap);
        }
Пример #3
0
        // Mode engages
        public override void OnEngage()
        {
            base.OnEngage();

            // Nothing highlighted
            highlighted = null;
            hx          = -1;
            hy          = -1;

            // Custom presentation to hide the grid
            CustomPresentation p = new CustomPresentation();

            p.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask, General.Settings.BackgroundAlpha));
            p.AddLayer(new PresentLayer(RendererLayer.Surface, BlendingMode.Mask));
            p.AddLayer(new PresentLayer(RendererLayer.Overlay, BlendingMode.Alpha, 1f, true));
            p.AddLayer(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, 1.0f));
            p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
            renderer.SetPresentation(p);

            // Make the blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area     = MapSet.IncreaseArea(area, General.Map.Map.Things);
            blockmap = new BlockMap <BlockEntry>(area);
            blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
            blockmap.AddSectorsSet(General.Map.Map.Sectors);
            blockmap.AddThingsSet(General.Map.Map.Things);
        }
        private BlockMap <BlockEntry> CreateBlockmap(bool ignorecontrolsectors)
        {
            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area = MapSet.IncreaseArea(area, new Vector2D(outerleft, outertop));
            area = MapSet.IncreaseArea(area, new Vector2D(outerright, outerbottom));
            area = AlignAreaToGrid(area);

            BlockMap <BlockEntry> blockmap = new BlockMap <BlockEntry>(area, (int)gridsize);

            if (ignorecontrolsectors)
            {
                foreach (Sector s in General.Map.Map.Sectors)
                {
                    // Managed control sectors have the custom UDMF field "user_managed_3d_floor" set to true
                    // So if the field is NOT set, add the sector to the blockmap
                    bool managed = s.Fields.GetValue("user_managed_3d_floor", false);

                    if (managed == false)
                    {
                        blockmap.AddSector(s);
                    }
                    else                     // When a tag was manually removed a control sector still might have the user_managed_3d_floor field, but not be
                    {                        // recognized as a 3D floor control sector. In that case also add the sector to the blockmap
                        bool orphaned = true;

                        foreach (ThreeDFloor tdf in ((ThreeDFloorHelperMode)General.Editing.Mode).ThreeDFloors)
                        {
                            if (tdf.Sector == s)
                            {
                                orphaned = false;
                                break;
                            }
                        }

                        if (orphaned)
                        {
                            blockmap.AddSector(s);
                        }
                    }
                }
            }
            else
            {
                blockmap.AddSectorsSet(General.Map.Map.Sectors);
            }

            return(blockmap);
        }
Пример #5
0
        // This starts checking
        private void StartChecking()
        {
            if (running)
            {
                return;
            }

            Cursor.Current = Cursors.WaitCursor;

            // Make blockmap
            RectangleF area = MapSet.CreateArea(General.Map.Map.Vertices);

            area     = MapSet.IncreaseArea(area, General.Map.Map.Things);
            blockmap = new BlockMap <BlockEntry>(area);
            blockmap.AddLinedefsSet(General.Map.Map.Linedefs);
            blockmap.AddSectorsSet(General.Map.Map.Sectors);
            blockmap.AddThingsSet(General.Map.Map.Things);
            blockmap.AddVerticesSet(General.Map.Map.Vertices);             //mxd

            //mxd. Open the results panel
            if (!resultspanel.Visible)
            {
                this.MinimumSize     = new Size();
                this.MaximumSize     = new Size();
                this.Size            = initialsize;
                resultspanel.Size    = new Size(resultspanel.Width, this.ClientSize.Height - resultspanel.Top);
                resultspanel.Visible = true;
            }
            progress.Value = 0;
            results.Items.Clear();
            results.Enabled = true;
            resultslist     = new List <ErrorResult>();        //mxd
            ClearSelectedResult();
            buttoncheck.Text = "Abort Analysis";
            General.Interface.RedrawDisplay();

            // Start checking
            running               = true;
            checksthread          = new Thread(RunChecks);
            checksthread.Name     = "Error Checking Management";
            checksthread.Priority = ThreadPriority.Normal;
            checksthread.Start();

            Cursor.Current = Cursors.Default;
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
0
        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);
        }
Пример #9
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;
        }