예제 #1
0
파일: widgets.py 프로젝트: gic888/MIEN
def getArgChoice(fn, data=None, viewer=None, previous={}):
	arglist, defaults, info=mien.dsp.modules.ARGUMENTS[fn]
	if defaults==None:
		defaults=[]
	nnd=len(arglist)-len(defaults)
	d=[]
	if viewer:
		xcd = [x['loc'] for x in viewer.graph.xmarkers]
		xcd.append("%.7g" %  (viewer.graph.limits[0],))
		xcd.append("%.7g" %  (viewer.graph.limits[1],))
		ycd = [x['loc'] for x in viewer.graph.ymarkers]
	else:
		xcd=ycd=None
	for i, arg in enumerate(arglist):
		if previous.has_key(arg):
			preval=previous[arg]
			pvs=True
		else:
			pvs=False
		svl=info['switch values'].get(arg)
		if svl:
			e={"Name":arg,
			"Type":"List",
			"Value":svl}
			if pvs:
				e["Default"]=preval
			d.append(e)
			continue
		e={"Name":arg,
			"Type":str}
		if pvs:
			e['Value']=repr(preval)
		else:	
			defv=None
			if viewer and arg.startswith('select'):
				defv=(None, None, getDefRange(viewer))
			elif arg.startswith('xco') and xcd:
				defv=float(xcd.pop(0))
			elif (arg.startswith('yco') or arg.startswith('thresh') ) and ycd:
				defv=float(ycd.pop(0))
			elif i>=nnd:
				defv=repr(defaults[i-nnd])
			if defv:
				e['Value']=defv
		browse=getArgBrowser(arg, ARGBROWSERS_DSP)
		if not data and not browse in [FileBrowse, browseTree]:
			browse=None
		if not viewer and browse in [XMarkBrowse,YMarkBrowse]:
			browse=None
		if browse:
 			e['DataSet']=data
			e['Viewer']=viewer
			e['Browser']=browse
		if not e["Type"]:
			e["Type"]=='flex'	
		d.append(e)
	return d	
예제 #2
0
파일: widgets.py 프로젝트: gic888/MIEN
def getArgChoice(fn, doc=None, viewer=None, previous={}):
	arglist, defaults, info=mien.spatial.modules.ARGUMENTS[fn]
	if defaults==None:
		defaults=[]
	nnd=len(arglist)-len(defaults)
	d=[]
	if viewer:
		vdef=veiwerDefaults(viewer, arglist)
	else:
		vdef={}
	for i, arg in enumerate(arglist):
		if previous.has_key(arg):
			preval=previous[arg]
			pvs=True
		else:
			pvs=False
		svl=info['switch values'].get(arg)
		if svl:
			e={"Name":arg,
			"Type":"List",
			"Value":svl}
			if pvs:
				e["Default"]=preval
			d.append(e)
			continue
		e={"Name":arg,
			"Type":str}
		if pvs:
			e['Value']=preval
		else:	
			if vdef.has_key(arg):
				e['Value']=vdef[arg]
			elif i>=nnd:
				e['Value']=defaults[i-nnd]
		if type(e.get('Value'))==bool:
			defv=e['Value']
			e["Type"]="List"
			e['Value']=[True, False]
			e['Default']=defv
		browse=getArgBrowser(arg, ARGBROWSERS_SPATIAL)
		if browse:
 			e['Doc']=doc
			e['Viewer']=viewer
			e['Browser']=browse
		d.append(e)
	return d