Beispiel #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())
        # zoom in/out with the wheel
        #magnifier = Qwt.QwtPlotMagnifier( self.canvas() ) FIXME
        #magnifier.setMouseButton( Qt.NoButton )
        # 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))
Beispiel #2
0
    def __init__(self, parent):
        Qwt.QwtPlot.__init__(self, parent)
        self.RGBMap = 0
        self.IndexMap = 1
        self.HueMap = 2
        self.AlphaMap = 3
        self.d_alpha = 255
        self.d_spectrogram = Qwt.QwtPlotSpectrogram()
        self.d_spectrogram.setRenderThreadCount(
            0)  # use system specific thread count
        self.d_spectrogram.setCachePolicy(Qwt.QwtPlotRasterItem.PaintCache)

        contourLevels = []
        for level in range(1, 20, 2):
            contourLevels.append(0.5 * level)
        self.d_spectrogram.setContourLevels(contourLevels)
        self.d_spectrogram.setData(SpectrogramData())
        self.d_spectrogram.attach(self)

        zInterval = self.d_spectrogram.data().interval(Qt.ZAxis)

        # A color bar on the right axis
        self.rightAxis = self.axisWidget(Qwt.QwtPlot.yRight)
        self.rightAxis.setTitle("Intensity")
        self.rightAxis.setColorBarEnabled(True)

        self.setAxisScale(Qwt.QwtPlot.yRight, zInterval.minValue(),
                          zInterval.maxValue())
        self.enableAxis(Qwt.QwtPlot.yRight)

        self.plotLayout().setAlignCanvasToScales(True)

        self.setColorMap(self.RGBMap)

        # LeftButton for the zooming
        # MidButton for the panning
        # RightButton: zoom out by 1
        # Ctrl+RighButton: zoom out to full size

        self.zoomer = MyZoomer(self.canvas())
        self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect2,
                                    Qt.RightButton, Qt.ControlModifier)
        self.zoomer.setMousePattern(Qwt.QwtEventPattern.MouseSelect3,
                                    Qt.RightButton)

        self.panner = Qwt.QwtPlotPanner(self.canvas())
        self.panner.setAxisEnabled(Qwt.QwtPlot.yRight, False)
        self.panner.setMouseButton(Qt.MidButton)

        # Avoid jumping when labels with more/less digits
        # appear/disappear when scrolling vertically

        fm = QFontMetrics(self.axisWidget(Qwt.QwtPlot.yLeft).font())
        sd = self.axisScaleDraw(Qwt.QwtPlot.yLeft)
        sd.setMinimumExtent(fm.width("100.00"))

        c = QColor(Qt.darkBlue)
        self.zoomer.setRubberBandPen(c)
        self.zoomer.setTrackerPen(c)
Beispiel #3
0
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.d_plot = Plot(self)
        margin = 5
        self.d_plot.setContentsMargins(margin, margin, margin, 0)

        self.setContextMenuPolicy(Qt.NoContextMenu)

        self.d_zoomer = [None, None]
        self.d_zoomer[0] = Zoomer(Qwt.QwtPlot.xBottom, Qwt.QwtPlot.yLeft,
                                  self.d_plot.canvas())
        self.d_zoomer[0].setRubberBand(Qwt.QwtPicker.RectRubberBand)
        self.d_zoomer[0].setRubberBandPen(QColor(Qt.green))
        self.d_zoomer[0].setTrackerMode(Qwt.QwtPicker.ActiveOnly)
        self.d_zoomer[0].setTrackerPen(QColor(Qt.white))

        self.d_zoomer[1] = Zoomer(Qwt.QwtPlot.xTop, Qwt.QwtPlot.yRight,
                                  self.d_plot.canvas())
        self.d_panner = Qwt.QwtPlotPanner(self.d_plot.canvas())
        self.d_panner.setMouseButton(Qt.MidButton)

        self.d_picker = Qwt.QwtPlotPicker(Qwt.QwtPlot.xBottom,
                                          Qwt.QwtPlot.yLeft,
                                          Qwt.QwtPlotPicker.CrossRubberBand,
                                          Qwt.QwtPicker.AlwaysOn,
                                          self.d_plot.canvas())
        self.d_picker.setStateMachine(Qwt.QwtPickerDragPointMachine())
        self.d_picker.setRubberBandPen(QColor(Qt.green))
        self.d_picker.setRubberBand(Qwt.QwtPicker.CrossRubberBand)
        self.d_picker.setTrackerPen(QColor(Qt.white))

        self.setCentralWidget(self.d_plot)

        self.toolBar = QToolBar(self)

        self.btnZoom = QToolButton(self.toolBar)
        self.btnZoom.setText("Zoom")
        self.btnZoom.setIcon(QIcon(QPixmap(zoom_xpm)))
        self.btnZoom.setCheckable(True)
        self.btnZoom.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.toolBar.addWidget(self.btnZoom)
        self.btnZoom.toggled.connect(self.enableZoomMode)

        self.btnPrint = QToolButton(self.toolBar)
        self.btnPrint.setText("Print")
        self.btnPrint.setIcon(QIcon(QPixmap(print_xpm)))
        self.btnPrint.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.toolBar.addWidget(self.btnPrint)
        self.btnPrint.clicked.connect(self.mprint)

        self.btnExport = QToolButton(self.toolBar)
        self.btnExport.setText("Export")
        self.btnExport.setIcon(QIcon(QPixmap(print_xpm)))
        self.btnExport.setToolButtonStyle(Qt.ToolButtonTextUnderIcon)
        self.toolBar.addWidget(self.btnExport)
        self.btnExport.clicked.connect(self.exportDocument)

        self.toolBar.addSeparator()

        hBox = QWidget(self.toolBar)

        self.layout = QHBoxLayout(hBox)
        self.layout.setSpacing(0)
        self.layout.addWidget(QWidget(hBox), 10)  # spacer
        self.layout.addWidget(QLabel("Damping Factor", hBox), 0)
        self.layout.addSpacing(10)

        self.cntDamp = Qwt.QwtCounter(hBox)
        self.cntDamp.setRange(0.0, 5.0)
        self.cntDamp.setSingleStep(0.01)
        self.cntDamp.setValue(0.0)

        self.layout.addWidget(self.cntDamp, 0)

        self.toolBar.addWidget(hBox)

        self.addToolBar(self.toolBar)
        self.statusBar()
        self.enableZoomMode(False)
        self.showInfo("humm")

        self.cntDamp.valueChanged['double'].connect(self.d_plot.setDamp)
        self.d_picker.moved.connect(self.moved)