Ejemplo n.º 1
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero);
        HeatMap   heatMap   = HeatMapGenerator.GenerateHeatMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMapSettings, Vector2.zero);
        TreeMap   treeMap   = TreeMapGenerator.generateVegetationMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMap, treeMapSettings, Vector2.zero);

        DestroyTrees();          //temporary fix

        if (drawMode == DrawMode.HeightMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh2(heightMap.values, meshSettings, editorPreviewLOD, heatMap.values));
            DrawTrees(heightMap.values, meshSettings, treeMap.values);
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
        else if (drawMode == DrawMode.HeatMap)
        {
            DrawTexture(TextureGenerator.TextureColorizedFromHeatMap(heatMap));
        }
        else if (drawMode == DrawMode.TreeMap)
        {
            DrawTexture(TextureGenerator.TextureFromTreeMap(treeMap));
        }
    }
Ejemplo n.º 2
0
 private void UpdateHeatMap()
 {
     if (rectHeat == null)
     {
         return;
     }
     rectHeat.Fill = HeatMapGenerator.Generate(Beats.ToList(), TimeSpan.Zero, Duration, 100, true);
 }
Ejemplo n.º 3
0
 private void UpdateHeatMap()
 {
     if (cckHeatMap.IsChecked != true)
     {
         SeekBar.Background = System.Windows.Media.Brushes.Black;
     }
     else
     {
         var timeStamps = _scriptHandler.GetScript().Select(s => s.TimeStamp).ToList();
         int segments   = Math.Max(20, (int)VideoPlayer.Duration.Divide(TimeSpan.FromSeconds(10)));
         SeekBar.Background = HeatMapGenerator.Generate(timeStamps, TimeSpan.Zero, VideoPlayer.Duration, segments, true);
     }
 }
Ejemplo n.º 4
0
        public ActionResult WebpagePublicStats(int id, string path, DateTime?start, DateTime?end)
        {
            if (!start.HasValue)
            {
                start = new DateTime(DateTime.UtcNow.AddDays(-15).Year, DateTime.UtcNow.AddDays(-15).Month, DateTime.UtcNow.AddDays(-15).Day);
            }
            if (!end.HasValue)
            {
                end = DateTime.UtcNow;
            }
            WebpageDisplayPublic wdp = new WebpageDisplayPublic();

            wdp.Path      = path;
            wdp.WebsiteId = id;
            wdp.Start     = start.Value;
            wdp.End       = new DateTime(end.Value.Year, end.Value.Month, end.Value.Day, 23, 59, 59);
            if (wdp.Start.Year == wdp.End.Year && wdp.Start.Month == wdp.End.Month && wdp.Start.Day == wdp.End.Day)
            {
                wdp.Range = ReportDateRangeCustomType.Day;
            }
            else if (wdp.End.Subtract(wdp.Start).TotalDays < 60)
            {
                wdp.Range = ReportDateRangeCustomType.Days;
            }
            else if (wdp.End.Subtract(wdp.Start).TotalDays > 60)
            {
                wdp.Range = ReportDateRangeCustomType.Months;
            }
            wdp.VisitChartDescription = string.Format("Visits from {0} till {1}", wdp.Start.ToString("d/MMM/yy"), end);
            Website w = websiteRepository.GetWebsiteByID(id);

            if (w != null)
            {
                wdp.WebsiteName = w.Name;
                Uri     u  = new Uri(path);
                Webpage wp = webpageRepository.GetWebpage(w.ID, u.AbsolutePath.Trim(), u.Query.Trim());
                if (wp != null)
                {
                    var visits   = visitRepository.GetVisitsByWebpage(wp.ID, start, end);
                    var visitact = visitRepository.GetVisitPageActivities(visits.Select(t => t.ID).ToList(), wp.ID);


                    wdp.BrowserData.AddRange(GetBrowserUsage(visits.ToList()));
                    wdp.VisitCount = visits.ToList().Count;
                    DateTime current = DateTime.UtcNow;
                    Dictionary <string, int> browsers = new Dictionary <string, int>();
                    foreach (var item in visits)
                    {
                        string refstr = "";

                        if (!string.IsNullOrEmpty(item.Referer))
                        {
                            Uri referurl = new Uri(HttpUtility.UrlDecode(item.Referer));
                            refstr = referurl.Host;
                        }



                        RefererData rd = wdp.RefererList.SingleOrDefault(t => t.Referer == refstr);
                        if (rd != null)
                        {
                            rd.Count++;
                        }
                        else
                        {
                            wdp.RefererList.Add(new RefererData()
                            {
                                Count = 1, Referer = refstr
                            });
                        }
                    }
                    DateTime daystart = wdp.Start;
                    switch (wdp.Range)
                    {
                    case ReportDateRangeCustomType.Day:
                        while (daystart <= wdp.End)
                        {
                            VisitCountChartPoint p = new VisitCountChartPoint();
                            p.X = daystart.ToString("h:m tt");
                            p.Y = visits.Where(t => t.DateCreated >= daystart &&
                                               t.DateCreated <= daystart.AddHours(1)).Count();
                            wdp.VisitsData.Add(p);

                            VisitCountChartPoint np = new VisitCountChartPoint();
                            np.X = daystart.ToString("h:m tt");
                            np.Y = visits.Where(t => t.DateCreated >= daystart &&
                                                t.DateCreated <= daystart.AddHours(1) && t.LastVisitID.HasValue == false).Count();
                            wdp.NewVisitsData.Add(np);

                            VisitCountChartPoint rp = new VisitCountChartPoint();
                            rp.X = daystart.ToString("h:m tt");
                            rp.Y = visits.Where(t => t.DateCreated >= daystart &&
                                                t.DateCreated <= daystart.AddHours(1) && t.LastVisitID.HasValue == true).Count();
                            wdp.ReturnVisitsData.Add(rp);

                            daystart = daystart.AddHours(1);
                        }


                        break;


                    case ReportDateRangeCustomType.Days:

                        while (daystart <= wdp.End)
                        {
                            VisitCountChartPoint p = new VisitCountChartPoint();
                            p.X = daystart.ToString("MM/d");
                            p.Y = visits.Where(t => t.DateCreated.Year == daystart.Year && t.DateCreated.Month == daystart.Month && t.DateCreated.Day == daystart.Day).Count();
                            wdp.VisitsData.Add(p);

                            VisitCountChartPoint np = new VisitCountChartPoint();
                            np.X = daystart.ToString("MM/d");
                            np.Y = visits.Where(t => t.DateCreated.Year == daystart.Year && t.DateCreated.Month == daystart.Month && t.DateCreated.Day == daystart.Day && t.LastVisitID.HasValue == false).Count();
                            wdp.NewVisitsData.Add(np);

                            VisitCountChartPoint rp = new VisitCountChartPoint();
                            rp.X = daystart.ToString("MM/d");
                            rp.Y = visits.Where(t => t.DateCreated.Year == daystart.Year && t.DateCreated.Month == daystart.Month && t.DateCreated.Day == daystart.Day && t.LastVisitID.HasValue == true).Count();
                            wdp.ReturnVisitsData.Add(rp);

                            daystart = daystart.AddDays(1);
                        }


                        break;

                    case ReportDateRangeCustomType.Months:


                        while (daystart <= wdp.End)
                        {
                            VisitCountChartPoint p = new VisitCountChartPoint();
                            p.X = daystart.AddDays(15).ToString("y-M-d");
                            p.Y = visits.Where(t => t.DateCreated >= daystart && t.DateCreated < daystart.AddDays(15)).Count();
                            wdp.VisitsData.Add(p);

                            VisitCountChartPoint np = new VisitCountChartPoint();
                            np.X = daystart.AddDays(15).ToString("y-M-d");
                            np.Y = visits.Where(t => t.DateCreated >= daystart && t.DateCreated < daystart.AddDays(15) && t.LastVisitID.HasValue == false).Count();
                            wdp.NewVisitsData.Add(np);

                            VisitCountChartPoint rp = new VisitCountChartPoint();
                            rp.X = daystart.AddDays(15).ToString("y-M-d");
                            rp.Y = visits.Where(t => t.DateCreated >= daystart && t.DateCreated < daystart.AddDays(15) && t.LastVisitID.HasValue == true).Count();
                            wdp.ReturnVisitsData.Add(rp);

                            daystart = daystart.AddDays(15);
                        }

                        break;
                    }
                    HeatMapGenerator hmg = new HeatMapGenerator(Server.MapPath("~/Content/img/palette.bmp"));
                    hmg.ws         = w;
                    hmg.wp         = wp;
                    hmg.Activities = visitact.Where(t => t.Activity == ActivityName.Click).ToList();
                    hmg.GenerateMap();
                    wdp.HeatMapPath = hmg.HeatMapPath;
                }
            }


            return(View(wdp));
        }
Ejemplo n.º 5
0
        protected override GeneratorResult ProcessInternal(HeatmapGeneratorSettings settings, GeneratorEntry entry)
        {
            try
            {
                entry.State = JobStates.Processing;

                _wrapper = new FfmpegWrapper(FfmpegExePath);

                var videoInfo = _wrapper.GetVideoInfo(settings.VideoFile);

                if (videoInfo.Duration <= TimeSpan.Zero)
                {
                    entry.State    = JobStates.Done;
                    entry.DoneType = JobDoneTypes.Failure;
                    entry.Update("Failed", 1);
                    return(GeneratorResult.Failed());
                }

                TimeSpan duration = videoInfo.Duration;

                //TODO

                string script  = ViewModel.GetScriptFile(settings.VideoFile);
                var    actions = ViewModel.LoadScriptActions(script, null);

                if (actions == null || actions.Count == 0)
                {
                    entry.State    = JobStates.Done;
                    entry.DoneType = JobDoneTypes.Failure;
                    entry.Update("Failed", 1);
                    return(GeneratorResult.Failed());
                }

                List <TimedPosition> timeStamps = ViewModel.FilterDuplicates(actions.ToList()).Cast <FunScriptAction>().Select(f => new
                                                                                                                               TimedPosition
                {
                    Position  = f.Position,
                    TimeStamp = f.TimeStamp
                }).ToList();

                Brush heatmap = HeatMapGenerator.Generate3(timeStamps, TimeSpan.FromSeconds(10), TimeSpan.Zero, duration, 1.0, out Geometry bounds);
                bounds.Transform = new ScaleTransform(settings.Width, settings.Height);
                var rect = new Rect(0, 0, settings.Width, settings.Height);

                DrawingVisual visual = new DrawingVisual();
                using (DrawingContext context = visual.RenderOpen())
                {
                    if (!settings.TransparentBackground)
                    {
                        context.DrawRectangle(Brushes.Black, null, rect);
                    }

                    if (settings.MovementRange)
                    {
                        context.PushClip(bounds);
                    }

                    context.DrawRectangle(heatmap, null, rect);

                    if (settings.AddShadow)
                    {
                        LinearGradientBrush shadow = new LinearGradientBrush();
                        shadow.StartPoint = new Point(0.5, 0);
                        shadow.EndPoint   = new Point(0.5, 1);

                        shadow.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF - 0x20, 0, 0, 0), 0));
                        shadow.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF - 0xcc, 0, 0, 0), 0.98));
                        shadow.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF - 0x50, 0, 0, 0), 0.98));
                        shadow.GradientStops.Add(new GradientStop(Color.FromArgb(0xFF - 0x50, 0, 0, 0), 1));

                        context.DrawRectangle(shadow, null, rect);
                    }

                    if (settings.MovementRange)
                    {
                        context.Pop();
                    }
                }

                RenderTargetBitmap bitmap = new RenderTargetBitmap(settings.Width, settings.Height, 96, 96, PixelFormats.Pbgra32);
                bitmap.Render(visual);

                PngBitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bitmap));

                using (FileStream stream = new FileStream(settings.OutputFile, FileMode.Create))
                    encoder.Save(stream);

                entry.DoneType = JobDoneTypes.Success;
                entry.Update("Done", 1);

                return(GeneratorResult.Succeeded(settings.OutputFile));
            }
            catch (Exception)
            {
                entry.Update("Failed", 1);
                entry.DoneType = JobDoneTypes.Failure;

                return(GeneratorResult.Failed());
            }
            finally
            {
                entry.State = JobStates.Done;

                if (_canceled)
                {
                    entry.DoneType = JobDoneTypes.Cancelled;
                    entry.Update("Cancelled", 1);
                }
            }
        }
Ejemplo n.º 6
0
 public LodiiisBot(ShipGenerator sg, HeatMapGenerator hmg, bool useOptimalization)
 {
     _sg  = sg;
     _hmg = hmg;
     _opt = useOptimalization;
 }