Moving from GLEE to MSAGL

Microsoft Automatic Graph Layout (MSAGL) is the successor to GLEE and now have received permission to use the MSAGL binaries in the sample code for VisioAutoExt, I've dropped GLEE support and moved completely over to MSAGL. The move to MSAGL was straightforward, but I also managed to improve the overall results of the topology being drawn (for example: now the connectors are one long Bezier curve in visio instead of multiple segments consisting of Bezier curves and line segments).

The new source is available on codeplex here: http://codeplex.com/visioautoext/

NOTE: You do *NOT* have to purchase a license to MSAGL to use this sample code in the project (which includes the MSAGL binaries).

A few words about Microsoft Automatic Graph Layout

  • This is a tremendous piece of work by Lev Nachmanson in Microsoft Research. The results it produces are stellar and because its written as a .NET Framework library incorporating into my code has been very simple.
  • If you are considering doing any graph layout, please check out MSAGL before you try to implement one yourself. You'll save yourself a lot of work and produce far better looking results by letting geniuses like Lev do the heavy lifting for you. So if you plan on doing any graph layout for your own projects or products, I recommend  going to Windows Marketplace and purchase a license.

Sample output

image

Get the Code

You can find some sample in the VisioAutomation codeplex project in a VS project called TestVisioAutomation – search for a method called “Render_With_Dynamic_Connectors”

 

//------------------------

            var vdom = new VA.DOM.AutoLayout.Drawing();

            var n0 = vdom.AddShape("n0", "Untitled Node", "basflo_u.vss", "Decision");
            n0.Size = new Isotope.Drawing.Size(3, 2);
            var n1 = vdom.AddShape("n1", "", "basflo_u.vss", "Decision");
            n1.FillFormat = new FillFormat();
            n1.FillFormat.FillForegnd.Value = "rgb(255,0,0)";
            n1.FillFormat.FillBkgnd.Value = "rgb(255,255,0)";
            n1.FillFormat.FillPattern.Value = 40;
            var n2 = vdom.AddShape("n2", "MailServer", "server_u.vss", "Email Server");
            var n3 = vdom.AddShape("n3", null, "basflo_u.vss", "Data");
            var n4 = vdom.AddShape("n4", "Alone", "basflo_u.vss", "Data");

            var c0 = vdom.Connect("c0", n0, n1, null, VA.DOM.ConnectorType.Curved);
            var c1 = vdom.Connect("c1", n1, n2, "YES", VA.DOM.ConnectorType.RightAngle);
            var c3 = vdom.Connect("c2", n1, n0, "NO", VA.DOM.ConnectorType.Curved);
            var c4 = vdom.Connect("c3", n0, n2, null, VA.DOM.ConnectorType.Straight);
            var c5 = vdom.Connect("c4", n2, n3, null, VA.DOM.ConnectorType.Curved);
            var c6 = vdom.Connect("c5", n3, n0, null, VA.DOM.ConnectorType.Curved);

            var page1 = GetNewPage(StandardPageSize);
            var renderer = new VA.DOM.AutoLayout.Renderer();
            renderer.RenderOptions.UseDynamicConnectors = true;
            var application = page1.Application;
            renderer.RenderToVisio(vdom, application, page1.Document, null);
            page1.ResizeToFitContents();


//------------------------