Add GraphView module & the World Storage inspector window into the main branch

All final changes into the main branch

Merge request reports

Loading
+83
Changes for Assets/ETSI.ARF/ARF World Storage API/Editor/Graph/ARFEdgeLink.cs: 83 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
//
// 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;

namespace Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Graph
{
    public class ARFEdgeLink : Edge
    {
        public WorldLink worldLink;
        public string GUID;

        public Image savedIcon;

        public ARFEdgeLink()
        {
            var doubleClickManipulator = new Clickable(Clicked);
            doubleClickManipulator.activators.Clear();
            doubleClickManipulator.activators.Add(new ManipulatorActivationFilter { button = MouseButton.LeftMouse, clickCount = 2 });
            this.AddManipulator(doubleClickManipulator);
        }
        public void Clicked()
        {
            Debug.Log(worldLink.ToJson());
            GraphEditorWindow.ShowWindow(this);
        }
        public void MarkUnsaved()
        {
            if (savedIcon == null)
            {
                //the icon to add if the node does not correspond to an element in the server
                Texture2D warningImage = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/ETSI.ARF/ARF World Storage API/Images/cloud.png", typeof(Texture2D));
                savedIcon = new Image
                {
                    image = warningImage
                };
                savedIcon.style.width = 18;
                savedIcon.style.height = 18;
                savedIcon.style.minWidth = 18;
                savedIcon.style.minHeight = 18;
                savedIcon.style.flexGrow = 1;
                savedIcon.style.alignSelf = Align.Center;

            }
            if (!edgeControl.Contains(savedIcon))
            {
                edgeControl.Add(savedIcon);
            }
            tooltip = "This element is not synchronized with the World Storage";
        }

        public void MarkSaved()
        {
            if (edgeControl.Contains(savedIcon))
            {
                edgeControl.Remove(savedIcon);
                tooltip = "";
            }
        }
    }
}
 No newline at end of file
+1 −1

File changed and moved.

Generated files are collapsed by default. To change this behavior, edit the .gitattributes file. Learn more.

+582 −40

File changed.

Preview size limit exceeded, changes collapsed.

+109 −6
Changes for Assets/ETSI.ARF/ARF World Storage API/Editor/Graph/ARFNode.cs: 109 added lines, 6 removed lines.
Original line number Original line Diff line number Diff line
@@ -15,27 +15,130 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
//
//
// Last change: June 2022
// Last change: July 2022
//
//


using System.Collections;
#define USING_OPENAPI_GENERATOR // alt. is Swagger
using System.Collections.Generic;

using UnityEngine;
using UnityEditor;

#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
using IO.Swagger.Model;
#endif
using UnityEngine.UIElements;
using UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
using UnityEditor.Experimental.GraphView;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Graph;
using System;
using UnityEngine;


namespace ETSI.ARF.WorldStorage.UI
namespace ETSI.ARF.WorldStorage.UI
{
{
    public class ARFNode : Node
    public abstract class ARFNode : Node
    {
    {
        public string GUID;
        public string GUID;
        public string text;
        public bool entryPoint = false;
        public bool entryPoint = false;
        public ARFPort portOut;
        public ARFPort portIn;
        public GUID id;

        public Image savedIcon;


        public ARFNode()
        public ARFNode()
        {
        {
        }
        public override Port InstantiatePort(Orientation orientation, Direction direction, Port.Capacity capacity, Type type)
        {
            switch (direction)
            {
                case Direction.Input:
                    portIn = ARFPort.CreateARF<ARFEdgeLink>(orientation, direction, capacity, type);
                    return portIn;
                case Direction.Output:
                    portOut = ARFPort.CreateARF<ARFEdgeLink>(orientation, direction, capacity, type);
                    return portOut;
                default:
                    return null;
            }
        }


        public void DisconnectAllPorts(ARFGraphView graphView)
        {
            DisconnectInputPorts(graphView);
            DisconnectOutputPorts(graphView);
        }

        private void DisconnectInputPorts(ARFGraphView graphView)
        {
            DisconnectPorts(inputContainer, graphView);
        }

        private void DisconnectOutputPorts(ARFGraphView graphView)
        {
            DisconnectPorts(outputContainer, graphView);
        }

        private void DisconnectPorts(VisualElement container, ARFGraphView graphView)
        {
            foreach (Port port in container.Children())
            {
                if (!port.connected)
                {
                    continue;
                }


                graphView.DeleteElements(port.connections);
            }
            }
        }
        }

        public Port GeneratePort(ARFNode node, Direction portDirection, Port.Capacity capacity = Port.Capacity.Multi)
        {
            return node.InstantiatePort(Orientation.Horizontal, portDirection, capacity, typeof(int)); // dummy
        }

        //override the BuildContextualMenu method to prevent the "disconnect" option from appearing in the contextual menu
        public override void BuildContextualMenu(ContextualMenuPopulateEvent evt)
        {
        }

        public abstract ObjectType GetElemType();
        public void MarkUnsaved()
        {
            if(savedIcon == null)
            {
                //the icon to add if the node does not correspond to an element in the server
                Texture2D warningImage = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/ETSI.ARF/ARF World Storage API/Images/cloud.png", typeof(Texture2D));
                savedIcon = new Image
                {
                    image = warningImage,
                    scaleMode = ScaleMode.ScaleToFit
                };
                savedIcon.style.width = 25;
                savedIcon.style.height = 25;
                savedIcon.style.minWidth = 25;
                savedIcon.style.minHeight = 25;
                savedIcon.style.left = 8;
                savedIcon.style.paddingRight = 8;
                savedIcon.style.alignSelf = Align.Center;

            }
            if (!titleContainer.Contains(savedIcon))
            {
                titleContainer.Insert(0,savedIcon);
            }
            tooltip = "This element is not synchronized with the World Storage";
        }

        public void MarkSaved()
        {
            if (titleContainer.Contains(savedIcon))
            {
                titleContainer.Remove(savedIcon);
                tooltip = "";
            }
        }

    }
}
}
 No newline at end of file
+90
Changes for Assets/ETSI.ARF/ARF World Storage API/Editor/Graph/ARFNodeTrackable.cs: 90 added lines, 0 removed lines.
Original line number Original line Diff line number Diff line
//
// 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
//

#define USING_OPENAPI_GENERATOR // alt. is Swagger

using UnityEngine;

#if USING_OPENAPI_GENERATOR
using Org.OpenAPITools.Model;
#else
using IO.Swagger.Api;
using IO.Swagger.Model;
#endif
using UnityEngine.UIElements;
using UnityEditor.Experimental.GraphView;
using Assets.ETSI.ARF.ARF_World_Storage_API.Editor.Windows;
using UnityEditor;

namespace ETSI.ARF.WorldStorage.UI
{
    public class ARFNodeTrackable : ARFNode
    {
        public Trackable trackable;

        public ARFNodeTrackable(Trackable trackable)
        {
            this.trackable = trackable;
            this.GUID = trackable.UUID.ToString();
            this.title = trackable.Name;

            /*COLOR*/
            var colorRectangle = new VisualElement();
            colorRectangle.style.height = 160;
            colorRectangle.style.height = 5;
            colorRectangle.style.backgroundColor = new Color(1, 0.31f, 0.31f, 0.9f);
            //get the index of the title container
            int titleIndex = mainContainer.hierarchy.IndexOf(titleContainer);
            mainContainer.Insert(titleIndex+1, colorRectangle);

            /*PORTS*/
            var portIn = GeneratePort(this, Direction.Input, Port.Capacity.Multi);
            portIn.portColor = new Color(0.66f, 0.39f, 1, 0.77f);
            portIn.portName = "Target"; // "Input"
            //portIn.AddManipulator(new EdgeConnector<ARFEdgeLink>(new WorldLinkListener()));
            inputContainer.Add(portIn);

            var portOut = GeneratePort(this, Direction.Output, Port.Capacity.Multi);
            portOut.portColor = new Color(0.66f, 0.39f, 1, 0.77f);
            portOut.portName = "Source"; // "Output";
            //portOut.AddManipulator(new EdgeConnector<ARFEdgeLink>(new WorldLinkListener())); ;
            outputContainer.Add(portOut);

            RefreshExpandedState();
            RefreshPorts();

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

        public void Clicked()
        {
            Debug.Log(trackable.ToJson());
            GraphEditorWindow.ShowWindow(this);
        }
        public override ObjectType GetElemType()
        {
            return ObjectType.Trackable;
        }
    }
}
 No newline at end of file
Loading
Loading