def __init__(self, parent): QWidget.__init__(self, parent) self.freqMin = 87.5 self.freqMax = 108 self.d_sliderFrequency = Qwt.QwtSlider(self) self.d_sliderFrequency.setOrientation(Qt.Horizontal) self.d_sliderFrequency.setScalePosition(Qwt.QwtSlider.TrailingScale) self.d_sliderFrequency.setScale(self.freqMin, self.freqMax) #self.d_sliderFrequency.setTotalSteps( math.round( ( self.freqMax - self.freqMin ) / 0.01 ) ) FIXME self.d_sliderFrequency.setTotalSteps( int(math.ceil((self.freqMax - self.freqMin) / 0.01))) self.d_sliderFrequency.setSingleSteps(1) self.d_sliderFrequency.setPageSteps(10) self.d_sliderFrequency.setScaleMaxMinor(5) self.d_sliderFrequency.setScaleMaxMajor(12) self.d_sliderFrequency.setHandleSize(QSize(80, 20)) self.d_sliderFrequency.setBorderWidth(1) self.d_thermoTune = TuningThermo(self) self.d_wheelFrequency = Qwt.QwtWheel(self) self.d_wheelFrequency.setMass(0.5) self.d_wheelFrequency.setRange(87.5, 108) self.d_wheelFrequency.setSingleStep(0.01) self.d_wheelFrequency.setPageStepCount(10) self.d_wheelFrequency.setTotalAngle(3600.0) self.d_wheelFrequency.setFixedHeight(30) self.d_wheelFrequency.valueChanged['double'].connect(self.adjustFreq) self.d_sliderFrequency.valueChanged['double'].connect(self.adjustFreq) self.mainLayout = QVBoxLayout(self) #self.mainLayout.setMargin( 10 ) self.mainLayout.setSpacing(5) self.mainLayout.addWidget(self.d_sliderFrequency) self.hLayout = QHBoxLayout() #self.hLayout.setMargin( 0 ) #self.hLayout.addWidget( self.d_thermoTune, 0 ) self.hLayout.addStretch(5) self.hLayout.addWidget(self.d_wheelFrequency, 2) self.mainLayout.addLayout(self.hLayout)
def createBox(self, orientation, typ): self.d_wheel = Qwt.QwtWheel() self.d_wheel.setValue(80) self.d_wheel.setWheelWidth(20) self.d_wheel.setMass(1.0) self.d_thermo = Qwt.QwtThermo() self.d_thermo.setOrientation(orientation) if (orientation == Qt.Horizontal): self.d_thermo.setScalePosition(Qwt.QwtThermo.LeadingScale) self.d_wheel.setOrientation(Qt.Vertical) else: self.d_thermo.setScalePosition(Qwt.QwtThermo.TrailingScale) self.d_wheel.setOrientation(Qt.Horizontal) if typ == 0: colorMap = Qwt.QwtLinearColorMap() colorMap.setColorInterval(Qt.blue, Qt.red) self.d_thermo.setColorMap(colorMap) elif typ == 1: colorMap = Qwt.QwtLinearColorMap() colorMap.setMode(Qwt.QwtLinearColorMap.FixedColors) idx = 4 colorMap.setColorInterval(Qt.GlobalColor(idx), Qt.GlobalColor(idx + 10)) for i in range(10): colorMap.addColorStop(i / 10.0, Qt.GlobalColor(idx + i)) self.d_thermo.setColorMap(colorMap) elif typ == 2: self.d_wheel.setRange(10, 1000) self.d_wheel.setSingleStep(1.0) #self.d_thermo.setScaleEngine( Qwt.QwtLogScaleEngine ) self.d_thermo.setScaleMaxMinor(10) self.d_thermo.setFillBrush(Qt.darkCyan) self.d_thermo.setAlarmBrush(Qt.magenta) self.d_thermo.setAlarmLevel(500.0) self.d_wheel.setValue(800) elif typ == 3: self.d_wheel.setRange(-1000, 1000) self.d_wheel.setSingleStep(1.0) #self.d_wheel.setPalette( QColor( "Tan" ) ) #scaleEngine = Qwt.QwtLinearScaleEngine() #scaleEngine.setTransformation( Qwt.QwtPowerTransform( 2 ) ) self.d_thermo.setScaleMaxMinor(5) #self.d_thermo.setScaleEngine( scaleEngine ) pal = QPalette() pal.setColor(QPalette.Base, Qt.darkGray) #pal.setColor( QPalette.ButtonText, QColor( "darkKhaki" ) ) self.d_thermo.setPalette(pal) elif typ == 4: self.d_wheel.setRange(-100, 300) self.d_wheel.setInverted(True) colorMap = Qwt.QwtLinearColorMap() colorMap.setColorInterval(Qt.darkCyan, Qt.yellow) self.d_thermo.setColorMap(colorMap) self.d_wheel.setValue(243) elif typ == 5: self.d_thermo.setFillBrush(Qt.darkCyan) self.d_thermo.setAlarmBrush(Qt.magenta) self.d_thermo.setAlarmLevel(60.0) elif typ == 6: self.d_thermo.setOriginMode(Qwt.QwtThermo.OriginMinimum) #self.d_thermo.setFillBrush( QBrush( "DarkSlateBlue" ) ) #self.d_thermo.setAlarmBrush( QBrush( "DarkOrange" ) ) self.d_thermo.setAlarmLevel(60.0) elif typ == 7: self.d_wheel.setRange(-100, 100) self.d_thermo.setOriginMode(Qwt.QwtThermo.OriginCustom) self.d_thermo.setOrigin(0.0) self.d_thermo.setFillBrush(Qt.darkBlue) dmin = self.d_wheel.minimum() dmax = self.d_wheel.maximum() #if ( self.d_wheel.isInverted() ): # tmp = dmin # dmin = dmax # dmax = tmp # #swap( dmin, dmax ) self.d_thermo.setScale(dmin, dmax) self.d_thermo.setValue(self.d_wheel.value()) self.d_wheel.valueChanged['double'].connect(self.d_thermo.setValue) box = QWidget() layout = None if (orientation == Qt.Horizontal): layout = QHBoxLayout(box) else: layout = QVBoxLayout(box) layout.addWidget(self.d_thermo, Qt.AlignCenter) layout.addWidget(self.d_wheel) return box