public void UpdateMenu() { if (currentFocusPoint >= 0) { return; } if (CurrentObject.ActionObjectMetadata.ObjectModel?.Type == IO.Swagger.Model.ObjectModel.TypeEnum.Mesh) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(true); RobotsListsBlock.SetActive(true); } else if (CurrentObject.ActionObjectMetadata.ObjectModel != null) { UpdatePositionBlockVO.SetActive(true); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(true); } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } RobotsList.gameObject.GetComponent <DropdownRobots>().Init(OnRobotChanged, true); if (RobotsList.Dropdown.dropdownItems.Count > 0) { OnRobotChanged(RobotsList.Dropdown.selectedText.text); } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } FocusObjectDoneButton.interactable = false; NextButton.interactable = false; PreviousButton.interactable = false; objectName.text = CurrentObject.Data.Name; VisibilitySlider.value = CurrentObject.GetVisibility() * 100; }
public async Task UpdateMenu() { CalibrateBtn.gameObject.SetActive(false); if (!SceneManager.Instance.SceneStarted) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); Hide(); return; } CalibrateBtn.Button.onClick.RemoveAllListeners(); if (currentObject.IsRobot()) { CalibrateBtn.gameObject.SetActive(true); CalibrateBtn.SetDescription("Calibrate robot"); CalibrateBtn.Button.onClick.AddListener(() => ShowCalibrateRobotDialog()); if (SceneManager.Instance.GetCamerasNames().Count > 0) { CalibrateBtn.SetInteractivity(true); } else { CalibrateBtn.SetInteractivity(false, "Could not calibrate robot without camera"); } } else if (currentObject.IsCamera()) { CalibrateBtn.gameObject.SetActive(true); CalibrateBtn.SetDescription("Calibrate camera"); CalibrateBtn.Button.onClick.AddListener(() => ShowCalibrateCameraDialog()); } if (SceneManager.Instance.IsRobotAndEESelected()) { if (currentObject.ActionObjectMetadata.ObjectModel?.Type == IO.Swagger.Model.ObjectModel.TypeEnum.Mesh && currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints?.Count > 0) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(true); int idx = 0; foreach (AimingPointSphere sphere in spheres) { if (sphere != null) { Destroy(sphere.gameObject); } } spheres.Clear(); foreach (IO.Swagger.Model.Pose point in currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints) { AimingPointSphere sphere = Instantiate(Sphere, currentObject.transform).GetComponent <AimingPointSphere>(); sphere.transform.localScale = new Vector3(0.02f, 0.02f, 0.02f); sphere.transform.localPosition = TransformConvertor.ROSToUnity(DataHelper.PositionToVector3(point.Position)); sphere.transform.localRotation = TransformConvertor.ROSToUnity(DataHelper.OrientationToQuaternion(point.Orientation)); sphere.Init(idx, $"Aiming point #{idx}"); spheres.Add(sphere); ++idx; } try { List <int> finishedIndexes = await WebsocketManager.Instance.ObjectAimingAddPoint(0, true); foreach (AimingPointSphere sphere in spheres) { sphere.SetAimed(finishedIndexes.Contains(sphere.Index)); } if (!automaticPointSelection) { currentFocusPoint = 0; } StartObjectFocusingButton.SetInteractivity(false, "Already started"); SavePositionButton.SetInteractivity(true); CancelAimingButton.SetInteractivity(true); await CheckDoneBtn(); AimingInProgress = true; if (currentObject is ActionObject3D actionObject3D) { actionObject3D.UnHighlight(); } UpdateCurrentPointLabel(); if (!automaticPointSelection && currentObject.ActionObjectMetadata.ObjectModel.Mesh.FocusPoints.Count > 1) { NextButton.SetInteractivity(true); PreviousButton.SetInteractivity(true); PreviousPoint(); } } catch (RequestFailedException ex) { StartObjectFocusingButton.SetInteractivity(true); FocusObjectDoneButton.SetInteractivity(false, "No aiming in progress"); NextButton.SetInteractivity(false, "No aiming in progress"); PreviousButton.SetInteractivity(false, "No aiming in progress"); SavePositionButton.SetInteractivity(false, "No aiming in progress"); CancelAimingButton.SetInteractivity(false, "No aiming in progress"); AimingInProgress = false; if (currentObject is ActionObject3D actionObject3D) { actionObject3D.Highlight(); } } } else if (!currentObject.IsRobot() && !currentObject.IsCamera() && currentObject.ActionObjectMetadata.ObjectModel != null) { UpdatePositionBlockVO.SetActive(true); UpdatePositionBlockMesh.SetActive(false); ShowModelSwitch.Interactable = SceneManager.Instance.RobotsEEVisible; if (ShowModelSwitch.Interactable && ShowModelSwitch.Switch.isOn) { ShowModelOnEE(); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); } }
public async override void UpdateMenu() { base.UpdateMenu(); objectParameters = Parameter.InitParameters(CurrentObject.ObjectParameters.Values.ToList(), Parameters, OnChangeParameterHandler, DynamicContentLayout, CanvasRoot, true); parametersChanged = false; UpdateSaveBtn(); if (!SceneManager.Instance.SceneStarted) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); return; } if (currentFocusPoint >= 0) { return; } if (SceneManager.Instance.RobotInScene()) { await RobotsList.gameObject.GetComponent <DropdownRobots>().Init(OnRobotChanged, true); string robotId = null; try { robotId = SceneManager.Instance.RobotNameToId(RobotsList.GetValue().ToString()); } catch (ItemNotFoundException ex) { Debug.LogError(ex); robotId = null; } if (string.IsNullOrEmpty(robotId)) { Notifications.Instance.ShowNotification("Robot not found", "Robot with name " + RobotsList.GetValue().ToString() + "does not exists"); } else { OnRobotChanged(robotId); } if (CurrentObject.ActionObjectMetadata.ObjectModel?.Type == IO.Swagger.Model.ObjectModel.TypeEnum.Mesh) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(true); RobotsListsBlock.SetActive(true); } else if (CurrentObject.ActionObjectMetadata.ObjectModel != null) { UpdatePositionBlockVO.SetActive(true); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(true); ShowModelSwitch.Interactable = SceneManager.Instance.RobotsEEVisible; if (ShowModelSwitch.Interactable && ShowModelSwitch.Switch.isOn) { ShowModelOnEE(); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } FocusObjectDoneButton.interactable = false; NextButton.interactable = false; PreviousButton.interactable = false; }
public void UpdateMenu() { if (currentFocusPoint >= 0) { return; } if (SceneManager.Instance.RobotInScene()) { RobotsList.gameObject.GetComponent <DropdownRobots>().Init(OnRobotChanged, true); string robotId = null; try { robotId = SceneManager.Instance.RobotNameToId(RobotsList.GetValue().ToString()); } catch (ItemNotFoundException ex) { Debug.LogError(ex); robotId = null; } if (string.IsNullOrEmpty(robotId)) { Notifications.Instance.ShowNotification("Robot not found", "Robot with name " + RobotsList.GetValue().ToString() + "does not exists"); } else { OnRobotChanged(robotId); } if (CurrentObject.ActionObjectMetadata.ObjectModel?.Type == IO.Swagger.Model.ObjectModel.TypeEnum.Mesh) { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(true); RobotsListsBlock.SetActive(true); } else if (CurrentObject.ActionObjectMetadata.ObjectModel != null) { UpdatePositionBlockVO.SetActive(true); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(true); ShowModelSwitch.Interactable = SceneManager.Instance.RobotsEEVisible; if (ShowModelSwitch.Interactable && ShowModelSwitch.Switch.isOn) { ShowModelOnEE(); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } } else { UpdatePositionBlockVO.SetActive(false); UpdatePositionBlockMesh.SetActive(false); RobotsListsBlock.SetActive(false); } FocusObjectDoneButton.interactable = false; NextButton.interactable = false; PreviousButton.interactable = false; objectName.text = CurrentObject.Data.Name; VisibilitySlider.value = CurrentObject.GetVisibility() * 100; }