|
@@ -4,6 +4,7 @@ import numpy as np |
|
|
import websocket |
|
|
import websocket |
|
|
from socket import error as socket_error |
|
|
from socket import error as socket_error |
|
|
import graphstate |
|
|
import graphstate |
|
|
|
|
|
import clifford |
|
|
import util |
|
|
import util |
|
|
|
|
|
|
|
|
class GraphState(graphstate.GraphState, networkx.Graph): |
|
|
class GraphState(graphstate.GraphState, networkx.Graph): |
|
@@ -33,6 +34,9 @@ class GraphState(graphstate.GraphState, networkx.Graph): |
|
|
if not all(("position" in node) for node in self.node.values()): |
|
|
if not all(("position" in node) for node in self.node.values()): |
|
|
self.layout() |
|
|
self.layout() |
|
|
|
|
|
|
|
|
|
|
|
if not all(("vop" in node) for node in self.node.values()): |
|
|
|
|
|
self.add_vops() |
|
|
|
|
|
|
|
|
# Send data to browser and rate-limit |
|
|
# Send data to browser and rate-limit |
|
|
self.ws.send(json.dumps(self.to_json())) |
|
|
self.ws.send(json.dumps(self.to_json())) |
|
|
time.sleep(delay) |
|
|
time.sleep(delay) |
|
@@ -45,4 +49,10 @@ class GraphState(graphstate.GraphState, networkx.Graph): |
|
|
for key, (x, y, z) in pos.items(): |
|
|
for key, (x, y, z) in pos.items(): |
|
|
self.node[key]["position"] = util.xyz(x, y, z) |
|
|
self.node[key]["position"] = util.xyz(x, y, z) |
|
|
|
|
|
|
|
|
|
|
|
def add_vops(self): |
|
|
|
|
|
""" Automatically add vops if they're not present """ |
|
|
|
|
|
for key in self.node: |
|
|
|
|
|
if not "vop" in self.node[key]: |
|
|
|
|
|
self.node[key]["vop"] = clifford.by_name["identity"] |
|
|
|
|
|
|
|
|
|
|
|
|