//TODO: review later, probaly delete //public List<PathNode> MountTreeByType(List<PathNode> pnCollection) //{ // List<PathNode> tree = new List<PathNode>(); // List<PathNode> roots = pnCollection.Where(pn => pn.Parent_Id == Guid.Empty).ToList(); // tree.AddRange(roots); // foreach (PathNode root in roots) // { // foreach (PathNode child in pnCollection.Where(pn => pn.Parent_Id == root.Id).ToList()) // { // if (tree.Any(pn => pn.Type == child.Type)) // continue; // tree.Add(child); // PathNode parent = tree // } // } //} public List <ElementModel.Element> GetTaskVisualization(string id) { ElementModel model = new ElementModel(); List <PathNode> pnCollection = new List <PathNode>(); List <Breakpoint> bCollection = new List <Breakpoint>(); using (SwarmData context = new SwarmData()) { var sessionFilter = context.Sessions.Where(s => s.Id.ToString() == id).Select(s => new { TaskName = s.TaskName, ProjectName = s.ProjectName }).FirstOrDefault(); Guid[] sessionIds = context.Sessions.Where(s => s.TaskName == sessionFilter.TaskName && s.ProjectName == sessionFilter.ProjectName).Select(s => s.Id).ToArray(); pnCollection = context.PathNodes.Where(pn => sessionIds.Contains(pn.Session.Id)).GroupBy(pn => pn.Type).Select(pn => pn.FirstOrDefault()).OrderBy(pn => pn.Created).ToList(); bCollection = context.Breakpoints.Where(b => sessionIds.Contains(b.Session.Id)).GroupBy(b => new { b.Namespace, b.Type, b.LineNumber }).Select(b => b.FirstOrDefault()).ToList(); } NodeColor nodeColor = new NodeColor(bCollection); //load nodes foreach (PathNode pn in pnCollection) { model.ElementCollection.Add(new ElementModel.Element() { data = new ElementModel.Data() { id = pn.Id.ToString(), parent_id = model.ElementCollection.Count() == 0 ? null : model.ElementCollection.Last().data.id, method = pn.Type + " - " + bCollection.Where(b => b.Type == pn.Type).Count().ToString(), size = bCollection.Where(b => b.Type == pn.Type).Count() + 10, color = nodeColor.GetColor(pn.Type) } }); } //load edges List <ElementModel.Element> edgesCollection = new List <ElementModel.Element>(); foreach (ElementModel.Element element in model.ElementCollection) { if (String.IsNullOrWhiteSpace(element.data.parent_id)) { continue; } edgesCollection.Add(new ElementModel.Element() { data = new ElementModel.Data() { id = element.data.id + "-" + element.data.id, source = element.data.parent_id, target = element.data.id } }); } model.ElementCollection.AddRange(edgesCollection); return(model.ElementCollection); }
public void ChangeColor() { SwitchColor(); if (mode == DemonstrationMode.Volume) { var modelRenderer = model.transform.GetChild(0).GetComponent <Renderer>(); modelRenderer.material.SetColor("_Color", NodeColor.GetColor(nodeColor)); } else if (mode == DemonstrationMode.Flat) { var modelRenderer = model.transform.GetChild(0).GetChild(0).GetComponent <SpriteRenderer>(); modelRenderer.material.SetColor("_Color", NodeColor.GetColor(nodeColor)); } }
private void SetupFlatNode() { // loading the model depending on the chosen shape switch (Shape.GetFlatShape(shapeType)) { case Shape.FlatShape.Circle: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Circle", typeof(GameObject))); break; case Shape.FlatShape.Rectangle: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Rectangle", typeof(GameObject))); break; case Shape.FlatShape.Ellipse: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Ellipse", typeof(GameObject))); break; } // make instantiated model be child of the node object model.transform.SetParent(gameObject.transform, false); // stretching the model depending on the chosen size model.transform.localScale *= size; // changing the color depending on the chosen color var modelRenderer = model.transform.GetChild(0).GetChild(0).GetComponent <SpriteRenderer>(); modelRenderer.material.SetColor("_Color", NodeColor.GetColor(nodeColor)); // changing transparency if it is preview if (transform.parent != null && transform.parent.GetComponent <MindMap>().isPreview) { modelRenderer.material.color = new Color32(NodeColor.GetColor(nodeColor).r, NodeColor.GetColor(nodeColor).g, NodeColor.GetColor(nodeColor).b, 127); } // set the text on the shape model.transform.GetChild(0).GetChild(1).GetComponent <TextMesh>().text = text; // moving the model upward to place it on the surface model.transform.position += new Vector3(0, model.transform.GetChild(0).localScale.y / 2, 0); }
private void SetupVolumeNode() { // loading the model depending on the chosen shape switch (Shape.GetVolumeShape(shapeType)) { case Shape.VolumeShape.Sphere: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Sphere", typeof(GameObject))); break; case Shape.VolumeShape.Parallelopipedon: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Parallelopipedon", typeof(GameObject))); break; case Shape.VolumeShape.Capsule: model = Instantiate((GameObject)Resources.Load("Prefabs/Shapes/Capsule", typeof(GameObject))); break; } // make instantiated model be child of the node object model.transform.SetParent(gameObject.transform, false); // stretching the model depending on the chosen size model.transform.localScale *= size; // changing the color depending on the chosen color var modelRenderer = model.transform.GetChild(0).GetComponent <Renderer>(); modelRenderer.material.SetColor("_Color", NodeColor.GetColor(nodeColor)); // changing transparency if it is preview if (transform.parent != null && transform.parent.GetComponent <MindMap>().isPreview) { modelRenderer.material.color = new Color32(NodeColor.GetColor(nodeColor).r, NodeColor.GetColor(nodeColor).g, NodeColor.GetColor(nodeColor).b, 127); } // moving the model upward to place it on the surface model.transform.position += new Vector3(0, model.transform.GetChild(0).localScale.y / 2, 0); }