internal DeviceIndependendZoomCalculatorForNodes(
     Func<Node, LgNodeInfo> nodeToLgNodeInfo, GeometryGraph graph, LgLayoutSettings settings, int maxAmountPerTile)
 {
     NodeToLgNodeInfo = nodeToLgNodeInfo;
     this.maxAmountPerTile = maxAmountPerTile;
     Graph = graph;
     Settings = settings;
     unassigned = graph.Nodes.Count;
 }
Exemplo n.º 2
0
 internal DeviceIndependendZoomCalculatorForNodes(
     Func <Node, LgNodeInfo> nodeToLgNodeInfo, GeometryGraph graph, LgLayoutSettings settings, int maxAmountPerTile)
 {
     NodeToLgNodeInfo      = nodeToLgNodeInfo;
     this.maxAmountPerTile = maxAmountPerTile;
     Graph      = graph;
     Settings   = settings;
     unassigned = graph.Nodes.Count;
 }
        internal static void SetNodeZoomLevelsAndRouteEdgesOnLevels(
            LgData lgData,
            GeometryGraph mainGeometryGraph,
            LgLayoutSettings lgLayoutSettings) {

            var nodeZoomLevelCalculator =
                new DeviceIndependendZoomCalculatorForNodes(node => lgData.GeometryNodesToLgNodeInfos[node],
                                                            mainGeometryGraph, lgLayoutSettings, lgLayoutSettings.MaxNumberOfNodesPerTile);
            nodeZoomLevelCalculator.Run();
            lgData.SortedLgNodeInfos = nodeZoomLevelCalculator.SortedLgNodeInfos;
            lgData.LevelNodeCounts = nodeZoomLevelCalculator.LevelNodeCounts;
            AssignEdges(lgData, nodeZoomLevelCalculator);
        }
Exemplo n.º 4
0
        internal static void SetEdgesOnLevels(
            LgData lgData,
            GeometryGraph mainGeometryGraph,
            LgLayoutSettings lgLayoutSettings)
        {
            var nodeZoomLevelCalculator =
                new DeviceIndependendZoomCalculatorForNodes(node => lgData.GeometryNodesToLgNodeInfos[node],
                                                            mainGeometryGraph, lgLayoutSettings, lgLayoutSettings.MaxNumberOfNodesPerTile);

            nodeZoomLevelCalculator.RunAfterFlow(lgData);
            lgData.SortedLgNodeInfos = nodeZoomLevelCalculator.SortedLgNodeInfos;
            lgData.LevelNodeCounts   = nodeZoomLevelCalculator.LevelNodeCounts;
        }
Exemplo n.º 5
0
        internal static void SetNodeZoomLevelsAndRouteEdgesOnLevels(
            LgData lgData,
            GeometryGraph mainGeometryGraph,
            LgLayoutSettings lgLayoutSettings)
        {
            var nodeZoomLevelCalculator =
                new DeviceIndependendZoomCalculatorForNodes(node => lgData.GeometryNodesToLgNodeInfos[node],
                                                            mainGeometryGraph, lgLayoutSettings, lgLayoutSettings.MaxNumberOfNodesPerTile);

            //jyoti this is the place where you might want to bound the theoretical zoom level
            nodeZoomLevelCalculator.Run();
            lgData.SortedLgNodeInfos = nodeZoomLevelCalculator.SortedLgNodeInfos;
            lgData.LevelNodeCounts   = nodeZoomLevelCalculator.LevelNodeCounts;
            AssignEdges(lgData, nodeZoomLevelCalculator);
        }
Exemplo n.º 6
0
        static bool RouteEdgesOnLevel(LgData lgData, IZoomLevelCalculator nodeZoomLevelCalculator,
                                      LgLayoutSettings lgLayoutSettings, int nodeCountOnLevel, LgEdgeInfo[] edgeInfos, GeometryGraph mainGeomGraph)
        {
            var zoomLevel        = (int)nodeZoomLevelCalculator.SortedLgNodeInfos[nodeCountOnLevel - 1].ZoomLevel;
            var edgeInfosOfLevel = edgeInfos.TakeWhile(ei => ei.ZoomLevel <= zoomLevel).ToList();

            var tmpGraphForRouting = CreateTmpGraphForRouting(lgData, edgeInfosOfLevel, zoomLevel);

            //LayoutAlgorithmSettings.ShowGraph(tmpGraphForRouting);

            var level = lgData.AddLevel(zoomLevel);

            RouteEdges(lgLayoutSettings, tmpGraphForRouting, lgData, level);
            //lgData.ExtractRailsFromRouting(tmpGraphForRouting.Edges, zoomLevel);
            return(edgeInfosOfLevel.Count() == lgData.GeometryEdgesToLgEdgeInfos.Count);
        }
Exemplo n.º 7
0
        static void RouteEdges(LgLayoutSettings lgLayoutSettings,
                               GeometryGraph tmpGraphForRouting,
                               LgData lgData,
                               LgLevel level)
        {
            int routedEdges = 0;

            Console.WriteLine("\nrouting for level {0}", level.ZoomLevel);
            var router = new SplineRouter(tmpGraphForRouting, lgLayoutSettings.EdgeRoutingSettings.Padding,
                                          lgLayoutSettings.EdgeRoutingSettings.PolylinePadding, Math.PI / 6,
                                          null)
            {
                RouteMultiEdgesAsBundles     = false,
                UseEdgeLengthMultiplier      = true,
                UsePolylineEndShortcutting   = false,
                UseInnerPolylingShortcutting = false,
                // LineSweeperPorts = GetLineSweeperPorts(tmpGraphForRouting, tileSize),
                AllowedShootingStraightLines = false,
                ContinueOnOverlaps           = true,
                CacheCornersForSmoothing     = true,
                ReplaceEdgeByRails           =
                    e => {
                    routedEdges++;
                    if (routedEdges % 1000 == 0)
                    {
                        Console.Write(".");
                    }
                    level.RegisterRailsOfEdge(lgData.GeometryEdgesToLgEdgeInfos[e]);
                },
                Bidirectional = true
            };    //new BundlingSettings {KeepOverlaps = true, EdgeSeparation = 0, StopAfterShortestPaths = true});

            router.Run();
            level.CreateRailTree();
            foreach (var edge in tmpGraphForRouting.Edges)
            {
                level.FillRailDictionaryForEdge(edge);
                edge.Curve = null;
            }
            // level.RunLevelStatistics(lgData.GeometryNodesToLgNodeInfos.Where(e=>e.Value.ZoomLevel<=level.ZoomLevel).Select(p=>p.Key));
        }
Exemplo n.º 8
0
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="geometryGraph"></param>
        /// <param name="lgLayoutSettings"></param>
        /// <param name="cancelToken"></param>
        public LgInteractor(GeometryGraph geometryGraph, LgLayoutSettings lgLayoutSettings, CancelToken cancelToken)
        {
            mainGeometryGraph     = geometryGraph;
            this.lgLayoutSettings = lgLayoutSettings;
            this.cancelToken      = cancelToken;
            if (geometryGraph.LgData == null)
            {
                lgData = new LgData(geometryGraph)
                {
                    GeometryNodesToLgNodeInfos = lgLayoutSettings.GeometryNodesToLgNodeInfos
                };

                geometryGraph.LgData = lgData;
            }
            else
            {
                _initFromPrecomputedLgData = true;
                lgData = geometryGraph.LgData;
                lgLayoutSettings.GeometryNodesToLgNodeInfos = lgData.GeometryNodesToLgNodeInfos;
            }
        }
        internal GraphmapsNode(Node node, LgNodeInfo lgNodeInfo, FrameworkElement frameworkElementOfNodeForLabelOfLabel,
            Func<Edge, GraphmapsEdge> funcFromDrawingEdgeToVEdge, Func<double> pathStrokeThicknessFunc, LgLayoutSettings lgSettings)
        {
            this.lgSettings = lgSettings;
            PathStrokeThicknessFunc = pathStrokeThicknessFunc;
            LgNodeInfo = lgNodeInfo;
            Node = node;
            FrameworkElementOfNodeForLabel = frameworkElementOfNodeForLabelOfLabel;

            this.funcFromDrawingEdgeToVEdge = funcFromDrawingEdgeToVEdge;

            CreateNodeBoundaryPath();
            if (FrameworkElementOfNodeForLabel != null) {
                FrameworkElementOfNodeForLabel.Tag = this; //get a backpointer to the VNode 
                Common.PositionFrameworkElement(FrameworkElementOfNodeForLabel, node.GeometryNode.Center, 1);
                Panel.SetZIndex(FrameworkElementOfNodeForLabel, Panel.GetZIndex(BoundaryPath) + 1);
            }
            SetupSubgraphDrawing();
            Node.GeometryNode.BeforeLayoutChangeEvent += GeometryNodeBeforeLayoutChangeEvent;
            Node.Attr.VisualsChanged += (a, b) => Invalidate();         
           
        }
Exemplo n.º 10
0
        internal static void SetNodeZoomLevelsAndRouteEdgesOnLevels(
            LgData lgData,
            GeometryGraph mainGeometryGraph,
            LgLayoutSettings lgLayoutSettings)
        {
            //fromDrawingToEdgeInfo = new Dictionary<ICurve, LgEdgeInfo>();
            foreach (var connectedGraph in lgData.ConnectedGeometryGraphs)
            {
                RankTheGraph(lgData, mainGeometryGraph, connectedGraph);
            }

            UpdateRankClusters(lgData);

            var nodeZoomLevelCalculator =
                new DeviceIndependendZoomCalculatorForNodes(node => lgData.GeometryNodesToLgNodeInfos[node],
                                                            mainGeometryGraph, lgLayoutSettings, lgLayoutSettings.MaxNumberNodesPerTile);

            nodeZoomLevelCalculator.Run();
            lgData.SortedLgNodeInfos = nodeZoomLevelCalculator.SortedLgNodeInfos;
            lgData.LevelNodeCounts   = nodeZoomLevelCalculator.LevelNodeCounts;
            RouteEdgesOnLevels(lgData, nodeZoomLevelCalculator, lgLayoutSettings, mainGeometryGraph);
        }
        void LayoutGraph() {
            if (NeedToCalculateLayout) {
                try {
                    var ls = _drawingGraph.LayoutAlgorithmSettings as LgLayoutSettings;
                    LayoutHelpers.CalculateLayout(geometryGraphUnderLayout, _drawingGraph.LayoutAlgorithmSettings,
                        CancelToken);                    
                }
                catch (OperationCanceledException) {
                    //swallow this exception
                }
            }
            else
                LayoutHelpers.LayoutLargeGraphWithLayers(geometryGraphUnderLayout, _drawingGraph.LayoutAlgorithmSettings,
                    CancelToken);

            _lgLayoutSettings = Graph.LayoutAlgorithmSettings as LgLayoutSettings;

            var noldeLabelRatios = new List<double>();
            foreach (var n in geometryGraphUnderLayout.Nodes)
            {
                var node = (Drawing.Node) n.UserData;
                noldeLabelRatios.Add(node == null ? 1 : node.Attr.LabelWidthToHeightRatio);
            }


            LayoutHelpers.ComputeNodeLabelsOfLargeGraphWithLayers(geometryGraphUnderLayout,
                _drawingGraph.LayoutAlgorithmSettings,
                noldeLabelRatios,
                CancelToken);

            //added            
        }
Exemplo n.º 12
0
        static void RouteEdgesOnLevels(LgData lgData, IZoomLevelCalculator nodeZoomLevelCalculator, LgLayoutSettings lgLayoutSettings, GeometryGraph mainGeomGraph)
        {
            AssignEdgesToLevels(lgData, nodeZoomLevelCalculator);

            var edgeInfos = SortEdgeInfosByLevel(lgData);

            foreach (int nodeCountOnLevel in nodeZoomLevelCalculator.LevelNodeCounts)
            {
                bool finished = RouteEdgesOnLevel(lgData, nodeZoomLevelCalculator, lgLayoutSettings, nodeCountOnLevel, edgeInfos,
                                                  mainGeomGraph);
                if (finished)
                {
                    break;
                }
            }
            Console.WriteLine("routing is done");
        }
Exemplo n.º 13
0
 public VEdge(Edge edge, LgLayoutSettings lgSettings) {
     Edge = edge;
     EdgeAttrClone = edge.Attr.Clone();
 }
Exemplo n.º 14
0
 bool GetLgSettingsAndActiveLevel(out LgLayoutSettings settings, out int iLevel) {
     settings = _graphViewer.Graph.LayoutAlgorithmSettings as LgLayoutSettings;
     iLevel = 0;
     return (settings != null && iLevel >= 0);
 }
Exemplo n.º 15
0
 bool GetLgSettings(out LgLayoutSettings settings) {
     settings = null;
     if (_graphViewer == null) return false;
     if (_graphViewer.Graph == null) return false;
     if (_graphViewer.Graph.LayoutAlgorithmSettings == null) return false;
     settings = _graphViewer.Graph.LayoutAlgorithmSettings as LgLayoutSettings;
     return settings != null;
 }
        VEdge CreateEdge(DrawingEdge edge, LgLayoutSettings lgSettings) {
            lock (this) {
                if (drawingObjectsToIViewerObjects.ContainsKey(edge))
                    return (VEdge) drawingObjectsToIViewerObjects[edge];
                if (lgSettings != null)
                    return CreateEdgeForLgCase(lgSettings, edge);

                FrameworkElement labelTextBox;
                drawingObjectsToFrameworkElements.TryGetValue(edge, out labelTextBox);
                var vEdge = new VEdge(edge, labelTextBox);

                var zIndex = ZIndexOfEdge(edge);
                drawingObjectsToIViewerObjects[edge] = vEdge;

                if (edge.Label != null)
                    SetVEdgeLabel(edge, vEdge, zIndex);

                Panel.SetZIndex(vEdge.CurvePath, zIndex);
                _graphCanvas.Children.Add(vEdge.CurvePath);
                SetVEdgeArrowheads(vEdge, zIndex);

                return vEdge;
            }
        }
Exemplo n.º 17
0
 public GraphmapsEdge(Edge edge, LgLayoutSettings lgSettings) {
     Edge = edge;
     EdgeAttrClone = edge.Attr.Clone();
     this.lgSettings = lgSettings;
 }
Exemplo n.º 18
0
        void ProcessGraph()
        {
            try {
                selectedObject = null;
                if (drawingGraph == null) return;

                graphCanvas.Visibility = Visibility.Hidden; // hide canvas while we lay it out asynchronously.
                ClearGraphViewer();

                // Make nodes and edges

                if (LargeGraphBrowsing) {
                    LayoutEditingEnabled = false;
                    var lgsettings = new LgLayoutSettings(
                        () => new Rectangle(0, 0, graphCanvas.RenderSize.Width, graphCanvas.RenderSize.Height),
                        () => Transform, DpiX, DpiY, ()=> 0.1 * DpiX / CurrentScale /*0.1 inch*/);
                    drawingGraph.LayoutAlgorithmSettings = lgsettings;
                    lgsettings.ViewerChangeTransformAndInvalidateGraph +=OGraphChanged;
                }
                if (NeedToCalculateLayout) {
                    drawingGraph.CreateGeometryGraph(); //forcing the layout recalculation
                    geometryGraphUnderLayout = drawingGraph.GeometryGraph;
                }

                PushGeometryIntoLayoutGraph();
                graphCanvas.RaiseEvent(new RoutedEventArgs(LayoutStartEvent));
                LayoutHelpers.CalculateLayout(geometryGraphUnderLayout, drawingGraph.LayoutAlgorithmSettings);

                TransferLayoutDataToWpf();
            }
            catch
                (Exception e) {
                MessageBox.Show(e.ToString());
            }
        }
        void ProcessGraphUnderLock() {
            try {
                if (LayoutStarted != null)
                    LayoutStarted(null, null);

                CancelToken = new CancelToken();

                if (_drawingGraph == null) return;
                HideCanvas();
                Clear();
                /*  if (!LargeGraphBrowsing)
                      CreateFrameworkElementsForLabelsOnly(); */
                LayoutEditingEnabled = false;
                var lgsettings = new LgLayoutSettings(
                    GetCanvasRenderViewport,
                    () => Transform, DpiX, DpiY, () => ArrowheadLength) {
                        NeedToLayout = NeedToCalculateLayout,
                        MaxNumberOfNodesPerTile = DefaultLargeLayoutSettings.MaxNumberOfNodesPerTile,
                        MaxNumberOfRailsPerTile = DefaultLargeLayoutSettings.MaxNumberOfRailsPerTile,
                        RailColors = DefaultLargeLayoutSettings.RailColors,
                        SelectionColors = DefaultLargeLayoutSettings.SelectionColors,
                        IncreaseNodeQuota = DefaultLargeLayoutSettings.IncreaseNodeQuota,
                        ExitAfterInit = DefaultLargeLayoutSettings.ExitAfterInit,
                        SimplifyRoutes = DefaultLargeLayoutSettings.SimplifyRoutes,
                        NodeLabelHeightInInches = DefaultLargeLayoutSettings.NodeLabelHeightInInches,
                        ClientViewportMappedToGraph = ()=>GetVisibleRectangleInGraph()
                    };

                _drawingGraph.LayoutAlgorithmSettings = lgsettings;
                //lgsettings.ViewModel = ViewModel;
                lgsettings.ViewerChangeTransformAndInvalidateGraph +=
                    OGraphChanged;
                if (NeedToCalculateLayout)
                {
                    _drawingGraph.CreateGeometryGraph(); //forcing the layout recalculation
                    if (_graphCanvas.Dispatcher.CheckAccess())
                        PopulateGeometryOfGeometryGraph();
                    else
                        _graphCanvas.Dispatcher.Invoke(PopulateGeometryOfGeometryGraph);
                }
                else
                {
                    if (_graphCanvas.Dispatcher.CheckAccess())
                        SetLabelWidthToHeightRatiosOfGeometryGraph();
                    else
                        _graphCanvas.Dispatcher.Invoke(SetLabelWidthToHeightRatiosOfGeometryGraph);
                }

                geometryGraphUnderLayout = _drawingGraph.GeometryGraph;
                if (RunLayoutAsync)
                    SetUpBackgrounWorkerAndRunAsync();
                else
                    RunLayoutInUIThread();
            }
            catch (Exception e) {
                MessageBox.Show(e.ToString());
            }
        }
 bool getLgSettings(out LgLayoutSettings settings) {
     settings = _drawingGraph.LayoutAlgorithmSettings as LgLayoutSettings;
     return settings != null;
 }
 VEdge CreateEdgeForLgCase(LgLayoutSettings lgSettings, DrawingEdge edge) {
     return (VEdge) (drawingObjectsToIViewerObjects[edge] = new VEdge(edge, lgSettings) {
         PathStrokeThicknessFunc = () => GetBorderPathThickness()*edge.Attr.LineWidth
     });
 }