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 __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()
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() self.cntDamp.valueChanged['double'].connect(self.d_plot.setDamp) self.d_picker.moved.connect(self.moved)