def convert(_parameter_exploration): _parameter_exploration.__class__ = ParameterExploration for function in _parameter_exploration.db_functions: PEFunction.convert(function) _parameter_exploration.set_defaults()
def getParameterExploration(self): """ getParameterExploration() -> ParameterExploration Generates a ParameterExploration object hat represents the current parameter exploration, and which can be loaded with setParameterExploration(). """ # Construct xml for persisting parameter exploration escape_dict = {"'": "'", '"': '"', '\n': '
'} palette = self.get_palette() id_scope = self.controller.id_scope functions = [] for i in xrange(self.table.layout().count()): pEditor = self.table.layout().itemAt(i).widget() if pEditor and isinstance(pEditor, QParameterSetEditor): function = None firstParam = True for paramWidget in pEditor.paramWidgets: paramInfo = paramWidget.param interpolator = paramWidget.editor.stackedEditors.currentWidget( ) intType = interpolator.exploration_name # Write function tag prior to the first parameter of the function if firstParam: function = PEFunction( id=id_scope.getNewId(PEFunction.vtType), module_id=paramInfo.module_id, port_name=paramInfo.name, is_alias=1 if paramInfo.is_alias else 0) firstParam = False if intType in [ 'Linear Interpolation', 'RGB Interpolation', 'HSV Interpolation' ]: value = '["%s", "%s"]' % ( interpolator.fromEdit.get_value(), interpolator.toEdit.get_value()) elif intType == 'List': value = '%s' % escape(str(interpolator._str_values), escape_dict) elif intType == 'User-defined Function': value = '%s' % escape(interpolator.function, escape_dict) # Write parameter tag param = PEParam(id=id_scope.getNewId(PEParam.vtType), pos=paramInfo.pos, interpolator=intType, value=value, dimension=paramWidget.getDimension()) function.addParameter(param) functions.append(function) pe = ParameterExploration( dims=str(self.table.label.getCounts()), layout=repr(palette.virtual_cell.getConfiguration()[2]), date=current_time(), user=getuser(), functions=functions) return pe
def getParameterExploration(self): """ getParameterExploration() -> ParameterExploration Generates a ParameterExploration object hat represents the current parameter exploration, and which can be loaded with setParameterExploration(). """ # Construct xml for persisting parameter exploration escape_dict = { "'":"'", '"':'"', '\n':'
' } palette = self.get_palette() id_scope = self.controller.id_scope functions = [] for i in xrange(self.table.layout().count()): pEditor = self.table.layout().itemAt(i).widget() if pEditor and isinstance(pEditor, QParameterSetEditor): function = None firstParam = True for paramWidget in pEditor.paramWidgets: paramInfo = paramWidget.param interpolator = paramWidget.editor.stackedEditors.currentWidget() intType = interpolator.exploration_name # Write function tag prior to the first parameter of the function if firstParam: function = PEFunction(id=id_scope.getNewId(PEFunction.vtType), module_id=paramInfo.module_id, port_name=paramInfo.name, is_alias = 1 if paramInfo.is_alias else 0) firstParam = False if intType in ['Linear Interpolation', 'RGB Interpolation', 'HSV Interpolation']: value = '["%s", "%s"]' % (interpolator.fromEdit.get_value(), interpolator.toEdit.get_value()) elif intType == 'List': value = '%s' % escape(str(interpolator._str_values), escape_dict) elif intType == 'User-defined Function': value ='%s' % escape(interpolator.function, escape_dict) else: assert False # Write parameter tag param = PEParam(id=id_scope.getNewId(PEParam.vtType), pos=paramInfo.pos, interpolator=intType, value=value, dimension=paramWidget.getDimension()) function.addParameter(param) functions.append(function) pe = ParameterExploration(dims=str(self.table.label.getCounts()), layout=repr(palette.virtual_cell.getConfiguration()[2]), date=current_time(), user=getuser(), functions=functions) return pe