Saner scrolling behavior and range labeling.

This commit is contained in:
Nick Foster 2013-07-22 18:15:03 -07:00
parent 6e230a7d9e
commit 1eca043bac

View File

@ -27,7 +27,7 @@ import threading
import math import math
import air_modes import air_modes
from air_modes.exceptions import * from air_modes.exceptions import *
import numpy as np
# model has max range vs. azimuth in n-degree increments # model has max range vs. azimuth in n-degree increments
# contains separate max range for a variety of altitudes so # contains separate max range for a variety of altitudes so
@ -53,7 +53,7 @@ class az_map_model(QtCore.QObject):
def data(self, row, col): def data(self, row, col):
return self._data[row][col] return self._data[row][col]
def addRecord(self, bearing, altitude, distance): def addRecord(self, bearing, altitude, distance):
with self.lock: with self.lock:
#round up to nearest altitude in altitudes list #round up to nearest altitude in altitudes list
@ -157,20 +157,22 @@ class az_map(QtGui.QWidget):
def drawRangeRings(self, painter): def drawRangeRings(self, painter):
painter.translate(self.width()/2, self.height()/2) painter.translate(self.width()/2, self.height()/2)
#choose intelligent range step -- keep it between 3-5 rings #choose intelligent range step -- keep it between 3-5 rings
rangestep = 25 rangestep = 100
while self.get_range() / rangestep > 5: while self.get_range() / rangestep < 3:
rangestep *= 2 rangestep /= 2.0
for i in range(rangestep, self.get_range(), rangestep): for i in np.arange(rangestep, self.get_range(), rangestep):
diameter = (float(i) / self.get_range()) * min(self.width(), self.height()) diameter = (float(i) / self.get_range()) * min(self.width(), self.height())
painter.setPen(az_map.ringpen) painter.setPen(az_map.ringpen)
painter.drawEllipse(QtCore.QRectF(-diameter / 2.0, painter.drawEllipse(QtCore.QRectF(-diameter / 2.0,
-diameter / 2.0, diameter, diameter)) -diameter / 2.0, diameter, diameter))
painter.setPen(QtGui.QColor(255,127,0,255)) painter.setPen(QtGui.QColor(255,127,0,255))
painter.drawText(0-50/2.0, diameter/2.0, 50, 30, QtCore.Qt.AlignHCenter, painter.drawText(0-70/2.0, diameter/2.0, 70, 30, QtCore.Qt.AlignHCenter,
"%.0fnm" % i) "%.1fnm" % i)
def setMaxRange(self, maxrange): def setMaxRange(self, maxrange):
maxrange = max(3.25, maxrange)
maxrange = min(500., maxrange)
self.maxrange = maxrange self.maxrange = maxrange
self.repaint() self.repaint()