diff --git a/abp/static/index.html b/abp/static/index.html index e0f3148..4f6529d 100644 --- a/abp/static/index.html +++ b/abp/static/index.html @@ -29,16 +29,14 @@
diff --git a/abp/static/main.css b/abp/static/main.css index 8614b3a..4e17bb9 100644 --- a/abp/static/main.css +++ b/abp/static/main.css @@ -26,6 +26,9 @@ html, body { margin: 0; padding: 0; overflow: hidden; font-size: 10pt; font-fam font-size: 9pt; } +#node_name { + font-size: 12pt; +} #node_data { background-color: black; diff --git a/abp/static/scripts/editor.js b/abp/static/scripts/editor.js index 0605dbe..b22c00d 100644 --- a/abp/static/scripts/editor.js +++ b/abp/static/scripts/editor.js @@ -76,7 +76,6 @@ editor.onShiftClick = function() { websocket.edit({action:"cz", start:found, end:editor.selection}); gui.serverMessage("Acted CZ between " + found + " & " + editor.selection + "."); editor.focus(found); - graph.update(); }; editor.onCtrlClick = function() { @@ -86,7 +85,6 @@ editor.onCtrlClick = function() { editor.focus(found); websocket.edit({action:"hadamard", node:found}); gui.serverMessage("Acted H on node " + found + "."); - graph.update(); }; @@ -138,19 +136,49 @@ editor.findNodeOnRay = function(ray) { return undefined; }; - editor.deleteNode = function() { if (editor.selection === undefined){ return; } websocket.edit({action:"delete", node:editor.selection}); - graph.update(); gui.serverMessage("Deleted node " + editor.selection + "."); editor.selection = undefined; node_data.className = "hidden"; }; +//TODO: loadsa space for DRY here + +editor.hadamard = function() { + if (editor.selection === undefined){ return; } + websocket.edit({action:"hadamard", node:editor.selection}); + gui.serverMessage("Acted Hadamard on node " + editor.selection + "."); +}; + +editor.phase = function() { + if (editor.selection === undefined){ return; } + websocket.edit({action:"phase", node:editor.selection}); + gui.serverMessage("Acted phase on node " + editor.selection + "."); +}; + +editor.measureX = function() { + if (editor.selection === undefined){ return; } + websocket.edit({action:"measure", node:editor.selection, basis:"x"}); + gui.serverMessage("Measured node " + editor.selection + " in X."); +}; + +editor.measureY = function() { + if (editor.selection === undefined){ return; } + websocket.edit({action:"measure", node:editor.selection, basis:"y"}); + gui.serverMessage("Measured node " + editor.selection + " in Y."); +}; + +editor.measureZ = function() { + if (editor.selection === undefined){ return; } + websocket.edit({action:"measure", node:editor.selection, basis:"z"}); + gui.serverMessage("Measured node " + editor.selection + " in z."); +}; + editor.localComplementation = function() { if (editor.selection === undefined){ return; } + websocket.edit({action:"localcomplementation", node:editor.selection}); abj.local_complementation(editor.selection); - graph.update(); gui.serverMessage("Inverted neighbourhood of " + editor.selection + "."); }; diff --git a/bin/abpserver b/bin/abpserver index 25786d5..f50419d 100755 --- a/bin/abpserver +++ b/bin/abpserver @@ -25,12 +25,20 @@ def process_edit(edit, client, server): if action == "create": local_state.add_qubit(edit["name"], position=edit["position"], vop=0) - if action == "cz": + elif action == "cz": local_state.act_cz(edit["start"], edit["end"]) - if action == "hadamard": - local_state.act_cz(edit["start"], edit["end"]) - if action == "delete": + elif action == "hadamard": + local_state.act_hadamard(edit["node"]) + elif action == "phase": + local_state.act_local_rotation(edit["node"], "phase") + elif action == "delete": local_state._del_node(edit["node"]) + elif action == "localcomplementation": + local_state.local_complementation(edit["node"]) + elif action == "measure": + local_state.measure(edit["node"], "p"+edit["basis"]) + else: + pass server.send_message(client, json.dumps(local_state.to_json()))