Skip to content

Commit 1103f31

Browse files
committed
feat: working on craniotomy data across different atlases
1 parent 0049490 commit 1103f31

File tree

2 files changed

+83
-29
lines changed

2 files changed

+83
-29
lines changed

Assets/Scenes/TrajectoryPlanner.unity

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,17 @@ MonoBehaviour:
11881188
m_Script: {fileID: 11500000, guid: 1f0d7476d212c8842bb7706a6d996932, type: 3}
11891189
m_Name:
11901190
m_EditorClassIdentifier:
1191+
--- !u!114 &922715042 stripped
1192+
MonoBehaviour:
1193+
m_CorrespondingSourceObject: {fileID: 7610818863979926319, guid: 734f6254569c01842b9d2e2ff1b1d7ae, type: 3}
1194+
m_PrefabInstance: {fileID: 1302158968208938923}
1195+
m_PrefabAsset: {fileID: 0}
1196+
m_GameObject: {fileID: 0}
1197+
m_Enabled: 1
1198+
m_EditorHideFlags: 0
1199+
m_Script: {fileID: 11500000, guid: d9e6156b343e276468f718e49124fa4f, type: 3}
1200+
m_Name:
1201+
m_EditorClassIdentifier:
11911202
--- !u!1 &952734154 stripped
11921203
GameObject:
11931204
m_CorrespondingSourceObject: {fileID: 206732207517579495, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
@@ -3052,15 +3063,15 @@ PrefabInstance:
30523063
objectReference: {fileID: 1703646459}
30533064
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
30543065
propertyPath: m_AnchorMax.y
3055-
value: 0
3066+
value: 1
30563067
objectReference: {fileID: 0}
30573068
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
30583069
propertyPath: m_AnchorMin.y
3059-
value: 0
3070+
value: 1
30603071
objectReference: {fileID: 0}
30613072
- target: {fileID: 341190943836035196, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
30623073
propertyPath: m_AnchoredPosition.x
3063-
value: 0
3074+
value: 169.88
30643075
objectReference: {fileID: 0}
30653076
- target: {fileID: 341190943836276264, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
30663077
propertyPath: m_IsOn
@@ -3196,19 +3207,19 @@ PrefabInstance:
31963207
objectReference: {fileID: 0}
31973208
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
31983209
propertyPath: m_AnchorMax.y
3199-
value: 0
3210+
value: 1
32003211
objectReference: {fileID: 0}
32013212
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32023213
propertyPath: m_AnchorMin.y
3203-
value: 0
3214+
value: 1
32043215
objectReference: {fileID: 0}
32053216
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32063217
propertyPath: m_AnchoredPosition.x
3207-
value: 0
3218+
value: 354.84
32083219
objectReference: {fileID: 0}
32093220
- target: {fileID: 341190944034978748, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32103221
propertyPath: m_AnchoredPosition.y
3211-
value: 0
3222+
value: -15
32123223
objectReference: {fileID: 0}
32133224
- target: {fileID: 341190944071593138, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
32143225
propertyPath: m_AnchorMax.x
@@ -3488,19 +3499,19 @@ PrefabInstance:
34883499
objectReference: {fileID: 0}
34893500
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
34903501
propertyPath: m_AnchorMax.y
3491-
value: 0
3502+
value: 1
34923503
objectReference: {fileID: 0}
34933504
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
34943505
propertyPath: m_AnchorMin.y
3495-
value: 0
3506+
value: 1
34963507
objectReference: {fileID: 0}
34973508
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
34983509
propertyPath: m_AnchoredPosition.x
3499-
value: 0
3510+
value: 384.91998
35003511
objectReference: {fileID: 0}
35013512
- target: {fileID: 341190944410943211, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35023513
propertyPath: m_AnchoredPosition.y
3503-
value: 0
3514+
value: -15
35043515
objectReference: {fileID: 0}
35053516
- target: {fileID: 341190944411999430, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
35063517
propertyPath: m_AnchorMax.y
@@ -4150,6 +4161,18 @@ PrefabInstance:
41504161
propertyPath: _craniotomySkull
41514162
value:
41524163
objectReference: {fileID: 1826524689}
4164+
- target: {fileID: 341190945559892368, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
4165+
propertyPath: _skullList.Array.size
4166+
value: 2
4167+
objectReference: {fileID: 0}
4168+
- target: {fileID: 341190945559892368, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
4169+
propertyPath: _skullList.Array.data[0]
4170+
value:
4171+
objectReference: {fileID: 1826524689}
4172+
- target: {fileID: 341190945559892368, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
4173+
propertyPath: _skullList.Array.data[1]
4174+
value:
4175+
objectReference: {fileID: 922715042}
41534176
- target: {fileID: 341190945559892372, guid: 94cdeca105038d74ea47b57e6b99eb4e, type: 3}
41544177
propertyPath: m_AnchorMax.y
41554178
value: 1

Assets/Scripts/Craniotomy/CraniotomyPanel.cs

Lines changed: 49 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using UnityEngine.Serialization;
55
using UnityEngine.UI;
66
using BrainAtlas;
7+
using System.Collections.Generic;
78

89
public class CraniotomyPanel : MonoBehaviour
910
{
@@ -26,7 +27,7 @@ public class CraniotomyPanel : MonoBehaviour
2627

2728
private int _lastCraniotomyIdx = 0;
2829

29-
[FormerlySerializedAs("craniotomySkull")] [SerializeField] private CraniotomySkull _craniotomySkull;
30+
[SerializeField] private List<CraniotomySkull> _skullList;
3031

3132
private void Awake()
3233
{
@@ -35,22 +36,40 @@ private void Awake()
3536

3637
private void OnEnable()
3738
{
38-
_craniotomySkull.Enable();
39-
UpdateCraniotomyIdx(_lastCraniotomyIdx);
39+
foreach (CraniotomySkull skull in _skullList)
40+
{
41+
if (skull.gameObject.activeSelf)
42+
{
43+
skull.Enable();
44+
UpdateCraniotomyIdx(_lastCraniotomyIdx);
45+
}
46+
}
4047
}
4148

4249
private void SetDefaultCraniotomyPositions()
4350
{
44-
for (int i = 0; i < 5; i++)
51+
foreach (CraniotomySkull skull in _skullList)
4552
{
46-
_craniotomySkull.SetActiveCraniotomy(i);
47-
_craniotomySkull.SetCraniotomyPosition(BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(Vector3.zero));
48-
}
53+
if (skull.gameObject.activeSelf)
54+
{
55+
for (int i = 0; i < 5; i++)
56+
{
57+
skull.SetActiveCraniotomy(i);
58+
skull.SetCraniotomyPosition(BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(Vector3.zero));
59+
}
60+
}
61+
}
4962
}
5063

5164
private void OnDisable()
5265
{
53-
_craniotomySkull.Disable();
66+
foreach (CraniotomySkull skull in _skullList)
67+
{
68+
if (skull.gameObject.activeSelf)
69+
{
70+
skull.Disable();
71+
}
72+
}
5473
}
5574

5675
public void UpdateAP(float ap)
@@ -74,13 +93,19 @@ public void UpdateSize(float newSize)
7493

7594
public void UpdateCraniotomyIdx(int craniotomyIdx)
7695
{
77-
_lastCraniotomyIdx = craniotomyIdx;
78-
_craniotomySkull.SetActiveCraniotomy(craniotomyIdx);
79-
_positionWorld = _craniotomySkull.GetCraniotomyPosition();
80-
_positionSpace = BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(_positionWorld);
81-
size = _craniotomySkull.GetCraniotomySize();
82-
UpdateText();
83-
UpdateSliders();
96+
foreach (CraniotomySkull skull in _skullList)
97+
{
98+
if (skull.gameObject.activeSelf)
99+
{
100+
_lastCraniotomyIdx = craniotomyIdx;
101+
skull.SetActiveCraniotomy(craniotomyIdx);
102+
_positionWorld = skull.GetCraniotomyPosition();
103+
_positionSpace = BrainAtlasManager.ActiveReferenceAtlas.World2Atlas(_positionWorld);
104+
size = skull.GetCraniotomySize();
105+
UpdateText();
106+
UpdateSliders();
107+
}
108+
}
84109
}
85110

86111
private void UpdateSliders()
@@ -105,10 +130,16 @@ private void UpdateCraniotomy()
105130
// We need to rotate the x/y coordinates into the current transformed space...
106131
_positionWorld = BrainAtlasManager.ActiveReferenceAtlas.Atlas2World(_positionSpace);
107132

108-
if (_craniotomySkull != null)
133+
foreach (CraniotomySkull skull in _skullList)
109134
{
110-
_craniotomySkull.SetCraniotomyPosition(_positionWorld);
111-
_craniotomySkull.SetCraniotomySize(size);
135+
if (skull.gameObject.activeSelf)
136+
{
137+
if (skull != null)
138+
{
139+
skull.SetCraniotomyPosition(_positionWorld);
140+
skull.SetCraniotomySize(size);
141+
}
142+
}
112143
}
113144
}
114145

0 commit comments

Comments
 (0)