Skip to content

Commit d2277d1

Browse files
committed
Merge Brendon -> Main
1 parent 3f73948 commit d2277d1

17 files changed

Lines changed: 522 additions & 19 deletions

.idea/.idea.BoGLWeb/.idea/.name

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

.idea/.idea.BoGLWeb/.idea/encodings.xml

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

.idea/.idea.BoGLWeb/.idea/indexLayout.xml

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

.idea/.idea.BoGLWeb/.idea/projectSettingsUpdater.xml

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

.idea/.idea.BoGLWeb/.idea/vcs.xml

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

.idea/.idea.BoGLWeb/.idea/workspace.xml

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

BoGLWeb/BoGLWeb.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,20 @@
826826
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
827827
</ItemGroup>
828828

829+
<PropertyGroup>
830+
<Company>BoGLWeb</Company>
831+
<Configuration>Debug</Configuration>
832+
<FileVersion>1.0.0.0</FileVersion>
833+
<InformationalVersion>1.0.0+6c6171249dfed73b6080245fb99863e333475c06</InformationalVersion>
834+
<Product>BoGLWeb</Product>
835+
<Title>BoGLWeb</Title>
836+
<Version>1.0.0.0</Version>
837+
</PropertyGroup>
838+
839+
<PropertyGroup>
840+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
841+
</PropertyGroup>
842+
829843
<ItemGroup>
830844
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
831845
</ItemGroup>

BoGLWeb/BondGraph.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using BoGLWeb.EditorHelper;
33
using GraphSynth.Representation;
44
using Newtonsoft.Json;
5+
using System.Runtime.CompilerServices;
56
using System.Runtime.ConstrainedExecution;
67
using System.Text;
78
using System.Text.RegularExpressions;
@@ -14,14 +15,16 @@ public class BondGraph {
1415
protected Dictionary<string, Element> elements;
1516
[JsonProperty]
1617
protected List<Bond> bonds;
17-
18+
1819
/// <summary>
1920
/// Creates an instance of BondGraph
2021
/// </summary>
2122
public BondGraph() {
23+
2224
this.elements = new Dictionary<string, Element>();
2325
this.bonds = new List<Bond>();
2426
}
27+
2528

2629
/// <summary>
2730
/// Copies a separate object into this <c>BondGraph</c>.
@@ -124,8 +127,11 @@ public static BondGraph generateBondGraphFromGraphSynth(designGraph graph) {
124127
throw new ArgumentException("Graph was null");
125128
}
126129

127-
BondGraph bondGraph = new();
130+
Element.resetUni();
131+
Bond.resetUni();
128132

133+
BondGraph bondGraph = new();
134+
129135
//Construct an Element for each node
130136
foreach(node node in graph.nodes) {
131137
StringBuilder sb = new();
@@ -141,7 +147,7 @@ public static BondGraph generateBondGraphFromGraphSynth(designGraph graph) {
141147
break;
142148
}
143149
}
144-
150+
145151
bondGraph.addElement(node.name, new Element(node.name, label, 0));
146152
}
147153

@@ -170,6 +176,7 @@ public static BondGraph generateBondGraphFromGraphSynth(designGraph graph) {
170176
}
171177
}
172178

179+
173180
return bondGraph;
174181
}
175182

@@ -261,7 +268,11 @@ public Element(string name, string label, double value) {
261268
this.name = name;
262269
this.label = label;
263270
this.value = value;
264-
AssignID(0, true);
271+
bool dist = false;
272+
if (name.Contains(":") || label.Contains("1") || label.Contains("0")) {
273+
dist = true;
274+
}
275+
AssignID(0, dist);
265276

266277
Random rnd = new();
267278
this.x = rnd.Next(2000);
@@ -358,6 +369,10 @@ public override bool Equals(object? obj) {
358369
this.name.Equals(element.name);
359370
}
360371

372+
public static void resetUni() {
373+
universalID = 0;
374+
}
375+
361376
/// <summary>
362377
/// Creates a hash code for the element using the element's name
363378
/// </summary>
@@ -418,7 +433,7 @@ public class Bond {
418433
public string flowLabel = "f";
419434
[JsonProperty]
420435
public string effortLabel = "e";
421-
436+
422437
//The arrow will always point at the sink
423438
/// <summary>
424439
/// Creates a Bond between two elements
@@ -444,7 +459,11 @@ public Bond(int sourceID, int targetID, Element source, Element sink, string lab
444459
this.flow = flow;
445460
this.effort = effort;
446461
this.hasDirection = hasDirection;
447-
AssignID(0, true);
462+
this.ID = source.GetID();
463+
}
464+
465+
public static void resetUni() {
466+
universalID = 0;
448467
}
449468

450469
/// <summary>

BoGLWeb/GraphProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class BondGraphFactory {
1313
/// <exception cref="Exception">Thrown if the any generated BondGraphs are null</exception>
1414
public static (BondGraph, BondGraph, List<BondGraph>) generateBondGraphs(designGraph systemGraph) {
1515
BondGraphFactory factory = new(systemGraph);
16-
16+
1717
//Check that we create all three bond graphs
1818
switch (factory.simplifiedBG) {
1919
case null when factory.unsimplifiedBG is null:

BoGLWeb/wwwroot/backendManager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export namespace backendManager {
5151

5252
// makes BondGraphDisplay
5353
let bonds = JSON.parse(bg.bonds).map(b => {
54-
return new BondGraphBond(b.ID, elements[b.sourceID], elements[b.targetID], b.causalStroke, b.causalStrokeDirection, !b.hasDirection && id != 0, b.effortLabel, b.flowLabel);
54+
return new BondGraphBond(b.ID, elements[b.sourceID], elements[b.targetID], b.causalStroke, b.causalStrokeDirection, !b.hasDirection && id != 0, b.effortLabel, b.flowLabel, 0, elements[b.sourceID].label, elements[b.targetID].label, b.sourceID, b.targetID);
5555
}) as BondGraphBond[];
5656
let bondGraph = new BondGraphDisplay(id, svg, new BondGraph(elements, bonds));
5757

0 commit comments

Comments
 (0)