static double GetPaddings(ArgsParser.ArgsParser argsParser, out double loosePadding) { double tightPadding = 0.5; if (argsParser.OptionIsUsed(TightPaddingOption)) { string tightPaddingString = argsParser.GetStringOptionValue(TightPaddingOption); if (!double.TryParse(tightPaddingString, out tightPadding)) { System.Diagnostics.Debug.WriteLine("cannot parse {0} {1}", TightPaddingOption, tightPaddingString); Environment.Exit(1); } } loosePadding = 2.25; if (argsParser.OptionIsUsed(LoosePaddingOption)) { string loosePaddingString = argsParser.GetStringOptionValue(LoosePaddingOption); if (!double.TryParse(loosePaddingString, out loosePadding)) { System.Diagnostics.Debug.WriteLine("cannot parse {0} {1}", LoosePaddingOption, loosePaddingString); Environment.Exit(1); } } return(tightPadding); }
void TrySettingGraphViewerLargeLayoutThresholdAndSomeOtherLgSettings() { if (_argsParser.OptionIsUsed("-no_route_simpl")) { _graphViewer.DefaultLargeLayoutSettings.SimplifyRoutes = false; } if (_argsParser.OptionIsUsed("-no_tiles")) { _graphViewer.DefaultLargeLayoutSettings.GenerateTiles = false; } string labelH = _argsParser.GetStringOptionValue("-labelH"); if (labelH != null) { double h; if (double.TryParse(labelH, out h)) { _graphViewer.DefaultLargeLayoutSettings.NodeLabelHeightInInches = h; } } CheckNodeQuota(); CheckRailQuota(); CheckRailColors(); CheckSelectionColors(); CheckIncreaseNodeQuota(); }
static BundlingSettings GetBundlingSettings(ArgsParser.ArgsParser argsParser) { if (!argsParser.OptionIsUsed(BundlingOption)) { return(null); } var bs = new BundlingSettings(); string ink = argsParser.GetStringOptionValue(InkImportanceOption); double inkCoeff; if (ink != null && double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } string esString = argsParser.GetStringOptionValue(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } string capacityCoeffString = argsParser.GetStringOptionValue(CapacityCoeffOption); if (capacityCoeffString != null) { double capacityCoeff; if (double.TryParse(capacityCoeffString, out capacityCoeff)) { bs.CapacityOverflowCoefficient = capacityCoeff; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", capacityCoeffString); Environment.Exit(1); } } return(bs); }
int DoJob() { if (!argsParser.Parse()) { var s = String.Format("{2}. Wrong arguments. Usage \"graphRendererSample foo.dot bar.dot [-f listOfDotFile] [-printOut] [-svg] [-xml] [-precision number] [{0}] [{1}] ", NoLabelsOption, PrintProcessedFileNameOption, argsParser.ErrorMessage); return(-1); } if (argsParser.OptionIsUsed(HelpOption)) { return(PrintHelpAndExit()); } var precisionStr = argsParser.GetStringOptionValue(PrecisionOption); if (precisionStr != null) { var prec = int.Parse(precisionStr); if (prec != 0) { precision = prec; } } msaglOutput = argsParser.OptionIsUsed(MsaglOutputOption); printOutToConsole = argsParser.OptionIsUsed(PrintOutOption); foreach (var file in argsParser.FreeArgs) { int r = ProcessFile(file); if (r != 0) { return(r); } } var listFile = argsParser.GetStringOptionValue(FileOption); if (listFile != null) { return(ProccessFileList(listFile)); } return(0); }
private void Run() { _testDir = _argsParser.GetStringOptionValue("-test_dir"); if (_testDir == null) { Console.WriteLine("-test_dir is not given, exiting"); return; } bool run_layout; if (!_argsParser.OptionIsUsed("-dot")) { _graphWidth = GetWidthOfGraph(); _circleRadius = _graphWidth / 10; _nofCircles = GetNumberOfCircles(); _nodesPerCircle = GetNumberOfNodesPerCircle(); _nodeWidth = 2 * _circleRadius / 3; _randomNodesCount = GetRandomNodesCount(); if (_randomNodesCount != 0) { _circleRadius = 0; _nofCircles = 0; } run_layout = false; CreateArtificialGraphsIfRequired(); } else { run_layout = true; } OverlapRemovalTestSuite.ComparisonSuite( _testDir, "ResultsPrism-original-datasetTestSuite1.csv", false, run_layout); }
static void Main(string[] args) { #if TEST_MSAGL DisplayGeometryGraph.SetShowFunctions(); #endif ArgsParser.ArgsParser argsParser = SetArgsParser(args); if (argsParser.OptionIsUsed("-help")) { Console.WriteLine(argsParser.UsageString()); Environment.Exit(0); } bundling = argsParser.OptionIsUsed(BundlingOption); var gviewer = new GViewer(); if (argsParser.OptionIsUsed(FdOption)) { gviewer.CurrentLayoutMethod = LayoutMethod.IcrementalLayout; } Form form = CreateForm(null, gviewer); if (argsParser.OptionIsUsed(AsyncLayoutOption)) { gviewer.AsyncLayout = true; } string fileName = argsParser.GetStringOptionValue(FileOption); if (fileName != null) { string ext = Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLower(); if (ext == ".dot") { ProcessDotFile(gviewer, argsParser, fileName); } } else { Console.WriteLine("do not know how to process {0}", fileName); Environment.Exit(1); } } if (!argsParser.OptionIsUsed(QuietOption)) { Application.Run(form); } }
//RangeSlider edgeRangeSlider; protected override void OnStartup(StartupEventArgs e) { #if TEST_MSAGL Microsoft.Msagl.GraphViewerGdi.DisplayGeometryGraph.SetShowFunctions(); #endif appWindow = new Window { Title = "My app for testing wpf graph control", Content = dockPanel, WindowStartupLocation = WindowStartupLocation.CenterScreen, WindowState = WindowState.Normal }; SetupToolbar(); graphViewerPanel.ClipToBounds = true; dockPanel.Children.Add(toolBar); SetUpStatusBar(); dockPanel.LastChildFill = true; dockPanel.Children.Add(graphViewerPanel); graphViewer.BindToPanel(graphViewerPanel); dockPanel.Loaded += GraphViewerLoaded; argsParser = SetArgsParser(Args); //graphViewer.MainPanel.MouseLeftButtonUp += TestApi; graphViewer.ViewChangeEvent += GraphViewerViewChangeEvent; graphViewer.ObjectUnderMouseCursorChanged += GvObjectUnderMouseCursorChanged; graphViewer.MouseDown += GraphViewerMouseDown; graphViewer.MouseMove += GraphViewerMouseMove; var msaglFile = argsParser.GetStringOptionValue(SaveMsaglOption); if (msaglFile != null) { graphViewer.MsaglFileToSave = msaglFile; } graphViewer.GraphChanged += graphViewer_GraphChanged; //graphViewer.LayoutEditingEnabled = false; appWindow.Show(); }
void GraphViewerLoaded(object sender, EventArgs e) { if (_graphViewerIsLoaded) { return; } _graphViewerIsLoaded = true; string fileName = argsParser.GetStringOptionValue(FileOption); if (fileName != null) { CreateAndLayoutGraph(fileName); } else { string fileList = argsParser.GetStringOptionValue(FileListOption); if (fileList != null) { ProcessFileList(fileList); } } }
static void Main(string[] args) { #if TEST_MSAGL DisplayGeometryGraph.SetShowFunctions(); #endif ArgsParser.ArgsParser argsParser = SetArgsParser(args); if (argsParser.OptionIsUsed("-help")) { Console.WriteLine(argsParser.UsageString()); Environment.Exit(0); } if (argsParser.OptionIsUsed(PolygonDistanceTestOption)) { TestPolygonDistance(); } else if (argsParser.OptionIsUsed(TestCdtThreaderOption)) { TestCdtThreader(); } else if (argsParser.OptionIsUsed(RandomBundlingTest)) { RandomBundlingTests.RsmContent(); } bundling = argsParser.OptionIsUsed(BundlingOption); var gviewer = new GViewer(); gviewer.MouseMove += Draw.GviewerMouseMove; if (argsParser.OptionIsUsed(FdOption)) { TestFD(); gviewer.CurrentLayoutMethod = LayoutMethod.IcrementalLayout; } Form form = CreateForm(null, gviewer); if (argsParser.OptionIsUsed(AsyncLayoutOption)) { gviewer.AsyncLayout = true; } string listOfFilesFile = argsParser.GetStringOptionValue(ListOfFilesOption); if (listOfFilesFile != null) { ProcessListOfFiles(listOfFilesFile, argsParser); return; } string fileName = argsParser.GetStringOptionValue(FileOption); string ext = Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLower(); if (ext == ".dot") { ProcessDotFile(gviewer, argsParser, fileName); } else { if (ext == ".geom") { GeometryGraph geometryGraph = GeometryGraphReader.CreateFromFile(fileName); geometryGraph.Margins = 10; FixHookPorts(geometryGraph); // if (argsParser.OptionIsUsed(BundlingOption)) { for (int i = 0; i < 1; i++) { #if TEST_MSAGL /*DisplayGeometryGraph.ShowGraph(geometryGraph); * var l = new List<DebugCurve>(); l.AddRange(geometryGraph.Nodes.Select(n=>new DebugCurve(100,1,"black",n.BoundaryCurve))); * l.AddRange(geometryGraph.Edges.Select(e=>new DebugCurve(100,1,"black", new LineSegment(e.Source.Center,e.Target.Center)))); * foreach (var cl in geometryGraph.RootCluster.AllClustersDepthFirst()) { * l.Add(new DebugCurve(100,2,"blue",cl.BoundaryCurve)); * foreach (var node in cl.Nodes) * l.Add(new DebugCurve(100, 2, "brown", node.BoundaryCurve)); * * foreach (var e in cl.Edges) * l.Add(new DebugCurve(100, 2, "pink", new LineSegment(e.Source.Center, e.Target.Center))); * * } * * DisplayGeometryGraph.ShowDebugCurves(l.ToArray());*/ #endif BundlingSettings bs = GetBundlingSettings(argsParser); double loosePadding; double tightPadding = GetPaddings(argsParser, out loosePadding); if (argsParser.OptionIsUsed(MdsOption)) { var mdsLayoutSettings = new MdsLayoutSettings { RemoveOverlaps = true, NodeSeparation = loosePadding * 3 }; var mdsLayout = new MdsGraphLayout(mdsLayoutSettings, geometryGraph); mdsLayout.Run(); } else { if (argsParser.OptionIsUsed(FdOption)) { var settings = new FastIncrementalLayoutSettings { AvoidOverlaps = true }; (new InitialLayout(geometryGraph, settings)).Run(); } } var splineRouter = new SplineRouter(geometryGraph, geometryGraph.Edges, tightPadding, loosePadding, Math.PI / 6, bs); splineRouter.Run(); } #if TEST_MSAGL DisplayGeometryGraph.ShowGraph(geometryGraph); #endif return; } else { if (ext == ".msagl") { Graph graph = Graph.Read(fileName); // DisplayGeometryGraph.ShowGraph(graph.GeometryGraph); if (graph != null) { if (argsParser.OptionIsUsed(BundlingOption)) { BundlingSettings bs = GetBundlingSettings(argsParser); double loosePadding; double tightPadding = GetPaddings(argsParser, out loosePadding); var br = new SplineRouter(graph.GeometryGraph, tightPadding, loosePadding, Math.PI / 6, bs); br.Run(); // DisplayGeometryGraph.ShowGraph(graph.GeometryGraph); } } gviewer.NeedToCalculateLayout = false; gviewer.Graph = graph; gviewer.NeedToCalculateLayout = true; } } } } else if (argsParser.OptionIsUsed(TestCdtOption)) { Triangulation(argsParser.OptionIsUsed(ReverseXOption)); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption0)) { TestTriangulationOnSmallGraph(argsParser); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption2)) { TestTriangulationOnPolys(); Environment.Exit(0); } else if (argsParser.OptionIsUsed(TestCdtOption1)) { ThreadThroughCdt(); Environment.Exit(0); } else if (argsParser.OptionIsUsed(ConstraintsTestOption)) { TestGraphWithConstraints(); } if (!argsParser.OptionIsUsed(QuietOption)) { Application.Run(form); } }
static void ProcessDotFile(GViewer gviewer, ArgsParser.ArgsParser argsParser, string dotFileName) { int line; int col; string msg; Graph graph = Parser.Parse(dotFileName, out line, out col, out msg); if (graph == null) { System.Diagnostics.Debug.WriteLine("{0}({1},{2}): error: {3}", dotFileName, line, col, msg); Environment.Exit(1); } if (argsParser.OptionIsUsed(RecoverSugiyamaTestOption)) { gviewer.CalculateLayout(graph); graph.GeometryGraph.AlgorithmData = null; LayeredLayout.RecoverAlgorithmData(graph.GeometryGraph); Node node = graph.GeometryGraph.Nodes[1]; node.BoundaryCurve = node.BoundaryCurve.Transform(new PlaneTransformation(3, 0, 0, 0, 3, 0)); LayeredLayout.IncrementalLayout(graph.GeometryGraph, node); gviewer.NeedToCalculateLayout = false; gviewer.Graph = graph; gviewer.NeedToCalculateLayout = true; return; } if (argsParser.OptionIsUsed(MdsOption)) { graph.LayoutAlgorithmSettings = gviewer.mdsLayoutSettings; } else if (argsParser.OptionIsUsed(FdOption)) { graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings(); } if (argsParser.OptionIsUsed(BundlingOption)) { graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling; BundlingSettings bs = GetBundlingSettings(argsParser); graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings = bs; string ink = argsParser.GetStringOptionValue(InkImportanceOption); if (ink != null) { double inkCoeff; if (double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", ink); Environment.Exit(1); } } string esString = argsParser.GetStringOptionValue(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { System.Diagnostics.Debug.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } } gviewer.Graph = graph; string svgout = argsParser.GetStringOptionValue(SvgFileNameOption); try { if (svgout != null) { SvgGraphWriter.Write(gviewer.Graph, svgout, null, null, 4); } } catch (Exception e) { Console.WriteLine(e.Message); } }
protected override void OnStartup(StartupEventArgs e) { #if TEST_MSAGL DisplayGeometryGraph.SetShowFunctions(); #endif // debug //Test1.RunTest9(); _appWindow = new AppWindow { Title = "Graphmaps browser", Width = SystemParameters.WorkArea.Width - 300, Height = SystemParameters.WorkArea.Height, GraphViewer = _graphViewer, //Content = dockPanel, //WindowStartupLocation = WindowStartupLocation.CenterScreen, //WindowState = WindowState.Normal }; _dockPanel = _appWindow.GetMainDockPanel(); _graphViewerPanel = _appWindow.GetGraphViewerPanel(); _statusTextBox = _appWindow.GetStatusTextBox(); //SetupToolbar(); SetAppCommands(); //graphViewerPanel.ClipToBounds = true; //dockPanel.Children.Add(toolBar); //SetUpStatusBar(); //dockPanel.LastChildFill = true; //dockPanel.Children.Add(graphViewerPanel); _graphViewer.BindToPanel(_graphViewerPanel); _dockPanel.Loaded += GraphViewerLoaded; _argsParser = SetArgsParser(Args); if (_argsParser.OptionIsUsed(BackgroundColorOption)) { var bc = _argsParser.GetStringOptionValue(BackgroundColorOption); _graphViewerPanel.Background = (SolidColorBrush)(new BrushConverter().ConvertFrom(bc)); } //graphViewer.MainPanel.MouseLeftButtonUp += TestApi; TrySettingGraphViewerLargeLayoutThresholdAndSomeOtherLgSettings(); if (_argsParser.OptionIsUsed(ExitAfterLgLayoutOption)) { _graphViewer.DefaultLargeLayoutSettings.ExitAfterInit = true; } _graphViewer.ViewChangeEvent += GraphViewerViewChangeEvent; _graphViewer.ObjectUnderMouseCursorChanged += GvObjectUnderMouseCursorChanged; _graphViewer.MouseDown += GraphViewerMouseDown; _graphViewer.MouseMove += GraphViewerMouseMove; _graphViewer.GraphChanged += graphViewer_GraphChanged; //graphViewer.LayoutEditingEnabled = false; OnStartupTextBox(e); base.OnStartup(e); _appWindow.Show(); //SetUpAndShowSideWindow(); }
static void ProcessDotFile(GViewer gviewer, ArgsParser.ArgsParser argsParser, string dotFileName) { Graph graph = Parser.Parse(dotFileName, out int line, out int col, out string msg); if (graph == null) { Console.WriteLine("{0}({1},{2}): error: {3}", dotFileName, line, col, msg); Environment.Exit(1); } if (argsParser.OptionIsUsed(MdsOption)) { graph.LayoutAlgorithmSettings = new MdsLayoutSettings(); } else if (argsParser.OptionIsUsed(FdOption)) { graph.LayoutAlgorithmSettings = new FastIncrementalLayoutSettings(); } if (argsParser.OptionIsUsed(BundlingOption)) { graph.LayoutAlgorithmSettings.EdgeRoutingSettings.EdgeRoutingMode = EdgeRoutingMode.SplineBundling; BundlingSettings bs = GetBundlingSettings(argsParser); graph.LayoutAlgorithmSettings.EdgeRoutingSettings.BundlingSettings = bs; string ink = argsParser.GetStringOptionValue(InkImportanceOption); if (ink != null) { if (double.TryParse(ink, out double inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } else { Console.WriteLine("cannot parse {0}", ink); Environment.Exit(1); } } string esString = argsParser.GetStringOptionValue(EdgeSeparationOption); if (esString != null) { if (double.TryParse(esString, out double es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { Console.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } } gviewer.Graph = graph; string svgout = argsParser.GetStringOptionValue(SvgFileNameOption); try { if (svgout != null) { SvgGraphWriter.Write(gviewer.Graph, svgout, null, null, 4); } } catch (Exception e) { Console.WriteLine(e.Message); } }