示例#1
0
    def setModel(self, model):
        TaurusBaseWidget.setModel(self, model)
        plot = self.get_plot()

        if self.image is not None:
            self.disconnect(self.image.getSignaller(),
                            Qt.SIGNAL("dataChanged"),
                            self.update_cross_sections)
            plot.del_item(self.image)
            del self.image

        self.unregisterEvents()

        if model is None:
            return

        beamviewer = self.getPluginDevice('beamviewer')
        if not beamviewer:
            return

        image_attr = beamviewer.getAttribute('VideoImage')

        param = ImageParam()
        param.interpolation = 0  # None (nearest pixel)

        self.image = LimaVideoImageItem(param)
        self.image.setModel(image_attr)

        self.connect(self.image.getSignaller(), Qt.SIGNAL("dataChanged"),
                     self.update_cross_sections)

        plot.add_item(self.image)
        self.registerEvents()
示例#2
0
def setup_pressure_trend(tt, log=True, length=12 * 3600):
    print '*' * 80
    print 'in setup_pressure_trend(%s,length=%s s)' % (tt, length)
    from PyQt4 import Qwt5
    try:
        #n,w = str(qtw.tabText(qtw.count()-1)),qtw.widget(qtw.count()-1)
        #qtw.insertTab(0,w,n)
        tt.setXDynScale(True)
        xMax = time.time()  #tt.axisScaleDiv(Qwt5.QwtPlot.xBottom).upperBound()
        #xMin = tt.axisScaleDiv(Qwt5.QwtPlot.xBottom).lowerBound()
        rg = length  #abs(self.str2deltatime(str(self.ui.xRangeCB.currentText())))
        xMin = xMax - rg
        tt.setAxisScale(Qwt5.QwtPlot.xBottom, xMin, xMax)
        if log:
            tt.setAxisScaleType(Qwt5.QwtPlot.yLeft,
                                Qwt5.QwtScaleTransformation.Log10)
            #tt.setAxisScale(Qwt5.QwtPlot.yLeft,1e-11,1e-2)
        tt.setUseArchiving(False)
        tt.setModelInConfig(False)
        tt.disconnect(tt.axisWidget(tt.xBottom),
                      Qt.SIGNAL("scaleDivChanged ()"), tt._scaleChangeWarning)
        #tt.setCurvesYAxis([tcs],tt.yRight)
        #: Disabling loading of configuration from file; to avoid a faulty setup to continuously crash the application.
        setattr(tt, 'applyConfig', (lambda *k, **kw: None))
    except:
        print 'Exception in set_pressure_trend(%s)' % tt
        print traceback.format_exc()
    print '*' * 80
示例#3
0
 def on_click(self, kind, name):
     """The default behavior is to mark a clicked device and to zoom to a clicked section.
     Override this function if you need something else."""
     if kind == "device":
         self.select_devices([name])
         self.emit(Qt.SIGNAL("graphicItemSelected(QString)"), name)
     elif kind == "section":
         self.zoom_to_section(name)
示例#4
0
 def setModel(self, model, action):
     #print 'DomainButton.setModel(%s,%s)'%(model,action)
     self._model = model
     self._led.setModel(model)
     if not self._label.text(): self.setLabel(model.split('/')[0])
     self._cmd = action  #action.split()
     self._action = taurus.qt.qtgui.util.ExternalAppAction(
         cmdargs=self._cmd)
     self.connect(self, Qt.SIGNAL("pressed()"), self.show)
    def contextMenuEvent(self, event):
        action_display_current = Qt.QAction(self)
        action_display_current.setText('Display Current')
        action_display_current.setCheckable(True)
        action_display_current.setChecked(
            self.taurusValueBuddy().getDisplayAttr() == 'current')
        slot = partial(self.taurusValueBuddy().setDisplayAttr, 'current')
        self.connect(action_display_current, Qt.SIGNAL('toggled(bool)'), slot)

        action_display_pressure = Qt.QAction(self)
        action_display_pressure.setText('Display Pressure')
        action_display_pressure.setCheckable(True)
        action_display_pressure.setChecked(
            self.taurusValueBuddy().getDisplayAttr() == 'pressure')
        slot = partial(self.taurusValueBuddy().setDisplayAttr, 'pressure')
        self.connect(action_display_pressure, Qt.SIGNAL('toggled(bool)'), slot)

        action_display_voltage = Qt.QAction(self)
        action_display_voltage.setText('Display Voltage')
        action_display_voltage.setCheckable(True)
        action_display_voltage.setChecked(
            self.taurusValueBuddy().getDisplayAttr() == 'voltage')
        slot = partial(self.taurusValueBuddy().setDisplayAttr, 'voltage')
        self.connect(action_display_voltage, Qt.SIGNAL('toggled(bool)'), slot)

        action_device_panel = Qt.QAction(self)
        action_device_panel.setText('Show Device Panel')
        self.connect(action_device_panel, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().showDevicePanel)

        action_start = Qt.QAction(self)
        action_start.setText('Start')
        self.connect(action_start, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().start)

        action_stop = Qt.QAction(self)
        action_stop.setText('Stop')
        self.connect(action_stop, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().stop)

        action_reconnect = Qt.QAction(self)
        action_reconnect.setText('Reconnect')
        self.connect(action_reconnect, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().reconnect)

        menu = Qt.QMenu(self)
        menu.addAction(action_device_panel)
        menu.addSeparator()
        menu.addAction(action_display_pressure)
        menu.addAction(action_display_current)
        menu.addAction(action_display_voltage)
        menu.addSeparator()
        menu.addAction(action_start)
        menu.addAction(action_stop)
        menu.addSeparator()
        menu.addAction(action_reconnect)
        menu.exec_(event.globalPos())
        event.accept()
    def contextMenuEvent(self, event):
        action_device_panel = Qt.QAction(self)
        action_device_panel.setText('Show Device Panel')
        self.connect(action_device_panel, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().showDevicePanel)

        action_move_in = Qt.QAction(self)
        action_move_in.setText('Move In')
        self.connect(action_move_in, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().moveIn)

        action_move_out = Qt.QAction(self)
        action_move_out.setText('Move Out')
        self.connect(action_move_out, Qt.SIGNAL('triggered()'),
                     self.taurusValueBuddy().moveOut)

        menu = Qt.QMenu(self)
        menu.addAction(action_device_panel)
        menu.addSeparator()
        menu.addAction(action_move_in)
        menu.addAction(action_move_out)
        menu.exec_(event.globalPos())
        event.accept()
示例#7
0
 def __init__(self, preffix='', suffix='', labels=False, parent=None):
     TaurusWidget.__init__(self, parent)
     self.preffix = preffix
     self.suffix = suffix
     self.labels = labels
     if preffix or suffix:
         self.setWindowTitle('%s ... %s' % (preffix, suffix))
     self.setLayout(Qt.QVBoxLayout())
     self.bar = Qt.QWidget(self)
     self.search = Qt.QLineEdit()
     self.button = Qt.QPushButton('Load')
     self.connect(self.button, Qt.SIGNAL("pressed()"), self.apply_search)
     self.bar.setLayout(Qt.QHBoxLayout())
     self.bar.layout().addWidget(self.search)
     self.bar.layout().addWidget(self.button)
     self.layout().addWidget(self.bar)
     self.form = TaurusForm(self)
     self.layout().addWidget(self.form)
示例#8
0
        if DEVICE and DEVICE.lower() not in DEVICES:
            DEVICES.append(DEVICE.lower())
        if DEVICES and not DEVICE:
            DEVICE = DEVICES[0]
    except:
        traceback.print_exc()

    if any((USE_DEVICE_TREE, JDRAW_FILE, len(DEVICES) > 1)):
        print('\t>>> Loading Tree panel(%s) ...' % (len(DEVICES)))
        from tree import *
        try:
            # The lastWindowClosed() signal will close all opened widgets and dialogs on application exit
            assert Qt.QApplication.instance(), 'QApplication not running!'
            panelclass = VaccaPanel  #VaccaAction(default=PANEL_COMMAND)
            Qt.QObject.connect(Qt.QApplication.instance(),
                               Qt.SIGNAL("lastWindowClosed()"),
                               panelclass.kill)
            VaccaTree.setDefaultPanelClass(panelclass)
        except:
            print("Cannot instance Device Tree")
        logger = fn.Logger()
        printf = logger.info

        def filterMatching(a, dct=AttributeFilters, p=printf):
            match = False
            if a.lower().endswith('/state'): return True
            elif a.lower().endswith('/status'): return False
            for k, l in dct.items():
                if fn.searchCl(k, a.rsplit('/', 1)[0]):
                    for t in l:  #T is every declared Tab for panel (TabName,[attrlist]); or just attrname when not using tabs
                        p((k, t))
示例#9
0
def setup_profile_plot(tp, composer, picker=True):
    #,gauges,pumps,tcs,positions=None,labels=None):
    """ This method configures a tau plot to show pressure/temperature profiles """
    tp.info('setup_profile_plot(%s,%s)' % (composer, picker))
    #tp.setModel('BO/VC/Composer/IPAxxis|BO/VC/Composer/IPPressures')
    #tp.setModel('BO/VC/Composer/CCGAxxis|BO/VC/Composer/CCGPressures,BO/VC/Composer/IPPressures')
    #positions = [0,17,31,33,49,63,80,94,111,114,116,122]
    #labels=['Q1A','Q1B','Q1LTB','Q2A','Q2B','Q3A','Q3B','Q4A','Q4B','Q4BT','Q4C','Q4D+RF']
    gauges = '%s/CCGAxxis|%s/CCGPressures' % (composer, composer)
    pumps = '%s/IPAxxis|%s/IPPressures' % (composer, composer)
    tcs = '%s/ThermoAxxis|%s/Thermocouples' % (composer, composer)
    positions = '%s/AxxisPositions' % composer
    labels = '%s/AxxisLabels' % composer

    pumps, gauges, tcs = [str(s).lower() for s in (pumps, gauges, tcs)]
    tp.setModelInConfig(False)
    tp.setModifiableByUser(False)
    tp.setModel(pumps)
    tp.addModels([tcs])
    tcs = tcs.split('|')[-1]
    tp.setCurvesYAxis([tcs], tp.yRight)
    tp.addModels([gauges])
    gauges = gauges.split('|')[-1]
    Curves = {}
    for cname in (pumps, gauges, tcs):
        tp.info('set curve %s' % cname)
        try:
            Curves[cname] = tp.curves[cname]
        except:
            Curves[cname] = tp.curves[cname.split('|')[-1]]

    if positions and labels:
        tp.info('Setting CustomXLabels ...')
        try:
            tp._positions = list(
                int(i) for i in taurus.Attribute(positions).read().value)
            tp._labels = list(
                str(i) for i in taurus.Attribute(labels).read().value)
            tp.setAxisCustomLabels(Qwt5.QwtPlot.xBottom,
                                   zip(tp._positions, tp._labels), 60)
        except:
            print 'Unable to read pressure profile labels'
            tp._positions = []
            tp._labels = []
            #print traceback.format_exc()

    for cname, color, width in [(gauges, Qt.Qt.blue, 3),
                                (pumps, Qt.Qt.magenta, 1),
                                (tcs, Qt.Qt.red, 2)]:
        cap = Curves[cname].getAppearanceProperties()
        cap.lColor = color
        cap.lWidth = width
        tp.setCurveAppearanceProperties({Curves[cname].getCurveName(): cap})

    Curves[gauges].setSymbol(
        Qwt5.QwtSymbol(Qwt5.QwtSymbol.Diamond, Qt.QBrush(Qt.Qt.yellow),
                       Qt.QPen(Qt.Qt.green), Qt.QSize(7, 7)))
    #f1 = Qwt5.QwtSplineCurveFitter()
    #f1.setSplineSize(2000)
    #Curves[pumps].setCurveFitter(f1)
    #Curves[pumps].setCurveAttribute(Curves[pumps].Fitted,True)
    tp.enableAxis(tp.yRight)
    tp.setAxisScaleType(Qwt5.QwtPlot.yLeft, Qwt5.QwtScaleTransformation.Log10)
    #tp.setAxisScale(Qwt5.QwtPlot.yLeft,1e-11,1e-4)
    tp.setCanvasBackground(Qt.Qt.white)
    tp.toggleDataInspectorMode(True)
    tp.showMaxPeaks(True)
    Curves[pumps].showMaxPeak(False)
    tp.setAllowZoomers(False)
    tp.toggleDataInspectorMode(True)

    if picker:
        tp.info('setting Picker ...')
        tp.disconnect(tp._pointPicker, Qt.SIGNAL('selected(QwtPolygon)'),
                      tp.pickDataPoint)
        tp.connect(tp._pointPicker,
                   Qt.SIGNAL('selected(QwtPolygon)'),
                   lambda pos, s=tp: pickPlotPoint(
                       s,
                       pos,
                       xlabels=(zip(tp._positions, tp._labels)
                                if tp._positions and tp._labels else None)))

    tp._profile_loaded = True
    return tp