Skip to content

Commit 85f9056

Browse files
committed
Add ignore foreign includes option.
1 parent bff6ab0 commit 85f9056

File tree

4 files changed

+40
-9
lines changed

4 files changed

+40
-9
lines changed

CxxDependencyVisualizer/Graph.cs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void AddChild(string childId)
3838
public List<string> parents = new List<string>();
3939
public int minLevel = int.MaxValue;
4040
public int maxLevel = int.MinValue;
41+
public bool isForeign = false;
4142
public bool duplicatedChildren = false;
4243

4344
public List<Node> childNodes = new List<Node>();
@@ -58,8 +59,9 @@ public LibData()
5859

5960
public LibData(string dir, string file, bool fromLibOnly, bool ignoreComments)
6061
{
62+
string dirPath = Util.PathFromDirFile(dir, "");
6163
rootPath = Util.PathFromDirFile(dir, file);
62-
Analyze(dir, rootPath, null, fromLibOnly, ignoreComments);
64+
Analyze(dirPath, rootPath, null, fromLibOnly, ignoreComments);
6365

6466
foreach (var d in dict)
6567
{
@@ -80,17 +82,35 @@ private void Analyze(string dir, string path, string parentPath,
8082
}
8183
else
8284
{
85+
if (!File.Exists(path))
86+
{
87+
if (fromLibOnly)
88+
return;
89+
90+
Node foreignNode = new Node(parentPath, level);
91+
foreignNode.isForeign = true;
92+
dict.Add(path, foreignNode);
93+
return;
94+
}
95+
8396
if (fromLibOnly && !File.Exists(path))
8497
return;
8598

8699
List<string> children = Util.GetIncludePaths(dir, path, ignoreComments);
87100
Node data = new Node(parentPath, level);
88101
foreach (string c in children)
89102
{
90-
if (fromLibOnly && !File.Exists(c))
91-
continue;
103+
if (File.Exists(c))
104+
{
105+
data.AddChild(c);
106+
}
107+
else
108+
{
109+
if (fromLibOnly)
110+
continue;
92111

93-
data.AddChild(c);
112+
data.AddChild(c.Substring(dir.Length));
113+
}
94114
}
95115

96116
dict.Add(path, data);

CxxDependencyVisualizer/GraphLayout.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ public static GraphData RadialHierarchicalLayout(string dir, Dictionary<string,
148148
string path = d.Key.Substring(dirPath.Length);
149149
inputNodes.Add(new DirNode.PathNodePair(path, d.Value));
150150
}
151+
else
152+
{
153+
inputNodes.Add(new DirNode.PathNodePair(d.Key, d.Value));
154+
}
151155
}
152156

153157
DirNode hierarchy = DirNode.Create(inputNodes);

CxxDependencyVisualizer/MainWindow.xaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252
<RadioButton x:Name="menu_Layout2" Content="Layout 2 (Max Level)" Margin="10,0" />
5353
<RadioButton x:Name="menu_Layout3" Content="Layout 3 (Radial-Hierarchy)" Margin="10,0" />
5454
<RadioButton x:Name="menu_Layout4" Content="Layout 4 (Force-Directed)" Margin="10,0" />
55-
<CheckBox x:Name="menu_IgnoreComments" Content="Ignore Comments" IsChecked="True" Margin="10,10,10,10" />
56-
<Button x:Name="buttonAnalyze" Content="Analyze" Margin="10,10,10,20"
55+
<CheckBox x:Name="menu_IgnoreForeign" Content="Ignore Foreign" IsChecked="True" Margin="10,10,10,0" />
56+
<CheckBox x:Name="menu_IgnoreComments" Content="Ignore Comments" IsChecked="True" Margin="10,10,10,0" />
57+
<Button x:Name="buttonAnalyze" Content="Analyze" Margin="10,20,10,20"
5758
Click="buttonAnalyze_Click" />
5859
<CheckBox x:Name="menu_ShowLines" Content="Show Lines" Margin="10,20,10,5" Checked="menu_ShowLines_Checked" Unchecked="menu_ShowLines_Unchecked"/>
5960
<Label Content="Lines Width" Margin="5,10,5,0"/>

CxxDependencyVisualizer/MainWindow.xaml.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ private void buttonAnalyze_Click(object sender, RoutedEventArgs e)
8585
canvas.Children.Clear();
8686

8787
// Analyze includes and create dictionary
88-
data = new LibData(textBoxDir.Text, textBoxFile.Text, true, (bool)menu_IgnoreComments.IsChecked);
88+
data = new LibData(textBoxDir.Text, textBoxFile.Text,
89+
(bool)menu_IgnoreForeign.IsChecked,
90+
(bool)menu_IgnoreComments.IsChecked);
8991

9092
if ((bool)menu_Layout4.IsChecked)
9193
{
@@ -129,7 +131,9 @@ private void buttonAnalyze_Click(object sender, RoutedEventArgs e)
129131

130132
Border border = new Border();
131133
border.BorderThickness = new Thickness(1);
132-
border.BorderBrush = Brushes.Blue;
134+
border.BorderBrush = d.Value.isForeign
135+
? Brushes.Black
136+
: Brushes.Blue;
133137
border.Child = textBlock;
134138
double l = d.Value.center.X - d.Value.textBlock.Width / 2;
135139
double t = d.Value.center.Y - d.Value.textBlock.Height / 2;
@@ -229,7 +233,9 @@ public void Reset(LibData data)
229233

230234
Border borderActive = tb.Parent as Border;
231235
borderActive.BorderThickness = new Thickness(1);
232-
borderActive.BorderBrush = Brushes.Blue;
236+
borderActive.BorderBrush = d.isForeign
237+
? Brushes.Black
238+
: Brushes.Blue;
233239
}
234240
textBlocks.Clear();
235241

0 commit comments

Comments
 (0)