本文整理汇总了Python中pyformex.message函数的典型用法代码示例。如果您正苦于以下问题:Python message函数的具体用法?Python message怎么用?Python message使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了message函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: pick
def pick(mode='actor',single=False,func=None,filtr=None):
"""Enter interactive picking mode and return selection.
See viewport.py for more details.
This function differs in that it provides default highlighting
during the picking operation, a button to stop the selection operation
If no filter is given, the available filters are presented in a combobox.
"""
if GD.canvas.selection_mode is not None:
warning("You need to finish the previous picking operation first!")
return
pick_buttons = widgets.ButtonBox('Selection:',['Cancel','OK'],[GD.canvas.cancel_selection,GD.canvas.accept_selection])
GD.GUI.statusbar.addWidget(pick_buttons)
if mode == 'element':
filters = selection_filters
else:
filters = selection_filters[:3]
filter_combo = widgets.ComboBox('Filter:',filters,set_selection_filter)
if filtr is not None and filtr in selection_filters:
i = selection_filters.index(filtr)
filter_combo.setIndex(i)
GD.GUI.statusbar.addWidget(filter_combo)
if func is None:
func = highlight_funcs.get(mode,None)
GD.message("Select %s %s" % (filtr,mode))
sel = GD.canvas.pick(mode,single,func,filtr)
GD.GUI.statusbar.removeWidget(pick_buttons)
GD.GUI.statusbar.removeWidget(filter_combo)
return sel
示例2: printSettings
def printSettings(self):
for i,v in enumerate(self.all):
pf.message("""
## VIEWPORTS ##
Viewport %s; Current:%s; Settings:
%s
""" % (i, v == self.current, v.settings))
示例3: create_tetgen_volume
def create_tetgen_volume():
"""Generate a volume tetraeder mesh inside an stl surface."""
types = [ 'STL/OFF Files (*.stl *.off)', 'All Files (*)' ]
fn = askFilename(GD.cfg['workdir'],types)
if os.path.exists(fn):
sta,out = utils.runCommand('tetgen -z %s' % fn)
GD.message(out)
示例4: checkResultsOnServer
def checkResultsOnServer(host=None,userdir=None):
"""Get a list of job results from the cluster.
Specify userdir='bumper/running' to get a list of running jobs.
"""
global the_host,the_userdir,the_jobnames
if host is None or userdir is None:
res = askItems([
('host',None,'select',{'choices':['bumpfs','bumpfs2','other']}),
('other','',{'text':'Other host name'}),
('status',None,'select',{'choices':['results','running','custom']}),
('userdir','bumper/results/',{'text':'Custom user directory'}),
])
if not res:
return
host = res['host']
if host == 'other':
host = res['other']
status = res['status']
if status in ['results','running']:
userdir = 'bumper/%s/' % status
else:
userdir = res['userdir']
jobnames = getSubdirs(host,userdir)
if jobnames:
the_host = host
the_userdir = userdir
the_jobnames = jobnames
else:
the_host = None
the_userdir = None
the_jobnames = None
pf.message(the_jobnames)
示例5: inputControlLines
def inputControlLines():
"""Enter three polyline paths in counterclockwise direction."""
branch = []
BA = []
perspective(False)
for i in range(6):
pf.message("Input Branch %s" % i)
if i % 2 == 0:
coords = None
else:
coords = branch[i-1].coords[-1:]
obj = d2.drawObject2D(mode='polyline',npoints=-1,coords=coords,zvalue=0.)
obj.specular = 0.
pf.canvas.removeHighlight()
## WHY is bbox='last' or zoomAll needed here
if obj is not None:
BA.append(draw(obj,color='blue',flat=True))
zoomAll()
branch.append(obj)
else:
break
if len(branch) == 6:
undraw(BA)
createBranches(branch)
zoomAll()
else:
warning("Incorrect definition of helper lines")
示例6: pick_parts
def pick_parts(self,obj_type,max_objects,store_closest=False):
"""Set the list of actor parts inside the pick_window.
obj_type can be 'element', 'point' or 'edge'(SurfaceActor only)
max_objects specifies the maximum number of objects
The picked object numbers are stored in self.picked.
If store_closest==True, the closest picked object is stored in as a
tuple ( [actor,object] ,distance) in self.picked_closest
"""
self.picked = []
if max_objects <= 0:
GD.message("No such objects to be picked!")
return
self.camera.loadProjection(pick=self.pick_window)
self.camera.loadMatrix()
stackdepth = 2
selbuf = GL.glSelectBuffer(max_objects*(3+stackdepth))
GL.glRenderMode(GL.GL_SELECT)
GL.glInitNames()
for i,a in enumerate(self.actors):
GL.glPushName(i)
a.pickGL(obj_type) # this will push the number of the part
GL.glPopName()
self.picked = []
libGL.glRenderMode(GL.GL_RENDER)
if selbuf[0] > 0:
buf = asarray(selbuf).reshape(-1,3+selbuf[0])
buf = buf[buf[:,0] > 0]
self.picked = buf[:,3:]
if store_closest and len(buf) > 0:
w = buf[:,1].argmin()
self.closest_pick = (self.picked[w], buf[w,1])
示例7: importProject
def importProject():
"""Import an existing project.
Ask the user to select an existing project file, and then import
all or selected data from it into the current project.
"""
proj = openProject(exist=True,access='r')
if proj: # only if non-empty
keys = utils.sortedKeys(proj)
res = draw.askItems(
[ _I('mode',choices=['All','Defined','Undefined','Selected','None'],itemtype='radio'),
_I('selected',choices=keys,itemtype='list'),
],
caption='Select variables to import',
)
if res:
mode = res['mode'][0]
if mode == 'A':
pass
elif mode == 'D':
proj = utils.selectDict(proj,pf.PF)
elif mode == 'U':
proj = utils.removeDict(proj,pf.PF)
elif mode == 'S':
proj = utils.selectDict(proj,res['selected'])
elif mode == 'N':
return
pf.message("Importing symbols: %s" % utils.sortedKeys(proj))
pf.PF.update(proj)
listProject()
示例8: detect
def detect(trypaths=None):
"""Check if we have calpy and if so, add its path to sys.path."""
global calpy_path
calpy = utils.checkExternal('calpy')
if not calpy:
return
pf.message("You have calpy version %s" % calpy)
path = ''
calpy = calpy.split('-')[0] # trim the version trailer
if utils.checkVersion('calpy','0.3.4-rev3',external=True) >= 0:
sta,out = utils.runCommand('calpy --whereami')
if not sta:
path = out
pf.debug("I found calpy in %s" % path)
if not path:
if trypaths is None:
trypaths = [ '/usr/local/lib', '/usr/local' ]
for p in trypaths:
path = '%s/calpy-%s' % (p,calpy)
if os.path.exists(path):
pf.debug('path exists: %s' % path)
break
else:
pf.debug('path does not exist: %s' % path)
path = ''
if path:
#path += '/calpy'
pf.message("I found calpy in '%s'" % path)
sys.path.append(path)
calpy_path = path
示例9: write_stl_asc
def write_stl_asc(fn,x):
"""Write a collection of triangles to an ascii .stl file.
Parameters:
- `fn`: file name, by preference ending with '.stl' or '.stla'
- `x`: (ntriangles,3,3) shaped array with the vertices of the
triangles
"""
if not x.shape[1:] == (4,3):
raise ValueError,"Expected an (ntri,4,3) array, got %s" % x.shape
pf.message("Writing ascii STL %s" % fn)
with open(fn,'wb') as fil:
fil.write("solid Created by %s\n" % pf.fullVersion())
for e in x:
fil.write(" facet normal %s %s %s\n" % tuple(e[0]))
fil.write(" outer loop\n")
for p in e[1:]:
fil.write(" vertex %s %s %s\n" % tuple(p))
fil.write(" endloop\n")
fil.write(" endfacet\n")
fil.write("endsolid\n")
pf.message("Finished writing ascii STL, %s bytes" % utils.fileSize(fn))
示例10: write
def write(self,geom,name=None,sep=None):
"""Write any geometry object to the geometry file.
`geom` is one of the Geometry data types of pyFormex or a list
or dict of such objects.
Currently exported geometry objects are
:class:`Coords`, :class:`Formex`, :class:`Mesh`,
:class:`PolyLine`, :class:`BezierSpline`.
The geometry object is written to the file using the specified
separator, or the default.
"""
self.checkWritable()
if isinstance(geom,dict):
for name in geom:
self.write(geom[name],name,sep)
elif isinstance(geom,list):
if name is None:
for obj in geom:
self.write(obj,None,sep)
else:
name = utils.NameSequence(name)
for obj in geom:
self.write(obj,name.next(),sep)
elif hasattr(geom,'write_geom'):
geom.write_geom(self,name,sep)
else:
try:
writefunc = getattr(self,'write'+geom.__class__.__name__)
#print writefunc
writefunc(geom,name,sep)
except:
message("Can not (yet) write objects of type %s to geometry file: skipping" % type(geom))
示例11: clip_surface
def clip_surface():
"""Clip the stl model."""
if not check_surface():
return
itemlist = [['axis',0],['begin',0.0],['end',1.0],['nodes','any']]
res = askItems(itemlist,caption='Clipping Parameters')
if res:
updateGUI()
nodes,elems = PF['old_surface'] = PF['surface']
F = Formex(nodes[elems])
bb = F.bbox()
GD.message("Original bbox: %s" % bb)
xmi = bb[0][0]
xma = bb[1][0]
dx = xma-xmi
axis = int(res[0][1])
xc1 = xmi + float(res[1][1]) * dx
xc2 = xmi + float(res[2][1]) * dx
nodid = res[3][1]
#print(nodid)
clear()
draw(F,color='yellow')
w = F.test(nodes='any',dir=axis,min=xc1,max=xc2)
F = F.clip(w)
draw(F,color='red')
示例12: workHere
def workHere():
"""Change the current working directory to the script's location.
This function is deprecated: use chdir(_file__) instead.
"""
GD.message("workHere is deprecated: use chdir(_file__) instead")
chdir(GD.PF.get("curfile", ""))
示例13: gtsinside
def gtsinside(self,pts,dir=0):
"""_Test whether points are inside the surface.
pts is a plex-1 Formex.
dir is the shooting direction.
Returns a list of point numbers that are inside.
This is not intended to be used directly. Use inside instead
"""
import os
print(os.environ)
S = self.rollAxes(dir)
P = pts.rollAxes(dir)
tmp = utils.tempFile(suffix='.gts').name
tmp1 = utils.tempFile(suffix='.dta').name
tmp2 = utils.tempFile(suffix='.out').name
pf.message("Writing temp file %s" % tmp)
S.write(tmp,'gts')
pf.message("Writing temp file %s" % tmp1)
f = open(tmp1,'w')
P.coords.tofile(f,sep=' ')
f.write('\n')
f.close()
pf.message("Performing inside testing")
cmd = "gtsinside %s %s > %s" % (tmp,tmp1,tmp2)
sta,out = utils.runCommand(cmd)
os.remove(tmp)
os.remove(tmp1)
if sta:
pf.message("An error occurred during the testing.\nSee file %s for more details." % tmp2)
return None
pf.message("Reading results from %s" % tmp2)
ind = fromfile(tmp2,sep=' ',dtype=Int)
return ind
示例14: printBbox
def printBbox(self):
"""Print the bbox of the current selection."""
objects = self.check()
for n,o in zip(self.names,objects):
GD.message("Object %s has bbox %s" % (n,o.bbox()))
if len(self.names) > 1:
GD.message("Overal bbox is %s" % bbox(objects))
示例15: closeProject
def closeProject(save=None,clear=None):
"""Close the current project, saving it or not.
Parameters:
- `save`: None, True or False. Determines whether the project should be
saved prior to closing it. If None, it will be asked from the user.
Note that this parameter is only used for named Projects. Temporary
Projects are never saved implicitely.
- `clear`: None, True or False.
"""
if pf.PF.filename is not None:
if save is None:
save = draw.ack("Save the current project before closing it?")
pf.message("Closing project %s (save=%s)" % (pf.PF.filename,save))
if save:
saveProject()
if pf.PF:
listProject()
if clear is None:
clear = draw.ask("What shall I do with the existing globals?",["Delete","Keep"]) == "Delete"
if clear:
pf.PF.clear()
pf.PF.filename = None
pf.GUI.setcurproj('None')
updateSettings({
'curproj':pf.PF.filename,
},save=True)