protected virtual void DrawDroplets()
        {
            foreach (var droplet in droplets)
            {
                Vector2 position;

                if (droplet < handleAlignmentMargin)
                {
                    var t = droplet / handleAlignmentMargin;
                    position = Vector2.Lerp(sourceHandlePosition.center, sourceHandleEdgeCenter, t);
                }
                else if (droplet > 1 - handleAlignmentMargin)
                {
                    var t = (droplet - (1 - handleAlignmentMargin)) / handleAlignmentMargin;
                    position = Vector2.Lerp(destinationHandleEdgeCenter, destinationHandlePosition.center, t);
                }
                else
                {
                    var t = (droplet - handleAlignmentMargin) / (1 - 2 * handleAlignmentMargin);
                    position = GraphGUI.GetPointOnConnection(t, sourceHandleEdgeCenter, destinationHandleEdgeCenter, Edge.Right, Edge.Left, UnitConnectionStyles.relativeBend, UnitConnectionStyles.minBend);
                }

                var size = GetDropletSize();

                using (LudiqGUI.color.Override(GUI.color * color))
                {
                    DrawDroplet(new Rect(position.x - size.x / 2, position.y - size.y / 2, size.x, size.y));
                }
            }
        }
Ejemplo n.º 2
0
        private void DrawDroplets()
        {
            foreach (var droplet in droplets)
            {
                Vector2 position;

                if (droplet < 0.5f)
                {
                    var t = droplet / 0.5f;
                    position = GraphGUI.GetPointOnConnection(t, sourceEdgeCenter, entryEdgeCenter, sourceEdge, entryEdge, relativeBend, minBend);
                }
                else
                {
                    var t = (droplet - 0.5f) / 0.5f;
                    position = GraphGUI.GetPointOnConnection(t, exitEdgeCenter, destinationEdgeCenter, exitEdge, destinationEdge, relativeBend, minBend);
                }

                var size = GetDropletSize();

                using (LudiqGUI.color.Override(Color.white))
                {
                    DrawDroplet(new Rect(position.x - size.x / 2, position.y - size.y / 2, size.x, size.y));
                }
            }
        }
 internal void Update(List <node> _nodes, GraphGUI _gui)
 {
     textPrpt.gui      = gui = _gui;
     nodes             = _nodes;
     textPrpt.Elements = nodes.Cast <graphElement>().ToList();
     Update();
 }
Ejemplo n.º 4
0
 public MainForm()
 {
     InitializeComponent();
     picture.Image        = new Bitmap(picture.Size.Width, picture.Size.Height);
     graph                = new GraphGUI(picture, 30, 2);
     cmbBox.SelectedIndex = 0;
 }
Ejemplo n.º 5
0
        void InitializeGUIs()
        {
            this.GUI_List       = new List <UserControl>();
            this.DoubleBuffered = true;

            this.MyGraphGUI      = new GraphGUI();
            this.MyGraphGUI.Dock = DockStyle.Fill;
            this.MyGraphGUI.Name = "GraphGUI";
            this.Controls.Add(this.MyGraphGUI);
            this.GUI_List.Add(this.MyGraphGUI);
            this.MyGraphGUI.Visible = true;

            this.MyAgentGUI      = new AgentGUI();
            this.MyAgentGUI.Dock = DockStyle.Fill;
            this.MyAgentGUI.Name = "AgentGUI";
            this.Controls.Add(this.MyAgentGUI);
            this.GUI_List.Add(this.MyAgentGUI);
            this.MyAgentGUI.Visible = false;

            this.MyLearningGUI      = new LearningGUI();
            this.MyLearningGUI.Dock = DockStyle.Fill;
            this.MyLearningGUI.Name = "LearningGUI";
            this.Controls.Add(this.MyLearningGUI);
            this.GUI_List.Add(this.MyLearningGUI);
            this.MyLearningGUI.Visible = false;

            this.MyExperimentGUI      = new ExperimentGUI();
            this.MyExperimentGUI.Dock = DockStyle.Fill;
            this.MyExperimentGUI.Name = "ExperimentGUI";
            this.Controls.Add(this.MyExperimentGUI);
            this.GUI_List.Add(this.MyExperimentGUI);
            this.MyExperimentGUI.Visible = false;
        }
Ejemplo n.º 6
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);

            var e = this.runtimeInstance as TxRobotNode;

            GUILayout.BeginHorizontal();
            GUILayout.EndHorizontal();

            /*
             * if (pinStyle == null) {
             *      pinStyle = new GUIStyle (Styles.pinOut);
             *      pinStyle.alignment = TextAnchor.MiddleRight;
             * }
             *
             * int space = 0;
             * foreach (var slot in this.outputSlots)
             * {
             *      EditorGUILayout.BeginHorizontal();
             *      GUILayout.FlexibleSpace();
             *      GUILayout.BeginArea (new Rect (128-35	, 10+space, 50, 30));
             *      host.LayoutSlot(slot, slot.title, true, false, true,pinStyle );
             *      GUILayout.EndArea ();
             *      EditorGUILayout.EndHorizontal();
             *
             *      space += 20;
             * }*/
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Helper method to draw a node slot.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="slotName"></param>
        protected void DrawSlot(GraphGUI host, string slotName)
        {
            Slot slot = this[slotName];

            EditorGUILayout.LabelField(slotName);
            SlotDrawer.Draw(host, slot);
        }
Ejemplo n.º 8
0
 private void InitGraph(Graph graph)
 {
     graphGUI       = GraphGUI.CreateInstance <UnityEditorGrapGUI>();
     graphGUI.graph = graph;
     graphGUI.drawSelectionRectCallback += CallBack;
     DefultNode();
 }
Ejemplo n.º 9
0
        public void UpdateCanvasProperties(GraphGUI gd)
        {
            gd.gridAndAxes.AxesColor   = BrushSelector.GetBrushFromString(AxesColor);
            gd.gridAndAxes.AxesOpacity = AxesOpacity;
            gd.gridAndAxes.AxesThick   = AxesThick;

            gd.gridAndAxes.GridColor   = BrushSelector.GetBrushFromString(GridColor);
            gd.gridAndAxes.GridOpacity = GridOpacity;
            gd.gridAndAxes.GridSpacing = GridSpacing;
            gd.gridAndAxes.GridThick   = GridThick;

            gd.nodeShapes.Opacity = ShapeOpacity;

            gd.nodeIcons.ShowName   = ShowNodeName;
            gd.nodeIcons.ShowLabels = ShowNodeLabel;
            gd.arcIcons.ShowName    = ShowArcName;
            gd.arcIcons.ShowLabels  = ShowArcLabel;

            gd.nodeIcons.FontSize            = NodeLabelFontSize;
            gd.nodeIcons.DisplayTextDistance = NodeDisplayTextDistance;
            gd.nodeIcons.DisplayTextPosition = NodeDisplayTextPosition;
            gd.arcIcons.FontSize             = ArcLabelFontSize;
            gd.arcIcons.DisplayTextDistance  = ArcDisplayTextDistance;
            gd.arcIcons.DisplayTextPosition  = ArcDisplayTextPosition;


            gd.SnapToGrid = SnapToGrid;

            gd.ScaleFactor = ScaleFactor;
            gd.ZoomToFit   = ZoomToFit;
            //if (BackgroundColor.Equals("#FFFFFFFF"))
            //    gd.Background =
            //else
            //    gd.Background = new SolidColorBrush(BrushSelector.GetColorFromString(BackgroundColor));
        }
Ejemplo n.º 10
0
    public override void OnNodeUI(GraphGUI host)
    {
        if (!populated)
        {
            CollectSlots(graph as Graph);
        }

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical();
        GUILayout.FlexibleSpace();

        DrawInputSlots(host, inSlots, true);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndVertical();

        slots.Clear();
        GUILayout.FlexibleSpace();
        EditorGUILayout.BeginVertical();
        GUILayout.FlexibleSpace();
        DrawOutputSlots(host, outSlots, true);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
Ejemplo n.º 11
0
        /// <summary>
        /// Draws a slot given a GraphGUI host.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="slot"></param>
        public static void Draw(GraphGUI host, Slot slot)
        {
            Rect position = GUILayoutUtility.GetLastRect();

            position = GetRect(position, slot, 5.0f);
            Draw(position, host, slot);
        }
Ejemplo n.º 12
0
    public override void OnNodeUI(GraphGUI host)
    {
        if (false && nodeStyle == null)
        {
            nodeStyle = new GUIStyle(Graphs.Styles.GetNodeStyle(this.style, this.color, true));
            nodeStyle.normal.background = Resources.Load <Texture2D> ("Character");
            nodeStyle.fontStyle         = FontStyle.Bold;
        }

        base.OnNodeUI(host);
        var e   = this.runtimeInstance as TextureOutput;
        var tex = e.tex;

        if (texSlot == null)
        {
            texSlot = AddInputSlot("Test", typeof(Texture));
        }

        // TODO: Check if texture is readable

        GUILayout.BeginHorizontal();
        GUILayout.Label("Texture");
        GUILayout.Box(tex, new GUILayoutOption[] { GUILayout.Width(64), GUILayout.Height(64) });
        GUILayout.EndHorizontal();

        if (texSlot != null)
        {
            var instance = (texSlot.node as Node).runtimeInstance;
            var v        = TryGetSlotPropertyValue(texSlot);
            if (v != null)
            {
                GUILayout.Box(v as Texture, new GUILayoutOption[] { GUILayout.Width(64), GUILayout.Height(64) });
            }
        }
    }
 internal void Update(List <hyperarc> list, GraphGUI GraphGUI)
 {
     textPrpt.gui      = gui = GraphGUI;
     hyperarcs         = list;
     textPrpt.Elements = hyperarcs.Cast <graphElement>().ToList();
     Update();
 }
Ejemplo n.º 14
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.NodeUI(host);

            var e = this.runtimeInstance as RobotConnectorNode;

            GUILayout.BeginHorizontal();
            GUILayout.EndHorizontal();

            if (pinStyle == null)
            {
                pinStyle           = new GUIStyle(Styles.pinOut);
                pinStyle.alignment = TextAnchor.MiddleRight;
            }

            int space = 50;

            foreach (var slot in this.outputSlots)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.BeginArea(new Rect(256 - 50, 10 + space, 50, 30));
                host.LayoutSlot(slot, slot.title, true, false, true, pinStyle);
                GUILayout.EndArea();
                EditorGUILayout.EndHorizontal();

                space += 20;
            }
        }
Ejemplo n.º 15
0
        GraphGUI GetEditor(Graph graph)
        {
            GraphGUI graphGUI = CreateInstance("GraphGUI") as GraphGUI;

            graphGUI.graph     = graph;
            graphGUI.hideFlags = HideFlags.HideAndDontSave;
            return(graphGUI);
        }
Ejemplo n.º 16
0
 internal void Update(List <hyperarc> _hyperarcs, designGraph _graph, GraphGUI _gui)
 {
     hyperarcs    = _hyperarcs;
     graph        = _graph;
     gui          = _gui;
     hyperArcIcon = ((HyperArcShape)firstHyperArc.DisplayShape.Shape).icon;
     Update();
 }
Ejemplo n.º 17
0
 internal void Update(List <arc> _arcs, designGraph _graph, GraphGUI _gui)
 {
     arcs    = _arcs;
     graph   = _graph;
     gui     = _gui;
     arcIcon = ((ArcShape)firstArc.DisplayShape.Shape).icon;
     Update();
 }
Ejemplo n.º 18
0
 internal void Update(List <node> _nodes, designGraph _graph, GraphGUI _gui)
 {
     nodes    = _nodes;
     graph    = _graph;
     gui      = _gui;
     nodeIcon = ((DisplayShape)firstNode.DisplayShape).icon;
     Update();
 }
Ejemplo n.º 19
0
 public override void NodeUI(GraphGUI host)
 {
     base.NodeUI(host);
     if (icon != null)
     {
         GUI.DrawTexture(new Rect(Vector2.one * 5, new Vector2(20, 20)), icon);
     }
 }
        public override void BeforeFrame()
        {
            base.BeforeFrame();

            if (showDroplets)
            {
                GraphGUI.UpdateDroplets(canvas, droplets, ConnectionDebugData.lastInvokeFrame, ref lastInvokeTime, ref dropTime);
            }
        }
    public override void OnNodeUI(GraphGUI host)
    {
        /*if (_currObject != (runtimeInstance as GenericNode).sourceObject) {
         *      CollectSlots ();
         *      PopulateEdges ();
         * }*/

        base.OnNodeUI(host);
    }
Ejemplo n.º 22
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);
            var e = this.runtimeInstance as FloatMix;

            GUILayout.BeginHorizontal();
            e._modulationType = (FloatMix.ModulationType)EditorGUILayout.EnumPopup(e._modulationType);
            GUILayout.EndHorizontal();
        }
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);
            var e = this.runtimeInstance as FloatFilter;

            GUILayout.BeginHorizontal();
            EditorGUILayout.CurveField(e._responseCurve);
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Helper method to draw a node slot.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="expression"></param>
        protected void DrawSlot(GraphGUI host, Expression <System.Func <object> > expression)
        {
            string slotName;

            if (StaticReflectionHelper.GetMemberName(expression).TryGet(out slotName))
            {
                DrawSlot(host, slotName);
            }
        }
Ejemplo n.º 25
0
        protected override void OnShowNode(GraphGUI host)
        {
            color = Styles.Color.Orange;

            DrawOutputSlot(host);
            DrawSlot(host, () => Input);

            Node.value = EditorGUILayout.IntField("Value", Node.value);
        }
Ejemplo n.º 26
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);

            var e = this.runtimeInstance as RobotConnectorNode;

            GUILayout.BeginHorizontal();
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 27
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);
            var e = this.runtimeInstance as IntValueOutput;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Value");
            UnityEditor.EditorGUILayout.IntField(e.Value, EditorStyles.boldLabel);
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 28
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);
            var e = this.runtimeInstance as KeyInput;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Label("Key");
            e._keyCode = (KeyCode)EditorGUILayout.EnumPopup(e._keyCode);
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 29
0
        private void DrawOutputSlot(GraphGUI host)
        {
            Slot slot = this["Output"];

            Rect titlePosition = new Rect(0.0f, 6.0f, position.width, 16.0f);

            titlePosition = SlotDrawer.GetRect(titlePosition, slot, 1.0f);

            SlotDrawer.Draw(titlePosition, host, slot);
        }
Ejemplo n.º 30
0
        public override void OnNodeUI(GraphGUI host)
        {
            base.OnNodeUI(host);
            var e = this.runtimeInstance as AxisInput;

            GUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Label("Axis");
            e._axisName = GUILayout.TextArea(e._axisName);
            GUILayout.EndHorizontal();
        }
Ejemplo n.º 31
0
 public override void NodeUI(GraphGUI host)
 {
     GUILayout.Label("Internal Nodes:" + this.m_SubGraph.nodes.Count, new GUILayoutOption[0]);
     if (GUILayout.Button("Ungroup", new GUILayoutOption[0]))
     {
         this.UnGroup();
     }
     if (GUILayout.Button("Edit", new GUILayoutOption[0]))
     {
         host.ZoomToGraph(this.m_SubGraph);
     }
 }