예제 #1
0
    def __init__(self, parent=None):
        Qwt.QwtPlot.__init__(self, parent)
        self.canvas().setStyleSheet(
            "border: 2px solid Black;"
            "border-radius: 15px;"
            "background-color: qlineargradient( x1: 0, y1: 0, x2: 0, y2: 1,"
            "stop: 0 LemonChiffon, stop: 1 PaleGoldenrod );")

        # attach curve
        self.d_curve = Qwt.QwtPlotCurve("Scattered Points")
        self.d_curve.setPen(QColor("Purple"))

        # when using QwtPlotCurve.ImageBuffer simple dots can be
        # rendered in parallel on multicore systems.
        self.d_curve.setRenderThreadCount(
            0)  # 0: use QThread.idealThreadCount()
        self.d_curve.attach(self)
        self.setSymbol(None)
        # panning with the left mouse button
        Qwt.QwtPlotPanner(self.canvas())

        # distanve measurement with the right mouse button
        self.picker = DistancePicker(self.canvas())
        self.picker.setMousePattern(Qwt.QwtPlotPicker.MouseSelect1,
                                    Qt.RightButton)
        self.picker.setRubberBandPen(QPen(Qt.blue))
        # zoom in/out with the wheel
        self.magnifier = Qwt.QwtPlotMagnifier(self.canvas())
        self.magnifier.setMouseButton(Qt.NoButton)
    def update(self, layer, style):
        """Update plot for given Safecast layer.

        :param layer: Safecast layer
        """
        # collect plot coordinates
        x, y = layer.plotData()

        # clear plot first & detach curve
        if hasQwt6:
            items = Qwt.QwtPlotItem.Rtti_PlotItem
        else:
            items = [Qwt.QwtPlotItem.Rtti_PlotItem]
        self.detachItems(items, True)

        # attach a curve
        self.curve = Qwt.QwtPlotCurve('ader_microSvh')
        self.curve.attach(self)

        if style == 0:  # lines
            self.curve.setPen(Qt.QPen(Qt.Qt.blue, 0))
        else:  # points
            self.curve.setStyle(Qwt.QwtPlotCurve.NoCurve)
            self.curve.setSymbol(
                Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.blue),
                              Qt.QPen(Qt.Qt.blue), Qt.QSize(5, 5)))

        self.curve.setSamples(x, y)

        self.replot()
예제 #3
0
    def __init__(self):
        super().__init__()
        self.setAutoFillBackground(True)
        self.setPalette(QPalette(QColor(165, 193, 228)))
        self.updateGradient()
        self.setTitle("A Simple QwtPlot Demonstration")
        self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend)

        #axes
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "x -->")
        self.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 10.0)

        self.setAxisTitle(Qwt.QwtPlot.yLeft, "y -->")
        self.setAxisScale(Qwt.QwtPlot.yLeft, -1.0, 1.0)
        # canvas
        self.canvas = Qwt.QwtPlotCanvas()
        self.canvas.setLineWidth(1)
        self.canvas.setFrameStyle(QFrame.Box | QFrame.Plain)
        self.canvas.setBorderRadius(15)

        self.canvasPalette = QPalette(Qt.white)
        self.canvasPalette.setColor(QPalette.Foreground, QColor(133, 190, 232))
        self.canvas.setPalette(self.canvasPalette)

        self.setCanvas(self.canvas)

        #panning with the left mouse button
        self.panner = Qwt.QwtPlotPanner(self.canvas)

        #zoom in/out with the wheel
        self.magnifier = Qwt.QwtPlotMagnifier(self.canvas)
        self.magnifier.setMouseButton(Qt.NoButton)

        self.populate()
예제 #4
0
    def __init__(self, parent=None):
        Qwt.QwtPlot.__init__(self, parent)
        self.setTitle("Watching TV during a weekend")
        canvas = Qwt.QwtPlotCanvas()
        canvas.setPalette(QPalette(Qt.gray))
        canvas.setBorderRadius(10)
        self.setCanvas(canvas)

        self.plotLayout().setAlignCanvasToScales(True)

        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Number of People")
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Number of Hours")

        legend = Qwt.QwtLegend()
        legend.setDefaultItemMode(Qwt.QwtLegendData.Checkable)
        self.insertLegend(legend, Qwt.QwtPlot.RightLegend)
        self.populate()

        #connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ), SLOT( showItem( const QVariant &, bool ) ) );
        legend.checked['QVariant', 'bool', 'int'].connect(self.showItem)

        self.replot()  # creating the legend items
        self.items = self.itemList(Qwt.QwtPlotItem.Rtti_PlotHistogram)
        for i in range(len(self.items)):
            if (i == 0):
                #const QVariant
                itemInfo = self.itemToInfo(self.items[i])
                #QwtLegendLabel *
                legendLabel = legend.legendWidget(itemInfo)
                if (legendLabel):
                    legendLabel.setChecked(True)
                self.items[i].setVisible(True)
            else:
                self.items[i].setVisible(False)
        self.setAutoReplot(True)
예제 #5
0
    def __init__(self, parent):
        Qwt.QwtPlot.__init__(self, parent)
        self.setAutoFillBackground(True)
        self.setPalette(QPalette(Qt.white))
        self.canvas().setPalette(QPalette(colours["LemonChiffon"]))

        self.setTitle("Bar Chart")

        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Whatever")
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Whatever")

        self.d_barChartItem = Qwt.QwtPlotMultiBarChart("Bar Chart")
        self.d_barChartItem.setLayoutPolicy(
            Qwt.QwtPlotMultiBarChart.AutoAdjustSamples)
        self.d_barChartItem.setSpacing(20)
        self.d_barChartItem.setMargin(3)

        self.d_barChartItem.attach(self)

        self.insertLegend(Qwt.QwtLegend())

        self.populate()
        self.setOrientation(0)

        self.setAutoReplot(True)
예제 #6
0
    def populate(self):
        colors = [colours["DarkOrchid"], colours["SteelBlue"], colours["Gold"]]

        numSamples = 5
        numBars = len(colors)

        titles = []
        for i in range(numBars):
            titles.append(Qwt.QwtText("Bar %d" % i))

        self.d_barChartItem.setBarTitles(titles)
        self.d_barChartItem.setLegendIconSize(QSize(10, 14))

        for i in range(numBars):
            symbol = Qwt.QwtColumnSymbol(Qwt.QwtColumnSymbol.Box)
            symbol.setLineWidth(2)
            symbol.setFrameStyle(Qwt.QwtColumnSymbol.Raised)
            symbol.setPalette(QPalette(colors[i]))
            self.d_barChartItem.setSymbol(i, symbol)

        self.series = []
        for i in range(numSamples):
            values = []
            for j in range(numBars):
                values.append(2.0 + random.randint(0, 8) % 8)
            self.series.append(values)
        print(self.series)
        self.d_barChartItem.setSamples(self.series)
예제 #7
0
 def setValues(self, values):
     numValues = len(values)
     #QVector<QwtIntervalSample> samples( numValues )
     samples = []
     for i in range(numValues):
         interval = Qwt.QwtInterval(i, i + 1.0)
         interval.setBorderFlags(Qwt.QwtInterval.ExcludeMaximum)
         samples.append(Qwt.QwtIntervalSample(values[i], interval))
     self.setSamples(samples)
예제 #8
0
 def createKnob(self, knobType):
     knob = Qwt.QwtKnob()
     knob.setTracking(True)
     if knobType == 0:
         knob.setKnobStyle(Qwt.QwtKnob.Sunken)
         knob.setMarkerStyle(Qwt.QwtKnob.Nub)
         knob.setWrapping(True)
         knob.setNumTurns(4)
         knob.setScaleStepSize(10.0)
         knob.setScale(0, 400)
         knob.setTotalSteps(400)
     elif knobType == 1:
         knob.setKnobStyle(Qwt.QwtKnob.Sunken)
         knob.setMarkerStyle(Qwt.QwtKnob.Dot)
     elif knobType == 2:
         knob.setKnobStyle(Qwt.QwtKnob.Sunken)
         knob.setMarkerStyle(Qwt.QwtKnob.Tick)
         #QwtLinearScaleEngine *scaleEngine = new QwtLinearScaleEngine( 2 )
         #scaleEngine.setTransformation( new QwtPowerTransform( 2 ) )
         #knob.setScaleEngine( scaleEngine )
         """QList< double > ticks[ QwtScaleDiv.NTickTypes ]
         ticks[ QwtScaleDiv.MajorTick ] << 0 << 4 
             << 16 << 32 << 64 << 96 << 128
         ticks[ QwtScaleDiv.MediumTick ] << 24 << 48 << 80 << 112
         ticks[ QwtScaleDiv.MinorTick ] 
             << 0.5 << 1 << 2 
             << 7 << 10 << 13
             << 20 << 28 
             << 40 << 56 
             << 72 << 88 
             << 104 << 120 
         knob.setScale( QwtScaleDiv( 0, 128, ticks ) )"""
         knob.setTotalSteps(100)
         knob.setStepAlignment(False)
         knob.setSingleSteps(1)
         knob.setPageSteps(5)
     elif knobType == 3:
         knob.setKnobStyle(Qwt.QwtKnob.Flat)
         knob.setMarkerStyle(Qwt.QwtKnob.Notch)
         knob.setScaleEngine(Qwt.QwtLogScaleEngine())
         knob.setScaleStepSize(1.0)
         knob.setScale(0.1, 1000.0)
         knob.setScaleMaxMinor(10)
     elif knobType == 4:
         knob.setKnobStyle(Qwt.QwtKnob.Raised)
         knob.setMarkerStyle(Qwt.QwtKnob.Dot)
         knob.setWrapping(True)
     elif knobType == 5:
         knob.setKnobStyle(Qwt.QwtKnob.Styled)
         knob.setMarkerStyle(Qwt.QwtKnob.Triangle)
         knob.setTotalAngle(180.0)
         knob.setScale(100, -100)
     return knob
예제 #9
0
파일: __init__.py 프로젝트: wolfc01/procexp
    def __init__(self, name, penWidth, lineColor, fillColor, plot):
        self.__curve__ = Qwt.QwtPlotCurve(name)
        pen = QtGui.QPen(lineColor)
        pen.setWidth(penWidth)
        self.__curve__.setPen(pen)
        self.__curve__.setBrush(fillColor)
        self.__curve__.attach(plot)

        #work around to get nicer plotting.
        self.__curveExt__ = Qwt.QwtPlotCurve(name + " extra")
        self.__curveExt__.setPen(QtGui.QPen(lineColor))
        self.__curveExt__.attach(plot)
예제 #10
0
 def drawScale(self, painter, center, radius):
     offset = 4.0
     p0 = self.qwtPolar2Pos(center, offset, 1.5 * M_PI)
     w = self.innerRect().width()
     path = QPainterPath()
     path.moveTo(Qwt.qwtPolar2Pos(p0, w, 0.0))
     path.lineTo(Qwt.qwtPolar2Pos(path.currentPosition(), 2 * w, M_PI))
     path.lineTo(Qwt.qwtPolar2Pos(path.currentPosition(), w, 0.5 * M_PI))
     path.lineTo(Qwt.qwtPolar2Pos(path.currentPosition(), w, 0.0))
     painter.save()
     painter.setClipPath(path)  # swallow 180 - 360 degrees
     Qwt.QwtDial.drawScale(painter, center, radius)
     painter.restore()
예제 #11
0
파일: plotqwt.py 프로젝트: rizzoa/PyQt-Qwt
    def __updateCurve(self):
        curveData = self.__d_curve.data() 
        curveData.values().lock()

        numPoints = curveData.size()
        if ( numPoints > self.__d_paintedPoints ):
            doClip = not self.canvas().testAttribute( Qt.WA_PaintOnScreen )
            if ( doClip ):
        
            
            #    Depending on the platform setting a clip might be an important
            #    performance issue. F.e. for Qt Embedded this reduces the
            #    part of the backing store that has to be copied out - maybe
            #    to an unaccelerated frame buffer device.
            

                xMap = self.canvasMap( self.__d_curve.xAxis() )
                yMap = self.canvasMap( self.__d_curve.yAxis() )

                br = Qwt.qwtBoundingRect( curveData,
                    self.__d_paintedPoints - 1, numPoints - 1 )

                clipRect = Qwt.QwtScaleMap.transform( xMap, yMap, br ).toRect()
                self.__d_directPainter.setClipRegion( QRegion(clipRect) )
        

            self.__d_directPainter.drawSeries( self.__d_curve,
                self.__d_paintedPoints - 1, numPoints - 1 )
            self.__d_paintedPoints = numPoints
    

        curveData.values().unlock()
예제 #12
0
파일: plotqwt.py 프로젝트: rizzoa/PyQt-Qwt
    def __incrementInterval(self):
        self.__d_interval = Qwt.QwtInterval( self.__d_interval.maxValue(),
            self.__d_interval.maxValue() + self.__d_interval.width() )

        curveData = self.__d_curve.data() 
        curveData.values().clearStaleValues( self.__d_interval.minValue() )

        #To avoid, that the grid is jumping, we disable
        #the autocalculation of the ticks and shift them
        #manually instead.

        scaleDiv = self.axisScaleDiv( Qwt.QwtPlot.xBottom )
        scaleDiv.setInterval( self.__d_interval )

        for i in range( 0, Qwt.QwtScaleDiv.NTickTypes):
    
            ticks = scaleDiv.ticks( i )
            for j in range(0 , len(ticks)):
                ticks[j] += self.__d_interval.width()
            scaleDiv.setTicks( i, ticks )
    
        self.setAxisScaleDiv( Qwt.QwtPlot.xBottom, scaleDiv )

        self.__d_origin.setValue( self.__d_interval.minValue() + self.__d_interval.width() / 2.0, 0.0 )

        self.__d_paintedPoints = 0
        self.replot()
예제 #13
0
 def showPeak(self, freq, amplitude):
     label = "Peak: %.3g dB" % amplitude
     text = Qwt.QwtText(label)
     text.setFont(QFont("Helvetica", 10, QFont.Bold))
     text.setColor(QColor(200, 150, 0))
     self.d_marker2.setValue(freq, amplitude)
     self.d_marker2.setLabel(text)
예제 #14
0
 def show3dB(self, freq):
     label = "-3 dB at f = %.3g" % freq
     text = Qwt.QwtText(label)
     text.setFont(QFont("Helvetica", 10, QFont.Bold))
     text.setColor(Qt.green)
     self.d_marker1.setValue(freq, 0.0)
     self.d_marker1.setLabel(text)
예제 #15
0
파일: mainwin.py 프로젝트: rizzoa/PyQt-Qwt
    def __init__(self, title, min, max, parent):
        super().__init__(parent)
        QWidget = parent
        font = QFont("Helvetica", 10)

        self.__d_knob = Qwt.QwtKnob(self)
        self.__d_knob.setFont(font)

        scaleDiv = self.__d_knob.scaleEngine().divideScale(min, max, 5, 3)

        ticks = scaleDiv.ticks(Qwt.QwtScaleDiv.MajorTick)
        if (len(ticks) > 0 and ticks[0] > min):
            if (ticks[0] > min):
                ticks.insert(0, min)
            if (ticks[-1] < max):
                ticks.append(max)

        scaleDiv.setTicks(Qwt.QwtScaleDiv.MajorTick, ticks)
        self.__d_knob.setScale(scaleDiv)

        self.__d_knob.setKnobWidth(50)

        font.setBold(True)
        self.__d_label = QLabel(title, self)
        self.__d_label.setFont(font)
        self.__d_label.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.setSizePolicy(QSizePolicy.MinimumExpanding,
                           QSizePolicy.MinimumExpanding)

        self.__d_knob.valueChanged.connect(self.valueChanged)
    def __init__(self, *args):
        Qwt.QwtPlot.__init__(self, *args)

        # create a plot with a white canvas
        self.setCanvasBackground(Qt.Qt.white)

        # set plot layout
        self.plotLayout().setCanvasMargin(0)
        self.plotLayout().setAlignCanvasToScales(True)
        # attach a grid
        grid = Qwt.QwtPlotGrid()
        grid.attach(self)
        grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine))

        # attach a x-axis
        xaxis = SafecastAxis(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft)
        xaxis.attach(self)
        self.setAxisTitle(Qwt.QwtPlot.xBottom, self.tr("Distance (km)"))

        # attach a y-axis
        yaxis = SafecastAxis(Qwt.QwtPlot.yLeft, Qwt.QwtPlot.xBottom)
        yaxis.attach(self)
        self.setAxisTitle(Qwt.QwtPlot.yLeft, self.tr("ADER (microSv/h)"))

        # curve
        self.curve = None
예제 #17
0
    def createDial(self, pos):
        dial = None
        if pos == 0:
            self.d_clock = Qwt.QwtAnalogClock()
            # disable minor ticks
            #d_clock.scaleDraw().setTickLength( QwtScaleDiv.MinorTick, 0 )
            knobColor = QColor(Qt.gray)  # .light( 130 )

            for i in range(Qwt.QwtAnalogClock.NHands):
                handColor = QColor(Qt.gray)  #.light( 150 )
                width = 8
                if i == Qwt.QwtAnalogClock.SecondHand:
                    handColor = Qt.gray
                    width = 5
                hand = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow,
                                               True, handColor, knobColor)
                hand.setWidth(width)
                self.d_clock.setHand(Qwt.QwtAnalogClock.Hand(i), hand)
            timer = QTimer(self.d_clock)
            timer.timeout.connect(self.d_clock.setCurrentTime)
            timer.start(1000)
            dial = self.d_clock
        elif pos == 1:
            self.d_speedo = SpeedoMeter(self)
            self.d_speedo.setScaleStepSize(20.0)
            self.d_speedo.setScale(0.0, 240.0)
            self.d_speedo.scaleDraw().setPenWidth(2)
            timer = QTimer(self.d_speedo)
            timer.timeout.connect(self.changeSpeed)
            timer.start(50)
            dial = self.d_speedo
        elif pos == 2:
            self.d_ai = AttitudeIndicator(self)
            self.d_ai.scaleDraw().setPenWidth(3)
            gradientTimer = QTimer(self.d_ai)
            gradientTimer.timeout.connect(self.changeGradient)
            gradientTimer.start(100)
            angleTimer = QTimer(self.d_ai)
            angleTimer.timeout.connect(self.changeAngle)
            angleTimer.start(100)
            dial = self.d_ai

        if (dial):
            dial.setReadOnly(True)
            dial.setLineWidth(4)
            dial.setFrameShadow(Qwt.QwtDial.Sunken)
        return dial
예제 #18
0
 def __init__(self):
     QFrame.__init__(self)
     self.d_curves = [None] * CurvCnt
     xMap.setScaleInterval(-0.5, 10.5)
     yMap.setScaleInterval(-1.1, 1.1)
     # Frame style FIXME This doesn't seem to work properly
     self.setFrameStyle(QFrame.Box | QFrame.Raised)
     self.setLineWidth(2)
     self.setMidLineWidth(3)
     # Calculate values
     for i in range(Size):
         xval[i] = i * 10.0 / (Size - 1.0)
         yval[i] = math.sin(xval[i]) * math.cos(2.0 * xval[i])
     #  define curve styles
     i = 0
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.Cross, QBrush(Qt.NoBrush),
                       QPen(Qt.black), QSize(5, 5)))
     self.d_curves[i].setPen(Qt.darkGreen)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     self.d_curves[i].setCurveAttribute(Qwt.QwtPlotCurve.Fitted)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.yellow, QPen(Qt.blue),
                       QSize(5, 5)))
     self.d_curves[i].setPen(Qt.red)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Sticks)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkBlue)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkBlue)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Lines)
     self.d_curves[i].setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setPen(Qt.darkCyan)
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.Steps)
     i += 1
     self.d_curves[i] = Qwt.QwtPlotCurve()
     self.d_curves[i].setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, QBrush(Qt.NoBrush),
                       QPen(Qt.darkMagenta), QSize(5, 5)))
     self.d_curves[i].setStyle(Qwt.QwtPlotCurve.NoCurve)
     # attach data
     for i in range(CurvCnt):
         self.d_curves[i].setSamples(xval, yval)
예제 #19
0
    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)
예제 #20
0
    def populate(self):
        #Insert new curves
        self.cSin = Qwt.QwtPlotCurve("y = sin(x)")
        self.cSin.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        self.cSin.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine, True)
        self.cSin.setPen(Qt.red)
        self.cSin.attach(self)

        self.cCos = Qwt.QwtPlotCurve("y = cos(x)")
        self.cCos.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        self.cCos.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine, True)
        self.cCos.setPen(Qt.blue)
        self.cCos.attach(self)

        #Create sin and cos data
        self.s = FunctionData(sin)
        self.cSin.setData(self.s)
        self.c = FunctionData(cos)
        self.cCos.setData(self.c)

        #Insert markers

        #  ...a horizontal line at y = 0...
        self.mY = Qwt.QwtPlotMarker()
        self.mY.setLabel(Qwt.QwtText("y = 0"))
        self.mY.setLabelAlignment(Qt.AlignRight | Qt.AlignTop)
        self.mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
        self.mY.setYValue(0.0)
        self.mY.attach(self)

        #  ...a vertical line at x = 2 * pi
        self.mX = Qwt.QwtPlotMarker()
        self.mX.setLabel(Qwt.QwtText("x = 2 pi"))
        self.mX.setLabelAlignment(Qt.AlignLeft | Qt.AlignBottom)
        self.mX.setLabelOrientation(Qt.Vertical)
        self.mX.setLineStyle(Qwt.QwtPlotMarker.VLine)
        self.mX.setLinePen(Qt.black, 0, Qt.DashDotLine)
        self.mX.setXValue(2.0 * pi)
        self.mX.attach(self)

        x = 7.7

        # an arrow at a specific position
        self.mPos = Qwt.QwtPlotMarker("Marker")
        self.mPos.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased, True)
        self.mPos.setItemAttribute(Qwt.QwtPlotItem.Legend, True)
        self.arr = ArrowSymbol()
        self.mPos.setSymbol(self.arr)
        self.mPos.setValue(QPointF(x, sin(x)))
        self.mPos.setLabel(Qwt.QwtText("x = %.1f" % x))
        self.mPos.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        self.mPos.attach(self)
예제 #21
0
    def __init__(self, parent=None):
        Qwt.QwtDial.__init__(self, parent)
        self.d_label = "km/h"
        scaleDraw = Qwt.QwtRoundScaleDraw()
        scaleDraw.setSpacing(8)
        scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False)
        scaleDraw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0)
        scaleDraw.setTickLength(Qwt.QwtScaleDiv.MediumTick, 4)
        scaleDraw.setTickLength(Qwt.QwtScaleDiv.MajorTick, 8)
        self.setScaleDraw(scaleDraw)

        self.setWrapping(False)
        self.setReadOnly(True)

        self.setOrigin(135.0)
        self.setScaleArc(0.0, 270.0)

        needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True,
                                         Qt.red,
                                         QColor(Qt.gray))  #.light( 130 ) )
        self.setNeedle(needle)
예제 #22
0
    def __init__(self, orientation, text, parent, value=0.0):
        QWidget.__init__(self, parent)
        self.d_label = QLabel(text, self)
        self.d_label.setFont(QFont("Helvetica", 10))

        self.d_thermo = Qwt.QwtThermo(self)
        self.d_thermo.setOrientation(orientation)
        self.d_thermo.setScale(0.0, 100.0)
        self.d_thermo.setValue(value)
        self.d_thermo.setFont(QFont("Helvetica", 8))
        self.d_thermo.setPipeWidth(6)
        self.d_thermo.setScaleMaxMajor(6)
        self.d_thermo.setScaleMaxMinor(5)
        self.d_thermo.setFillBrush(Qt.darkMagenta)

        #if 0
        colorMap = Qwt.QwtLinearColorMap(Qt.blue, Qt.red)

        colorMap.addColorStop(0.2, Qt.yellow)
        colorMap.addColorStop(0.3, Qt.cyan)
        colorMap.addColorStop(0.4, Qt.green)
        colorMap.addColorStop(0.5, Qt.magenta)
        colorMap.setMode(Qwt.QwtLinearColorMap.FixedColors)
        self.d_thermo.setColorMap(colorMap)
        #endif"""

        self.layout = QVBoxLayout(self)
        #self.layout.setCanvasMargin( 0 )
        self.layout.setSpacing(0)

        if (orientation == Qt.Horizontal):
            self.d_label.setAlignment(Qt.AlignCenter)
            self.d_thermo.setScalePosition(Qwt.QwtThermo.LeadingScale)
            self.layout.addWidget(self.d_label)
            self.layout.addWidget(self.d_thermo)
        else:
            self.d_label.setAlignment(Qt.AlignRight)
            self.d_thermo.setScalePosition(Qwt.QwtThermo.TrailingScale)
            self.layout.addWidget(self.d_thermo, 10, Qt.AlignHCenter)
            self.layout.addWidget(self.d_label, 0)
 def __init__(self, masterAxis, slaveAxis):
     """Valid input values for masterAxis and slaveAxis are QwtPlot.yLeft,
     QwtPlot.yRight, QwtPlot.xBottom, and QwtPlot.xTop. When masterAxis is
     an x-axis, slaveAxis must be an y-axis; and vice versa.
     """
     Qwt.QwtPlotItem.__init__(self)
     self.__axis = masterAxis
     if masterAxis in (Qwt.QwtPlot.yLeft, Qwt.QwtPlot.yRight):
         self.setAxes(slaveAxis, masterAxis)
     else:
         self.setAxes(masterAxis, slaveAxis)
     self.scaleDraw = Qwt.QwtScaleDraw()
     self.scaleDraw.setAlignment(
         (Qwt.QwtScaleDraw.LeftScale, Qwt.QwtScaleDraw.RightScale,
          Qwt.QwtScaleDraw.BottomScale,
          Qwt.QwtScaleDraw.TopScale)[masterAxis])
예제 #24
0
    def __init__(self, parent):
        QWidget.__init__(self, parent)
        self.d_thermo = Qwt.QwtThermo(self)
        self.d_thermo.setOrientation(Qt.Horizontal)
        self.d_thermo.setScalePosition(Qwt.QwtThermo.NoScale)
        self.d_thermo.setScale(0.0, 1.0)
        self.d_thermo.setFillBrush(Qt.green)

        self.label = QLabel("Tuning", self)
        self.label.setAlignment(Qt.AlignCenter)

        self.layout = QVBoxLayout(self)
        #self.layout.setMargin( 0 ) FIXME
        self.layout.addWidget(self.d_thermo)
        self.layout.addWidget(self.label)

        self.setFixedWidth(3 * self.label.sizeHint().width())
예제 #25
0
    def populate(self):
        grid = Qwt.QwtPlotGrid()
        grid.enableX(False)
        grid.enableY(True)
        grid.enableXMin(False)
        grid.enableYMin(False)
        grid.setMajorPen(Qt.black, 0, Qt.DotLine)
        grid.attach(self)
        juneValues = [7.0, 19.0, 24.0, 32.0, 10.0, 5.0, 3.0]
        novemberValues = [4.0, 15.0, 22.0, 34.0, 13.0, 8.0, 4.0]

        histogramJune = Histogram("Summer", Qt.red)
        histogramJune.setValues(juneValues)
        histogramJune.attach(self)

        histogramNovember = Histogram("Winter", Qt.blue)
        histogramNovember.setValues(novemberValues)
        histogramNovember.attach(self)
예제 #26
0
    def __init__(self, title, parent):
        QWidget.__init__(self, parent)
        self.d_thermo = Qwt.QwtThermo(self)
        self.d_thermo.setPipeWidth(6)
        self.d_thermo.setScale(-40, 10)
        self.d_thermo.setFillBrush(Qt.green)
        self.d_thermo.setAlarmBrush(Qt.red)
        self.d_thermo.setAlarmLevel(0.0)
        self.d_thermo.setAlarmEnabled(True)

        label = QLabel(title, self)
        label.setAlignment(Qt.AlignTop | Qt.AlignLeft)

        self.layout = QVBoxLayout(self)
        #self.layout.setMargin( 0 )
        self.layout.setSpacing(0)
        self.layout.addWidget(self.d_thermo, 10)
        self.layout.addWidget(label)
예제 #27
0
파일: __init__.py 프로젝트: wolfc01/procexp
 def __init__(self, qwtPlot, scale=None, hasGrid=True):
     self.__plot__ = qwtPlot
     if hasGrid:
         self.__curveCpuPlotGrid = Qwt.QwtPlotGrid()
         self.__curveCpuPlotGrid.setMajorPen(
             QtGui.QPen(QtGui.QColor(0, 100, 0), 0, QtCore.Qt.SolidLine))
         self.__curveCpuPlotGrid.setMinorPen(
             QtGui.QPen(QtGui.QColor(0, 100, 0), 0, QtCore.Qt.SolidLine))
         self.__curveCpuPlotGrid.enableXMin(True)
         self.__curveCpuPlotGrid.attach(self.__plot__)
     self.__plot__.setCanvasBackground(QtGui.QColor(0, 0, 0))
     self.__plot__.enableAxis(0, False)
     self.__plot__.enableAxis(2, False)
     if scale is None:
         #self.__plot__.setAxisScale(0,0,100,20)
         pass
     else:
         self.__plot__.setAxisScale(0, scale.min, scale.max,
                                    (scale.max - scale.min) / 10.0)
예제 #28
0
    def __init__(self, parent=None):
        Qwt.QwtDial.__init__(self, parent)
        self.d_gradient = 0.0
        scaleDraw = Qwt.QwtRoundScaleDraw()
        scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False)
        scaleDraw.enableComponent(Qwt.QwtAbstractScaleDraw.Labels, False)
        self.setScaleDraw(scaleDraw)

        #self.setMode( Qwt.RotateScale )
        self.setWrapping(True)

        self.setOrigin(270.0)

        self.setScaleMaxMinor(0)
        self.setScaleStepSize(30.0)
        self.setScale(0.0, 360.0)

        color = self.palette().color(QPalette.Text)
        self.setNeedle(AttitudeIndicatorNeedle(color))
예제 #29
0
    def mprint(self):
        printer = QPrinter(QPrinter.HighResolution)
        docName = "Humm"  #self.d_plot.title().text()
        #if ( not docName.isEmpty() ):
        #docName.replace ( QRegExp ( QString.fromLatin1 ( "\n" ) ), tr ( " -- " ) )
        printer.setDocName(docName)

        printer.setCreator("Bode example")
        printer.setOrientation(QPrinter.Landscape)

        dialog = QPrintDialog(printer)
        if (dialog.exec_()):
            renderer = Qwt.QwtPlotRenderer()
            if (printer.colorMode() == QPrinter.GrayScale):
                renderer.setDiscardFlag(Qwt.QwtPlotRenderer.DiscardBackground)
                renderer.setDiscardFlag(
                    Qwt.QwtPlotRenderer.DiscardCanvasBackground)
                renderer.setDiscardFlag(Qwt.QwtPlotRenderer.DiscardCanvasFrame)
                renderer.setLayoutFlag(Qwt.QwtPlotRenderer.FrameWithScales)
            renderer.renderTo(self.d_plot, printer)
예제 #30
0
 def setMode(self, mode):
     #QwtPlotItemList
     #print("Set mode %d"%mode)
     items = self.itemList(Qwt.QwtPlotItem.Rtti_PlotHistogram)
     for i in range(len(items)):
         histogram = items[i]
         if (mode < 3):
             histogram.setStyle(mode)
             histogram.setSymbol(None)
             pen = QPen(Qt.black, 0)
             if (mode == Qwt.QwtPlotHistogram.Lines):
                 pen.setBrush(histogram.brush())
             histogram.setPen(pen)
         else:
             histogram.setStyle(Qwt.QwtPlotHistogram.Columns)
             symbol = Qwt.QwtColumnSymbol(Qwt.QwtColumnSymbol.Box)
             symbol.setFrameStyle(Qwt.QwtColumnSymbol.Raised)
             symbol.setLineWidth(2)
             symbol.setPalette(QPalette(histogram.brush().color()))
             histogram.setSymbol(symbol)