From 5567258c53407594c93d455e3011d2c68023b7f3 Mon Sep 17 00:00:00 2001 From: Pete Shadbolt Date: Fri, 4 Nov 2016 21:30:24 +0000 Subject: [PATCH] Now I can do CZ gates. Focus sucks though. --- abp/static/scripts/editor.js | 6 ++++-- bin/abpserver | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/abp/static/scripts/editor.js b/abp/static/scripts/editor.js index 71f1610..29dcedd 100644 --- a/abp/static/scripts/editor.js +++ b/abp/static/scripts/editor.js @@ -47,8 +47,9 @@ editor.addQubitAtPoint = function(point) { return; } point.round(); - var new_node = Math.floor(point.x*1000000 + point.y*1000 + point.z); + var new_node = Math.floor(point.x) + "," + Math.floor(point.y) + "," + Math.floor(point.z); websocket.edit({action:"create", name:new_node, position: point}); + editor.focus(new_node); gui.serverMessage("Created node " + new_node +"."); }; @@ -69,7 +70,8 @@ editor.onShiftClick = function() { if (found === undefined){ return; } if (editor.selection === undefined){ return; } if (found === editor.selection){ return; } - abj.act_cz(found, editor.selection); + //abj.act_cz(found, editor.selection); + websocket.edit({action:"cz", start:found, end:editor.selection}); editor.focus(found); gui.serverMessage("Acted CZ between " + found + " & " + editor.selection + "."); graph.update(); diff --git a/bin/abpserver b/bin/abpserver index ccf545d..a78a6eb 100755 --- a/bin/abpserver +++ b/bin/abpserver @@ -20,9 +20,19 @@ local_state = abp.GraphState() def process_edit(edit, server): action = edit["action"] + + print edit + + print local_state.node.keys() + if action == "create": - local_state.add_qubit(edit["name"], position=edit["position"]) - server.send_message_to_all(json.dumps(local_state.to_json())) + print type(edit["name"]) + local_state.add_qubit(edit["name"], position=edit["position"], vop=0) + if action == "cz": + local_state.act_cz(edit["start"], edit["end"]) + + server.send_message_to_all(json.dumps(local_state.to_json())) + def new_message(client, server, message):