本文整理匯總了Python中bus.Bus.scalemapLoopupWaypoint方法的典型用法代碼示例。如果您正苦於以下問題:Python Bus.scalemapLoopupWaypoint方法的具體用法?Python Bus.scalemapLoopupWaypoint怎麽用?Python Bus.scalemapLoopupWaypoint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bus.Bus
的用法示例。
在下文中一共展示了Bus.scalemapLoopupWaypoint方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Window
# 需要導入模塊: from bus import Bus [as 別名]
# 或者: from bus.Bus import scalemapLoopupWaypoint [as 別名]
#.........這裏部分代碼省略.........
self.bus.locateBus()
self.mouse=None
self.timer=QtCore.QTimer()
self.timer.timeout.connect(self.doWork)
self.timer.start(8000)
def showMessage(self,message):
icon = QtGui.QSystemTrayIcon.MessageIcon()
#icon=QtGui.QSystemTrayIcon.Information
self.trayIcon.showMessage(
u'bus coming',message, icon,2000)
def mousePressEvent(self, event):
self.mouse=event.pos()
self.update()
def paintEvent(self,event):
qp=QtGui.QPainter()
qp.begin(self)
self.drawDetails(event,qp)
qp.end()
def drawDetails(self,event,qp):
if len(self.bus.shape)==0:
return
size=self.size()
w=size.width()
h=size.height()
wid=min(h,w/self.bus.xfactor)
margine=int(wid*0.05)
if self.mouse!=None:
t=self.mouse.toTuple()
qp.setPen(QtGui.QColor(168,34,3))
qp.setFont(QtGui.QFont('Decorative', 10))
qp.drawText(event.rect(), QtCore.Qt.AlignTop, "Offset: %s. Stop: %s"% (str(self.bus.scalemapLoopupWaypoint(margine,wid,t)),self.bus.scalemapLoopupStopName(margine,wid,t)))
monitorl=self.bus.busoffset-self.bus.backward
if monitorl<0:
monitorl+=len(self.bus.route)
monitorr=self.bus.busoffset+self.bus.forward
if monitorr>len(self.bus.route):
monitorr-=len(self.bus.route)
pen = QtGui.QPen(QtCore.Qt.black, 2, QtCore.Qt.SolidLine)
qp.setPen(pen)
for i in range(len(self.bus.route)-1):
if i>=monitorl and i<monitorr:
continue
if (i>=monitorl or i<monitorr ) and monitorl>monitorr:
continue
cordi=self.bus.route[i]
nx,ny=self.bus.scalemap(margine,wid,cordi)
cordi2=self.bus.route[i+1]
nx2,ny2=self.bus.scalemap(margine,wid,cordi2)
qp.drawLine(nx,ny,nx2,ny2)
#print nx,ny,nx2,ny2
pen = QtGui.QPen(QtCore.Qt.green, 2, QtCore.Qt.SolidLine)
qp.setPen(pen)
if monitorl<monitorr:
for i in range(monitorl,monitorr):
cordi=self.bus.route[i]
nx,ny=self.bus.scalemap(margine,wid,cordi)
cordi2=self.bus.route[i+1]
nx2,ny2=self.bus.scalemap(margine,wid,cordi2)
qp.drawLine(nx,ny,nx2,ny2)
else:
for i in range(0,monitorr):
cordi=self.bus.route[i]
nx,ny=self.bus.scalemap(margine,wid,cordi)