From f302591d3d9745e778942ca3f5552a1a7f69ffa5 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Fri, 16 Feb 2024 15:27:46 -0800 Subject: [PATCH 1/3] Reset target selection if none are found --- .../InsertionSelectionPanelHandler.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs index a17906ee..c30ca97e 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs @@ -249,10 +249,19 @@ public void UpdateTargetInsertionOptions() // Restore selection (if possible) var selectedProbeManager = ManipulatorIDToSelectedTargetProbeManager.GetValueOrDefault( ProbeManager.ManipulatorBehaviorController.ManipulatorID, null); - _targetInsertionDropdown.SetValueWithoutNotify( - _targetProbeManagerOptions.ToList() - .IndexOf(selectedProbeManager) + 1 - ); + if (selectedProbeManager == null) + { + // Select none if no previous selection. + _targetInsertionDropdown.SetValueWithoutNotify(0); + } + else + { + _targetInsertionDropdown.SetValueWithoutNotify( + _targetProbeManagerOptions.ToList() + .IndexOf(selectedProbeManager) + 1 + ); + } + // Color dropdown to match probe color if (!selectedProbeManager) return; From 6825ecfbdefb65f3fa5d94c0e1c2444e49100368 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Fri, 16 Feb 2024 15:34:04 -0800 Subject: [PATCH 2/3] Fix null id error --- .../UI/EphysCopilot/InsertionSelectionPanelHandler.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs index c30ca97e..14631bdf 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysCopilot/InsertionSelectionPanelHandler.cs @@ -246,21 +246,20 @@ public void UpdateTargetInsertionOptions() .Select(probeManager => (probeManager.OverrideName ?? probeManager.name) + ": " + SurfaceCoordinateToString(probeManager.GetSurfaceCoordinateT())).ToList()); + // Return early if no manipulator ID + if (ProbeManager.ManipulatorBehaviorController.ManipulatorID == null) return; + // Restore selection (if possible) var selectedProbeManager = ManipulatorIDToSelectedTargetProbeManager.GetValueOrDefault( ProbeManager.ManipulatorBehaviorController.ManipulatorID, null); if (selectedProbeManager == null) - { // Select none if no previous selection. _targetInsertionDropdown.SetValueWithoutNotify(0); - } else - { _targetInsertionDropdown.SetValueWithoutNotify( _targetProbeManagerOptions.ToList() .IndexOf(selectedProbeManager) + 1 ); - } // Color dropdown to match probe color From 481ee7648a6fe147b54a24bb6ef2ff60d575ef92 Mon Sep 17 00:00:00 2001 From: Kenneth Yang Date: Fri, 16 Feb 2024 15:39:45 -0800 Subject: [PATCH 3/3] Only enable copilot toggle if there are connected probes --- Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab | 2 +- .../Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab b/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab index 748806e1..f683b830 100644 --- a/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab +++ b/Assets/Prefabs/UI/SettingsMenu/Menus/EphysLinkMenu.prefab @@ -2565,7 +2565,7 @@ MonoBehaviour: m_PressedTrigger: Pressed m_SelectedTrigger: Selected m_DisabledTrigger: Disabled - m_Interactable: 1 + m_Interactable: 0 m_TargetGraphic: {fileID: 6487466997665187127} toggleTransition: 1 graphic: {fileID: 2477337667047670143} diff --git a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs index 8efdc807..ca48284b 100644 --- a/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs +++ b/Assets/Scripts/Pinpoint/UI/EphysLinkSettings/EphysLinkSettings.cs @@ -85,15 +85,11 @@ private void UpdateConnectionPanel() private void UpdateManipulatorPanels() { // Default Copilot to be disabled unless the right manipulator type is found - _copilotToggle.interactable = false; if (CommunicationManager.Instance.IsConnected) { CommunicationManager.Instance.GetManipulators((availableIDs, numAxes, _) => { - // Enable Copilot button if using Sensapex or New Scale - _copilotToggle.interactable = numAxes > 0; - // Keep track of handled manipulator panels var handledManipulatorIds = new HashSet(); @@ -232,6 +228,9 @@ public void ToggleCopilotPanel(bool isEnabled) public void InvokeShouldUpdateProbesListEvent() { ShouldUpdateProbesListEvent.Invoke(); + + // Enable/Disable Copilot toggle based on if there are any probes that can be controlled by it. + _copilotToggle.interactable = LinkedProbes.Count > 0; } #endregion