예제 #1
0
    def __init__(self, *args):
        Qt.QFrame.__init__(self, *args)

        self.setFrameStyle(Qt.QFrame.Box | Qt.QFrame.Raised)
        self.setLineWidth(2)
        self.setMidLineWidth(3)

        p = Qt.QPalette()
        p.setColor(self.backgroundRole(), Qt.QColor(30, 30, 50))
        self.setPalette(p)
        # make curves and maps
        self.tuples = []
        # curve 1
        curve = Qwt.QwtPlotCurve()
        curve.setPen(Qt.QPen(Qt.QColor(150, 150, 200), 2))
        curve.setStyle(Qwt.QwtPlotCurve.Spline)
        curve.setCurveAttribute(Qwt.QwtPlotCurve.Xfy)
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, Qt.QBrush(),
                          Qt.QPen(Qt.Qt.yellow, 2), Qt.QSize(7, 7)))
        self.tuples.append((curve, Qwt.QwtScaleMap(0, 100, -1.5, 1.5),
                            Qwt.QwtScaleMap(0, 100, 0.0, 2 * pi)))
        # curve 2
        curve = Qwt.QwtPlotCurve()
        curve.setPen(Qt.QPen(Qt.QColor(200, 150, 50), 1, Qt.Qt.DashDotDotLine))
        curve.setStyle(Qwt.QwtPlotCurve.Sticks)
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.blue),
                          Qt.QPen(Qt.Qt.yellow), Qt.QSize(5, 5)))
        self.tuples.append((curve, Qwt.QwtScaleMap(0, 100, 0.0, 2 * pi),
                            Qwt.QwtScaleMap(0, 100, -3.0, 1.1)))
        # curve 3
        curve = Qwt.QwtPlotCurve()
        curve.setPen(Qt.QPen(Qt.QColor(100, 200, 150)))
        curve.setStyle(Qwt.QwtPlotCurve.Spline)
        curve.setCurveAttribute(Qwt.QwtPlotCurve.Periodic)
        curve.setCurveAttribute(Qwt.QwtPlotCurve.Parametric)
        curve.setSplineSize(200)
        self.tuples.append(
            (curve, Qwt.QwtScaleMap(0, 100, -1.1,
                                    3.0), Qwt.QwtScaleMap(0, 100, -1.1, 3.0)))
        # curve 4
        curve = Qwt.QwtPlotCurve()
        curve.setPen(Qt.QPen(Qt.Qt.red))
        curve.setStyle(Qwt.QwtPlotCurve.Spline)
        curve.setSplineSize(200)
        self.tuples.append(
            (curve, Qwt.QwtScaleMap(0, 100, -5.0,
                                    1.1), Qwt.QwtScaleMap(0, 100, -1.1, 5.0)))
        # data
        self.phase = 0.0
        self.base = arange(0.0, 2.01 * pi, 2 * pi / (USize - 1))
        self.uval = cos(self.base)
        self.vval = sin(self.base)
        self.uval[1::2] *= 0.5
        self.vval[1::2] *= 0.5
        self.newValues()
        # start timer
        self.tid = self.startTimer(250)
    def addCurve(self, frequency_axis, transfer_function, vertical_units):

        transfer_function_uncalibrated = copy.copy(transfer_function) * (
            10**((-5.06 - -6. + 0.16) / 20.)
        )  # adjustment based on low-frequency RedPitaya's transfer function
        self.writeOutputFile(
            transfer_function_uncalibrated,
            frequency_axis,
            vertical_units,
            bCalibrated=False
        )  # we always save the uncalibrated TF regardless of whether we apply cal or not

        # Load and apply calibration data based on the measurement of the Red Pitaya's transfer function:
        if vertical_units == 'V/V':
            # the copy.copy() is not strictly needed since applying the calibration would create a copy, but this potentially avoids a mistake later if I bypass the calibration
            transfer_function_calibrated = self.loadAndApplyCalibration(
                transfer_function_uncalibrated, frequency_axis)
            self.transfer_function_list.append(transfer_function_calibrated)
            self.writeOutputFile(transfer_function_calibrated,
                                 frequency_axis,
                                 vertical_units,
                                 bCalibrated=True)
        else:
            self.transfer_function_list.append(transfer_function_uncalibrated)

        self.vertical_units_list.append(copy.copy(vertical_units))
        self.frequency_axis_list.append(copy.copy(frequency_axis))

        # create a new curve object in both magnitude and phase plots:
        # magnitude plot
        #TODO: add color cycling according to matlab's color scheme.
        current_color_as_list = self.colors_order[
            (len(self.transfer_function_list) - 1) % len(self.colors_order)]
        R_value = current_color_as_list[0]
        G_value = current_color_as_list[1]
        B_value = current_color_as_list[2]

        current_color = Qt.QColor(R_value, G_value, B_value)
        self.curve_mag_list.append(Qwt.QwtPlotCurve('qplt_freq'))
        self.curve_mag_list[-1].attach(self.qplt_mag)
        self.curve_mag_list[-1].setPen(Qt.QPen(current_color))
        self.curve_mag_list[-1].setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(current_color),
                          Qt.QPen(current_color), Qt.QSize(3, 3)))
        self.curve_mag_list[-1].setRenderHint(
            Qwt.QwtPlotItem.RenderAntialiased)

        # Create the curve in the phase plot
        self.curve_phase_list.append(Qwt.QwtPlotCurve('qplt_freq'))
        self.curve_phase_list[-1].attach(self.qplt_phase)
        self.curve_phase_list[-1].setPen(Qt.QPen(current_color))
        self.curve_phase_list[-1].setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(current_color),
                          Qt.QPen(current_color), Qt.QSize(3, 3)))
        self.curve_phase_list[-1].setRenderHint(
            Qwt.QwtPlotItem.RenderAntialiased)

        self.updateGraph()
        return
예제 #3
0
    def __drawAddedzero_pole(self, showIt, pos):
        editcurve = ''
        for curve in self.__plot.itemList():
            if isinstance(curve, Qwt.QwtPlotCurve):
                if self.enableZeroadd:
                    if curve.symbol().style() == Qwt.QwtSymbol.Ellipse:
                        editcurve = curve
                if self.enablePoleadd:
                    if curve.symbol().style() == Qwt.QwtSymbol.XCross:
                        editcurve = curve
        if not editcurve:
            return

        if self.changeConjugate:
            extrapoints = 2
        else:
            extrapoints = 1

        xData = zeros(editcurve.dataSize() + extrapoints, Float)
        yData = zeros(editcurve.dataSize() + extrapoints, Float)

        for i in range(editcurve.dataSize()):
            xData[i] = editcurve.x(i)
            yData[i] = editcurve.y(i)
        xData[i + 1] = self.__plot.invTransform(editcurve.xAxis(), pos.x())
        yData[i + 1] = self.__plot.invTransform(editcurve.yAxis(), pos.y())

        if self.changeConjugate:
            xData[i + 2] = xData[i + 1]
            yData[i + 2] = -yData[i + 1]
            self.__addedcZero = i + 2

        editcurve.setData(xData, yData)

        self.__addedZero = i + 1
        symbol = Qwt.QwtSymbol(editcurve.symbol())
        newSymbol = Qwt.QwtSymbol(symbol)
        newSymbol.setPen(Qt.QPen(Qt.Qt.red))
        doReplot = self.__plot.autoReplot()

        self.__plot.setAutoReplot(False)
        editcurve.setSymbol(newSymbol)

        editcurve.draw(self.__addedZero, self.__addedZero)
        if self.changeConjugate:
            editcurve.draw(self.__addedcZero, self.__addedcZero)

        editcurve.setSymbol(symbol)
        self.__plot.setAutoReplot(doReplot)
        px = []
        py = []
        for c in self.__plot.itemList():
            if isinstance(c, Qwt.QwtPlotCurve):
                px.append([c.x(i) for i in range(c.dataSize())])
                py.append([c.y(i) for i in range(c.dataSize())])
        tp = (vectorize(complex)(px[0], py[0]), vectorize(complex)(px[1],
                                                                   py[1]))
        self.curveChanged.emit(tp)
        self.__showCursor(True)
예제 #4
0
    def __init__(self):
        QtGui.QMainWindow.__init__(self)
        '''
        self.view = pg.GraphicsView()
        self.graph = pg.PlotItem()
        self.view.setCentralWidget(self.graph)
        self.setCentralWidget(self.view)

        testx = np.random.rand(10)
        testy = np.random.rand(10)

        self.graph.plot(testx,testy,pen=None,symbol='o')
        '''

        self.qwtPlot = Qwt5.QwtPlot(self)
        self.setCentralWidget(self.qwtPlot)
        #self.qwtPlot.setGeometry(QtCore.QRect(260, 400, 581, 200))
        self.scatter = Qwt5.QwtPlotCurve('')
        self.scatter.attach(self.qwtPlot)
        self.scatter.setPen(QtGui.QPen(QtCore.Qt.NoPen))
        scatter_symbol = Qwt5.QwtSymbol(Qwt5.QwtSymbol.Ellipse,
                                        QtGui.QBrush(QtCore.Qt.red),
                                        QtGui.QPen(QtCore.Qt.red),
                                        QtCore.QSize(7, 7))
        self.scatter.setSymbol(scatter_symbol)

        self.scatterAll = Qwt5.QwtPlotCurve('')
        self.scatterAll.attach(self.qwtPlot)
        self.scatterAll.setPen(QtGui.QPen(QtCore.Qt.NoPen))
        scatter_symbol = Qwt5.QwtSymbol(Qwt5.QwtSymbol.Ellipse,
                                        QtGui.QBrush(QtCore.Qt.black),
                                        QtGui.QPen(QtCore.Qt.black),
                                        QtCore.QSize(3, 3))
        self.scatterAll.setSymbol(scatter_symbol)

        self.setGeometry(40, 40, 512, 512)

        self.cell_size = 32
        self.threshold = 200

        self.fof = fof.MedFastObjectFinder(self.cell_size, self.threshold)
        #self.setLayout(vbox)

        self.statusBar = QtGui.QStatusBar(self)
        self.setStatusBar(self.statusBar)

        self.allXs = np.array([])
        self.allYs = np.array([])
예제 #5
0
    def _initPlotEditors(self):
        """ """

        self.plot_editors = {}

        selection_highlighter_curve = qwt.QwtPlotCurve('selection highlight')
        selection_highlighter_curve.setStyle(
            qwt.QwtPlotCurve.NoCurve
        )  # Line Connection Type (Lines, NoCurve, Sticks, Steps)
        selection_highlighter_curve.setSymbol(
            qwt.QwtSymbol(
                qwt.QwtSymbol.
                Rect,  # Marker Type (None, Ellipse, Rect, Diamond)
                Qt.QBrush(
                    Qt.Qt.white
                ),  # Fill Color (Use "Qt.QBrush()" if you want transparent)
                Qt.QPen(
                    Qt.Qt.black, 1
                ),  # Edge Color & Edge Thickness (Use "Qt.QPen()" if you want transparent
                Qt.QSize(5,
                         5)))  # Marker Size (Horizontal Size, Vertical Size)
        selection_highlighter_curve.setVisible(False)
        selection_highlighter_curve.attach(self.qwtPlot)

        plot_editor = PlotEditor(selection_highlighter_curve,
                                 qwt.QwtPlot.xBottom, qwt.QwtPlot.yLeft,
                                 qwt.QwtPicker.PointSelection,
                                 qwt.QwtPlotPicker.NoRubberBand,
                                 qwt.QwtPicker.AlwaysOff,
                                 self.qwtPlot.canvas())

        plot_editor.setEnabled(False)

        self.plot_editors['qwtPlot'] = plot_editor
예제 #6
0
    def _initPlots(self):
        """ """

        # Initialize the plot canvas
        p = self.qwtPlot  # for short-hand notation
        p.setCanvasBackground(Qt.Qt.white)
        p.setAxisTitle(qwt.QwtPlot.xBottom, 'Time [s]')
        p.setAxisTitle(qwt.QwtPlot.yLeft, 'Current [mA]')
        p.setAxisAutoScale(qwt.QwtPlot.xBottom)
        p.setAxisAutoScale(qwt.QwtPlot.yLeft)
        p.setAutoReplot()

        # Initialize the curve representing the current history
        p.curve = qwt.QwtPlotCurve('Current [mA]')
        p.curve.setPen(Qt.QPen(Qt.Qt.red, 5, Qt.Qt.SolidLine))
        p.curve.setStyle(qwt.QwtPlotCurve.Lines)
        p.curve.setSymbol(
            qwt.QwtSymbol(qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.green),
                          Qt.QPen(Qt.Qt.black, 6), Qt.QSize(5, 5)))
        p.curve.setData(np.linspace(1, self.data.current_array_index + 1, 1),
                        self.data.current_array)
        p.curve.attach(self.qwtPlot)

        p.replot()

        self.plots = self.findChildren(qwt.QwtPlot)
예제 #7
0
 def __init__(self, *args):
     # Initialize some local variables
     self.__SIZE = 7
     self.__editable = False
     self.movingPoint = None
     self.pointX = empty(0)
     self.pointY = empty(0)
     self.markers = []
     self.dataX = None
     self.dataY = None
     self.__lagrangeUpdate()
     self.symbol = Qwt.QwtSymbol(
         Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.gray, Qt.Qt.SolidPattern),
         Qt.QPen(Qt.Qt.blue, 1, Qt.Qt.SolidLine, Qt.Qt.RoundCap,
                 Qt.Qt.RoundJoin), Qt.QSize(self.__SIZE, self.__SIZE))
     # Call parent constructor
     Plotter.__init__(self, *args)
     self.curve.setPen(Qt.QPen(Qt.Qt.red, 2))
     # Connect signals
     QtCore.QObject.connect(self.plot, QtCore.SIGNAL("mousePressed"),
                            self.mousePressed)
     QtCore.QObject.connect(self.plot, QtCore.SIGNAL("mouseReleased"),
                            self.mouseReleased)
     QtCore.QObject.connect(self.plot, QtCore.SIGNAL("mouseMove"),
                            self.mouseMove)
예제 #8
0
    def PlotLine(self,
                 plot,
                 x,
                 y,
                 color='k',
                 linestyle='-',
                 linethick=1,
                 symbol=None,
                 symbolsize=9,
                 symbolcolor=None,
                 symbolthick=1):
        cu = Qwt.QwtPlotCurve()
        cu.setPen(Qt.QPen(self.getColor(color)))
        if linestyle == '':
            cu.setStyle(Qwt.QwtPlotCurve.NoCurve)
        else:
            cu.setStyle(Qwt.QwtPlotCurve.Lines)

        if symbol == None or self.getSymbol(symbol) == None:
            pass
        else:
            scolor = self.getColor(color)
            cu.setSymbol(
                Qwt.QwtSymbol(self.getSymbol(symbol), Qt.QBrush(scolor),
                              Qt.QPen(scolor, symbolthick),
                              Qt.QSize(int(symbolsize), int(symbolsize))))

        cu.attach(plot)
        cu.setData(x, y)
        if hasattr(plot, 'zoomer'):  # need to make sure zoomer base is correct
            plot.zoomer.setZoomBase()  # note - calls pending replot anyway
        else:
            plot.replot()
def make():
    # create a plot with a white canvas
    demo = Qwt.QwtPlot(Qwt.QwtText("Errorbar Demonstation"))
    demo.setCanvasBackground(Qt.Qt.white)
    demo.plotLayout().setAlignCanvasToScales(True)

    grid = Qwt.QwtPlotGrid()
    grid.attach(demo)
    grid.setPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine))

    # calculate data and errors for a curve with error bars
    x = arange(0, 10.1, 0.5, Float)
    y = sin(x)
    dy = 0.2 * abs(y)
    # dy = (0.15 * abs(y), 0.25 * abs(y)) # uncomment for asymmetric error bars
    dx = 0.2  # all error bars the same size
    errorOnTop = False  # uncomment to draw the curve on top of the error bars
    # errorOnTop = True # uncomment to draw the error bars on top of the curve
    curve = ErrorBarPlotCurve(
        x=x,
        y=y,
        dx=dx,
        dy=dy,
        curvePen=Qt.QPen(Qt.Qt.black, 2),
        curveSymbol=Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.red),
                                  Qt.QPen(Qt.Qt.black, 2), Qt.QSize(9, 9)),
        errorPen=Qt.QPen(Qt.Qt.blue, 2),
        errorCap=10,
        errorOnTop=errorOnTop,
    )
    curve.attach(demo)
    demo.resize(400, 300)
    demo.show()
    return demo
예제 #10
0
파일: hlaPlot.py 프로젝트: huyong1979/aphla
    def onMarkerActionTriggered(self):
        """"""

        sender = self.sender()
        markerStr = str(sender.text())

        c = self.selected_curve

        currentSymbol = c.symbol()

        if markerStr == 'None':
            QwtSymbol = Qwt.QwtSymbol.NoSymbol
        elif markerStr == 'rect':
            QwtSymbol = Qwt.QwtSymbol.Rect
        elif markerStr == 'triangle':
            QwtSymbol = Qwt.QwtSymbol.Triangle
        elif markerStr == 'o':
            QwtSymbol = Qwt.QwtSymbol.Ellipse
        else:
            raise ValueError('Unexpected marker string.')

        c.setSymbol( Qwt.QwtSymbol(QwtSymbol,
                                   currentSymbol.brush(),
                                   currentSymbol.pen(),
                                   currentSymbol.size()) )

        c.plot().replot()
예제 #11
0
    def __init__(self, *args):
        Qt.QMainWindow.__init__(self, *args)

        self.plot = Qwt.QwtPlot(self)
        self.plot.setTitle("A Simple Map Demonstration")
        self.plot.setCanvasBackground(Qt.Qt.white)
        self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, "x")
        self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, "y")
        self.plot.setAxisScale(Qwt.QwtPlot.xBottom, 0.0, 1.0)
        self.plot.setAxisScale(Qwt.QwtPlot.yLeft, 0.0, 1.0)
        self.setCentralWidget(self.plot)

        # Initialize map data
        self.count = self.i = 1000
        self.xs = zeros(self.count, Float)
        self.ys = zeros(self.count, Float)

        self.kappa = 0.2

        self.curve = Qwt.QwtPlotCurve("Map")
        self.curve.attach(self.plot)

        self.curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.red),
                          Qt.QPen(Qt.Qt.blue), Qt.QSize(5, 5)))

        self.curve.setPen(Qt.QPen(Qt.Qt.cyan))

        toolBar = Qt.QToolBar(self)
        self.addToolBar(toolBar)

        toolBar.addWidget(Qt.QLabel("Count:", toolBar))
        sizeCounter = Qwt.QwtCounter(toolBar)
        toolBar.addWidget(sizeCounter)
        toolBar.addSeparator()
        sizeCounter.setRange(0, 1000000, 100)
        sizeCounter.setValue(self.count)
        sizeCounter.setNumButtons(3)
        self.connect(sizeCounter, Qt.SIGNAL('valueChanged(double)'),
                     self.setCount)

        toolBar.addWidget(Qt.QLabel("Ticks (ms):", toolBar))
        tickCounter = Qwt.QwtCounter(toolBar)
        toolBar.addWidget(tickCounter)
        toolBar.addSeparator()
        # 1 tick = 1 ms, 10 ticks = 10 ms (Linux clock is 100 Hz)
        self.ticks = 10
        tickCounter.setRange(0, 1000, 1)
        tickCounter.setValue(self.ticks)
        tickCounter.setNumButtons(3)
        self.connect(tickCounter, Qt.SIGNAL('valueChanged(double)'),
                     self.setTicks)
        self.tid = self.startTimer(self.ticks)

        self.timer_tic = None
        self.user_tic = None
        self.system_tic = None

        self.plot.replot()
예제 #12
0
 def setLineStyle(self, item, color=None):
     if color is None:
         color = QColor(self.colors.next())
     item.setPen(QPen(color, 1))
     item.setSymbol(
         Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, QBrush(color), QPen(color, 1),
                       QSize(5, 5)))
     self.replot()
def make():
    demo = Qwt.QwtPlot()
    demo.setTitle('Symbols Demo')
    curve = QwtPlotCurveSizes()
    curve.attach(demo)
    curve_a = QwtPlotCurveSizes()
    curve_a.attach(demo)
    # need to create a default symbol for the curves due to inner
    # workings of QwtCurve
    curve.setSymbol(
        Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.black),
                      Qt.QPen(Qt.Qt.black), Qt.QSize(5, 5)))
    curve.setPen(Qt.QPen(Qt.Qt.blue, 2))
    curve_a.setSymbol(
        Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.black),
                      Qt.QPen(Qt.Qt.black), Qt.QSize(5, 5)))
    curve_a.setPen(Qt.QPen(Qt.Qt.blue, 2))

    # create some data
    x_array = numpy.zeros(20, numpy.float32)
    y_array = numpy.zeros(20, numpy.float32)
    symbol_sizes = numpy.zeros(20, numpy.int32)
    symbolList = []
    for i in range(20):
        x_array[i] = 1.0 * i
        y_array[i] = 2.0 * i
        symbol_sizes[i] = 3 + i
        if i % 2 == 0:
            symbolList.append(
                Qwt.QwtSymbol(Qwt.QwtSymbol.UTriangle, Qt.QBrush(Qt.Qt.black),
                              Qt.QPen(Qt.Qt.black), Qt.QSize(3 + i, 3 + i)))
        else:
            symbolList.append(
                Qwt.QwtSymbol(Qwt.QwtSymbol.DTriangle, Qt.QBrush(Qt.Qt.red),
                              Qt.QPen(Qt.Qt.red), Qt.QSize(3 + i, 3 + i)))
    curve.setData(x_array, y_array, symbol_sizes)
    x_array = x_array + 10
    curve_a.setData(x_array, y_array)
    curve_a.setSymbolList(symbolList)
    grid = Qwt.QwtPlotGrid()
    grid.setMajPen(Qt.QPen(Qt.Qt.black, 0, Qt.Qt.DotLine))
    grid.setMinPen(Qt.QPen(Qt.Qt.gray, 0, Qt.Qt.DotLine))

    grid.attach(demo)
    demo.replot()
    return demo
예제 #14
0
    def __insertPole(self, color, px, py):
        curve = Qwt.QwtPlotCurve()
        curve.attach(self)

        curve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.XCross, Qt.QBrush(Qt.Qt.gray),
                          Qt.QPen(color), Qt.QSize(7, 7)))
        curve.setData(px, py)
예제 #15
0
    def measDispersion(self):
        p = ApMdiSubPlot(live=False)
        p.setAttribute(Qt.WA_DeleteOnClose)
        curves = [
            p.aplot.curve1,
            p.aplot.addCurve(),  # x and xref
            p.aplot.addCurve(),
            p.aplot.addCurve()  # y and yref
        ]
        for curv in curves:
            curv.setStyle(Qwt.QwtPlotCurve.Lines)
        curves[0].setPen(QPen(Qt.red, 1.3, Qt.DashLine))
        curves[1].setPen(QPen(Qt.red, 1.5))
        curves[2].setPen(QPen(Qt.blue, 1.3, Qt.DashLine))
        curves[3].setPen(QPen(Qt.blue, 1.5))
        curves[2].setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Triangle, QBrush(Qt.blue),
                          QPen(Qt.black, 1), QSize(8, 8)))

        #p.aplot.curve1.setStyle(Qwt.QwtPlotCurve.)

        #p.setWindowTitle("[%s.%s] %s %s" % (mach, lat, title, fld))
        self.mdiarea.addSubWindow(p)
        #print "Show"
        p.show()
        #plots.append(p)

        #bpms = ap.getGroupMembers(['C20', 'BPM']) + \
        #    ap.getGroupMembers(['C21', 'BPM'])
        bpms = ap.getElements('BPM')
        xl = min([q.sb for q in bpms])
        xr = max([q.se for q in bpms])
        s, btx, bty = [], [], []
        try:
            etaref = ap.getEta([q.name for q in bpms], spos=True)
            curves[1].setData(etaref[:, -1], etaref[:, 0], None)
            curves[3].setData(etaref[:, -1], etaref[:, 1], None)

            fullmagprof = ap.machines.getLattice().getBeamlineProfile()
            magprof = [v for v in fullmagprof if max(v[0]) > xl \
                           and min(v[0]) < xr]
            p.aplot.setMagnetProfile(magprof)
            #p.wid.autoScaleXY()
            p.aplot.replot()

            disp = ap.measDispersion(bpms, verbose=2)
            curves[0].setData(disp[:, -1], disp[:, 0], None)
            curves[2].setData(disp[:, -1], disp[:, 1], None)
            p.wid.autoScaleXY()
            p.aplot.replot()
            _logger.info("dispersion eta measured")
        except:
            _logger.error("error at measEta")
            raise

        _logger.info("finished eta measurement.")
예제 #16
0
    def __insertZero(self, color, px, py):

        curve = Qwt.QwtPlotCurve()
        curve.attach(self)

        curve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.gray),
                          Qt.QPen(color), Qt.QSize(10, 10)))
        curve.setData(px, py)
예제 #17
0
 def _set_curve_point_properties(self, curve, properties_in):
     # make a copy of properties so we can pop out elements
     #   without changing the original
     properties = properties_in.copy()
     new_symbol = Qwt.QwtSymbol()
     # pen to draw the symbol outline
     new_pen = QtGui.QPen()
     if 'line_color' in properties:
         value = properties.pop('line_color')
         new_pen.setColor(QtGui.QColor(value))
     if 'line_width' in properties:
         value = properties.pop('line_width')
         new_pen.setWidth(value)
     if 'fill_color' in properties:
         value = properties.pop('fill_color')
         # brush to fill the symbol interior
         new_brush = QtGui.QBrush(QtGui.QColor(value))
     if 'symbol' in properties:
         s = properties.pop('symbol')
         if s == 'square':
             new_symbol.setStyle(Qwt.QwtSymbol.Rect)
         elif s == 'diamond':
             new_symbol.setStyle(Qwt.QwtSymbol.Diamond)
         elif s == 'triangle':
             new_symbol.setStyle(Qwt.QwtSymbol.Triangle)
         elif s == 'triangle_down':
             new_symbol.setStyle(Qwt.QwtSymbol.DTriangle)
         elif s == 'triangle_up':
             new_symbol.setStyle(Qwt.QwtSymbol.UTriangle)
         elif s == 'triangle_left':
             new_symbol.setStyle(Qwt.QwtSymbol.LTriangle)
         elif s == 'triangle_right':
             new_symbol.setStyle(Qwt.QwtSymbol.RTriangle)
         elif s == 'cross':
             new_symbol.setStyle(Qwt.QwtSymbol.Cross)
         elif s == 'cross_x':
             new_symbol.setStyle(Qwt.QwtSymbol.XCross)
         elif s == 'line_horizontal':
             new_symbol.setStyle(Qwt.QwtSymbol.HLine)
         elif s == 'line_vertical':
             new_symbol.setStyle(Qwt.QwtSymbol.VLine)
         elif s == 'star':
             new_symbol.setStyle(Qwt.QwtSymbol.Star1)
         elif s == 'star_2':
             new_symbol.setStyle(Qwt.QwtSymbol.Star2)
         elif s == 'hexagon':
             new_symbol.setStyle(Qwt.QwtSymbol.Hexagon)
         else:  # 'circle'
             new_symbol.setStyle(Qwt.QwtSymbol.Ellipse)
     if 'size' in properties:
         value = properties.pop('size')
         new_symbol.setSize(value)
     new_symbol.setPen(new_pen)
     new_symbol.setBrush(new_brush)
     curve.setSymbol(new_symbol)
    def __showCursor(self, showIt):
        curve = self.__selectedCurve
        if not curve:
            return

        # Use copy constructors to defeat the reference semantics.
        symbol = Qwt.QwtSymbol(curve.symbol())
        newSymbol = Qwt.QwtSymbol(symbol)
        if showIt:
            newSymbol.setBrush(symbol.brush().color().dark(150))

        doReplot = self.__plot.autoReplot()

        self.__plot.setAutoReplot(False)
        curve.setSymbol(newSymbol)

        curve.draw(self.__selectedPoint, self.__selectedPoint)

        curve.setSymbol(symbol)
        self.__plot.setAutoReplot(doReplot)
예제 #19
0
    def on_show(self):
        self.plot.clear()
        self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'x -->')
        self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'y -->')

        grid = Qwt.QwtPlotGrid()
        pen = QPen(Qt.DotLine)
        pen.setColor(Qt.black)
        pen.setWidth(0)
        grid.setPen(pen)
        grid.attach(self.plot)

        has_series = False

        coloriter = iter(COLORS)

        for row in range(self.series_list_model.rowCount()):
            model_index = self.series_list_model.index(row, 0)
            checked = self.series_list_model.data(
                model_index, Qt.CheckStateRole) == QVariant(Qt.Checked)
            name = str(self.series_list_model.data(model_index).toString())

            if checked:
                has_series = True

                x_from = self.from_spin.value()
                x_to = self.to_spin.value()
                series = self.data.get_series_data(name)[x_from:x_to + 1]

                color = QColor(coloriter.next())

                curve = Qwt.QwtPlotCurve(name)
                pen = QPen(color)
                pen.setWidth(2)
                curve.setPen(pen)
                curve.setData(range(len(series)), series)

                curve.setSymbol(
                    Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, QBrush(color),
                                  QPen(color), QSize(5, 5)))

                curve.attach(self.plot)

        if has_series and self.legend_cb.isChecked():
            self.plot.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend)
        else:
            self.plot.insertLegend(None)

        self.plot.replot()
    def __insertCurve(self, orientation, color, base):
        curve = Qwt.QwtPlotCurve()
        curve.attach(self)

        curve.setPen(Qt.QPen(color))
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(Qt.Qt.gray),
                          Qt.QPen(color), Qt.QSize(8, 8)))

        fixed = base * ones(10, Float)
        changing = arange(0, 95.0, 10.0, Float) + 5.0
        if orientation == Qt.Qt.Horizontal:
            curve.setData(changing, fixed)
        else:
            curve.setData(fixed, changing)
예제 #21
0
파일: plot.py 프로젝트: wal613/peach
    def __init__(self, xlim, ylim, *args):
        '''
        Initializes the graph plotting. The usual parameters are available.

        :Parameters:
          nplots
            Number of plots in the same window.
        '''
        Qwt.QwtPlot.__init__(self, *args)
        self.set_scale(xlim, ylim)

        self.setCanvasBackground(Qt.white)
        grid = Qwt.QwtPlotGrid()
        grid.attach(self)
        grid.setMajPen(QPen(Qt.black, 0, Qt.DotLine))

        self.lr = Qwt.QwtPlotCurve('')
        self.lr.attach(self)
        self.lr.setPen(QPen(Qt.darkYellow))
        self.lr.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)

        scatter_symbol = Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, QBrush(Qt.white),
                                       QPen(Qt.darkCyan), QSize(9, 9))
        self.scatter = Qwt.QwtPlotCurve('')
        self.scatter.attach(self)
        self.scatter.setPen(QPen(Qt.NoPen))
        self.scatter.setSymbol(scatter_symbol)
        self.scatter.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)

        example_symbol = Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, QBrush(Qt.red),
                                       QPen(Qt.red), QSize(9, 9))
        self.example = Qwt.QwtPlotCurve('')
        self.example.attach(self)
        self.example.setPen(QPen(Qt.NoPen))
        self.example.setSymbol(example_symbol)
        self.example.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
예제 #22
0
    def __init__(
            self,
            x=[],
            y=[],
            dx=None,
            dy=None,
            curvePen=Qt.QPen(Qt.Qt.NoPen),
            curveStyle=Qwt.QwtPlotCurve.Lines,
            curveSymbol=Qwt.QwtSymbol(),
            errorPen=Qt.QPen(Qt.Qt.NoPen),
            errorCap=0,
            errorOnTop=False,
    ):
        """A curve of x versus y data with error bars in dx and dy.

        Horizontal error bars are plotted if dx is not None.
        Vertical error bars are plotted if dy is not None.

        x and y must be sequences with a shape (N,) and dx and dy must be
        sequences (if not None) with a shape (), (N,), or (2, N):
        - if dx or dy has a shape () or (N,), the error bars are given by
          (x-dx, x+dx) or (y-dy, y+dy),
        - if dx or dy has a shape (2, N), the error bars are given by
          (x-dx[0], x+dx[1]) or (y-dy[0], y+dy[1]).

        curvePen is the pen used to plot the curve
        
        curveStyle is the style used to plot the curve
        
        curveSymbol is the symbol used to plot the symbols
        
        errorPen is the pen used to plot the error bars
        
        errorCap is the size of the error bar caps
        
        errorOnTop is a boolean:
        - if True, plot the error bars on top of the curve,
        - if False, plot the curve on top of the error bars.
        """

        Qwt.QwtPlotCurve.__init__(self)
        self.setData(x, y, dx, dy)
        self.setPen(curvePen)
        self.setStyle(curveStyle)
        self.setSymbol(curveSymbol)
        self.errorPen = errorPen
        self.errorCap = errorCap
        self.errorOnTop = errorOnTop
예제 #23
0
파일: hlaPlot.py 프로젝트: huyong1979/aphla
    def onMarkerSizeActionTriggered(self):
        """"""

        sender = self.sender()
        markerSize = int(str(sender.text()))

        c = self.selected_curve

        currentSymbol = c.symbol()

        c.setSymbol( Qwt.QwtSymbol(currentSymbol.style(),
                                   currentSymbol.brush(),
                                   currentSymbol.pen(),
                                   Qt.QSize(markerSize,markerSize)) )

        c.plot().replot()
예제 #24
0
파일: hlaPlot.py 프로젝트: huyong1979/aphla
    def onMarkerFaceColorActionTriggered(self):
        """"""

        sender = self.sender()
        colorString = str(sender.text())

        c = self.selected_curve

        currentSymbol = c.symbol()
        currentFaceBrush = currentSymbol.brush()

        c.setSymbol( Qwt.QwtSymbol(currentSymbol.style(),
                                   Qt.QBrush(getattr(Qt.Qt,colorString)),
                                   currentSymbol.pen(),
                                   currentSymbol.size()) )

        c.plot().replot()
예제 #25
0
    def onMarkerEdgeWidthActionTriggered(self):
        """"""

        sender = self.sender()
        edgeWidth = int(str(sender.text()))

        c = self.selected_curve

        currentSymbol = c.symbol()
        currentEdgePen = currentSymbol.pen()

        c.setSymbol(
            Qwt.QwtSymbol(currentSymbol.style(), currentSymbol.brush(),
                          Qt.QPen(currentEdgePen.color(), edgeWidth),
                          currentSymbol.size()))

        c.plot().replot()
예제 #26
0
    def __init__(self, *args):
        # call base class constructor
        Qwt.QwtPlot.__init__(self, *args)

        self.setCanvasBackground(Qt.Qt.white)

        # initialize data
        self.x = np.arange(0.0, 100.1, 0.5)
        self.y = np.zeros(len(self.x), np.float)
        self.z = np.zeros(len(self.x), np.float)

        # title
        self.setTitle("A Moving QwtPlot Demonstration")
        # legend
        self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend)

        # plot going right
        self.curveR = Qwt.QwtPlotCurve("Data Moving Right")
        self.curveR.attach(self)
        # plot going left
        self.curveL = Qwt.QwtPlotCurve("Data Moving Left")
        self.curveL.attach(self)

        # accent on each data point of plot going left
        self.curveL.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(),
                          Qt.QPen(Qt.Qt.yellow), Qt.QSize(7, 7)))

        # line colors
        self.curveR.setPen(Qt.QPen(Qt.Qt.red))
        self.curveL.setPen(Qt.QPen(Qt.Qt.blue))

        # set a line marker at zero
        mY = Qwt.QwtPlotMarker()
        mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop)
        mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
        mY.setYValue(0.0)
        mY.attach(self)

        # axis titles
        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (seconds)")
        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Values")

        self.phase = 0.0
예제 #27
0
    def initCurve(self):
        """(Re)initialize the curve on the plot """

        # (re)Initialize data
        self.x = []
        self.y = []

        if self.curve is not None:
            self.curve.detach()
            del self.curve

        self.curve = Qwt.QwtPlotCurve()
        self.curve.attach(self)

        self.curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, Qt.QBrush(),
                          Qt.QPen(Qt.Qt.green), Qt.QSize(7, 7)))

        self.curve.setPen(Qt.QPen(Qt.Qt.red))
예제 #28
0
 def addPlotMarker(self, xPosition, label, samplecounter):
     ''' Create and add trigger event marker
     @param xPosition: horizontal screen position
     @param label: label string
     @param samplecounter: total sample position
     '''
     margin = float(len(self.traces) + 1) / 10.0 / 3.0  # 2.5% bottom margin
     sym = Qwt.QwtSymbol()
     sym.setStyle(Qwt.QwtSymbol.VLine)
     sym.setSize(20)
     mX = Qwt.QwtPlotMarker()
     mX.setLabel(Qwt.QwtText(label))
     mX.setLabelAlignment(Qt.Qt.AlignHCenter | Qt.Qt.AlignBottom)
     mX.setLineStyle(Qwt.QwtPlotMarker.NoLine)
     mX.setXValue(xPosition)
     mX.setYValue(-1.0 + margin)
     mX.setSymbol(sym)
     mX.sampleCounter = samplecounter
     mX.attach(self)
     self.plot_markers.append(mX)
예제 #29
0
    def create_plot(self):

        plot = Qwt.QwtPlot(self)
        plot.setCanvasBackground(Qt.black)
        plot.setAxisTitle(Qwt.QwtPlot.xBottom, 'Frame')
        plot.setAxisScale(Qwt.QwtPlot.xBottom, 0, 10, 1)
        plot.setAxisTitle(Qwt.QwtPlot.yLeft, 'Number of Cells')
        plot.setAxisScale(Qwt.QwtPlot.yLeft, 0, 200, 40)
        plot.replot()

        curve = Qwt.QwtPlotCurve('')
        curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        pen = QPen(QColor('limegreen'))
        pen.setWidth(2)
        curve.setPen(pen)
        curve.attach(plot)
        curve.setSymbol(
            Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse, pen.color(), pen.color(),
                          QSize(10, 10)))

        return plot, curve
예제 #30
0
   def __init__(self, multimeter, *args):
       Qwt.QwtPlot.__init__(self, *args)

       self.multimeter = multimeter

       self.setCanvasBackground(Qt.Qt.white)
       self.alignScales()

       # Initialize data
       self.x = arange(0.0, 100.1, 0.5)
       self.y = zeros(len(self.x), Float)
       #self.z = zeros(len(self.x), Float)

       self.setTitle("A Moving QwtPlot Demonstration")
       self.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend);

       #self.curveR = Qwt.QwtPlotCurve("Data Moving Right")
       #self.curveR.attach(self)
       self.curveL = Qwt.QwtPlotCurve("Data Moving Left")
       self.curveL.attach(self)

       self.curveL.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
                                       Qt.QBrush(),
                                       Qt.QPen(Qt.Qt.yellow),
                                       Qt.QSize(7, 7)))

       #self.curveR.setPen(Qt.QPen(Qt.Qt.red))
       self.curveL.setPen(Qt.QPen(Qt.Qt.blue))

       mY = Qwt.QwtPlotMarker()
       mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop)
       mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
       mY.setYValue(0.0)
       mY.attach(self)

       self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (seconds)")
       self.setAxisTitle(Qwt.QwtPlot.yLeft, "Values")

       self.startTimer(50)
       self.phase = 0.0