basically finish new property list?
This commit is contained in:
parent
fe11151e7c
commit
acefab7b9a
|
@ -44,7 +44,7 @@ def run():
|
||||||
def initDecorateDb(db):
|
def initDecorateDb(db):
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
cur.execute("CREATE TABLE graph([graph] INTEGER, [graph_name] TEXT, [width] INTEGER, [height] INTEGER, [index] INTEGER, [belong_to] TEXT);")
|
cur.execute("CREATE TABLE graph([graph] INTEGER, [graph_name] TEXT, [width] INTEGER, [height] INTEGER, [index] INTEGER, [belong_to] TEXT);")
|
||||||
cur.execute("CREATE TABLE info([target] INTEGER, [attach_bb] INTEGER, [is_setting] INTEGER, [field] TEXT, [data] TEXT);")
|
cur.execute("CREATE TABLE info([target] INTEGER, [attach_bb] INTEGER, [is_setting] INTEGER, [name] TEXT, [field] TEXT, [data] TEXT);")
|
||||||
|
|
||||||
cur.execute("CREATE TABLE block([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [pin-ptarget] TEXT, [pin-pin] TEXT, [pin-pout] TEXT, [pin-bin] TEXT, [pin-bout] TEXT, [x] REAL, [y] REAL, [width] REAL, [height] REAL, [expandable] INTEGER);")
|
cur.execute("CREATE TABLE block([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [pin-ptarget] TEXT, [pin-pin] TEXT, [pin-pout] TEXT, [pin-bin] TEXT, [pin-bout] TEXT, [x] REAL, [y] REAL, [width] REAL, [height] REAL, [expandable] INTEGER);")
|
||||||
cur.execute("CREATE TABLE cell([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [x] REAL, [y] REAL, [type] INTEGER);")
|
cur.execute("CREATE TABLE cell([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [x] REAL, [y] REAL, [type] INTEGER);")
|
||||||
|
@ -673,33 +673,38 @@ def buildInfo(exDb, deDb):
|
||||||
|
|
||||||
# declare tiny storage for convenient query
|
# declare tiny storage for convenient query
|
||||||
tinyStorageKey = 0
|
tinyStorageKey = 0
|
||||||
tineStorageBB = 0
|
tinyStorageBB = -1
|
||||||
tineStorageSetting = 0
|
tinyStorageSetting = 0
|
||||||
|
tinyStorageName = ""
|
||||||
|
|
||||||
# export local data (including proto bb internal data)
|
# export local data (including proto bb internal data)
|
||||||
exInfoCur.execute("SELECT * FROM pData;")
|
exInfoCur.execute("SELECT * FROM pData;")
|
||||||
for i in exInfoCur.fetchall():
|
for i in exInfoCur.fetchall():
|
||||||
attachBB = 0
|
attachBB = -1
|
||||||
isSetting = 0
|
isSetting = 0
|
||||||
|
infoName = ""
|
||||||
|
|
||||||
if i[2] == tinyStorageKey:
|
if i[2] == tinyStorageKey:
|
||||||
attachBB = tineStorageBB
|
attachBB = tinyStorageBB
|
||||||
isSetting = tineStorageSetting
|
isSetting = tinyStorageSetting
|
||||||
|
infotName = tinyStorageName
|
||||||
else:
|
else:
|
||||||
# clear storage first
|
# clear storage first
|
||||||
tineStorageBB = 0
|
tinyStorageBB = -1
|
||||||
tineStorageSetting = 0
|
tinyStorageSetting = 0
|
||||||
|
tinyStorageName = ""
|
||||||
|
|
||||||
# query correspond pLocal
|
# query correspond pLocal
|
||||||
exQueryCur.execute("SELECT [belong_to], [is_setting] FROM pLocal WHERE [thisobj] = ?", (i[2], ))
|
exQueryCur.execute("SELECT [belong_to], [is_setting], [name] FROM pLocal WHERE [thisobj] = ?", (i[2], ))
|
||||||
plocalCache = exQueryCur.fetchone()
|
plocalCache = exQueryCur.fetchone()
|
||||||
if plocalCache is not None:
|
if plocalCache is not None:
|
||||||
# add setting config
|
# add setting config
|
||||||
tineStorageSetting = isSetting = plocalCache[1]
|
tinyStorageSetting = isSetting = plocalCache[1]
|
||||||
|
tinyStorageName = infoName = plocalCache[2]
|
||||||
# query bb again
|
# query bb again
|
||||||
exQueryCur.execute("SELECT [thisobj] FROM behavior WHERE ( [thisobj] = ? AND [type] = 0)", (plocalCache[0], ))
|
exQueryCur.execute("SELECT [thisobj] FROM behavior WHERE ([thisobj] = ? AND [type] = 0)", (plocalCache[0], ))
|
||||||
behaviorCache = exQueryCur.fetchone()
|
behaviorCache = exQueryCur.fetchone()
|
||||||
if behaviorCache is not None:
|
if behaviorCache is not None:
|
||||||
tineStorageBB = attachBB = behaviorCache[0]
|
tinyStorageBB = attachBB = behaviorCache[0]
|
||||||
|
|
||||||
deCur.execute("INSERT INTO info VALUES (?, ?, ?, ?, ?)", (i[2], attachBB, isSetting, i[0], i[1]))
|
deCur.execute("INSERT INTO info VALUES (?, ?, ?, ?, ?, ?)", (i[2], attachBB, isSetting, infoName, i[0], i[1]))
|
|
@ -192,18 +192,36 @@ def viewerHandle(scriptPath):
|
||||||
def actionHandle(scriptPath):
|
def actionHandle(scriptPath):
|
||||||
cache = request.form['operation']
|
cache = request.form['operation']
|
||||||
if cache == "info":
|
if cache == "info":
|
||||||
return infoHandle(request.form['target'])
|
return infoHandle(request.form['target'], request.form['tag'])
|
||||||
elif cache == "move":
|
elif cache == "move":
|
||||||
return moveHandle(request.form['target'])
|
return moveHandle(request.form['target'])
|
||||||
else:
|
else:
|
||||||
abort(400)
|
abort(400)
|
||||||
|
|
||||||
def infoHandle(target):
|
def infoHandle(target, tag):
|
||||||
cur = get_db().cursor()
|
cur = get_db().cursor()
|
||||||
cur.execute("SELECT [field], [data] FROM info WHERE [target] == ?", (target, ))
|
|
||||||
data = {}
|
data = {}
|
||||||
|
existedSet = set()
|
||||||
|
if tag == 0:
|
||||||
|
# call from cell
|
||||||
|
cur.execute("SELECT * FROM info WHERE [target] == ?", (target, ))
|
||||||
|
elif tag == 1:
|
||||||
|
# call from bb
|
||||||
|
cur.execute("SELECT * FROM info WHERE [attach_bb] == ?", (target, ))
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
# get data
|
||||||
for i in cur.fetchall():
|
for i in cur.fetchall():
|
||||||
data[i[0]] = i[1]
|
if i[0] in existedSet:
|
||||||
|
data[i[0]]['data'].append((i[4], i[5]))
|
||||||
|
else:
|
||||||
|
existedSet.add(i[0])
|
||||||
|
data[i[0]] = {
|
||||||
|
'name': i[3],
|
||||||
|
'is_setting': True if i[2] != 0 else False,
|
||||||
|
'data': []
|
||||||
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,9 @@ text.link-delay {
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
/* property list*/
|
||||||
|
|
||||||
|
pre.propertyItem {
|
||||||
border: 1px solid black;
|
border: 1px solid black;
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
@ -93,3 +95,19 @@ pre {
|
||||||
background: #3f3f3f;
|
background: #3f3f3f;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code.propertyItem {
|
||||||
|
border: 1px solid black;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 5px;
|
||||||
|
margin: 5px;
|
||||||
|
background: gray;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.propertyItem {
|
||||||
|
margin: 5px;
|
||||||
|
border: 1px solid gray;
|
||||||
|
border-radius: 2px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
|
@ -96,7 +96,9 @@ function highlightLink(target) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryInfo(obj) {
|
// type = 0: call from cell
|
||||||
|
// type = 1: call from bb
|
||||||
|
function queryInfo(type, obj) {
|
||||||
// confirm user enable this function
|
// confirm user enable this function
|
||||||
if (!currentSettings["properties"])
|
if (!currentSettings["properties"])
|
||||||
return;
|
return;
|
||||||
|
@ -104,16 +106,29 @@ function queryInfo(obj) {
|
||||||
$.post(window.location,
|
$.post(window.location,
|
||||||
{
|
{
|
||||||
operation: "info",
|
operation: "info",
|
||||||
|
tag: type,
|
||||||
target: obj
|
target: obj
|
||||||
},
|
},
|
||||||
function (data, status) {
|
function (data, status) {
|
||||||
//set id
|
|
||||||
$("#sidepanel-properties-id").text(obj);
|
|
||||||
|
|
||||||
//set data
|
//set data
|
||||||
$("#sidepanel-properties-container").empty()
|
$("#sidepanel-properties-container").empty()
|
||||||
for (var key in data) {
|
for (var key in data) {
|
||||||
$("#sidepanel-properties-container").append("<p><b>" + key + ":</b><br /><pre>" + data[key] + "</pre></p>")
|
$("#sidepanel-properties-container").append("<div class=\"propertyItem\"></div>");
|
||||||
|
|
||||||
|
var box = $("#sidepanel-properties-container div:last-child");
|
||||||
|
if (data[key]["is_setting"])
|
||||||
|
$(box).append("<p><code class=\"propertyItem\">S</code><b></b><i></i></p>");
|
||||||
|
else
|
||||||
|
$(box).append("<p><b></b><i></i></p>");
|
||||||
|
|
||||||
|
$(box).find("p b").text(data[key]["name"]);
|
||||||
|
$(box).find("p i").text("(" + key + ")");
|
||||||
|
|
||||||
|
for (var i = 0; i < data[key]['data'].length; i++) {
|
||||||
|
$(box).append("<p></p><pre class=\"propertyItem\"></pre>")
|
||||||
|
$(box).find("p:last-child").text(data[key]['data'][0])
|
||||||
|
$(box).find("pre:last-child").text(data[key]['data'][1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<div>
|
<div>
|
||||||
{# blocks content #}
|
{# blocks content #}
|
||||||
{% for i in blocks %}
|
{% for i in blocks %}
|
||||||
<div class="block-body" style="height: {{ i[12] }}px; width: {{ i[11] }}px; top: {{ i[10] }}px; left: {{ i[9] }}px;" onclick="highlightLink({{ i[1] }});">
|
<div class="block-body" style="height: {{ i[12] }}px; width: {{ i[11] }}px; top: {{ i[10] }}px; left: {{ i[9] }}px;" ondblclick="queryInfo(1,{{ i[1] }});" onclick="highlightLink({{ i[1] }});">
|
||||||
{% if i[4] != '{}' %}
|
{% if i[4] != '{}' %}
|
||||||
<div class="block-target" title="{{ "Name: %s\nType: %s"|format(*pinDecoder2(i[4])) }}" style="height: 6px; width: 6px; top: 0; left: 0;" onclick="highlightLink({{ pinDecoder(i[4]).id }});"></div>
|
<div class="block-target" title="{{ "Name: %s\nType: %s"|format(*pinDecoder2(i[4])) }}" style="height: 6px; width: 6px; top: 0; left: 0;" onclick="highlightLink({{ pinDecoder(i[4]).id }});"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
{% for i in cells %}
|
{% for i in cells %}
|
||||||
<div class="{% if i[6] == 0 %}cell-plocal{% elif i[6] == 1 %}cell-shortcut{% elif i[6] == 2 %}cell-pio{% elif i[6] == 3 %}cell-bio{% else %}cell-ptarget{% endif %}"
|
<div class="{% if i[6] == 0 %}cell-plocal{% elif i[6] == 1 %}cell-shortcut{% elif i[6] == 2 %}cell-pio{% elif i[6] == 3 %}cell-bio{% else %}cell-ptarget{% endif %}"
|
||||||
style="height: {% if i[6] == 2 or i[6] == 3 %}6{% else %}5{% endif %}px; width: {% if i[6] == 2 or i[6] == 3 %}6{% else %}15{% endif %}px; top: {{ i[5] }}px; left: {{ i[4] }}px;"
|
style="height: {% if i[6] == 2 or i[6] == 3 %}6{% else %}5{% endif %}px; width: {% if i[6] == 2 or i[6] == 3 %}6{% else %}15{% endif %}px; top: {{ i[5] }}px; left: {{ i[4] }}px;"
|
||||||
title="{{ "Name: %s\nType: %s"|format(i[2], i[3]) }}" ondblclick="queryInfo({{ i[1] }});" onclick="highlightLink({{ i[1] }});"></div>
|
title="{{ "Name: %s\nType: %s"|format(i[2], i[3]) }}" ondblclick="queryInfo(0,{{ i[1] }});" onclick="highlightLink({{ i[1] }});"></div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
<svg version="1.1" width="{{ gWidth }}px" height="{{ gHeight }}px" style="position: absolute; top: 0; left: 0;pointer-events: none;">
|
<svg version="1.1" width="{{ gWidth }}px" height="{{ gHeight }}px" style="position: absolute; top: 0; left: 0;pointer-events: none;">
|
||||||
|
@ -89,7 +89,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="tabpanel_1_1" class="tabpanel_1" style="display: flex; flex-flow: column;width: 100%; height: 100%; display: flex; flex-flow: column;">
|
<div id="tabpanel_1_1" class="tabpanel_1" style="display: flex; flex-flow: column;width: 100%; height: 100%; display: flex; flex-flow: column;">
|
||||||
<p style="margin: 5px;">Properties of <b id="sidepanel-properties-id">---</b></p>
|
|
||||||
<div id="sidepanel-properties-container" style="width: 100%; height: 100%; overflow: scroll;">
|
<div id="sidepanel-properties-container" style="width: 100%; height: 100%; overflow: scroll;">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user