Exemple #1
0
        private void GraphAreaExample_Setup()
        {
            // Настройки лейоута - какие алгоритмы импользуются, чтобы оптимально расположить граф
            var logicCore = new GXLogicCoreExample()
            {
                Graph = GraphExample_Setup()
            };

            logicCore.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.KK;
            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);
            ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;

            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;
            logicCore.AsyncAlgorithmCompute       = false;
            Area.LogicCore = logicCore;

            // Генерируруем граф
            Area.GenerateGraph(true, true);

            // Настройки
            Area.ShowAllEdgesArrows(false);
            Area.ShowAllEdgesLabels(false);
            zoomctrl.ZoomToFill();
        }
Exemple #2
0
        private void LogicCoreSetup(ref GraphAreaExample graphArea)
        {
            var logicCore = new GXLogicCoreExample()
            {
            };

            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;

            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);

            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;

            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            logicCore.AsyncAlgorithmCompute = false;

            graphArea.LogicCore = logicCore;
        }
        private void InitialSetup()
        {
            var logicCore = new GXLogicCoreExample();

            graph.LogicCore = logicCore;

            var layParams = new LinLogLayoutParameters {
                IterationCount = 100
            };

            logicCore.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.SimpleRandom;
            logicCore.DefaultLayoutAlgorithmParams = layParams;

            logicCore.DefaultOverlapRemovalAlgorithmParams = logicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;

            graph.MoveAnimation            = AnimationFactory.CreateMoveAnimation(MoveAnimation.Move, TimeSpan.FromMilliseconds(500));
            graph.MoveAnimation.Completed += MoveAnimation_Completed;
        }
        private void GraphAreaPcap_Setup()
        {
            //Lets create logic core and filled data graph with edges and vertices
            var logicCore = new GXLogicCoreExample()
            {
                Graph = GraphPcap_Setup()
            };

            //This property sets layout algorithm that will be used to calculate vertices positions
            //Different algorithms uses different values and some of them uses edge Weight property.
            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;
            //Now we can set parameters for selected algorithm using AlgorithmFactory property. This property provides methods for
            //creating all available algorithms and algo parameters.
            logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.KK);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            ((KKLayoutParameters)logicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;
            //Default parameters are created automaticaly when new default algorithm is set and previous params were NULL
            logicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
            logicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap   = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            logicCore.AsyncAlgorithmCompute = false;

            //Finally assign logic core to GraphArea object
            Area.LogicCore = logicCore;
        }
        private void GraphAreaExample_Setup()
        {
            //Lets create logic core and filled data graph with edges and vertices
            var LogicCore = new GXLogicCoreExample() { Graph = GraphExample_Setup() };
            //This property sets layout algorithm that will be used to calculate vertices positions
            //Different algorithms uses different values and some of them uses edge Weight property.
            LogicCore.DefaultLayoutAlgorithm = GraphX.LayoutAlgorithmTypeEnum.KK;
            //Now we can set parameters for selected algorithm using AlgorithmFactory property. This property provides methods for
            //creating all available algorithms and algo parameters.
            LogicCore.DefaultLayoutAlgorithmParams = LogicCore.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.KK);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            ((KKLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            LogicCore.DefaultOverlapRemovalAlgorithm = GraphX.OverlapRemovalAlgorithmTypeEnum.FSA;
            LogicCore.DefaultOverlapRemovalAlgorithmParams = LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            //Bundling algorithm will try to tie different edges that follows same direction to a single channel making complex graphs more appealing.
            LogicCore.DefaultEdgeRoutingAlgorithm = GraphX.EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            LogicCore.AsyncAlgorithmCompute = false;

            //Finally assign logic core to GraphArea object
            Area.LogicCore = LogicCore;// as IGXLogicCore<DataVertex, DataEdge, BidirectionalGraph<DataVertex, DataEdge>>;
        }
        private void InitialSetup()
        {
            var logicCore = new GXLogicCoreExample();
            graph.LogicCore = logicCore;

            var layParams = new LinLogLayoutParameters { IterationCount = 100 };
            logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.SimpleRandom;
            logicCore.DefaultLayoutAlgorithmParams = layParams;

            logicCore.DefaultOverlapRemovalAlgorithmParams = logicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)logicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap = 50;

            graph.MoveAnimation = AnimationFactory.CreateMoveAnimation(MoveAnimation.Move, TimeSpan.FromMilliseconds(500));
            graph.MoveAnimation.Completed += MoveAnimation_Completed;
        }
Exemple #7
0
        private void GenerateGraph(bool reset = false)
        {
            gr.Clear();
            foreach (var d in Story.Dialogs)
            {
                gr.AddVertex(new DialogVertex(d));
            }

            foreach (var v in gr.Vertices)
            {
                foreach (var o in v.Dialog.Options)
                {
                    if (!o.TargetID.IsNullOrEmpty())
                    {
                        gr.AddEdge(new DialogEdge(v, gr.Vertices.First(x => x.Dialog.ID == o.TargetID))
                        {
                            DialogOption = o
                        });
                    }
                }
            }

            if (graph.LogicCore == null)
            {
                var LogicCore = new GXLogicCoreExample()
                {
                    Graph = gr
                };
                LogicCore.DefaultLayoutAlgorithm       = LayoutAlgorithmTypeEnum.Tree;
                LogicCore.DefaultLayoutAlgorithmParams =
                    LogicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.Tree);
                ((SimpleTreeLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).Direction = LayoutDirection.LeftToRight;
                //LogicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.OneWayFSA;
                //LogicCore.DefaultOverlapRemovalAlgorithmParams = LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(OverlapRemovalAlgorithmTypeEnum.OneWayFSA);
                //LogicCore.DefaultOverlapRemovalAlgorithmParams.HorizontalGap = 50;
                //LogicCore.DefaultOverlapRemovalAlgorithmParams.VerticalGap = 50;
                LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
                LogicCore.AsyncAlgorithmCompute       = false;
                LogicCore.EdgeCurvingEnabled          = true;
                LogicCore.EnableParallelEdges         = true;
                LogicCore.ParallelEdgeDistance        = 10;

                graph.LogicCore = LogicCore;
            }

            graph.GenerateGraph(true, true);
            if (!reset && path.Length > 0 && File.Exists(path.Replace(".apstp", ".apmap")))
            {
                System.Xml.Serialization.XmlSerializer xml = new System.Xml.Serialization.XmlSerializer(typeof(List <GraphPos>));
                try
                {
                    using (var fs = File.OpenRead(path.Replace(".apstp", ".apmap")))
                        pos = xml.Deserialize(fs) as List <GraphPos>;
                    Relayout(false);
                }
                catch { }
            }
            graph.ShowAllEdgesLabels(false);
            graph.SetVerticesDrag(true, true);
            graph.SetEdgesDashStyle(EdgeDashStyle.Dash);
            foreach (var v in graph.VertexList)
            {
                v.Value.Background = v.Key.Dialog.Tag == null ? Brushes.LightGray : new SolidColorBrush(v.Key.Dialog.Tag.Color.ToMediaColor());
            }
        }
        public void DrawAllKB(FrameContainer mainFrameContainer)
        {
            try
            {
                List <Frame>  currentFrames       = mainFrameContainer.GetAllFrames();
                List <Domain> currentDomains      = mainFrameContainer.GetDomains();
                List <string> currentDomainValues = new List <string>();

                foreach (Domain domain in currentDomains)
                {
                    foreach (string value in domain.values)
                    {
                        currentDomainValues.Add(value);
                    }
                }

                EasyGraph dataGraph = new EasyGraph();//TODO: Нужно определить полем в классе.

                foreach (Frame frame in currentFrames)
                {
                    //находим корневой фрейм

                    bool isFrameInDomains = currentDomainValues.Contains(frame.name);
                    bool isFrameIsNil     = frame.isA == "null";

                    if (!isFrameInDomains && isFrameIsNil)
                    {
                        Frame nilFrame = frame;

                        DataVertex nilDataVertex = new DataVertex(nilFrame.name)
                        {
                            ID = nilFrame.Id
                        };

                        dataGraph.AddVertex(nilDataVertex);

                        DrawAllRelatedVertices(nilFrame, ref dataGraph, mainFrameContainer);
                    }
                }

                _graphArea.SetEdgesDashStyle(EdgeDashStyle.Solid);

                var logicCore = new GXLogicCoreExample()
                {
                    Graph = dataGraph
                };

                //CompoundFDP,ISOM,LinLog,
                //Sugiyama
                logicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.LinLog;

                logicCore.DefaultLayoutAlgorithmParams = logicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.LinLog);

                logicCore.DefaultOverlapRemovalAlgorithm = OverlapRemovalAlgorithmTypeEnum.FSA;

                logicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;


                logicCore.AsyncAlgorithmCompute = true;

                _graphArea.LogicCore = logicCore;

                _graphArea.GenerateGraph(true, false);
            }
            catch (Exception e)
            {
                MessageBox.Show("При отрисовке что-то пошло не так :( \n" + e.ToString());
            }
        }
Exemple #9
0
        private void UpdateTabGraphX(Solution s)
        {
            //Create data graph object
            var graph = new GraphExample();

            //Create and add vertices using some DataSource for ID's
            foreach (Node n in ModelManager.Instance.Filecvrp.LstNodes)
            {
                graph.AddVertex(new DataVertex()
                {
                    ID = n.Id, Text = n.Id.ToString()
                });
            }
            foreach (List <Node> ruta in s.BestRutas)
            {
                if (ruta.Count > 0)
                {
                    DataVertex origen  = graph.Vertices.ToList()[ModelManager.Instance.Filecvrp.IdNodeDepot - 1];
                    DataVertex destino = graph.Vertices.ToList()[ruta[0].Id - 1];
                    graph.AddEdge(new DataEdge(origen, destino));
                    for (int i = 0; i < ruta.Count - 1; i++)
                    {
                        origen  = graph.Vertices.ToList()[ruta[i].Id - 1];
                        destino = graph.Vertices.ToList()[ruta[i + 1].Id - 1];
                        graph.AddEdge(new DataEdge(origen, destino));
                    }

                    origen  = graph.Vertices.ToList()[ruta[ruta.Count - 1].Id - 1];
                    destino = graph.Vertices.ToList()[ModelManager.Instance.Filecvrp.IdNodeDepot - 1];
                    graph.AddEdge(new DataEdge(origen, destino));
                }
            }

            var LogicCore = new GXLogicCoreExample();

            LogicCore.Graph = graph;
            //This property sets layout algorithm that will be used to calculate vertices positions
            //Different algorithms uses different values and some of them uses edge Weight property.
            LogicCore.DefaultLayoutAlgorithm = GraphX.PCL.Common.Enums.LayoutAlgorithmTypeEnum.KK;
            //Now we can set optional parameters using AlgorithmFactory
            //NOTE: default parameters can be automatically created each time you change Default algorithms
            LogicCore.DefaultLayoutAlgorithmParams =
                LogicCore.AlgorithmFactory.CreateLayoutParameters(GraphX.PCL.Common.Enums.LayoutAlgorithmTypeEnum.KK);
            //Unfortunately to change algo parameters you need to specify params type which is different for every algorithm.
            ((KKLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;

            //This property sets vertex overlap removal algorithm.
            //Such algorithms help to arrange vertices in the layout so no one overlaps each other.
            LogicCore.DefaultOverlapRemovalAlgorithm = GraphX.PCL.Common.Enums.OverlapRemovalAlgorithmTypeEnum.FSA;
            //Setup optional params
            LogicCore.DefaultOverlapRemovalAlgorithmParams =
                LogicCore.AlgorithmFactory.CreateOverlapRemovalParameters(GraphX.PCL.Common.Enums.OverlapRemovalAlgorithmTypeEnum.FSA);
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).HorizontalGap = 50;
            ((OverlapRemovalParameters)LogicCore.DefaultOverlapRemovalAlgorithmParams).VerticalGap   = 50;

            //This property sets edge routing algorithm that is used to build route paths according to algorithm logic.
            //For ex., SimpleER algorithm will try to set edge paths around vertices so no edge will intersect any vertex.
            LogicCore.DefaultEdgeRoutingAlgorithm = GraphX.PCL.Common.Enums.EdgeRoutingAlgorithmTypeEnum.SimpleER;

            //This property sets async algorithms computation so methods like: Area.RelayoutGraph() and Area.GenerateGraph()
            //will run async with the UI thread. Completion of the specified methods can be catched by corresponding events:
            //Area.RelayoutFinished and Area.GenerateGraphFinished.
            LogicCore.AsyncAlgorithmCompute = false;

            LogicCoreSolution = LogicCore;
        }