private void ExpendNode(RGNode node) { if (isSpawning || node == null || nowLevel > maxLevel) { return; } if (node.Data.IsVirtual) { layout.ExpendNode(node.Data.UID); var graph = DataManager.Instance.GetGraph(node.Data.parent); var nodes = graph.GetNodesByVLink(node.Data.vName, node.Data.UID); var edges = graph.GetLinksByType(node.Data.vName); StartCoroutine(CreateNodesInspector(node.Data, nodes, edges)); } else { if (node.Expend == ExpendStatus.Disable) { return; } if (node.Expend == ExpendStatus.Closed) { DataManager.Instance.CheckGraph(node.Data.UID, ""); node.Expend = ExpendStatus.Opened; } else { layout.ShrinkNode(node); } } }
// 收缩节点 public void ShrinkNode(RGNode node) { if (node == null) { return; } node.Expend = ExpendStatus.Closed; List <RGEdge> edges = GetEdgesByTarget(node.Data.UID); for (int i = 0; i < edges.Count; i += 1) { RGNode other = edges[i].GetAnother(node.Data.UID); if (other != null && !other.Data.IsVirtual) { var count = proxy.GetLeafNodeCount(other.Data.UID); if (count < 2 && !other.Data.Pinned) { RemoveNode(other.Data.UID); RemoveEdge(edges[i].Data.UID); } else { if (edges[i].Data.offLength < 0.01f) { RemoveEdge(edges[i].Data.UID); } } } } }
public override void AddNode(RGNode node, string parent, bool add) { if (add) { allNodes.Add(node); } }
private void OnNodePinned(object data) { var uid = data as string; RGNode item = layout.GetNode(uid); if (item != null) { item.Pinned = !item.Pinned; } DFNotifyManager.SendNotify(DFNotifyType.OnUIRefresh, ""); }
private void OnNodeExpend(object data) { if (isSpawning) { return; } var uid = data as string; RGNode node = layout.GetNode(uid); ExpendNode(node); DFNotifyManager.SendNotify(DFNotifyType.OnUIRefresh, ""); }
private void OnDragStart(RGNode node) { if (node == null) { return; } ClearSelected(); node.ShowMenu = false; node.Selected = true; selectedNode = node; node.Data.isDrag = true; node.Pinned = true; }
public virtual void AddNode(RGNode node, string parent, bool add) { if (add) { node.Data.mass = 1.0f; allNodes.Add(node); } var graph = GetGraphBox(parent); if (graph == null) { graph = new GraphBox(parent); graphBoxs.Add(graph); } //graph.AddNode(node); }
/// <summary> /// 选择一个节点 /// </summary> /// <param name="gesture"></param> private void OnSimpleTap(RGNode node) { var obj = node.viewer.gameObject; if (obj == null) { layout.HighlightRelation(""); ClearSelected(); return; } if (obj.name.Contains("Menu")) { GMenuParts menu = obj.GetComponentInParent <GMenuParts>(); MenuType type = menu.SelectState(node.viewer.name); CheckMenuType(type); } else { if (node == selectedNode) { return; } ClearSelected(); selectedNode = node; //node.ShowMenu = true; node.Selected = true; layout.HighlightRelation(node.Data.UID); if (node.Data.IsVirtual) { ExpendNode(node); } else { if (CheckNextGraph(node)) { ExpendNode(node); } } if (callAction != null) { callAction.Invoke(node.Data.UID); } } }
private bool CheckNextGraph(RGNode node) { string root = MessageManager.Instance.RootPath; var expend = layout.CheckExpend(root, node); if (!expend) { return(false); } if (node.Data.entity == null) { var file = Path.Combine(node.Data.fullPath); if (File.Exists(file)) { var json = File.ReadAllText(file); var tmp = ParseUtil.ParseEntityJson(json, root); if (tmp != null) { tmp.uid = node.Data.UID; node.Data.entity = tmp; } else { node.Data.entity = new EntityInfo { uid = node.Data.UID, name = node.Data.name }; } } else { node.Data.entity = new EntityInfo { uid = node.Data.UID, name = node.Data.name }; } } node.Data.Screen = RectTransformUtility.WorldToScreenPoint(renderCamera, node.mTransform.position); // DFNotifyManager.SendNotify(DFNotifyType.OnNodeSelected, node.Data); return(true); }
private void ClearSelected() { if (selectedNode != null) { selectedNode.Data.VX = 0f; selectedNode.Data.VY = 0f; selectedNode.Data.X = selectedNode.Data.LastPosition.x; selectedNode.Data.Y = selectedNode.Data.LastPosition.y; selectedNode.Data.isDrag = false; selectedNode.Selected = false; selectedNode.ShowMenu = false; selectedNode = null; if (callAction != null) { callAction.Invoke(""); } } }
// 隐藏指定的节点 public void HideNode(RGNode node) { if (node == null) { return; } RemoveNode(node.Data.UID); List <RGEdge> edges = GetEdgesByTarget(node.Data.UID); for (int i = 0; i < edges.Count; i += 1) { RGNode other = edges[i].GetAnother(node.Data.UID); var count = proxy.GetLeafNodeCount(other.Data.UID); if (count < 2 && !other.Data.Pinned) { RemoveNode(other.Data.UID); } RemoveEdge(edges[i].Data.UID); } }
private void OnTouchNode(RGNode node, TouchPhase phase) { if (phase == TouchPhase.Began) { SwitchTouch(TouchType.Empty); } else { SwitchTouch(TouchType.Node); } if (phase == TouchPhase.Ended) { if (node.Pinned) { node.Pinned = false; } else { node.Pinned = true; } } }
// 检查节点能否展开 public bool CheckExpend(string root, RGNode node) { if (node == null) { return(false); } var path = Path.Combine(root, "graph/graph_" + node.Data.UID + ".json"); if (!File.Exists(path)) { ZLog.Warning("the file not exist that path = " + path); node.Expend = ExpendStatus.Disable; return(false); } else { if (node.Expend == ExpendStatus.Disable) { node.Expend = ExpendStatus.Closed; } return(true); } }
public RGNode CreateNode(NodeInfo info, Transform center, Transform box, float radius, string parent) { if (info == null) { return(null); } RGNode item = GetNode(info.UID); bool add = false; bool icon = File.Exists(info.avatar); if (item == null) { GNodeParts view = null; if (info.IsVirtual || !icon) { view = ZAssetController.Instance.ActivateAsset <GNodeParts>(box); } else { view = ZAssetController.Instance.ActivateAsset <GNodePersonParts>(box); } item = new RGNode(info, view); var pos = GetRandomPosition(center, radius); item.Data.LastPosition = pos; item.Data.X = pos.x; item.Data.Y = pos.y; item.distPos = new Vector2(pos.x, pos.y); item.mTransform.localPosition = pos; add = true; } AddNode(item, parent, add); if (icon) { ZImageController.Instance.Load(info.UID, info.avatar, OnImageLoad); } return(item); }
public override void AddNode(RGNode node, string parent, bool add) { base.AddNode(node, parent, add); k = Mathf.Sqrt(1920f * 1080f / (float)allNodes.Count); }
private void OnDragEnd(RGNode node) { ClearSelected(); }