/// <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 GenerateAnchors(StudyData currentStudy) { var visContainers = ParseAnchors(currentStudy.Anchors); Services.VisManager().DeleteAllViewContainers(false); foreach (var container in visContainers) { Services.VisManager().CreateViewContainer(container, false); } }
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"); }
private void UpdateViewContainers() { var containers = Services.VisManager().ViewContainers; long currentTime = Services.StudyManager().CurrentTimestamp; foreach (var element in containers) { var id = element.Key; var viewContainer = element.Value; if (viewContainer.ParentId != -1) { // This view container has a parent and could have changed its transform. // get the AnalysisObject that is this container's parent var parent = dataSets.Find( delegate(AnalysisObject obj) { return(obj.Id == viewContainer.ParentId); }); // skip this container if the parent is not part of our list of AnalysisObjects if (parent == null) { viewContainer.gameObject.SetActive(false); continue; } // skip this container if more than one session or condition is selected if (sessions.Count != 1 || conditions.Count != 1) { viewContainer.gameObject.SetActive(false); continue; // ToDo: support multiple sessions and conditions. Ideally, automatically create one ViewContainer per session/condition, keep its settings synced to the others and only show data for the current session/condition } else { // (Settings.Sessions.Count == 1 && Settings.Conditions.Count == 1) if (currentTime < currentTimeFilterMin || currentTime > currentTimeFilterMax) { viewContainer.gameObject.SetActive(false); continue; } viewContainer.gameObject.SetActive(true); // get parent position and orientation at current time stamp int session = sessions[0]; int condition = conditions[0]; Vector3 parentPosition; Quaternion parentOrientation; int earlierIndex = parent.GetIndexFromTimestamp(currentTime, session, condition); var earlierSample = parent.GetInfoObjects(session, condition)[earlierIndex]; if (earlierIndex + 1 >= parent.GetInfoObjects(session, condition).Count || earlierSample.Timestamp >= currentTime) { parentPosition = earlierSample.Position; parentOrientation = earlierSample.Rotation; } else { int laterIndex = earlierIndex + 1; var laterSample = parent.GetInfoObjects(session, condition)[laterIndex]; float interpolant = (currentTime - earlierSample.Timestamp) * 1.0f / (laterSample.Timestamp - earlierSample.Timestamp) * 1.0f; parentPosition = Vector3.Lerp(earlierSample.Position, laterSample.Position, interpolant); parentOrientation = Quaternion.Lerp(earlierSample.Rotation, laterSample.Rotation, interpolant); } // update child container transform accordingly Quaternion newRotation = parentOrientation; Vector3 newPosition = parentPosition + (newRotation * viewContainer.PositionOffset); if (newRotation != viewContainer.transform.localRotation || newPosition != viewContainer.transform.localPosition) { viewContainer.UpdateTransform(newPosition, newRotation); ////viewContainer.transform.localRotation = newRotation; ////viewContainer.transform.localPosition = newPosition; ////viewContainer.transform.hasChanged = true; } } } } }