Esempio n. 1
0
        public void AddVertex(GraphApp app, GraphAppGUI appGUI, Point p)
        {
            Vertex v = app.AddVertex();

            GraphPanel gp = appGUI.CurrentGraphPanel;
            gp.AddVertex(v, p);
        }
Esempio n. 2
0
        public void DeleteSelection(GraphApp app)
        {
            List <GUIEdge> localEdges = new List <GUIEdge>();

            foreach (ISelectable i in currentSelection)
            {
                GUIVertex gv = i as GUIVertex;
                if (gv != null)
                {
                    RemoveVertex(gv, app);
                    foreach (GUIEdge ge in gv.GetEdges())
                    {
                        localEdges.Add(ge);
                    }
                    continue;
                }

                GUIEdge e = i as GUIEdge;
                if (e != null)
                {
                    RemoveEdge(e, app);
                    continue;
                }
            }

            foreach (GUIEdge connected in localEdges)
            {
                RemoveEdge(connected, app);
            }

            Refresh();
        }
Esempio n. 3
0
 public GraphAppViewModel(RevitToGraphPublisher pubisher, GraphApp app)
 {
     _publishToGraphCommand = new Command(PublishToGraph);
     _cancelCommand         = new Command(Close);
     _publisher             = pubisher;
     _settings = app.SessionSettings;
     _app      = app;
 }
Esempio n. 4
0
        public void AddVertex(GraphApp app, GraphAppGUI appGUI, Point p)
        {
            Vertex v = app.AddVertex();

            GraphPanel gp = appGUI.CurrentGraphPanel;

            gp.AddVertex(v, p);
        }
Esempio n. 5
0
        public GraphAppGUI()
        {
            InitializeComponent();
            Output.Initialize(textBox1);

            app = new GraphApp();

            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(Vertex)));
            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(Edge)));
            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(FlowEdge)));
        }
Esempio n. 6
0
        private int graphCounter; //Counter which keeps track of how many graphs we have

        #endregion Fields

        #region Constructors

        public GraphAppGUI()
        {
            InitializeComponent();
            Output.Initialize(textBox1);

            app = new GraphApp();

            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(Vertex)));
            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(Edge)));
            AppTool.SelectTool.AddFilter(new SelectionFilter(typeof(FlowEdge)));
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        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;
            }
        }
Esempio n. 9
0
        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;
            }
        }
Esempio n. 10
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }
Esempio n. 11
0
 private void RemoveEdge(GUIEdge e, GraphApp app)
 {
     app.RemoveEdge(e.Edge);
     edges.Remove(e);
     selectables.Remove(e);
 }
Esempio n. 12
0
        public void DeleteSelection(GraphApp app)
        {
            List<GUIEdge> localEdges = new List<GUIEdge>();

            foreach (ISelectable i in currentSelection)
            {
                GUIVertex gv = i as GUIVertex;
                if (gv != null)
                {
                    RemoveVertex(gv, app);
                    foreach (GUIEdge ge in gv.GetEdges())
                    {
                        localEdges.Add(ge);
                    }
                    continue;
                }

                GUIEdge e = i as GUIEdge;
                if (e != null)
                {
                    RemoveEdge(e, app);
                    continue;
                }
            }

            foreach (GUIEdge connected in localEdges)
            {
                RemoveEdge(connected, app);
            }

            Refresh();
        }
Esempio n. 13
0
 private void RemoveEdge(GUIEdge e, GraphApp app)
 {
     app.RemoveEdge(e.Edge);
     edges.Remove(e);
     selectables.Remove(e);
 }
Esempio n. 14
0
 private void RemoveVertex(GUIVertex gv, GraphApp app)
 {
     app.RemoveVertex(gv.Vertex);
     verts.Remove(gv);
     selectables.Remove(gv);
 }