-
Notifications
You must be signed in to change notification settings - Fork 0
/
detectionWindow.py
111 lines (84 loc) · 3.79 KB
/
detectionWindow.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
import sys
from PyQt4 import QtGui, QtCore, QtWebKit
from detectionWindowUI import Ui_DetectionWindow as UI
class detectionWindow(QtGui.QWidget):
def __init__(self, parent):
QtGui.QWidget.__init__(self)
self.ui = UI()
self.ui.setupUi(self)
self.parent = parent
self.signal = QtCore.SIGNAL("signal")
self.GPSWebView = self.ui.GPSWebView
self.GPSWebView.settings().setAttribute(QtWebKit.QWebSettings.LocalStorageEnabled, True)
self.GPSWebView.settings().enablePersistentStorage()
self.GPSWebView.load(QtCore.QUrl("file:////home/ieee/UX/geo.html"))
self.GPSWebView.loadFinished.connect(self.webAppReady)
self.ui.FPSComboBox.addItem("05") #Hack to avoid changing remote end
for i in range(2, 7):
self.ui.FPSComboBox.addItem(str(i * 5))
self.ui.FPSComboBox.setCurrentIndex(1)
self.ui.FPSComboBox.activated[str].connect(self.selectFPS)
self.ui.camComboBox.addItem("Left Camera")
self.ui.camComboBox.addItem("Right Camera")
self.ui.markerComboBox.addItem("Purple Rock")
self.ui.markerComboBox.addItem("Green Rock")
self.ui.markerComboBox.addItem("Blue Rock")
self.ui.markerComboBox.addItem("Red Rock")
self.ui.markerComboBox.addItem("Orange Rock")
self.ui.markerComboBox.addItem("Yellow Rock")
self.ui.markerComboBox.activated[str].connect(self.changeMarker)
self.ui.clearComboBox.addItem("Clear Route")
self.ui.clearComboBox.addItem("Clear Markers")
self.ui.clearComboBox.addItem("Clear All")
self.ui.clearButton.clicked.connect(self.handleClear)
self.ui.openButton.clicked.connect(self.handleOpen)
self.ui.saveButton.clicked.connect(self.handleSave)
self.showMaximized()
self.setVisible(False)
self.ui.splitter.splitterMoved.connect(self.showMax)
self.ui.splitter_2.splitterMoved.connect(self.showMax)
def webAppReady(self):
pass
def getWinId(self):
return self.ui.VideoWidget.winId()
def keyPressEvent(self, event):
self.parent.keyPressEvent(event)
def keyReleaseEvent(self, event):
self.parent.keyReleaseEvent(event)
def selectFPS(self):
camstr = 'D' + self.ui.FPSComboBox.currentText()
self.emit(self.signal, camstr)
def switchCam(self):
self.ui.camComboBox.setCurrentIndex(self.ui.camComboBox.currentIndex() ^ 1)
def setDropCam(self):
self.ui.camComboBox.setCurrentIndex(1)
def changeMarker(self):
color = self.ui.markerComboBox.currentText().split(' ')[0]
print color
scriptString = "setMarkerColor(\"" + color + "\");"
self.evaluateJS(scriptString)
def handleClear(self):
clearType = self.ui.clearComboBox.currentText().split(' ')[1]
scriptString = "clearScreen(\"" + clearType + "\");"
self.evaluateJS(scriptString)
def handleOpen(self):
scriptString = "openMarkers()"
print scriptString
self.evaluateJS(scriptString)
def handleSave(self):
scriptString = "saveMarkers()"
print scriptString
self.evaluateJS(scriptString)
def handleCallback(self, lat, lng):
scriptString = "addToRoute({0}, {1});".format(lat, lng)
print scriptString
self.evaluateJS(scriptString)
def showMax(self):
self.setVisible(True)
height = self.ui.GPSWidget.frameGeometry().height() - 25
width = self.ui.GPSWidget.frameGeometry().width() - 25
scriptString = "resetSize({0}, {1});".format(width, height)
self.evaluateJS(scriptString)
self.GPSWebView.show()
def evaluateJS(self, scriptString):
self.GPSWebView.page().mainFrame().evaluateJavaScript(scriptString)