finish cell generate(untested)

This commit is contained in:
2020-04-12 15:19:13 +08:00
parent b24a341da6
commit 812ea62561
9 changed files with 422 additions and 108 deletions

View File

@ -1,3 +1,5 @@
import json
FONT_SIZE = 12
GRAPH_POFFSET = 40 # 主体bb的p距离左边框距离
@ -5,17 +7,16 @@ GRAPH_BOFFSET = 40 # 主体bb的b距离上边框距离
GRAPH_PSPAN = 20 # 主体bb的每个p之间的水平间距
GRAPH_BSPAN = 20 # 主体bb的每个b之间的垂直间距
GRAPH_LAYER_SPAN = 50 # 绘图中各个bb层之间的间距
GRAPH_BB_SPAN = 25 # 绘图中每个bb之间的距离
GRAPH_BB_SPAN = 25 # 绘图中每个bb之间的距离扩展到Oper和不可插入的local之间的距离
GRAPH_SPAN_BB_POPER = 60 # 每个bb上面挂载的oper和被挂载bb之间的垂直距离 和 每个bb上面挂载的oper的各层之间的垂直距离
GRAPH_SPAN_BB_PLOCAL = 10 # 每个bb上面挂载的plocal和被挂载bb之间的垂直距离
GRAPH_CONTENTOFFSET_X = 40 # 绘图内容原点到左边框的距离
GRAPH_CONTENTOFFSET_Y = 40 # 绘图内容原点到顶边框的距离
BB_POFFSET = 20 # bb框中的p距离左边框距离
BB_BOFFSET = 10 # bb框中的b距离上边框距离
BB_PSPAN = 20 # bb框每个p之间的水平间距
BB_BSPAN = 20 # bb框每个b之间的垂直间距
BB_PBSIZE = 6 # bb框中o和b的正方形符号的边长
BB_PBSIZE = 6 # bb框中o和b的正方形符号的边长扩展到graph中的p/b大小
CELL_WIDTH = 15
CELL_HEIGHT = 5
@ -29,11 +30,31 @@ class dbBLinkInputOutputType(object):
INPUT = 0
OUTPUT = 1
class LinkType(object):
class CellType(object):
PLOCAL = 0
SHORTCUR = 1
SHORTCUT = 1
PIO = 2
BIO = 3
PTARGET = 4
class LocalUsageType(object):
PIN = 0
POUT = 1
PLOCAL = 2
class JsonCustomEncoder(json.JSONEncoder):
def default(self, field):
if isinstance(field, PinInformation):
return {'id': field.id, 'name': field.name, 'type': field.type}
else:
return json.JSONEncoder.default(self, field)
class BlockCellItem(object):
def __init__(self, x, y, w, h):
self.x = x
self.y = y
self.w = w
self.h = h
class BBTreeNode(object):
def __init__(self, ckid, layer):
@ -45,14 +66,15 @@ class BBResult(object):
def __init__(self, name, assistName, pin, pout, bin, bout, expandable):
self.name = name
self.assistName = assistName
self.ptargetData = None
self.pin = int(pin)
self.pinData = []
self.pinData = None
self.pout = int(pout)
self.poutData = []
self.poutData = None
self.bin = int(bin)
self.binData = []
self.binData = None
self.bout = int(bout)
self.boutData = []
self.boutData = None
self.x = 0.0
self.y = 0.0
self.width = 0.0
@ -60,7 +82,7 @@ class BBResult(object):
self.expandable = expandable
def computSize(self):
wText = max(len(self.name), len(self.assistName)) * FONT_SIZE / 2
wText = max(len(self.name), len(self.assistName)) * FONT_SIZE / 3 * 2
hText = FONT_SIZE * 3
wp = max(self.pin, self.pout) * (BB_PBSIZE + BB_PSPAN)
@ -74,13 +96,13 @@ class OperResult(object):
self.name = name
self.x = 0.0
self.y = 0.0
self.pinData = []
self.poutData = []
self.pinData = None
self.poutData = None
self.height = 0.0
self.width = 0.0
def computSize(self):
wText = len(self.name) * FONT_SIZE / 2
wText = len(self.name) * FONT_SIZE / 3 * 2
hText = FONT_SIZE * 3
wp = 2 * BB_POFFSET + 2 * (BB_PBSIZE + BB_PSPAN)
@ -88,3 +110,18 @@ class OperResult(object):
self.width = max(wp, wText)
self.height = max(hb, hText)
class PinInformation(object):
def __init__(self, id, name, type):
self.id = id
self.name = name
self.type = type
class LocalUsageItem(object):
def __init__(self, count, isshortcut, internal_type):
self.count = count
self.lastUse = -1
self.lastDirection = 0 # 0 for pIn, 1 for pOut
self.lastIndex = -1 # -1 for pTarget, otherwise the real index
self.isshortcut = isshortcut
self.internal_type = internal_type # 0 pIn, 1 pOut, 2 pLocal. for convenient query match data

View File

@ -1,6 +1,6 @@
import sqlite3
import DecoratorConstValue as dcv
import queue
import json
def run():
exportDb = sqlite3.connect('export.db')
@ -16,8 +16,12 @@ def run():
decorateGraph(exportDb, decorateDb, graphList)
# decorate each graph
currentGraphBlockCell = {}
for i in graphList:
(plocal_layer, bbMap, operMap) = buildBlock(exportDb, decorateDb, i)
currentGraphBlockCell.clear()
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
# give up all change of eexport.db (because no change)
exportDb.close()
@ -63,7 +67,7 @@ def decorateGraph(exDb, deDb, graph):
# sub bb
deCur.execute("INSERT INTO graph VALUES(?, ?, 0, 0, -1, '')", (lines[0], lines[2]))
def buildBlock(exDb, deDb, target):
def buildBlock(exDb, deDb, target, currentGraphBlockCell):
exCur = exDb.cursor()
deCur = deDb.cursor()
@ -74,7 +78,8 @@ def buildBlock(exDb, deDb, target):
# layer start from 2, 0 is occupied for pLocal, 1 is occupied for pOper
arrangedLayer = recursiveBuildBBTree(treeRoot, exCur, processedBB, 2, 0, target)
# get no linked bb and place them. linked bb position will be computed following
# get no linked bb and place them. linked bb position will be computed
# following
# calc each bb's x postion, as for y, calc later
# flat bb tree
arrangedLayer+=1
@ -82,7 +87,7 @@ def buildBlock(exDb, deDb, target):
bbResult = {}
bb_layer_map = {}
baseX = dcv.GRAPH_CONTENTOFFSET_X
exCur.execute('SELECT [thisobj], [name], [type], [proto_name], [pin_count] FROM behavior WHERE parent == ?', (target, ))
exCur.execute('SELECT [thisobj], [name], [type], [proto_name], [pin_count] FROM behavior WHERE parent == ?', (target,))
for i in exCur.fetchall():
pinSplit = i[4].split(',')
bbCache = dcv.BBResult(i[1], i[3], pinSplit[1], pinSplit[2], pinSplit[3], pinSplit[4], (i[0] if i[2] != 0 else -1))
@ -103,7 +108,7 @@ def buildBlock(exDb, deDb, target):
processedOper = set()
pluggedOper = {}
occupiedLayerCountForSpecificBB = {}
exCur.execute('SELECT [thisobj] FROM pOper WHERE [belong_to] == ?', (target, ))
exCur.execute('SELECT [thisobj] FROM pOper WHERE [belong_to] == ?', (target,))
newCur = exDb.cursor()
newCur2 = exDb.cursor()
for i in exCur.fetchall():
@ -151,7 +156,7 @@ def buildBlock(exDb, deDb, target):
# calc oper position
# flat oper tree
operResult = {}
exCur.execute('SELECT [thisobj], [op] FROM pOper WHERE [belong_to] == ?', (target, ))
exCur.execute('SELECT [thisobj], [op] FROM pOper WHERE [belong_to] == ?', (target,))
homelessOperCurrentX = dcv.GRAPH_CONTENTOFFSET_X
for i in exCur.fetchall():
if i[0] not in processedOper:
@ -169,7 +174,7 @@ def buildBlock(exDb, deDb, target):
jCache = pluggedOper[i][j]
baseX = cache.x
for q in jCache:
exCur.execute("SELECT [op] FROM pOper WHERE [thisobj] == ?", (q, ))
exCur.execute("SELECT [op] FROM pOper WHERE [thisobj] == ?", (q,))
cache2 = dcv.OperResult(exCur.fetchone()[0])
cache2.computSize()
cache2.x = baseX
@ -178,42 +183,74 @@ def buildBlock(exDb, deDb, target):
operResult[q] = cache2
# query bb pin's data
listCache = []
listItemCache = None
for i in allBB:
cache = bbResult[i]
exCur.execute("SELECT [thisobj] FROM bIn WHERE [belong_to] == ? ORDER BY [index];", (i, ))
exCur.execute("SELECT [thisobj], [name], [type] FROM pTarget WHERE [belong_to] == ?;", (i,))
temp = exCur.fetchone()
if temp == None:
cache.ptargetData = ''
else:
cache.ptargetData = json.dumps(dcv.PinInformation(temp[0], temp[1], temp[2]), cls = dcv.JsonCustomEncoder)
listCache.clear()
exCur.execute("SELECT [thisobj], [name] FROM bIn WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.binData.append(str(j[0]))
exCur.execute("SELECT [thisobj] FROM bOut WHERE [belong_to] == ? ORDER BY [index];", (i, ))
listItemCache = dcv.PinInformation(j[0], j[1], '')
listCache.append(listItemCache)
cache.binData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
listCache.clear()
exCur.execute("SELECT [thisobj], [name] FROM bOut WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.boutData.append(str(j[0]))
exCur.execute("SELECT [thisobj] FROM pIn WHERE [belong_to] == ? ORDER BY [index];", (i, ))
listItemCache = dcv.PinInformation(j[0], j[1], '')
listCache.append(listItemCache)
cache.boutData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
listCache.clear()
exCur.execute("SELECT [thisobj], [name], [type] FROM pIn WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.pinData.append(str(j[0]))
exCur.execute("SELECT [thisobj] FROM pOut WHERE [belong_to] == ? ORDER BY [index];", (i, ))
listItemCache = dcv.PinInformation(j[0], j[1], j[2])
listCache.append(listItemCache)
cache.pinData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
listCache.clear()
exCur.execute("SELECT [thisobj], [name], [type] FROM pOut WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.poutData.append(str(j[0]))
listItemCache = dcv.PinInformation(j[0], j[1], j[2])
listCache.append(listItemCache)
cache.poutData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
# query oper pin's data
for i in operResult.keys():
cache = operResult[i]
exCur.execute("SELECT [thisobj] FROM pIn WHERE [belong_to] == ? ORDER BY [index];", (i, ))
listCache.clear()
exCur.execute("SELECT [thisobj], [name], [type] FROM pIn WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.pinData.append(str(j[0]))
exCur.execute("SELECT [thisobj] FROM pOut WHERE [belong_to] == ? ORDER BY [index];", (i, ))
listItemCache = dcv.PinInformation(j[0], j[1], j[2])
listCache.append(listItemCache)
cache.pinData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
listCache.clear()
exCur.execute("SELECT [thisobj], [name], [type] FROM pOut WHERE [belong_to] == ? ORDER BY [index];", (i,))
for j in exCur.fetchall():
cache.poutData.append(str(j[0]))
listItemCache = dcv.PinInformation(j[0], j[1], j[2])
listCache.append(listItemCache)
cache.poutData = json.dumps(listCache, cls = dcv.JsonCustomEncoder)
# write to database and return
for i in bbResult.keys():
cache = bbResult[i]
currentGraphBlockCell[i] = dcv.BlockCellItem(cache.x, cache.y, cache.width, cache.height)
deCur.execute('INSERT INTO block VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
(target, i, cache.name, cache.assistName, ','.join(cache.pinData), ','.join(cache.poutData), ','.join(cache.binData), ','.join(cache.boutData), cache.x, cache.y, cache.width, cache.height, cache.expandable))
(target, i, cache.name, cache.assistName, cache.pinData, cache.poutData, cache.binData, cache.boutData, cache.x, cache.y, cache.width, cache.height, cache.expandable))
for i in operResult.keys():
cache = operResult[i]
deCur.execute("INSERT INTO block VALUES (?, ?, ?, '', ?, ?, '', '', ?, ?, ?, ?, -1)",
(target, i, cache.name, ','.join(cache.pinData), ','.join(cache.poutData), cache.x, cache.y, cache.width, cache.height))
return (layer_y[0] - dcv.CELL_HEIGHT, bbResult, operResult)
currentGraphBlockCell[i] = dcv.BlockCellItem(cache.x, cache.y, cache.width, cache.height)
deCur.execute("INSERT INTO block VALUES (?, ?, ?, '', ?, ?, '[]', '[]', ?, ?, ?, ?, -1)",
(target, i, cache.name, cache.pinData, cache.poutData, cache.x, cache.y, cache.width, cache.height))
def recursiveBuildBBTree(node, exCur, processedBB, layer, depth, graphId):
realLinkedBB = set()
@ -229,7 +266,8 @@ def recursiveBuildBBTree(node, exCur, processedBB, layer, depth, graphId):
# ignore duplicated bb
# calc need processed bb first
# and register all gotten bb. for preventing infinity resursive func and keep bb tree structure
# and register all gotten bb. for preventing infinity resursive func and
# keep bb tree structure
realLinkedBB = realLinkedBB - processedBB
processedBB.update(realLinkedBB)
@ -262,8 +300,9 @@ def recursiveBuildOperTree(oper, bb_layer_map, processedOper, occupiedLayerMap,
if oper in processedOper:
return
# for avoid fucking export parameter feature. check whether self is current graph's memeber
exCur.execute("SELECT [belong_to] FROM pOper WHERE [thisobj] == ?;", (oper, ))
# for avoid fucking export parameter feature. check whether self is
# current graph's memeber
exCur.execute("SELECT [belong_to] FROM pOper WHERE [thisobj] == ?;", (oper,))
if (exCur.fetchone()[0] != graphId):
# fuck export param, exit
return
@ -289,3 +328,184 @@ def recursiveBuildOperTree(oper, bb_layer_map, processedOper, occupiedLayerMap,
for i in res:
recursiveBuildOperTree(i, bb_layer_map, processedOper, occupiedLayerMap, exCur, sublayer + 1, bb, graphId, subLayerColumnMap)
def buildCell(exDb, deDb, target, currentGraphBlockCell):
exCur = exDb.cursor()
deCur = deDb.cursor()
# prepare block set
blockSet = set()
for i in currentGraphBlockCell.keys():
blockSet.add(i)
# find current graph's pio bio
boutx = set()
pouty = set()
graphPIO = set()
# bOut.x and pOut.y data is not confirmed, when graph size was confirmed,
# update it
exCur.execute("SELECT [thisobj], [name], [index] FROM bIn WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
x = 0
y = dcv.GRAPH_BOFFSET + i[2] * dcv.GRAPH_BSPAN
currentGraphBlockCell[i[0]] = dcv.BlockCellItem(x, y, dcv.BB_PBSIZE, dcv.BB_PBSIZE)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, '', ?, ?, ?)", (target, i[0], i[1], x, y, dcv.CellType.BIO))
exCur.execute("SELECT [thisobj], [name], [index] FROM bOut WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
x = 0
y = dcv.GRAPH_BOFFSET + i[2] * dcv.GRAPH_BSPAN
currentGraphBlockCell[i[0]] = dcv.BlockCellItem(x, y, dcv.BB_PBSIZE, dcv.BB_PBSIZE)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, '', ?, ?, ?)", (target, i[0], i[1], x, y, dcv.CellType.BIO))
boutx.add(i[0])
exCur.execute("SELECT [thisobj], [name], [index], [type] FROM pIn WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
x = dcv.GRAPH_POFFSET + i[2] * dcv.GRAPH_PSPAN
y = 0
currentGraphBlockCell[i[0]] = dcv.BlockCellItem(x, y, dcv.BB_PBSIZE, dcv.BB_PBSIZE)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, ?, ?, ?, ?)", (target, i[0], i[1], i[3], x, y, dcv.CellType.PIO))
graphPIO.add(i[0])
exCur.execute("SELECT [thisobj], [name], [index], [type] FROM pOut WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
x = dcv.GRAPH_POFFSET + i[2] * dcv.GRAPH_PSPAN
y = 0
currentGraphBlockCell[i[0]] = dcv.BlockCellItem(x, y, dcv.BB_PBSIZE, dcv.BB_PBSIZE)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, ?, ?, ?, ?)", (target, i[0], i[1], i[3], x, y, dcv.CellType.PIO))
graphPIO.add(i[0])
pouty.add(i[0])
exCur.execute("SELECT [thisobj], [name], [type] FROM pTarget WHERE [belong_to] == ?", (target,))
cache = exCur.fetchone()
if cache != None:
currentGraphBlockCell[cache[0]] = dcv.BlockCellItem(0, 0, dcv.BB_PBSIZE, dcv.BB_PBSIZE)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, ?, 0, 0, ?)", (target, i[0], i[1], i[2], dcv.CellType.PTARGET))
graphPIO.add(cache[0])
# query all plocal
allLocal = set()
localUsageCounter = {}
exCur.execute("SELECT [thisobj], [name], [type] FROM pLocal WHERE [belong_to] == ?;", (target,))
for i in exCur.fetchall():
allLocal.add(i[0])
localUsageCounter[i[0]] = dcv.LocalUsageItem(0, False, dcv.LocalUsageType.PLOCAL)
# query all links(don't need to consider export pIO, due to it will not add
# any shortcut)
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall():
# check export pIO.
if ((i[2] == target) and (i[0] in graphPIO) or (i[6] == target) and (i[1] in graphPIO)):
# fuck export param
continue
# analyse 5 chancee one by one
if (i[7] == dcv.dbPLinkInputOutputType.PTARGET or i[7] == dcv.dbPLinkInputOutputType.PIN):
if (i[3] == dcv.dbPLinkInputOutputType.PLOCAL):
if i[2] in allLocal:
cache = localUsageCounter[i[2]]
else:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PLOCAL)
localUsageCounter[i[2]] = cache
cache.count += 1
cache.lastUse = i[6]
cache.lastDirection = 0
cache.lastIndex = i[9]
elif (i[3] == dcv.dbPLinkInputOutputType.PIN):
if i[2] not in blockSet:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PIN)
localUsageCounter[i[0]] = cache
cache.count+=1
cache.lastUse = i[6]
cache.lastDirection = 0
cache.lastIndex = i[9]
else:
if i[2] not in blockSet:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.POUT)
localUsageCounter[i[0]] = cache
cache.count+=1
cache.lastUse = i[6]
cache.lastDirection = 1
cache.lastIndex = i[9]
else:
if (i[7] == dcv.dbPLinkInputOutputType.PLOCAL):
if i[6] in allLocal:
cache = localUsageCounter[i[6]]
else:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.PLOCAL)
localUsageCounter[i[6]] = cache
cache.count += 1
cache.lastUse = i[2]
cache.lastDirection = 1
cache.lastIndex = i[5]
else:
if i[6] not in blockSet:
cache = dcv.LocalUsageItem(0, True, dcv.LocalUsageType.POUT)
localUsageCounter[i[1]] = cache
cache.count += 1
cache.lastUse = i[2]
cache.lastDirection = 1
cache.lastIndex = i[5]
# apply all cells
defaultCellIndex = 0
for i in localUsageCounter.keys():
cache = localUsageCounter[i]
# comput x,y
if (cache.count == 1):
# attachable
attachTarget = currentGraphBlockCell[cache.lastUse]
(x, y) = computCellPosition(attachTarget.x, attachTarget.y, attachTarget.h, cache.lastDirection, cache.lastIndex)
else:
# place it in default area
y = dcv.GRAPH_CONTENTOFFSET_Y
x = dcv.GRAPH_CONTENTOFFSET_X + defaultCellIndex * (dcv.CELL_WIDTH + dcv.GRAPH_BB_SPAN)
defaultCellIndex += 1
# get information
if (cache.internal_type == dcv.LocalUsageType.PIN):
tableName = 'pIn'
elif (cache.internal_type == dcv.LocalUsageType.POUT):
tableName = 'pOut'
else:
tableName = 'pLocal'
exCur.execute("SELECT [name], [type] FROM {} WHERE [thisobj] == ?".format(tableName), (i,))
temp = exCur.fetchone()
# submit to database and map
currentGraphBlockCell[i] = dcv.BlockCellItem(x, y, dcv.CELL_WIDTH, dcv.CELL_HEIGHT)
deCur.execute("INSERT INTO cell VALUES (?, ?, ?, ?, ?, ?, ?)",
(target, i, temp[0], temp[1], x, y, (dcv.CellType.SHORTCUT if cache.isshortcut else dcv.CellType.PLOCAL)))
# comput size and update database
graphX = 0
graphY = 0
for key, values in currentGraphBlockCell.items():
graphX = max(graphX, values.x + values.w)
graphY = max(graphY, values.y + values.h)
graphX += dcv.GRAPH_POFFSET
graphY += dcv.GRAPH_BOFFSET
deCur.execute("UPDATE graph SET [width] = ?, [height] = ? WHERE [graph] == ?", (graphX, graphY, target))
# update bOut.x and pOut.y data
for i in boutx:
deCur.execute("UPDATE cell SET [x] = ? WHERE ([thisobj] == ? AND [belong_to_graph] == ?)", (graphX - dcv.BB_PBSIZE, i, target))
for i in pouty:
deCur.execute("UPDATE cell SET [y] = ? WHERE ([thisobj] == ? AND [belong_to_graph] == ?)", (graphY - dcv.BB_PBSIZE, i, target))
def computCellPosition(baseX, baseY, height, direction, index):
if (index == -1):
return (0, 0)
if (direction == 0):
return (baseX + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN), baseY - dcv.GRAPH_SPAN_BB_PLOCAL)
else:
return (baseX + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN), baseY + height + dcv.GRAPH_SPAN_BB_PLOCAL)
def buildLink(exDb, deDb, target, currentGraphBlockCell):
pass

View File

@ -25,10 +25,7 @@ def close_connection(exception):
@app.template_global(name = 'pinDecoder')
def block_pin_filter(target):
if target == '':
return []
# return json.loads(target)
return target.split(',')
return json.loads(target)
@app.route('/', methods=['GET'])
def indexHandle():
@ -58,20 +55,34 @@ def scriptHandle(scriptPath):
for i in range(len(pathSlice) - 1):
hamburger.append(ss.HamburgerItem(hamburgerMap[pathSlice[i]], reduce(lambda x,y: x + '/' + y, pathSlice[0:i + 1], '')))
# gei w/h
cur.execute('SELECT [width], [height] FROM graph WHERE [graph] == ?', (pathSlice[-1], ))
cache = cur.fetchone()
width = cache[0]
height = cache[1]
# get blocks
cur.execute('SELECT * FROM block WHERE [belong_to_graph] = ?', (pathSlice[-1], ))
dbBlocks = cur.fetchall()
# todo:xxxxx
# get cells
cur.execute("SELECT * FROM cell WHERE [belong_to_graph] = ?", (pathSlice[-1], ))
dbCells = cur.fetchall()
# get links
# todo:xxxx
# render
return render_template('viewer.html',
currentPath = scriptPath,
gWidth = width,
gHeight = height,
hamburgerHistory = hamburger,
static_css = url_for('static', filename='site.css'),
static_js = url_for('static', filename='site.js'),
hamburgerCurrent = currentHamburger,
blocks = dbBlocks)
blocks = dbBlocks,
cells = dbCells)
def run():
app.run()

View File

@ -4,7 +4,7 @@ import os
import sys
# debug use
# os.remove('decorate.db')
os.remove('decorate.db')
print('Super Script View')
if not os.path.isfile("decorate.db"):

View File

@ -41,4 +41,34 @@ div.block-body {
position: absolute;
background: #8f8f8f;
border: 1px solid #cfcfcf;
}
div.cell-ptarget {
position: absolute;
background: green
border: 1px solid #cfcfcf;
}
div.cell-plocal {
position: absolute;
background: #8f8f8f;
border: 1px solid #cfcfcf;
}
div.cell-shortcut {
position: absolute;
background: purple
border: 1px solid #cfcfcf;
}
div.cell-pio {
position: absolute;
background: blue
border: 1px solid #cfcfcf;
}
div.cell-bio {
position: absolute;
background: yellow
border: 1px solid #cfcfcf;
}

View File

@ -29,25 +29,26 @@
</div>
<div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll; position: relative;">
<div>
<svg version="1.1" width="5000px" height="5000px" style="position: absolute; top: 0; left: 0;">
<svg version="1.1" width="{{ gWidth }}px" height="{{ gHeight }}px" style="position: absolute; top: 0; left: 0;">
<line x1="502" y1="210" x2="100" y2="100" stroke="black" stroke-width="1px"></line>
<line x1="320" y1="200" x2="100" y2="100" stroke="blue" stroke-width="1px" stroke-dasharray="10, 5">
</line>
<text x="200" y="155" fill="black">0</text>
</svg>
{# blocks content #}
{% for i in blocks %}
<div class="block-body" style="height: {{ i[11] }}px; width: {{ i[10] }}px; top: {{ i[9] }}px; left: {{ i[8] }}px;">
{% for pin in pinDecoder(i[4]) %}
<div class="block-p" title="{{ pin|e }}" style="height: 6px; width: 6px; top: 0; left: {{ 20 + loop.index0 * ( 6 + 20) }}px;"></div>
<div class="block-p" title="{{ "Name: %s &#13;Type: %s"|format(pin.name, pin.type) }}" style="height: 6px; width: 6px; top: 0; left: {{ 20 + loop.index0 * ( 6 + 20) }}px;"></div>
{% endfor %}
{% for pout in pinDecoder(i[5]) %}
<div class="block-p" title="{{ pout|e }}" style="height: 6px; width: 6px; bottom: 0; left: {{ 20 + loop.index0 * ( 6 + 20) }}px;"></div>
<div class="block-p" title="{{ "Name: %s &#13;Type: %s"|format(pout.name, pout.type) }}" style="height: 6px; width: 6px; bottom: 0; left: {{ 20 + loop.index0 * ( 6 + 20) }}px;"></div>
{% endfor %}
{% for bin in pinDecoder(i[6]) %}
<div class="block-b" title="{{ bin|e }}" style="height: 6px; width: 6px; top: {{ 10 + loop.index0 * ( 6 + 20) }}px; left: 0;"></div>
<div class="block-b" title="{{ "Name: %s &#13;Type: %s"|format(bin.name, bin.type) }}" style="height: 6px; width: 6px; top: {{ 10 + loop.index0 * ( 6 + 20) }}px; left: 0;"></div>
{% endfor %}
{% for bout in pinDecoder(i[6]) %}
<div class="block-b" title="{{ bout|e }}" style="height: 6px; width: 6px; top: {{ 10 + loop.index0 * ( 6 + 20) }}px; right: 0;"></div>
{% for bout in pinDecoder(i[7]) %}
<div class="block-b" title="{{ "Name: %s &#13;Type: %s"|format(bout.name, bout.type) }}" style="height: 6px; width: 6px; top: {{ 10 + loop.index0 * ( 6 + 20) }}px; right: 0;"></div>
{% endfor %}
{% if i[12] != -1 %}
@ -58,6 +59,13 @@
<p class="block-asstext" style="top: 24px; left: 20px;">{{ i[3]|e }}</p>
</div>
{% endfor %}
{# cells content #}
{% 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 %}bio{% else %}cell-ptarget{% endif %}"
style="height: 5px; width: 15px; top: {{ i[5] }}px; left: {{ i[4] }}px;"
title="{{ "Name: %s &#13;Type: %s"|format(i[2], i[3]) }}"></div>
{% endfor %}
</div>
</div>