Example #1
0
class CorrelationParameterTree(ParameterTree):
    """Parameter tree that captures XPCS correlation adjustable parameters.

    Starting point to attempt to allow selecting an 'algorithm'
    and then repopulating the parameter tree accordingly.
    Any visible input parameters in the associated workflow will be adjustable here.
    The workflow can also be run here.
    """
    def __init__(self, parent=None, showHeader=True, processor: Callable[[], None] = None):
        """Create the parameter tree, optionally providing a workflow.

        When a workflow is provided,

        Parameters
        ----------
        parent
            See pyqtgraph.ParameterTree.__init__.
        showHeader
            See pyqtgraph.ParameterTree.__init__.
        processor
            If provided, creates a 'Run' button that is connected to the callable passed (default is None).
            For example, this callable could grab the necessary data to pass into a workflow, then execute it.
        """
        super(CorrelationParameterTree, self).__init__(parent, showHeader)
        self._paramName = 'Algorithm'
        self._name = 'Correlation Processor'
        self.processor = processor
        self.param = None
        self.workflow = None
        self._workflows = dict()

        # List of algorithms available
        # key   -> algorithm name (workflow.name)
        # value -> algorithm callable (workflow)
        self.listParameter = ListParameter(name=self._paramName,
                                           values={'':''},
                                           value='')

        self.param = Parameter(name=self._name)
        self.param.addChild(self.listParameter)
        self.setParameters(self.param, showTop=False)

        if self.processor:
            # Button added separately since update removes then adds all children in self.param
            self.processButton = ActionParameter(name="Run")
            self.processButton.sigActivated.connect(self.processor)
            self.addParameters(self.processButton)

    def update(self, *_):
        """Update the parameter tree according to which algorithm (workflow) is selected."""
        # for child in self.param.children():  # this doesn't seem to work...
        for child in self.param.childs[1:]:
            child.remove()

        # Based on current workflow (listParameter value), re-populate the tree.
        self.workflow = self._workflows.get(self.listParameter.value().name, self.listParameter.value()())
        self._workflows[self.workflow.name] = self.workflow
        for operation in self.workflow.operations:
            self.param.addChild(Parameter(name=operation.name, type='group', children=operation.as_parameter()))
Example #2
0
    def __init__(self, *args, **kwargs):
        super(XPCSProcessor, self).__init__()
        self._paramName = 'Algorithm'
        self._name = 'XPCS Processor'
        self.workflow = None
        self.param = None
        self._workflows = dict()

        self.listParameter = ListParameter(name=self._paramName,
                                           values={'': ''},
                                           value='')

        self.param = Parameter(children=[self.listParameter], name=self._name)
        self.setParameters(self.param, showTop=False)
    def __init__(self, **opts):
        LParameter.__init__(self, **opts)
        opts = self.opts
        fd = self.fieldDescriptor

        limits = OrderedDict()
        if not fd.has_default_value:
            limits['None'] = -1
            opts['default'] = -1
        else:
            opts['default'] = fd.default_value
        for value in fd.enum_type.values:
            limits[value.name] = value.number
        opts['limits'] = limits

        ListParameter.__init__(self, **opts)
Example #4
0
class XPCSProcessor(ParameterTree):
    def __init__(self, *args, **kwargs):
        super(XPCSProcessor, self).__init__()
        self._paramName = 'Algorithm'
        self._name = 'XPCS Processor'
        self.workflow = None
        self.param = None
        self._workflows = dict()

        self.listParameter = ListParameter(name=self._paramName,
                                           values={'': ''},
                                           value='')

        self.param = Parameter(children=[self.listParameter], name=self._name)
        self.setParameters(self.param, showTop=False)

    def update(self, *_):
        for child in self.param.childs[1:]:
            child.remove()

        self.workflow = self._workflows.get(self.listParameter.value().name,
                                            self.listParameter.value()())
        self._workflows[self.workflow.name] = self.workflow
        for process in self.workflow.processes:
            self.param.addChild(process.parameter)
Example #5
0
    def __init__(self, parent=None, showHeader=True, processor: Callable[[], None] = None):
        """Create the parameter tree, optionally providing a workflow.

        When a workflow is provided,

        Parameters
        ----------
        parent
            See pyqtgraph.ParameterTree.__init__.
        showHeader
            See pyqtgraph.ParameterTree.__init__.
        processor
            If provided, creates a 'Run' button that is connected to the callable passed (default is None).
            For example, this callable could grab the necessary data to pass into a workflow, then execute it.
        """
        super(CorrelationParameterTree, self).__init__(parent, showHeader)
        self._paramName = 'Algorithm'
        self._name = 'Correlation Processor'
        self.processor = processor
        self.param = None
        self.workflow = None
        self._workflows = dict()

        # List of algorithms available
        # key   -> algorithm name (workflow.name)
        # value -> algorithm callable (workflow)
        self.listParameter = ListParameter(name=self._paramName,
                                           values={'':''},
                                           value='')

        self.param = Parameter(name=self._name)
        self.param.addChild(self.listParameter)
        self.setParameters(self.param, showTop=False)

        if self.processor:
            # Button added separately since update removes then adds all children in self.param
            self.processButton = ActionParameter(name="Run")
            self.processButton.sigActivated.connect(self.processor)
            self.addParameters(self.processButton)
 def setValue(self, value, blockSignal=None):
     if isinstance(value, Message):
         val = value.number
     else:
         val = value
     ListParameter.setValue(self, val)
Example #7
0
        {'name': 'Restore State', 'type': 'action', 'children': [
            {'name': 'Add missing items', 'type': 'bool', 'value': True},
            {'name': 'Remove extra items', 'type': 'bool', 'value': True},
        ]},
    ]},
    {'name': 'Extra Parameter Options', 'type': 'group', 'children': [
        {'name': 'Read-only', 'type': 'float', 'value': 1.2e6, 'siPrefix': True, 'suffix': 'Hz', 'readonly': True},
        {'name': 'Renamable', 'type': 'float', 'value': 1.2e6, 'siPrefix': True, 'suffix': 'Hz', 'renamable': True},
        {'name': 'Removable', 'type': 'float', 'value': 1.2e6, 'siPrefix': True, 'suffix': 'Hz', 'removable': True},
    ]},
]

params = [
    {'name': 'Visulization', 'type': 'group', 'children': [
        {'name': 'Colormap limits', 'type': 'group', 'children': [
            ListParameter(name='Type', limits=['local', 'global', 'manual']),
            {'name': 'Lock current limits', 'type': 'bool', 'value': False},
            {'name': 'Lower limit', 'type': 'float'},
            {'name': 'Upper limit', 'type': 'float'},
            {'name': 'Threshold', 'type': 'float'},
        ]},
        {'name': 'Cortex', 'type': 'group', 'children':[
            {'name': 'Flattening', 'type': 'int', 'suffix': '%', 'bounds': [0, 100], 'step': 10, 'value': 0},
            ListParameter(name='Hemispheres', limits=['left', 'right', 'both']),
            ListParameter(name='Shader', limits=gl.shaders.ShaderProgram.names.keys(), value='shaded')
        ]},

    ]},
    {'name': 'Signal', 'type': 'group', 'children': [
        {'name': 'Filter bounds', 'type': 'group', 'children': [
            ListParameter(name='Type', limits=['Insantaneous', 'Envelope']),
Example #8
0
    def __init__(self, device, **opts):
        opts['type'] = 'bool'
        opts['value'] = True
        opts['name'] = device
        ALL_DETECTORS = {(getattr(
            detector,
            'aliases',
        ) or [detector.__name__])[0]: detector
                         for detector in detectors.ALL_DETECTORS.values()}
        geometrystyle = ListParameter(name='Geometry Style',
                                      type='list',
                                      values=['Fit2D', 'pyFAI', 'wxDiff'],
                                      value='Fit2D')
        detector = ListParameter(name='Detector',
                                 type='list',
                                 values=ALL_DETECTORS,
                                 value=ALL_DETECTORS['Pilatus 2M'])
        pixelx = SimpleParameter(name='Pixel Size X',
                                 type='float',
                                 value=172.e-6,
                                 siPrefix=True,
                                 suffix='m')
        pixely = SimpleParameter(name='Pixel Size Y',
                                 type='float',
                                 value=172.e-6,
                                 siPrefix=True,
                                 suffix='m')
        binning = SimpleParameter(name='Binning',
                                  type='int',
                                  value=1,
                                  suffix='x',
                                  limits=(1, 100))
        centerx = SimpleParameter(name='Center X',
                                  type='float',
                                  value=0,
                                  suffix=' px',
                                  decimals=4)
        centery = SimpleParameter(name='Center Y',
                                  type='float',
                                  value=0,
                                  suffix=' px',
                                  decimals=4)
        sdd = SimpleParameter(name='Detector Distance',
                              type='float',
                              value=1,
                              siPrefix=True,
                              suffix='m',
                              limits=(0, 1000),
                              step=1e-3)
        tilt = SimpleParameter(name='Detector Tilt',
                               type='float',
                               value=0,
                               siPrefix=False,
                               suffix=u'°')
        rotation = SimpleParameter(name='Detector Rotation',
                                   type='float',
                                   value=0,
                                   siPrefix=False,
                                   suffix=u'°')

        self.children = [
            geometrystyle, detector, pixelx, pixely, binning, centerx, centery,
            sdd, tilt, rotation
        ]
        opts['children'] = self.children
        super(DeviceParameter, self).__init__(**opts)