- # Used in 'format_value()' to check against.
- self.inf = float('inf')
-
- def format_unit(self, u):
- units = {
- sr.Unit.VOLT: 'V',
- sr.Unit.AMPERE: 'A',
- sr.Unit.OHM: u'\u03A9',
- sr.Unit.FARAD: 'F',
- sr.Unit.KELVIN: 'K',
- sr.Unit.CELSIUS: u'\u00B0C',
- sr.Unit.FAHRENHEIT: u'\u00B0F',
- sr.Unit.HERTZ: 'Hz',
- sr.Unit.PERCENTAGE: '%',
- # sr.Unit.BOOLEAN
- sr.Unit.SECOND: 's',
- sr.Unit.SIEMENS: 'S',
- sr.Unit.DECIBEL_MW: 'dBu',
- sr.Unit.DECIBEL_VOLT: 'dBV',
- # sr.Unit.UNITLESS
- sr.Unit.DECIBEL_SPL: 'dB',
- # sr.Unit.CONCENTRATION
- sr.Unit.REVOLUTIONS_PER_MINUTE: 'rpm',
- sr.Unit.VOLT_AMPERE: 'VA',
- sr.Unit.WATT: 'W',
- sr.Unit.WATT_HOUR: 'Wh',
- sr.Unit.METER_SECOND: 'm/s',
- sr.Unit.HECTOPASCAL: 'hPa',
- sr.Unit.HUMIDITY_293K: '%rF',
- sr.Unit.DEGREE: u'\u00B0',
- sr.Unit.HENRY: 'H'
- }
-
- return units.get(u, '')
+ # A generator for the colors of the channels.
+ self._colorgen = self._make_colorgen()
+
+ def _make_colorgen(self):
+ cols = [
+ QtGui.QColor(0x8F, 0x52, 0x02), # brown
+ QtGui.QColor(0x73, 0xD2, 0x16), # green
+ QtGui.QColor(0xCC, 0x00, 0x00), # red
+ QtGui.QColor(0x34, 0x65, 0xA4), # blue
+ QtGui.QColor(0xF5, 0x79, 0x00), # orange
+ QtGui.QColor(0xED, 0xD4, 0x00), # yellow
+ QtGui.QColor(0x75, 0x50, 0x7B) # violet
+ ]
+
+ def myrepeat(g, n):
+ '''Repeats every element from 'g' 'n' times'.'''
+ for e in g:
+ for f in itertools.repeat(e, n):
+ yield f
+
+ colorcycle = itertools.cycle(cols)
+ darkness = myrepeat(itertools.count(100, 10), len(cols))
+
+ for c, d in izip(colorcycle, darkness):
+ yield QtGui.QColor(c).darker(d)