add blink dispaly
This commit is contained in:
parent
9d3d7e8aad
commit
70b876bbf2
|
@ -20,7 +20,8 @@ def run():
|
|||
for i in graphList:
|
||||
currentGraphBlockCell.clear()
|
||||
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
(gWidth, gHeight) = buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
|
||||
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, gWidth, gHeight)
|
||||
|
||||
|
||||
# give up all change of eexport.db (because no change)
|
||||
|
@ -35,7 +36,7 @@ def initDecorateDb(db):
|
|||
|
||||
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 link([belong_to_graph] INETGER, [thisobj] INTEGER, [delay] INTEGER, [startobj] INTEGER, [endobj] INTEGER, [start_index] INTEGER, [end_index] INTEGER, [x1] REAL, [y1] REAL, [x2] REAL, [y2] REAL);")
|
||||
cur.execute("CREATE TABLE link([belong_to_graph] INETGER, [delay] INTEGER, [startobj] INTEGER, [endobj] INTEGER, [start_type] INTEGER, [end_type] INTEGER, [start_index] INTEGER, [end_index] INTEGER, [x1] REAL, [y1] REAL, [x2] REAL, [y2] REAL);")
|
||||
|
||||
def decorateGraph(exDb, deDb, graph):
|
||||
exCur = exDb.cursor()
|
||||
|
@ -347,27 +348,27 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
|
|||
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
|
||||
y = dcv.GRAPH_BOFFSET + i[2] * (dcv. BB_PBSIZE + 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
|
||||
y = dcv.GRAPH_BOFFSET + i[2] * (dcv. BB_PBSIZE + 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
|
||||
x = dcv.GRAPH_POFFSET + i[2] * (dcv. BB_PBSIZE + 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
|
||||
x = dcv.GRAPH_POFFSET + i[2] * (dcv. BB_PBSIZE + 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))
|
||||
|
@ -498,6 +499,8 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
|
|||
for i in pouty:
|
||||
deCur.execute("UPDATE cell SET [y] = ? WHERE ([thisobj] == ? AND [belong_to_graph] == ?)", (graphY - dcv.BB_PBSIZE, i, target))
|
||||
|
||||
return (graphX, graphY)
|
||||
|
||||
def computCellPosition(baseX, baseY, height, direction, index):
|
||||
if (index == -1):
|
||||
return (0, 0)
|
||||
|
@ -507,5 +510,29 @@ def computCellPosition(baseX, baseY, height, direction, index):
|
|||
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
|
||||
def buildLink(exDb, deDb, target, currentGraphBlockCell, gWidth, gHeight):
|
||||
exCur = exDb.cursor()
|
||||
deCur = deDb.cursor()
|
||||
|
||||
# bLink
|
||||
exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target, ))
|
||||
for i in exCur.fetchall():
|
||||
(x1, y1) = computLinkBTerminal(i[3], i[4], i[5], currentGraphBlockCell, target, gWidth)
|
||||
(x2, y2) = computLinkBTerminal(i[6], i[7], i[8], currentGraphBlockCell, target, gWidth)
|
||||
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
|
||||
(target, i[2], i[3], i[6], i[4], i[7], i[5], i[6], x1, y1, x2, y2))
|
||||
|
||||
def computLinkBTerminal(obj, type, index, currentGraphBlockCell, target, maxWidth):
|
||||
if (obj == target):
|
||||
# connect to self
|
||||
if (type == 0): # bIn
|
||||
return (0, dcv.GRAPH_BOFFSET + index * (dcv.BB_PBSIZE + dcv.GRAPH_BSPAN))
|
||||
else: # bOut
|
||||
return (maxWidth - dcv.BB_PBSIZE, dcv.GRAPH_BOFFSET + index * (dcv.BB_PBSIZE + dcv.GRAPH_BSPAN))
|
||||
else:
|
||||
# connect to specific obj
|
||||
cache = currentGraphBlockCell[obj]
|
||||
if (type == 0): # bIn
|
||||
return (cache.x, cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN))
|
||||
else: # bOut
|
||||
return (cache.x + cache.w - dcv.BB_PBSIZE, cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN))
|
||||
|
|
|
@ -67,15 +67,16 @@ def scriptHandle(scriptPath):
|
|||
height = cache[1]
|
||||
|
||||
# get blocks
|
||||
cur.execute('SELECT * FROM block WHERE [belong_to_graph] = ?', (pathSlice[-1], ))
|
||||
cur.execute('SELECT * FROM block WHERE [belong_to_graph] == ?', (pathSlice[-1], ))
|
||||
dbBlocks = cur.fetchall()
|
||||
|
||||
# get cells
|
||||
cur.execute("SELECT * FROM cell WHERE [belong_to_graph] = ?", (pathSlice[-1], ))
|
||||
cur.execute("SELECT * FROM cell WHERE [belong_to_graph] == ?", (pathSlice[-1], ))
|
||||
dbCells = cur.fetchall()
|
||||
|
||||
# get links
|
||||
# todo:xxxx
|
||||
cur.execute("SELECT * FROM link WHERE [belong_to_graph] == ?", (pathSlice[-1], ))
|
||||
dbLinks = cur.fetchall()
|
||||
|
||||
# render
|
||||
return render_template('viewer.html',
|
||||
|
@ -87,7 +88,8 @@ def scriptHandle(scriptPath):
|
|||
static_js = url_for('static', filename='site.js'),
|
||||
hamburgerCurrent = currentHamburger,
|
||||
blocks = dbBlocks,
|
||||
cells = dbCells)
|
||||
cells = dbCells,
|
||||
links = dbLinks)
|
||||
|
||||
def run():
|
||||
app.run()
|
||||
|
|
|
@ -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"):
|
||||
|
|
|
@ -77,3 +77,8 @@ div.cell-bio {
|
|||
background: yellow;
|
||||
border: 1px solid #cfcfcf;
|
||||
}
|
||||
|
||||
text.link-delay {
|
||||
font-size: 12px;
|
||||
color: black;
|
||||
}
|
|
@ -29,12 +29,6 @@
|
|||
</div>
|
||||
<div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll; position: relative;">
|
||||
<div>
|
||||
<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[12] }}px; width: {{ i[11] }}px; top: {{ i[10] }}px; left: {{ i[9] }}px;">
|
||||
|
@ -69,6 +63,22 @@
|
|||
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]) }}"></div>
|
||||
{% endfor %}
|
||||
|
||||
<svg version="1.1" width="{{ gWidth }}px" height="{{ gHeight }}px" style="position: absolute; top: 0; left: 0;pointer-events: none;">
|
||||
{# links content #}
|
||||
{% for i in links %}
|
||||
{% if i[1] == -2 %}
|
||||
{# todo: finish export link #}
|
||||
{% elif i[1] == -1 %}
|
||||
{# todo: finish plink #}
|
||||
{% else %}
|
||||
<line x1="{{ i[8] }}" y1="{{ i[9] }}" x2="{{ i[10] }}" y2="{{ i[11] }}" stroke="black" stroke-width="1px"></line>
|
||||
<text class="link-delay" x="{{ (i[8] + i[10]) / 2 }}" y="{{ (i[9] + i[11]) / 2 }}" fill="black">{{ i[1] }}</text>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
<!-- <line x1="320" y1="200" x2="100" y2="100" stroke="blue" stroke-width="1px" stroke-dasharray="10, 5">
|
||||
</line>-->
|
||||
</svg>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user