예제 #1
0
 public CreateNodeFromExecutionPortAction(IPortModel portModel, Vector2 position,
                                          IEnumerable <IEdgeModel> edgesToDelete = null, IGroupNodeModel groupModel = null)
 {
     PortModel     = portModel;
     Position      = position;
     EdgesToDelete = edgesToDelete ?? Enumerable.Empty <IEdgeModel>();
     GroupModel    = groupModel;
 }
예제 #2
0
 public CreateGroupedNodeFromSearcherAction(IGraphModel graphModel, IGroupNodeModel groupNodeModel,
                                            Vector2 position, GraphNodeModelSearcherItem selectedItem)
 {
     GraphModel     = graphModel;
     GroupNodeModel = groupNodeModel;
     Position       = position;
     SelectedItem   = selectedItem;
 }
예제 #3
0
 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;
 }
예제 #4
0
파일: Port.cs 프로젝트: substence/UnityVS3
        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);
        }
예제 #5
0
 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;
 }
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
        static void AddToGroup(IEnumerable <INodeModel> nodes, IGroupNodeModel groupModel)
        {
            if (groupModel == null)
            {
                return;
            }

            IEnumerable <INodeModel> nodeModels = nodes.ToList();

            ((GroupNodeModel)groupModel).AddNodes(nodeModels);
        }
예제 #9
0
        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;
        }
예제 #10
0
파일: Port.cs 프로젝트: substence/UnityVS3
        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;
예제 #11
0
 public RenameGroupNodeAction(IGroupNodeModel groupNodeModel, string newName)
 {
     GroupNodeModel = groupNodeModel;
     NewName        = newName;
 }
예제 #12
0
 public AddToGroupNodeAction(IGroupNodeModel groupNodeModel, Vector2 newStackPosition, params INodeModel[] nodeModels)
 {
     GroupNodeModel   = groupNodeModel;
     NewStackPosition = newStackPosition;
     NodeModels       = nodeModels;
 }
예제 #13
0
        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)
        {
        }
예제 #14
0
 public CreateVariableNodesAction(List <Tuple <IVariableDeclarationModel, Vector2> > variablesToCreate, IGroupNodeModel groupModel = null, bool autoAlign = false)
 {
     VariablesToCreate = variablesToCreate;
     GroupModel        = groupModel;
     AutoAlign         = autoAlign;
 }