def make():
    demo = QwtPlot()
    demo.setCanvasBackground(Qt.white)
    demo.setTitle("Histogram")

    grid = QwtPlotGrid()
    grid.enableXMin(True)
    grid.enableYMin(True)
    grid.setMajorPen(QPen(Qt.black, 0, Qt.DotLine))
    grid.setMinorPen(QPen(Qt.gray, 0, Qt.DotLine))
    grid.attach(demo)

    histogram = HistogramItem()
    histogram.setColor(Qt.darkCyan)

    numValues = 20
    samples = []
    pos = 0.0
    for i in range(numValues):
        width = 5 + random.randint(0, 4)
        value = random.randint(0, 99)
        samples.append(QwtIntervalSample(value, QwtInterval(pos, pos + width)))
        pos += width

    histogram.setData(QwtIntervalSeriesData(samples))
    histogram.attach(demo)
    demo.setAxisScale(QwtPlot.yLeft, 0.0, 100.0)
    demo.setAxisScale(QwtPlot.xBottom, 0.0, pos)
    demo.replot()
    demo.resize(600, 400)
    demo.show()
    return demo
class NewGraph():
    def __init__(self):

        self.curves = []
        self.titleFont = QFont("Helvetica", 12, QFont.Bold)
        self.axisFont = QFont("Helvetica", 11, QFont.Bold)

    def createGraph(self):

        self.plot = QwtPlot()
        self.plot.resize(1000, 1000)
        self.plot.setAxisScaleDraw(QwtPlot.xBottom,
                                   DateTimeTimeScaleDraw(names=False))
        self.plot.replot()
        self.plot.show()

    def createCurve(self, x, y, colour):

        curve = QwtPlotCurve()
        colour = QColor(colour)
        curve.setPen(colour)
        curve.setData(x, y)
        curve.attach(self.plot)
        #self.plot.replot()
        self.curves.append(curve)

    def removeCurve(self, curveIndex):

        self.curves[curveIndex].attach(0)
        del self.curves[curveIndex]

    def setAxisTitles(self, yAxis, xAxis):

        # Create text for graph and axis titles
        xTitle = QwtText()
        xTitle.setText(xAxis)
        xTitle.setFont(self.axisFont)
        yTitle = QwtText()
        yTitle.setText(yAxis)
        yTitle.setFont(self.axisFont)

        self.plot.setAxisTitle(self.plot.yLeft, yTitle)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)

    def setTitle(self, title):

        titleText = QwtText()
        titleText.setText(title)
        titleText.setFont(self.titleFont)
        self.plot.setTitle(titleText)
def create_log_plot():
    plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)')
    plot.enableAxis(QwtPlot.xBottom)
    plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
    curve = QwtPlotCurve()
    curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
    pen = QPen(Qt.magenta)
    pen.setWidth(1.5)
    curve.setPen(pen)
    curve.attach(plot)
    x = np.arange(0.0, 10.0, 0.1)
    y = 10*np.cos(x)**2-.1
    print("y<=0:", y<=0)
    curve.setData(x, y)
    plot.replot()
    return plot
def create_log_plot():
    plot = QwtPlot('LogCurveDemo.py (or how to handle -inf values)')
    plot.enableAxis(QwtPlot.xBottom)
    plot.setAxisScaleEngine(QwtPlot.yLeft, QwtLogScaleEngine())
    curve = QwtPlotCurve()
    curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
    pen = QPen(Qt.magenta)
    pen.setWidth(1.5)
    curve.setPen(pen)
    curve.attach(plot)
    x = np.arange(0.0, 10.0, 0.1)
    y = 10 * np.cos(x)**2 - .1
    print("y<=0:", y <= 0)
    curve.setData(x, y)
    plot.replot()
    return plot
Beispiel #5
0
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        layout = QGridLayout(self)        
        # try to create a plot for SciPy arrays

        # make a curve and copy the data
        numpy_curve = QwtPlotCurve('y = lorentzian(x)')
        x = np.arange(0.0, 10.0, 0.01)
        y = lorentzian(x)
        numpy_curve.setData(x, y)
        # here, we know we can plot NumPy arrays
        numpy_plot = QwtPlot(self)
        numpy_plot.setTitle('numpy array')
        numpy_plot.setCanvasBackground(Qt.white)
        numpy_plot.plotLayout().setCanvasMargin(0)
        numpy_plot.plotLayout().setAlignCanvasToScales(True)
        # insert a curve and make it red
        numpy_curve.attach(numpy_plot)
        numpy_curve.setPen(QPen(Qt.red))
        layout.addWidget(numpy_plot, 0, 0)
        numpy_plot.replot()

        # create a plot widget for lists of Python floats
        list_plot = QwtPlot(self)
        list_plot.setTitle('Python list')
        list_plot.setCanvasBackground(Qt.white)
        list_plot.plotLayout().setCanvasMargin(0)
        list_plot.plotLayout().setAlignCanvasToScales(True)
        x = drange(0.0, 10.0, 0.01)
        y = [lorentzian(item) for item in x]
        # insert a curve, make it red and copy the lists
        list_curve = QwtPlotCurve('y = lorentzian(x)')
        list_curve.attach(list_plot)
        list_curve.setPen(QPen(Qt.red))
        list_curve.setData(x, y)
        layout.addWidget(list_plot, 0, 1)
        layout.addWidget(DataPlot(self),1,1)
        layout.addWidget(3dstl(self), 1, 0)
        list_plot.replot()
def main(args):
    app = QApplication(args)
    demo = QwtPlot()
    grid = QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
    grid.enableX(True)
    grid.enableY(True)
    complex_divider = 50.0

    myXScale = ComplexScaleDraw(start_value=0.0, end_value=complex_divider)
    #print('myXScale', myXScale)
    demo.setAxisScaleDraw(QwtPlot.xBottom, myXScale)

    m = QwtPlotMarker()
    m.attach(demo)
    m.setValue(complex_divider, 0.0)
    m.setLineStyle(QwtPlotMarker.VLine)
    m.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
    m.setLinePen(QPen(Qt.black, 2, Qt.SolidLine))

    vector_array = numpy.zeros((100, ), numpy.float32)
    for i in range(100):
        vector_array[i] = i

    curve = QwtPlotCurve('example data')
    curve.attach(demo)
    x_array = numpy.zeros(100, numpy.float32)
    y_array = numpy.zeros(100, numpy.float32)
    for i in range(100):
        x_array[i] = 1.0 * i
        y_array[i] = 2.0 * i
    curve.setSamples(x_array, y_array)

    demo.resize(600, 400)
    demo.replot()
    demo.show()
    #   app.setMainWidget(demo)
    app.exec_()
Beispiel #7
0
    def __init__(self, *args):
        QWidget.__init__(self, *args)
        layout = QGridLayout(self)        
        # try to create a plot for SciPy arrays

        # make a curve and copy the data
        numpy_curve = QwtPlotCurve('y = lorentzian(x)')
        x = np.arange(0.0, 10.0, 0.01)
        y = lorentzian(x)
        numpy_curve.setData(x, y)
        # here, we know we can plot NumPy arrays
        numpy_plot = QwtPlot(self)
        numpy_plot.setTitle('numpy array')
        numpy_plot.setCanvasBackground(Qt.white)
        numpy_plot.plotLayout().setCanvasMargin(0)
        numpy_plot.plotLayout().setAlignCanvasToScales(True)
        # insert a curve and make it red
        numpy_curve.attach(numpy_plot)
        numpy_curve.setPen(QPen(Qt.red))
        layout.addWidget(numpy_plot, 0, 0)
        numpy_plot.replot()

        # create a plot widget for lists of Python floats
        list_plot = QwtPlot(self)
        list_plot.setTitle('Python list')
        list_plot.setCanvasBackground(Qt.white)
        list_plot.plotLayout().setCanvasMargin(0)
        list_plot.plotLayout().setAlignCanvasToScales(True)
        x = drange(0.0, 10.0, 0.01)
        y = [lorentzian(item) for item in x]
        # insert a curve, make it red and copy the lists
        list_curve = QwtPlotCurve('y = lorentzian(x)')
        list_curve.attach(list_plot)
        list_curve.setPen(QPen(Qt.red))
        list_curve.setData(x, y)
        layout.addWidget(list_plot, 0, 1)
        list_plot.replot()
class MapDemo(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.plot = QwtPlot(self)
        self.plot.setTitle("A Simple Map Demonstration")
        self.plot.setCanvasBackground(Qt.white)
        self.plot.setAxisTitle(QwtPlot.xBottom, "x")
        self.plot.setAxisTitle(QwtPlot.yLeft, "y")
        self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0)
        self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0)
        self.setCentralWidget(self.plot)
        # Initialize map data
        self.count = self.i = 1000
        self.xs = np.zeros(self.count, np.float)
        self.ys = np.zeros(self.count, np.float)
        self.kappa = 0.2
        self.curve = QwtPlotCurve("Map")
        self.curve.attach(self.plot)
        self.curve.setSymbol(
            QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.red), QPen(Qt.blue),
                      QSize(5, 5)))
        self.curve.setPen(QPen(Qt.cyan))
        toolBar = QToolBar(self)
        self.addToolBar(toolBar)
        # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz)
        self.ticks = 10
        self.tid = self.startTimer(self.ticks)
        self.timer_tic = None
        self.user_tic = None
        self.system_tic = None
        self.plot.replot()

    def setTicks(self, ticks):
        self.i = self.count
        self.ticks = int(ticks)
        self.killTimer(self.tid)
        self.tid = self.startTimer(ticks)

    def resizeEvent(self, event):
        self.plot.resize(event.size())
        self.plot.move(0, 0)

    def moreData(self):
        if self.i == self.count:
            self.i = 0
            self.x = random.random()
            self.y = random.random()
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1
            chunks = []
            self.timer_toc = time.time()
            if self.timer_tic:
                chunks.append("wall: %s s." %
                              (self.timer_toc - self.timer_tic))
                print(' '.join(chunks))
            self.timer_tic = self.timer_toc
        else:
            self.x, self.y = standard_map(self.x, self.y, self.kappa)
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1

    def timerEvent(self, e):
        self.moreData()
        self.curve.setData(self.xs[:self.i], self.ys[:self.i])
        self.plot.replot()
Beispiel #9
0
class MapDemo(QMainWindow):
    def __init__(self, *args):
        QMainWindow.__init__(self, *args)
        self.plot = QwtPlot(self)
        self.plot.setTitle("A Simple Map Demonstration")
        self.plot.setCanvasBackground(Qt.white)
        self.plot.setAxisTitle(QwtPlot.xBottom, "x")
        self.plot.setAxisTitle(QwtPlot.yLeft, "y")    
        self.plot.setAxisScale(QwtPlot.xBottom, 0.0, 1.0)
        self.plot.setAxisScale(QwtPlot.yLeft, 0.0, 1.0)
        self.setCentralWidget(self.plot)
        # Initialize map data
        self.count = self.i = 1000
        self.xs = np.zeros(self.count, np.float)
        self.ys = np.zeros(self.count, np.float)
        self.kappa = 0.2
        self.curve = QwtPlotCurve("Map")
        self.curve.attach(self.plot)
        self.curve.setSymbol(QwtSymbol(QwtSymbol.Ellipse,
                                           QBrush(Qt.red),
                                           QPen(Qt.blue),
                                           QSize(5, 5)))
        self.curve.setPen(QPen(Qt.cyan))
        toolBar = QToolBar(self)
        self.addToolBar(toolBar)
        # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz)
        self.ticks = 10
        self.tid = self.startTimer(self.ticks)
        self.timer_tic = None
        self.user_tic = None
        self.system_tic = None    
        self.plot.replot()

    def setTicks(self, ticks):
        self.i = self.count
        self.ticks = int(ticks)
        self.killTimer(self.tid)
        self.tid = self.startTimer(ticks)
        
    def resizeEvent(self, event):
        self.plot.resize(event.size())
        self.plot.move(0, 0)

    def moreData(self):
        if self.i == self.count:
            self.i = 0
            self.x = random.random()
            self.y = random.random()
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1
            chunks = []
            self.timer_toc = time.time()
            if self.timer_tic:
                chunks.append("wall: %s s." % (self.timer_toc-self.timer_tic))
                print(' '.join(chunks))
            self.timer_tic = self.timer_toc
        else:
            self.x, self.y = standard_map(self.x, self.y, self.kappa)
            self.xs[self.i] = self.x
            self.ys[self.i] = self.y
            self.i += 1
        
    def timerEvent(self, e):
        self.moreData()
        self.curve.setData(self.xs[:self.i], self.ys[:self.i])
        self.plot.replot()
Beispiel #10
0
    def __init__(self, parent=None):
        super(Mision, self).__init__(parent)
        layout = QGridLayout(self)
        layout.lb1 = QLabel(self)
        x=0
        layout.lb1.setPixmap(QPixmap("CANSAT_BKG.png"))
        layout.lb1.setGeometry(0, 0, 1500, 1000)

        ############################TITLE#############################
        font = QFont("UKNumberPlate", 20, 10, 0)  #### FUENTE, TAMAÑO, GROSOR, ITALICA 0-F
        titulo1=QLabel()
        titulo1.setFont(font)
        titulo1.setStyleSheet('color: white')
        titulo1.setText('TEAM THOR')
        layout.addWidget(titulo1,0,1)
        #############################################################
        x = [1, 2]
        y = [1, 2]
        layout.addWidget(grap1, 1, 0)
 ##############################################################
        graph2 = QwtPlot()
        curva2 = QwtPlotCurve()
        curva3 = QwtPlotCurve()
        xcurva2 = [-800, 800]
        ycurva2 = [0, 0]
        xcurva3 = [0, 0]
        ycurva3 = [-800, 800]
        curva2.setData(xcurva2, ycurva2)
        curva2.setPen(QPen(Qt.black))
        curva2.attach(graph2)
        curva3.setData(xcurva3, ycurva3)
        curva3.setPen(QPen(Qt.black))
        curva3.attach(graph2)
        pal = QPalette();
        pal.setColor(QPalette.Text, Qt.white)
        pal.setColor(QPalette.Foreground, Qt.white)
        layout.addWidget(graph2, 2, 0)
        grid = QwtPlotGrid()
        grid.attach(graph2)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        graph2.replot()
        graph2.setAxisScale(QwtPlot.xBottom, -800, 800)
        graph2.setAxisScale(QwtPlot.yLeft, -800, 800)
        graph2.setPalette(pal)
#############################################################)
        layoutv = QVBoxLayout()
        layoutvN = QVBoxLayout()
        lb1 = QLabel(self)
        pixmap=QPixmap("DIAL4.png")
        pixmap2 = QPixmap("pointer.png")
        pixmap = pixmap.scaledToWidth(220)
        pixmap2 = pixmap2.scaledToWidth(20)
        lb1.setPixmap(pixmap)
        layoutv.addWidget(text_pressure)
        layoutv.addWidget(lb1)
        frame5.setLayout(layoutv)
        layoutvN.addWidget(frame5)
        layout.addLayout(layoutvN, 1, 1)
        ###
        self.lbN = QLabel(self)
        #x=50400
        press=0
        ang=(0.002685)*press-140
        if ang>=0:
            correctionx =  0
            correctiony=round(ang*0.2)
        else:
            correctiony = - round(ang * 0.2)
            if ang<=-105:
                correctionx = -round((((-ang-100)*0.07)**(2))-40)
            else:
                if ang>=-9.4:
                    correctionx = round(12 * (((-ang-1)/100) ** (1 / 4)))
                else:
                    correctionx = round(12 * (((-ang -9.5)) ** (1 / 4)))
        t = QTransform()
        t.rotate(ang)
        rotated_pixmap = pixmap2.transformed(t, Qt.SmoothTransformation)
        #lbN = QLabel(self)
        self.lbN.setPixmap(rotated_pixmap)
        self.lbN.setGeometry(619 - correctionx, 180 + correctiony, 70, 70)
        layout.lbN= self.lbN
        #layout.lbN.setPixmap(rotated_pixmap)
        #layout.lbN.setGeometry(619-correctionx, 180 + correctiony, 70, 70)
        #ang2.correctiony
#############################################################

############################################################
        layouth1 = QHBoxLayout()
        layouth2 = QHBoxLayout()
        layouth1.addWidget(volt_bar)
        layouth1.addWidget(text_volt)
        frame3.setLayout(layouth1)
        layouth2.addWidget(frame3)
        layout.addLayout(layouth2, 1, 2)
############################################################
        layoutG = QVBoxLayout()
        layoutG2 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        layoutG4 = QVBoxLayout()
        layoutG5 = QVBoxLayout()
        layoutG.addWidget(text_gps_time)
        layoutG.addWidget(text_gps_la)
        layoutG.addWidget(text_gps_lo)
        layoutG.addWidget(text_gps_al)
        layoutG.addWidget(text_gps_sats)
        layoutG3.addWidget(text_teamId)
        layoutG3.addWidget(text_mission_time)
        layoutG3.addWidget(text_Packet_count)
        frame2.setLayout(layoutG)
        frame7.setLayout(layoutG3)
        layoutG2.addWidget(frame2)
        layoutG4.addWidget(frame7)
        layoutG5.addLayout(layoutG2)
        layoutG5.addLayout(layoutG4)
        layout.addLayout(layoutG5, 2,2)
############################################################
        vboxj3 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        vboxj3.addWidget(text_sys)
        vboxj3.addWidget(text_elevation)
        vboxj3.addWidget(text_azimut)
        vboxj3.addWidget(text_gs_to_cansat)
        vboxj3.addWidget(text_space)
        frame1.setLayout(vboxj3)
        layoutG3.addWidget(frame1)
        layout.addLayout(layoutG3, 1, 3)
###########################################################
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(40)
############################################################
        layouth3 = QVBoxLayout()
        layouth4 = QVBoxLayout()
        layouth3.addWidget(temp_text)
        layouth3.addWidget(temp_bar)
        frame4.setLayout(layouth3)
        layouth4.addWidget(frame4)
        layout.addLayout(layouth4, 2, 3)
        temp_bar.setStyleSheet('QProgressBar::chunk {background: rgb(255, 0, 0);}')
############################################################
        self.setLayout(layout)
Beispiel #11
0
    def __init__(self, parent=None):
        super(Mision, self).__init__(parent)
        layout = QGridLayout(self)
        layout.lb1 = QLabel(self)
        layout.IM1=QLabel(self)
        layout.IM2=QLabel(self)
        layout.IM3=QLabel(self)
        layout.IM4 = QLabel(self)
        layout.IM5 = QLabel(self)
        layout.IM1.setPixmap(QPixmap("ipn.png"))
        layout.IM1.setGeometry(1250, 0, 120, 90)
        layout.IM2.setPixmap(QPixmap("mexico.png"))
        layout.IM2.setGeometry(1160, 0, 120, 90)
        layout.IM3.setPixmap(QPixmap("upiita.png"))
        layout.IM3.setGeometry(80, 0, 120, 90)
        layout.IM4.setPixmap(QPixmap("CANSATCOMP.png"))
        layout.IM4.setGeometry(500, 30, 180, 90)
        layout.IM5.setPixmap(QPixmap("IPNUPIITA.png"))
        layout.IM5.setGeometry(700, 30, 180, 90)
        ###############
        layout.lb1.setPixmap(QPixmap("CANSAT_BKG.png"))
        layout.lb1.setGeometry(0, 0, 1500, 1000)

        ############################TITLE#############################
        titulo1=QLabel()
        teamthor = QPixmap("TEAM3.png")
        titulo1.setPixmap(teamthor)
        layout.addWidget(titulo1,0,1)
        #############################################################
        x = [1, 2]
        y = [1, 2]
        layout.addWidget(grap1, 1, 0)
 ##############################################################
        graph2 = QwtPlot()
        curva2 = QwtPlotCurve()
        curva3 = QwtPlotCurve()
        xcurva2 = [-800, 800]
        ycurva2 = [0, 0]
        xcurva3 = [0, 0]
        ycurva3 = [-800, 800]
        curva2.setData(xcurva2, ycurva2)
        curva2.setPen(QPen(Qt.black))
        curva2.attach(graph2)
        curva3.setData(xcurva3, ycurva3)
        curva3.setPen(QPen(Qt.black))
        curva3.attach(graph2)
        pal = QPalette();
        pal.setColor(QPalette.Text, Qt.white)
        pal.setColor(QPalette.Foreground, Qt.white)
        layout.addWidget(graph2, 2, 0)
        grid = QwtPlotGrid()
        grid.attach(graph2)
        grid.setPen(QPen(Qt.black, 0, Qt.DotLine))
        graph2.replot()
        graph2.setAxisScale(QwtPlot.xBottom, -800, 800)
        graph2.setAxisScale(QwtPlot.yLeft, -800, 800)
        graph2.setPalette(pal)
#############################################################)
        layoutv = QGridLayout()
        layoutvN = QVBoxLayout()
        lb1 = QLabel(self)
        pixmap=QPixmap("DIAL4.png")
        pixmap = pixmap.scaledToWidth(220)
        lb1.setPixmap(pixmap)
        layoutv.addWidget(text_pressure,0,0)
        layoutv.addWidget(lb1,1,0)
        layoutv.addWidget(ql1,1,0,Qt.AlignCenter)
        frame5.setLayout(layoutv)
        layoutvN.addWidget(frame5)
        layout.addLayout(layoutvN, 1, 1)
#############################################################
        layoutvp = QGridLayout()
        layoutvNp = QVBoxLayout()
        lb1p = QLabel(self)
        pixmapp = QPixmap("DIAL4.png")
        pixmapp = pixmap.scaledToWidth(160)
        lb1p.setPixmap(pixmapp)
        layoutvp.addWidget(text_pitch, 0, 0)
        layoutvp.addWidget(text_roll, 1, 0)
        layoutvp.addWidget(text_bladespin, 2, 0)
        layoutvp.addWidget(lb1p, 3, 0 ,Qt.AlignCenter)
        layoutvp.addWidget(ql1p, 3, 0, Qt.AlignCenter)
        frame6.setLayout(layoutvp)
        layoutvNp.addWidget(frame6)
        layout.addLayout(layoutvNp, 2, 1)
############################################################
        layouth1 = QHBoxLayout()
        layouth2 = QHBoxLayout()
        layouth1.addWidget(volt_bar)
        layouth1.addWidget(text_volt)
        frame3.setLayout(layouth1)
        layouth2.addWidget(frame3)
        layout.addLayout(layouth2, 1, 2)
############################################################
        layoutG = QVBoxLayout()
        layoutG2 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        layoutG4 = QVBoxLayout()
        layoutG5 = QVBoxLayout()
        layoutG.addWidget(text_gps_time)
        layoutG.addWidget(text_gps_la)
        layoutG.addWidget(text_gps_lo)
        layoutG.addWidget(text_gps_al)
        layoutG.addWidget(text_gps_sats)
        layoutG3.addWidget(text_teamId)
        layoutG3.addWidget(text_mission_time)
        layoutG3.addWidget(text_Packet_count)
        frame2.setLayout(layoutG)
        frame7.setLayout(layoutG3)
        layoutG2.addWidget(frame2)
        layoutG4.addWidget(frame7)
        layoutG5.addLayout(layoutG2)
        layoutG5.addLayout(layoutG4)
        layout.addLayout(layoutG5, 2,2)
############################################################
        vboxj3 = QVBoxLayout()
        layoutG3 = QVBoxLayout()
        vboxj3.addWidget(text_sys)
        vboxj3.addWidget(text_elevation)
        vboxj3.addWidget(text_azimut)
        vboxj3.addWidget(text_gs_to_cansat)
        vboxj3.addWidget(text_space)
        frame1.setLayout(vboxj3)
        layoutG3.addWidget(frame1)
        layout.addLayout(layoutG3, 1, 3)
###########################################################
        layout.setContentsMargins(0,0,0,0)
        layout.setSpacing(30)
############################################################
        layouth3 = QHBoxLayout()
        layouth4 = QHBoxLayout()
        layouth3.addWidget(temp_bar)
        layouth3.addWidget(temp_text)
        frame4.setLayout(layouth3)
        layouth4.addWidget(frame4)
        layout.addLayout(layouth4, 2, 3)
        temp_bar.setStyleSheet('QProgressBar::chunk {background: rgb(255, 0, 0);}')
        temp_bar.setRange(0, 350)
        temp_bar.setFixedSize(50, 200)
############################################################
        self.setLayout(layout)
Beispiel #12
0
class FermentGraph(QWidget):
    _logname = 'FermentGraphGeneric'
    _log = logging.getLogger(f'{_logname}')

    def __init__(self, database, parent=None):
        super().__init__(parent)
        self.db = database
        self.updateTimer = QTimer(self)
        self.updateTimer.start(5000)

        self.plot = QwtPlot()
        self.curve = QwtPlotCurve()
        self.curve.attach(self.plot)
        self.plot.resize(1000, 1000)
        self.plot.show()
        self.plot.setAxisScaleDraw(QwtPlot.xBottom, DateTimeTimeScaleDraw())

        axisFont = QFont("Helvetica", 11, QFont.Bold)
        titleFont = QFont("Helvetica", 12, QFont.Bold)

        xTitle = QwtText()
        xTitle.setText("Time")
        xTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)

        self.yTitle = QwtText()
        self.yTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.yLeft, self.yTitle)

        self.titleText = QwtText()
        self.titleText.setFont(titleFont)
        self.plot.setTitle(self.titleText)

        mainLayout = QHBoxLayout()
        mainLayout.addWidget(self.plot)
        self.setLayout(mainLayout)

        self.plot.show()
        self.results = []
        self.batchID = None

    def updatePlot(self, variable):
        if self.batchID is not None:
            self.db.flushTables()
            sql = f"SELECT TimeStamp, {variable} FROM Ferment WHERE BatchID = '{self.batchID}'"

            timestamps = []
            self.results = []
            for data in self.db.custom(sql)[1:]:
                timestamps.append(data[0])
                self.results.append(data[1])

            startTime = timestamps[0]
            for i in range(len(timestamps)):
                timestamps[i] = (timestamps[i] - startTime).seconds

            # self.plot.setAxisScaleDraw(QwtPlot.xBottom, TimeScaleDraw())

            self.curve.setData(timestamps, self.results)
            self.plot.replot()
            self.plot.show()

    def changeTank(self, tankID):
        self.titleText.setText(f"Fermentation Tank: {tankID}")
Beispiel #13
0
pen.setJoinStyle(Qt.MiterJoin)

symbol = QwtSymbol()
symbol.setPen(pen)
symbol.setBrush(Qt.red)
symbol.setPath(path)
symbol.setPinPoint(QPointF(0.0, 0.0))
symbol.setSize(10, 14)

# --- Test it within a simple plot ---

curve = QwtPlotCurve()
curve_pen = QPen(Qt.blue)
curve_pen.setStyle(Qt.DotLine)
curve.setPen(curve_pen)
curve.setSymbol(symbol)
x = np.linspace(0, 10, 10)
curve.setData(x, np.sin(x))

plot = QwtPlot()
curve.attach(plot)
plot.resize(600, 300)
plot.replot()
plot.show()

plot.grab().save(
    osp.join(osp.abspath(osp.dirname(__file__)), "images",
             "symbol_path_example.png"))

app.exec_()
class TabGraph(QWidget):

    _logname = 'TabGraph'
    _log = logging.getLogger(f'{_logname}')

    ##TabGraph constructor
    #
    #Create the graph and accompanying buttons
    def __init__(self, db, parent=None):
        super().__init__(parent)
        # self.LOGIN = LOGIN
        # self.db = dataBase(self.LOGIN, "Brewing")
        self.db = db
        self.dataY = np.zeros(0)
        self.dataX = np.linspace(0, len(self.dataY), len(self.dataY))

        self.count = 0
        self.timeLabel = QLabel("Timer:")
        self.timeLabel.setAlignment(QtCore.Qt.AlignRight)

        self.tempLabel = QLabel("Temp:")
        self.tempLabel.setAlignment(QtCore.Qt.AlignRight)

        self.targetTemp = QLabel("Set Temp:")
        self.targetTime = QLabel("Set Time:")

        self.targetTimeLabel = QLabel("Target: ")
        self.targetTimeLabel.setAlignment(QtCore.Qt.AlignRight)
        self.targetTempLabel = QLabel("Target: ")
        self.targetTempLabel.setAlignment(QtCore.Qt.AlignRight)

        self.startButton = QPushButton()
        self.stopButton = QPushButton()

        self.plot = QwtPlot()
        self.curve = QwtPlotCurve()
        self.curve.attach(self.plot)
        self.plot.resize(1000, 1000)
        self.plot.replot()
        self.plot.show()

        axisFont = QFont("Helvetica", 11, QFont.Bold)
        titleFont = QFont("Helvetica", 12, QFont.Bold)

        xTitle = QwtText()
        xTitle.setText("Time")
        xTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.xBottom, xTitle)
        yTitle = QwtText()
        yTitle.setText(f"Temperature {DEGREESC}")
        yTitle.setFont(axisFont)
        self.plot.setAxisTitle(self.plot.yLeft, yTitle)

        self.tempStatusLED = QLed(self,
                                  onColour=QLed.Green,
                                  offColour=QLed.Red,
                                  shape=QLed.Circle)
        self.tempStatusLED.value = False
        self.tempStatusLED.setMaximumSize(25, 25)

        self.timeStatusLED = QLed(self,
                                  onColour=QLed.Green,
                                  offColour=QLed.Red,
                                  shape=QLed.Circle)
        self.timeStatusLED.value = False
        self.timeStatusLED.setMaximumSize(25, 25)

        self.recipeGrid = QGridLayout()
        self.recipeGrid.addWidget(QLabel(f"Recipe:"), 0, 0)
        self.recipeGrid.addWidget(QLabel(f"{self.recipedata['recipeName']}"),
                                  0, 1)
        self.recipeGrid.addWidget(QHLine(), 1, 0, 1, 2)
        self.recipeGrid.addWidget(self.targetTemp)
        self.recipeGrid.addWidget(self.targetTempLabel)
        self.recipeGrid.addWidget(self.targetTime)
        self.recipeGrid.addWidget(self.targetTimeLabel)
        self.recipeGrid.addWidget(QHLine(), 4, 0, 1, 2)

        self.tempLayout = QHBoxLayout()
        # self.tempLayout.addWidget(self.targetTempLabel)
        # self.tempLayout.addStretch(10)
        self.tempLayout.addWidget(self.tempLabel)
        # self.tempLayout.addStretch(10)
        self.tempLayout.addWidget(self.tempStatusLED)
        self.tempLayout.addStretch(10)

        self.timeLayout = QHBoxLayout()
        # self.timeLayout.addWidget(self.targetTimeLabel)
        # self.timeLayout.addStretch(10)
        self.timeLayout.addWidget(self.timeLabel)
        # self.timeLayout.addStretch(10)
        self.timeLayout.addWidget(self.timeStatusLED)
        self.timeLayout.addStretch(10)

        self.plotLayout = QVBoxLayout()
        self.plotLayout.addLayout(self.timeLayout)
        # self.plotLayout.addStretch(10)
        self.plotLayout.addLayout(self.tempLayout)
        # self.plotLayout.addStretch(10)
        self.plotLayout.addWidget(self.plot)

        self.buttonLayout = QVBoxLayout()
        self.buttonLayout.addWidget(self.startButton)
        self.buttonLayout.addWidget(self.stopButton)
        self.buttonLayout.addLayout(self.recipeGrid)
        self.buttonLayout.addStretch(100)

        mainLayout = QHBoxLayout()
        mainLayout.addLayout(self.buttonLayout)
        mainLayout.addLayout(self.plotLayout)

        vLayout = QVBoxLayout(self)
        vLayout.addLayout(mainLayout)

        self.minuteTimer = QTimer(self)
        self.minuteTimer.timeout.connect(lambda: self.addTimer(60))

    ##Keep track of the timer
    def addTimer(self, seconds):
        self.count += seconds

    ##convery the time from seconds to hours/minutes
    def display_time(self, seconds, granularity=2):
        result = []
        for name, count in TIME_INTERVALS:
            value = seconds // count
            if value:
                seconds -= value * count
                if value == 1:
                    name = name.rstrip('s')
                result.append("{} {}".format(value, name))
        return ', '.join(result[:granularity])
Beispiel #15
0
from qwt.qt.QtGui import QApplication
from qwt import QwtPlot, QwtPlotCurve
import numpy as np

app = QApplication([])

x = np.linspace(-10, 10, 500)
y1, y2 = np.cos(x), np.sin(x)

my_plot = QwtPlot("Two curves")
curve1, curve2 = QwtPlotCurve("Curve 1"), QwtPlotCurve("Curve 2")
curve1.setData(x, y1)
curve2.setData(x, y2)
curve1.attach(my_plot)
curve2.attach(my_plot)
my_plot.resize(600, 300)
my_plot.replot()
my_plot.show()

app.exec_()