/// <summary> /// Loads the study with the provided index. /// </summary> /// <param name="studyIndex">The index of the study to load.</param> public async void LoadStudy(int studyIndex) { _ = ProgressIndicator.StartProgressIndicator("Loading data..."); // tell other clients to also load the study var command = new MessageLoadStudy(studyIndex); Services.NetworkManager().SendMessage(command.Pack()); // delete all current Visualizations Services.VisManager().DeleteAllVisualizations(false); // load the actual data await Services.DataManager().LoadStudyAsync(studyIndex); StudyChangeBroadcast.Invoke(studyIndex); // set session filter (also remotely) Services.StudyManager().UpdateSessionFilter(new List <int> { 0 }, new List <int> { 0 }); _ = ProgressIndicator.StopProgressIndicator(); }
private void UpdateTimestampBounds() { MinTimestamp = long.MaxValue; MaxTimestamp = long.MinValue; foreach (int s in CurrentStudySessions) { foreach (int c in CurrentStudyConditions) { foreach (var dataSet in Services.DataManager().DataSets) { if (dataSet.Value.IsStatic) { continue; } MinTimestamp = Math.Min(dataSet.Value.GetMinTimestamp(s, c), MinTimestamp); MaxTimestamp = Math.Max(dataSet.Value.GetMaxTimestamp(s, c), MaxTimestamp); } } } if (MinTimestamp == long.MinValue) { MinTimestamp = 0; } if (MaxTimestamp == long.MinValue) { MaxTimestamp = 0; } CurrentTimeFilter.MinTimestamp = (long)(CurrentTimeFilter.MinTime * (MaxTimestamp - MinTimestamp)) + MinTimestamp; CurrentTimeFilter.MaxTimestamp = (long)(CurrentTimeFilter.MaxTime * (MaxTimestamp - MinTimestamp)) + MinTimestamp; }
/// <summary> /// Initializes a new instance of the <see cref="ObjectImportHelper"/> class. /// </summary> /// <param name="source">The <see cref="ObjectSource"/> containing the meta data of the object.</param> /// <param name="analysisObject">The <see cref="AnalysisObject"/> already containing the static data of the object.</param> public ObjectImportHelper(ObjectSource source, AnalysisObject analysisObject) { Source = source; ObjectId = source.ObjectId; SessionId = source.SessionId; ConditionId = source.ConditionId; ImportData = new CsvImportBlock(source); Parsers = new List <ParserFunc>(); ParserIndices = new List <int[]>(); StaticPosition = analysisObject.LocalPosition; StaticOrientation = analysisObject.LocalRotation; StaticScale = analysisObject.LocalScale; UnitConversionFactor = analysisObject.UnitConversionFactor; RotationFormat = analysisObject.RotationFormat; timeFormat = analysisObject.TimeFormat; axisTransformationMatrix4x4 = Services.DataManager().AxisTransformationMatrix4x4; }
/// <summary> /// Centers or un-centers the data to the origin, based on the average position of the samples. /// </summary> /// <param name="isCentering">Indicated whether to center or to reverse.</param> /// <param name="syncWithRemote">Indicates whether the centering should also happen on remote clients.</param> public void CenterData(bool isCentering, bool syncWithRemote = true) { var GlobalOffset = GameObject.FindGameObjectWithTag("GlobalOffset"); if (GlobalOffset != null) { // center or un-center data if (isCentering == true && GlobalOffset.transform.position == Vector3.zero) { Vector3 averagePosition = Vector3.zero; foreach (var studyObject in Services.DataManager().DataSets.Values) { averagePosition += studyObject.AveragePosition; } averagePosition /= Services.DataManager().DataSets.Values.Count; GameObject.FindGameObjectWithTag("GlobalOffset").transform.localPosition -= averagePosition; // send message to the other clients if (syncWithRemote) { var message = new MessageCenterData(isCentering); Services.NetworkManager().SendMessage(message.Pack()); } // send notification event that the data was centered or un-centered DataCenteringEventBroadcast.Invoke(true); } else { GameObject.FindGameObjectWithTag("GlobalOffset").transform.localPosition = Vector3.zero; // send message to the other clients if (syncWithRemote) { var message = new MessageCenterData(isCentering); Services.NetworkManager().SendMessage(message.Pack()); } // send notification event that the data was centered or un-centered DataCenteringEventBroadcast.Invoke(false); } } }
/// <summary> /// Initializes the <see cref="ViewContainerManager"/>. /// </summary> public void Init() { 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 } UpdateSessionFilter(); // update the list of sessions and conditions for (int i = 0; i < Services.DataManager().DataSets.Count; i++) { dataSets.Add(Services.DataManager().DataSets[i]); } // get filter min/max if (Services.StudyManager() != null) { // get min and max time stamp foreach (int s in sessions) { foreach (int c in conditions) { foreach (var dataSet in dataSets) { minTimestamp = Math.Min(dataSet.GetMinTimestamp(s, c), minTimestamp); maxTimestamp = Math.Max(dataSet.GetMaxTimestamp(s, c), maxTimestamp); } } } // set filtered min and max, based on filter value [0,1] and global min/max currentTimeFilterMin = (long)(Services.StudyManager().CurrentTimeFilter.MinTime *(maxTimestamp - minTimestamp)) + minTimestamp; currentTimeFilterMax = (long)(Services.StudyManager().CurrentTimeFilter.MaxTime *(maxTimestamp - minTimestamp)) + minTimestamp; } isInitialized = true; }
private async Task OnLoadStudy(MessageContainer obj) { Debug.Log("Loading Study"); Services.NetworkManager().Pause(); MessageLoadStudy message = MessageLoadStudy.Unpack(obj); if (message != null) { _ = ProgressIndicator.StartProgressIndicator("Loading data..."); // delete all current Visualizations Services.VisManager().DeleteAllVisualizations(false); // load the actual data await Services.DataManager().LoadStudyAsync(message.StudyIndex); StudyChangeBroadcast.Invoke(message.StudyIndex); _ = ProgressIndicator.StopProgressIndicator(); } Services.NetworkManager().Unpause(); Debug.Log("Loading Study - Completed"); }