/
history.py
475 lines (405 loc) · 15.7 KB
/
history.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
from db_code import get_db_session
from models import *
import setup
from panda3d.core import *
from pandac.PandaModules import *
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from direct.showbase.ShowBase import ShowBase
from direct.showbase.DirectObject import DirectObject
from panda3d.core import Vec3
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import TextNode
import random
from panda3d.core import *
from pandac.PandaModules import *
from direct.gui.OnscreenText import *
from direct.gui.DirectGui import *
from direct.interval.IntervalGlobal import *
from direct.showbase.ShowBase import ShowBase
from datetime import *
dbsession = get_db_session()
cx = 1
class Env(ShowBase):
def __init__(self):
self.n = 0
cmnd = ""
self.commandBox = ""
self.store = ["","","",""]
ShowBase.__init__(self)
base.setFrameRateMeter(True)
base.setBackgroundColor(0,0,0)
self.centr = (1, 1, 1)
self.cam.setPos(15, -30, 22)
light = PointLight('light')
self.render.setLight(self.cam.attachNewNode(light))
self.cam.lookAt(0, 0, 0)
self.i = 1
self.sy = 1
self.sx = 1
self.sz = 1
self.addx =1
self.addy =1
self.addz =1
# Function to put instructions on the screen.
def AddInstructions(self, pos, msg):
return OnscreenText(text=msg , style=1, fg=(1,1,1,1),
pos=(-1.3, pos), align=TextNode.ALeft, scale = .05)
# Function to put title on the screen.
def AddTitle(self, pos, text):
return OnscreenText(text=text, style=1, fg=(1,1,1,1),
pos=(-1.3, pos), align=TextNode.ALeft, scale = .08)
# Function to add command line are
def AddArea(self):
# Username textbox where you type in your username
p = Vec3(-1.3, 0.0, -0.75)
self.commandBox = DirectEntry(text = "" , width = 40, pos = p, scale=.07, command=self.SetText,
extraArgs=[self], focus=1, numLines = 3)
#callback function to set text
def SetText(self, textEntered, dummy):
self.commandBox.enterText('')
self.commandBox.setFocus()
oldText = self.instArea.getText()
self.instArea.setText(oldText + textEntered +"\n- - - - - - - - - - - - - - - - - - - - - -\n" )
self.store[self.n] = textEntered
self.n += self.n
self.commandBox.accept('arrow_up', self.GetHistory, [-1] )
self.app.filter(textEntered)
#function to maintain history
def GetHistory(self, a):
self.commandBox.enterText(self.store[self.n])
self.n -= self.n
def center(self, prsn_name , m):
if (m < 5):
self.i = self.i + 1
X = 'Person_pics/' + prsn_name + '.jpeg'
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("models/ball1")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(.9)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball1")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(.5)
return pos
def addball(self, NUM, date):
X = "Person_pics/" + NUM + '.jpeg'
tex = loader.loadTexture(X)
f = loader.loadModel("models/ball1.egg")
f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
#f = loader.loadModel("models/ball")
f.setTexture(tex, 1)
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNode2 = TextNode('text') # Create a new TextNode
newTextNode2.setText(date) # Set the TextNode text
newTextNode2.setAlign(TextNode.ACenter) # Set the text align
newTextNode2.setWordwrap(12.0)
date_generate = newTextNode2.generate()
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath2 = render.attachNewNode(date_generate)
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.5)
newTextNodePath2.setPos(a,b,(c - 0.6))
newTextNodePath2.setColor(255, 0, 0,1)
newTextNodePath2.setScale(.5)
return pos
def drawLine(self,startPoint,endPoint,color,thickness):
linesegs = LineSegs("lines")
linesegs.setColor(color)
linesegs.setThickness(thickness)
linesegs.moveTo(startPoint)
linesegs.drawTo(endPoint)
node = linesegs.create(False)
nodePath = render.attachNewNode(node)
def separate_in (self, callss):
#...data ...seperate incomming
in_list = []
for a in callss:
if a.e_type == 'incoming':
in_list.append(a)
return in_list
exit()
def separate_out (self, callss):
#...data ...seperate outgoing
oout_list = []
for a in callss:
if a.e_type == 'outgoing':
oout_list.append(a)
return oout_list
exit()
def colours (self, a):
if a == 'c':
coloursss = (0,147,255,1)
return coloursss
elif a == 'm':
coloursss = (0,255,0,1)
return coloursss
elif a == 'e':
coloursss = (0,255,180,1)
return coloursss
elif a == 'ce':
coloursss = (255,20,147,1)
return coloursss
elif a == 'ec':
coloursss = (255,20,147,1)
return coloursss
elif a == 'cm':
coloursss = (0,0,255,1)
return coloursss
elif a == 'mc':
coloursss = (0,0,255,1)
return coloursss
elif a == 'me':
coloursss = (255,0,0,1)
return coloursss
elif a == 'em':
coloursss = (255,0,0,1)
return coloursss
elif a == 'cme':
coloursss = (0,180,255,1)
return coloursss
elif a == 'ecm':
coloursss = (128,0,128,1)
return coloursss
else :
coloursss = (0,255,255,1)
return coloursss
def durations (self, inn_list):
for aList1 in inn_list:
if inn_list is not None :
for aList2 in inn_list:
if aList1.e_from == aList2.e_from and aList1 != aList2 and aList1.name == aList2.name:
a= aList1.duration
b= aList2.duration
a = a + b
aList1.duration = a
#inn_list.delete(aList2)
if inn_list is not None :
inn_list = inn_list.remove(aList2)
return inn_list
def merge (self, a=[]):
L1 = a
L2 = []
for l in L1:
for j in l:
L2.append(j)
a = L2
for aList1 in a:
for aList2 in a:
if aList1.e_from == aList2.e_from and aList1 !=aList2 and aList1.name == aList2.name:
x= aList1.duration
y= aList2.duration
x = x + y
aList1.duration = x
j = aList1.key
i = aList2.key
i = j+i
aList1.key = i
a.remove(aList2)
return a
def merge_out (self, p):
L1 = p
L2 = []
for l in L1:
for j in l:
L2.append(j)
p = L2
for aList1 in p:
for aList2 in p:
if aList1.e_from == aList2.e_from and aList1 !=aList2 and aList1.name == aList2.name:
x= aList1.duration
y= aList2.duration
x = x + y
aList1.duration = x
j = aList1.key
i = aList2.key
i = j+i
aList1.key = i
p.remove(aList2)
return p
def m (self, p):
L1 = p
L2 = []
for l in L1:
for j in l:
L2.append(j)
p = L2
return p
class Application(DirectObject):
def __init__(self):
e = Env()
count = 0
self.dbsession = get_db_session()
V = self.dbsession.query(Person).count()
rname = raw_input("Enter person name : ")
date = raw_input("Enter starting date(yyyy-mm-dd) : ")
date2 = raw_input("Enter finish date(yyyy-mm-dd) : ")
center = e.center(rname, count)
cntct_num = self.dbsession.query(Person).filter(Person.name == rname )
for i in cntct_num :
cntct_num = i.phone_no
calls = []
msg = []
email = []
d=0
calls = self.dbsession.query(Call).filter(Call.e_from == cntct_num ).all()
msg = self.dbsession.query(Msg).filter(Msg.e_from == cntct_num ).all()
email = self.dbsession.query(Email).filter(Email.e_from == cntct_num ).all()
d = 1
#rmv_cal_dub_in = []
calls_in_list = e.separate_in(calls)
#rmv_cal_dub_in = e.durations(calls_in_list)
#..................
calls_out_list = e.separate_out(calls)
#rmv_cal_dub_out = e.durations(calls_out_list)
#.................
msg_in_list = e.separate_in(msg)
#rem_msg_dub_in = e.durations(msg_in_list)
#.................
msg_out_list = e.separate_out(msg)
#rem_msg_dub_out = e.durations(msg_out_list)
#...................
mail_in_list = e.separate_in(email)
#rem_mail_dub_in = e.durations(mail_in_list)
#.......................
mail_out_list = e.separate_out(email)
#rem_mail_dub_out = e.durations(mail_out_list)
#.....merge all incomming_outgoing..set duration
in_list = []
in_list.append(calls_in_list)
in_list.append(msg_in_list)
in_list.append(mail_in_list)
in_list = e.m(in_list)
#......................
out_list = []
out_list.append(calls_out_list)
out_list.append(msg_out_list)
out_list.append(mail_out_list)
out_list = e.m(out_list)
#..........represent incoming outgoing both.............
r =[]
g = []
for item in in_list:
for o in out_list:
if ((cmp(int(item.e_from), int(o.e_from))) == 0) and item.name== o.name:
DATE = str(datetime.date(item.datetime))
TIME = str(datetime.time(item.datetime))
history = DATE + ' ' +TIME
if((DATE >= (date)) and (DATE <= (date2))):
r = item
g = o
NUM = item.name
pos= e.addball(NUM, DATE)
k = item.e_key
colour1 = e.colours(k)
len = len + 1
if item.duration <= 10:
d = 0.1
if item.duration > 10:
d = item.duration
d = d/10
d = d*(0.1)
e.drawLine(center,pos,colour1,d)
#....................................
# if o['duration'] <= 10:
# m = 0.1
# if o['duration'] > 10:
# m = o['duration']
# m = m/10
# m = m*(0.1)
#e.drawLine(center,pos,colourr2,m)
#..................................
in_list.remove(r)
out_list.remove(g)
#......for incoming use any other line seg........................
for i in in_list:
DATE = str(datetime.date(i.datetime))
TIME = str(datetime.time(i.datetime))
history = DATE + ' ' + TIME
if((DATE >= (date)) and (DATE <= (date2))):
NUM = i.name
pos= e.addball(NUM, history)
k = i.key
if i.duration <= 10:
d = 0.1
if i.duration > 10:
d = i.duration
d = d/10
d = d*(0.1)
colour2 = e.colours(k)
e.drawLine(center,pos,colour2,d)
#else if((DATE >= (date)) and (DATE <= (date2))):
#..........Use different style of line to draw outgoing
for l in out_list:
DATE = str(datetime.date(i.datetime))
TIME = str(datetime.time(i.datetime))
history = DATE + ' ' + TIME
if((DATE >= (date)) and (DATE <= (date2))):#2012-05-17
NUM = l.name
pos= e.addball(NUM, history)
k = l.key
if l.duration <= 10:
d = 0.8
if l.duration > 10:
d = l.duration
d = d/10
d = d*(0.8)
colour3 = e.colours(k)
e.drawLine(center,pos,colour3,d)
if d ==0 :
print("contact name does not exists")
w = Application()
run()