-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpresentation_list.py
101 lines (67 loc) · 3.04 KB
/
presentation_list.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import cv2
import numpy as np
import os
import re
class element:
def __init__(self,width,height,posx,posy,drawIndex,name, color):
name = str(name)
self.cx =posx
self.cy = posy
self.canvas = np.zeros((height,width,3), np.uint8)
self.canvas = cv2.rectangle(self.canvas, (0, 0), (width, height), color, cv2.FILLED)
self.elem = np.zeros((height - 4 ,width - 4, 3), np.uint8)
self.elem = cv2.rectangle(self.elem, (0, 0), (width - 4 , height - 4 ), (255,255,255), cv2.FILLED)
self.canvas[ 2 :height - 2 , 2 :width - 2 ] = self.elem
self.cx1 = self.cx + self.canvas.shape[0]
self.cy1 = self.cy + self.canvas.shape[1]
self.canvas = cv2.putText(self.canvas,f'{name}',( 10 , height - 10 ) , cv2.FONT_HERSHEY_SIMPLEX, 1, ( 0,0,0 ) , 2, cv2.LINE_AA )
self.drawIndex = drawIndex
self.presIndex = False
def draw(self,img):
if self.drawIndex:
img[self.cx : self.cx1, self.cy : self.cy1 ] = self.canvas
class presentation_table:
def __init__(self,resizeX,resizeY,posX,posY):
self.ListNonHover = list ()
self.ListHover = list ()
self.resizeX = resizeX
self.resizeY = resizeY
self.posX = posX
self.posY = posY
self.updateY = posY
self.updateX = posX
self.selectedPresentation = None
path = "PresentationFiles"
#self.presList = os.listdir("PresentationFiles")
self.presList = os.listdir("PresentationFiles")
for i in range(0, len(self.presList)):
if i >= len(self.presList):
break
if re.search(".ppt",self.presList[i]) != None:
self.presList.pop(i)
for i in range(0, len(self.presList)):
if i != 0:
self.updateY = self.updateY + self.resizeY
self.ListNonHover.append(element(self.resizeX,resizeY, self.updateY, self.updateX,True,self.presList[i], (124, 140, 208) ) )
self.ListHover.append(element(self.resizeX,resizeY,self.updateY,self.updateX,False,self.presList[i], ( 37,68,175) ) )
def changeStateClick(self,drawIndex):
if drawIndex == True:
drawIndex = False
else:
drawIndex = True
return drawIndex
def checkForHover(self,m, obj,index):
if m.hands:
if obj.cx < m.lmList1[8][1] < obj.cx1 and obj.cy < m.lmList1[8][0] < obj.cy1 and self.ListNonHover[index].drawIndex == True:
obj.drawIndex = True
if m.clicked:
self.selectedPresentation = index
else:
obj.drawIndex = False
def draw(self,img,m):
for i in range (0, len(self.ListNonHover)):
self.checkForHover(m,self.ListHover[i],i)
if self.ListHover[i].drawIndex == True:
self.ListHover[i].draw(img)
else:
self.ListNonHover[i].draw(img)