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
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)
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)
def __init__(self,parent): super().__init__(parent) self.__d_interval = Qwt.QwtInterval( 0.0, 10.0 ) self.__d_timerId = -1 self.__d_directPainter = Qwt.QwtPlotDirectPainter() self.__d_clock = Qwt.QwtSystemClock() self.__d_paintedPoints = 0 self.setAutoReplot( False ) self.setCanvas( Canvas() ) self.plotLayout().setAlignCanvasToScales( True ) self.setAxisTitle( Qwt.QwtPlot.xBottom, "Time [s]" ) self.setAxisScale( Qwt.QwtPlot.xBottom, self.__d_interval.minValue(), self.__d_interval.maxValue() ) self.setAxisScale( Qwt.QwtPlot.yLeft, -200.0, 200.0 ) self.grid = Qwt.QwtPlotGrid() self.grid.setPen( Qt.gray, 0.0, Qt.DotLine ) self.grid.enableX( True ) self.grid.enableXMin( True ) self.grid.enableY( True ) self.grid.enableYMin( False ) self.grid.attach( self ) self.__d_origin = Qwt.QwtPlotMarker() self.__d_origin.setLineStyle( Qwt.QwtPlotMarker.Cross ) self.__d_origin.setValue( self.__d_interval.minValue() + self.__d_interval.width() / 2.0, 0.0 ) self.__d_origin.setLinePen( Qt.gray, 0.0, Qt.DashLine ) self.__d_origin.attach( self ) self.__d_curve = Qwt.QwtPlotCurve() self.__d_curve.setStyle( Qwt.QwtPlotCurve.Lines ) self.__d_curve.setPen( self.canvas().palette().color( QPalette.WindowText ) ) self.__d_curve.setRenderHint( Qwt.QwtPlotItem.RenderAntialiased, True ) self.__d_curve.setPaintAttribute( Qwt.QwtPlotCurve.ClipPolygons, False ) self.__cdata = CurveData() self.__d_curve.setData( self.__cdata ) self.__d_curve.attach( self )
def __init__(self, parent=None): Qwt.QwtPlot.__init__(self, parent) self.setAutoReplot(False) self.setTitle("Frequency Response of a Second-Order System") canvas = Qwt.QwtPlotCanvas() canvas.setBorderRadius(10) self.setCanvas(canvas) self.setCanvasBackground(QColor("MidnightBlue")) # legend legend = Qwt.QwtLegend() self.insertLegend(legend, Qwt.QwtPlot.BottomLegend) # grid grid = Qwt.QwtPlotGrid() grid.enableXMin(True) grid.setMajorPen(Qt.white, 0, Qt.DotLine) grid.setMinorPen(Qt.gray, 0, Qt.DotLine) grid.attach(self) # axes self.enableAxis(Qwt.QwtPlot.yRight) self.setAxisTitle(Qwt.QwtPlot.xBottom, "Normalized Frequency") self.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude [dB]") self.setAxisTitle(Qwt.QwtPlot.yRight, "Phase [deg]") self.setAxisMaxMajor(Qwt.QwtPlot.xBottom, 6) self.setAxisMaxMinor(Qwt.QwtPlot.xBottom, 9) self.setAxisScaleEngine(Qwt.QwtPlot.xBottom, Qwt.QwtLogScaleEngine()) # curves self.d_curve1 = Qwt.QwtPlotCurve("Amplitude") self.d_curve1.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.d_curve1.setPen(Qt.yellow) self.d_curve1.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine) self.d_curve1.setYAxis(Qwt.QwtPlot.yLeft) self.d_curve1.attach(self) self.d_curve2 = Qwt.QwtPlotCurve("Phase") self.d_curve2.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased) self.d_curve2.setPen(Qt.cyan) self.d_curve2.setLegendAttribute(Qwt.QwtPlotCurve.LegendShowLine) self.d_curve2.setYAxis(Qwt.QwtPlot.yRight) self.d_curve2.attach(self) # marker self.d_marker1 = Qwt.QwtPlotMarker() self.d_marker1.setValue(0.0, 0.0) self.d_marker1.setLineStyle(Qwt.QwtPlotMarker.VLine) self.d_marker1.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) self.d_marker1.setLinePen(Qt.green, 0, Qt.DashDotLine) self.d_marker1.attach(self) self.d_marker2 = Qwt.QwtPlotMarker() self.d_marker2.setLineStyle(Qwt.QwtPlotMarker.HLine) self.d_marker2.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom) self.d_marker2.setLinePen(QColor(200, 150, 0), 0, Qt.DashDotLine) self.d_marker2.setSymbol( Qwt.QwtSymbol(Qwt.QwtSymbol.Diamond, QColor(Qt.yellow), QColor(Qt.green), QSize(8, 8))) self.d_marker2.attach(self) self.setDamp(0) self.setAutoReplot(True)
import sys #import Qwt from PyQt5 import Qwt import numpy as np from PyQt5.QtCore import Qt, QSize from PyQt5.QtGui import QBrush, QPen from PyQt5.QtWidgets import QApplication a = QApplication(sys.argv) plot=Qwt.QwtPlot() plot.setTitle("Plot Demo") plot.setCanvasBackground(Qt.white) plot.insertLegend( Qwt.QwtLegend() ) grid = Qwt.QwtPlotGrid() grid.attach( plot ) curve = Qwt.QwtPlotCurve() curve.setTitle("Some Points") curve.setPen(Qt.blue,4) curve.setRenderHint( Qwt.QwtPlotItem.RenderAntialiased, True ); symbol = Qwt.QwtSymbol( Qwt.QwtSymbol.Ellipse, QBrush( Qt.yellow ), QPen( Qt.red, 2 ), QSize( 8, 8 ) ); curve.setSymbol( symbol ) x=np.arange(0,10,0.1) y=np.sin(x) curve.setSamples(x,y) curve.attach(plot)
def __init__(self): super(MyApp, self).__init__() # Set up the user interface from Designer. self.ui = Ui_mainWindow() self.ui.setupUi(self) # ======= LOCAL WIDGET MODIFICATIONS =============================================================== spdMeter = self.ui.SpeedDial spdLCD = self.ui.SpeedLCD spdWheel = self.ui.SpeedWheel thermo = self.ui.Thermo thermSlide = self.ui.ThermoSlider compass = self.ui.Compass counter = self.ui.Counter global clk clk = self.ui.AnalogClock # SPEEDOMETER SETUP palette2 = QPalette() palette2.setColor(QPalette.Base, Qt.black) palette2.setColor(QPalette.WindowText, QColor(Qt.darkBlue)) palette2.setColor(QPalette.Text, Qt.yellow) palette2.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette2.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 spdMeter.setPalette(palette2) needle = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, Qt.red, QtGui.QColor(Qt.gray)) spdMeter.setNeedle(needle) # THERMO SETUP colorMap = Qwt.QwtLinearColorMap() colorMap.setColorInterval(Qt.blue, Qt.red) thermo.setColorMap(colorMap) # COMPASS SETUP palette0 = QPalette() palette0.setColor(QPalette.Base, Qt.darkBlue) palette0.setColor(QPalette.WindowText, QColor(Qt.darkBlue)) palette0.setColor(QPalette.Text, Qt.yellow) palette0.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette0.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 compass.setPalette(palette0) # Tick marks for each degree CompSclDrw = Qwt.QwtCompassScaleDraw() CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Ticks, True) CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Labels, True) CompSclDrw.enableComponent(Qwt.QwtAbstractScaleDraw.Backbone, False) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MediumTick, 0) CompSclDrw.setTickLength(Qwt.QwtScaleDiv.MajorTick, 5) compass.setScaleDraw(CompSclDrw) compass.setNeedle(Qwt.QwtCompassMagnetNeedle(Qwt.QwtCompassMagnetNeedle.ThinStyle, Qt.darkBlue, Qt.red)) # ANALOG CLOCK SETUP palette1 = QPalette() palette1.setColor(QPalette.Base, Qt.black) # Clock number ring background palette1.setColor(QPalette.Text, Qt.yellow) # Clock numbers color palette1.setColor(QPalette.Foreground, Qt.darkBlue) # Inner Ring Color palette1.setColor(QPalette.Dark, Qt.darkGray) # Bezel ring color 1 palette1.setColor(QPalette.Light, Qt.lightGray) # Bezel Ring Color 2 clk.setPalette(palette1) # Disable minor ticks ClkSclDrw = Qwt.QwtRoundScaleDraw() ClkSclDrw.setTickLength(Qwt.QwtScaleDiv.MinorTick, 0) # Set color of clock hands knobColor = QColor(Qt.gray) for i in range(clk.NHands): handColor = QColor(Qt.gray) width = 8 if i == clk.SecondHand: handColor = Qt.red knobColor = QColor(Qt.darkRed) width = 5 hand = Qwt.QwtDialSimpleNeedle(Qwt.QwtDialSimpleNeedle.Arrow, True, handColor, knobColor) hand.setWidth(width) clk.setHand(clk.Hand(i), hand) # ======= WIDGET CONNECTIONS ======================================================================= spdMeter.setValue(self.ui.SpeedWheel.value()) spdWheel.valueChanged['double'].connect(spdMeter.setValue) spdWheel.valueChanged['double'].connect(spdLCD.display) thermSlide.valueChanged['double'].connect(thermo.setValue) counter.valueChanged['double'].connect(compass.setValue) # ======= SINE WAVE PLOT SETUP ==================================================================== global ampKnob, frqKnob, maxPts, n, angle, xData, yData, curve, plot, deg ampKnob = self.ui.AmpKnob # Amplitude knob object frqKnob = self.ui.FreqKnob # Frequency knob object maxPts = 250 # X axis range for plots xData = np.zeros(1, dtype=np.uint16) # Buffer for x data yData = np.zeros(1, dtype=np.float32) # Buffer for y Data n = 0 # loop counter and base for frequency steps angle = 0 # Rotation angle along X axis for plots deg = u'\N{DEGREE SIGN}' plot = self.ui.qwtPlot # Plot object # plot.setTitle("SINE WAVE PLOT") # plot.insertLegend(Qwt.QwtLegend()) plot.setCanvasBackground(Qt.black) plot.setAxisScale(2, 0, maxPts, 50) # X bottom axis plot.setAxisMaxMinor(2, 5) plot.setAxisScale(0, -10, 10, 2) # Y Left Axis plot.setAxisMaxMinor(0, 2) grid = Qwt.QwtPlotGrid() grid.setPen(Qt.darkGray, 0, Qt.DotLine) grid.attach(plot) curve = Qwt.QwtPlotCurve() # curve.setTitle("Some Points") curve.attach(plot) curve.setPen(Qt.yellow, 2) curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased, True) # Start the loop function update()
def __init__(self, proc, cmdLine, name, reader, depth): self.__depth__ = depth self.__proc__ = proc self.__reader__ = reader self.__name__ = name self.__dialog__ = QtWidgets.QDialog() self.__procDetails__ = uic.loadUi(os.path.join(os.path.dirname(__file__), "./ui/processdetails.ui"), baseinstance=self.__dialog__) self.__dialog__.show() self.__dialog__.setWindowTitle(proc+":"+cmdLine+" Properties") self.__processGone__ = False self.__y__ = range(self.__depth__) self.__tcpConnections__ = [] self.__tcpStat__ = None self.__TCPHist__ = [0] * self.__reader__.getHistoryDepth(self.__proc__) self.__prevtcpipbytes__ = 0 self.__envData = procreader.reader.UNKNOWN #tell reader that a singleprocess GUI is using its data, for optimization self.__reader__.setListener(self.__proc__) #-------- top plot CPU usage------------------------------------------------------------------- #Curves for CPU usage self.__curveCpuHist__ = Qwt.QwtPlotCurve("CPU History") pen = QtGui.QPen(QtGui.QColor(0,255,0)) pen.setWidth(2) #work around to get better plotting. self.__curveCpuHistExt__ = Qwt.QwtPlotCurve("CPU History extra") self.__curveCpuHistExt__.setPen(QtGui.QPen(QtGui.QColor(0,255,0))) self.__curveCpuHistExt__.attach(self.__procDetails__.qwtPlotCpuHist) self.__curveCpuHist__.setPen(pen) self.__curveCpuHist__.setBrush(QtGui.QColor(0,170,0)) self.__curveCpuHist__.attach(self.__procDetails__.qwtPlotCpuHist) #Curve for kernel usage self.__curveCpuKernelHist__ = Qwt.QwtPlotCurve("CPU Kernel History") pen = QtGui.QPen(QtGui.QColor(255,0,0)) pen.setWidth(1) self.__curveCpuKernelHist__.setPen(pen) self.__curveCpuKernelHist__.setBrush(QtGui.QColor(170,0,0)) self.__curveCpuKernelHist__.attach(self.__procDetails__.qwtPlotCpuHist) #work around to get better plotting. self.__curveCpuKernelHistExt__ = Qwt.QwtPlotCurve("CPU Kernel History extra") self.__curveCpuKernelHistExt__.setPen(QtGui.QPen(QtGui.QColor(255,0,0))) self.__curveCpuKernelHistExt__.attach(self.__procDetails__.qwtPlotCpuHist) #self.__procDetails__.qwtPlotCpuHist.setAxisScale(0,0,self.__depth__,10) 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.__procDetails__.qwtPlotCpuHist) #---------------------------------------------------------------------------------------------- #-------- Middle plot memory usage------------------------------------------------------------- #Curve for memory usage self.__curveRssHist__ = Qwt.QwtPlotCurve("Rss History") pen = QtGui.QPen(QtGui.QColor(248,248,0)) pen.setWidth(1) self.__curveRssHist__.setPen(pen) self.__curveRssHist__.setBrush(QtGui.QColor(190,190,0)) self.__curveRssHist__.attach(self.__procDetails__.qwtPlotRssHist) self.__curveRssHistExt__ = Qwt.QwtPlotCurve("Rss extra") self.__curveRssHistExt__.setPen(QtGui.QPen(QtGui.QColor(248,248,0))) self.__curveRssHistExt__.attach(self.__procDetails__.qwtPlotRssHist) #self.__procDetails__.qwtPlotRssHgetThreist.setAxisScale(0,0,100,10) self.__RssPlotGrid__ = Qwt.QwtPlotGrid() self.__RssPlotGrid__.setMajorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__RssPlotGrid__.setMinorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__RssPlotGrid__.enableXMin(True) self.__RssPlotGrid__.attach(self.__procDetails__.qwtPlotRssHist) #---------------------------------------------------------------------------------------------- #-------- Bottom plot IO usage ---------------------------------------------------------------- #Curve for memory usage self.__curveIOHist__ = Qwt.QwtPlotCurve("IO History") pen = QtGui.QPen(QtGui.QColor(0,214,214)) pen.setWidth(1) self.__curveIOHist__.setPen(pen) self.__curveIOHist__.setBrush(QtGui.QColor(0,150,150)) self.__curveIOHist__.attach(self.__procDetails__.qwtPlotIoHist) self.__curveIOHistExt__ = Qwt.QwtPlotCurve("IO History extra") self.__curveIOHistExt__.setPen(QtGui.QPen(QtGui.QColor(0,214,214))) self.__curveIOHistExt__.attach(self.__procDetails__.qwtPlotIoHist) #self.__procDetails__.qwtPlotIoHist.setAxisScale(0,0,100,10) self.__IOPlotGrid__ = Qwt.QwtPlotGrid() self.__IOPlotGrid__.setMajorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__IOPlotGrid__.setMinorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__IOPlotGrid__.enableXMin(True) self.__IOPlotGrid__.attach(self.__procDetails__.qwtPlotIoHist) #---------------------------------------------------------------------------------------------- #-------- TCP IO usage ---------------------------------------------------------------- self.__curveTcpipHist__ = Qwt.QwtPlotCurve("TCPIP History") pen = QtGui.QPen(QtGui.QColor(0,214,214)) pen.setWidth(1) self.__curveTcpipHist__.setPen(pen) self.__curveTcpipHist__.setBrush(QtGui.QColor(196,60,210)) self.__curveTcpipHist__.attach(self.__procDetails__.qwtPlotTcpipHist) self.__curveTcpipHistExt__ = Qwt.QwtPlotCurve("TCPIP History extra") self.__curveTcpipHistExt__.setPen(QtGui.QPen(QtGui.QColor(215,124,224))) self.__curveTcpipHistExt__.attach(self.__procDetails__.qwtPlotTcpipHist) #self.__procDetails__.qwtPlotIoHist.setAxisScale(0,0,100,10) self.__TcpipPlotGrid__ = Qwt.QwtPlotGrid() self.__TcpipPlotGrid__.setMajorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__TcpipPlotGrid__.setMinorPen(QtGui.QPen(QtGui.QColor(0,100,0), 0, QtCore.Qt.SolidLine)) self.__TcpipPlotGrid__.enableXMin(True) self.__TcpipPlotGrid__.attach(self.__procDetails__.qwtPlotTcpipHist) #---------------------------------------------------------------------------------------------- # all plots ---------------------------------------------------------------------------------- self.__procDetails__.qwtPlotCpuHist.setCanvasBackground(QtGui.QColor(0,0,0)) self.__procDetails__.qwtPlotRssHist.setCanvasBackground(QtGui.QColor(0,0,0)) self.__procDetails__.qwtPlotIoHist.setCanvasBackground(QtGui.QColor(0,0,0)) self.__procDetails__.qwtPlotTcpipHist.setCanvasBackground(QtGui.QColor(0,0,0)) self.__procDetails__.qwtPlotCpuHist.enableAxis(0, False ) self.__procDetails__.qwtPlotCpuHist.enableAxis(2, False ) self.__procDetails__.qwtPlotRssHist.enableAxis(0, False ) self.__procDetails__.qwtPlotRssHist.enableAxis(2, False ) self.__procDetails__.qwtPlotIoHist.enableAxis(0, False ) self.__procDetails__.qwtPlotIoHist.enableAxis(2, False ) self.__procDetails__.qwtPlotTcpipHist.enableAxis(0, False ) self.__procDetails__.qwtPlotTcpipHist.enableAxis(2, False ) #---------------------------------------------------------------------------------------------- self._availableLabel = QtWidgets.QLabel(" ", parent=self.__procDetails__.qwtPlotTcpipHist ) font = QtGui.QFont("Arial", pointSize=12) self._availableLabel.setFont(font) self._availableLabel.setStyleSheet("QLabel { color : grey; }"); self._availableLabel.show() self.__procDetails__.pushButtonOK.clicked.connect(self.__onClose__) # Fill some field only at construction time self.__procDetails__.filterEdit.textEdited.connect(self.__onFilterTextEdit__) self.__lddoutput__ = None self._tcpstat = tcpip_stat.tcpStat() self._tcpstat.start() self.update_sockets()