Skip to content

Commit 92bfb71

Browse files
committed
Added tree view navigator to select subsections of the graph to render.
Added remaining interaction support. Added way too many other things to list.
1 parent 29b983a commit 92bfb71

21 files changed

+569
-239
lines changed

Code Grapher/ParseTreeGrapher.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ public Graph CreateGraph()
107107
var graph = new Graph();
108108
if (Subject != null)
109109
{
110-
GraphEdges(graph, Subject);
110+
if (Subject.ChildCount == 0)
111+
graph.AddNode(Subject.GetHashCode().ToString());
112+
else
113+
GraphEdges(graph, Subject);
111114
FormatNodes(graph, Subject);
112115
}
113116

Code Grapher/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.20065.9")]
36-
[assembly: AssemblyFileVersion("1.0.20065.9")]
35+
[assembly: AssemblyVersion("1.0.20066.2")]
36+
[assembly: AssemblyFileVersion("1.0.20066.2")]

Grun/Grun.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,18 @@
3939
<Reference Include="CommandLine, Version=2.7.82.0, Culture=neutral, PublicKeyToken=5a870481e358d379, processorArchitecture=MSIL">
4040
<HintPath>..\packages\CommandLineParser.2.7.82\lib\net461\CommandLine.dll</HintPath>
4141
</Reference>
42+
<Reference Include="Microsoft.Msagl, Version=3.0.0.0, Culture=neutral, PublicKeyToken=640c57aa40e7ae7d, processorArchitecture=MSIL">
43+
<HintPath>..\packages\Microsoft.Msagl.1.1.3\lib\net40\Microsoft.Msagl.dll</HintPath>
44+
</Reference>
45+
<Reference Include="Microsoft.Msagl.Drawing, Version=3.0.0.0, Culture=neutral, PublicKeyToken=8a3d7c21d5fa1306, processorArchitecture=MSIL">
46+
<HintPath>..\packages\Microsoft.Msagl.Drawing.1.1.3\lib\net40\Microsoft.Msagl.Drawing.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Microsoft.Msagl.GraphViewerGdi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=fffc27ea4058b3a1, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Microsoft.Msagl.GraphViewerGDI.1.1.3\lib\net40\Microsoft.Msagl.GraphViewerGdi.dll</HintPath>
50+
</Reference>
4251
<Reference Include="System" />
4352
<Reference Include="System.Core" />
53+
<Reference Include="System.Drawing" />
4454
<Reference Include="System.Windows.Forms" />
4555
<Reference Include="System.Xml.Linq" />
4656
<Reference Include="System.Data.DataSetExtensions" />
@@ -59,6 +69,10 @@
5969
<None Include="packages.config" />
6070
</ItemGroup>
6171
<ItemGroup>
72+
<ProjectReference Include="..\Code Grapher\Code Grapher.csproj">
73+
<Project>{ec6f674c-4d48-40c4-b28b-85627c1ea3ce}</Project>
74+
<Name>Code Grapher</Name>
75+
</ProjectReference>
6276
<ProjectReference Include="..\GunWin\GunWin.csproj">
6377
<Project>{a3568fa3-d6b3-4165-af95-cdb78d86f416}</Project>
6478
<Name>GunWin</Name>

Grun/Options.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ public class Options
7373
[Option("encoding", Required = false, HelpText = "Encoding type to use")]
7474
public string EncodingName { get; set; }
7575

76-
[Option("ps", Required = false, HelpText = "File to output postscript parse tree too")]
77-
public string PostScript { get; set; }
78-
76+
[Option("svg", Required = false, HelpText = "File to output parse tree graph to in svg format")]
77+
public string SvgFileName { get; set; }
7978
}
8079
}

Grun/Program.cs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
using System;
4040
using System.Collections.Generic;
4141
using System.IO;
42+
using System.Linq;
4243
using System.Text;
4344
using System.Windows.Forms;
4445

@@ -47,6 +48,12 @@
4748
using CommandLine;
4849
using CommandLine.Text;
4950

51+
using Microsoft.Msagl.Drawing;
52+
using Microsoft.Msagl.GraphViewerGdi;
53+
using Microsoft.Msagl.Layout.Layered;
54+
55+
using Org.Edgerunner.ANTLR4.Tools.Graphing;
56+
using Org.Edgerunner.ANTLR4.Tools.Testing.Grammar;
5057
using Org.Edgerunner.ANTLR4.Tools.Testing.GrunWin;
5158

5259
namespace Org.Edgerunner.ANTLR4.Tools.Testing.GrunDotNet
@@ -89,9 +96,6 @@ private static void Main(string[] args)
8996
options |= Grammar.ParseOption.Tree;
9097
}
9198

92-
if (!string.IsNullOrEmpty(o.PostScript))
93-
Console.WriteLine("Option --ps is not yet supported.");
94-
9599
var workingDirectory = Environment.CurrentDirectory;
96100
var scanner = new Grammar.Scanner();
97101

@@ -132,6 +136,24 @@ private static void Main(string[] args)
132136
if (showParseTree)
133137
Console.WriteLine(analyzer.StringSourceTree);
134138

139+
if (!string.IsNullOrEmpty(o.SvgFileName))
140+
{
141+
Console.WriteLine("--svg option is not yet supported.");
142+
143+
//var rules = scanner.GetParserRulesForGrammar(grammar);
144+
//var grapher = new ParseTreeGrapher(analyzer.ParseContext, rules.ToList())
145+
//{
146+
// BackgroundColor = Color.LightBlue,
147+
// BorderColor = Color.Black,
148+
// TextColor = Color.Black
149+
//};
150+
//var graph = grapher.CreateGraph();
151+
//graph.LayoutAlgorithmSettings = new SugiyamaLayoutSettings();
152+
//GraphRenderer renderer = new GraphRenderer(graph);
153+
//renderer.CalculateLayout();
154+
//SvgGraphWriter.Write(graph, o.SvgFileName, null, null, 4);
155+
}
156+
135157
if (loadGui)
136158
LoadGui(data, grammar, o.RuleName);
137159
})

Grun/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.20065.2")]
36-
[assembly: AssemblyFileVersion("1.0.20065.2")]
35+
[assembly: AssemblyVersion("1.0.20066.8")]
36+
[assembly: AssemblyFileVersion("1.0.20066.8")]

Grun/packages.config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
<packages>
33
<package id="Antlr4.Runtime" version="4.6.6" targetFramework="net461" />
44
<package id="CommandLineParser" version="2.7.82" targetFramework="net461" />
5+
<package id="Microsoft.Msagl" version="1.1.3" targetFramework="net461" />
6+
<package id="Microsoft.Msagl.Drawing" version="1.1.3" targetFramework="net461" />
7+
<package id="Microsoft.Msagl.GraphViewerGDI" version="1.1.3" targetFramework="net461" />
58
</packages>

GunWin/GunWin.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
<Reference Include="FastColoredTextBox, Version=2.16.24.0, Culture=neutral, PublicKeyToken=fb8aa12b994ef61b, processorArchitecture=MSIL">
4343
<HintPath>..\packages\FCTB.2.16.24\lib\FastColoredTextBox.dll</HintPath>
4444
</Reference>
45+
<Reference Include="JetBrains.Annotations, Version=2019.1.3.0, Culture=neutral, PublicKeyToken=1010a0d8d6380325, processorArchitecture=MSIL">
46+
<HintPath>..\packages\JetBrains.Annotations.2019.1.3\lib\net20\JetBrains.Annotations.dll</HintPath>
47+
</Reference>
4548
<Reference Include="ListViewPrinter, Version=2.7.1.31255, Culture=neutral, processorArchitecture=MSIL">
4649
<HintPath>..\packages\ObjectListView.2.7.1.5\lib\ListViewPrinter.dll</HintPath>
4750
</Reference>

GunWin/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.20065.29")]
36-
[assembly: AssemblyFileVersion("1.0.20065.29")]
35+
[assembly: AssemblyVersion("1.0.20066.33")]
36+
[assembly: AssemblyFileVersion("1.0.20066.33")]

GunWin/Properties/Resources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)