finish pLink. it have toooooooooooo much bugs

This commit is contained in:
yyc12345 2020-04-14 23:19:06 +08:00
parent bbd3ba2e3a
commit 863badc809
4 changed files with 106 additions and 28 deletions

View File

@ -22,8 +22,8 @@ def run():
for i in graphList: for i in graphList:
currentGraphBlockCell.clear() currentGraphBlockCell.clear()
buildBlock(exportDb, decorateDb, i, currentGraphBlockCell) buildBlock(exportDb, decorateDb, i, currentGraphBlockCell)
(gWidth, gHeight) = buildCell(exportDb, decorateDb, i, currentGraphBlockCell) graphPIO = buildCell(exportDb, decorateDb, i, currentGraphBlockCell)
buildLink(exportDb, decorateDb, i, currentGraphBlockCell, gWidth, gHeight) buildLink(exportDb, decorateDb, i, currentGraphBlockCell, graphPIO)
# export information # export information
buildInfo(exportDb, decorateDb) buildInfo(exportDb, decorateDb)
@ -395,11 +395,12 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
# query all links(don't need to consider export pIO, due to it will not add # query all links(don't need to consider export pIO, due to it will not add
# any shortcut) # any shortcut)
# !! the same if framework in pLink generator function !! SHARED
createdShortcut = set() createdShortcut = set()
exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,)) exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
for i in exCur.fetchall(): for i in exCur.fetchall():
# check export pIO. # check export pIO.
if (((i[2] == target) and (i[0] in graphPIO)) or ((i[6] == target) and (i[1] in graphPIO))): if (((i[2] != target) and (i[0] in graphPIO)) or ((i[6] != target) and (i[1] in graphPIO))):
# fuck export param # fuck export param
continue continue
@ -518,7 +519,7 @@ def buildCell(exDb, deDb, target, currentGraphBlockCell):
for i in pouty: for i in pouty:
deCur.execute("UPDATE cell SET [y] = ? WHERE ([thisobj] == ? AND [belong_to_graph] == ?)", (graphY - dcv.BB_PBSIZE, i, target)) deCur.execute("UPDATE cell SET [y] = ? WHERE ([thisobj] == ? AND [belong_to_graph] == ?)", (graphY - dcv.BB_PBSIZE, i, target))
return (graphX, graphY) return graphPIO
def computCellPosition(baseX, baseY, height, direction, index): def computCellPosition(baseX, baseY, height, direction, index):
if (index == -1): if (index == -1):
@ -529,32 +530,99 @@ def computCellPosition(baseX, baseY, height, direction, index):
else: else:
return (baseX + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN), baseY + height + dcv.GRAPH_SPAN_BB_PLOCAL) 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, gWidth, gHeight): def buildLink(exDb, deDb, target, currentGraphBlockCell, graphPIO):
exCur = exDb.cursor() exCur = exDb.cursor()
deCur = deDb.cursor() deCur = deDb.cursor()
# bLink # bLink
exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target, )) exCur.execute("SELECT * FROM bLink WHERE [belong_to] == ?", (target, ))
for i in exCur.fetchall(): for i in exCur.fetchall():
(x1, y1) = computLinkBTerminal(i[3], i[4], i[5], currentGraphBlockCell, target, gWidth) (x1, y1) = computLinkBTerminal(i[3] if i[3] != target else i[0],
(x2, y2) = computLinkBTerminal(i[6], i[7], i[8], currentGraphBlockCell, target, gWidth) i[4],
i[5] if i[3] != target else -1,
currentGraphBlockCell)
(x2, y2) = computLinkBTerminal(i[6] if i[6] != target else i[1],
i[7],
i[8] if i[6] != target else -1,
currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);", deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, i[2], i[3], i[0], i[1], i[6], i[4], i[7], i[5], i[6], x1, y1, x2, y2)) (target, i[2], i[0], i[1], i[3], i[6], i[4], i[7], i[5], i[8], x1, y1, x2, y2))
def computLinkBTerminal(obj, type, index, currentGraphBlockCell, target, maxWidth): # pLink
if (obj == target): # !! the same if framework in cell generator function !! SHARED
# connect to self exCur.execute("SELECT * FROM pLink WHERE [belong_to] == ?", (target,))
if (type == 0): # bIn for i in exCur.fetchall():
return (0, dcv.GRAPH_BOFFSET + index * (dcv.BB_PBSIZE + dcv.GRAPH_BSPAN)) # check export pIO.
else: # bOut if (i[2] != target) and (i[0] in graphPIO):
return (maxWidth - dcv.BB_PBSIZE, dcv.GRAPH_BOFFSET + index * (dcv.BB_PBSIZE + dcv.GRAPH_BSPAN)) # fuck export param, create a export link. in this if, i[0] is a pOut and was plugged into graph. it is start point
else: (x1, y1) = computLinkPTerminal(i[0], 0, -1, currentGraphBlockCell)
# connect to specific obj (x2, y2) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
cache = currentGraphBlockCell[obj] deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
if (type == 0): # bIn (target, -2, i[0], i[0], target, i[2], 0, 1, -1, i[5], x1, y1, x2, y2))
return (cache.x, cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN)) continue
else: # bOut
return (cache.x + cache.w - dcv.BB_PBSIZE, cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN)) if (i[6] != target) and (i[1] in graphPIO):
# fuck export param, create a export link. in this if, i[1] is a pIn/pTarget and was plugged into graph. it is end point
(x1, y1) = computLinkPTerminal(i[1], 0, -1, currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -2, i[1], i[1], target, i[6], 0, 0, -1, i[9], x1, y1, x2, y2))
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):
(x1, y1) = computLinkPTerminal(i[0], 0, -1, currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 0, 0, -1, i[9], x1, y1, x2, y2))
elif (i[3] == dcv.dbPLinkInputOutputType.PIN):
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
if i[2] == target:
(x1, y1) = computLinkPTerminal(i[0], 0, -1, currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[0], i[6], 0, 0, -1, i[9], x1, y1, x2, y2))
else:
(x1, y1) = computLinkPTerminal(i[2], 0, i[5], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 0, 0, i[5], i[9], x1, y1, x2, y2))
else:
(x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[6], 0, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 1, 0, i[5], i[9], x1, y1, x2, y2))
else:
if (i[7] == dcv.dbPLinkInputOutputType.PLOCAL):
(x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
(x2, y2) = computLinkPTerminal(i[1], 0, -1, currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 1, 0, i[5], -1, x1, y1, x2, y2))
else:
(x1, y1) = computLinkPTerminal(i[2], 1, i[5], currentGraphBlockCell)
if i[6] == target:
(x2, y2) = computLinkPTerminal(i[1], 0, -1, currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[1], 1, 0, i[5], -1, x1, y1, x2, y2))
else:
(x2, y2) = computLinkPTerminal(i[6], 1, i[9], currentGraphBlockCell)
deCur.execute("INSERT INTO link VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);",
(target, -1, i[0], i[1], i[2], i[6], 1, 1, i[5], i[9], x1, y1, x2, y2))
def computLinkBTerminal(obj, xtype, index, currentGraphBlockCell):
# index = -1 mean no offset, it will connect to graph io
cache = currentGraphBlockCell[obj]
return (cache.x if xtype == 0 else cache.x + cache.w - dcv.BB_PBSIZE,
cache.y if index == -1 else (cache.y + dcv.BB_BOFFSET + index * (dcv.BB_PBSIZE + dcv.BB_BSPAN)))
def computLinkPTerminal(obj, ytype, index, currentGraphBlockCell):
# ytype is not database type. it have the same meaning of LinkBTerminal, indicating the position. 0 is keep origin position(for pIn and pTarget), 1 is consider height(for pOut)
cache = currentGraphBlockCell[obj]
return (cache.x if index == -1 else (cache.x + dcv.BB_POFFSET + index * (dcv.BB_PBSIZE + dcv.BB_PSPAN)),
cache.y if ytype == 0 else (cache.y + cache.h - dcv.BB_PBSIZE))
def buildInfo(exDb, deDb): def buildInfo(exDb, deDb):
exCur = exDb.cursor() exCur = exDb.cursor()

View File

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

View File

@ -12,6 +12,12 @@ function highlightLink(target) {
if ($(this).hasClass("link-blinkDelay")) { if ($(this).hasClass("link-blinkDelay")) {
$(this).attr("fill", "black") $(this).attr("fill", "black")
} }
if ($(this).hasClass("link-plink")) {
$(this).attr("stroke", "blue")
}
if ($(this).hasClass("link-elink")) {
$(this).attr("stroke", "cyan")
}
}); });
} }
@ -27,6 +33,12 @@ function highlightLink(target) {
if ($(this).hasClass("link-blinkDelay")) { if ($(this).hasClass("link-blinkDelay")) {
$(this).attr("fill", "yellow") $(this).attr("fill", "yellow")
} }
if ($(this).hasClass("link-plink")) {
$(this).attr("stroke", "orange")
}
if ($(this).hasClass("link-elink")) {
$(this).attr("stroke", "orange")
}
}); });
previousHighlight = realTarget previousHighlight = realTarget

View File

@ -69,16 +69,14 @@
{# links content #} {# links content #}
{% for i in links %} {% for i in links %}
{% if i[1] == -2 %} {% if i[1] == -2 %}
{# todo: finish export link #} <line class="link-elink target{{ i[2] }} target{{ i[3] }} target{{ i[4] }} target{{ i[5] }}" x1="{{ i[10] }}" y1="{{ i[11] }}" x2="{{ i[12] }}" y2="{{ i[13] }}" stroke="cyan" stroke-width="1px" stroke-dasharray="5, 1"></line>
{% elif i[1] == -1 %} {% elif i[1] == -1 %}
{# todo: finish plink #} <line class="link-plink target{{ i[2] }} target{{ i[3] }} target{{ i[4] }} target{{ i[5] }}" x1="{{ i[10] }}" y1="{{ i[11] }}" x2="{{ i[12] }}" y2="{{ i[13] }}" stroke="blue" stroke-width="1px" stroke-dasharray="5, 1"></line>
{% else %} {% else %}
<line class="link-blink target{{ i[2] }} target{{ i[3] }} target{{ i[4] }} target{{ i[5] }}" x1="{{ i[10] }}" y1="{{ i[11] }}" x2="{{ i[12] }}" y2="{{ i[13] }}" stroke="black" stroke-width="1px"></line> <line class="link-blink target{{ i[2] }} target{{ i[3] }} target{{ i[4] }} target{{ i[5] }}" x1="{{ i[10] }}" y1="{{ i[11] }}" x2="{{ i[12] }}" y2="{{ i[13] }}" stroke="black" stroke-width="1px"></line>
<text class="link-blinkDelay target{{ i[2] }} target{{ i[3] }} link-delay target{{ i[4] }} target{{ i[5] }}" x="{{ (i[10] + i[12]) / 2 }}" y="{{ (i[11] + i[13]) / 2 }}" fill="black">{{ i[1] }}</text> <text class="link-blinkDelay target{{ i[2] }} target{{ i[3] }} link-delay target{{ i[4] }} target{{ i[5] }}" x="{{ (i[10] + i[12]) / 2 }}" y="{{ (i[11] + i[13]) / 2 }}" fill="black">{{ i[1] }}</text>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<!-- <line x1="320" y1="200" x2="100" y2="100" stroke="blue" stroke-width="1px" stroke-dasharray="10, 5">
</line>-->
</svg> </svg>
</div> </div>
</div> </div>