示例#1
0
        public override void OnDataChanged()
        {
            base.OnDataChanged();
            EdgePresenter edgePresenter = base.GetPresenter <EdgePresenter>();

            if (edgePresenter != null)
            {
                if (this.output == null || this.output.presenter != edgePresenter.output)
                {
                    GraphView firstAncestorOfType = base.GetFirstAncestorOfType <GraphView>();
                    if (firstAncestorOfType != null)
                    {
                        this.output = from t in firstAncestorOfType.Query().OfType <Port>(null, null)
                                      where t.presenter == edgePresenter.output
                                      select t;
                    }
                }
                if (this.input == null || this.input.presenter != edgePresenter.input)
                {
                    GraphView firstAncestorOfType2 = base.GetFirstAncestorOfType <GraphView>();
                    if (firstAncestorOfType2 != null)
                    {
                        this.input = from t in firstAncestorOfType2.Query().OfType <Port>(null, null)
                                     where t.presenter == edgePresenter.input
                                     select t;
                    }
                }
                if (edgePresenter.output != null || edgePresenter.input != null)
                {
                    this.edgeControl.orientation = ((!(edgePresenter.output != null)) ? edgePresenter.input.orientation : edgePresenter.output.orientation);
                }
            }
        }
        protected void OnMouseDown(MouseDownEvent evt)
        {
            if (m_Active)
            {
                evt.StopImmediatePropagation();
                return;
            }

            if (!CanStartManipulation(evt))
            {
                return;
            }

            m_Edge = (evt.target as VisualElement).parent as Edge;

            if (m_Edge != null)
            {
                m_EdgePresenter = m_Edge.GetPresenter <EdgePresenter>();
            }

            m_PressPos = evt.mousePosition;
            target.TakeMouseCapture();
            evt.StopPropagation();
            m_LastMouseDownEvent = evt;
        }
示例#3
0
            public void OnDrop(GraphView graphView, Edge edge)
            {
                if (graphView == null || edge == null)
                {
                    return;
                }

                if (graphView.presenter == null)
                {
                    return;
                }

                // Check if the edge already has a presenter then do not create it
                EdgePresenter edgePresenter = edge.GetPresenter <EdgePresenter>();

                if (edgePresenter == null)
                {
                    edgePresenter = ScriptableObject.CreateInstance <TEdgePresenter>();
                }

                edgePresenter.output = edge.output.GetPresenter <PortPresenter>();
                edgePresenter.input  = edge.input.GetPresenter <PortPresenter>();

                edgePresenter.output.Connect(edgePresenter);
                edgePresenter.input.Connect(edgePresenter);

                graphView.presenter.AddElement(edgePresenter);
            }
示例#4
0
        public override void OnDataChanged()
        {
            base.OnDataChanged();

            EdgePresenter edgePresenter = GetPresenter <EdgePresenter>();

            if (edgePresenter != null)
            {
                if (output == null || output.presenter != edgePresenter.output)
                {
                    GraphView view = GetFirstAncestorOfType <GraphView>();
                    if (view != null)
                    {
                        output = view.Query().OfType <Port>().Where(t => t.presenter == edgePresenter.output);
                    }
                }

                if (input == null || input.presenter != edgePresenter.input)
                {
                    GraphView view = GetFirstAncestorOfType <GraphView>();
                    if (view != null)
                    {
                        input = view.Query().OfType <Port>().Where(t => t.presenter == edgePresenter.input);
                    }
                }

                if (edgePresenter.output != null || edgePresenter.input != null)
                {
                    edgeControl.orientation = edgePresenter.output != null ? edgePresenter.output.orientation : edgePresenter.input.orientation;
                }
            }
        }
示例#5
0
 public virtual void Disconnect(EdgePresenter edgePresenter)
 {
     if (edgePresenter == null)
     {
         throw new ArgumentException("The value passed to PortPresenter.Disconnect is null");
     }
     this.m_Connections.Remove(edgePresenter);
 }
示例#6
0
 protected virtual void DrawEdge()
 {
     if (this.UpdateEdgeControl())
     {
         if (base.selected)
         {
             if (this.isGhostEdge)
             {
                 Debug.Log("Selected Ghost Edge: this should never be");
             }
             this.edgeControl.inputColor  = this.selectedColor;
             this.edgeControl.outputColor = this.selectedColor;
             this.edgeControl.edgeWidth   = this.edgeWidth;
             if (this.m_InputPort != null)
             {
                 this.m_InputPort.capColor = this.selectedColor;
             }
             if (this.m_OutputPort != null)
             {
                 this.m_OutputPort.capColor = this.selectedColor;
             }
         }
         else
         {
             if (this.m_InputPort != null)
             {
                 this.m_InputPort.UpdateCapColor();
             }
             if (this.m_OutputPort != null)
             {
                 this.m_OutputPort.UpdateCapColor();
             }
             this.edgeControl.inputColor  = ((this.m_InputPort != null) ? this.m_InputPort.portColor : this.m_OutputPort.portColor);
             this.edgeControl.outputColor = ((this.m_OutputPort != null) ? this.m_OutputPort.portColor : this.m_InputPort.portColor);
             this.edgeControl.edgeWidth   = this.edgeWidth;
             EdgePresenter presenter = base.GetPresenter <EdgePresenter>();
             if (presenter == null)
             {
                 this.edgeControl.toCapColor   = ((this.m_InputPort != null) ? this.m_InputPort.portColor : this.m_OutputPort.portColor);
                 this.edgeControl.fromCapColor = ((this.m_OutputPort != null) ? this.m_OutputPort.portColor : this.m_InputPort.portColor);
             }
             else
             {
                 this.edgeControl.toCapColor   = ((!(presenter.input == null)) ? this.m_InputPort.portColor : this.m_OutputPort.portColor);
                 this.edgeControl.fromCapColor = ((!(presenter.output == null)) ? this.m_OutputPort.portColor : this.m_InputPort.portColor);
             }
             if (this.isGhostEdge)
             {
                 this.edgeControl.inputColor  = new Color(this.edgeControl.inputColor.r, this.edgeControl.inputColor.g, this.edgeControl.inputColor.b, 0.5f);
                 this.edgeControl.outputColor = new Color(this.edgeControl.outputColor.r, this.edgeControl.outputColor.g, this.edgeControl.outputColor.b, 0.5f);
             }
         }
     }
 }
示例#7
0
 public virtual void Connect(EdgePresenter edgePresenter)
 {
     if (edgePresenter == null)
     {
         throw new ArgumentException("The value passed to PortPresenter.Connect is null");
     }
     if (!this.m_Connections.Contains(edgePresenter))
     {
         this.m_Connections.Add(edgePresenter);
     }
 }
示例#8
0
        public virtual void DisconnectAll()
        {
            PortPresenter presenter = base.GetPresenter <PortPresenter>();

            if (presenter != null)
            {
                foreach (Edge current in this.m_Connections)
                {
                    EdgePresenter presenter2 = current.GetPresenter <EdgePresenter>();
                    presenter.Disconnect(presenter2);
                }
            }
            this.m_Connections.Clear();
            if (this.OnDisconnect != null)
            {
                this.OnDisconnect(this);
            }
        }
示例#9
0
 protected void OnMouseDown(MouseDownEvent evt)
 {
     if (this.m_Active)
     {
         evt.StopImmediatePropagation();
     }
     else if (base.CanStartManipulation(evt))
     {
         this.m_Edge = ((evt.target as VisualElement).parent as Edge);
         if (this.m_Edge != null)
         {
             this.m_EdgePresenter = this.m_Edge.GetPresenter <EdgePresenter>();
         }
         this.m_PressPos = evt.mousePosition;
         base.target.TakeMouseCapture();
         evt.StopPropagation();
         this.m_LastMouseDownEvent = evt;
     }
 }
示例#10
0
 public void OnDrop(GraphView graphView, Edge edge)
 {
     if (graphView != null && edge != null)
     {
         if (!(graphView.presenter == null))
         {
             EdgePresenter edgePresenter = edge.GetPresenter <EdgePresenter>();
             if (edgePresenter == null)
             {
                 edgePresenter = ScriptableObject.CreateInstance <TEdgePresenter>();
             }
             edgePresenter.output = edge.output.GetPresenter <PortPresenter>();
             edgePresenter.input  = edge.input.GetPresenter <PortPresenter>();
             edgePresenter.output.Connect(edgePresenter);
             edgePresenter.input.Connect(edgePresenter);
             graphView.presenter.AddElement(edgePresenter);
         }
     }
 }
示例#11
0
        public virtual void Disconnect(Edge edge)
        {
            if (edge == null)
            {
                throw new ArgumentException("The value passed to PortPresenter.Disconnect is null");
            }
            PortPresenter presenter = base.GetPresenter <PortPresenter>();

            if (presenter != null)
            {
                EdgePresenter presenter2 = edge.GetPresenter <EdgePresenter>();
                presenter.Disconnect(presenter2);
            }
            else
            {
                this.m_Connections.Remove(edge);
            }
            if (this.OnDisconnect != null)
            {
                this.OnDisconnect(this);
            }
        }
示例#12
0
        public virtual void Connect(Edge edge)
        {
            if (edge == null)
            {
                throw new ArgumentException("The value passed to Port.Connect is null");
            }
            PortPresenter presenter = base.GetPresenter <PortPresenter>();

            if (presenter != null)
            {
                EdgePresenter presenter2 = edge.GetPresenter <EdgePresenter>();
                presenter.Connect(presenter2);
            }
            else if (!this.m_Connections.Contains(edge))
            {
                this.m_Connections.Add(edge);
            }
            if (this.OnConnect != null)
            {
                this.OnConnect(this);
            }
        }
示例#13
0
 public virtual void AddElement(EdgePresenter edge)
 {
     this.AddElement(edge);
 }
 // Some usage require a separate handler for edges.
 public virtual void AddElement(EdgePresenter edge)
 {
     AddElement((GraphElementPresenter)edge);
 }