public CreateNodeFromExecutionPortAction(IPortModel portModel, Vector2 position, IEnumerable <IEdgeModel> edgesToDelete = null, IGroupNodeModel groupModel = null) { PortModel = portModel; Position = position; EdgesToDelete = edgesToDelete ?? Enumerable.Empty <IEdgeModel>(); GroupModel = groupModel; }
public CreateGroupedNodeFromSearcherAction(IGraphModel graphModel, IGroupNodeModel groupNodeModel, Vector2 position, GraphNodeModelSearcherItem selectedItem) { GraphModel = graphModel; GroupNodeModel = groupNodeModel; Position = position; SelectedItem = selectedItem; }
public CreateVariableNodesAction(IVariableDeclarationModel graphElementModel, Vector2 mousePosition, IEnumerable <IEdgeModel> edgeModelsToDelete = null, IPortModel connectAfterCreation = null, IGroupNodeModel groupModel = null, bool autoAlign = false) { VariablesToCreate = new List <Tuple <IVariableDeclarationModel, Vector2> >(); VariablesToCreate.Add(Tuple.Create(graphElementModel, mousePosition)); EdgeModelsToDelete = edgeModelsToDelete; ConnectAfterCreation = connectAfterCreation; GroupModel = groupModel; AutoAlign = autoAlign; }
static void OnDropOutsideCallback(Store store, Vector2 pos, Edge edge) { VseGraphView graphView = edge.GetFirstAncestorOfType <VseGraphView>(); Vector2 worldPos = pos; pos = graphView.contentViewContainer.WorldToLocal(pos); List <IEdgeModel> edgesToDelete = GetDropEdgeModelsToDelete(edge); // when grabbing an existing edge's end, the edgeModel should be deleted if ((edge).GraphElementModel != null) { edgesToDelete.Add((IEdgeModel)edge.GraphElementModel); } IStackModel targetStackModel = null; int targetIndex = -1; IGroupNodeModel groupModel = null; StackNode stackNode = graphView.lastHoveredVisualElement as StackNode ?? graphView.lastHoveredVisualElement.GetFirstOfType <StackNode>(); if (stackNode != null) { targetStackModel = stackNode.stackModel; targetIndex = stackNode.GetInsertionIndex(worldPos); } else if (graphView.lastHoveredVisualElement is Group group) { groupModel = group.model; } IPortModel existingPortModel; // warning: when dragging the end of an existing edge, both ports are non null. if (edge.input != null && edge.output != null) { float distanceToOutput = Vector2.Distance(edge.edgeControl.from, pos); float distanceToInput = Vector2.Distance(edge.edgeControl.to, pos); // note: if the user was able to stack perfectly both ports, we'd be in trouble if (distanceToOutput < distanceToInput) { existingPortModel = (IPortModel)edge.input.userData; } else { existingPortModel = (IPortModel)edge.output.userData; } } else { Port existingPort = (Port)(edge.input ?? edge.output); existingPortModel = existingPort.userData as IPortModel; } CreateNodes(store, existingPortModel, pos, edgesToDelete, targetStackModel, targetIndex, groupModel); }
public CreateNodeFromInputPortAction(IPortModel portModel, Vector2 position, GraphNodeModelSearcherItem selectedItem, IEnumerable <IEdgeModel> edgesToDelete = null, IGroupNodeModel groupModel = null) { PortModel = portModel; Position = position; SelectedItem = selectedItem; EdgesToDelete = edgesToDelete ?? Enumerable.Empty <IEdgeModel>(); GroupModel = groupModel; }
public CreateStackedNodeFromOutputPortAction(IPortModel portModel, IStackModel stackModel, int index, StackNodeModelSearcherItem selectedItem, IEnumerable <IEdgeModel> edgesToDelete = null, IGroupNodeModel groupModel = null) { PortModel = portModel; StackModel = stackModel; Index = index; SelectedItem = selectedItem; EdgesToDelete = edgesToDelete ?? Enumerable.Empty <IEdgeModel>(); GroupModel = groupModel; }
public CreateInsertLoopNodeAction(IPortModel portModel, IStackModel stackModel, int index, LoopStackModel loopStackModel, IEnumerable <IEdgeModel> edgesToDelete = null, IGroupNodeModel groupModel = null) { PortModel = portModel; StackModel = stackModel; Index = index; LoopStackModel = loopStackModel; EdgesToDelete = edgesToDelete ?? Enumerable.Empty <IEdgeModel>(); GroupModel = groupModel; }
static void AddToGroup(IEnumerable <INodeModel> nodes, IGroupNodeModel groupModel) { if (groupModel == null) { return; } IEnumerable <INodeModel> nodeModels = nodes.ToList(); ((GroupNodeModel)groupModel).AddNodes(nodeModels); }
public Group(IGroupNodeModel model, Store store, GraphView graphView) { capabilities |= Capabilities.Deletable; styleSheets.Add(AssetDatabase.LoadAssetAtPath <StyleSheet>(UICreationHelper.templatePath + "Group.uss")); this.model = model; m_Store = store; m_GraphView = graphView; this.MandatoryQ(name: "contentContainerPlaceholder").ElementAt(1).pickingMode = PickingMode.Ignore; // TODO hack for 0.4, fix this in graphview or something this.AddManipulator(new ContextualMenuManipulator(OnContextualMenuEvent)); base.title = model.Title; }
static void CreateNodes(Store store, IPortModel portModel, Vector2 position, IEnumerable <IEdgeModel> edgesToDelete, IStackModel stackModel, int index, IGroupNodeModel groupModel) { switch (portModel.PortType) { case PortType.Data: case PortType.Instance: switch (portModel.Direction) { case Direction.Output when stackModel != null: if (portModel.DataType != TypeHandle.Unknown) { SearcherService.ShowOutputToStackNodes( store.GetState(), stackModel, portModel, position, item => { store.Dispatch(new CreateStackedNodeFromOutputPortAction( portModel, stackModel, index, item, edgesToDelete, groupModel)); }); } break; case Direction.Output: SearcherService.ShowOutputToGraphNodes(store.GetState(), portModel, position, item => { store.Dispatch(new CreateNodeFromOutputPortAction( portModel, position, item, edgesToDelete, groupModel)); }); break; case Direction.Input: SearcherService.ShowInputToGraphNodes(store.GetState(), portModel, position, item => { store.Dispatch(new CreateNodeFromInputPortAction( portModel, position, item, edgesToDelete, groupModel)); }); break; default: throw new ArgumentOutOfRangeException(); } break; case PortType.Execution: if (portModel.NodeModel is LoopStackModel loopStack && portModel.Direction == Direction.Input) { if (stackModel != null) { store.Dispatch(new CreateInsertLoopNodeAction( portModel, stackModel, index, loopStack, edgesToDelete, groupModel)); } } else { store.Dispatch(new CreateNodeFromExecutionPortAction( portModel, position, edgesToDelete, groupModel)); } break;
public RenameGroupNodeAction(IGroupNodeModel groupNodeModel, string newName) { GroupNodeModel = groupNodeModel; NewName = newName; }
public AddToGroupNodeAction(IGroupNodeModel groupNodeModel, Vector2 newStackPosition, params INodeModel[] nodeModels) { GroupNodeModel = groupNodeModel; NewStackPosition = newStackPosition; NodeModels = nodeModels; }
public readonly Vector2 NewStackPosition; // Position to use if we have to create a new stack with the given elements. public AddToGroupNodeAction(IGroupNodeModel groupNodeModel, params INodeModel[] nodeModels) : this(groupNodeModel, Vector2.negativeInfinity, nodeModels) { }
public CreateVariableNodesAction(List <Tuple <IVariableDeclarationModel, Vector2> > variablesToCreate, IGroupNodeModel groupModel = null, bool autoAlign = false) { VariablesToCreate = variablesToCreate; GroupModel = groupModel; AutoAlign = autoAlign; }