static double GetPaddings(ArgsParser.ArgsParser argsParser, out double loosePadding) { double tightPadding = 0.5; if (argsParser.OptionIsUsed(TightPaddingOption)) { string tightPaddingString = argsParser.GetValueOfOptionWithAfterString(TightPaddingOption); if (!double.TryParse(tightPaddingString, out tightPadding)) { Console.WriteLine("cannot parse {0} {1}", TightPaddingOption, tightPaddingString); Environment.Exit(1); } } loosePadding = 2.25; if (argsParser.OptionIsUsed(LoosePaddingOption)) { string loosePaddingString = argsParser.GetValueOfOptionWithAfterString(LoosePaddingOption); if (!double.TryParse(loosePaddingString, out loosePadding)) { Console.WriteLine("cannot parse {0} {1}", LoosePaddingOption, loosePaddingString); Environment.Exit(1); } } return(tightPadding); }
private void Run() { _testDir = _argsParser.GetValueOfOptionWithAfterString("-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; run_layout = false; CreateArtificialGraphsIfRequired(); } else { run_layout = true; } OverlapRemovalTestSuite.ComparisonSuite( _testDir, "ResultsPrism-original-datasetTestSuite1.csv", false, run_layout); }
void TrySettingGraphViewerLargeLayoutThresholdAndSomeOtherLgSettings() { if (_argsParser.OptionIsUsed("-no_route_simpl")) { _graphViewer.DefaultLargeLayoutSettings.SimplifyRoutes = false; } if (_argsParser.OptionIsUsed("-no_tiles")) { _graphViewer.DefaultLargeLayoutSettings.GenerateTiles = false; } string labelH = _argsParser.GetValueOfOptionWithAfterString("-labelH"); if (labelH != null) { double h; if (double.TryParse(labelH, out h)) { _graphViewer.DefaultLargeLayoutSettings.NodeLabelHeightInInches = h; } } CheckNodeQuota(); CheckRailQuota(); CheckRailColors(); CheckSelectionColors(); CheckIncreaseNodeQuota(); }
//RangeSlider edgeRangeSlider; protected override void OnStartup(StartupEventArgs e) { #if DEBUG 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; TrySettingGraphViewerLargeLayoutThresholdAndSomeOtherLgSettings(); if (argsParser.OptionIsUsed(ExitAfterLgLayoutOption)) { graphViewer.DefaultLargeLayoutSettings.ExitAfterInit = true; } if (argsParser.OptionIsUsed(BackgroundImageOption)) { graphViewer.DefaultLargeLayoutSettings.BackgroundImage = argsParser.GetValueOfOptionWithAfterString(BackgroundImageOption); } if (argsParser.OptionIsUsed(DrawBackgrounImageOption)) { graphViewer.DefaultLargeLayoutSettings.DrawBackgroundImage = true; } graphViewer.ViewChangeEvent += GraphViewerViewChangeEvent; graphViewer.ObjectUnderMouseCursorChanged += GvObjectUnderMouseCursorChanged; graphViewer.MouseDown += GraphViewerMouseDown; graphViewer.MouseMove += GraphViewerMouseMove; var msaglFile = argsParser.GetValueOfOptionWithAfterString(SaveMsaglOption); if (msaglFile != null) { graphViewer.MsaglFileToSave = msaglFile; } graphViewer.GraphChanged += graphViewer_GraphChanged; //graphViewer.LayoutEditingEnabled = false; appWindow.Show(); }
static BundlingSettings GetBundlingSettings(ArgsParser.ArgsParser argsParser) { if (!argsParser.OptionIsUsed(BundlingOption)) { return(null); } var bs = new BundlingSettings(); string ink = argsParser.GetValueOfOptionWithAfterString(InkImportanceOption); double inkCoeff; if (ink != null && double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } string esString = argsParser.GetValueOfOptionWithAfterString(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { Console.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } string capacityCoeffString = argsParser.GetValueOfOptionWithAfterString(CapacityCoeffOption); if (capacityCoeffString != null) { double capacityCoeff; if (double.TryParse(capacityCoeffString, out capacityCoeff)) { bs.CapacityOverflowCoefficient = capacityCoeff; } else { Console.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.GetValueOfOptionWithAfterString(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.GetValueOfOptionWithAfterString(FileOption); if (listFile != null) { return(ProccessFileList(listFile)); } return(0); }
void TrySettingGraphViewerLargeLayoutThresholdAndSomeOtherLgSettings() { var val = argsParser.GetValueOfOptionWithAfterString(LargeLayoutThresholdOption); if (val != null) { int thresh; if (int.TryParse(val, out thresh)) { graphViewer.LargeGraphCountThreshold = thresh; } } val = argsParser.GetValueOfOptionWithAfterString(MaxNodesPerTileOption); if (val != null) { int max; if (int.TryParse(val, out max)) { graphViewer.DefaultLargeLayoutSettings.MaxNumberNodesPerTile = max; } } }
void GraphViewerLoaded(object sender, EventArgs e) { if (_graphViewerIsLoaded) { return; } _graphViewerIsLoaded = true; string fileName = argsParser.GetValueOfOptionWithAfterString(FileOption); if (fileName != null) { CreateAndLayoutGraph(fileName); } else { string fileList = argsParser.GetValueOfOptionWithAfterString(FileListOption); if (fileList != null) { ProcessFileList(fileList); } } }
protected override void OnStartup(StartupEventArgs e) { #if DEBUG 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.GetValueOfOptionWithAfterString(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(); }
protected override void OnStartup(StartupEventArgs e) { #if DEBUG 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.GetValueOfOptionWithAfterString(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 Main(string[] args) { #if DEBUG DisplayGeometryGraph.SetShowFunctions(); #endif ArgsParser.ArgsParser argsParser = SetArgsParser(args); if (argsParser.OptionIsUsed(PolygonDistanceTestOption)) { TestPolygonDistance(); } else if (argsParser.OptionIsUsed(PolygonDistanceTestOption3)) { TestPolygonDistance3(); } 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.GetValueOfOptionWithAfterString(ListOfFilesOption); if (listOfFilesFile != null) { ProcessListOfFiles(listOfFilesFile, argsParser); return; } string fileName = argsParser.GetValueOfOptionWithAfterString(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 DEBUG /*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 DEBUG 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(); } 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) { Console.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 = 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.GetValueOfOptionWithAfterString(InkImportanceOption); if (ink != null) { double inkCoeff; if (double.TryParse(ink, out inkCoeff)) { bs.InkImportance = inkCoeff; BundlingSettings.DefaultInkImportance = inkCoeff; } else { Console.WriteLine("cannot parse {0}", ink); Environment.Exit(1); } } string esString = argsParser.GetValueOfOptionWithAfterString(EdgeSeparationOption); if (esString != null) { double es; if (double.TryParse(esString, out es)) { BundlingSettings.DefaultEdgeSeparation = es; bs.EdgeSeparation = es; } else { Console.WriteLine("cannot parse {0}", esString); Environment.Exit(1); } } } gviewer.Graph = graph; }
//RangeSlider edgeRangeSlider; protected override void OnStartup(StartupEventArgs e) { #if DEBUG 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.GetValueOfOptionWithAfterString(SaveMsaglOption); if (msaglFile != null) graphViewer.MsaglFileToSave = msaglFile; graphViewer.GraphChanged += graphViewer_GraphChanged; //graphViewer.LayoutEditingEnabled = false; appWindow.Show(); }