/// <summary> /// Constructs descriptive name of circuit item. Debugging Helper method.</summary> /// <param name="domNode">DomNode of circuit item</param> /// <returns>Descriptive name of circuit item</returns> static public string GetDomNodeName(DomNode domNode) { string result = string.Empty; if (domNode.Is <Element>()) { result = domNode.Cast <Element>().Name; } else if (domNode.Is <GroupPin>()) { result = "Group Pin : " + domNode.Cast <GroupPin>().Name; } else if (domNode.Is <Wire>()) { var connection = domNode.Cast <Wire>(); int inputPinIndex, outputPinIndex; // during undo/redo, the pin index may temporarily out of range, need to check index before call OutputPin|InputPin if (connection.IsValid(out inputPinIndex, out outputPinIndex)) { result = "Edge from " + connection.OutputElement.Name + "[" + connection.OutputPin.Name + "]" + " to " + connection.InputElement.Name + "[" + connection.InputPin.Name + "]"; } else { result = "Edge from " + connection.OutputElement.Name + "[" + outputPinIndex + "]" + " to " + connection.InputElement.Name + "[" + inputPinIndex + "]"; } } else if (domNode.Is <Circuit>()) { var doc = domNode.As <IDocument>(); if (doc != null && doc.Uri != null) { result = "Circuit " + Path.GetFileNameWithoutExtension(doc.Uri.LocalPath); } else { result = "Circuit " + domNode.GetId(); } } if (result == string.Empty) { result = domNode.GetId() ?? domNode.ToString(); } return(result); }
void DescibeNode(DomNode node, TreeNode parentNode) { var node_info = node.ToString(); var treeNode = new TreeNode(node_info); parentNode.Nodes.Add(treeNode); var domElt = node as DomElement; if (domElt != null) { var childCount = domElt.ChildrenCount; for (int i = 0; i < childCount; ++i) { DescibeNode(domElt.GetChildNode(i), treeNode); } } }
/// <summary> /// Performs initialization when the adapter's node is set. /// This method is called each time the adapter is connected to its underlying node. /// Typically overridden by creators of DOM adapters.</summary> protected override void OnNodeSet() { base.OnNodeSet(); Visible = true; DomNodeType domtype = this.DomNode.Type; ChildInfo inputChildInfo = domtype.GetChildInfo("input"); Mesh mesh = GetParentAs <Mesh>(); int maxoffset = -1; // get input child info. foreach (DomNode inputNode in DomNode.GetChildList(inputChildInfo)) { PrimInput pinput = new PrimInput(inputNode, mesh); if (pinput.Offset > maxoffset) { maxoffset = pinput.Offset; } if (pinput.Semantic == "VERTEX") { foreach (PrimInput vinput in mesh.VertexInputs) { PrimInput input = new PrimInput(vinput, pinput.Offset); m_inputs.Add(input); } } else { m_inputs.Add(pinput); } } m_bindingCount = maxoffset + 1; // prim type string type = DomNode.ToString(); m_primitiveType = type.Substring(type.LastIndexOf(':') + 1).ToUpper(); if (m_primitiveType == "POLYLIST") { m_primitiveType = "POLYGONS"; } // indices AttributeInfo pattrib = DomNode.Type.GetAttributeInfo("p"); m_indices = Tools.ULongToInt(GetAttribute <ulong[]>(pattrib)); // material AttributeInfo mtrlAttrib = DomNode.Type.GetAttributeInfo("material"); string mtrl = GetAttribute <string>(mtrlAttrib); Geometry geom = DomNode.Parent.Parent.Cast <Geometry>(); m_effect = geom.Effects[mtrl]; // vcount, element sizes AttributeInfo vcountAttrib = DomNode.Type.GetAttributeInfo("vcount"); if (vcountAttrib != null) { m_sizes = Tools.ULongToInt(GetAttribute <ulong[]>(vcountAttrib)); } else { m_sizes = new int[] { 3 } }; //count AttributeInfo countAttrib = DomNode.Type.GetAttributeInfo("count"); m_count = (int)GetAttribute <ulong>(countAttrib); // name AttributeInfo nameAttrib = DomNode.Type.GetAttributeInfo("name"); m_name = GetAttribute <string>(nameAttrib); }