예제 #1
0
파일: __init__.py 프로젝트: ess-dmsc/nicos
    def __init__(self, widget, xdual=False, ydual=False, **kwds):
        PlotAxes.__init__(self, **kwds)
        self.widget = widget
        self.xdual, self.ydual = xdual, ydual

        self.drawxylines = False
        self.xlines = []  # draw vertical lines at x-coordinates
        self.ylines = []  # draw horizontal lines at y-coordinates
        self.xylinecolor = GRCOLORS['magenta']
예제 #2
0
파일: __init__.py 프로젝트: ess-dmsc/nicos
 def drawGR(self):
     lwidth = gr.inqlinewidth()
     gr.setlinewidth(0.)
     PlotAxes.drawGR(self)
     if self.drawxylines:
         xmin, xmax, ymin, ymax = self.getWindow()
         linecolor = gr.inqlinecolorind()
         gr.setlinecolorind(self.xylinecolor)
         for xpos in self.xlines:
             gr.polyline([xpos, xpos], [ymin, ymax])
         for ypos in self.ylines:
             gr.polyline([xmin, xmax], [ypos, ypos])
         gr.setlinecolorind(linecolor)
     gr.setlinewidth(lwidth)
예제 #3
0
파일: qtgrtimer.py 프로젝트: Juanlu001/gr
 def doAutoScale(self, curvechanged=None):
     xmin, xmax, ymin, ymax = PlotAxes.doAutoScale(self, curvechanged)
     bxmin, _bxmax, _bymin, _bymax = self.getBoundingBox()
     if xmin < bxmin:
         xmin = bxmin
     self.setWindow(xmin, xmax, ymin, ymax)
     return self.getWindow()
 def doAutoScale(self, curvechanged=None):
     xmin, xmax, ymin, ymax = PlotAxes.doAutoScale(self, curvechanged)
     bxmin, _bxmax, _bymin, _bymax = self.getBoundingBox()
     if xmin < bxmin:
         xmin = bxmin
     self.setWindow(xmin, xmax, ymin, ymax)
     return self.getWindow()
예제 #5
0
파일: __init__.py 프로젝트: ess-dmsc/nicos
    def setWindow(self, xmin, xmax, ymin, ymax):
        res = PlotAxes.setWindow(self, xmin, xmax, ymin, ymax)

        # use 2 ** n for tickmarks

        def tick(amin, amax):
            if amin > amax:
                amax, amin = amin, amax
            # calculate next (lower) power of two (2**n) for the
            # full range [amax - amin] and divide this:
            #
            #           ld(amax - amin)  :  number of powers of two => exponent
            #       int(        "      ) :  integral part
            #                               (cut off fractions => floor)
            # 2 ** (  "         "       ):  next lower power of two (2**n)
            # 2 ** (   int( ... ) - 4)  ):  - 4 => divided by 2 ** 4
            return 2**(int(math.log(max(amax - amin, 0.1), 2)) - 4)

        if self.xdual:
            self.xtick = tick(xmin, xmax)
            self.majorx = 4
        if self.ydual:
            self.ytick = tick(ymin, ymax)
            self.majory = 4
        return res
예제 #6
0
파일: plots.py 프로젝트: umithardal/nicos
 def doAutoScale(self, curvechanged=None):
     vc = self.getVisibleCurves() or self.getCurves()
     original_win = self.getWindow()
     if original_win and curvechanged:
         xmin, xmax = original_win[:2]
         cmin, cmax = vc.xmin, vc.xmax
         new_x = curvechanged.x[-1]
         if cmax > xmax and new_x > xmax:
             return original_win
         elif cmin < xmin and new_x < xmin:
             return original_win
     return PlotAxes.doAutoScale(self, curvechanged)
예제 #7
0
if __name__ == "__main__":
    import sys
    from gr import pygr
    logging.basicConfig(level=logging.CRITICAL)
    for name in [__name__, pygr.base.__name__, pygr.__name__]:
        logging.getLogger(name).setLevel(logging.DEBUG)
    app = QtGui.QApplication(sys.argv)
    grw = InteractiveGRWidget()
    grw.resize(QtCore.QSize(500, 500))
    viewport = [0.1, 0.9, 0.1, 0.88]

    x = [-3.3 + t * .1 for t in range(66)]
    y = [t**5 - 13 * t**3 + 36 * t for t in x]

    n = 100
    pi2_n = 2. * math.pi / n
    x2 = [i * pi2_n for i in range(0, n + 1)]
    y2 = map(lambda xi: math.sin(xi), x2)

    plot = Plot(viewport).addAxes(PlotAxes().plot(x, y),
                                  PlotAxes().plot(x2, y2))
    plot.title, plot.subTitle = "foo", "bar"
    plot.xlabel, plot.ylabel = "x", "f(x)"

    grw.addPlot(plot)
    grw.show()
    grw.update()

    sys.exit(app.exec_())
예제 #8
0
 def plot(self, *args, **kwargs):
     plot = Plot()
     axes = PlotAxes(plot.viewport)
     axes.plot(*args, **kwargs)
     plot.addAxes(axes)
     return self.addPlot(plot)
예제 #9
0
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                "qtgrdemo.ui"), self)

        dictPrintType = dict(gr.PRINT_TYPE)
        map(dictPrintType.pop, [gr.PRINT_JPEG, gr.PRINT_TIF])
        self._saveTypes = (";;".join(dictPrintType.values()) + ";;" +
                           ";;".join(gr.GRAPHIC_TYPE.values()))
        self._saveName = None
        self._title = unicode(self.windowTitle())
        self._startupTime = time.time()

        self._chkLogX.stateChanged.connect(self._logXClicked)
        self._chkLogY.stateChanged.connect(self._logYClicked)
        self._chkGrid.stateChanged.connect(self._gridClicked)
        self._chkErr.stateChanged.connect(self._errorsClicked)
        self._chkKeepRatio.stateChanged.connect(self._keepRatioClicked)
        self._btnReset.clicked.connect(self._resetClicked)
        self._btnPick.clicked.connect(self._pickClicked)
        self._shell.returnPressed.connect(self._shellEx)
        self._actionSave.triggered.connect(self.save)
        self._actionPrint.triggered.connect(self.printGR)
        self._gr.logXinDomain.connect(self._logXinDomain)
        self._gr.logYinDomain.connect(self._logYinDomain)
        self._gr.modePick.connect(self._pickModeChanged)

        guiConn = GUIConnector(self._gr)
        guiConn.connect(MouseEvent.MOUSE_MOVE, self.mouseMoveGr)
        guiConn.connect(PickEvent.PICK_PRESS, self.pointPickGr)
        guiConn.connect(LegendEvent.ROI_CLICKED, self.legendClick)
        guiConn.connect(LegendEvent.ROI_OVER, self.legendOver)

        x = [-3.3 + t * .1 for t in range(66)]
        y = [t ** 5 - 13 * t ** 3 + 36 * t for t in x]
        x2 = [-3.5 + i * .5 for i in range(0, 15)]
        y2 = x2

        dneg = map(lambda y: y - 0.25 * abs(y), y)
        dpos = map(lambda y: y + 0.25 * abs(y), y)
        self._errBar = ErrorBar(x, y, dneg, dpos)

        self._curveFoo = PlotCurve(x, y, legend="foo bar")
        axes = PlotAxes().addCurves(self._curveFoo)
        axes.setXtickCallback(self._xtickCallBack)
        self._plot = Plot((.1, .92, .2, .88)).addAxes(axes,
                                    PlotAxes(drawX=False).plot(x2, y2))
        self._plot.offsetXLabel = -.1
        self._plot2 = Plot((.1, .95, .15, .88)).addAxes(PlotAxes().addCurves(PlotCurve(x2, y2,
                                                           legend="second")))

        self._plot.title = "QtGR Demo"
        self._plot.subTitle = "Multiple Axes Example"
        self._plot.xlabel = "x"
        self._plot.ylabel = "f(x)"
        self._plot.setLegend(True)
        self._gr.addPlot(self._plot)

        self._plot2.title = "Second Widget"
        self._plot2.subTitle = "Linear Example (less interactive)"
        self._plot2.xlabel = "x2"
        self._plot2.ylabel = "f2(x2)"
        self._plot2.setLegend(True)
        self._plot2.setGrid(False)
        self._gr2.addPlot(self._plot2)
예제 #10
0
    def __init__(self, *args, **kwargs):
        while not shared_memory['data_fresh']:
            pass
        super(MainWindow, self).__init__(*args, **kwargs)
        uic.loadUi(os.path.join(os.path.dirname(os.path.realpath(__file__)),
                                "second.ui"), self) 
        self.monitor_mode = False
        self.state = 'Connecting...'
        self.prev_time = time.time()

        self._heat_capacity_spin.valueChanged.connect(self.updateHeatCapacity)
        self._heat_capacity_spin.setDecimals(4)
        self._heat_capacity_spin.setMaximum(15.00) # Will we ever heat hydrogen?
        self._heat_capacity_spin.setSingleStep(0.0001)

        self._mass_spin.valueChanged.connect(self.updateMass)
        self._mass_spin.setDecimals(4)
        self._mass_spin.setMaximum(1000.00) 
        self._mass_spin.setSingleStep(0.0001)

        self._emissivity_spin.valueChanged.connect(self.updateEmissivity)
        self._emissivity_spin.setDecimals(4)
        self._emissivity_spin.setMaximum(1.00)
        self._emissivity_spin.setSingleStep(0.0001)

        self._area_spin.valueChanged.connect(self.updateArea)
        self._area_spin.setDecimals(4)
        self._area_spin.setMaximum(1000.00) 
        self._area_spin.setSingleStep(0.0001)

        self._resistance_spin.valueChanged.connect(self.updateResistance)
        self._resistance_spin.setDecimals(1)
        self._resistance_spin.setMaximum(1000.0) 
        self._resistance_spin.setSingleStep(0.1)

        self._voltage_spin.valueChanged.connect(self.updateVoltage)
        self._voltage_spin.setDecimals(2)
        self._voltage_spin.setMaximum(1000.00) 
        self._voltage_spin.setSingleStep(0.01)

        self._p_spin.valueChanged.connect(self.updateP)
        self._p_spin.setDecimals(4)
        self._p_spin.setMaximum(2.00) 
        self._p_spin.setSingleStep(0.0001)

        self._i_spin.valueChanged.connect(self.updateI)
        self._i_spin.setDecimals(4)
        self._i_spin.setMaximum(2.00) 
        self._i_spin.setSingleStep(0.0001)

        self._d_spin.valueChanged.connect(self.updateD)
        self._d_spin.setDecimals(4)
        self._d_spin.setMaximum(2.00) 
        self._d_spin.setSingleStep(0.0001)

        self._target_spin.valueChanged.connect(self.updateTarget)
        self._target_spin.setDecimals(2)
        self._target_spin.setMaximum(500.00) 
        self._target_spin.setSingleStep(0.01)

 
        self._monitor_check.stateChanged.connect(self.updateMonitor)
        self._btn_start.clicked.connect(self.startProcess)
        self._btn_stop.clicked.connect(self.stopProcess)
        self._state_out_label.setText(self.state)

        try:
          self._heat_capacity_spin.setValue(shared_memory['heatCapacity'])
          self._mass_spin.setValue(shared_memory['mass'])
          self._emissivity_spin.setValue(shared_memory['emissivity'])
          self._area_spin.setValue(shared_memory['area'])
          self._resistance_spin.setValue(shared_memory['resistance'])
          self._voltage_spin.setValue(shared_memory['voltage'])
          self._p_spin.setValue(shared_memory['p'])
          self._i_spin.setValue(shared_memory['i'])
          self._d_spin.setValue(shared_memory['d'])
        except:
           pass

        # palette = self._ambient_lcd.palette()
        # # foreground color
        # palette.setColor(palette.WindowText, QtGui.QColor(0, 0, 0))
        # # background color
        # palette.setColor(palette.Background, QtGui.QColor(0, 0, 0))
        # # "light" border
        # # palette.setColor(palette.Light, QtGui.QColor(255, 0, 0))
        # # "dark" border
        # palette.setColor(palette.Dark, QtGui.QColor(0, 0, 0))
        # # set the palette
        # self._ambient_lcd.setPalette(palette)
        # self._bath_lcd.setPalette(palette)
        # self._ambient_lcd.display(0.0)
        # self._bath_lcd.display(0.0)

        x = [1.0]
        y = [shared_memory['bath_temp']]
        xe = [1.0]
        ye = [shared_memory['env_temp']]

        viewport = [0.1, 0.95, 0.1, 0.95]

        self.env_curve = PlotCurve(xe, ye, legend = "Environment")
        self.env_curve.linetype = gr.LINETYPE_DASHED
        self.env_curve.linecolor = 7

        self.bath_curve = PlotCurve(x, y, legend = "Bath Medium")

        axes = PlotAxes(viewport)
        # axes.addCurves(self.env_curve)
        axes.addCurves(self.bath_curve)
        self._plot = Plot(viewport).addAxes(axes)
        self._plot.title = "System Temperatures"
        #self._plot.subTitle = "live data"
        self._plot.xlabel = "Seconds"
        self._plot.ylabel = "Celsius"
        self._plot.setLegend(True)
        self._plot.autoscale = PlotAxes.SCALE_X | PlotAxes.SCALE_Y
        self._stage.addPlot(self._plot)

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.updateData)
        timer.start(5000)
예제 #11
0
        logging.getLogger(name).setLevel(logging.DEBUG)
    app = QApplication(sys.argv)
    grw = InteractiveGRWidget()
    grw.resize(QtCore.QSize(500, 500))
    viewport = [0.1, 0.45, 0.1, 0.88]
    vp2 = [.6, .95, .1, .88]

    x = [-3.3 + t * .1 for t in range(66)]
    y = [t ** 5 - 13 * t ** 3 + 36 * t for t in x]

    n = 100
    pi2_n = 2.*math.pi / n
    x2 = [i * pi2_n for i in range(0, n + 1)]
    y2 = map(lambda xi: math.sin(xi), x2)

    plot = Plot(viewport).addAxes(PlotAxes(viewport).plot(x, y),
                                  PlotAxes(viewport).plot(x2, y2))
    plot.title, plot.subTitle = "foo", "bar"
    plot.xlabel, plot.ylabel = "x", "f(x)"

    plot2 = Plot(vp2).addAxes(PlotAxes(vp2).plot(x2, y2))
    plot2.title, plot2.subTitle = "Title", "Subtitle"
    plot2.xlabel = "x"

    grw.addPlot(plot)
    grw.addPlot(plot2)
    grw.show()
    grw.update()

    sys.exit(app.exec_())
예제 #12
0
파일: qtgrsurface.py 프로젝트: vleo/gr
 def setWindow(self, xmin, xmax, ymin, ymax):
     if xmin < 1:
         xmin = 1
     if ymin < 1:
         ymin = 1
     return PlotAxes.setWindow(self, xmin, xmax, ymin, ymax)
예제 #13
0
import gr
from gr.pygr import Plot, PlotAxes, PlotCurve, Text

tx, ty = 0, -20
x = [-3.3 + t * .1 for t in range(66)]
y = [t**5 - 13 * t**3 + 36 * t for t in x]
txtfmt = "Text drawn on\n(%g, %g) with\nhalign left, valign top"

plt = Plot((.1, .95, .1, .88))
plt.title = "Text on Axes Example"
plt.subTitle = "Show usage of gr.pygr.Text"
plt.xlabel = "x"
plt.ylabel = "y"

curve = PlotCurve(x, y, legend="foo bar")
axes = PlotAxes(plt.viewport).addCurves(curve)
axes.setWindow(-4.0, 4.0, -60.0, 40.0)
text = Text(tx, -ty, txtfmt % (tx, -ty), axes, .02)
plt.addAxes(axes)
text2 = Text(tx, ty, txtfmt % (tx, ty), axes, .02)
tbx, tby = text2.getBoundingBox()

plt.drawGR()
text.drawGR()
text2.drawGR()

# set viewport and window accordingly to draw in NDC space
gr.setviewport(0, axes.sizex, 0, axes.sizey)
gr.setwindow(0, axes.sizex, 0, axes.sizey)
gr.fillarea(tbx, tby)
gr.updatews()
예제 #14
0
파일: plots.py 프로젝트: umithardal/nicos
 def drawGR(self):
     lwidth = gr.inqlinewidth()
     gr.setlinewidth(0.)
     PlotAxes.drawGR(self)
     gr.setlinewidth(lwidth)
예제 #15
0
 def plot(self, *args, **kwargs):
     plot = Plot()
     axes = PlotAxes(plot.viewport)
     axes.plot(*args, **kwargs)
     plot.addAxes(axes)
     return self.addPlot(plot)
예제 #16
0
 def setWindow(self, xmin, xmax, ymin, ymax):
     if ymin < 0:
         ymin = 0
     PlotAxes.setWindow(self, xmin, xmax, ymin, ymax)
예제 #17
0
 def setWindow(self, xmin, xmax, ymin, ymax):
     if xmin < 1:
         xmin = 1
     if ymin < 1:
         ymin = 1
     return PlotAxes.setWindow(self, xmin, xmax, ymin, ymax)
예제 #18
0
파일: textonaxes.py 프로젝트: vleo/gr
from gr.pygr import Plot, PlotAxes, PlotCurve, Text

if __name__ == "__main__":
    tx, ty = 0, -20
    x = [-3.3 + t * 0.1 for t in range(66)]
    y = [t ** 5 - 13 * t ** 3 + 36 * t for t in x]
    txtfmt = "Text drawn on\n(%g, %g) with\nhalign left, valign top"

    plt = Plot((0.1, 0.95, 0.1, 0.88))
    plt.title = "Text on Axes Example"
    plt.subTitle = "Show usage of gr.pygr.Text"
    plt.xlabel = "x"
    plt.ylabel = "y"

    curve = PlotCurve(x, y, legend="foo bar")
    axes = PlotAxes(plt.viewport).addCurves(curve)
    axes.setWindow(-4.0, 4.0, -60.0, 40.0)
    text = Text(tx, -ty, txtfmt % (tx, -ty), axes, 0.02)
    plt.addAxes(axes)
    text2 = Text(tx, ty, txtfmt % (tx, ty), axes, 0.02)
    tbx, tby = text2.getBoundingBox()

    plt.drawGR()
    text.drawGR()
    text2.drawGR()

    # set viewport and window accordingly to draw in NDC space
    gr.setviewport(0, axes.sizex, 0, axes.sizey)
    gr.setwindow(0, axes.sizex, 0, axes.sizey)
    gr.fillarea(tbx, tby)