Loading Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/BaseWindow.cs 0 → 100644 +117 −0 Original line number Diff line number Diff line // // ARF - Augmented Reality Framework (ETSI ISG ARF) // // Copyright 2024 ETSI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Last change: June 2024 // #define isDEBUG using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; using UnityEditor; using TMPro; using ETSI.ARF.WorldStorage.REST; using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public abstract class BaseWindow<T> : EditorWindow { [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> trackables = new List<string>(); // // Keyvalues // [SerializeField] protected KeyvalueTagList keyValueTags = new KeyvalueTagList(); protected List<(string, string)> keyValuesFixed = new List<(string, string)>(3) { ("", ""),("", ""),("", "") }; protected void OutputKeyValue(int n) { string i1 = keyValuesFixed[n].Item1; string i2 = keyValuesFixed[n].Item2; i1 = EditorGUILayout.TextField("Key " + n, i1); i2 = EditorGUILayout.TextField("Value " + n, i2); keyValuesFixed[n] = (i1, i2); } // // UI stuffs // protected bool groupEnabled; protected bool repaint = false; protected Vector2 scrollPos; protected Color ori; protected GUIStyle gsTest; public void Update() { if (repaint) { Repaint(); repaint = false; } } void OnGUI() { ori = GUI.backgroundColor; // remember ori color gsTest = new GUIStyle("window"); //gsTest.normal.textColor = WorldStorageWindow.arfColors[0]; gsTest.fontStyle = FontStyle.Bold; gsTest.alignment = TextAnchor.UpperLeft; gsTest.fontSize = 16; scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); if (GUILayout.Button("Close Window")) { Close(); } } public abstract void DrawUIStuffs(); public virtual void GetParams() { } public virtual void AddObject() { } public virtual T GenerateObject() { return default(T); } } } No newline at end of file Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/BaseWindow.cs.meta 0 → 100644 +14 −0 Original line number Diff line number Diff line fileFormatVersion: 2 guid: b879c85f4eccbee40a78e1a01aaf77ca MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: - m_ViewDataDictionary: {instanceID: 0} - worldStorageServer: {fileID: 11400000, guid: 4f997253243de534dad12937f1284975, type: 2} - worldStorageUser: {instanceID: 0} executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant: Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/TrackableWindow.cs +84 −64 Original line number Diff line number Diff line Loading @@ -34,21 +34,15 @@ using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public class TrackableWindow : EditorWindow public class TrackableWindow : BaseWindow<Trackable> { static public TrackableWindow winSingleton; [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> trackables = new List<string>(); bool groupEnabled; // Trackable params string UUID = System.Guid.Empty.ToString(); string customName = "NotDefined"; string creatorUUID = System.Guid.Empty.ToString(); double confidence = 0f; TrackableType type = TrackableType.OTHER; UnitSystem unit = UnitSystem.CM; Vector3 trackableSize; Loading @@ -56,20 +50,16 @@ namespace ETSI.ARF.WorldStorage.UI Vector3 localCRS_rot; byte[] trackablePayload = new byte[1] { 0 }; [SerializeField] KeyvalueTagList keyValueTags = new KeyvalueTagList(); string key1 = ""; string value1 = ""; // UI stuffs private Vector2 scrollPos; private Color ori; private GUIStyle gsTest; //graph params to generate the node public bool useCoord; public float nodePosX = 0; public float nodePosY = 0; public TrackableWindow() { // init somne stuffs } public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user, string UUID = "") { winSingleton = EditorWindow.GetWindow(typeof(TrackableWindow), false, "ETSI ARF - Trackable") as TrackableWindow; Loading @@ -78,12 +68,12 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID)) { winSingleton.UUID = UUID; winSingleton.GetTrackableParams(); winSingleton.GetParams(); } else { // Create new one winSingleton.AddTrackable(); winSingleton.AddObject(); } } Loading @@ -108,11 +98,6 @@ namespace ETSI.ARF.WorldStorage.UI return visual; } public TrackableWindow() { // init somne stuffs } void OnGUI() { ori = GUI.backgroundColor; // remember ori color Loading @@ -126,7 +111,7 @@ namespace ETSI.ARF.WorldStorage.UI scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawTrackableStuffs(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); Loading @@ -136,7 +121,7 @@ namespace ETSI.ARF.WorldStorage.UI } } void DrawTrackableStuffs()// Trackable trackable) public override void DrawUIStuffs()// Trackable trackable) { GUILayout.BeginVertical(); // "Trackable Editor", gsTest); EditorGUILayout.Space(); Loading @@ -157,11 +142,12 @@ namespace ETSI.ARF.WorldStorage.UI GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel); EditorGUILayout.Space(); customName = EditorGUILayout.TextField("Name of Trackable:", customName); #if isDEBUG GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly EditorGUILayout.Space(); #endif customName = EditorGUILayout.TextField("Name of Trackable:", customName); EditorGUILayout.Space(); // --------------------- Loading @@ -175,7 +161,7 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID) && UUID != "0" && UUID != System.Guid.Empty.ToString()) { Trackable obj = GenerateTrackable(); Trackable obj = GenerateObject(); TrackableRequest.UpdateTrackableAsync(worldStorageServer, obj, (response) => { UUID = response.result; Loading @@ -184,7 +170,7 @@ namespace ETSI.ARF.WorldStorage.UI if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; } Close(); }); Loading @@ -193,6 +179,8 @@ namespace ETSI.ARF.WorldStorage.UI GUI.backgroundColor = WorldStorageWindow.arfColors[3]; if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete", "Are you sure you want to delete this Trackable?", "Delete", "Cancel")) { Debug.Log("Delete Trackable"); TrackableRequest.DeleteTrackableAsync(worldStorageServer, Guid.Parse(UUID), (response) => Loading @@ -200,16 +188,18 @@ namespace ETSI.ARF.WorldStorage.UI UUID = System.Guid.Empty.ToString(); customName = "Warning: Object deleted !"; creatorUUID = System.Guid.Empty.ToString(); confidence = 0f; type = TrackableType.OTHER; unit = UnitSystem.CM; if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; } Close(); }); } } GUI.backgroundColor = ori; GUI.backgroundColor = WorldStorageWindow.arfColors[5]; Loading @@ -226,6 +216,7 @@ namespace ETSI.ARF.WorldStorage.UI // --------------------- type = (TrackableType)EditorGUILayout.EnumPopup("Trackable Type:", type); unit = (UnitSystem)EditorGUILayout.EnumPopup("Unit System:", unit); confidence = EditorGUILayout.DoubleField("Confidence:", confidence); EditorGUILayout.Space(); trackableSize = EditorGUILayout.Vector3Field("Trackable Size:", trackableSize); Loading @@ -246,17 +237,26 @@ namespace ETSI.ARF.WorldStorage.UI } } // --------------------- // Keyvalues // --------------------- EditorGUILayout.Space(); groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled); key1 = EditorGUILayout.TextField("Key 1", key1); value1 = EditorGUILayout.TextField("Value 1", value1); if (keyValuesFixed.Count > 0) { OutputKeyValue(0); OutputKeyValue(1); OutputKeyValue(2); } EditorGUILayout.EndToggleGroup(); // GUILayout.EndVertical(); } private void GetTrackableParams() public override void GetParams() { customName = "Requesting information..."; TrackableRequest.GetTrackableAsync(worldStorageServer, Guid.Parse(UUID), (response) => { Trackable obj = response.result; Loading @@ -264,6 +264,7 @@ namespace ETSI.ARF.WorldStorage.UI creatorUUID = obj.CreatorUUID.ToString(); type = obj.TrackableType; unit = obj.Unit; confidence = obj.Confidence; if (obj.TrackableSize.Count == 3) { trackableSize = new Vector3((float)obj.TrackableSize[0], (float)obj.TrackableSize[1], (float)obj.TrackableSize[2]); Loading @@ -282,32 +283,44 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_rot = Vector3.zero; } // Read a key value (demo) var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); key1 = first.Item1; value1 = first.Item2; // --------------------- // Keyvalues // --------------------- //var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); //keyValuesFixed.Clear(); // no for (int i = 0; i < keyValuesFixed.Count; i++) keyValuesFixed[i] = ("", ""); this.Repaint(); if (obj.KeyvalueTags.Count > 0) { int cnt = 0; foreach (var item in obj.KeyvalueTags) { if (item.Key == "unityAuthoringPosX" || item.Key == "unityAuthoringPosY") continue; // ignore internal params if (cnt < keyValuesFixed.Count) keyValuesFixed[cnt] = (item.Key, item.Value[0]); cnt++; } } repaint = true; }); } public void AddTrackable() public override void AddObject() { Debug.Log("POST Trackable"); UUID = System.Guid.Empty.ToString(); customName = "Default Trackable"; Trackable obj = GenerateTrackable(); Trackable obj = GenerateObject(); TrackableRequest.CreateTrackableAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; }); } public Trackable GenerateTrackable() public override Trackable GenerateObject() { EncodingInformationStructure trackableEncodingInformation = new EncodingInformationStructure() { Loading @@ -327,9 +340,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS = Matrix4x4.TRS(localCRS_pos, Quaternion.Euler(localCRS_rot), Vector3.one); Transform3D _localCRS = WorldStorageUnityHelper.ConvertUnityToETSIARFTransform3D(localCRS); // Create a key value (one from demo) // Remember the position of the Unity graph node var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); // --------------------- // Keyvalues // --------------------- keyValueTags.Clear(); keyValueTags.Add(key1, new Collection<string> { value1 }); keyValueTags.Add("unityAuthoringPosX", posX); keyValueTags.Add("unityAuthoringPosY", posY); if (keyValuesFixed.Count > 0) foreach (var item in keyValuesFixed) { if (!string.IsNullOrEmpty(item.Item1)) keyValueTags.Add(item.Item1, new Collection<string> { item.Item2 }); } System.Guid _uuid = System.Guid.Parse(UUID); System.Guid _creator = System.Guid.Parse(worldStorageUser.UUID); Loading @@ -342,17 +369,10 @@ namespace ETSI.ARF.WorldStorage.UI TrackablePayload = trackablePayload, LocalCRS = _localCRS, Unit = unit, Confidence = confidence, TrackableSize = _trackableSize, KeyvalueTags = keyValueTags }; var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); t.KeyvalueTags["unityAuthoringPosX"] = posX; var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); t.KeyvalueTags["unityAuthoringPosY"] = posY; return t; } } Loading Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/WorldAnchorWindow.cs +76 −65 Original line number Diff line number Diff line Loading @@ -34,17 +34,10 @@ using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public class WorldAnchorWindow : EditorWindow public class WorldAnchorWindow : BaseWindow<WorldAnchor> { static public WorldAnchorWindow winSingleton; [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> anchors = new List<string>(); bool groupEnabled; // World Anchors params string UUID = System.Guid.Empty.ToString(); string customName = "NotDefined"; Loading @@ -54,20 +47,16 @@ namespace ETSI.ARF.WorldStorage.UI Vector3 localCRS_pos; Vector3 localCRS_rot; [SerializeField] KeyvalueTagList keyValueTags = new KeyvalueTagList(); string key1 = ""; string value1 = ""; // UI stuffs private Vector2 scrollPos; private Color ori; private GUIStyle gsTest; //graph params to generate the node public bool useCoord; public float nodePosX = 0; public float nodePosY = 0; public WorldAnchorWindow() { // init somne stuffs } public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user, string UUID = "") { winSingleton = EditorWindow.GetWindow(typeof(WorldAnchorWindow), false, "ETSI ARF - World Anchor") as WorldAnchorWindow; Loading @@ -76,12 +65,12 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID)) { winSingleton.UUID = UUID; winSingleton.GetWorldAnchorParams(); winSingleton.GetParams(); } else { // Create new one winSingleton.AddAnchor(); winSingleton.AddObject(); } } Loading @@ -106,11 +95,6 @@ namespace ETSI.ARF.WorldStorage.UI return visual; } public WorldAnchorWindow() { // init somne stuffs } void OnGUI() { ori = GUI.backgroundColor; // remember ori color Loading @@ -124,7 +108,7 @@ namespace ETSI.ARF.WorldStorage.UI scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawAnchorStuffs(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); Loading @@ -134,7 +118,7 @@ namespace ETSI.ARF.WorldStorage.UI } } void DrawAnchorStuffs() public override void DrawUIStuffs() { GUILayout.BeginVertical(); // "World Anchor Editor", gsTest); EditorGUILayout.Space(); Loading @@ -155,11 +139,12 @@ namespace ETSI.ARF.WorldStorage.UI GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel); EditorGUILayout.Space(); customName = EditorGUILayout.TextField("Name of Anchor:", customName); #if isDEBUG GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly EditorGUILayout.Space(); #endif customName = EditorGUILayout.TextField("Name of Anchor:", customName); EditorGUILayout.Space(); // --------------------- Loading @@ -173,23 +158,25 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID) && UUID != "0" && UUID != System.Guid.Empty.ToString()) { WorldAnchor obj = GenerateWorldAnchor(); WorldAnchor obj = GenerateObject(); WorldAnchorRequest.UpdateWorldAnchorAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); } Close(); }); } Close(); } GUI.backgroundColor = WorldStorageWindow.arfColors[3]; if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete", "Are you sure you want to delete this World Anchor?", "Delete", "Cancel")) { Debug.Log("Delete World Anchor"); WorldAnchorRequest.DeleteWorldAnchorAsync(worldStorageServer, Guid.Parse(UUID), (response) => Loading @@ -201,11 +188,11 @@ namespace ETSI.ARF.WorldStorage.UI if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); } Close(); }); } } GUI.backgroundColor = ori; GUI.backgroundColor = WorldStorageWindow.arfColors[5]; Loading @@ -230,16 +217,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_pos = EditorGUILayout.Vector3Field(" Position:", localCRS_pos); localCRS_rot = EditorGUILayout.Vector3Field(" Rotation:", localCRS_rot); // --------------------- // Keyvalues // --------------------- EditorGUILayout.Space(); groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled); key1 = EditorGUILayout.TextField("Key 1", key1); value1 = EditorGUILayout.TextField("Value 1", value1); if (keyValuesFixed.Count > 0) { OutputKeyValue(0); OutputKeyValue(1); OutputKeyValue(2); } EditorGUILayout.EndToggleGroup(); // GUILayout.EndVertical(); } private void GetWorldAnchorParams() public override void GetParams() { WorldAnchorRequest.GetWorldAnchorAsync(worldStorageServer, Guid.Parse(UUID), (response) => { Loading @@ -265,32 +259,43 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_rot = Vector3.zero; } // Read a key value (demo) var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); key1 = first.Item1; value1 = first.Item2; // --------------------- // Keyvalues // --------------------- //var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); //keyValuesFixed.Clear(); // no for (int i = 0; i < keyValuesFixed.Count; i++) keyValuesFixed[i] = ("", ""); this.Repaint(); if (obj.KeyvalueTags.Count > 0) { int cnt = 0; foreach (var item in obj.KeyvalueTags) { if (item.Key == "unityAuthoringPosX" || item.Key == "unityAuthoringPosY") continue; // ignore internal params if (cnt < keyValuesFixed.Count) keyValuesFixed[cnt] = (item.Key, item.Value[0]); cnt++; } } repaint = true; }); } public void AddAnchor() public override void AddObject() { Debug.Log("POST World Anchor"); UUID = System.Guid.Empty.ToString(); customName = "Default Anchor"; WorldAnchor obj = GenerateWorldAnchor(); WorldAnchor obj = GenerateObject(); WorldAnchorRequest.CreateWorldAnchorAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); }); } public WorldAnchor GenerateWorldAnchor() public override WorldAnchor GenerateObject() { Size _worldAnchorSize = new Size(); _worldAnchorSize.Add(worldAnchorSize.x); Loading @@ -302,9 +307,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS = Matrix4x4.TRS(localCRS_pos, Quaternion.Euler(localCRS_rot), Vector3.one); Transform3D _localCRS = WorldStorageUnityHelper.ConvertUnityToETSIARFTransform3D(localCRS); // Create a key value (one from demo) // Remember the position of the Unity graph node var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); // --------------------- // Keyvalues // --------------------- keyValueTags.Clear(); keyValueTags.Add(key1, new Collection<string> { value1 }); keyValueTags.Add("unityAuthoringPosX", posX); keyValueTags.Add("unityAuthoringPosY", posY); if (keyValuesFixed.Count > 0) foreach (var item in keyValuesFixed) { if (!string.IsNullOrEmpty(item.Item1)) keyValueTags.Add(item.Item1, new Collection<string> { item.Item2 }); } Guid _uuid = Guid.Parse(UUID); Guid _creator = Guid.Parse(worldStorageUser.UUID); Loading @@ -317,14 +336,6 @@ namespace ETSI.ARF.WorldStorage.UI WorldAnchorSize = _worldAnchorSize, KeyvalueTags = keyValueTags }; var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); t.KeyvalueTags["unityAuthoringPosX"] = posX; var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); t.KeyvalueTags["unityAuthoringPosY"] = posY; return t; } } Loading Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/WorldLinkWindow.cs +73 −49 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/BaseWindow.cs 0 → 100644 +117 −0 Original line number Diff line number Diff line // // ARF - Augmented Reality Framework (ETSI ISG ARF) // // Copyright 2024 ETSI // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // // Last change: June 2024 // #define isDEBUG using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using UnityEngine; using UnityEditor; using TMPro; using ETSI.ARF.WorldStorage.REST; using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public abstract class BaseWindow<T> : EditorWindow { [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> trackables = new List<string>(); // // Keyvalues // [SerializeField] protected KeyvalueTagList keyValueTags = new KeyvalueTagList(); protected List<(string, string)> keyValuesFixed = new List<(string, string)>(3) { ("", ""),("", ""),("", "") }; protected void OutputKeyValue(int n) { string i1 = keyValuesFixed[n].Item1; string i2 = keyValuesFixed[n].Item2; i1 = EditorGUILayout.TextField("Key " + n, i1); i2 = EditorGUILayout.TextField("Value " + n, i2); keyValuesFixed[n] = (i1, i2); } // // UI stuffs // protected bool groupEnabled; protected bool repaint = false; protected Vector2 scrollPos; protected Color ori; protected GUIStyle gsTest; public void Update() { if (repaint) { Repaint(); repaint = false; } } void OnGUI() { ori = GUI.backgroundColor; // remember ori color gsTest = new GUIStyle("window"); //gsTest.normal.textColor = WorldStorageWindow.arfColors[0]; gsTest.fontStyle = FontStyle.Bold; gsTest.alignment = TextAnchor.UpperLeft; gsTest.fontSize = 16; scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); if (GUILayout.Button("Close Window")) { Close(); } } public abstract void DrawUIStuffs(); public virtual void GetParams() { } public virtual void AddObject() { } public virtual T GenerateObject() { return default(T); } } } No newline at end of file
Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/BaseWindow.cs.meta 0 → 100644 +14 −0 Original line number Diff line number Diff line fileFormatVersion: 2 guid: b879c85f4eccbee40a78e1a01aaf77ca MonoImporter: externalObjects: {} serializedVersion: 2 defaultReferences: - m_ViewDataDictionary: {instanceID: 0} - worldStorageServer: {fileID: 11400000, guid: 4f997253243de534dad12937f1284975, type: 2} - worldStorageUser: {instanceID: 0} executionOrder: 0 icon: {instanceID: 0} userData: assetBundleName: assetBundleVariant:
Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/TrackableWindow.cs +84 −64 Original line number Diff line number Diff line Loading @@ -34,21 +34,15 @@ using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public class TrackableWindow : EditorWindow public class TrackableWindow : BaseWindow<Trackable> { static public TrackableWindow winSingleton; [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> trackables = new List<string>(); bool groupEnabled; // Trackable params string UUID = System.Guid.Empty.ToString(); string customName = "NotDefined"; string creatorUUID = System.Guid.Empty.ToString(); double confidence = 0f; TrackableType type = TrackableType.OTHER; UnitSystem unit = UnitSystem.CM; Vector3 trackableSize; Loading @@ -56,20 +50,16 @@ namespace ETSI.ARF.WorldStorage.UI Vector3 localCRS_rot; byte[] trackablePayload = new byte[1] { 0 }; [SerializeField] KeyvalueTagList keyValueTags = new KeyvalueTagList(); string key1 = ""; string value1 = ""; // UI stuffs private Vector2 scrollPos; private Color ori; private GUIStyle gsTest; //graph params to generate the node public bool useCoord; public float nodePosX = 0; public float nodePosY = 0; public TrackableWindow() { // init somne stuffs } public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user, string UUID = "") { winSingleton = EditorWindow.GetWindow(typeof(TrackableWindow), false, "ETSI ARF - Trackable") as TrackableWindow; Loading @@ -78,12 +68,12 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID)) { winSingleton.UUID = UUID; winSingleton.GetTrackableParams(); winSingleton.GetParams(); } else { // Create new one winSingleton.AddTrackable(); winSingleton.AddObject(); } } Loading @@ -108,11 +98,6 @@ namespace ETSI.ARF.WorldStorage.UI return visual; } public TrackableWindow() { // init somne stuffs } void OnGUI() { ori = GUI.backgroundColor; // remember ori color Loading @@ -126,7 +111,7 @@ namespace ETSI.ARF.WorldStorage.UI scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawTrackableStuffs(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); Loading @@ -136,7 +121,7 @@ namespace ETSI.ARF.WorldStorage.UI } } void DrawTrackableStuffs()// Trackable trackable) public override void DrawUIStuffs()// Trackable trackable) { GUILayout.BeginVertical(); // "Trackable Editor", gsTest); EditorGUILayout.Space(); Loading @@ -157,11 +142,12 @@ namespace ETSI.ARF.WorldStorage.UI GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel); EditorGUILayout.Space(); customName = EditorGUILayout.TextField("Name of Trackable:", customName); #if isDEBUG GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly EditorGUILayout.Space(); #endif customName = EditorGUILayout.TextField("Name of Trackable:", customName); EditorGUILayout.Space(); // --------------------- Loading @@ -175,7 +161,7 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID) && UUID != "0" && UUID != System.Guid.Empty.ToString()) { Trackable obj = GenerateTrackable(); Trackable obj = GenerateObject(); TrackableRequest.UpdateTrackableAsync(worldStorageServer, obj, (response) => { UUID = response.result; Loading @@ -184,7 +170,7 @@ namespace ETSI.ARF.WorldStorage.UI if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; } Close(); }); Loading @@ -193,6 +179,8 @@ namespace ETSI.ARF.WorldStorage.UI GUI.backgroundColor = WorldStorageWindow.arfColors[3]; if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete", "Are you sure you want to delete this Trackable?", "Delete", "Cancel")) { Debug.Log("Delete Trackable"); TrackableRequest.DeleteTrackableAsync(worldStorageServer, Guid.Parse(UUID), (response) => Loading @@ -200,16 +188,18 @@ namespace ETSI.ARF.WorldStorage.UI UUID = System.Guid.Empty.ToString(); customName = "Warning: Object deleted !"; creatorUUID = System.Guid.Empty.ToString(); confidence = 0f; type = TrackableType.OTHER; unit = UnitSystem.CM; if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; } Close(); }); } } GUI.backgroundColor = ori; GUI.backgroundColor = WorldStorageWindow.arfColors[5]; Loading @@ -226,6 +216,7 @@ namespace ETSI.ARF.WorldStorage.UI // --------------------- type = (TrackableType)EditorGUILayout.EnumPopup("Trackable Type:", type); unit = (UnitSystem)EditorGUILayout.EnumPopup("Unit System:", unit); confidence = EditorGUILayout.DoubleField("Confidence:", confidence); EditorGUILayout.Space(); trackableSize = EditorGUILayout.Vector3Field("Trackable Size:", trackableSize); Loading @@ -246,17 +237,26 @@ namespace ETSI.ARF.WorldStorage.UI } } // --------------------- // Keyvalues // --------------------- EditorGUILayout.Space(); groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled); key1 = EditorGUILayout.TextField("Key 1", key1); value1 = EditorGUILayout.TextField("Value 1", value1); if (keyValuesFixed.Count > 0) { OutputKeyValue(0); OutputKeyValue(1); OutputKeyValue(2); } EditorGUILayout.EndToggleGroup(); // GUILayout.EndVertical(); } private void GetTrackableParams() public override void GetParams() { customName = "Requesting information..."; TrackableRequest.GetTrackableAsync(worldStorageServer, Guid.Parse(UUID), (response) => { Trackable obj = response.result; Loading @@ -264,6 +264,7 @@ namespace ETSI.ARF.WorldStorage.UI creatorUUID = obj.CreatorUUID.ToString(); type = obj.TrackableType; unit = obj.Unit; confidence = obj.Confidence; if (obj.TrackableSize.Count == 3) { trackableSize = new Vector3((float)obj.TrackableSize[0], (float)obj.TrackableSize[1], (float)obj.TrackableSize[2]); Loading @@ -282,32 +283,44 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_rot = Vector3.zero; } // Read a key value (demo) var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); key1 = first.Item1; value1 = first.Item2; // --------------------- // Keyvalues // --------------------- //var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); //keyValuesFixed.Clear(); // no for (int i = 0; i < keyValuesFixed.Count; i++) keyValuesFixed[i] = ("", ""); this.Repaint(); if (obj.KeyvalueTags.Count > 0) { int cnt = 0; foreach (var item in obj.KeyvalueTags) { if (item.Key == "unityAuthoringPosX" || item.Key == "unityAuthoringPosY") continue; // ignore internal params if (cnt < keyValuesFixed.Count) keyValuesFixed[cnt] = (item.Key, item.Value[0]); cnt++; } } repaint = true; }); } public void AddTrackable() public override void AddObject() { Debug.Log("POST Trackable"); UUID = System.Guid.Empty.ToString(); customName = "Default Trackable"; Trackable obj = GenerateTrackable(); Trackable obj = GenerateObject(); TrackableRequest.CreateTrackableAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); WorldStorageWindow.WorldStorageWindowSingleton.repaint = true; }); } public Trackable GenerateTrackable() public override Trackable GenerateObject() { EncodingInformationStructure trackableEncodingInformation = new EncodingInformationStructure() { Loading @@ -327,9 +340,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS = Matrix4x4.TRS(localCRS_pos, Quaternion.Euler(localCRS_rot), Vector3.one); Transform3D _localCRS = WorldStorageUnityHelper.ConvertUnityToETSIARFTransform3D(localCRS); // Create a key value (one from demo) // Remember the position of the Unity graph node var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); // --------------------- // Keyvalues // --------------------- keyValueTags.Clear(); keyValueTags.Add(key1, new Collection<string> { value1 }); keyValueTags.Add("unityAuthoringPosX", posX); keyValueTags.Add("unityAuthoringPosY", posY); if (keyValuesFixed.Count > 0) foreach (var item in keyValuesFixed) { if (!string.IsNullOrEmpty(item.Item1)) keyValueTags.Add(item.Item1, new Collection<string> { item.Item2 }); } System.Guid _uuid = System.Guid.Parse(UUID); System.Guid _creator = System.Guid.Parse(worldStorageUser.UUID); Loading @@ -342,17 +369,10 @@ namespace ETSI.ARF.WorldStorage.UI TrackablePayload = trackablePayload, LocalCRS = _localCRS, Unit = unit, Confidence = confidence, TrackableSize = _trackableSize, KeyvalueTags = keyValueTags }; var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); t.KeyvalueTags["unityAuthoringPosX"] = posX; var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); t.KeyvalueTags["unityAuthoringPosY"] = posY; return t; } } Loading
Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/WorldAnchorWindow.cs +76 −65 Original line number Diff line number Diff line Loading @@ -34,17 +34,10 @@ using ETSI.ARF.OpenAPI.WorldStorage; namespace ETSI.ARF.WorldStorage.UI { public class WorldAnchorWindow : EditorWindow public class WorldAnchorWindow : BaseWindow<WorldAnchor> { static public WorldAnchorWindow winSingleton; [HideInInspector] public WorldStorageServer worldStorageServer; [HideInInspector] public WorldStorageUser worldStorageUser; [SerializeField] public List<string> anchors = new List<string>(); bool groupEnabled; // World Anchors params string UUID = System.Guid.Empty.ToString(); string customName = "NotDefined"; Loading @@ -54,20 +47,16 @@ namespace ETSI.ARF.WorldStorage.UI Vector3 localCRS_pos; Vector3 localCRS_rot; [SerializeField] KeyvalueTagList keyValueTags = new KeyvalueTagList(); string key1 = ""; string value1 = ""; // UI stuffs private Vector2 scrollPos; private Color ori; private GUIStyle gsTest; //graph params to generate the node public bool useCoord; public float nodePosX = 0; public float nodePosY = 0; public WorldAnchorWindow() { // init somne stuffs } public static void ShowWindow(WorldStorageServer ws, WorldStorageUser user, string UUID = "") { winSingleton = EditorWindow.GetWindow(typeof(WorldAnchorWindow), false, "ETSI ARF - World Anchor") as WorldAnchorWindow; Loading @@ -76,12 +65,12 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID)) { winSingleton.UUID = UUID; winSingleton.GetWorldAnchorParams(); winSingleton.GetParams(); } else { // Create new one winSingleton.AddAnchor(); winSingleton.AddObject(); } } Loading @@ -106,11 +95,6 @@ namespace ETSI.ARF.WorldStorage.UI return visual; } public WorldAnchorWindow() { // init somne stuffs } void OnGUI() { ori = GUI.backgroundColor; // remember ori color Loading @@ -124,7 +108,7 @@ namespace ETSI.ARF.WorldStorage.UI scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.ExpandWidth(true)); WorldStorageWindow.DrawCopyright(); DrawAnchorStuffs(); DrawUIStuffs(); EditorGUILayout.EndScrollView(); Loading @@ -134,7 +118,7 @@ namespace ETSI.ARF.WorldStorage.UI } } void DrawAnchorStuffs() public override void DrawUIStuffs() { GUILayout.BeginVertical(); // "World Anchor Editor", gsTest); EditorGUILayout.Space(); Loading @@ -155,11 +139,12 @@ namespace ETSI.ARF.WorldStorage.UI GUILayout.Label("User: " + worldStorageUser.userName, EditorStyles.whiteLargeLabel); EditorGUILayout.Space(); customName = EditorGUILayout.TextField("Name of Anchor:", customName); #if isDEBUG GUILayout.Label("UUID: " + UUID, EditorStyles.miniLabel); // readonly GUILayout.Label("Creator UID: " + creatorUUID, EditorStyles.miniLabel); // readonly EditorGUILayout.Space(); #endif customName = EditorGUILayout.TextField("Name of Anchor:", customName); EditorGUILayout.Space(); // --------------------- Loading @@ -173,23 +158,25 @@ namespace ETSI.ARF.WorldStorage.UI if (!string.IsNullOrEmpty(UUID) && UUID != "0" && UUID != System.Guid.Empty.ToString()) { WorldAnchor obj = GenerateWorldAnchor(); WorldAnchor obj = GenerateObject(); WorldAnchorRequest.UpdateWorldAnchorAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); } Close(); }); } Close(); } GUI.backgroundColor = WorldStorageWindow.arfColors[3]; if (GUILayout.Button("Delete")) { if (EditorUtility.DisplayDialog("Delete", "Are you sure you want to delete this World Anchor?", "Delete", "Cancel")) { Debug.Log("Delete World Anchor"); WorldAnchorRequest.DeleteWorldAnchorAsync(worldStorageServer, Guid.Parse(UUID), (response) => Loading @@ -201,11 +188,11 @@ namespace ETSI.ARF.WorldStorage.UI if (WorldStorageWindow.WorldStorageWindowSingleton != null) { WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); } Close(); }); } } GUI.backgroundColor = ori; GUI.backgroundColor = WorldStorageWindow.arfColors[5]; Loading @@ -230,16 +217,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_pos = EditorGUILayout.Vector3Field(" Position:", localCRS_pos); localCRS_rot = EditorGUILayout.Vector3Field(" Rotation:", localCRS_rot); // --------------------- // Keyvalues // --------------------- EditorGUILayout.Space(); groupEnabled = EditorGUILayout.BeginToggleGroup("Optional Parameters:", groupEnabled); key1 = EditorGUILayout.TextField("Key 1", key1); value1 = EditorGUILayout.TextField("Value 1", value1); if (keyValuesFixed.Count > 0) { OutputKeyValue(0); OutputKeyValue(1); OutputKeyValue(2); } EditorGUILayout.EndToggleGroup(); // GUILayout.EndVertical(); } private void GetWorldAnchorParams() public override void GetParams() { WorldAnchorRequest.GetWorldAnchorAsync(worldStorageServer, Guid.Parse(UUID), (response) => { Loading @@ -265,32 +259,43 @@ namespace ETSI.ARF.WorldStorage.UI localCRS_rot = Vector3.zero; } // Read a key value (demo) var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); key1 = first.Item1; value1 = first.Item2; // --------------------- // Keyvalues // --------------------- //var first = WorldStorageWindow.GetFirstKeyValueTags(obj.KeyvalueTags); //keyValuesFixed.Clear(); // no for (int i = 0; i < keyValuesFixed.Count; i++) keyValuesFixed[i] = ("", ""); this.Repaint(); if (obj.KeyvalueTags.Count > 0) { int cnt = 0; foreach (var item in obj.KeyvalueTags) { if (item.Key == "unityAuthoringPosX" || item.Key == "unityAuthoringPosY") continue; // ignore internal params if (cnt < keyValuesFixed.Count) keyValuesFixed[cnt] = (item.Key, item.Value[0]); cnt++; } } repaint = true; }); } public void AddAnchor() public override void AddObject() { Debug.Log("POST World Anchor"); UUID = System.Guid.Empty.ToString(); customName = "Default Anchor"; WorldAnchor obj = GenerateWorldAnchor(); WorldAnchor obj = GenerateObject(); WorldAnchorRequest.CreateWorldAnchorAsync(worldStorageServer, obj, (response) => { UUID = response.result; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); WorldStorageWindow.WorldStorageWindowSingleton.Repaint(); }); } public WorldAnchor GenerateWorldAnchor() public override WorldAnchor GenerateObject() { Size _worldAnchorSize = new Size(); _worldAnchorSize.Add(worldAnchorSize.x); Loading @@ -302,9 +307,23 @@ namespace ETSI.ARF.WorldStorage.UI localCRS = Matrix4x4.TRS(localCRS_pos, Quaternion.Euler(localCRS_rot), Vector3.one); Transform3D _localCRS = WorldStorageUnityHelper.ConvertUnityToETSIARFTransform3D(localCRS); // Create a key value (one from demo) // Remember the position of the Unity graph node var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); // --------------------- // Keyvalues // --------------------- keyValueTags.Clear(); keyValueTags.Add(key1, new Collection<string> { value1 }); keyValueTags.Add("unityAuthoringPosX", posX); keyValueTags.Add("unityAuthoringPosY", posY); if (keyValuesFixed.Count > 0) foreach (var item in keyValuesFixed) { if (!string.IsNullOrEmpty(item.Item1)) keyValueTags.Add(item.Item1, new Collection<string> { item.Item2 }); } Guid _uuid = Guid.Parse(UUID); Guid _creator = Guid.Parse(worldStorageUser.UUID); Loading @@ -317,14 +336,6 @@ namespace ETSI.ARF.WorldStorage.UI WorldAnchorSize = _worldAnchorSize, KeyvalueTags = keyValueTags }; var posX = new Collection<String>(); posX.Add(nodePosX.ToString()); t.KeyvalueTags["unityAuthoringPosX"] = posX; var posY = new Collection<String>(); posY.Add(nodePosY.ToString()); t.KeyvalueTags["unityAuthoringPosY"] = posY; return t; } } Loading
Assets/ETSI.ARF/ARF World Storage API/Editor/Windows/WorldLinkWindow.cs +73 −49 File changed.Preview size limit exceeded, changes collapsed. Show changes