def __init__(self, parent=None): super(overlayElQwtDial, self).__init__(parent) self.parent = parent self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, 1, QtGui.QColor(0,0,255)) self.setOrigin(180) self.initUI() self.setGeometry(5,5,330,330)
def __init__(self, parent=None): super(az_QwtDial, self).__init__(parent) self.parent = parent self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, 1, QtGui.QColor(255,0,0)) self.setOrigin(270) self.initUI() self.setGeometry(5,5,330,330)
def __init__(self): super(overlayAzQwtDial, self).__init__() self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, 1, QtGui.QColor(0, 0, 255)) #self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, 1, QtGui.QColor(0,0,255)) self.setOrigin(270) self.initUI()
def __init__(self, parent_grid): super(el_QwtDial, self).__init__() self.parent_grid = parent_grid self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, 1, QtGui.QColor(255, 0, 0)) self.setOrigin(180) self.initUI()
def __init__(self, parent=None): super(el_QwtDial, self).__init__(parent) self.parent = parent #self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, 1, QtGui.QColor(255,0,0)) self.needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, 1, QtGui.QColor(255,0,0)) self.setOrigin(180) self.initUI()
def __init__(self, parent=None): Widget.__init__(self) Qwt.QwtDial.__init__(self, parent) self.label = QtGui.QLabel() font = QtGui.QFont() font.setPointSize(28) #self.label.setFont(font) self.__label = 'km/h' #self.__label.resize(20) self.setWrapping(False) self.setReadOnly(True) self.setMode(self.RotateNeedle) self.setFrameShadow(self.Sunken) self.setOrigin(90) self.setScaleArc(45.0, 315.0) self.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.QColor(Qt.Qt.red), Qt.QColor(Qt.Qt.gray).light(130))) self.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) self.setScaleTicks(0, 4, 8) self.setPalette(self.__colorTheme(Qt.QColor(Qt.Qt.darkGray).dark(150))) self._minValue = 0 self._maxValue = 300 self._lowerLimit = 0.0 self._upperLimit = 10.0 self._step = 20.0 self.setScale(self._lowerLimit, self._upperLimit, self._step) self.setRange(self._minValue, self._maxValue) self._labelFix = False
def __createDial(self, pos): dial = None if pos == 0: self.__clock = Qwt.QwtAnalogClock(self) knobColor = Qt.QColor(Qt.Qt.gray).light(130) for h in handList: handColor = Qt.QColor(Qt.Qt.gray).light(150) width = 8 if h == Qwt.QwtAnalogClock.SecondHand: handColor = Qt.Qt.gray width = 5 hand = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, handColor, knobColor) hand.setWidth(width) self.__clock.setHand(h, hand) timer = Qt.QTimer(self.__clock) timer.connect(timer, Qt.SIGNAL('timeout()'), self.__clock.setCurrentTime) timer.start(1000) dial = self.__clock dial.setToolTip("relogio") elif pos == 1: self.__speedo = SpeedoMeter(self) self.__speedo.setRange(0.0, 240.0) self.__speedo.setScale(-1, 2, 20) timer = Qt.QTimer(self.__speedo) timer.connect(timer, Qt.SIGNAL('timeout()'), self.changeSpeed) timer.start(50) dial = self.__speedo dial.setToolTip("1") elif pos == 2: self.__ai = AttitudeIndicator(self) gradientTimer = Qt.QTimer(self.__ai) gradientTimer.connect(gradientTimer, Qt.SIGNAL('timeout()'), self.changeGradient) gradientTimer.start(100) angleTimer = Qt.QTimer(self.__ai) angleTimer.connect(angleTimer, Qt.SIGNAL('timeout()'), self.changeAngle) angleTimer.start(100) dial = self.__ai dial.setToolTip("kakaka") if dial: dial.setReadOnly(True) dial.scaleDraw().setPenWidth(3) dial.setLineWidth(4) dial.setFrameShadow(Qwt.QwtDial.Sunken) return dial
def __init__(self, *args): Qwt.QwtDial.__init__(self, *args) self.__label = 'km/h' self.setWrapping(False) self.setReadOnly(True) self.setOrigin(135.0) self.setScaleArc(0.0, 270.0) self.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.QColor(Qt.Qt.red), Qt.QColor(Qt.Qt.gray).light(130))) self.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) self.setScaleTicks(0, 4, 8)
def __init__(self, label, *args): Qwt.QwtDial.__init__(self, *args) self.__label = label self.setWrapping(False) self.setReadOnly(True) self.setOrigin(135.0) self.setScaleArc(0.0, 270.0) self.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.QColor(QtCore.Qt.red), Qt.QColor(QtCore.Qt.gray).light(130))) self.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) self.setScaleTicks(0, 4, 8) self.setPalette(self.__colorTheme(Qt.QColor(Qt.Qt.darkGray).dark(150)))
def __init__(self, parent=None): Widget.__init__(self) Qwt.QwtDial.__init__(self, parent) self.setGeometry(QtCore.QRect(90, 10, 266, 261)) self.name = "Dial" self.setReadOnly(True) self.setLineWidth(5) self.setFrameShadow(Qwt.QwtDial.Sunken) self.setMode(Qwt.QwtDial.RotateNeedle) self.setOrigin(90.0) self.setWrapping(False) self.setObjectName("qwtDial") self._minValue = 0 self._maxValue = 500 self._lowerLimit = 0.0 self._upperLimit = 10.0 self._step = 25.0 self.setScale(self._lowerLimit, self._upperLimit, self._step) self.setRange(self._minValue, self._maxValue) self._labelFix = False #-- paramétrage initial du QwtDial -- self.setOrigin( 90.0) # point de référence du tracé - 0°=3H, 90° = 6H, etc.. #self.qwtDial.setScaleArc(90.0, 270.0) # angle début / angle fin du tracé par rapport à l'origine self.setScaleArc( 45.0, 315.0) # angle début / angle fin du tracé par rapport à l'origine self.__label = 'km/h' #self.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) #self.setScaleTicks(0, 4, 8) #-- création de l'aiguille et association au QwtDial #QwtDialSimpleNeedle ( Style style, bool hasKnob = true, const QColor & mid = Qt::gray, const QColor & base = Qt::darkGray ) aiguille = Qwt.QwtDialSimpleNeedle( Qwt.QwtDialSimpleNeedle.Arrow, True, QtGui.QColor(QtCore.Qt.red), QtGui.QColor(QtCore.Qt.blue )) # défini un QwtDialSimpleNeedle = aiguille simple # .Arrow = style aiguille "flèche" | .Ray = style simple ligne self.setNeedle(aiguille) # associe l
def __init__(self, *args): Qwt.QwtDial.__init__(self, *args) self.setMinimumSize(200, 200) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.direction = 'Standstill' self.setWrapping(False) self.setReadOnly(True) self.setOrigin(135.0) self.setScaleArc(0.0, 270.0) self.setScale(0, 0x7fff, 5000) self.setRange(0, 0x7fff) self.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, QColor(Qt.red), QColor(Qt.gray).light(130))) self.setScaleOptions(Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) self.setScaleTicks(0, 4, 8)
def __createCompass(self, pos): palette = Qt.QPalette() for colorRole in colorRoleList: palette.setColor(colorRole, Qt.QColor()) palette.setColor( Qt.QPalette.Base, self.palette().color(self.backgroundRole()).light(120)) palette.setColor(Qt.QPalette.Foreground, palette.color(Qt.QPalette.Base)) compass = Qwt.QwtCompass() compass.setLineWidth(4) if pos < 3: compass.setFrameShadow(Qwt.QwtCompass.Sunken) else: compass.setFrameShadow(Qwt.QwtCompass.Raised) if pos == 0: compass.setMode(Qwt.QwtCompass.RotateScale) rose = Qwt.QwtSimpleCompassRose(16, 2) rose.setWidth(0.15) compass.setRose(rose) compass.setToolTip("Bussola") elif pos == 1: compass.setLabelMap({ 0.0: "N", 45.0: "NE", 90.0: "E", 180.0: "S", 270.0: "W" }) rose = Qwt.QwtSimpleCompassRose(4, 1) compass.setRose(rose) compass.setNeedle( Qwt.QwtCompassWindArrow(Qwt.QwtCompassWindArrow.Style2)) compass.setValue(60.0) compass.setToolTip("Bussola_1") elif pos == 2: palette.setColor(Qt.QPalette.Base, Qt.Qt.darkBlue) palette.setColor(Qt.QPalette.Foreground, Qt.QColor(Qt.Qt.darkBlue).dark(120)) palette.setColor(Qt.QPalette.Text, Qt.Qt.white) compass.setScaleTicks(1, 1, 3) compass.setScale(36, 5, 0) compass.setNeedle( Qwt.QwtCompassMagnetNeedle( Qwt.QwtCompassMagnetNeedle.ThinStyle)) compass.setValue(220.0) compass.setToolTip("Bussola2") elif pos == 3: palette.setColor(Qt.QPalette.Base, self.palette().color(self.backgroundRole())) palette.setColor(Qt.QPalette.Foreground, Qt.Qt.blue) compass.setLineWidth(0) compass.setScaleOptions(Qwt.QwtDial.ScaleBackbone | Qwt.QwtDial.ScaleTicks | Qwt.QwtDial.ScaleLabel) compass.setScaleTicks(0, 0, 3) compass.setLabelMap({ 0.0: '0', 60.0: '60-', 120.0: '120', 180.0: '180', 240.0: '240', 320.0: '320' }) compass.setScale(36, 5, 0) compass.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, False, Qt.Qt.white)) compass.setOrigin(220.0) compass.setValue(20.0) compass.setToolTip("Bussola_2") elif pos == 4: compass.setScaleTicks(0, 0, 3) #compass.setScaleTicks() compass.setLabelMap({0.0: "N", 90.0: "E", 180.0: "S", 270.0: "W"}) compass.setNeedle( Qwt.QwtCompassMagnetNeedle( Qwt.QwtCompassMagnetNeedle.TriangleStyle, Qt.Qt.white, Qt.Qt.red)) compass.setValue(75.0) compass.setToolTip("Bussola_3") elif pos == 5: palette.setColor(Qt.QPalette.Foreground, Qt.Qt.black) compass.setNeedle( Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Ray, False, Qt.Qt.yellow)) compass.setValue(315.0) compass.setToolTip("Bussola_4") newPalette = compass.palette() for colorRole in colorRoleList: if palette.color(colorRole).isValid(): for colorGroup in colorGroupList: newPalette.setColor(colorGroup, colorRole, palette.color(colorRole)) for colorGroup in colorGroupList: light = newPalette.color(colorGroup, Qt.QPalette.Base).light(170) dark = newPalette.color(colorGroup, Qt.QPalette.Base).dark(170) if compass.frameShadow() == Qwt.QwtDial.Raised: mid = newPalette.color(colorGroup, Qt.QPalette.Base).dark(110) else: mid = newPalette.color(colorGroup, Qt.QPalette.Base).light(110) newPalette.setColor(colorGroup, Qt.QPalette.Dark, dark) newPalette.setColor(colorGroup, Qt.QPalette.Mid, mid) newPalette.setColor(colorGroup, Qt.QPalette.Light, light) compass.setPalette(newPalette) return compass
def __init__(self, label="", min_val=-90, max_val=90, step=10, arc_bias=0, *args): gr.sync_block.__init__(self,name="QT Compass",in_sig=[numpy.float32],out_sig=[]) Qwt.QwtPlot.__init__(self, *args) # Set parameters self.update_period = 0.1 self.last = time.time() self.next_angle = 0 ### QT STUFF # Setup overall layouts self.this_layout = Qt.QVBoxLayout() self.compass_layout = Qt.QGridLayout() # Setup Dial self.dial = Qwt.QwtDial(self) self.dial.setOrigin(180+arc_bias) # Orient dial so 0 is at 9 o'clock self.dial.setScaleArc(min_val,max_val) self.dial.setRange(min_val, max_val, step) self.dial.setScale(min_val ,max_val, step) self.dial.setScaleTicks(1,20,30) # Add needle self.dial.setNeedle(Qwt.QwtDialSimpleNeedle( Qwt.QwtDialSimpleNeedle.Arrow, True, QtGui.QColor(QtCore.Qt.red), QtGui.QColor(QtCore.Qt.gray).light(130))) self.dial.setValue(0) # Set sizing self.dial.setMinimumSize(250,250) self.dial.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) # Add to overall layout self.compass_layout.addWidget(self.dial,0,0) # Add label self.label = Qt.QLabel(label) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.this_layout.addWidget(self.label) self.this_layout.addLayout(self.compass_layout) # Setup LCD lcd_layout = Qt.QGridLayout() self.lcd = QtGui.QLCDNumber(self) sizePolicy = Qt.QSizePolicy(Qt.QSizePolicy.Preferred, Qt.QSizePolicy.Preferred) sizePolicy.setHeightForWidth(True) self.lcd.setSizePolicy(sizePolicy) self.lcd.setLineWidth(0) # Set sizing self.lcd.setMinimumHeight(self.dial.minimumHeight()/2) self.lcd.setMinimumWidth(self.dial.minimumWidth()/2) self.lcd.raise_() # Bring to front self.lcd.setDigitCount(3) # Max digits displayed self.lcd.setSmallDecimalPoint(True) self.lcd.display(123.4) self.compass_layout.addLayout(lcd_layout,0,0) lcd_layout.addWidget(self.lcd,1,1,1,1) # Add spacers to center LCD spacerTop = QtGui.QSpacerItem(1,300,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) spacerSides = QtGui.QSpacerItem(220,1,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) spacerBottom = QtGui.QSpacerItem(1,150,Qt.QSizePolicy.Maximum,Qt.QSizePolicy.Expanding) # Top Spacers lcd_layout.addItem(spacerTop,0,1,1,1) # Side Spacers lcd_layout.addItem(spacerSides,1,0,1,1) lcd_layout.addItem(spacerSides,1,2,1,1) # Bottom Spacers lcd_layout.addItem(spacerBottom,2,1,1,1) self.label.raise_() # connect the plot callback signal QtCore.QObject.connect(self, QtCore.SIGNAL("updatePlot(int)"), self.do_plot)
def __init__(self, label="", min_val=-90, max_val=90, step=10, arc_bias=0, needle_N=1, *args): gr.sync_block.__init__(self, name="QT Compass", in_sig=[numpy.float32] * needle_N, out_sig=[]) Qwt.QwtPlot.__init__(self, *args) # Set parameters self.update_period = 0.1 self.last = time.time() self.next_angles = [] ### QT STUFF # Setup overall layouts self.this_layout = Qt.QVBoxLayout() self.compass_layout = Qt.QGridLayout() # Setup Dials self.dial_list = [] for i in range(needle_N): dial = Qwt.QwtDial(self) dial_palette = dial.palette() transparent_color = QtGui.QBrush(QtGui.QColor(255, 255, 255, 0)) dial_palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, transparent_color) dial_palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, transparent_color) dial_palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, transparent_color) dial_palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, transparent_color) dial_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, transparent_color) dial_palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, transparent_color) dial.setPalette(dial_palette) dial.setOrigin(180 + arc_bias) # Orient dial so 0 is at 9 o'clock dial.setScaleArc(min_val, max_val) dial.setRange(min_val, max_val, step) dial.setScale(min_val, max_val, step) dial.setScaleTicks(1, 20, 30) # Add needle color_index = int(str(i)[len(str(i)) - 1:len(str(i)):]) # get last digit of i if color_index == 0: needleColor = QtGui.QColor(255, 0, 0) # red elif color_index == 1: needleColor = QtGui.QColor(255, 125, 0) # orange elif color_index == 2: needleColor = QtGui.QColor(255, 255, 0) # yellow elif color_index == 3: needleColor = QtGui.QColor(0, 255, 0) # green elif color_index == 4: needleColor = QtGui.QColor(0, 255, 255) # light blue elif color_index == 5: needleColor = QtGui.QColor(0, 0, 255) # blue elif color_index == 6: needleColor = QtGui.QColor(255, 0, 255) # light purple elif color_index == 7: needleColor = QtGui.QColor(150, 0, 255) # purple elif color_index == 8: needleColor = QtGui.QColor(150, 100, 0) # brown else: needleColor = QtGui.QColor(0, 0, 0) # black dial.setNeedle( Qwt.QwtDialSimpleNeedle( Qwt.QwtDialSimpleNeedle.Arrow, True, needleColor, QtGui.QColor(QtCore.Qt.gray).light(130))) dial.setValue(0) # Set sizing dial.setMinimumSize(250, 250) dial.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding) self.dial_list.append(dial) self.next_angles.append(0) # Add to overall layout for i in self.dial_list: self.compass_layout.addWidget(i, 0, 0) # Add label self.label = Qt.QLabel(label) font = QtGui.QFont() font.setPointSize(14) font.setBold(True) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignCenter) self.this_layout.addWidget(self.label) self.this_layout.addLayout(self.compass_layout) self.label.raise_() # connect the plot callback signal QtCore.QObject.connect(self, QtCore.SIGNAL("updatePlot(int)"), self.do_plot)