From 198d46ac999d252cd1e2ffdd94fcf3525d95f55a Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Wed, 10 Oct 2012 00:22:13 -0700 Subject: [PATCH] Event link between model and azimuth map. --- python/az_map.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/python/az_map.py b/python/az_map.py index 8ce0f98..bdb625a 100755 --- a/python/az_map.py +++ b/python/az_map.py @@ -95,6 +95,7 @@ class az_map(QtGui.QWidget): def setModel(self, model): self._model = model + self._model.dataChanged.connect(self.drawPath) def paintEvent(self, event): painter = QtGui.QPainter(self) @@ -105,7 +106,7 @@ class az_map(QtGui.QWidget): #draw the range rings self.drawRangeRings(painter) - self.drawPath() + #self.drawPath() painter.setPen(az_map.rangepen) painter.drawPath(self._path) @@ -128,6 +129,7 @@ class az_map(QtGui.QWidget): self._path.lineTo(xpts,0-ypts) self._path.arcTo(arcrect, 90-bearing, 360./az_map_model.npoints) + #self.paintEvent(QtCore.QEvent()) def drawRangeRings(self, painter): painter.translate(self.width()/2, self.height()/2) @@ -137,19 +139,21 @@ class az_map(QtGui.QWidget): painter.drawEllipse(QtCore.QRectF(-diameter / 2.0, -diameter / 2.0, diameter, diameter)) -import random +import random, time class Window(QtGui.QWidget): def __init__(self): super(Window, self).__init__() layout = QtGui.QGridLayout() - model = az_map_model() - for i in range(az_map_model.npoints): - model._data[i][model.columnCount()-1] = random.randint(0,400) + self.model = az_map_model() mymap = az_map(None) - mymap.setModel(model) + mymap.setModel(self.model) layout.addWidget(mymap, 0, 1) 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__': @@ -158,4 +162,5 @@ if __name__ == '__main__': app = QtGui.QApplication(sys.argv) window = Window() window.show() + window.update() sys.exit(app.exec_())