The draw module provides the basic user interface to the OpenGL rendering capabilities of pyFOrmex.
Warning: the draw module is still subject to regular changes. Therefore, the information given below may not be fully accurate.
) |
question,choices=None,default=None) |
Return answer if accepted or default if rejected. The remaining arguments are passed to the InputDialog getResult method.
question) |
message,actions=['OK']) |
message,actions=['OK']) |
message,actions=['OK']) |
text,type=None,actions=['OK']) |
This can display a large text and will add scrollbars when needed.
filename) |
items,caption=None) |
Create an interactive widget to let the user set the value of some items. Input is a list of input items (basically [key,value] pairs). See the widgets.InputDialog class for complete description of the available input items.
The remaining arguments are keyword arguments that are passed to the InputDialog.getResult method. A timeout (in seconds) can be specified to have the input dialog interrupted automatically.
Return a dictionary with the results: for each input item there is a (key,value) pair. Returns an empty dictionary if the dialog was canceled. Sets the dialog timeout and accepted status in global variables.
) |
) |
cur=None,filter="All files (*.*)",exist=False,multi=False) |
cur is a directory or filename. All the files matching the filter in that directory (or that file's directory) will be shown. If cur is a file, it will be selected as the current filename.
cur=None) |
cur is a directory. All the directories in that directory will initially be shown.
s) |
F,view=None,bbox=None,color='prop',colormap=None,alpha=0.5,mode=None,linewidth=None,shrink=None,marksize=None,wait=True,clear=None,allviews=False) |
The first argument is an object to be drawn. All other arguments are settings that influence how the object is being drawn.
F is either a Formex or a TriSurface object, or a name of such object (global or exported), or a list thereof. If F is a list, the draw() function is called repeatedly with each of ithe items of the list as first argument and with the remaining arguments unchanged.
The remaining arguments are drawing options. If None, they are filled in from the current viewport drawing options.
view is either the name of a defined view or 'last' or None. Predefined views are 'front','back','top','bottom','left','right','iso'. With view=None the camera settings remain unchanged (but might be changed interactively through the user interface). This may make the drawn object out of view! With view='last', the camera angles will be set to the same camera angles as in the last draw operation, undoing any interactive changes. The initial default view is 'front' (looking in the -z direction).
bbox specifies the 3D volume at which the camera will be aimed (using the angles set by view). The camera position wil be set so that the volume comes in view using the current lens (default 45 degrees). bbox is a list of two points or compatible (array with shape (2,3)). Setting the bbox to a volume not enclosing the object may make the object invisible on the canvas. The special value bbox='auto' will use the bounding box of the objects getting drawn (object.bbox()), thus ensuring that the camera will focus on these objects. The special value bbox=None will use the bounding box of the previous drawing operation, thus ensuring that the camera's target volume remains unchanged.
color,colormap,linewidth,alpha,marksize are passed to the creation of the 3D actor.
shrink is a floating point shrink factor that will be applied to object before drawing it.
If the Formex has properties and a color list is specified, then the the properties will be used as an index in the color list and each member will be drawn with the resulting color. If color is one color value, the whole Formex will be drawn with that color. Finally, if color=None is specified, the whole Formex is drawn in black.
Each draw action activates a locking mechanism for the next draw action, which will only be allowed after drawdelay seconds have elapsed. This makes it easier to see subsequent images and is far more elegant that an explicit sleep() operation, because all script processing will continue up to the next drawing instruction. The value of drawdelay is set in the config, or 2 seconds by default. The user can disable the wait cycle for the next draw operation by specifying wait=False. Setting drawdelay=0 will disable the waiting mechanism for all subsequent draw statements (until set >0 again).
d) |
) |
) |
) |
v) |
name,angles=None) |
If no angles are specified, the name should be an existing view, or the predefined value 'last'. If angles are specified, this is equivalent to createView(name,angles) followed by setView(name).
F,factor) |
A shrinked object is one where each element is shrinked with a factor around its own center.
P,v,d=1.0,color='red') |
P,N,size) |
X,M,color='black') |
X is an Coords array. M is a list with the same length as X. The string representation of the marks are drawn at the corresponding 3D coordinate.
F,color='black',trl=None,offset=0) |
Normally, the numbers are drawn at the centroids of the elements. A translation may be given to put the numbers out of the centroids, e.g. to put them in front of the objects to make them visible, or to allow to view a mark at the centroids. If an offset is specified, it is added to the shown numbers.
F,color='black',trl=None) |
Normally, the numbers are drawn at the location of the vertices. A translation may be given to put the numbers out of the location, e.g. to put them in front of the objects to make them visible, or to allow to view a mark at the vertices.
P,text,color='black',font=None,size=None) |
pos,color=None) |
A) |
A) |
itemlist) |
Use the return value from one of the draw... functions to remove the item that was drawn from the canvas. A single item or a list of items may be specified.
object) |
object can be anything having a bbox() method.
The camera is moved with fixed axis directions to a place where the whole object can be viewed using a 45. degrees lens opening. This technique may change in future!
v,wait=False) |
on=None,size=1.0,pos=[0.0,0.0,0.0]) |
If on is True, the axes triade is displayed, if False it is removed. The default (None) toggles between on and off.
text,x,y,adjust='left',font='helvetica',size=14,color=None) |
annot) |
annot) |
decor) |
decor) |
) |
) |
) |
) |
) |
) |
) |
name,angles) |
The angles are (longitude, latitude, twist). If the view name is new, and there is a views toolbar, a view button will be added to it.
bb) |
) |
) |
f) |
color) |
color) |
mode) |
) |
) |
) |
) |
) |
alpha) |
onoff) |
typ,val) |
typ is one of 'ambient','specular','emission','shininess' val is a value between 0.0 and 1.0
i) |
i) |
i) |
i) |
wid) |
) |
This is a low level function not intended for the user.
) |
) |
msg="Use the Step or Continue button to proceed") |
When the pause statement is executed, execution of the pyformex script is suspended until some external event forces it to proceed again. Clicking the STEP or CONTINUE button will produce such an event.
) |
A step is a set of instructions until the next draw operation. If a script is running, this just releases the draw lock. Else, it starts the script in step mode.
) |
i) |
timeout=None) |
mode=0) |
This is the only way to exit the sleep() function. Default is to wake up from the current sleep. A mode > 0 forces wakeup for longer period.
) |
) |
nvps=None,ncols=None,nrows=None) |
) |
) |
vp,tovp) |
Both vp and tovp should be numbers of viewports.
n) |
) |
path='flypath',upvector=[0.,1.,0.],sleeptime=None) |
K) |
K is Collection of actors as returned by the pick() method. colormap is a list of two colors, for the actors not in, resp. in the Collection K.
K) |
K is Collection of actor elements as returned by the pick() method. colormap is a list of two colors, for the elements not in, resp. in the Collection K.
K) |
K is Collection of TriSurface actor edges as returned by the pick() method. colormap is a list of two colors, for the edges not in, resp. in the Collection K.
K) |
K is Collection of actor elements as returned by the pick() method.
K) |
K is a Collection of actor elements, where each actor element is connected to a collection of property numbers, as returned by the partitionCollection() method.
i) |
mode='actor',single=False,func=None,filtr=None) |
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.
single=False,func=None,filtr=None) |
single=False,func=None,filtr=None) |
single=False,func=None,filtr=None) |
single=False,func=None,filtr=None) |
K,mode) |
K is usually the return value of a pick operation, but might also be set by the user. mode is one of the pick modes.
marks=None) |
i) |
mode='line',single=False,func=None) |
See viewport.py for more details. This function differs in that it provides default displaying during the drawing operation and a button to stop the drawing operation.
The drawing can be edited using the methods 'undo', 'clear' and 'close', which are presented in a combobox.
L) |
L is usually the return value of an interactive draw operation, but might also be set by the user.
mode=True) |
mode=True) |