-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlockVo.py
52 lines (46 loc) · 1.62 KB
/
BlockVo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import uuid
import BlockRule
import WPS_DB
class BlockVo:
id = None
x = 0
y = 0
width = 0
height = 0
boxs = []
parent = None
children = []
isVisualBlock = True
isDividable = True
Doc = 0
count = 1
def __init__(self):
self.id = str(BlockVo.count)
BlockVo.count += 1
#str(uuid.uuid4())
self.boxs = []
self.children = []
def refresh(self):
for i in range(0, len(self.boxs)):
box = self.boxs[i]
if i == 0:
self.x = box.visual_cues['bounds']['x']
self.y = box.visual_cues['bounds']['y']
self.width = box.visual_cues['bounds']['width']
self.height = box.visual_cues['bounds']['height']
else:
RBX = self.x + self.width
RBY = self.y + self.height
boxRBX = box.visual_cues['bounds']['x']+box.visual_cues['bounds']['width']
boxRBY = box.visual_cues['bounds']['y']+box.visual_cues['bounds']['height']
RBX = boxRBX if (boxRBX > RBX) else RBX
RBY = boxRBY if (boxRBY > RBY) else RBY
self.x = box.visual_cues['bounds']['x'] if (box.visual_cues['bounds']['x']<self.x) else self.x
self.y = box.visual_cues['bounds']['y'] if (box.visual_cues['bounds']['y'] <self.y) else self.y
self.width = RBX - self.x
self.height = RBY - self.y
@staticmethod
def refreshBlock(block):
block.refresh()
for blockVo in block.children:
BlockVo.refreshBlock(blockVo)