public void AddVertex(GraphApp app, GraphAppGUI appGUI, Point p) { Vertex v = app.AddVertex(); GraphPanel gp = appGUI.CurrentGraphPanel; gp.AddVertex(v, p); }
public void Begin(GraphAppGUI appGUI, Point p) { if (HasBegun) { return; } isFlowNetwork = false; GraphPanel gp = appGUI.CurrentGraphPanel; isFlowNetwork = (gp.Graph as FlowNetwork) != null; List<GUIVertex> verts = gp.Vertices; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { startVert = v; Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label); HasBegun = true; return; } } startVert = null; HasBegun = false; Console.WriteLine("Edge tool selected null"); }
public void Begin(GraphAppGUI appGUI, Point p) { if (HasBegun) { return; } isFlowNetwork = false; GraphPanel gp = appGUI.CurrentGraphPanel; isFlowNetwork = (gp.Graph as FlowNetwork) != null; List <GUIVertex> verts = gp.Vertices; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { startVert = v; Console.WriteLine("Edge tool selected vertex " + v.Vertex.Label); HasBegun = true; return; } } startVert = null; HasBegun = false; Console.WriteLine("Edge tool selected null"); }
public void AddVertex(GraphApp app, GraphAppGUI appGUI, Point p) { Vertex v = app.AddVertex(); GraphPanel gp = appGUI.CurrentGraphPanel; gp.AddVertex(v, p); }
public void EndSelect(GraphApp app, GraphAppGUI appGUI, Point p, bool shiftHeld) { Console.WriteLine("Selection end: " + p.ToString()); Started = false; endPoint = p; Rectangle selectionRect = getSelectionRectangle(startPoint, endPoint); GraphPanel gp = appGUI.CurrentGraphPanel; if (!shiftHeld) { gp.Deselect(); } List <ISelectable> selectables = gp.Selectables; int selectTotal = 0; foreach (ISelectable s in selectables) { if (s.Intersects(selectionRect)) { bool filterPass = false; foreach (SelectionFilter filter in filters) { if (filter.PassesFilter(s.GetItem())) { filterPass = true; } } if (!filterPass) { continue; } gp.Select(s); s.Select(); selectTotal++; Console.WriteLine("Selected " + s.ToString()); } } if (selectTotal == 0) { Console.WriteLine("Selected nothing"); gp.Deselect(); } gp.Refresh(); }
public void EndSelect(GraphApp app, GraphAppGUI appGUI, Point p, bool shiftHeld) { Console.WriteLine("Selection end: " + p.ToString()); Started = false; endPoint = p; Rectangle selectionRect = getSelectionRectangle(startPoint, endPoint); GraphPanel gp = appGUI.CurrentGraphPanel; if (!shiftHeld) { gp.Deselect(); } List<ISelectable> selectables = gp.Selectables; int selectTotal = 0; foreach (ISelectable s in selectables) { if (s.Intersects(selectionRect)) { bool filterPass = false; foreach (SelectionFilter filter in filters) { if (filter.PassesFilter(s.GetItem())) { filterPass = true; } } if (!filterPass) { continue; } gp.Select(s); s.Select(); selectTotal++; Console.WriteLine("Selected " + s.ToString()); } } if (selectTotal == 0) { Console.WriteLine("Selected nothing"); gp.Deselect(); } gp.Refresh(); }
public void End(GraphApp app, GraphAppGUI appGUI, Point p) { if (!HasBegun) { return; } GraphPanel gp = appGUI.CurrentGraphPanel; List<GUIVertex> verts = gp.Vertices; bool foundVert = false; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { endVert = v; Console.WriteLine("Edge tool ended on vertex " + v.Vertex.Label); foundVert = true; //Add vertex if (isFlowNetwork) { FlowEdge fe = app.AddFlowEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, fe); } else { //Change to add two edges, for both directions Edge e = app.AddEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, e); } break; } } HasBegun = false; if (!foundVert) { startVert = null; endVert = null; return; } }
public void End(GraphApp app, GraphAppGUI appGUI, Point p) { if (!HasBegun) { return; } GraphPanel gp = appGUI.CurrentGraphPanel; List <GUIVertex> verts = gp.Vertices; bool foundVert = false; foreach (GUIVertex v in verts) { if (GeometryHelper.Intersects(p, new Circle(v.Pos, v.Radius))) { endVert = v; Console.WriteLine("Edge tool ended on vertex " + v.Vertex.Label); foundVert = true; //Add vertex if (isFlowNetwork) { FlowEdge fe = app.AddFlowEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, fe); } else { //Change to add two edges, for both directions Edge e = app.AddEdge(startVert.Vertex, endVert.Vertex); gp.AddEdge(startVert, endVert, e); } break; } } HasBegun = false; if (!foundVert) { startVert = null; endVert = null; return; } }