Skip to content

Commit

Permalink
hasse is back as default
Browse files Browse the repository at this point in the history
  • Loading branch information
fionnkeogh committed Jul 3, 2023
1 parent 354141d commit 665bbec
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 22 deletions.
24 changes: 18 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,25 @@ def gen_protosynergetic():
return None

@eel.expose
def calculate_orgs():
network = state.get_hasse_structure()
if network != None:
nodes, edges, heading, height, width, options = network.get_network_data()
return {"nodes": nodes, "edges": edges, "heading": heading, "height": height, "width": width, "options": options}
def calculate_orgs(full):
if full:
print("Full")
network = state.get_hasse_structure()
print("All Good")
print(network.get_network_data())
if network != None:
nodes, edges, heading, height, width, options = network.get_network_data()
return {"nodes": nodes, "edges": edges, "heading": heading, "height": height, "width": width, "options": options}
else:
return None
else:
return None
print("Lite")
network = state.get_hasse_structure_lite()
if network != None:
nodes, edges, heading, height, width, options = network.get_network_data()
return {"nodes": nodes, "edges": edges, "heading": heading, "height": height, "width": width, "options": options}
else:
return None

@eel.expose
def get_selected_org(org):
Expand Down
19 changes: 14 additions & 5 deletions src/Hasse/Hasse.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
let modal;
let cur_org = "";
let full = false;
let graphs = [
{ id: 1, text: `Reactive Organisation Structures` },
{ id: 2, text: `Synergistic Structures` }
Expand Down Expand Up @@ -51,9 +53,10 @@
is_loaded().then(result => {
has_file_open = result;
});
let promise = eel.calculate_orgs()();
let promise = eel.calculate_orgs(full)();
promise.then(result => {
if(result == null) {
console.log("NOTHING");
return;
}
console.log(result);
Expand Down Expand Up @@ -95,7 +98,7 @@
var ids = properties.nodes;
console.log(network);
var clickedNode = network.body.nodes[ids]; //nodes.get(ids)[0];
if (clickedNode && Array.from(clickedNode.options.label)[0] != "C") {
if (clickedNode && (Array.from(clickedNode.options.label)[0] == "L" || Array.from(clickedNode.options.label)[0] == "O")) {
console.log('clicked nodes:', clickedNode);
cur_org = clickedNode.options;
console.log(cur_org);
Expand Down Expand Up @@ -192,10 +195,16 @@

Y-Space: {y_space[0]}
<Slider bind:value = {y_space} max="200"/>

Use Layout:
<!--
<label>
Use Layout:
<input type=checkbox bind:value={useLayout} style="opacity: 1; position: relative;">
</label>
<br> -->
<label>
<input type=checkbox bind:value={useLayout}>
Full Graph:
<input type=checkbox bind:value={full} on:change={drawLattice} style="opacity: 1; position: relative;">
</label>
<br>
<!-- svelte-ignore a11y-missing-attribute -->
Expand Down
35 changes: 27 additions & 8 deletions src/store/Store.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def set_new_rn(self, path: Union[str, None], RN: Union[pyRN, None]):
self.network_graph: Union[Network, None] = None
self.protosynergies_graph: Union[Network, None] = None
self.hasse_graph: Union[Network, None] = None
self.hasse_graph_lite: Union[Network, None] = None
self.synergies_graph: Union[Network, None] = None
self.model: bool = False
self.simple_rw: bool = False
Expand Down Expand Up @@ -120,7 +121,7 @@ def add_outflow(self, extra) -> bool:
else:
return False

def generate_organizations(self) -> bool:
def generate_organizations(self, boolean) -> bool:
if self.reaction_network != None:
try:
self.reaction_network.setGenerators()
Expand All @@ -129,15 +130,22 @@ def generate_organizations(self) -> bool:
self.organizations = self.reaction_network.SynStrOrgListBtArray
print(self.organizations)
net=self.reaction_network.getHassePvFromSynStr(self.reaction_network.SynStrNx)
print(net)
print("NET")
net2=self.reaction_network.getHasseNxFromBtList(self.reaction_network.SynStrOrgListBtArray,setlabel="L")
print("1")
rn: pyRN = self.reaction_network
#net = nx.relabel_nodes(net, lambda x: str(rn.getIndArrayFromBt(bt(x))))
#nt = Network('500px', '500px',directed=False,notebook=False)
#nt.toggle_physics(False)
#nt.from_nx(net)
print("2")
net2 = nx.relabel_nodes(net2, lambda x: str(rn.getIndArrayFromBt(bt(x))))
print("3")
nt = Network('500px', '500px',directed=False,notebook=False)
print("4")
nt.toggle_physics(False)
nt.from_nx(net2)
print("Nothig wrong")
self.hasse_graph_lite = nt
self.hasse_graph = net
except:
print("FUGG")
print("Except")
return False
else:
return True
Expand Down Expand Up @@ -294,11 +302,22 @@ def get_protosynergetic_structure(self) -> Union[Network, None]:
else:
return None

def get_hasse_structure_lite(self) -> Union[Network, None]:
if self.hasse_graph_lite != None:
return self.hasse_graph_lite
elif self.hasse_graph_lite == None and self.reaction_network != None:
if self.generate_organizations(False):
return self.hasse_graph_lite
else:
return None
else:
return None

def get_hasse_structure(self) -> Union[Network, None]:
if self.hasse_graph != None:
return self.hasse_graph
elif self.hasse_graph == None and self.reaction_network != None:
if self.generate_organizations():
if self.generate_organizations(True):
return self.hasse_graph
else:
return None
Expand Down
2 changes: 1 addition & 1 deletion static/build/bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/build/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion static/build/bundle.js.map

Large diffs are not rendered by default.

0 comments on commit 665bbec

Please sign in to comment.