瀏覽代碼

Selection now works - pretty hacky though.

master
Pete Shadbolt 8 年之前
父節點
當前提交
1c80b1f394
共有 3 個檔案被更改,包括 21 行新增10 行删除
  1. +1
    -5
      abp/static/scripts/editor.js
  2. +12
    -0
      abp/static/scripts/graph.js
  3. +8
    -5
      bin/abpserver

+ 1
- 5
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);


+ 12
- 0
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();

};


+ 8
- 5
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()))



Loading…
取消
儲存