コード例 #1
0
ファイル: NodeGraphView.cs プロジェクト: ywscr/NodeGraph
        /// <summary>
        /// SERIALIZATION: Creates a NodeGraphView from a Serialized XML Copy
        /// </summary>
        /// <param name="p_XmlTreeNode">the parent XmlTreeNode used in serialization</param>
        /// <param name="p_Panel">the panel that will contain this NodeGraphView</param>
        public NodeGraphView(XmlTreeNode p_XmlTreeNode, NodeGraphPanel p_Panel)
        {
            System.Globalization.CultureInfo v_IntlCultureInfo = new System.Globalization.CultureInfo("en-us");
            this.m_oPanel = p_Panel;
            this.ViewX    = int.Parse(p_XmlTreeNode.m_attributes["ViewX"]);
            this.ViewY    = int.Parse(p_XmlTreeNode.m_attributes["ViewY"]);
            this.ViewZoom = float.Parse(p_XmlTreeNode.m_attributes["ViewZoom"], v_IntlCultureInfo);


            this.m_NodeCollection = new List <NodeGraphNode>();

            XmlTreeNode v_NodesXml = p_XmlTreeNode.GetFirstChild("NodeGraphNodeCollection");

            foreach (XmlTreeNode i_ChildNode in v_NodesXml.m_childNodes)
            {
                this.m_NodeCollection.Add(NodeGraphNode.DeserializeFromXML(i_ChildNode, this));
            }


            this.m_Links = new List <NodeGraphLink>();

            XmlTreeNode v_LinksXml = p_XmlTreeNode.GetFirstChild("NodeGraphLinkCollection");

            foreach (XmlTreeNode i_ChildLink in v_LinksXml.m_childNodes)
            {
                this.m_Links.Add(NodeGraphLink.DeserializeFromXML(i_ChildLink, this));
            }

            this.m_SelectedItems = new List <NodeGraphNode>();
        }
コード例 #2
0
ファイル: NodeGraphData.cs プロジェクト: RyanWangTHU/ccv2
 /// <summary>
 /// Creates a new NodeGraphInvalidData based on an Invalid node and given an Error message
 /// </summary>
 /// <param name="p_InvalidNode">the Invalid node</param>
 /// <param name="p_ErrorMessage">the Error message</param>
 public NodeGraphInvalidData(NodeGraphNode p_InvalidNode, string p_ErrorMessage) : base()
 {
     this.m_lErrorMessages = new List<string>();
     this.m_lInvalidNodes = new List<NodeGraphNode>();
     this.AddInvalidNode(p_InvalidNode, p_ErrorMessage);
     
 }
コード例 #3
0
ファイル: NodeGraphConnector.cs プロジェクト: zgsxwsdxg/ccv2
 /// <summary>
 /// Creates a new NodeGraphConnector, given a name, a parent container, type and index
 /// </summary>
 /// <param name="p_Name">The display name of the connector</param>
 /// <param name="p_parent">Reference to the parent NodeGraphNode</param>
 /// <param name="p_ConnectorType">Type of the connector (input/output)</param>
 /// <param name="p_ConnectorIndex">Connector Index</param>
 public NodeGraphConnector(string p_Name, NodeGraphNode p_parent, ConnectorType p_ConnectorType, int p_ConnectorIndex)
 {
     this.m_Name            = p_Name;
     this.m_oParentNode     = p_parent;
     this.m_oView           = p_parent.ParentView;
     this.m_oConnectorType  = p_ConnectorType;
     this.m_iConnectorIndex = p_ConnectorIndex;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new NodeGraphConnector, given a name, a parent container, type and index
 /// </summary>
 /// <param name="p_Name">The display name of the connector</param>
 /// <param name="p_parent">Reference to the parent NodeGraphNode</param>
 /// <param name="p_ConnectorType">Type of the connector (input/output)</param>
 /// <param name="p_ConnectorIndex">Connector Index</param>
 public NodeGraphConnector(string p_Name, NodeGraphNode p_parent, ConnectorType p_ConnectorType,int p_ConnectorIndex)
 {
     this.m_Name = p_Name;
     this.m_oParentNode = p_parent;
     this.m_oView = p_parent.ParentView;
     this.m_oConnectorType = p_ConnectorType;
     this.m_iConnectorIndex = p_ConnectorIndex;
 }
コード例 #5
0
 public NodeGraphConnector(EndpointDescriptor descriptor, NodeGraphNode p_parent, ConnectorType type)
 {
     this.m_Name = String.Empty;
     this.m_oParentNode = p_parent;
     this.m_oView = p_parent.ParentView;
     this.m_oConnectorType = type;
     this.m_iConnectorIndex = descriptor.index;
 }
コード例 #6
0
 /// <summary>
 /// Adds an invalid node to the current NodeGraphInvalidData
 /// </summary>
 /// <param name="p_InvalidNode">the Invalid node</param>
 /// <param name="p_ErrorMessage">the Error message</param>
 public void AddInvalidNode(NodeGraphNode p_InvalidNode, string p_ErrorMessage)
 {
     if (!this.m_lInvalidNodes.Contains(p_InvalidNode))
     {
         this.m_lInvalidNodes.Add(p_InvalidNode);
     }
     this.m_lErrorMessages.Add(p_InvalidNode.Name + ":" + p_ErrorMessage);
 }
コード例 #7
0
        public NodeGraphConnector(EndpointDescriptor descriptor, NodeGraphView p_view, ConnectorType type)
        {
            this.m_Name = String.Empty;
            this.m_oParentNode = null;

            this.m_oView = p_view;
            this.m_oConnectorType = type;
            this.m_iConnectorIndex = descriptor.index;
        }
コード例 #8
0
ファイル: NodeGraphConnector.cs プロジェクト: ywscr/NodeGraph
 /// <summary>
 /// Creates a new NodeGraphConnector, given a name, a parent container, type, index and DataType
 /// </summary>
 /// <param name="p_Name">The display name of the connector</param>
 /// <param name="p_parent">Reference to the parent NodeGraphNode</param>
 /// <param name="p_ConnectorType">Type of the connector (input/output)</param>
 /// <param name="p_ConnectorIndex">Connector Index</param>
 public NodeGraphConnector(string p_Name, NodeGraphNode p_parent, ConnectorType p_ConnectorType, int p_ConnectorIndex, string p_NodeGraphDataTypeName)
 {
     this.m_Name            = p_Name;
     this.m_oParentNode     = p_parent;
     this.m_oView           = p_parent.ParentView;
     this.m_oConnectorType  = p_ConnectorType;
     this.m_iConnectorIndex = p_ConnectorIndex;
     this.m_oDataType       = p_parent.ParentView.KnownDataTypes[p_NodeGraphDataTypeName];
 }
コード例 #9
0
ファイル: NodeGraphConnector.cs プロジェクト: zgsxwsdxg/ccv2
        public NodeGraphConnector(EndpointDescriptor descriptor, NodeGraphView p_view, ConnectorType type)
        {
            this.m_Name        = String.Empty;
            this.m_oParentNode = null;

            this.m_oView           = p_view;
            this.m_oConnectorType  = type;
            this.m_iConnectorIndex = descriptor.index;
        }
コード例 #10
0
ファイル: NodeGraphConnector.cs プロジェクト: johang88/triton
 /// <summary>
 /// Creates a new NodeGraphConnector, given a name, a parent container, type and index
 /// </summary>
 /// <param name="p_Name">The display name of the connector</param>
 /// <param name="p_parent">Reference to the parent NodeGraphNode</param>
 /// <param name="p_ConnectorType">Type of the connector (input/output)</param>
 /// <param name="p_ConnectorIndex">Connector Index</param>
 public NodeGraphConnector(string p_Name, NodeGraphNode p_parent, ConnectorType p_ConnectorType, int p_ConnectorIndex)
 {
     this.m_Name = p_Name;
     this.m_oParentNode = p_parent;
     this.m_oView = p_parent.ParentView;
     this.m_oConnectorType = p_ConnectorType;
     this.m_iConnectorIndex = p_ConnectorIndex;
     this.m_oDataType = p_parent.ParentView.KnownDataTypes["Generic"];
 }
コード例 #11
0
ファイル: NodeGraphView.cs プロジェクト: ywscr/NodeGraph
 /// <summary>
 /// Returns the Node Index of the NodeGraphNode in this view's current selection
 /// </summary>
 /// <param name="p_Node"></param>
 /// <returns></returns>
 public int GetSelectionNodeIndex(NodeGraphNode p_Node)
 {
     for (int i = 0; i < this.m_SelectedItems.Count; i++)
     {
         if (this.m_SelectedItems[i] == p_Node)
         {
             return(i);
         }
     }
     return(-1);
 }
コード例 #12
0
ファイル: NodeGraphView.cs プロジェクト: ywscr/NodeGraph
 /// <summary>
 /// Returns the Node Index of the NodeGraphNode in this view's collection
 /// </summary>
 /// <param name="p_Node"></param>
 /// <returns></returns>
 public int GetNodeIndex(NodeGraphNode p_Node)
 {
     for (int i = 0; i < this.m_NodeCollection.Count; i++)
     {
         if (this.m_NodeCollection[i] == p_Node)
         {
             return(i);
         }
     }
     return(-1);
 }
コード例 #13
0
ファイル: NodeGraphView.cs プロジェクト: ywscr/NodeGraph
        /// <summary>
        /// CLIPBOARD: If contains a NodeGraphClipboard.xml, deserializes and add nodes to current view.
        /// </summary>
        public void PasteSelectionFromClipBoard()
        {
            if (Clipboard.ContainsFileDropList())
            {
                if (Clipboard.GetFileDropList().Contains(Path.GetTempPath() + "NodeGraphClipboard.xml"))
                {
                    XmlTree     v_Contents     = XmlTree.FromFile(Path.GetTempPath() + "NodeGraphClipboard.xml");
                    XmlTreeNode v_ContentsRoot = v_Contents.m_rootNode;
                    XmlTreeNode v_NodesRoot    = v_ContentsRoot.GetFirstChild("Nodes");
                    XmlTreeNode v_LinksRoot    = v_ContentsRoot.GetFirstChild("Links");

                    int PreviousNodeCount = this.m_NodeCollection.Count;

                    NodeGraphNode v_CurrentNode;

                    foreach (XmlTreeNode i_Node in v_NodesRoot.m_childNodes)
                    {
                        v_CurrentNode    = NodeGraphNode.DeserializeFromXML(i_Node, this);
                        v_CurrentNode.X += 10;
                        v_CurrentNode.Y += 10;
                        v_CurrentNode.UpdateHitRectangle();
                        this.NodeCollection.Add(v_CurrentNode);
                    }


                    int v_InId, v_InConnectorIdx, v_OutId, v_OutConnectorIdx;

                    foreach (XmlTreeNode i_Link in v_LinksRoot.m_childNodes)
                    {
                        v_InId            = int.Parse(i_Link.m_attributes["InputNodeId"]);
                        v_InConnectorIdx  = int.Parse(i_Link.m_attributes["InputNodeConnectorIdx"]);
                        v_OutId           = int.Parse(i_Link.m_attributes["OutputNodeId"]);
                        v_OutConnectorIdx = int.Parse(i_Link.m_attributes["OutputNodeConnectorIdx"]);


                        // Relinking
                        this.m_Links.Add(new NodeGraphLink(
                                             // P_INPUT
                                             this.m_NodeCollection[PreviousNodeCount + v_InId].Connectors[v_InConnectorIdx],
                                             // P_OUTPUT
                                             this.m_NodeCollection[PreviousNodeCount + v_OutId].Connectors[v_OutConnectorIdx],
                                             // CONNECTOR TYPE
                                             this.m_NodeCollection[PreviousNodeCount + v_InId].Connectors[v_InConnectorIdx].DataType
                                             ));
                    }
                }
                ParentPanel.Refresh();
            }
        }
コード例 #14
0
        /// <summary>
        /// SERIALIZATION: Creates a XML Serialized copy of the link
        /// </summary>
        /// <param name="p_XmlParentTreeNode"></param>
        /// <returns></returns>
        public XmlTreeNode SerializeToXML(XmlTreeNode p_XmlParentTreeNode)
        {
            XmlTreeNode v_Out = new XmlTreeNode(SerializationUtils.GetFullTypeName(this), p_XmlParentTreeNode);

            NodeGraphView v_View       = Input.Parent.ParentView;
            NodeGraphNode v_InputNode  = Input.Parent;
            NodeGraphNode v_OutputNode = Output.Parent;

            v_Out.AddParameter("InputNodeId", v_View.GetNodeIndex(v_InputNode).ToString());
            v_Out.AddParameter("OutputNodeId", v_View.GetNodeIndex(v_OutputNode).ToString());
            v_Out.AddParameter("InputNodeConnectorIdx", v_InputNode.GetConnectorIndex(Input).ToString());
            v_Out.AddParameter("OutputNodeConnectorIdx", v_OutputNode.GetConnectorIndex(Output).ToString());

            return(v_Out);
        }
コード例 #15
0
ファイル: NodeGraphConnector.cs プロジェクト: zgsxwsdxg/ccv2
        public NodeGraphConnector(EndpointDescriptor descriptor, NodeGraphNode p_parent, ConnectorType type)
        {
            this.m_Name = String.Empty;
            if (p_parent != null)
            {
                this.m_oParentNode = p_parent;
            }
            else
            {
                this.m_oParentNode = null;
            }

            this.m_oView           = p_parent.ParentView;
            this.m_oConnectorType  = type;
            this.m_iConnectorIndex = descriptor.index;
        }
コード例 #16
0
ファイル: NodeGraphView.cs プロジェクト: zgsxwsdxg/ccv2
        /// <summary>
        /// SERIALIZATION: Creates a NodeGraphView from a Pipeline Descriptor
        /// </summary>
        /// <param name="p_Pipeline">Pipeline descriptor</param>
        /// <param name="p_Panel">the panel that will contain this NodeGraphView</param>
        public NodeGraphView(PipelineDescriptor p_Pipeline, NodeGraphPanel p_Panel)
        {
            //System.Globalization.CultureInfo v_IntlCultureInfo = new System.Globalization.CultureInfo("en-us");
            this.m_oPanel = p_Panel;
            this.ViewX    = 0;
            this.ViewY    = 0;
            this.ViewZoom = 1.0f;

            this.m_NodeCollection = new List <NodeGraphNode>();

            foreach (var module in p_Pipeline.modules)
            {
                this.m_NodeCollection.Add(NodeGraphNode.FromModuleDescriptor(module, this));
            }

            m_NodeConnectorCollection = new List <NodeGraphConnector>();

            foreach (var endpoint in p_Pipeline.inputEndpoints)
            {
                this.m_NodeConnectorCollection.Add(new NodeGraphConnector(endpoint, this, ConnectorType.InputConnector));
            }

            foreach (var endpoint in p_Pipeline.outputEndpoints)
            {
                this.m_NodeConnectorCollection.Add(new NodeGraphConnector(endpoint, this, ConnectorType.OutputConnector));
            }

            this.m_Links = new List <NodeGraphLink>();

            foreach (var connection in p_Pipeline.connections)
            {
                this.m_Links.Add(NodeGraphLink.FromConnectionDescriptor(connection, this));
            }

            for (int i = 0; i < this.m_NodeCollection.Count; i++)
            {
                //! TODO : normal algorythm for module placement
                this.m_NodeCollection[i].X = i * 100;
                this.m_NodeCollection[i].Y = i * 100;
                this.m_NodeCollection[i].UpdateHitRectangle();
            }

            this.m_SelectedItems = new List <NodeGraphNode>();
        }
コード例 #17
0
ファイル: NodeGraphData.cs プロジェクト: RyanWangTHU/ccv2
 /// <summary>
 /// Adds an invalid node to the current NodeGraphInvalidData
 /// </summary>
 /// <param name="p_InvalidNode">the Invalid node</param>
 /// <param name="p_ErrorMessage">the Error message</param>
 public void AddInvalidNode(NodeGraphNode p_InvalidNode,  string p_ErrorMessage)
 {
     if(!this.m_lInvalidNodes.Contains(p_InvalidNode)) this.m_lInvalidNodes.Add(p_InvalidNode);
     this.m_lErrorMessages.Add(p_InvalidNode.Name + ":" + p_ErrorMessage);
 }
コード例 #18
0
ファイル: NodeGraphPanel.cs プロジェクト: shalstvedt/client
        /// <summary>
        /// Adds a node to the current NodeGraphView
        /// </summary>
        /// <param name="p_Node"></param>
        public void AddNode(NodeGraphNode p_Node)
        {
            this.View.NodeCollection.Add(p_Node);

            this.Refresh();
        }
コード例 #19
0
ファイル: NodeGraphView.cs プロジェクト: johang88/triton
 /// <summary>
 /// Returns the Node Index of the NodeGraphNode in this view's current selection
 /// </summary>
 /// <param name="p_Node"></param>
 /// <returns></returns>
 public int GetSelectionNodeIndex(NodeGraphNode p_Node)
 {
     for (int i = 0; i < this.m_SelectedItems.Count; i++)
     {
         if (this.m_SelectedItems[i] == p_Node) return i;
     }
     return -1;
 }
コード例 #20
0
ファイル: NodeGraphView.cs プロジェクト: johang88/triton
 /// <summary>
 /// Returns the Node Index of the NodeGraphNode in this view's collection
 /// </summary>
 /// <param name="p_Node"></param>
 /// <returns></returns>
 public int GetNodeIndex(NodeGraphNode p_Node)
 {
     for (int i = 0; i < this.m_NodeCollection.Count; i++)
     {
         if (this.m_NodeCollection[i] == p_Node) return i;
     }
     return -1;
 }
コード例 #21
0
 /// <summary>
 /// Creates a new NodeGraphInvalidData based on an Invalid node and given an Error message
 /// </summary>
 /// <param name="p_InvalidNode">the Invalid node</param>
 /// <param name="p_ErrorMessage">the Error message</param>
 public NodeGraphInvalidData(NodeGraphNode p_InvalidNode, string p_ErrorMessage) : base()
 {
     this.m_lErrorMessages = new List <string>();
     this.m_lInvalidNodes  = new List <NodeGraphNode>();
     this.AddInvalidNode(p_InvalidNode, p_ErrorMessage);
 }