forked from UCSD-TIES/DVS-Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinteraction.py.orig
More file actions
763 lines (634 loc) · 24.8 KB
/
interaction.py.orig
File metadata and controls
763 lines (634 loc) · 24.8 KB
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
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
import wx, os
from Controller import *
from xlwt import Workbook
#use makepatient method from controller
IMGMASK = "JPEG Files(*.jpg;*.jpeg;*.jpe;*.jfif) " \
"|*.jpg; *.jpeg; *.jpe; *.jfif|" \
"Raw Files |*.cr2; *crw|" \
"All Files |*.*"
class interaction():
def __init__(self):
self.patient = None # This might not be used
self.horizontalPath = None # Path of horizontal image
self.verticalPath = None # Path of vertical image
self.heightRatio = None
self.widthRatio = None
self.hRightPath = None
self.hLeftPath = None
self.vRightPath = None
self.vLeftPath = None
# These bitmaps are needed to draw on, can't draw on img Ctrls
self.hBitMap = None
self.vBitMap = None
# Images to make bitmaps out of, will store original image for resets
self.hImg = None
self.vImg = None
# Coordinates for user input in tuple
# set of tuples for horizontal and vertical, outer tuple is (left eye, right eye)
# inner tuple is (Top Left X, Top Left Y, Bot Right X, Bot Right Y)
self.hcoors = [[0,0,0,0],[0,0,0,0]]
self.vcoors = [[0,0,0,0],[0,0,0,0]]
# For drawing and only for drawing
self.startX = 0
self.startY = 0
self.overlay = wx.Overlay()
# BUTTONS
# upload button, 1st page
# Args: page - the panel the image is on (will be page 1)
# imgCtrl - Either veritcal or horizontal
# text - Text control - either vertical or horizontal
# orientation - specify which image is uploading, 1 for vertical and 0 for horizontal
def upload(self, page, imgCtrl, text, orientation):
# pops up box for user to upload image
upBox = wx.FileDialog(page, "Choose an image.", os.getcwd(), "",
IMGMASK, wx.OPEN)
# Once the user hits the "OK" button
if upBox.ShowModal() == wx.ID_OK:
upPath = upBox.GetPath() # Gets the path of the uploaded file
text.SetValue(upPath) # Sets path into the text control
# Depending on which image is being uploaded, sets interaction object's
# data field and paints the image onto the page.
if orientation == 0:
self.upPaint(page, upPath, imgCtrl, orientation)
self.horizontalPath = upPath
elif orientation == 1:
self.upPaint(page, upPath, imgCtrl, orientation)
self.verticalPath = upPath
# reset button, 1st page
# Args: page - panel to clear images and paths (will be page 1)
# imgCtrl1 - vertical or horizontal image control to be cleared
# imgCtrl2 - Other control
# text1 - text control to be cleared
# text2 - other text control to be cleared
def reset(self, page, horImgCtrl, verImgCtrl, text1, text2, pageNum):
if pageNum == 1:
empty = wx.EmptyImage(440,440) # Create empty image
# Sets the 2 image controls to empty
horImgCtrl.SetBitmap(wx.BitmapFromImage(empty))
verImgCtrl.SetBitmap(wx.BitmapFromImage(empty))
# Resets path names
text1.SetValue("Please upload an image.")
text2.SetValue("Please upload an image.")
# Deletes interaction object's data
self.horizontalPath = None
self.verticalPath = None
self.hBitMap = None
self.vBitMap = None
elif pageNum == 3:
horImgCtrl.SetBitmap(self.hBitMap)
verImgCtrl.SetBitmap(self.vBitMap)
page.Refresh()
# helper method for upload button, resizes and shows uploaded image
# Args: page - the page passed in from upload() (page 1)
# upPath - path of the image to be shown
# imgCtrl - holds the newly shown image
# orientation - vertical or horizontal, taken from upload()
def upPaint(self, page, upPath, imgCtrl, orientation):
# Makes a new image using the file path
newImg = wx.Image(upPath, wx.BITMAP_TYPE_ANY)
# Getting width and height of this image
width = newImg.GetWidth()
height = newImg.GetHeight()
maxSize = 440
# scale the image to preserving the aspect ratio
''' UNUSED - FOR NOW
if width > height and width > maxSize:
newWidth = maxSize
newHeight = height / (width / float(maxSize))
elif width > height and width < maxSize:
newWidth = maxSize
newHeight = height * (width / float(maxSize))
elif width == maxSize:
newWidth = maxSize
if height > width and height > maxSize:
newHeight = maxSize
newWidth = width / (height / float(maxSize))
elif height > width and height < maxSize:
newHeight = maxSize
newWidth = width * (height / float(maxSize))
elif height == maxSize:
newHeight = maxSize
'''
# Scales the image
# This scaling works, but may have problems in future
if width > height:
newWidth = maxSize
newHeight = maxSize * height/ width
else:
newHeight = maxSize
newWidth = maxSize * width/ height
self.heightRatio = float(newHeight)/float(height)
self.widthRatio = float(newWidth)/float(width)
print "OG Height:", height, "| OG Width", width, "| New Height:", newHeight, "| New Width:", newWidth
print "Height Ratio:", self.heightRatio, "| Width Ratio:", self.widthRatio
# Finishes scaling and sets img into the imgCtrl
newImg = newImg.Scale(newWidth,newHeight)
imgCtrl.SetBitmap(wx.BitmapFromImage(newImg))
# Stores data for interaction obj depending on orientation
if orientation == 0:
self.hBitMap = wx.BitmapFromImage(newImg)
self.hImg = newImg
elif orientation == 1:
self.vBitMap = wx.BitmapFromImage(newImg)
self.vImg = newImg
page.Refresh()
# Next Button for first page
# Args: hPhotoTxt - text control for horizontal image
# vPhotoTxt - text control for vertical image
# page1 - 1st page
# page2 - 2nd page
# hImgCtrl - horizontal image control of 2nd page
# vImgCtrl - vertical image control of 2nd page
def next0(self, page0, page1, name, birth, gender, ethnicity, language,
<<<<<<< HEAD
roomNumber, school, screeningComment, referral):
<<<<<<< HEAD
self.patient = Patient()
if name != "":
self.patient.name = name
if birth != "":
self.patient.birth = birth
if gender != "":
self.patient.gender = gender
if ethnicity != "":
self.patient.ethnicity = ethnicity
if language != "":
self.patient.language = language
if roomNumber != "":
self.patient.roomNumber = roomNumber
if school != "":
self.patient.school = school
if screeningComment != "":
self.patient.screeningComment = screeningComment
if referral != "":
self.patient.referral = referral
page0.Hide()
self.ShowYourself(page1) # Shows 2nd page
=======
#if name == "" or age == "" or ethnicity == "":
# errorTxt = "Please fill out all inputs."
# errMsg = wx.MessageDialog(page0, errorTxt, "Please fill out all inputs.", wx.OK)
# errMsg.ShowModal()
# errMsg.Destroy()
#else:
self.patient = makePatient0(name, birth, gender, ethnicity, language,
roomNumber, school, screeningComment, referral)
page0.Hide()
self.ShowYourself(page1) # Shows 2nd page
>>>>>>> 9fde59ab06b3e0e493cb9c16717f6ba7bb77320c
=======
roomNumber, school, screeningComment, referral):
self.patient = Patient()
if name != "":
self.patient.name = name
if birth != "":
self.patient.birth = birth
if gender != "":
self.patient.gender = gender
if ethnicity != "":
self.patient.ethnicity = ethnicity
if language != "":
self.patient.language = language
if roomNumber != "":
self.patient.roomNumber = roomNumber
if school != "":
self.patient.school = school
if screeningComment != "":
self.patient.screeningComment = screeningComment
if referral != "":
self.patient.referral = referral
page0.Hide()
self.ShowYourself(page1) # Shows 2nd page
>>>>>>> 302ddaaecdb5d03c034f1692c19df69a12780c98
# Next Button for first page
# Args: hPhotoTxt - text control for horizontal image
# vPhotoTxt - text control for vertical image
# page1 - 1st page
# page2 - 2nd page
# hImgCtrl - horizontal image control of 2nd page
# vImgCtrl - vertical image control of 2nd page
def next1(self, hPhotoTxt, vPhotoTxt, page1, page2, hImgCtrl, vImgCtrl):
pleaseText = "Please upload an image."
if hPhotoTxt == pleaseText and vPhotoTxt == pleaseText:
errorTxt1 = "Missing images, please upload."
errMsg1 = wx.MessageDialog(page1, errorTxt1, "No Images Detected", wx.OK)
errMsg1.ShowModal()
errMsg1.Destroy()
print self.patient.name
#self.patient = makePatient(self.horizontalPath, self.verticalPath)
setPatient(self.horizontalPath, self.verticalPath, self.patient)
coors = getEyeCoors(self.patient) # this coors is local, just for drawing
print coors
# Paints the images of page 2 and hides the first page
self.upPaint(page2, self.verticalPath, vImgCtrl, 1)
self.upPaint(page2, self.horizontalPath, hImgCtrl, 0)
page1.Hide()
# Drawing rectangle with MemoryDC
mdc = wx.MemoryDC()
mdc.SelectObject(self.hBitMap) # sets a bitmap to e modified
mdc.SetBrush(wx.Brush('#CCFF99', wx.TRANSPARENT))
# Rectangles are drawn with DC.DrawRectangle(X, Y, width, Height)
mdc.DrawRectangle(coors[0][0]*self.widthRatio, coors[0][1]*self.heightRatio, coors[0][2]*self.widthRatio, coors[0][3]*self.heightRatio)
mdc.DrawRectangle(coors[1][0]*self.widthRatio, coors[1][1]*self.heightRatio, coors[1][2]*self.widthRatio, coors[1][3]*self.heightRatio)
hImgCtrl.SetBitmap(self.hBitMap) # Sets modified bitmap back into the img ctrl
img = self.vBitMap.ConvertToImage() # To get width
width = img.GetWidth()
#img = img.Rotate90()
#self.vBitMap = wx.BitmapFromImage(img)
mdc.SelectObject(self.vBitMap) # sets a bitmap to e modified
mdc.SetBrush(wx.Brush('#CCFF99', wx.TRANSPARENT))
# THIS MIGHT BE WRONG
#mdc.DrawRectangle((coors[2][1]+coors[2][3])*self.heightRatio, (width - coors[2][0]-coors[2][2])*self.widthRatio, coors[2][3], coors[2][2])
#mdc.DrawRectangle((coors[3][1]+coors[3][3])*self.heightRatio, (width - coors[3][0]-coors[3][2])*self.widthRatio, coors[3][3], coors[3][2])
mdc.DrawRectangle(coors[2][0]*self.widthRatio, coors[2][1]*self.heightRatio, coors[2][2]*self.widthRatio, coors[2][3]*self.heightRatio)
mdc.DrawRectangle(coors[3][0]*self.widthRatio, coors[3][1]*self.heightRatio, coors[3][2]*self.widthRatio, coors[3][3]*self.heightRatio)
vImgCtrl.SetBitmap(self.vBitMap) # Sets modified bitmap back into the img ctrl
mdc.SelectObject(wx.NullBitmap) # MemoryDC must be set back to a null bitmap when done
self.ShowYourself(page2) # Shows 2nd page
'''
UNUSED
# Painting the Rectangle on the 2nd page
def OnPaint(self, control):
draw = wx.PaintDC(control)
draw.Clear()
draw.SetBrush(wx.Brush('#000000', wx.TRANSPARENT))
draw.DrawRectangle(10, 10, 100, 100)
'''
# The "No" button on page2 - Moves from page 2 to 3
# Args: page2 - 2nd page
# page3 - 3rd page
# hImgCtrl - 3rd page's horizontal image control
# vImgCtrl - 3rd page's vertical image control
def No2(self, page2, page3, hImgCtrl, vImgCtrl):
# displays image on 3rd page
self.upPaint(page3, self.verticalPath, vImgCtrl, 1)
self.upPaint(page3, self.horizontalPath, hImgCtrl, 0)
page2.Hide() # Hides 2nd page
self.ShowYourself(page3) # Shows 3rd page
# The "Yes" button on page2 - Moves from page 2 to 4
# Args: page2 - 2nd page
# page4 - 4th page
def Yes2(self, page2, page4, hRightImgCtrl,
hLeftImgCtrl, vRightImgCtrl, vLeftImgCtrl):
EyePhotos = getEyePhotos(self.patient)
self.hRightPath = EyePhotos[0]
self.hLeftPath = EyePhotos[1]
self.vRightPath = EyePhotos[2]
self.vLeftPath = EyePhotos[3]
# displays image on 4th page
self.upPupilPaint(page4, self.hRightPath, hRightImgCtrl)
self.upPupilPaint(page4, self.hLeftPath, hLeftImgCtrl)
self.upPupilPaint(page4, self.vRightPath, vRightImgCtrl)
self.upPupilPaint(page4, self.vLeftPath, vLeftImgCtrl)
page2.Hide() # Hides 2nd page
self.ShowYourself(page4) # Shows 3rd page
# specialized upPaint function for cropped pupil photos
# Args: page - the page passed in from upload() (page 1)
# upPath - path of the image to be shown
# imgCtrl - holds the newly shown image
# orientation - vertical or horizontal, taken from upload()
def upPupilPaint(self, page, upPath, imgCtrl):
# Makes a new image using the file path
newImg = wx.Image(upPath, wx.BITMAP_TYPE_ANY)
# Getting width and height of this image
width = newImg.GetWidth()
height = newImg.GetHeight()
maxSize = 100
# Scales the image
# This scaling works, but may have problems in future
if width > height:
newWidth = maxSize
newHeight = maxSize * height/ width
else:
newHeight = maxSize
newWidth = maxSize * width/ height
self.heightRatio = float(newHeight)/float(height)
self.widthRatio = float(newWidth)/float(width)
print "OG Height:", height, "| OG Width", width, "| New Height:", newHeight, "| New Width:", newWidth
print "Height Ratio:", self.heightRatio, "| Width Ratio:", self.widthRatio
# Finishes scaling and sets img into the imgCtrl
newImg = newImg.Scale(newWidth,newHeight)
imgCtrl.SetBitmap(wx.BitmapFromImage(newImg))
page.Refresh()
# The "No" button on page4 - Moves from page 4 to 5
# Args: page4 - 4nd page
# page5 - 5rd page
# hImgCtrl - 5rd page's horizontal image control
# vImgCtrl - 5rd page's vertical image control
def No4(self, page4, page5, hRightImgCtrl,
hLeftImgCtrl, vRightImgCtrl, vLeftImgCtrl):
# displays image on 4th page
self.upPupilPaint(page5, self.hRightPath, hRightImgCtrl)
self.upPupilPaint(page5, self.hLeftPath, hLeftImgCtrl)
self.upPupilPaint(page5, self.vRightPath, vRightImgCtrl)
self.upPupilPaint(page5, self.vLeftPath, vLeftImgCtrl)
page4.Hide() # Hides 2nd page
self.ShowYourself(page5) # Shows 5th page
# page movement functions
# Page to be shown
def ShowYourself(self, page):
page.Raise()
page.SetPosition((0,0))
page.Fit()
page.GetParent().GetSizer().Show(page)
page.GetParent().GetSizer().Layout()
page.Refresh()
### Mouse events
# Mouse event handler, on click press
# orientation: vertical is 1, horizontal is 0
def mousePress(self, event, orientation):
#print "Mouse clicked"
newX = event.GetX()
newY = event.GetY()
self.startX = newX
self.startY = newY
if orientation == 0:
if self.hcoors[0][0] == 0: # if hcoors is empty, assume left eye
self.hcoors[0][0] = newX
self.hcoors[0][1] = newY
elif self.hcoors[1][0] == 0: # if right eye has no value yet
self.whichEye(0, newX, newY, 0) # check which eye new value belongs to
elif orientation == 1:
if self.vcoors[0][0] == 0:
self.vcoors[0][0] = newX
self.vcoors[0][1] = newY
elif self.vcoors[1][0] == 0:
self.whichEye(1, newX, newY, 0)
# Helper function checks which eye inputed values belong to
# orientation: vertical is 1, horizontal is 0
# point: 0 if starting point, 1 if ending point, of the rectangle
def whichEye(self, orientation, newX, newY, point):
if point == 1: # for ending point
if orientation == 0:
if newX > self.hcoors[0][2]: # values for right eye
self.hcoors[1][2] = newX
self.hcoors[1][3] = newY
else: # New eye values are for left eye
self.hcoors[1][2] = self.hcoors[0][2]
self.hcoors[1][3] = self.hcoors[0][3]
self.hcoors[0][2] = newX
self.hcoors[0][3] = newY
if orientation == 1:
if newX > self.vcoors[0][2]: # New eye values are for right eye
self.vcoors[1][2] = newX
self.vcoors[1][3] = newY
else: # New eye values are for left eye
self.vcoors[1][2] = self.vcoors[0][2]
self.vcoors[1][3] = self.vcoors[0][3]
self.vcoors[0][2] = newX
self.vcoors[0][3] = newY
# For starting point
if point == 0:
if orientation == 0:
if newX > self.hcoors[0][0]: # New eye values are for right eye
self.hcoors[1][0] = newX
self.hcoors[1][1] = newY
else: # New eye values are for left eye
self.hcoors[1][0] = self.hcoors[0][0]
self.hcoors[1][1] = self.hcoors[0][1]
self.hcoors[0][0] = newX
self.hcoors[0][1] = newY
if orientation == 1:
if newX > self.vcoors[0][0]: # New eye values are for right eye
self.vcoors[1][0] = newX
self.vcoors[1][1] = newY
else: # New eye values are for left eye
self.vcoors[1][0] = self.vcoors[0][0]
self.vcoors[1][1] = self.vcoors[0][1]
self.vcoors[0][0] = newX
self.vcoors[0][1] = newY
# Mouse event handler, on click release
# orientation: vertical is 1, horizontal is 0
def mouseRelease(self, event, imgCtrl, orientation):
#print "Mouse released"
endX = event.GetX()
endY = event.GetY()
# Managing how the user is drawing
# User might not draw from top left to bottom right
if self.startX > endX:
temp = self.startX
self.startX = endX
endX = temp
if self.startY > endY:
temp = self.startY
self.startY = endY
endY = temp
if orientation == 0:
if self.hcoors[0][2] == 0: # if hcoors is empty, assume left eye
self.hcoors[0][2] = endX
self.hcoors[0][3] = endY
elif self.hcoors[1][2] == 0:
self.whichEye(orientation, endX, endY, 1)
elif orientation == 1:
if self.vcoors[0][2] == 0:
self.vcoors[0][2] = endX
self.vcoors[0][3] = endY
elif self.vcoors[1][2] == 0:
self.whichEye(orientation, endX, endY, 1)
'''
elif orientation == 1:
if self.vstartX > self.vendX:
temp = self.vstartX
self.vstartX = self.vendX
self.vendX = temp
if self.vstartY > self.vendY:
temp = self.vstartY
self.vstartY = self.vendY
self.vendY = temp
'''
mdc = wx.MemoryDC()
bdc = wx.BufferedDC(mdc)
bitmap = imgCtrl.GetBitmap()
bdc.SelectObject(bitmap)
bdc.SetBrush(wx.Brush('#CCFF99', wx.TRANSPARENT))
bdc.DrawRectangle(self.startX, self.startY, endX - self.startX, endY - self.startY)
print "startX: %d startY: %d endX: %d endY: %d" % (self.startX, self.startY, endX, endY)
'''
elif orientation == 1:
bdc.DrawRectangle(self.vstartX, self.vstartY, self.vendX - self.vstartX, self.vendY - self.vstartY)
print "startX: %d startY: %d endX: %d endY: %d" % (self.vstartX, self.vstartY, self.vendX, self.vendY)
'''
bdc.SelectObject(wx.NullBitmap)
imgCtrl.SetBitmap(bitmap)
self.startX = 0
self.startY = 0
print self.hcoors
print self.vcoors
# Mouse event handler, on drag
def mouseDrag(self, event, imgCtrl):
if event.Dragging():
x = event.GetX()
y = event.GetY()
rect = wx.RectPP( (self.startX,self.startY), (x,y))
dc = wx.ClientDC(imgCtrl)
odc = wx.DCOverlay(self.overlay, dc)
odc.Clear()
dc.SetPen(wx.Pen("black", 2))
if 'wxMac' in wx.PlatformInfo:
dc.SetBrush(wx.Brush(wx.Colour(0xC0, 0xC0, 0xC0, 0x80)))
else:
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.DrawRectangleRect(rect)
del odc
'''
#print "Mouse dragged x: %d, y: %d" % (x, y)
# DRAWING HERE WAS SO YOU CAN SEE THE RECTANGLE BEING DRAWN
# DOESN'T WORK SO MOVED TO UPON RELEASE
mdc = wx.MemoryDC()
bdc = wx.BufferedDC(mdc)
bitmap = imgCtrl.GetBitmap()
bdc.SelectObject(bitmap)
bdc.SetBrush(wx.Brush('#CCFF99', wx.TRANSPARENT))
bdc.DrawRectangle(self.startX, self.startY, x - self.startX, y - self.startY)
bdc.SelectObject(wx.NullBitmap)
imgCtrl.SetBitmap(bitmap)
'''
### Mouse event tests end
'''
def OnBack(self, event):
self.Hide()
self.GetParent().panel0.ShowYourself()
self.GetParent().GetSizer().Layout()
def OnNext(self, event):
self.Hide()
self.GetParent().panel2.ShowYourself()
self.GetParent().GetSizer().Layout()
def OnCancelAndExit(self, event):
self.GetParent().ShutDown()
'''
# corrected = 1 if user corrected detection
def seeResult(self, page3, resultPage, corrected):
page3.Hide() # Hides 3nd page
self.ShowYourself(resultPage) # Shows result page
if corrected == 1:
x = self.widthRatio
y = self.heightRatio
hTuple = ((int (self.hcoors[0][0]/x),int (self.hcoors[0][1]/y),int (self.hcoors[0][2]/x),int (self.hcoors[0][3]/y)),
(int (self.hcoors[1][0]/x),int (self.hcoors[1][1]/y),int (self.hcoors[1][2]/x),int (self.hcoors[1][3]/y)))
vTuple = ((int (self.vcoors[0][0]/x),int (self.vcoors[0][1]/y),int (self.vcoors[0][2]/x),int (self.vcoors[0][3]/y)),
(int (self.vcoors[1][0]/x),int (self.vcoors[1][1]/y),int (self.vcoors[1][2]/x),int (self.vcoors[1][3]/y)))
resetEyes(self.patient, hTuple, vTuple)
self.patient.analyzeEyes(0.17)
all_info = self.patient.getInfo()
all_defects = self.patient.getDefects()
defectSize = len(all_defects)
infoSize = len(all_info)
print "all_defects size: ", defectSize
print "all_info size: ", infoSize
defectsArray = [[0 for x in xrange(2)] for y in xrange(defectSize)]
infoArray = [[0 for x in xrange(2)] for y in xrange(infoSize)]
refer = 0
lineCounter = 0
for line in all_defects.keys():
if line == "Anisomet" or line == "Strabismus" or line == "Astigmatism": refer = 1
defectsArray[lineCounter][0] = line
defectsArray[lineCounter][1] = str(all_defects[line])
lineCounter += 1
defectsArray.sort()
lineCounter = 0
for line in all_info.keys():
infoArray[lineCounter][0] = line
infoArray[lineCounter][1] = str(all_info[line])
lineCounter += 1
infoArray.sort()
# print info to the console
for line in defectsArray: print line
for line in infoArray: print line
# display defects to result page
y = 100
for line in defectsArray:
wx.StaticText(resultPage, -1, line[0], (200, y), (-1, -1), wx.ALIGN_CENTER)
wx.StaticText(resultPage, -1, line[1], (500, y), (-1, -1), wx.ALIGN_CENTER)
y += 30
print "\n"
# display info to result page
y += 30
for line in infoArray:
wx.StaticText(resultPage, -1, line[0], (200, y), (-1, -1), wx.ALIGN_CENTER)
wx.StaticText(resultPage, -1, line[1], (500, y), (-1, -1), wx.ALIGN_CENTER)
y += 30
print "\n"
# display refer result to result page
y += 30
referText = "Refer" if refer == 1 else "Not Refer"
font1 = wx.Font(30, wx.NORMAL, wx.ITALIC, wx.NORMAL)
result = wx.StaticText(resultPage, -1, referText, (850, y), (-1, -1), wx.ALIGN_CENTRE)
result.SetFont(font1)
def startOver(self, resultPage, page1, horImgCtrl, verImgCtrl, text1, text2, pageNum):
# Hides result page
resultPage.Hide()
self.reset(page1, horImgCtrl, verImgCtrl, text1, text2, pageNum)
# Shows first page
page1.Show()
def exportData(self,page):
<<<<<<< HEAD
book = Workbook()
sheet1 = book.add_sheet('Patient Data')
sheet1.write(0,0,'Name')
sheet1.write(0,1,self.patient.name)
row1 = sheet1.row(1)
row1.write(0,'Date of Birth')
row1.write(1,self.patient.birth)
row2 = sheet1.row(2)
row2.write(0,'Gender')
row2.write(1,self.patient.gender)
row3 = sheet1.row(3)
row3.write(0,'Ethnicity')
row3.write(1,self.patient.ethnicity)
row4 = sheet1.row(4)
row4.write(0,'Language')
row4.write(1,self.patient.language)
row5 = sheet1.row(5)
row5.write(0,'Room Number')
row5.write(1,self.patient.roomNumber)
row6 = sheet1.row(6)
row6.write(0,'School')
row6.write(1,self.patient.school)
row7 = sheet1.row(7)
row7.write(0,'Screening Comment')
row7.write(1,self.patient.screeningComment)
row8 = sheet1.row(8)
row8.write(0,'Referral')
row8.write(1,self.patient.referral)
sheet1.col(0).width = 5000
sheet1.col(1).width = 5000
book.save('patient_data.xls')
msg = "Excel file saved in current directory"
savedMsg = wx.MessageDialog(page, msg, "Patient Data Exported", wx.OK)
savedMsg.ShowModal()
=======
book = Workbook()
sheet1 = book.add_sheet('Patient Data')
sheet1.write(0,0,'Name')
sheet1.write(0,1,self.patient.name)
row1 = sheet1.row(1)
row1.write(0,'Date of Birth')
row1.write(1,self.patient.birth)
row2 = sheet1.row(2)
row2.write(0,'Gender')
row2.write(1,self.patient.gender)
row3 = sheet1.row(3)
row3.write(0,'Ethnicity')
row3.write(1,self.patient.ethnicity)
row4 = sheet1.row(4)
row4.write(0,'Language')
row4.write(1,self.patient.language)
row5 = sheet1.row(5)
row5.write(0,'Room Number')
row5.write(1,self.patient.roomNumber)
row6 = sheet1.row(6)
row6.write(0,'School')
row6.write(1,self.patient.school)
row7 = sheet1.row(7)
row7.write(0,'Screening Comment')
row7.write(1,self.patient.screeningComment)
row8 = sheet1.row(8)
row8.write(0,'Referral')
row8.write(1,self.patient.referral)
sheet1.col(0).width = 5000
sheet1.col(1).width = 5000
book.save('patient_data.xls')
msg = "Excel file saved in current directory"
savedMsg = wx.MessageDialog(page, msg, "Patient Data Exported", wx.OK)
savedMsg.ShowModal()
>>>>>>> 302ddaaecdb5d03c034f1692c19df69a12780c98