diff --git a/abp/static/scripts/editor.js b/abp/static/scripts/editor.js index 29dcedd..f5bc9e7 100644 --- a/abp/static/scripts/editor.js +++ b/abp/static/scripts/editor.js @@ -32,14 +32,9 @@ editor.onFreeMove = function() { }; editor.focus = function(node) { - editor.grid.position.copy(abj.node[node].position); - gui.controls.target.copy(abj.node[node].position); gui.hideNodeMessage(); editor.selection = node; gui.serverMessage("Selected node " + node + "."); - node_name.innerHTML = "Node " + node; - node_data.className = "visible"; - node_vop.innerHTML = "VOP: " + abj.node[node].vop; }; editor.addQubitAtPoint = function(point) { @@ -136,6 +131,7 @@ editor.findNodeOnRay = function(ray) { return undefined; }; + editor.deleteNode = function() { if (editor.selection === undefined){ return; } abj.del_node(editor.selection); diff --git a/abp/static/scripts/graph.js b/abp/static/scripts/graph.js index 98bd51b..1f09aaa 100644 --- a/abp/static/scripts/graph.js +++ b/abp/static/scripts/graph.js @@ -47,6 +47,17 @@ graph.update = function(newState) { edges.add(newEdge); } + if (editor.selection) { + var node = editor.selection; + editor.grid.position.copy(abj.node[node].position); + gui.controls.target.copy(abj.node[node].position); + node_name.innerHTML = "Node " + node; + node_data.className = "visible"; + node_vop.innerHTML = "VOP: " + abj.node[node].vop; + } else { + node_data.className = "hidden"; + } + var particles = new THREE.Points(geometry, materials.qubit); var object = new THREE.Object3D(); object.name = "graphstate"; @@ -54,5 +65,6 @@ graph.update = function(newState) { object.add(edges); gui.scene.add(object); gui.render(); + }; diff --git a/bin/abpserver b/bin/abpserver index a78a6eb..15ed0f7 100755 --- a/bin/abpserver +++ b/bin/abpserver @@ -25,11 +25,14 @@ def process_edit(edit, server): print local_state.node.keys() - if action == "create": - 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"]) + try: + if action == "create": + 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"]) + except Exception as e: + print e server.send_message_to_all(json.dumps(local_state.to_json()))