public override void OnFlowSettingsGUI()
        {
            if (Heatmap.settings == null)
            {
                Heatmap.settings = Heatmap.GetSettingsFile();
            }

            if (this.noDataTexture == null)
            {
                this.noDataTexture = UnityEngine.Resources.Load <Texture>("UI.Windows/Heatmap/NoData");
            }

            var settings = Heatmap.settings;

            if (settings == null)
            {
                EditorGUILayout.HelpBox(string.Format(FlowAddon.MODULE_HAS_ERRORS, "Settings file not found (HeatmapSettings)."), MessageType.Error);
            }
            else
            {
                GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

                if (this.editor == null)
                {
                    this.editor = Editor.CreateEditor(settings) as HeatmapSettingsEditor;
                    this.editor.SetResetCallback(this.ResetCache);
                }

                if (this.editor != null)
                {
                    this.editor.OnInspectorGUI();
                }
            }
        }
        public override void OnFlowWindowScreenMenuGUI(FD.FlowWindow window, GenericMenu menu)
        {
            if (window.isVisibleState == false)
            {
                return;
            }
            if (window.IsContainer() == true)
            {
                return;
            }
            if (window.IsSmall() == true && window.IsFunction() == true)
            {
                return;
            }
            if (window.IsShowDefault() == true)
            {
                return;
            }

            if (Heatmap.settings == null)
            {
                Heatmap.settings = Heatmap.GetSettingsFile();
            }

            var settings = Heatmap.settings;

            if (settings != null)
            {
                var data = settings.data.Get(window);
                if (data == null)
                {
                    return;
                }

                foreach (var item in settings.items)
                {
                    if (item.show == true && item.enabled == true)
                    {
                        foreach (var serviceBase in this.editor.services)
                        {
                            var service = serviceBase as IAnalyticsService;
                            if (service.GetServiceName() == item.serviceName)
                            {
                                var key      = string.Format("{0}_{1}", item.serviceName, window.id);
                                var windowId = window.id;
                                menu.AddItem(new GUIContent("Open Heatmap..."), false, () => {
                                    //this.fullScreenData = this.heatmapResultsCache[key];
                                    this.fullScreenTexture  = this.heatmapTexturesCache[key];
                                    this.fullScreenWindowId = windowId;
                                    this.fullScreenEditor   = null;

                                    this.openFullScreen = true;
                                    this.flowEditor.SetDisabled();
                                });
                            }
                        }
                    }
                }
            }
        }
Exemple #3
0
        public override void OnFlowWindowLayoutGUI(Rect rect, UnityEngine.UI.Windows.Plugins.Flow.FlowWindow window)
        {
            if (Heatmap.settings == null)
            {
                Heatmap.settings = this.GetSettingsFile();
            }

            var settings = Heatmap.settings;

            if (settings != null)
            {
                if (settings.show == true)
                {
                    var data = settings.data.Get(window);
                    data.UpdateMap();

                    if (data != null && data.texture != null && data.status == HeatmapSettings.WindowsData.Window.Status.Loaded)
                    {
                        GUI.DrawTexture(rect, data.texture, ScaleMode.StretchToFill, alphaBlend: true);
                    }
                    else
                    {
                        if (this.noDataTexture != null)
                        {
                            GUI.DrawTexture(rect, this.noDataTexture, ScaleMode.StretchToFill, alphaBlend: true);
                        }
                    }
                }
            }
        }
        public override void OnFlowWindow(FD.FlowWindow window)
        {
            if (window.isVisibleState == false)
            {
                return;
            }
            if (window.IsContainer() == true)
            {
                return;
            }
            if (window.IsSmall() == true && window.IsFunction() == true)
            {
                return;
            }
            if (window.IsShowDefault() == true)
            {
                return;
            }

            if (Heatmap.settings == null)
            {
                Heatmap.settings = Heatmap.GetSettingsFile();
            }

            var settings = Heatmap.settings;

            if (settings != null)
            {
                var result = new ScreenResult();

                foreach (var item in settings.items)
                {
                    if (item.show == true && item.enabled == true)
                    {
                        foreach (var serviceBase in this.editor.services)
                        {
                            var service = serviceBase as IAnalyticsService;
                            if (service.GetServiceName() == item.serviceName)
                            {
                                var rect = window.rect;
                                this.DrawBubble(new Rect(new Vector2(rect.x + rect.width * 0.5f, rect.y), Vector2.zero), 0, window.id, -1, Vector2.zero, "LabelGreen");

                                int value;
                                var keyTransition = string.Format("{0}_{1}", item.serviceName, window.id);
                                if (this.resultsTransitionCache.TryGetValue(keyTransition, out value) == true)
                                {
                                    result.uniqueCount = value;
                                }

                                if (result.uniqueCount > 0 && result.popup == false)
                                {
                                    // Draw exit bubble
                                    this.DrawBubble(new Vector2(rect.x + rect.width * 0.5f, rect.y + rect.height), result, Vector2.zero, "LabelRed", "{1}");
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public override void OnFlowSettingsGUI()
        {
            if (Heatmap.settings == null)
            {
                Heatmap.settings = this.GetSettingsFile();
                //if (Heatmap.settings == null) Heatmap.settings = ME.EditorUtilities.GetAssetsOfType<HeatmapSettings>(useCache: false).FirstOrDefault();
            }

            if (this.noDataTexture == null)
            {
                this.noDataTexture = Resources.Load("UI.Windows/Heatmap/NoData") as Texture;
            }

            var settings = Heatmap.settings;

            if (settings == null)
            {
                EditorGUILayout.HelpBox(string.Format(FlowAddon.MODULE_HAS_ERRORS, "Settings file not found (HeatmapSettings)."), MessageType.Error);
            }
            else
            {
                GUILayout.Label(FlowAddon.MODULE_INSTALLED, EditorStyles.centeredGreyMiniLabel);

                if (this.editor == null)
                {
                    this.editor = Editor.CreateEditor(settings);
                }
                if (this.editor != null)
                {
                    this.editor.OnInspectorGUI();
                }
            }
        }
        public HeatmapSettings RecordSettings()
        {
            HeatmapSettings settings = ScriptableObject.CreateInstance <HeatmapSettings>();

            settings.heatmapInFront       = heatmapInFront;
            settings.heatmapOptionIndex   = heatmapOptionIndex;
            settings.heatmapOptions       = heatmapOptions;
            settings.maskFollowType       = maskFollowType;
            settings.maskRadius           = maskRadius;
            settings.maskType             = maskType;
            settings.particleSize         = particleSize;
            settings.particleShape        = particleShape;
            settings.particleDirection    = particleDirection;
            settings.particleProjection   = particleProjection;
            settings.remapDensity         = remapDensity;
            settings.remapColorField      = remapColorField;
            settings.remapOptionIndex     = remapOptionIndex;
            settings.remapPercentile      = remapPercentile;
            settings.separateUsers        = separateUsers;
            settings.smoothSpaceOption    = smoothSpaceOption;
            settings.smoothSpace          = smoothSpace;
            settings.smoothRotationOption = smoothRotationOption;
            settings.smoothRotation       = smoothRotation;
            settings.smoothTimeOption     = smoothTimeOption;
            settings.smoothTime           = smoothTime;
            return(settings);
        }
Exemple #7
0
        public MasksHeatmapRenderer(IHyperArgsSink hyperStore, HyperMetadataSet metadataSet, HeatmapSettings settings)
        {
            _hyperStore  = hyperStore;
            _metadataSet = metadataSet;
            _settings    = settings;

            _keepWorking = true;
            _ctSource    = new CancellationTokenSource();
        }
        public JsonResult SetMapSettings([FromBody] HeatmapSettings heatMapSettings)
        {
            var cacheKey      = _configuration["Caching:Key"] ?? "";
            var cacheDuration = int.TryParse(_configuration["Caching:MinutesToCache"], out int returnValue)
                ? int.Parse(_configuration["Caching:MinutesToCache"])
                : 1440;

            var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromMinutes(cacheDuration));

            var result = _cache.Set(cacheKey, heatMapSettings, cacheEntryOptions);

            return(Json(result));
        }
        public JsonResult GetMapSettings()
        {
            //TODO: trap errors
            var cacheKey = _configuration["Caching:Key"] ?? "";
            var settings = new HeatmapSettings();

            if (_cache.TryGetValue(cacheKey, out HeatmapSettings result))
            {
                settings.GradientType = result.GradientType;
                settings.Radius       = result.Radius;
                settings.Opacity      = result.Opacity;
            }
            ;
            return(Json(settings));
        }
Exemple #10
0
 void Create(string name)
 {
     if (AssetNameUnique(name) && !string.IsNullOrEmpty(name))
     {
         HeatmapSettings profile = HeatmapInspectorViewModel.GetInstance().RecordSettings();
         profile.name = name;
         var savePath = GetAssetPath(profile.name);
         AssetDatabase.CreateAsset(profile, savePath);
         EditorUtility.SetDirty(profile);
         GenerateList();
         CloseCreation();
     }
     else
     {
         m_NameNotUnique = true;
     }
 }
        public void UpdateSettings(HeatmapSettings settings)
        {
            separateUsers = settings.separateUsers;

            smoothSpaceOption    = settings.smoothSpaceOption;
            smoothSpace          = settings.smoothSpace;
            smoothRotationOption = settings.smoothRotationOption;
            smoothRotation       = settings.smoothRotation;
            smoothTimeOption     = settings.smoothTimeOption;
            smoothTime           = settings.smoothTime;

            heatmapInFront = settings.heatmapInFront;

            maskFollowType     = settings.maskFollowType;
            maskRadius         = settings.maskRadius;
            maskType           = settings.maskType;
            particleSize       = settings.particleSize;
            particleShape      = settings.particleShape;
            particleProjection = settings.particleProjection;
            particleDirection  = settings.particleDirection;

            OptionListIsNew = true;
            heatmapOptions  = settings.heatmapOptions;
        }
Exemple #12
0
 protected virtual void OnInspectorGUI(HeatmapSettings settings, AnalyticsServiceItem item, System.Action onReset, GUISkin skin)
 {
 }
 void OnSettingsUpdate(object sender, HeatmapSettings settings)
 {
     SelectList();
 }
 void OnSettingsUpdate(object sender, HeatmapSettings settings)
 {
     m_Heatmapper.Repaint();
 }
        public void DrawBubble(Rect rect, int index, int fromScreenId, int toScreenId, Vector2 offset, string styleName = "LabelYellow", string format = "<b>All:</b> {0}\n<b>Unique:</b> {1}")
        {
            if (Heatmap.settings == null)
            {
                Heatmap.settings = Heatmap.GetSettingsFile();
            }
            if (this.editor == null)
            {
                return;
            }

            var settings = Heatmap.settings;

            foreach (var item in settings.items)
            {
                if (item.show == true && item.enabled == true && item.processing == false)
                {
                    foreach (var serviceBase in this.editor.services)
                    {
                        var service = serviceBase as IAnalyticsService;
                        if (service.GetServiceName() == item.serviceName)
                        {
                            var key           = string.Format("{0}_{1}_{2}_{3}", item.serviceName, index, fromScreenId, toScreenId);
                            var keyTransition = string.Format("{0}_{1}", item.serviceName, fromScreenId);

                            ScreenResult result;
                            if (this.resultsCache.TryGetValue(key, out result) == true)
                            {
                                if (result != null)
                                {
                                    this.DrawBubble(rect.center, result, offset, styleName, format);
                                }
                                else
                                {
                                    // still loading
                                    this.DrawBubble(rect.center, "Loading...", "LabelYellow", Vector2.zero);
                                }
                            }
                            else
                            {
                                this.resultsCache.Add(key, null);
                                if (this.resultsTransitionCache.ContainsKey(keyTransition) == false)
                                {
                                    this.resultsTransitionCache.Add(keyTransition, 0);
                                }

                                var filter = item.userFilter;

                                if (toScreenId == -1)
                                {
/*
 *                                                                      Debug.Log("Screen Request");
 */
                                    service.GetScreen(fromScreenId, filter, (_result) => {
                                        this.resultsCache[key] = _result;
                                        this.resultsTransitionCache[keyTransition] += _result.uniqueCount;
                                    });
                                }
                                else
                                {
/*
 *                                                                      Debug.Log("Screen Transition Request");
 */
                                    service.GetScreenTransition(index, fromScreenId, toScreenId, filter, (_result) => {
                                        this.resultsCache[key] = _result;
                                        this.resultsTransitionCache[keyTransition] -= _result.uniqueCount;
                                    });
                                }
                            }
                        }
                    }
                }
            }
        }
        public override void OnFlowWindowLayoutGUI(Rect rect, FD.FlowWindow window)
        {
            if (window.isVisibleState == false)
            {
                return;
            }
            if (window.IsContainer() == true)
            {
                return;
            }
            if (window.IsSmall() == true && window.IsFunction() == true)
            {
                return;
            }
            if (window.IsShowDefault() == true)
            {
                return;
            }

            if (Heatmap.settings == null)
            {
                Heatmap.settings = Heatmap.GetSettingsFile();
            }

            var settings = Heatmap.settings;

            if (settings != null)
            {
                var data = settings.data.Get(window);
                if (data == null)
                {
                    return;
                }

                LayoutWindowType screen;
                var layout = HeatmapSystem.GetLayout(window.id, out screen);
                if (layout == null)
                {
                    return;
                }

                var targetScreenSize = new Vector2(layout.root.editorRect.width, layout.root.editorRect.height);

                foreach (var item in settings.items)
                {
                    if (item.show == true && item.enabled == true)
                    {
                        foreach (var serviceBase in this.editor.services)
                        {
                            var service = serviceBase as IAnalyticsService;
                            if (service.GetServiceName() == item.serviceName)
                            {
                                var           key = string.Format("{0}_{1}", item.serviceName, window.id);
                                HeatmapResult result;
                                if (this.heatmapResultsCache.TryGetValue(key, out result) == true)
                                {
                                    if (result != null)
                                    {
                                        var texture = this.heatmapTexturesCache[key];
                                        if (texture != null)
                                        {
                                            var scaleFactor = HeatmapSystem.GetFactor(targetScreenSize, rect.size);
                                            //var scaleFactorCanvas = layout.editorScale > 0f ? 1f / layout.editorScale : 1f;
                                            //scaleFactor *= scaleFactorCanvas;
                                            var r = layout.root.editorRect;
                                            r.x      *= scaleFactor;
                                            r.y      *= scaleFactor;
                                            r.x      += rect.x + rect.width * 0.5f;
                                            r.y      += rect.y + rect.height * 0.5f;
                                            r.width  *= scaleFactor;
                                            r.height *= scaleFactor;

                                            var c = Color.white;
                                            GUI.color = c;
                                            GUI.DrawTexture(r, texture, ScaleMode.StretchToFill, alphaBlend: true);
                                            GUI.color = Color.white;
                                        }
                                        else
                                        {
                                            if (this.noDataTexture != null)
                                            {
                                                GUI.DrawTexture(rect, this.noDataTexture, ScaleMode.ScaleToFit, alphaBlend: true);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // still loading...
                                    }
                                }
                                else
                                {
                                    if (Event.current.type == EventType.Repaint)
                                    {
                                        var rectSize = targetScreenSize;                                        //rect.size;
                                        var rootRect = layout.root.editorRect;

                                        this.heatmapResultsCache.Add(key, null);
                                        this.heatmapTexturesCache.Add(key, null);
                                        service.GetHeatmapData(window.id, (int)targetScreenSize.x, (int)targetScreenSize.y, item.userFilter, (_result) => {
                                            var heatmapResult = _result as HeatmapResult;

                                            // Convert normalized points to real points
                                            for (int i = 0; i < heatmapResult.points.Length; ++i)
                                            {
                                                var root = layout.GetRootByTag((LayoutTag)heatmapResult.points[i].tag);
                                                if (root != null)
                                                {
                                                    var xn = heatmapResult.points[i].x;
                                                    var yn = heatmapResult.points[i].y;

                                                    var sourceRect     = root.editorRect;
                                                    var radius         = (float)HeatmapVisualizer.GetRadius();
                                                    sourceRect.x      += radius;
                                                    sourceRect.y      += radius;
                                                    sourceRect.width  -= radius * 2f;
                                                    sourceRect.height -= radius * 2f;

                                                    var scaleFactor = HeatmapSystem.GetFactor(targetScreenSize, rectSize);
                                                    var r           = sourceRect;
                                                    r.x            *= scaleFactor;
                                                    r.y            *= scaleFactor;
                                                    r.x            += rootRect.width * 0.5f;
                                                    r.y             = rootRect.height * 0.5f - r.y;
                                                    r.width        *= scaleFactor;
                                                    r.height       *= scaleFactor;

                                                    heatmapResult.points[i].realPoint = new Vector2(r.x + xn * r.width, r.y - yn * r.height);
                                                }
                                            }

                                            this.heatmapResultsCache[key] = heatmapResult;
                                            HeatmapSystem.GenerateTextureFromData((int)targetScreenSize.x, (int)targetScreenSize.y, this.heatmapResultsCache[key], (texture) => { this.heatmapTexturesCache[key] = texture; });
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }