コード例 #1
0
        /// <summary>
        /// Applies the changes from this settings view to the visualization.
        /// </summary>
        public override void ApplyChanges()
        {
            List <int>  dataSets = new List <int>();
            List <bool> useSpeed = new List <bool>();

            // generate list of objects to show in trajectory view
            foreach (var settingsViewObject in settingsViewObjects)
            {
                if (settingsViewObject.IsObjectSelected)
                {
                    dataSets.Add(settingsViewObject.DataSet.Id);
                    if (showSpeedSettings)
                    {
                        useSpeed.Add(settingsViewObject.IsUseSpeedSelected);
                    }
                }
            }

            var config = new VisProperties(settings.VisId, settings.VisType, settings.AnchorId, dataSets, new List <int>(Services.StudyManager().CurrentStudyConditions), new List <int>(Services.StudyManager().CurrentStudySessions));

            if (showSpeedSettings)
            {
                config.Set("useSpeed", useSpeed);
            }

            // update settings of visualization, also triggers update over network
            Services.VisManager().UpdateVisualization(config);
            Close();
        }
コード例 #2
0
        /// <summary>
        /// Initializes the settings view.
        /// </summary>
        /// <param name="vis">The visualization that will be configured by this settings view.</param>
        /// <param name="showStaticObjects">Whether static study objects should be shown in the settings view.</param>
        /// <param name="showSpeedSettings">Whether speed settings should be shown in the settings view.</param>
        public override void Init(IConfigurableVisualization vis, bool showStaticObjects = true, bool showSpeedSettings = false)
        {
            if (vis == null)
            {
                return;
            }

            settings            = vis.Settings;
            settingsViewObjects = new List <SettingsViewObject>();

            this.showStaticObjects = showStaticObjects;
            this.showSpeedSettings = showSpeedSettings;

            int i = 0;

            // create settings prefab for each object
            if (SettingsPrefab && Services.DataManager() != null)
            {
                foreach (var dataSet in Services.DataManager().DataSets.Values)
                {
                    if (this.showStaticObjects || dataSet.IsStatic == false)
                    {
                        var settingsViewObject = GameObject.Instantiate <SettingsViewObject>(SettingsPrefab, this.transform);
                        settingsViewObject.transform.localPosition = new Vector3(StartPositionX, StartPositionY - (i * OffsetY), -0.009f);
                        settingsViewObject.DataSet = dataSet;
                        settingsViewObject.Init(this.showSpeedSettings);
                        for (int idx = 0; idx < settings.ObjectIds.Count; idx++)
                        {
                            if (settings.ObjectIds[idx] == dataSet.Id)
                            {
                                settingsViewObject.IsObjectSelected = true;
                                if (this.showSpeedSettings)
                                {
                                    if (settings.TryGet("useSpeed", out List <bool> useSpeedList))
                                    {
                                        if (useSpeedList != null && useSpeedList.Count == settings.ObjectIds.Count)
                                        {
                                            settingsViewObject.IsUseSpeedSelected = useSpeedList[idx];
                                        }
                                    }
                                }
                            }
                        }

                        settingsViewObjects.Add(settingsViewObject);
                        i++;
                    }
                }
            }

            Transform cameraTransform = CameraCache.Main ? CameraCache.Main.transform : null;

            if (cameraTransform != null)
            {
                transform.position = cameraTransform.position + (0.5f * cameraTransform.forward);
                ////transform.LookAt(cameraTransform.position, Vector3.up);
                Quaternion rotation = Quaternion.LookRotation(cameraTransform.position + cameraTransform.forward, Vector3.up);
                transform.rotation = rotation;
            }
        }
コード例 #3
0
 private void UpdateEventVis(VisProperties settings)
 {
     if (EventVisualization)
     {
         EventVisualization.Init(settings);
     }
 }
コード例 #4
0
        /// <summary>
        /// Initializes the visualization with the provided settings.
        /// </summary>
        /// <param name="settings">The settings to use for this visualization.</param>
        public override void Init(VisProperties settings)
        {
            if (isInitialized)
            {
                Reset(); // reset if we are already initialized
            }

            if (Services.DataManager() == null || Services.DataManager().CurrentStudy == null)
            {
                // no study loaded
                return; // vis is now reset, we return because there is nothing to load
            }

            Settings = ParseSettings(settings); // parse the settings from the settings object, also makes a deep copy

            VisId = Settings.VisId;
            foreach (var dataSetIndex in Settings.ObjectIds)
            {
                dataSets.Add(Services.DataManager().DataSets[dataSetIndex]);
            }

            // get filter min/max
            if (Services.StudyManager() != null)
            {
                minTimestamp         = Services.StudyManager().MinTimestamp;
                maxTimestamp         = Services.StudyManager().MaxTimestamp;
                currentTimeFilterMin = Services.StudyManager().CurrentTimeFilter.MinTimestamp;
                currentTimeFilterMax = Services.StudyManager().CurrentTimeFilter.MaxTimestamp;
                Services.StudyManager().TimeFilterEventBroadcast.AddListener(TimeFilterUpdated); // set listener so we can get notified about future updates
            }

            DrawGraph();

            isInitialized = true;
        }
コード例 #5
0
        /// <summary>
        /// Initializes the visualization with the provided settings.
        /// </summary>
        /// <param name="settings">The settings to use for this visualization.</param>
        public override void Init(VisProperties settings)
        {
            if (isInitialized)
            {
                Reset();
            }

            if (Services.DataManager() == null || Services.DataManager().CurrentStudy == null)
            {
                // no study loaded
                return; // vis is now reset, we return because there is nothing to load
            }

            Settings = ParseSettings(settings); // parse the settings from the settings object, also makes a deep copy

            VisId = Settings.VisId;
            foreach (var dataSetIndex in Settings.ObjectIds)
            {
                dataSets.Add((AnalysisObject)Services.DataManager().DataSets[dataSetIndex]);
            }

            DrawGraph();

            isInitialized = true;
        }
コード例 #6
0
ファイル: ViewContainer.cs プロジェクト: imldresden/miria
        /// <summary>
        /// Enables the visualization of type <see cref="VisType.Scatterplot2D"/>.
        /// </summary>
        public void OnScatterplotVisEnabled()
        {
            if (GetVisualizationsOfType(VisType.Scatterplot2D).Count == 0)
            {
                // no visualization of this type exists in this ViewContainer
                List <int> dataSets = new List <int>();
                for (int i = 0; i < Services.DataManager().DataSets.Count; i++)
                {
                    if (Services.DataManager().DataSets[i].ObjectType == ObjectType.TOUCH)
                    {
                        dataSets.Add(i);
                    }
                }

                if (dataSets.Count == 0)
                {
                    foreach (var kvp in Services.DataManager().DataSets)
                    {
                        if (kvp.Value.IsStatic == false)
                        {
                            dataSets.Add(kvp.Key);
                        }
                    }
                }

                var properties = new VisProperties(Guid.Empty, VisType.Scatterplot2D, Id, dataSets, new List <int>(Services.StudyManager().CurrentStudyConditions), new List <int>(Services.StudyManager().CurrentStudySessions));
                RequestVisWhenReady(properties);
            }
        }
コード例 #7
0
        /// <summary>
        /// Initializes the visualization with the provided settings.
        /// </summary>
        /// <param name="settings">The settings to use for this visualization.</param>
        public override void Init(VisProperties settings)
        {
            if (isInitialized)
            {
                Reset();
            }

            if (Services.DataManager() == null || Services.DataManager().CurrentStudy == null)
            {
                // no study loaded
                return; // vis is now reset, we return because there is nothing to load
            }

            Settings = ParseSettings(settings); // parse the settings from the settings object, also makes a deep copy

            VisId = Settings.VisId;
            foreach (var dataSetIndex in Settings.ObjectIds)
            {
                dataSets.Add((AnalysisObject)Services.DataManager().DataSets[dataSetIndex]);
            }

            // get filter min/max and max number of samples
            if (Services.StudyManager() != null)
            {
                // get min and max timestamp & generate markers
                foreach (int s in Settings.Sessions)
                {
                    foreach (int c in Settings.Conditions)
                    {
                        foreach (var dataSet in dataSets)
                        {
                            minTimestamp = Math.Min(dataSet.GetMinTimestamp(s, c), minTimestamp);
                            maxTimestamp = Math.Max(dataSet.GetMaxTimestamp(s, c), maxTimestamp);
                            var marker = Instantiate <DotShaderMarker>(MarkerPrefab, transform);
                            marker.Condition             = c;
                            marker.Session               = s;
                            marker.ObjectId              = dataSet.Id;
                            marker.MeshFilter.sharedMesh = new Mesh();
                            marker.Material              = new Material(marker.Material);
                            markers.Add(marker);
                        }
                    }
                }

                // set filtered min and max, based on filter value [0,1] and global min/max
                currentTimeFilterMin  = (long)(Services.StudyManager().CurrentTimeFilter.MinTime *(maxTimestamp - minTimestamp)) + minTimestamp;
                lastRenderedTimestamp = currentTimeFilterMin;

                Services.StudyManager().TimeFilterEventBroadcast.AddListener(TimeFilterUpdated); // set listener so we can get notified about future updates
            }

            DrawGraph(); // Basically, this just adds markers

            isInitialized = true;
        }
コード例 #8
0
ファイル: ViewContainer.cs プロジェクト: imldresden/miria
 private void OnVisualizationDeleted(VisProperties settings)
 {
     foreach (var visButton in visButtons)
     {
         if (visButton.VisType == (VisType)settings.VisType)
         {
             visButton.SetActive(false);
             return;
         }
     }
 }
コード例 #9
0
ファイル: ViewContainer.cs プロジェクト: imldresden/miria
        /// <summary>
        /// Enables the visualization of type <see cref="VisType.Event2D"/>.
        /// </summary>
        public void OnEventVisEnabled()
        {
            if (GetVisualizationsOfType(VisType.Event2D).Count == 0)
            {
                // no visualization of this type exists in this ViewContainer
                List <int> dataSets = new List <int>();
                foreach (var kvp in Services.DataManager().DataSets)
                {
                    dataSets.Add(kvp.Key);
                }

                var properties = new VisProperties(Guid.Empty, VisType.Event2D, Id, dataSets, new List <int>(Services.StudyManager().CurrentStudyConditions), new List <int>(Services.StudyManager().CurrentStudySessions));
                RequestVisWhenReady(properties);
            }
        }
コード例 #10
0
        /// <summary>
        /// Takes the provided properties and sets defaults where necessary.
        /// </summary>
        /// <param name="properties">The properties for the view.</param>
        /// <returns>The modified <see cref="VisProperties"/>.</returns>
        protected override VisProperties ParseSettings(VisProperties properties)
        {
            properties = base.ParseSettings(properties);
            if (!properties.TryGet("useSpeed", out List <bool> useSpeedList) || useSpeedList.Count != properties.ObjectIds.Count)
            {
                useSpeedList = new List <bool>();
                for (int i = 0; i < properties.ObjectIds.Count; i++)
                {
                    useSpeedList.Add(false);
                }

                properties.Set("useSpeed", useSpeedList);
            }

            return(properties);
        }
コード例 #11
0
        /// <summary>
        /// Initializes this view with the provided settings.
        /// </summary>
        /// <param name="settings">The settings for the view.</param>
        public override void Init(VisProperties settings)
        {
            if (isInitialized)
            {
                Reset();
            }

            if (Services.DataManager() == null || Services.DataManager().CurrentStudy == null)
            {
                // no study loaded
                return; // vis is now reset, we return because there is nothing to load
            }

            Settings = ParseSettings(settings); // parse the settings from the settings object, also makes a deep copy
            VisId    = Settings.VisId;

            // set callbacks for UI buttons
            if (PlayButton)
            {
                PlayButton.OnClick.AddListener(TogglePlayback);
            }

            if (ReduceSpeedButton)
            {
                ReduceSpeedButton.OnClick.AddListener(ReducePlaybackSpeed);
            }

            if (IncreaseSpeedButton)
            {
                IncreaseSpeedButton.OnClick.AddListener(IncreasePlaybackSpeed);
            }

            studyManager = Services.StudyManager();
            studyManager.TimelineEventBroadcast.AddListener(TimelineUpdated);
            studyManager.TimeFilterEventBroadcast.AddListener(TimeFilterUpdated);
            sliderGestureControl = GetComponentInChildren <TimeSliderGestureControl>();
            scale = GetComponentInChildren <TimelineScale>();
            sliderGestureControl.OnUpdateEvent.AddListener(UpdatedSlider);
            filterSliderGestureControl = GetComponentInChildren <TimeFilterSliderGestureControl>();
            filterSliderGestureControl.OnUpdateEvent.AddListener(UpdatedFilterSlider);

            scale.Init(0.9f);
            isInitialized = true;

            UpdateView();
            UpdateEventVis(settings);
        }
コード例 #12
0
ファイル: ViewContainer.cs プロジェクト: imldresden/miria
        /// <summary>
        /// Enables the visualization of type <see cref="VisType.Media2D"/>.
        /// </summary>
        public void OnMediaVisEnabled()
        {
            if (GetVisualizationsOfType(VisType.Media2D).Count == 0)
            {
                // no visualization of this type exists in this ViewContainer
                List <int> dataSets = new List <int>();
                for (int i = 0; i < Services.DataManager().DataSets.Count; i++)
                {
                    if (Services.DataManager().DataSets[i].ObjectType == ObjectType.TOUCH)
                    {
                        dataSets.Add(i);
                    }
                }

                var properties = new VisProperties(Guid.Empty, VisType.Media2D, Id, dataSets, new List <int>(Services.StudyManager().CurrentStudyConditions), new List <int>(Services.StudyManager().CurrentStudySessions));
                RequestVisWhenReady(properties);
            }
        }
コード例 #13
0
        /// <summary>
        /// Initializes the settings view.
        /// </summary>
        /// <param name="vis">The visualization that will be configured by this settings view.</param>
        /// <param name="showStaticObjects">Whether static study objects should be shown in the settings view.</param>
        /// <param name="showSpeedSettings">Whether speed settings should be shown in the settings view.</param>
        public override void Init(IConfigurableVisualization vis, bool showStaticObjects = true, bool showSpeedSettings = false)
        {
            if (vis == null)
            {
                return;
            }

            VisProperties settings = vis.Settings;

            visId = vis.Settings.VisId;
            settingsViewObjects = new List <SettingsViewObject>();

            int i = 0;

            // create settings prefab for each object
            if (SettingsPrefab && Services.DataManager() != null)
            {
                foreach (var dataSetElem in Services.DataManager().DataSets.Values)
                {
                    AnalysisObject dataSet            = (AnalysisObject)dataSetElem;
                    var            settingsViewObject = GameObject.Instantiate <SettingsViewObject>(SettingsPrefab, this.transform);
                    settingsViewObject.transform.localPosition = new Vector3(StartPositionX, StartPositionY - (i * OffsetY), -0.009f);
                    settingsViewObject.DataSet = dataSet;
                    settingsViewObject.Init();
                    for (int idx = 0; idx < settings.ObjectIds.Count; idx++)
                    {
                        if (settings.ObjectIds[idx] == dataSetElem.Id)
                        {
                            settingsViewObject.IsObjectSelected = true;
                            if (settings.TryGet("useSpeed", out List <bool> useSpeedList))
                            {
                                if (useSpeedList != null && useSpeedList.Count == settings.ObjectIds.Count)
                                {
                                    settingsViewObject.IsUseSpeedSelected = useSpeedList[idx];
                                }
                            }
                        }
                    }

                    settingsViewObjects.Add(settingsViewObject);
                    i++;
                }
            }
        }
コード例 #14
0
ファイル: Vis2DMedia.cs プロジェクト: imldresden/miria
        /// <summary>
        /// Initializes the visualization with the provided settings.
        /// </summary>
        /// <param name="settings">The settings to use for this visualization.</param>
        public override void Init(VisProperties settings)
        {
            if (isInitialized)
            {
                Reset();
            }

            // no study loaded?
            if (Services.DataManager() == null || Services.DataManager().CurrentStudy == null)
            {
                return; // vis is now reset, we return because there is nothing to load
            }

            Settings = ParseSettings(settings); // parse the settings from the settings object, also makes a deep copy

            VisId = Settings.VisId;
            if (Settings.Sessions != null && Settings.Sessions.Count >= 1)
            {
                currentSession = Settings.Sessions[0];
            }
            else
            {
                currentSession = -1;
            }

            if (Settings.Conditions != null && Settings.Conditions.Count >= 1)
            {
                currentCondition = Settings.Conditions[0];
            }
            else
            {
                currentCondition = -1;
            }

            InitMedia();
            Services.StudyManager().TimelineEventBroadcast.AddListener(TimelineUpdated);
            isInitialized = true;
        }
コード例 #15
0
 /// <summary>
 /// Updates the view with the provided settings.
 /// </summary>
 /// <param name="settings">The new settings for the view.</param>
 public override void UpdateView(VisProperties settings)
 {
     Init(settings);
 }
コード例 #16
0
        /// <summary>
        /// Takes the provided properties and sets defaults where necessary.
        /// </summary>
        /// <param name="properties">The properties for the view.</param>
        /// <returns>The modified <see cref="VisProperties"/>.</returns>
        protected virtual VisProperties ParseSettings(VisProperties properties)
        {
            // set vis id
            if (properties.VisId == Guid.Empty)
            {
                properties.VisId = this.VisId;
            }

            // set vis type
            properties.VisType = this.VisType;

            if (properties.ObjectIds == null)
            {
                // not set, keep current ones
                if (Settings == null || Settings.ObjectIds == null)
                {
                    properties.ObjectIds = new List <int>();
                    for (int i = 0; i < Services.DataManager().CurrentStudy.Objects.Count; i++)
                    {
                        properties.ObjectIds.Add(Services.DataManager().CurrentStudy.Objects[i].Id);
                    }
                }
                else
                {
                    properties.ObjectIds = Settings.ObjectIds;
                }
            }
            else if (properties.ObjectIds.Count == 1 && properties.ObjectIds[0] == -1)
            {
                // set to -1, use all objects
                properties.ObjectIds = new List <int>();
                for (int i = 0; i < Services.DataManager().CurrentStudy.Objects.Count; i++)
                {
                    properties.ObjectIds.Add(Services.DataManager().CurrentStudy.Objects[i].Id);
                }
            }

            // parse conditions
            if (properties.Conditions == null)
            {
                // not set, keep current conditions
                if (Settings == null || Settings.Conditions == null)
                {
                    properties.Conditions = new List <int>(Services.StudyManager().CurrentStudyConditions);
                }
                else
                {
                    properties.Conditions = Settings.Conditions;
                }
            }
            else if (properties.Conditions.Count == 0 || (properties.Conditions.Count == 1 && properties.Conditions[0] == -1))
            {
                // set to -1, use all conditions
                properties.Conditions = new List <int>();
                for (int i = 0; i < Services.DataManager().CurrentStudy.Conditions.Count; i++)
                {
                    properties.Conditions.Add(i);
                }
            }

            // parse sessions
            if (properties.Sessions == null)
            {
                // not set, keep current sessions
                if (Settings == null || Settings.Sessions == null)
                {
                    properties.Sessions = new List <int>(Services.StudyManager().CurrentStudySessions);
                }
                else
                {
                    properties.Sessions = Settings.Sessions;
                }
            }
            else if (properties.Sessions.Count == 0 || (properties.Sessions.Count == 1 && properties.Sessions[0] == -1))
            {
                // set to -1, use all sessions
                properties.Sessions = new List <int>();
                for (int i = 0; i < Services.DataManager().CurrentStudy.Sessions.Count; i++)
                {
                    properties.Sessions.Add(i);
                }
            }

            return(properties);
        }
コード例 #17
0
 /// <summary>
 /// Initializes the view with the provided settings.
 /// </summary>
 /// <param name="settings">The settings to use for this view.</param>
 public abstract void Init(VisProperties settings);
コード例 #18
0
 /// <summary>
 /// Updates the view with the provided settings.
 /// </summary>
 /// <param name="settings">The new settings for the view.</param>
 public abstract void UpdateView(VisProperties settings);
コード例 #19
0
ファイル: ViewContainer.cs プロジェクト: imldresden/miria
 private void RequestVisWhenReady(VisProperties visSettingsStruct)
 {
     requestedVis   = visSettingsStruct;
     isVisRequested = true;
 }
コード例 #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageUpdateVisualization"/> class.
 /// </summary>
 /// <param name="settings">The settings for the visualization.</param>
 public MessageUpdateVisualization(VisProperties settings)
 {
     Settings = settings;
 }
コード例 #21
0
 /// <summary>
 /// Updates the view with the provided settings.
 /// </summary>
 /// <param name="settings">The new settings for the view.</param>
 public override void UpdateView(VisProperties settings)
 {
     Init(settings); // re-initialize
 }
コード例 #22
0
 /// <summary>
 /// Initializes the view with the provided settings.
 /// </summary>
 /// <param name="settings">The settings to use for this view.</param>
 public override void Init(VisProperties settings)
 {
     Init();
 }