Beispiel #1
0
 def __init__(self,
              parent=None,
              designMode=False,
              taurusparam=None,
              toolbar=True,
              **kwargs):
     '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters'''
     CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs)
     TaurusBaseWidget.__init__(self, 'TaurusTrendDialog')
     self.deprecated(rel='4.1',
                     dep='TaurusTrendDialog',
                     alt='TaurusTrend / taurus tpg trend launcher')
     self.setWindowFlags(Qt.Qt.Widget)
     self._designMode = designMode
     self._modelNames = CaselessList()
     from guiqwt.styles import style_generator
     self.style = style_generator()
     self.setSupportedMimeTypes(
         [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE])
     from taurus.qt.qtgui.extra_guiqwt.tools import TaurusModelChooserTool, AutoScrollTool
     self.add_tool(TaurusModelChooserTool, singleModel=False)
     self.add_tool(AutoScrollTool)
     self.setModifiableByUser(self._modifiableByUser)
     if taurusparam is None:
         taurusparam = TaurusTrendParam()
     self.defaultTaurusparam = taurusparam
     self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
     self.registerConfigDelegate(self.get_tool(AutoScrollTool))
Beispiel #2
0
    def setModel(self, modelNames):
        '''Removes current TaurusCurveItems and adds new ones.

        :param modelNames: (sequence<str> or str) the names of the models to be
                           plotted. For convenience, a string is also accepted
                           (instead of a sequence of strings), in which case the
                           string will be internally converted to a sequence by
                           splitting it on whitespace and commas. Each model can
                           optionally be composed of two parts, separated by "|"
                           indicating X and Y components for the curve. If only
                           one part is given, it is used for Y and X is
                           automatically generated as an index.

        .. seealso:: :meth:`addModels`
        '''

        plot = self.get_plot()
        # delete current TaurusCurveItems
        taurusCurveItems = [
            item for item in plot.get_public_items()
            if isinstance(item, TaurusCurveItem)
        ]
        plot.del_items(taurusCurveItems)
        self._modelNames = CaselessList()
        # add new TaurusCurveItems
        self.addModels(modelNames)
Beispiel #3
0
 def addModels(self, models):
     ''' Add given models to the selected models list'''
     if len(models) == 0:
         models = ['']
     if self.isSingleModelMode():
         self.resetListedModels()
     if self._allowDuplicates:
         self.list.addModels(models)
     else:
         listedmodels = CaselessList(self.getListedModels())
         for m in models:
             if m not in listedmodels:
                 listedmodels.append(m)
                 self.list.addModels([m])
Beispiel #4
0
 def __init__(self, parent=None, designMode=False, toolbar=True, **kwargs):
     '''see :class:`guiqwt.plot.CurveDialog` for other valid initialization parameters'''
     CurveDialog.__init__(self, parent=parent, toolbar=toolbar, **kwargs)
     TaurusBaseWidget.__init__(self, 'TaurusCurveDialog')
     self.setWindowFlags(Qt.Qt.Widget)
     self._designMode = designMode
     self._modelNames = CaselessList()
     from guiqwt.styles import style_generator
     self.style = style_generator()
     self.setSupportedMimeTypes(
         [TAURUS_MODEL_LIST_MIME_TYPE, TAURUS_ATTR_MIME_TYPE])
     from taurus.qt.qtgui.extra_guiqwt.tools import TaurusCurveChooserTool
     self.add_tool(TaurusCurveChooserTool)
     self.setModifiableByUser(self._modifiableByUser)
     self.setContextMenuPolicy(Qt.Qt.CustomContextMenu)
Beispiel #5
0
 def __init__(self, stream, cols=None, number_fmt='%8.4f', col_width=8,
              col_sep='  ', output_block=False, **pars):
     DataRecorder.__init__(self, **pars)
     self._stream = weakref.ref(stream)
     if not number_fmt.startswith('%'):
         number_fmt = '%%s' % number_fmt
     self._number_fmt = number_fmt
     self._col_sep = col_sep
     self._col_width = col_width
     if isinstance(cols, collections.Sequence) and \
             not isinstance(cols, str):
         cols = CaselessList(cols)
     elif isinstance(cols, numbers.Number):
         cols = cols
     else:
         cols = None
     self._columns = cols
     self._output_block = output_block
Beispiel #6
0
 def __init__(self, stream, cols=None, number_fmt='%8.4f', col_width=8,
              col_sep='  ', output_block=False, **pars):
     DataRecorder.__init__(self, **pars)
     self._stream = stream
     if not number_fmt.startswith('%'):
         number_fmt = '%%s' % number_fmt
     self._number_fmt = number_fmt
     self._col_sep = col_sep
     self._col_width = col_width
     if operator.isSequenceType(cols) and \
             not isinstance(cols, (str, unicode)):
         cols = CaselessList(cols)
     elif operator.isNumberType(cols):
         cols = cols
     else:
         cols = None
     self._columns = cols
     self._output_block = output_block
Beispiel #7
0
    def setModel(self, modelNames):
        '''Removes current TaurusCurveItems and adds new ones.

        :param modelNames: (sequence<str> or str) the names of the models to be
                           plotted. For convenience, a string is also accepted
                           (instead of a sequence of strings), in which case the
                           string will be internally converted to a sequence by
                           splitting it on whitespace and commas.

        .. seealso:: :meth:`addModels`
        '''

        plot = self.get_plot()
        # delete current TaurusCurveItems
        taurusTrendItems = self.getTaurusTrendItems()
        plot.del_items(taurusTrendItems)
        self._modelNames = CaselessList()
        # add new TaurusCurveItems
        self.addModels(modelNames)
Beispiel #8
0
    def onExpConfChanged(self, expconf):
        '''
        Slot to be called when experimental configuration changes. It should
        remove the temporary panels and create the new ones needed.

        :param expconf: (dict) An Experiment Description dictionary. See
                        :meth:`sardana.taurus.qt.qtcore.tango.sardana.
                        QDoor.getExperimentDescription`
                        for more details
        '''
        if expconf['ActiveMntGrp'] is None:
            return
        if expconf['ActiveMntGrp'] not in expconf['MntGrpConfigs'].keys():
            self.warning("ActiveMntGrp '%s' is not defined" %
                         expconf['ActiveMntGrp'])
            return
        mgconfig = expconf['MntGrpConfigs'][expconf['ActiveMntGrp']]
        channels = dict(getChannelConfigs(mgconfig, sort=False))

        # classify by type of plot:
        trends1d = {}
        trends2d = {}
        plots1d = {}
        images = {}

        for chname, chdata in channels.items():
            ptype = chdata['plot_type']
            if ptype == PlotType.No:
                continue
            elif ptype == PlotType.Spectrum:
                axes = tuple(chdata['plot_axes'])
                # TODO: get default value from the channel.
                ndim = chdata.get('ndim', 0)
                if ndim == 0:  # this is a trend
                    if axes in trends1d:
                        trends1d[axes].append(chname)
                    else:
                        trends1d[axes] = CaselessList([chname])
                elif ndim == 1:  # a 1D plot (e.g. a spectrum)
                    pass  # TODO: implement
                else:
                    self.warning('Cannot create plot for %s', chname)

            elif ptype == PlotType.Image:
                axes = tuple(chdata['plot_axes'])
                # TODO: get default value from the channel.
                ndim = chdata.get('ndim', 1)
                if ndim == 0:  # a mesh-like plot?
                    pass  # TODO implement
                elif ndim == 1:  # a 2D trend
                    if axes in trends2d:
                        trends2d[axes].append(chname)
                    else:
                        trends2d[axes] = CaselessList([chname])
                elif ndim == 2:  # a 2D plot (e.g. an image)
                    pass  # TODO: implement
                else:
                    self.warning('Cannot create plot for %s', chname)

        new1d, removed1d = self._updateTemporaryTrends1D(trends1d)
        self.newShortMessage.emit("Changed panels (%i new, %i removed)" %
                                  (len(new1d), len(removed1d)))
Beispiel #9
0
 def setImageAttrName(self, attr_name):
     self._image_attr_names = CaselessList()
     self.addImageAttrName(attr_name)