Beispiel #1
0
    def __init__(self, param, size, parent=None):
        """ QParameterWidget(param: ParameterInfo, size: int, parent: QWidget)
                             -> QParameterWidget
        """
        QtGui.QWidget.__init__(self, parent)
        self.param = param
        self.prevWidget = 0
        
        hLayout = QtGui.QHBoxLayout(self)
        hLayout.setMargin(0)
        hLayout.setSpacing(0)        
        self.setLayout(hLayout)

        hLayout.addSpacing(5+16+5)

        self.label = QtGui.QLabel(param.type)
        self.label.setFixedWidth(50)
        hLayout.addWidget(self.label)

        module = registry.get_module_by_name(param.identifier,
                                             param.type,
                                             param.namespace)
        assert issubclass(module, Constant)

        self.editor = QParameterEditor(param, size)
        hLayout.addWidget(self.editor)

        self.selector = QDimensionSelector()
        self.connect(self.selector.radioButtons[4],
                     QtCore.SIGNAL('toggled(bool)'),
                     self.disableParameter)
        hLayout.addWidget(self.selector)
    def get_values(self, count):
        """ get_values(count) -> []        
        Convert the list values into a list

        count should be an integer with the expected size of the list (given
        by the dimension 'size' in the exploration)
        
        """

        param_info = self._param_info
        module = registry.get_module_by_name(param_info.identifier,
                                             param_info.type,
                                             param_info.namespace)
        result = [module.translate_to_python(m)
                  for m in self._str_values]
        if len(result) != count:
            show_warning('Inconsistent Size',
                         'One of the <i>%s</i>\'s list '
                         'interpolated '
                         'values has a different '
                         'size from the step count. '
                         'Expected %d, got %d instead. '
                         'Parameter Exploration aborted.'
                         % (self.type, count, len(result)))
            return None
        return result
 def get_values(self, count):
     """ get_values() -> []        
     Convert the user define function into a list. Size specifies the size
     request.
     
     """
     param_info = self._param_info
     module = registry.get_module_by_name(param_info.identifier,
                                          param_info.type,
                                          param_info.namespace)
     def get():
         import code
         values = []
         d = {}
         try:
             exec(self.function) in {}, d
         except Exception, e:
             return [module.default_value] * count
         def evaluate(i):
             try:
                 v = d['value'](i)
                 if v == None:
                     return module.default_value
                 return v
             except Exception, e:
                 return str(e)
Beispiel #4
0
def registerSelf():
    """ registerSelf() -> None
    Registry module with the registry
    """
    identifier = "edu.utah.sci.vistrails.scirun"
    registerRender()
    registry.add_module(ViewerCell)
    registry.add_input_port(ViewerCell, "Location", CellLocation)
    registry.add_input_port(
        ViewerCell, "Scene Graph",
        registry.get_module_by_name(identifier, 'Geometry'), 'Scene Graph')
Beispiel #5
0
def registerSelf():
    """ registerSelf() -> None
    Registry module with the registry
    """
    identifier = "edu.utah.sci.vistrails.scirun"
    #    registry.add_module(Render, abstract=True)
    registry.add_module(CM2ViewCell)
    registry.add_input_port(CM2ViewCell, "Location", CellLocation)
    registry.add_input_port(
        CM2ViewCell, "Scene Graph", registry.get_module_by_name(identifier, "Geometry"), "Scene Graph"
    )
Beispiel #6
0
def registerSelf():
    """ registerSelf() -> None
    Registry module with the registry
    """
    identifier = "edu.utah.sci.vistrails.scirun"
    registerRender()
    registry.add_module(ViewerCell)
    registry.add_input_port(ViewerCell, "Location", CellLocation)
    registry.add_input_port(ViewerCell, "Scene Graph",
                            registry.get_module_by_name(identifier,
                                                        'Geometry'),
                            'Scene Graph')
    def value(self):
        """  value() -> any type 
        Returns its strValue as a python type.

        """
        from core.modules.module_registry import registry
        module = registry.get_module_by_name(self.identifier, self.type, 
                                             self.namespace)
        if self.strValue == "":
            self.strValue = module.default_value
            return module.default_value
        return module.translate_to_python(self.strValue)
    def __init__(self, param_info, size, parent=None):
        """ QParameterEditor(param_info: ParameterInfo: str,
                             size: int, parent=None: QWidget) -> QParameterEditor
        Put a stacked widget and a popup button
        
        """
        QtGui.QWidget.__init__(self, parent)
        self._param_info = param_info
        self.type = param_info.type
        self.defaultValue = param_info.value
        
        hLayout = QtGui.QHBoxLayout(self)
        hLayout.setMargin(0)
        hLayout.setSpacing(0)
        self.setLayout(hLayout)

        module = registry.get_module_by_name(param_info.identifier,
                                             param_info.type,
                                             param_info.namespace)

        self.stackedEditors = QtGui.QStackedWidget()
        self.stackedEditors.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                          QtGui.QSizePolicy.Maximum)
        self._exploration_widgets = []

        def add_exploration_widget(wd):
            self._exploration_widgets.append(wd)
            self.stackedEditors.addWidget(wd)
        
        if hasattr(module, 'parameter_exploration_widgets'):
            for widget_class in module.parameter_exploration_widgets:
                new_widget = widget_class(param_info, size)
                add_exploration_widget(new_widget)

        add_exploration_widget(QListInterpolationEditor(param_info, size))
        add_exploration_widget(QUserFunctionEditor(param_info, size))

        hLayout.addWidget(self.stackedEditors)

        selector = QParameterEditorSelector(param_info, self._exploration_widgets)
        self.connect(selector.actionGroup,
                     QtCore.SIGNAL('triggered(QAction*)'),
                     self.changeInterpolator)
        hLayout.addWidget(selector)
        selector.initAction()