Commit ccf5ef33 authored by Nathan Chambron's avatar Nathan Chambron
Browse files

everything is working, need ui fix

parent 373c7ab3
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows;
//
// ARF - Augmented Reality Framework (ETSI ISG ARF)
//
// Copyright 2022 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: July 2022
//

using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows;
using Org.OpenAPITools.Model;
using UnityEditor;
using UnityEditor.Experimental.GraphView;
using UnityEngine;
using UnityEngine.UIElements;
@@ -13,17 +32,17 @@ namespace Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Graph
        public string GUID;
        public ARFEdgeLink()
        {
            var doubleClickManipulator = new Clickable(clicked);
            var doubleClickManipulator = new Clickable(Clicked);
            doubleClickManipulator.activators.Clear();
            doubleClickManipulator.activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse, clickCount = 2 });
            this.AddManipulator(doubleClickManipulator);
            this.style.color = new Color(239, 239, 239);
            style.color = new Color(239, 239, 239);
        }

        public void clicked()
        public void Clicked()
        {
            Debug.Log(worldLink.ToJson());
            NodeEditorWindow.ShowWindow(this);
            GraphEditorWindow.ShowWindow(this);
        }
    }
}
 No newline at end of file
+62 −45
Original line number Diff line number Diff line
@@ -15,14 +15,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2022
// Last change: July 2022
//

#define USING_OPENAPI_GENERATOR

using System.Collections;
using System.Collections.Generic;
#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
@@ -54,7 +53,6 @@ namespace ETSI.ARF.WorldStorage.UI
            this.AddManipulator(new ContentDragger());
            this.AddManipulator(new SelectionDragger());
            this.AddManipulator(new RectangleSelector());

        }

        //method called when an element is deleted from the graphview
@@ -113,6 +111,8 @@ namespace ETSI.ARF.WorldStorage.UI
                    }
                }
            }

            GraphEditorWindow.ResetWindow();
        }

        public override void BuildContextualMenu(UnityEngine.UIElements.ContextualMenuPopulateEvent evt)
@@ -125,9 +125,9 @@ namespace ETSI.ARF.WorldStorage.UI
            {
                if (ServerAndLocalDifferent() && EditorUtility.DisplayDialog("Saving node positions", "The World Graph has been modified. \nWould you like to push the modifications to the server ?", "Yes", "No"))
                {
                    saveInServer();
                    SaveInServer();
                }
                reload();
                Reload();
                SaveInfo.instance.toReFrame = true;
            }, (DropdownMenuAction a) => DropdownMenuAction.Status.Normal);
            evt.menu.AppendAction("Create Trackable", delegate
@@ -135,31 +135,34 @@ namespace ETSI.ARF.WorldStorage.UI
                //generate the Trackables's attributes
                EncodingInformationStructure trackableEncodingInformation = new EncodingInformationStructure(EncodingInformationStructure.DataFormatEnum.OTHER, "0");

                List<float> localCRS = new List<float>();
                for (int i = 0; i < 16; i++)
                List<float> localCRS = new();
                for (int i = 0; i < 15; i++)
                {
                    localCRS.Add(0);
                }
                localCRS.Add(1);

                List<double> trackableSize = new List<double>();
                List<double> trackableSize = new();
                for (int i = 0; i < 3; i++)
                {
                    trackableSize.Add(0);
                }

                Trackable trackable = new Trackable(Guid.NewGuid(), "Defaulttrackable", Guid.Parse(worldStorageUser.UUID), Trackable.TrackableTypeEnum.OTHER, trackableEncodingInformation, new byte[64], localCRS, UnitSystem.CM, trackableSize, new Dictionary<string, List<string>>());
                createTrackableNode(trackable, actualGraphPosition.x, actualGraphPosition.y);
                
                selection.Clear();
                AddToSelection(CreateTrackableNode(trackable, actualGraphPosition.x, actualGraphPosition.y));

            }, (DropdownMenuAction a) => DropdownMenuAction.Status.Normal);
            evt.menu.AppendAction("Create World Anchor", delegate
            {
                //generate the worldAnchor attributes

                List<float> localCRS = new List<float>();
                for (int i = 0; i < 16; i++)
                for (int i = 0; i < 15; i++)
                {
                    localCRS.Add(0);
                }
                localCRS.Add(1);

                List<double> worldAnchorSize = new List<double>();
                for (int i = 0; i < 3; i++)
@@ -168,7 +171,7 @@ namespace ETSI.ARF.WorldStorage.UI
                }

                WorldAnchor anchor = new WorldAnchor(Guid.NewGuid(), "DefaultWorldAnchor", Guid.Parse(worldStorageUser.UUID), localCRS, UnitSystem.CM, worldAnchorSize, new Dictionary<string, List<string>>());
                createAnchorNode(anchor, actualGraphPosition.x, actualGraphPosition.y);
                CreateAnchorNode(anchor, actualGraphPosition.x, actualGraphPosition.y);

            }, (DropdownMenuAction a) => DropdownMenuAction.Status.Normal);
            evt.menu.AppendSeparator();
@@ -230,7 +233,7 @@ namespace ETSI.ARF.WorldStorage.UI
            return cPorts;
        }

        public void paintWorldStorage()
        public void PaintWorldStorage()
        {
            List<Trackable> trackables = TrackableRequest.GetAllTrackables(worldStorageServer);
            List<WorldAnchor> worldAnchors = WorldAnchorRequest.GetAllWorldAnchors(worldStorageServer);
@@ -259,7 +262,7 @@ namespace ETSI.ARF.WorldStorage.UI
            }
            foreach (WorldLink worldLink in worldLinks)
            {
                var portPair = getPortsFromWorldLink(worldLink);
                var portPair = GetPortsFromWorldLink(worldLink);
                ARFEdgeLink edge = portPair.Key.ConnectTo<ARFEdgeLink>(portPair.Value);
                edge.worldLink = worldLink;
                edge.GUID = worldLink.UUID.ToString();
@@ -269,16 +272,17 @@ namespace ETSI.ARF.WorldStorage.UI

        }

        internal void createTrackableNode(Trackable track, float posX, float posY)
        internal ARFNodeTrackable CreateTrackableNode(Trackable track, float posX, float posY)
        {
            var tracknode = new ARFNodeTrackable(track);
            Rect pos = new Rect(RoundToNearestHalf(posX), RoundToNearestHalf(posY), 160, 77);
            tracknode.SetPosition(pos);

            AddElement(tracknode);
            return tracknode;
        }

        internal void createAnchorNode(WorldAnchor wa, float posX, float posY)
        internal ARFNodeWorldAnchor CreateAnchorNode(WorldAnchor wa, float posX, float posY)
        {
            var waNode = new ARFNodeWorldAnchor(wa);

@@ -286,27 +290,31 @@ namespace ETSI.ARF.WorldStorage.UI
            waNode.SetPosition(pos);

            AddElement(waNode);
            return waNode;
        }

        internal void createLink(WorldLink worldLink)
        internal ARFEdgeLink CreateLink(WorldLink worldLink)
        {
            var portPair = getPortsFromWorldLink(worldLink);
            var portPair = GetPortsFromWorldLink(worldLink);
            ARFEdgeLink edge = portPair.Key.ConnectTo<ARFEdgeLink>(portPair.Value);
            edge.worldLink = worldLink;
            Debug.Log(worldLink.UUID.ToString());
            edge.GUID = worldLink.UUID.ToString();

            AddElement(edge);
            return edge;
        }

        public void reload()
        public void Reload()
        {
            GraphEditorWindow.ResetWindow();
            DeleteElements(graphElements);
            paintWorldStorage();
            SaveInfo.instance.InitNodePos(worldStorageServer, worldStorageUser);
            PaintWorldStorage();
            FrameAllElements();
        }

        public Dictionary<string, Rect> SavePositions()
        public Dictionary<string, Rect> GetNodePositions()
        {
            Dictionary<string, Rect> ret = new Dictionary<string, Rect>();
            foreach (ARFNode elem in nodes)
@@ -316,7 +324,7 @@ namespace ETSI.ARF.WorldStorage.UI
            return ret;
        }

        private KeyValuePair<Port, Port> getPortsFromWorldLink(WorldLink worldLink)
        private KeyValuePair<Port, Port> GetPortsFromWorldLink(WorldLink worldLink)
        {
            var ret = new KeyValuePair<Port, Port>();

@@ -443,8 +451,31 @@ namespace ETSI.ARF.WorldStorage.UI
        }

        //Save all modified/deleted/added elements to the server
        public void saveInServer()
        public void SaveInServer()
        {
            //DELETE ELEMENTS FROM THE SERVER
            foreach (KeyValuePair<String, Type> elemToRemove in SaveInfo.instance.elemsToRemove)
            {
                string typeName = elemToRemove.Value.Name;
                switch (typeName)
                {
                    case nameof(Trackable):
                        TrackableRequest.DeleteTrackable(worldStorageServer, elemToRemove.Key);
                        break;
                    case nameof(WorldAnchor):
                        Debug.Log("delete worldanchor");
                        WorldAnchorRequest.DeleteWorldAnchor(worldStorageServer, elemToRemove.Key);
                        break;
                    case nameof(WorldLink):
                        WorldLinkRequest.DeleteWorldLink(worldStorageServer, elemToRemove.Key);
                        break;
                    default:
                        Debug.Log("oops");
                        break;
                }
            }

            //UPDATE AND ADD ELEMENTS
            foreach (ARFNode node in nodes)
            {
                if (!SaveInfo.instance.nodePositions.ContainsKey(node.GUID))
@@ -473,6 +504,7 @@ namespace ETSI.ARF.WorldStorage.UI
                        }
                        aRFNodeTrackable.trackable.UUID = Guid.Parse(uuid);
                        aRFNodeTrackable.GUID = uuid;
                        aRFNodeTrackable.title = trackable.Name;
                    }
                    //POST WORLDANCHOR
                    if (node is ARFNodeWorldAnchor aRFNodeWorldAnchor)
@@ -499,6 +531,7 @@ namespace ETSI.ARF.WorldStorage.UI
                        }
                        aRFNodeWorldAnchor.worldAnchor.UUID = Guid.Parse(uuid);
                        aRFNodeWorldAnchor.GUID = uuid;
                        aRFNodeWorldAnchor.title = worldAnchor.Name;
                    }
                }
                else
@@ -519,6 +552,7 @@ namespace ETSI.ARF.WorldStorage.UI
                            trackable.KeyvalueTags["unityAuthoringPosX"] = posX;
                            trackable.KeyvalueTags["unityAuthoringPosY"] = posY;
                            TrackableRequest.UpdateTrackable(worldStorageServer, trackable);
                            aRFNodeTrackable.title = trackable.Name;
                        }
                        if (node is ARFNodeWorldAnchor aRFNodeWorldAnchor)
                        {
@@ -530,6 +564,7 @@ namespace ETSI.ARF.WorldStorage.UI
                            worldAnchor.KeyvalueTags["unityAuthoringPosX"] = posX;
                            worldAnchor.KeyvalueTags["unityAuthoringPosY"] = posY;
                            WorldAnchorRequest.UpdateWorldAnchor(worldStorageServer, worldAnchor);
                            aRFNodeWorldAnchor.title = worldAnchor.Name;
                        }
                    }
                }
@@ -554,27 +589,9 @@ namespace ETSI.ARF.WorldStorage.UI
                    }
                }
            }
            //DELETE ELEMENTS FROM THE SERVER
            foreach (KeyValuePair<String, Type> elemToRemove in SaveInfo.instance.elemsToRemove)
            {
                string typeName = elemToRemove.Value.Name;
                switch (typeName)
                {
                    case nameof(Trackable):
                        TrackableRequest.DeleteTrackable(worldStorageServer, elemToRemove.Key);
                        break;
                    case nameof(WorldAnchor):
                        WorldAnchorRequest.DeleteWorldAnchor(worldStorageServer, elemToRemove.Key);
                        break;
                    case nameof(WorldLink):
                        WorldLinkRequest.DeleteWorldLink(worldStorageServer, elemToRemove.Key);
                        break;
                    default:
                        Debug.Log("oops");
                        break;
                }
            }
            SaveInfo.instance.initNodePos(worldStorageServer, worldStorageUser);
            SaveInfo.instance.InitNodePos(worldStorageServer, worldStorageUser);

            GraphEditorWindow.ResetWindow();
        }
    }
}
 No newline at end of file
+2 −6
Original line number Diff line number Diff line
@@ -15,18 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2022
// Last change: July 2022
//

#define USING_OPENAPI_GENERATOR // alt. is Swagger

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ETSI.ARF.WorldStorage.REST;

#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
+6 −11
Original line number Diff line number Diff line
@@ -15,18 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2022
// Last change: July 2022
//

#define USING_OPENAPI_GENERATOR // alt. is Swagger

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ETSI.ARF.WorldStorage.REST;

#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
@@ -35,7 +31,6 @@ using IO.Swagger.Model;
using UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Graph;

namespace ETSI.ARF.WorldStorage.UI
{
@@ -73,16 +68,16 @@ namespace ETSI.ARF.WorldStorage.UI
            RefreshPorts();

            /*MANIPULATOR*/
            var doubleClickManipulator = new Clickable(clicked);
            var doubleClickManipulator = new Clickable(Clicked);
            doubleClickManipulator.activators.Clear();
            doubleClickManipulator.activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse, clickCount = 2 });
            this.AddManipulator(doubleClickManipulator);
        }

        public void clicked()
        public void Clicked()
        {
            NodeEditorWindow.ShowWindow(this);
            Debug.Log(trackable.ToString());
            Debug.Log(trackable.ToJson());
            GraphEditorWindow.ShowWindow(this);
        }
        public override ObjectType GetElemType()
        {
+5 −11
Original line number Diff line number Diff line
@@ -15,18 +15,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Last change: June 2022
// Last change: July 2022
//

#define USING_OPENAPI_GENERATOR // alt. is Swagger

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using ETSI.ARF.WorldStorage.REST;

#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Api;
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
@@ -35,7 +31,6 @@ using IO.Swagger.Model;
using UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Graph;

namespace ETSI.ARF.WorldStorage.UI
{
@@ -73,16 +68,15 @@ namespace ETSI.ARF.WorldStorage.UI
            RefreshPorts();

            /*MANIPULATOR*/
            var doubleClickManipulator = new Clickable(clicked);
            var doubleClickManipulator = new Clickable(Clicked);
            doubleClickManipulator.activators.Clear();
            doubleClickManipulator.activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse, clickCount = 2 });
            this.AddManipulator(doubleClickManipulator);
        }

        public void clicked()
        public void Clicked()
        {
            Debug.Log(worldAnchor.ToString());
            NodeEditorWindow.ShowWindow(this);
            GraphEditorWindow.ShowWindow(this);
        }
        public override ObjectType GetElemType()
        {
Loading