public void InsertPort(PortView portView, int index) { if (portView.direction == Direction.Input) { if (portView.portData.vertical) { topPortContainer.Insert(index, portView); } else { inputContainer.Insert(index, portView); } } else { if (portView.portData.vertical) { bottomPortContainer.Insert(index, portView); } else { outputContainer.Insert(index, portView); } } }
public void OnPortConnected(PortView pv, Edge edge) { // Fix port datas if (pv.direction == Direction.Input) { edge.input = pv; } else { edge.output = pv; } // If the edge is already connected, ignore it if (portViews.ContainsKey(edge)) { return; } portViews[edge] = pv; if (pv.GetEdges().Count == 0) { multiPorts.AddUniqueId(multiPorts.GetUniqueId()); AddPort(); } }
public PortView AddPort(FieldInfo fieldInfo, Direction direction, BaseEdgeConnectorListener listener, PortData portData) { // TODO: hardcoded value PortView p = PortView.CreatePV(Orientation.Horizontal, direction, fieldInfo, portData, listener); if (p.direction == Direction.Input) { inputPortViews.Add(p); inputContainer.Add(p); } else { outputPortViews.Add(p); outputContainer.Add(p); } p.Initialize(this, portData?.displayName); List <PortView> ports; portsPerFieldName.TryGetValue(p.fieldName, out ports); if (ports == null) { ports = new List <PortView>(); portsPerFieldName[p.fieldName] = ports; } ports.Add(p); return(p); }
public void RemovePort(PortView p) { // Remove all connected edges: var edgesCopy = p.GetEdges().ToList(); foreach (var e in edgesCopy) { owner.Disconnect(e, refreshPorts: false); } if (p.direction == Direction.Input) { if (inputPortViews.Remove(p)) { p.RemoveFromHierarchy(); } } else { if (outputPortViews.Remove(p)) { p.RemoveFromHierarchy(); } } List <PortView> ports; portsPerFieldName.TryGetValue(p.fieldName, out ports); ports.Remove(p); }
public static PortView CreatePortView(Direction direction, FieldInfo fieldInfo, PortData portData, BaseEdgeConnectorListener edgeConnectorListener) { var pv = new PortView(direction, fieldInfo, portData, edgeConnectorListener); pv.m_EdgeConnector = new BaseEdgeConnector(edgeConnectorListener); pv.AddManipulator(pv.m_EdgeConnector); // Force picking in the port label to enlarge the edge creation zone var portLabel = pv.Q("type"); if (portLabel != null) { portLabel.pickingMode = PickingMode.Position; portLabel.style.flexGrow = 1; } // hide label when the port is vertical if (portData.vertical && portLabel != null) { portLabel.style.display = DisplayStyle.None; } // Fixup picking mode for vertical top ports if (portData.vertical) { pv.Q("connector").pickingMode = PickingMode.Position; } return(pv); }
public static PortView CreatePV(Orientation orientation, Direction direction, FieldInfo fieldInfo, PortData portData, BaseEdgeConnectorListener edgeConnectorListener) { var pv = new PortView(orientation, direction, fieldInfo, portData, edgeConnectorListener); pv.m_EdgeConnector = new BaseEdgeConnector(edgeConnectorListener); pv.AddManipulator(pv.m_EdgeConnector); return(pv); }
void AddPort() { PortView pv = node.AddPort(fieldInfo, direction, listener, isMultiple, name); // We force the AddPort in the BaseNode class because the port list is not updated except at the construction of the class node.nodeTarget.AddPort(direction == Direction.Input, pv.fieldName); pv.OnConnected += OnPortConnected; pv.OnDisconnected += OnPortDisconnected; }
public void InsertPort(PortView portView, int index) { if (portView.direction == Direction.Input) { inputContainer.Insert(index, portView); } else { outputContainer.Insert(index, portView); } }
public void RemovePort(PortView p) { if (p.direction == Direction.Input) { inputPorts.Remove(p); inputContainer.Remove(p); } else { outputPorts.Remove(p); outputContainer.Remove(p); } portsPerFieldName.Remove(p.fieldName); }
public static List <PortDescription> GetEdgeCreationNodeMenuEntry(PortView portView) { return(nodeCreatePortDescription.Where(n => { if (portView.direction == Direction.Input && n.isInput || portView.direction == Direction.Output && !n.isInput) { return false; } if (!BaseGraph.TypesAreConnectable(n.portType, portView.portType)) { return false; } return true; }).ToList()); }
public void Initialize(BaseGraphView graphView, EditorWindow window, EdgeView edgeFilter = null) { this.graphView = graphView; this.window = window; this.edgeFilter = edgeFilter; this.inputPortView = edgeFilter?.input as PortView; this.outputPortView = edgeFilter?.output as PortView; // Transparent icon to trick search window into indenting items if (icon == null) { icon = new Texture2D(1, 1); } icon.SetPixel(0, 0, new Color(0, 0, 0, 0)); icon.Apply(); }
public RelayNodeView AddRelayNode(PortView inputPort, PortView outputPort, Vector2 position) { var relayNode = BaseNode.CreateFromType <RelayNode>(position); var view = AddNode(relayNode) as RelayNodeView; if (outputPort != null) { Connect(view.inputPortViews[0], outputPort); } if (inputPort != null) { Connect(inputPort, view.outputPortViews[0]); } return(view); }
public void OnPortDisconnected(PortView pv, Edge edge) { if (pv.GetEdges().Count == 0) { if ((edge as EdgeView).isConnected && portViews.ContainsKey(edge)) { var portToRemove = portViews[edge]; node.RemovePort(portToRemove); node.nodeTarget.RemovePort(direction == Direction.Input, portToRemove.fieldName); portViews.Remove(edge); multiPorts.RemoveUniqueId(0); } } }
public PortView AddPort(FieldInfo fieldInfo, Direction direction, BaseEdgeConnectorListener listener, PortData portData) { PortView p = CreatePortView(direction, fieldInfo, portData, listener); if (p.direction == Direction.Input) { inputPortViews.Add(p); if (portData.vertical) { topPortContainer.Add(p); } else { inputContainer.Add(p); } } else { outputPortViews.Add(p); if (portData.vertical) { bottomPortContainer.Add(p); } else { outputContainer.Add(p); } } p.Initialize(this, portData?.displayName); List <PortView> ports; portsPerFieldName.TryGetValue(p.fieldName, out ports); if (ports == null) { ports = new List <PortView>(); portsPerFieldName[p.fieldName] = ports; } ports.Add(p); return(p); }
public static PortView CreatePV(Orientation orientation, Direction direction, FieldInfo fieldInfo, PortData portData, BaseEdgeConnectorListener edgeConnectorListener) { var pv = new PortView(orientation, direction, fieldInfo, portData, edgeConnectorListener); pv.m_EdgeConnector = new BaseEdgeConnector(edgeConnectorListener); pv.AddManipulator(pv.m_EdgeConnector); // Force picking in the port label to enlarge the edge creation zone var portLabel = pv.Q("type"); if (portLabel != null) { portLabel.pickingMode = PickingMode.Position; portLabel.style.flexGrow = 1; } return(pv); }
public PortView AddPort(FieldInfo fieldInfo, Direction direction, EdgeConnectorListener listener, bool isMultiple = false, string name = null) { // TODO: hardcoded value PortView p = new PortView(Orientation.Horizontal, direction, fieldInfo, listener); if (p.direction == Direction.Input) { inputPorts.Add(p); inputContainer.Add(p); } else { outputPorts.Add(p); outputContainer.Add(p); } p.Initialize(this, isMultiple, name); portsPerFieldName[p.fieldName] = p; return(p); }
public static IEnumerable <PortDescription> GetEdgeCreationNodeMenuEntry(PortView portView, BaseGraph graph = null) { foreach (var description in genericNodes.nodeCreatePortDescription) { if (!IsPortCompatible(description)) { continue; } yield return(description); } if (graph != null && specificNodeDescriptions.TryGetValue(graph, out var specificNodes)) { foreach (var description in specificNodes.nodeCreatePortDescription) { if (!IsPortCompatible(description)) { continue; } yield return(description); } } bool IsPortCompatible(PortDescription description) { if (portView.direction == Direction.Input && description.isInput || portView.direction == Direction.Output && !description.isInput) { return(false); } if (!BaseGraph.TypesAreConnectable(description.portType, portView.portType)) { return(false); } return(true); } }
public bool Connect(PortView inputPortView, PortView outputPortView, bool autoDisconnectInputs = true) { var inputPort = inputPortView.owner.nodeTarget.GetPort(inputPortView.fieldName, inputPortView.portData.identifier); var outputPort = outputPortView.owner.nodeTarget.GetPort(outputPortView.fieldName, outputPortView.portData.identifier); // Checks that the node we are connecting still exists if (inputPortView.owner.parent == null || outputPortView.owner.parent == null) { return(false); } var newEdge = SerializableEdge.CreateNewEdge(graph, inputPort, outputPort); var edgeView = new EdgeView() { userData = newEdge, input = inputPortView, output = outputPortView, }; return(Connect(edgeView)); }
public virtual void OnPortDisconnected(PortView port) { }
protected virtual PortView CreatePortView(Direction direction, FieldInfo fieldInfo, PortData portData, BaseEdgeConnectorListener listener) => PortView.CreatePortView(direction, fieldInfo, portData, listener);
public void OnPortDisconnected(PortView port) { onPortDisconnected?.Invoke(port); }
internal void OnPortDisconnected(PortView port) { onPortDisconnected?.Invoke(port); }