예제 #1
0
        public virtual void AddStackedNode(INodeModel nodeModelInterface, int index)
        {
            if (!AcceptNode(nodeModelInterface.GetType()))
            {
                return;
            }

            var nodeModel = (NodeModel)nodeModelInterface;

            nodeModel.AssetModel       = AssetModel;
            nodeModel.ParentStackModel = this;

            if (index == -1)
            {
                m_StackedNodeModels.Add(nodeModel);
            }
            else
            {
                m_StackedNodeModels.Insert(index, nodeModel);
            }

            VSGraphModel vsGraphModel = (VSGraphModel)GraphModel;

            // We need to register before calling TransferConnections(), as edge models rely on the guid to node mapping to resolve ports
            vsGraphModel.UnregisterNodeGuid(nodeModel.Guid);
            vsGraphModel.RegisterNodeGuid(nodeModel);

            bool insertedLast = index == -1 || m_StackedNodeModels.Count == 1 || index == m_StackedNodeModels.Count;

            if (insertedLast && ModelDelegatesOutputs(nodeModelInterface))
            {
                TransferConnections(GraphModel, m_OutputPorts, OutputPorts);
            }


            vsGraphModel.LastChanges.ChangedElements.Add(nodeModel);

            // Needed to add/remove/update the return value port of the node according to the function type
            nodeModel.DefineNode();
        }
예제 #2
0
        public void AddStackedNode(INodeModel nodeModelInterface, int index)
        {
            if (!AcceptNode(nodeModelInterface.GetType()))
            {
                return;
            }

            var nodeModel = (NodeModel)nodeModelInterface;

            nodeModel.GraphModel       = GraphModel;
            nodeModel.ParentStackModel = this;
            if (index == -1)
            {
                m_StackedNodeModels.Add(nodeModel);
            }
            else
            {
                m_StackedNodeModels.Insert(index, nodeModel);
            }

            bool insertedLast = index == -1 || m_StackedNodeModels.Count == 1 || index == m_StackedNodeModels.Count;

            if (insertedLast && ModelDelegatesOutputs(nodeModelInterface))
            {
                TransferConnections(GraphModel, m_OutputPorts, OutputPorts);
            }
            VSGraphModel vsGraphModel = (VSGraphModel)GraphModel;

            // theor: why is that needed ?
            vsGraphModel.UnregisterNodeGuid(nodeModel.Guid);
            vsGraphModel.RegisterNodeGuid(nodeModel);

            vsGraphModel.LastChanges.ChangedElements.Add(nodeModel);

            // Needed to add/remove/update the return value port of the node according to the function type
            nodeModel.DefineNode();
        }