From 313c4a75e0d23be9039c11f6cf71c097b9962337 Mon Sep 17 00:00:00 2001 From: Lev Nachmanson Date: Fri, 28 Jan 2022 12:35:03 -1000 Subject: [PATCH] remove test dependencies from the core agl Signed-off-by: Lev Nachmanson --- GraphLayout/GraphLayout.sln | 23 ++ GraphLayout/MSAGL/AutomaticGraphLayout.csproj | 3 - .../FormForGViewer/FormForGViewer.csproj | 110 ++++++++ GraphLayout/tools/FormForGViewer/FormStuff.cs | 159 +++++++++++ .../FormForGViewer/Properties/AssemblyInfo.cs | 61 +++++ GraphLayout/tools/FormForGViewer/TForm.cs | 257 ++++++++++++++++++ GraphLayout/tools/agl/Program.cs | 2 +- GraphLayout/tools/agl/agl.csproj | 13 +- 8 files changed, 614 insertions(+), 14 deletions(-) create mode 100644 GraphLayout/tools/FormForGViewer/FormForGViewer.csproj create mode 100644 GraphLayout/tools/FormForGViewer/FormStuff.cs create mode 100644 GraphLayout/tools/FormForGViewer/Properties/AssemblyInfo.cs create mode 100644 GraphLayout/tools/FormForGViewer/TForm.cs diff --git a/GraphLayout/GraphLayout.sln b/GraphLayout/GraphLayout.sln index 8c14fb7a..21492b07 100644 --- a/GraphLayout/GraphLayout.sln +++ b/GraphLayout/GraphLayout.sln @@ -110,6 +110,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrawingFromGeometryWithGtk" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EdgeDirectionTest", "Samples\EdgeDirectionTest\EdgeDirectionTest.csproj", "{02EAF869-FB5A-40BD-AD78-92E193946B5D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBB}") = "FormForGViewer", "tools\FormForGViewer\FormForGViewer.csproj", "{AF9121C3-E4B7-464F-8EBB-96C9CF627C07}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -1044,6 +1046,26 @@ Global {02EAF869-FB5A-40BD-AD78-92E193946B5D}.Release|x64.Build.0 = Release|Any CPU {02EAF869-FB5A-40BD-AD78-92E193946B5D}.Release|x86.ActiveCfg = Release|Any CPU {02EAF869-FB5A-40BD-AD78-92E193946B5D}.Release|x86.Build.0 = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|ARM.ActiveCfg = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|ARM.Build.0 = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|ARM64.Build.0 = Debug|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|x64.ActiveCfg = Debug|x64 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|x64.Build.0 = Debug|x64 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|x86.ActiveCfg = Debug|x86 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Debug|x86.Build.0 = Debug|x86 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|Any CPU.Build.0 = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|ARM.ActiveCfg = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|ARM.Build.0 = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|ARM64.ActiveCfg = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|ARM64.Build.0 = Release|Any CPU + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|x64.ActiveCfg = Release|x64 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|x64.Build.0 = Release|x64 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|x86.ActiveCfg = Release|x86 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1093,6 +1115,7 @@ Global {02053710-70B8-4CEB-80DB-DC55BEDAA2C0} = {CAAD5476-353C-41F5-A6E7-88BA0C97C2C9} {AA8D2135-1BD2-47DD-9DC9-2FC266711536} = {CAAD5476-353C-41F5-A6E7-88BA0C97C2C9} {02EAF869-FB5A-40BD-AD78-92E193946B5D} = {CAAD5476-353C-41F5-A6E7-88BA0C97C2C9} + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07} = {9E51C177-3DF6-474E-AC7A-ED036ED32F05} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {0D81D757-911D-4F8B-A4B3-4C4F1CBD5B60} diff --git a/GraphLayout/MSAGL/AutomaticGraphLayout.csproj b/GraphLayout/MSAGL/AutomaticGraphLayout.csproj index c8ab1157..278c7d59 100644 --- a/GraphLayout/MSAGL/AutomaticGraphLayout.csproj +++ b/GraphLayout/MSAGL/AutomaticGraphLayout.csproj @@ -14,7 +14,4 @@ - - - \ No newline at end of file diff --git a/GraphLayout/tools/FormForGViewer/FormForGViewer.csproj b/GraphLayout/tools/FormForGViewer/FormForGViewer.csproj new file mode 100644 index 00000000..6240b384 --- /dev/null +++ b/GraphLayout/tools/FormForGViewer/FormForGViewer.csproj @@ -0,0 +1,110 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {AF9121C3-E4B7-464F-8EBB-96C9CF627C07} + Library + Properties + FormForGViewer + FormForGViewer + v4.7.2 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + prompt + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + prompt + + + + + + + + + + + + + + + + + + + {B76F8F71-4B00-4242-BE36-C9F0732511F7} + AutomaticGraphLayout.Drawing + + + {725CD2CB-CF37-414E-A5A6-F1D87D4D6EDE} + GraphViewerGDI + + + {415D3E3F-7105-46C1-84D2-7ECB34213D92} + AutomaticGraphLayout + + + {ba8fed53-458e-4cb3-8eb3-cbfcadd87e5d} + Dot2Graph + + + {ef5cf15e-5645-433b-8a23-af93e3f2682f} + QUT.ShiftReduceParser + + + + + \ No newline at end of file diff --git a/GraphLayout/tools/FormForGViewer/FormStuff.cs b/GraphLayout/tools/FormForGViewer/FormStuff.cs new file mode 100644 index 00000000..b01f7dbf --- /dev/null +++ b/GraphLayout/tools/FormForGViewer/FormStuff.cs @@ -0,0 +1,159 @@ +/* +Microsoft Automatic Graph Layout,MSAGL + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +""Software""), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +using System; +using System.Diagnostics; +using System.IO; +using System.Windows.Forms; +using Dot2Graph; +using Microsoft.Msagl.Drawing; +using Microsoft.Msagl.GraphViewerGdi; + +namespace FormForGViewer { + public class FormStuff { + public static bool initialLayout; + static string lastFileName; + public static GViewer GViewer; + + public static Form CreateOrAttachForm(GViewer gviewer, Form form) { + GViewer=gviewer; + if (form == null) + form = new Form(); + form.SuspendLayout(); + form.Controls.Add(gviewer); + gviewer.Dock = DockStyle.Fill; + gviewer.SendToBack(); + form.StartPosition = FormStartPosition.CenterScreen; + form.Size = new System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width, + Screen.PrimaryScreen.WorkingArea.Height); + form.MainMenuStrip = GetMainMenuStrip(); + form.Controls.Add(form.MainMenuStrip); + form.ResumeLayout(); + form.Load += form_Load; + return form; + } + + static void form_Load(object sender,EventArgs e) { + ((Form) sender).Focus(); + } + + + static MenuStrip GetMainMenuStrip() { + var menu=new MenuStrip(); + menu.Items.Add(FileStripItem()); + + return menu; + + } + + static ToolStripItem FileStripItem() { + var item = new ToolStripMenuItem("File"); + item.DropDownItems.Add((ToolStripItem) OpenDotFileItem()); + item.DropDownItems.Add(ReloadDotFileItem()); + return item; + } + + static ToolStripItem ReloadDotFileItem() { + var item = new ToolStripMenuItem("Reload file"); + item.ShortcutKeys = Keys.F5; + item.Click += ReloadFileClick; + return item; + } + + static void ReloadFileClick(object sender, EventArgs e) { + if(lastFileName!=null) + ReadGraphFromFile(lastFileName, GViewer, false); + } + + static ToolStripItem OpenDotFileItem() { + var item = new ToolStripMenuItem("Open file"); + item.ShortcutKeys = Keys.Control | Keys.O; + item.Click += OpenFileClick; + return item; + } + + static void OpenFileClick(object sender, EventArgs e) { + + var openFileDialog = new OpenFileDialog { + RestoreDirectory = true, + Filter = " dot files (*.dot)|*.dot|All files (*.*)|*.*" + }; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + ReadGraphFromFile(openFileDialog.FileName, GViewer, false); + } + + internal static Graph CreateDrawingGraphFromFile(string fileName, out int line, out int column, out bool msaglFile) { + string msg; + var graph = Parser.Parse(fileName, out line, out column, out msg); + if (graph != null) { + msaglFile = false; + return graph; + } + + try { + graph = Graph.Read(fileName); + msaglFile = true; + return graph; + } catch (Exception) { + System.Diagnostics.Debug.WriteLine("cannot read " + fileName); + } + msaglFile = false; + return null; + } + + + public static void ReadGraphFromFile(string fileName, GViewer gViewer, bool verbose) { + int eLine, eColumn; + bool msaglFile; + Graph graph = CreateDrawingGraphFromFile(fileName, out eLine, out eColumn, out msaglFile); + lastFileName = fileName; + if (graph == null) + MessageBox.Show(String.Format("{0}({1},{2}): cannot process the file", fileName, eLine, eColumn)); + + else { + +#if TEST_MSAGL + graph.LayoutAlgorithmSettings.Reporting = Test.verbose; +#endif + gViewer.FileName = fileName; + Stopwatch sw = null; + if (verbose) { + gViewer.AsyncLayout = false; + sw = new Stopwatch(); + sw.Start(); + } + gViewer.Graph = graph; + if (sw != null) { + sw.Stop(); + System.Diagnostics.Debug.WriteLine("layout done for {0} ms", (double)sw.ElapsedMilliseconds / 1000); + } + } + } + } +} diff --git a/GraphLayout/tools/FormForGViewer/Properties/AssemblyInfo.cs b/GraphLayout/tools/FormForGViewer/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..3b0bbb7e --- /dev/null +++ b/GraphLayout/tools/FormForGViewer/Properties/AssemblyInfo.cs @@ -0,0 +1,61 @@ +/* +Microsoft Automatic Graph Layout,MSAGL + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +""Software""), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("FormForGV")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/GraphLayout/tools/FormForGViewer/TForm.cs b/GraphLayout/tools/FormForGViewer/TForm.cs new file mode 100644 index 00000000..10592c96 --- /dev/null +++ b/GraphLayout/tools/FormForGViewer/TForm.cs @@ -0,0 +1,257 @@ +/* +Microsoft Automatic Graph Layout,MSAGL + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +""Software""), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ +using System; +using System.Diagnostics; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Windows.Forms; +using Dot2Graph; +using Microsoft.Msagl.Core.Layout; +using Microsoft.Msagl.Core.Routing; +using Microsoft.Msagl.Drawing; +using Microsoft.Msagl.GraphViewerGdi; +using Microsoft.Msagl.Routing.Spline.Bundling.GeneralBundling; +using Parser = DotParser.Parser; +using Size = System.Drawing.Size; + +namespace TestFormForGViewer { + public class TForm : Form { + readonly ToolTip tt=new ToolTip(); + + public GViewer GViewer { get; set; } + + public TrackBar monotoneBar { get; set; } + + public string lastFileName { get; set; } + + public double MonotoneBarValue { + get { + return (2.0 * monotoneBar.Value / (monotoneBar.Maximum - monotoneBar.Minimum)); + } + + } + + internal void SetMonotonicityCoefficientTrackBar() { + monotoneBar = new TrackBar(); + monotoneBar.Location = new Point(400, 0); + monotoneBar.Width = 200; + monotoneBar.Minimum = -100; + monotoneBar.Maximum = 100; + monotoneBar.SmallChange = 1; + + Controls.Add(monotoneBar); + monotoneBar.BringToFront(); + monotoneBar.ValueChanged += MonotoneBarValueChanged; + monotoneBar.MouseUp += MonotoneBarMouseUp; + } + + void MonotoneBarMouseUp(object sender, MouseEventArgs e) { + //RerouteWithNewMonotoneCoefficient(); + } + + void RerouteEdges(Graph graph, BundlingSettings bundleSettings) { + bundleSettings.MonotonicityCoefficient = MonotoneBarValue; + var iViewer = (IViewer)GViewer; + foreach (var iEdge in iViewer.Entities.Where(edge => edge is IViewerEdge)) { + iViewer.InvalidateBeforeTheChange(iEdge); + } + RouteBundledEdges(graph.GeometryGraph, false, graph.LayoutAlgorithmSettings.EdgeRoutingSettings); + foreach (var iEdge in iViewer.Entities.Where(edge=>edge is IViewerEdge) ){ + iViewer.Invalidate(iEdge); + } + } + + void MonotoneBarValueChanged(object sender, EventArgs e) { + tt.Show(MonotoneBarValue.ToString(), monotoneBar, monotoneBar.Width / 2, -monotoneBar.Height / 2); + RerouteWithNewMonotoneCoefficient(); + } + + void RerouteWithNewMonotoneCoefficient() { + var graph = GViewer.Graph; + if (graph == null) + return; + var ers = graph.LayoutAlgorithmSettings.EdgeRoutingSettings; + var bundleSettings = ers.BundlingSettings; + if (bundleSettings == null) return; + if (bundleSettings.MonotonicityCoefficient != MonotoneBarValue) { + RerouteEdges(graph, bundleSettings); + } + } + + public void SetGViewer(GViewer gviewer) { + + GViewer=gviewer; + SuspendLayout(); + Controls.Add(gviewer); + gviewer.Dock = DockStyle.Fill; + gviewer.SendToBack(); + StartPosition = FormStartPosition.CenterScreen; + Size = new Size(Screen.PrimaryScreen.WorkingArea.Width, + Screen.PrimaryScreen.WorkingArea.Height); + + var statusStrip = new StatusStrip(); + var toolStribLbl = new ToolStripStatusLabel("test"); + statusStrip.Items.Add(toolStribLbl); + Controls.Add(statusStrip); + MainMenuStrip = GetMainMenuStrip(); + Controls.Add(MainMenuStrip); + SetMonotonicityCoefficientTrackBar(); + ResumeLayout(); + gviewer.GraphChanged += gviewer_GraphChanged; + } + + + void gviewer_GraphChanged(object sender, EventArgs e) { + var bundlingSettings=GViewer.Graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings; + if (bundlingSettings != null) + SetValueForMonotoneBar(bundlingSettings.MonotonicityCoefficient); + } + + void SetValueForMonotoneBar(double monotonicityCoefficient) { + double a = (monotonicityCoefficient + 1)/2; + monotoneBar.ValueChanged -= MonotoneBarValueChanged; + monotoneBar.Value = (int) (a*(monotoneBar.Maximum - monotoneBar.Minimum) + monotoneBar.Minimum + 0.5); + monotoneBar.ValueChanged += MonotoneBarValueChanged; + } + + MenuStrip GetMainMenuStrip() { + var menu = new MenuStrip(); + menu.Items.Add(FileStripItem()); + return menu; + } + + ToolStripItem FileStripItem() { + var item = new ToolStripMenuItem("File"); + item.DropDownItems.Add((ToolStripItem)OpenDotFileItem()); + item.DropDownItems.Add(ReloadDotFileItem()); + return item; + } + + ToolStripItem ReloadDotFileItem() { + var item = new ToolStripMenuItem("Reload file"); + item.ShortcutKeys = Keys.F5; + item.Click += ReloadFileClick; + return item; + } + + ToolStripItem OpenDotFileItem() { + var item = new ToolStripMenuItem("Open file"); + item.ShortcutKeys = Keys.Control | Keys.O; + item.Click += OpenFileClick; + return item; + } + + void OpenFileClick(object sender, EventArgs e) { + + var openFileDialog = new OpenFileDialog { + RestoreDirectory = true, + Filter = " dot files (*.dot)|*.dot|All files (*.*)|*.*" + }; + + if (openFileDialog.ShowDialog() == DialogResult.OK) + ReadGraphFromFile(openFileDialog.FileName, GViewer, false); + } + + void ReloadFileClick(object sender, EventArgs e) { + if (lastFileName != null) + ReadGraphFromFile(lastFileName, GViewer, false); + } + + public static void ReadGraphFromFile(string fileName, GViewer gViewer, bool verbose) { + var tform = (TForm)gViewer.ParentForm; + int eLine, eColumn; + bool msaglFile; + Graph graph = CreateDrawingGraphFromFile(fileName, out eLine, out eColumn, out msaglFile); + tform.lastFileName = fileName; + if (graph == null) + MessageBox.Show(String.Format("{0}({1},{2}): cannot process the file", fileName, eLine, eColumn)); + + else { + +#if REPORTING + graph.LayoutAlgorithmSettings.Reporting = Test.verbose; +#endif + gViewer.FileName = fileName; + Stopwatch sw = null; + if (verbose) { + gViewer.AsyncLayout = false; + sw = new Stopwatch(); + sw.Start(); + } + + if(gViewer.Graph!=null) + graph.LayoutAlgorithmSettings=gViewer.Graph.LayoutAlgorithmSettings; + + gViewer.Graph = graph; + if (sw != null) { + sw.Stop(); + Console.WriteLine("layout done for {0} ms", (double)sw.ElapsedMilliseconds / 1000); + } + } + } + internal static Graph CreateDrawingGraphFromFile(string fileName, out int line, out int column, out bool msaglFile) { + var sr = new StreamReader(fileName); + string dotString = sr.ReadToEnd(); + sr.Close(); + string msg; + var graph = Parser.GraphFromDotString(dotString, out line, out column, out msg); + if (graph != null) { + graph.LayoutAlgorithmSettings.EdgeRoutingSettings.KeepSmoothedPolyline = true; + msaglFile = false; + return graph; + } + + try { + graph = Graph.Read(fileName); + msaglFile = true; + return graph; + } catch (Exception) { + Console.WriteLine("cannot read " + fileName); + } + msaglFile = false; + return null; + } + + public static void RouteBundledEdges(GeometryGraph geometryGraph, bool measureTime, EdgeRoutingSettings edgeRoutingSettings) { + Stopwatch sw=null; + if (measureTime) { + sw=new Stopwatch(); + sw.Start(); + } + BundleRouter br = new BundleRouter(geometryGraph, edgeRoutingSettings.ConeAngle, + edgeRoutingSettings.Padding, edgeRoutingSettings.PolylinePadding, edgeRoutingSettings.BundlingSettings); + br.Run(); + if (sw != null) { + sw.Stop(); + Console.WriteLine("bundling takes " + sw.Elapsed); + } + } + } +} \ No newline at end of file diff --git a/GraphLayout/tools/agl/Program.cs b/GraphLayout/tools/agl/Program.cs index c0ca192e..b36f4272 100644 --- a/GraphLayout/tools/agl/Program.cs +++ b/GraphLayout/tools/agl/Program.cs @@ -9,7 +9,7 @@ using Microsoft.Msagl.Layout.Incremental; using Microsoft.Msagl.Layout.MDS; using Microsoft.Msagl.Routing; -using TestFormForGViewer; +using FormForGViewer; namespace agl { internal class Program { diff --git a/GraphLayout/tools/agl/agl.csproj b/GraphLayout/tools/agl/agl.csproj index 1994a866..a296f055 100644 --- a/GraphLayout/tools/agl/agl.csproj +++ b/GraphLayout/tools/agl/agl.csproj @@ -107,21 +107,14 @@ {415D3E3F-7105-46C1-84D2-7ECB34213D92} AutomaticGraphLayout - - {AF9121C3-E4B7-464F-8EBB-96C9CF627C06} - TestFormForGViewer + + {af9121c3-e4b7-464f-8ebb-96c9cf627c07} + FormForGViewer - - - 2.9.6 - runtime; build; native; contentfiles; analyzers; buildtransitive - all - -