finish bb x position confirm
This commit is contained in:
parent
27ea2fc403
commit
2173836255
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,6 +3,8 @@
|
||||||
##
|
##
|
||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
*.db
|
||||||
|
|
||||||
# User-specific files
|
# User-specific files
|
||||||
*.rsuser
|
*.rsuser
|
||||||
*.suo
|
*.suo
|
||||||
|
|
|
@ -118,6 +118,14 @@ void database::close() {
|
||||||
//stop job
|
//stop job
|
||||||
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
|
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
|
||||||
|
|
||||||
|
//create index for quick select in following app
|
||||||
|
sqlite3_exec(db, "begin;", NULL, NULL, &errmsg);
|
||||||
|
sqlite3_exec(db, "CREATE INDEX 'quick_where1' ON bIn (thisobj)", NULL, NULL, &errmsg);
|
||||||
|
sqlite3_exec(db, "CREATE INDEX 'quick_where2' ON bOut (thisobj)", NULL, NULL, &errmsg);
|
||||||
|
sqlite3_exec(db, "CREATE INDEX 'quick_where3' ON pIn (thisobj)", NULL, NULL, &errmsg);
|
||||||
|
sqlite3_exec(db, "CREATE INDEX 'quick_where4' ON pOut (thisobj)", NULL, NULL, &errmsg);
|
||||||
|
sqlite3_exec(db, "commit;", NULL, NULL, &errmsg);
|
||||||
|
|
||||||
//release res
|
//release res
|
||||||
sqlite3_close(db);
|
sqlite3_close(db);
|
||||||
db = NULL;
|
db = NULL;
|
||||||
|
|
56
SuperScriptViewer/DecoratorConstValue.py
Normal file
56
SuperScriptViewer/DecoratorConstValue.py
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
FONT_SIZE = 12
|
||||||
|
|
||||||
|
GRAPH_POFFSET = 40
|
||||||
|
GRAPH_BOFFSET = 40
|
||||||
|
GRAPH_CONTENTOFFSET_X = 40
|
||||||
|
GRAPH_CONTENTOFFSET_Y = 40
|
||||||
|
GRAPH_PSPAN = 20
|
||||||
|
GRAPH_BSPAN = 20
|
||||||
|
GRAPH_LAYER_SPAN = 100
|
||||||
|
GRAPH_BB_SPAN = 50
|
||||||
|
|
||||||
|
BB_POFFSET = 20
|
||||||
|
BB_BOFFSET = 10
|
||||||
|
BB_PSPAN = 10
|
||||||
|
BB_BSPAN = 10
|
||||||
|
BB_PBSIZE = 6
|
||||||
|
|
||||||
|
CELL_WIDTH = 15
|
||||||
|
CELL_HEIGHT = 5
|
||||||
|
|
||||||
|
|
||||||
|
class LinkType(object):
|
||||||
|
PLOCAL = 0
|
||||||
|
SHORTCUR = 1
|
||||||
|
PIO = 2
|
||||||
|
BIO = 3
|
||||||
|
|
||||||
|
class BBTreeNode(object):
|
||||||
|
def __init__(self, ckid, layer):
|
||||||
|
self.bb = ckid
|
||||||
|
self.layer = layer
|
||||||
|
self.nodes = []
|
||||||
|
|
||||||
|
class BBResult(object):
|
||||||
|
def __init__(self, name, assistName, pin, pout, bin, bout, expandable):
|
||||||
|
self.name = name
|
||||||
|
self.assistName = assistName
|
||||||
|
self.pin = int(pin)
|
||||||
|
self.pout = int(pout)
|
||||||
|
self.bin = int(bin)
|
||||||
|
self.bout = int(bout)
|
||||||
|
self.x = 0.0
|
||||||
|
self.y = 0.0
|
||||||
|
self.width = 0.0
|
||||||
|
self.height = 0.0
|
||||||
|
self.expandable = expandable
|
||||||
|
|
||||||
|
def computSize(self):
|
||||||
|
wText = max(len(self.name), len(self.assistName)) * FONT_SIZE
|
||||||
|
hText = FONT_SIZE * 4
|
||||||
|
|
||||||
|
wp = 2 * BB_POFFSET + max(self.pin, self.pout) * (BB_PBSIZE + BB_PSPAN)
|
||||||
|
hb = 2 * BB_BOFFSET + max(self.bin, self.bout) * (BB_PBSIZE + BB_BSPAN)
|
||||||
|
|
||||||
|
self.width = max(wp, wText)
|
||||||
|
self.height = max(hb, hText)
|
|
@ -1 +1,159 @@
|
||||||
|
import sqlite3
|
||||||
|
import DecoratorConstValue as dcv
|
||||||
|
import queue
|
||||||
|
|
||||||
|
def run():
|
||||||
|
exportDb = sqlite3.connect('export.db')
|
||||||
|
decorateDb = sqlite3.connect('decorate.db')
|
||||||
|
exportCur = exportDb.cursor()
|
||||||
|
decorateCur = decorateDb.cursor()
|
||||||
|
|
||||||
|
# init table
|
||||||
|
print('Init decorate.dll')
|
||||||
|
initDecorateDb(decorateCur)
|
||||||
|
decorateDb.commit()
|
||||||
|
|
||||||
|
# decorate graph
|
||||||
|
graphList = []
|
||||||
|
decorateGraph(exportCur, decorateCur, graphList)
|
||||||
|
|
||||||
|
# decorate each graph
|
||||||
|
for i in graphList:
|
||||||
|
buildBBTree(exportCur, decorateCur, i)
|
||||||
|
|
||||||
|
# give up all change of eexport.db (because no change)
|
||||||
|
exportDb.close()
|
||||||
|
decorateDb.commit()
|
||||||
|
decorateDb.close()
|
||||||
|
|
||||||
|
def initDecorateDb(cur):
|
||||||
|
cur.execute("CREATE TABLE graph([graph] INTEGER, [width] INTEGER, [height] INTEGER, [index] INTEGER, [belong_to] TEXT);")
|
||||||
|
cur.execute("CREATE TABLE info([target] INTEGER, [field] TEXT, [data] TEXT);")
|
||||||
|
|
||||||
|
cur.execute("CREATE TABLE block([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [pin-pin] INTEGER, [pin-pout] INTEGER, [pin-bin] INTEGER, [pin-bout] INTEGER, [x] INTEGER, [y] INTEGER, [width] INTEGER, [height] INTEGER, [expandable] INTEGER);")
|
||||||
|
cur.execute("CREATE TABLE cell([belong_to_graph] INETGER, [thisobj] INTEGER, [name] TEXT, [assist_text] TEXT, [x] INTEGER, [y] INTEGER, [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] INTEGER, [y1] INTEGER, [x2] INTEGER, [y2] INTEGER);")
|
||||||
|
|
||||||
|
def decorateGraph(exCur, deCur, graph):
|
||||||
|
scriptMap = {}
|
||||||
|
|
||||||
|
exCur.execute("SELECT [behavior], [index], [name] FROM script;")
|
||||||
|
while True:
|
||||||
|
lines = exCur.fetchone()
|
||||||
|
if lines == None:
|
||||||
|
break
|
||||||
|
scriptMap[lines[0]] = (lines[1], lines[2])
|
||||||
|
|
||||||
|
exCur.execute("SELECT [thisobj], [type] FROM behavior WHERE [type] != 0;")
|
||||||
|
while True:
|
||||||
|
lines = exCur.fetchone()
|
||||||
|
if lines == None:
|
||||||
|
break
|
||||||
|
|
||||||
|
# add into global graph list
|
||||||
|
graph.append(lines[0])
|
||||||
|
|
||||||
|
# width and height will be computed by following method and use update
|
||||||
|
# statement to change it
|
||||||
|
if lines[1] == 1:
|
||||||
|
# script
|
||||||
|
deCur.execute("INSERT INTO graph VALUES(?, 0, 0, ?, ?)", (lines[0], scriptMap[lines[0]][0], scriptMap[lines[0]][1]))
|
||||||
|
else:
|
||||||
|
# sub bb
|
||||||
|
deCur.execute("INSERT INTO graph VALUES(?, 0, 0, -1, '')", (lines[0],))
|
||||||
|
|
||||||
|
def buildBBTree(exCur, deCur, target):
|
||||||
|
# sort inner bb
|
||||||
|
# use current graph input as the start point
|
||||||
|
treeRoot = dcv.BBTreeNode(target, -1)
|
||||||
|
processedBB = set()
|
||||||
|
bb_layer_map = {}
|
||||||
|
# layer start from 1, 0 is occupied for pLocal
|
||||||
|
arrangedLayer = recursiveBuildBBTree(treeRoot, exCur, deCur, processedBB, 1, 0, target)
|
||||||
|
|
||||||
|
# get no linked bb and place them. linked bb position will be computed following
|
||||||
|
# calc each bb's x postion, as for y, we need wait for oOper to confirm each layer's height
|
||||||
|
arrangedLayer+=1
|
||||||
|
singleBB = set()
|
||||||
|
bbResult = {}
|
||||||
|
baseX = dcv.GRAPH_CONTENTOFFSET_X
|
||||||
|
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[0], pinSplit[1], pinSplit[2], pinSplit[3], (i[0] if i[2] != 0 else -1))
|
||||||
|
bbCache.computSize()
|
||||||
|
if i[0] not in processedBB:
|
||||||
|
# single bb, process it
|
||||||
|
singleBB.add(i[0])
|
||||||
|
bbCache.x = baseX
|
||||||
|
baseX += bbCache.width + dcv.GRAPH_BB_SPAN
|
||||||
|
|
||||||
|
bbResult[i[0]] = bbCache
|
||||||
|
|
||||||
|
recursiveCalcBBX(treeRoot, dcv.GRAPH_CONTENTOFFSET_X, bbResult)
|
||||||
|
pass
|
||||||
|
|
||||||
|
def recursiveBuildBBTree(node, exCur, deCur, processedBB, layer, depth, graphId):
|
||||||
|
cache = []
|
||||||
|
if depth == 0:
|
||||||
|
# find bIn
|
||||||
|
exCur.execute('SELECT [thisobj] FROM bIn WHERE [belong_to] == ?;', (node.bb,))
|
||||||
|
else:
|
||||||
|
# find bOut
|
||||||
|
exCur.execute('SELECT [thisobj] FROM bOut WHERE [belong_to] == ?;', (node.bb,))
|
||||||
|
|
||||||
|
for i in exCur.fetchall():
|
||||||
|
cache.append(i[0])
|
||||||
|
|
||||||
|
if (len(cache) == 0):
|
||||||
|
return layer
|
||||||
|
|
||||||
|
# find links
|
||||||
|
exCur.execute("SELECT [output] FROM bLink WHERE ([belong_to] == ? AND ([input] IN ({})));".format(','.join(map(lambda x:str(x), cache))), (graphId,))
|
||||||
|
cache.clear()
|
||||||
|
for i in exCur.fetchall():
|
||||||
|
cache.append(i[0])
|
||||||
|
|
||||||
|
if (len(cache) == 0):
|
||||||
|
return layer
|
||||||
|
|
||||||
|
#find bIn (find in bIn list to omit the line linked to current bb's output)
|
||||||
|
exCur.execute("SELECT [belong_to] FROM bIn WHERE [thisobj] IN ({});".format(','.join(map(lambda x:str(x), cache))))
|
||||||
|
cache.clear()
|
||||||
|
for i in exCur.fetchall():
|
||||||
|
cache.append(i[0])
|
||||||
|
|
||||||
|
if (len(cache) == 0):
|
||||||
|
return layer
|
||||||
|
|
||||||
|
# ignore duplicated bb
|
||||||
|
realLinkedBB = set(cache)
|
||||||
|
# calc need processed bb first
|
||||||
|
# and register all gotten bb. for preventing infinity resursive func and keep bb tree structure
|
||||||
|
realLinkedBB = realLinkedBB - processedBB
|
||||||
|
processedBB.update(realLinkedBB)
|
||||||
|
|
||||||
|
# iterate each bb
|
||||||
|
for i in realLinkedBB:
|
||||||
|
# recursive execute this method
|
||||||
|
newNode = dcv.BBTreeNode(i, layer)
|
||||||
|
layer = recursiveBuildBBTree(newNode, exCur, deCur, processedBB, layer, depth + 1, graphId)
|
||||||
|
# add new node into list and ++layer
|
||||||
|
layer+=1
|
||||||
|
node.nodes.append(newNode)
|
||||||
|
|
||||||
|
# minus extra ++ due to for
|
||||||
|
if (len(realLinkedBB) != 0):
|
||||||
|
layer-=1
|
||||||
|
|
||||||
|
return layer
|
||||||
|
|
||||||
|
|
||||||
|
def recursiveCalcBBX(node, baseX, resultList):
|
||||||
|
maxExpand = 0
|
||||||
|
for i in node.nodes:
|
||||||
|
resultList[i.bb].x = baseX
|
||||||
|
maxExpand = max(maxExpand, resultList[i.bb].width)
|
||||||
|
|
||||||
|
for i in node.nodes:
|
||||||
|
recursiveCalcBBX(i, baseX + maxExpand + dcv.GRAPH_BB_SPAN, resultList)
|
|
@ -1 +1,20 @@
|
||||||
|
import DecoratorCore
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# debug use
|
||||||
|
os.remove('decorate.db')
|
||||||
|
|
||||||
|
|
||||||
print('Super Script View')
|
print('Super Script View')
|
||||||
|
if not os.path.isfile("decorate.db"):
|
||||||
|
print('No decorated database, generating it.')
|
||||||
|
if not os.path.isfile('export.db'):
|
||||||
|
print('No export.db. Fail to generate. Exit app.')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
# generate db
|
||||||
|
DecoratorCore.run()
|
||||||
|
print('Decorated database generating done.')
|
||||||
|
|
||||||
|
# todo: start flask
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="DecoratorConstValue.py">
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="DecoratorCore.py">
|
<Compile Include="DecoratorCore.py">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -29,18 +29,27 @@
|
||||||
<button style="width: 100px; height: 50px;">SAVE !!</button>
|
<button style="width: 100px; height: 50px;">SAVE !!</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll;">
|
<div style="background: #7f7f7f; width: 100%; height: 100%; overflow: scroll; position: relative;">
|
||||||
<svg version="1.1" width="1000px" height="500px">
|
<div>
|
||||||
|
<div
|
||||||
</svg>
|
style="position: absolute; height: 50px; width: 200px; top: 200px; left: 300px; background: #8f8f8f; border: 1px solid #cfcfcf;">
|
||||||
<div style="position: absolute; height: 50px; width: 200px; top: 200px; left: 300px; background: #8f8f8f; border: 1px solid white;">
|
|
||||||
<div style="position: absolute; height: 6px; width: 6px; top: 0; left: 20px; background: blue;"></div>
|
<div style="position: absolute; height: 6px; width: 6px; top: 0; left: 20px; background: blue;"></div>
|
||||||
<div style="position: absolute; height: 6px; width: 6px; top: 0; left: 35px; background: blue;"></div>
|
<div style="position: absolute; height: 6px; width: 6px; top: 0; left: 35px; background: blue;"></div>
|
||||||
<div style="position: absolute; height: 6px; width: 6px; bottom: 0; left: 20px; background: blue;"></div>
|
<div style="position: absolute; height: 6px; width: 6px; bottom: 0; left: 20px; background: blue;">
|
||||||
|
</div>
|
||||||
<div style="position: absolute; height: 6px; width: 6px; top: 10px; left: 0; background: yellow;"></div>
|
<div style="position: absolute; height: 6px; width: 6px; top: 10px; left: 0; background: yellow;"></div>
|
||||||
<div style="position: absolute; height: 6px; width: 6px; top: 10px; right: 0; background: yellow;"></div>
|
<div style="position: absolute; height: 6px; width: 6px; top: 10px; right: 0; background: yellow;">
|
||||||
|
</div>
|
||||||
<p style="position: absolute; top: 10px; left: 10px; margin: 0; padding: 0;">Get Cell</p>
|
<p style="position: absolute; top: 10px; left: 10px; margin: 0; padding: 0;">Get Cell</p>
|
||||||
</div>
|
</div>
|
||||||
|
<svg version="1.1" width="1000px" height="1000px" 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>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user