Exemple #1
0
        /// <summary>
        /// Creates an Map, showing where People died in this Tick.
        /// </summary>
        /// <param name="snapshot"></param>
        /// <param name="palette"></param>
        /// <returns>savepath</returns>
        public unsafe string GetDeathMap(TickSnapshot snapshot, EStatField field, EColorPalette palette, string namePrefix)
        {
            Color[] pal = GetPalette(palette);

            Bitmap map = new Bitmap(X, Y);
            BitmapData bData = map.LockBits(new Rectangle(0, 0, map.Width, map.Height), ImageLockMode.ReadWrite, map.PixelFormat);
            PixelData* start = (PixelData*)bData.Scan0.ToPointer();
            PixelData* pixelptr = null;

            foreach (CellSnapshot cell in snapshot.Cells)
            {
                Point p = cell.Position.DeFlatten(X);
                pixelptr = start + p.X + (p.Y * map.Width);
                pixelptr->Alpha = 255;
                pixelptr->Blue = 0;
                pixelptr->Green = 0;
                pixelptr->Red = 0;
            }
            foreach (HumanSnapshot snap in (HumanSnapshotCreteriaMatcher.GetMatchingHumans(snapshot.Deaths, field)))
            {
                Point p = ExtensionMethods.DeFlatten(snap.DeathCell, X);
                pixelptr = start + p.X + (p.Y * map.Width);
                pixelptr->Alpha = pal[0].A;
                pixelptr->Blue = pal[0].B;
                pixelptr->Green = pal[0].G;
                pixelptr->Red = pal[0].R;
            }
            map.UnlockBits(bData);
            string path = Target + "/" + namePrefix + "_" + snapshot.Tick + "_D-" + (int)field + ".png";
            map.Save(path, System.Drawing.Imaging.ImageFormat.Png);
            GenerateCaption(_steps, pal);
            return path;
        }
Exemple #2
0
 /// <summary>
 /// Creates a Graphic of the dead Humans
 /// </summary>
 /// <param name="field">The desired Field</param>
 /// <param name="colors">The desired ColorPalette</param>
 /// <param name="namePrefix">The desired Prefix</param>
 public string CreateDeathGraphics(EStatField field, EColorPalette colors, string namePrefix)
 {
     if (_currentArchive != null)
     {
         if (LoadedSnapshot != null)
         {
             return _creator.GetDeathMap(LoadedSnapshot, field, colors, namePrefix);
         }
         else
         {
             throw new ApplicationException("No Snapshot is opened!");
         }
     }
     else
     {
         throw new ApplicationException("No File loaded");
     }
 }
Exemple #3
0
        private void GenerateGraphics(string prefix, string destination,
            EColorPalette colorPalette, bool[] diagrams, EStatField fields, string[] entries)
        {
            // parallel run
            IncreaseProgressBar();

            _statsManager.SnapshotAnalized += (_, __) => IncreaseProgressBar();
            _statsManager.AnalyzingFinished += (_, __) => IncreaseProgressBar();
            _statsManager.ReviewManager.GraphicDone += (_, __) => IncreaseProgressBar();

            if (diagrams.Contains(true))
                _statsManager.AnalyzeSimulation();

            _statsManager.ReviewManager.SetNewDestination(destination);

            if (fields.HasFlag((EStatField)0x400))
                _snapshotSavePaths = _statsManager.ReviewManager.CreateMultipleDeathGraphics(
                    new List<string>(entries), (EStatField)((int)fields & ~0x400), colorPalette, prefix);
            else
                _snapshotSavePaths = _statsManager.ReviewManager.CreateMultipleGraphics(
                    new List<string>(entries), fields, colorPalette, prefix);

            FinishProgressBar();
            OutputTargetManager.GetInstance().WriteMessage("Done");
            _secondContainer.OutputPanel.TheButton.Invoke(new Action(() =>
                _secondContainer.OutputPanel.TheButton.Enabled = true));
        }
Exemple #4
0
 private static Color[] GetPalette(EColorPalette palette)
 {
     switch (palette)
     {
         case EColorPalette.Red:
             return ColorPalette.RED;
         case EColorPalette.Blue:
             return ColorPalette.BLUE;
         case EColorPalette.RedGreen:
             return ColorPalette.REDGREEN;
         default:
             return ColorPalette.RED;
     }
 }
Exemple #5
0
        /// <summary>
        /// Creates a map with the given parameters
        /// </summary>
        /// <param name="snapshot">The Snapshot to be mapped</param>
        /// <param name="field">The Field to be visualised</param>
        /// <param name="palette">The Color Palette to be used</param>
        /// <returns>savepath</returns>
        public unsafe string GetMap(TickSnapshot snapshot, EStatField field, EColorPalette palette, string namePrefix)
        {
            Color[] pal = GetPalette(palette);

            Bitmap map = new Bitmap(X, Y);
            BitmapData bData = map.LockBits(new Rectangle(0, 0, map.Width, map.Height), ImageLockMode.ReadWrite, map.PixelFormat);
            PixelData* start = (PixelData*)bData.Scan0.ToPointer();
            PixelData* pixelptr = null;

            List<int> fields = new List<int>();
            foreach (EStatField f in Enum.GetValues(typeof(EStatField)))
            {
                if ((f & field) == f)
                    fields.Add((int)Math.Log((double)f, 2d));
            }

            foreach (CellSnapshot cell in snapshot.Cells)
            {
                int count = 0;

                foreach (int i in fields)
                    count += cell.Values[i];

                Point p = cell.Position.DeFlatten(X);
                pixelptr = start + p.X + (p.Y * map.Width);

                if (count == 0)
                {
                    pixelptr->Alpha = 255;
                    pixelptr->Blue = 0;
                    pixelptr->Green = 0;
                    pixelptr->Red = 0;
                }
                else
                {
                    for (int i = ColorPalette.RANGE - 1; i >= 0; --i)
                    {
                        if (_steps[i] >= count)
                        {
                            pixelptr->Alpha = pal[i].A;
                            pixelptr->Blue = pal[i].B;
                            pixelptr->Green = pal[i].G;
                            pixelptr->Red = pal[i].R;
                            break;
                        }
                    }
                }

            }
            map.UnlockBits(bData);

            string path = Target + "/" + namePrefix + "_" + snapshot.Tick + "_S-" + (int)field + ".png";
            map.Save(path, ImageFormat.Png);
            GenerateCaption(_steps, pal);
            return path;
        }
Exemple #6
0
        /// <summary>
        /// Creates Graphics with the same Parameters for multiple Snapshots
        /// </summary>
        /// <param name="entries">The List of Snapshots</param>
        /// <param name="field">The desired Field</param>
        /// <param name="colors">The desired ColorPalette</param>
        /// <param name="namePrefix">The desired Prefix</param>
        public string[] CreateMultipleGraphics(List<string> entries, EStatField field, EColorPalette colors, string namePrefix)
        {
            int i = 1;
            int size = entries.Count;
            int sizeLength = size.ToString().Length;
            string[] paths = new string[size];

            foreach (string entry in entries)
            {
                if(Entries.Contains(entry))
                {
                    WriteMessage("Loading " + entry + "...");
                    LoadTickSnapshot(entry);
                    paths[i-1] = CreateGraphics(field, colors, namePrefix);
                    WriteMessage(String.Format("{0," + sizeLength + "} of {1} graphics finished.", i, size));
                }
                else
                {
                    WriteMessage(entry + " could not be created");
                }
                ++i;
                GraphicDone.Raise(this, null);
            }
            return paths;
        }