Event link between model and azimuth map.
This commit is contained in:
parent
a9c7e4bcca
commit
198d46ac99
@ -95,6 +95,7 @@ class az_map(QtGui.QWidget):
|
|||||||
|
|
||||||
def setModel(self, model):
|
def setModel(self, model):
|
||||||
self._model = model
|
self._model = model
|
||||||
|
self._model.dataChanged.connect(self.drawPath)
|
||||||
|
|
||||||
def paintEvent(self, event):
|
def paintEvent(self, event):
|
||||||
painter = QtGui.QPainter(self)
|
painter = QtGui.QPainter(self)
|
||||||
@ -105,7 +106,7 @@ class az_map(QtGui.QWidget):
|
|||||||
|
|
||||||
#draw the range rings
|
#draw the range rings
|
||||||
self.drawRangeRings(painter)
|
self.drawRangeRings(painter)
|
||||||
self.drawPath()
|
#self.drawPath()
|
||||||
|
|
||||||
painter.setPen(az_map.rangepen)
|
painter.setPen(az_map.rangepen)
|
||||||
painter.drawPath(self._path)
|
painter.drawPath(self._path)
|
||||||
@ -128,6 +129,7 @@ class az_map(QtGui.QWidget):
|
|||||||
|
|
||||||
self._path.lineTo(xpts,0-ypts)
|
self._path.lineTo(xpts,0-ypts)
|
||||||
self._path.arcTo(arcrect, 90-bearing, 360./az_map_model.npoints)
|
self._path.arcTo(arcrect, 90-bearing, 360./az_map_model.npoints)
|
||||||
|
#self.paintEvent(QtCore.QEvent())
|
||||||
|
|
||||||
def drawRangeRings(self, painter):
|
def drawRangeRings(self, painter):
|
||||||
painter.translate(self.width()/2, self.height()/2)
|
painter.translate(self.width()/2, self.height()/2)
|
||||||
@ -137,19 +139,21 @@ class az_map(QtGui.QWidget):
|
|||||||
painter.drawEllipse(QtCore.QRectF(-diameter / 2.0,
|
painter.drawEllipse(QtCore.QRectF(-diameter / 2.0,
|
||||||
-diameter / 2.0, diameter, diameter))
|
-diameter / 2.0, diameter, diameter))
|
||||||
|
|
||||||
import random
|
import random, time
|
||||||
class Window(QtGui.QWidget):
|
class Window(QtGui.QWidget):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Window, self).__init__()
|
super(Window, self).__init__()
|
||||||
layout = QtGui.QGridLayout()
|
layout = QtGui.QGridLayout()
|
||||||
model = az_map_model()
|
self.model = az_map_model()
|
||||||
for i in range(az_map_model.npoints):
|
|
||||||
model._data[i][model.columnCount()-1] = random.randint(0,400)
|
|
||||||
mymap = az_map(None)
|
mymap = az_map(None)
|
||||||
mymap.setModel(model)
|
mymap.setModel(self.model)
|
||||||
layout.addWidget(mymap, 0, 1)
|
layout.addWidget(mymap, 0, 1)
|
||||||
self.setLayout(layout)
|
self.setLayout(layout)
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
for i in range(az_map_model.npoints):
|
||||||
|
self.model.addRecord(i*360./az_map_model.npoints, 30000, random.randint(0,400))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
@ -158,4 +162,5 @@ if __name__ == '__main__':
|
|||||||
app = QtGui.QApplication(sys.argv)
|
app = QtGui.QApplication(sys.argv)
|
||||||
window = Window()
|
window = Window()
|
||||||
window.show()
|
window.show()
|
||||||
|
window.update()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
Loading…
Reference in New Issue
Block a user